Skip to content

Commit 69fb24b

Browse files
author
Juha Heiskanen
committed
Wi-sun address registration and RPL update
Fixed broken negative ARO handler call to RPL RPL new policy for request parent confirmation before send DAO. Moved ARO registartion code inside RPL instance. New solution will trigger NS one by one. Process is a little abit slower but more controlled and failure safe. DHCPv6 address register is triggered now with DHCPv6 status callback only. Change-Id: I36280463738e5349ab9f6bf4dc3863a644537f98
1 parent 9a6e4e0 commit 69fb24b

File tree

16 files changed

+309
-166
lines changed

16 files changed

+309
-166
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
147147
}
148148
if (reason == ADDR_CALLBACK_DAD_COMPLETE) {
149149
//Trig Address Registartion only when Bootstrap is ready
150-
if (interface->nwk_bootstrap_state == ER_BOOTSRAP_DONE || addr->source == ADDR_SOURCE_DHCP) {
151-
ws_bootsrap_event_trig(WS_ADDRESS_ADDED, interface->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, (void *)addr);
150+
if (interface->nwk_bootstrap_state == ER_BOOTSRAP_DONE && addr->source != ADDR_SOURCE_DHCP) {
151+
tr_debug("Address registration %s", trace_ipv6(addr->address));
152+
rpl_control_register_address(interface, addr->address);
152153
}
153154
if (addr_ipv6_scope(addr->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
154155
// at least ula address available inside mesh.
@@ -170,12 +171,10 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
170171
}
171172
}
172173
} else if (reason == ADDR_CALLBACK_TIMER) {
173-
tr_debug("Address Re registration %s", trace_ipv6(addr->address));
174-
175-
if (!interface->ws_info->address_registration_event_active) {
176-
interface->ws_info->address_registration_event_active = true;
177-
tr_info("Register ARO");
178-
ws_bootsrap_event_trig(WS_ADDRESS_ADDED, interface->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
174+
if (addr->source != ADDR_SOURCE_DHCP) {
175+
tr_debug("Address Re registration %s", trace_ipv6(addr->address));
176+
//Register
177+
rpl_control_register_address(interface, addr->address);
179178
}
180179
}
181180
}
@@ -1807,11 +1806,8 @@ static void ws_set_fhss_hop(protocol_interface_info_entry_t *cur)
18071806

18081807
static void ws_address_registration_update(protocol_interface_info_entry_t *interface)
18091808
{
1810-
if (!interface->ws_info->address_registration_event_active) {
1811-
interface->ws_info->address_registration_event_active = true;
1812-
tr_info("RPL parent update ... register ARO");
1813-
ws_bootsrap_event_trig(WS_ADDRESS_ADDED, interface->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
1814-
}
1809+
rpl_control_register_address(interface, NULL);
1810+
tr_info("RPL parent update ... register ARO");
18151811
}
18161812

18171813
static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
@@ -1864,7 +1860,13 @@ static void ws_dhcp_client_global_adress_cb(int8_t interface, uint8_t dhcp_addr[
18641860
(void)prefix;
18651861
(void)interface;
18661862
//TODO add handler for negative status
1867-
tr_debug("DHCPv6 %s status %u", trace_ipv6(dhcp_addr), register_status);
1863+
tr_debug("DHCPv6 %s status %u with link %s", trace_ipv6(prefix), register_status, trace_ipv6(dhcp_addr));
1864+
if (register_status) {
1865+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface);
1866+
if (cur) {
1867+
rpl_control_register_address(cur, prefix);
1868+
}
1869+
}
18681870
}
18691871

18701872

@@ -1936,6 +1938,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
19361938
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, cur);
19371939
// If i am router I Do this
19381940
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);
1941+
rpl_control_request_parent_link_confirmation(true);
19391942

19401943
cur->ws_info->rpl_state = 0xff; // Set invalid state and learn from event
19411944
}
@@ -2287,17 +2290,6 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
22872290
ws_llc_asynch_request(cur, &async_req);
22882291
}
22892292

2290-
static bool ws_bootstrap_address_registration_ongoing(protocol_interface_info_entry_t *cur)
2291-
{
2292-
ns_list_foreach(if_address_entry_t, addr, &cur->ip_addresses) {
2293-
if (addr->addr_reg_pend != 0) {
2294-
return true;
2295-
}
2296-
}
2297-
2298-
return false;
2299-
}
2300-
23012293
static void ws_bootstrap_event_handler(arm_event_s *event)
23022294
{
23032295
ws_bootsrap_event_type_e event_type;
@@ -2421,12 +2413,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
24212413
ws_bootstrap_advertise_start(cur);
24222414
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
24232415
break;
2424-
case WS_ADDRESS_ADDED:
2425-
cur->ws_info->address_registration_event_active = false;
2426-
if (!ws_bootstrap_address_registration_ongoing(cur)) {
2427-
rpl_control_register_address(cur, (if_address_entry_t *) event->data_ptr);
2428-
}
2429-
break;
2416+
24302417
default:
24312418
tr_err("Invalid event received");
24322419
break;

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ typedef enum {
2424
WS_DISCOVERY_START, /**< discovery start*/
2525
WS_CONFIGURATION_START, /**< configuration learn start*/
2626
WS_OPERATION_START, /**< active operation start*/
27-
WS_ROUTING_READY, /**< RPL routing connected to BR*/
28-
WS_ADDRESS_ADDED /**< Address added to IF*/
27+
WS_ROUTING_READY /**< RPL routing connected to BR*/
2928
} ws_bootsrap_event_type_e;
3029

3130
#ifdef HAVE_WS

source/6LoWPAN/ws/ws_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ typedef struct ws_info_s {
7373
uint32_t pan_version_timer; /**< border router version udate timeout */
7474
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
7575
uint8_t gtkhash[32];
76-
bool address_registration_event_active : 1;
7776
bool configuration_learned: 1;
7877
bool trickle_pas_running: 1;
7978
bool trickle_pa_running: 1;

source/Common_Protocols/icmpv6.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,21 @@ void ack_remove_neighbour_cb(struct buffer *buffer_ptr, uint8_t status)
13691369

13701370
}
13711371

1372+
static void icmpv6_aro_cb(buffer_t *buf, uint8_t status)
1373+
{
1374+
uint8_t ll_address[16];
1375+
if (buf->dst_sa.addr_type == ADDR_IPV6) {
1376+
/*Full IPv6 address*/
1377+
memcpy(ll_address, buf->dst_sa.address, 16);
1378+
} else if (buf->dst_sa.addr_type == ADDR_802_15_4_LONG) {
1379+
// Build link local address from long MAC address
1380+
memcpy(ll_address, ADDR_LINK_LOCAL_PREFIX, 8);
1381+
memcpy(ll_address + 8, &buf->dst_sa.address[2], 8);
1382+
ll_address[8] ^= 2;
1383+
}
1384+
rpl_control_address_register_done(buf->interface, ll_address, status);
1385+
}
1386+
13721387
buffer_t *icmpv6_build_ns(protocol_interface_info_entry_t *cur, const uint8_t target_addr[16], const uint8_t *prompting_src_addr, bool unicast, bool unspecified_source, const aro_t *aro)
13731388
{
13741389
if (!cur || addr_is_ipv6_multicast(target_addr)) {
@@ -1444,7 +1459,7 @@ buffer_t *icmpv6_build_ns(protocol_interface_info_entry_t *cur, const uint8_t ta
14441459
/* If ARO Success sending is omitted, MAC ACK is used instead */
14451460
/* Setting callback for receiving ACK from adaptation layer */
14461461
if (aro && cur->ipv6_neighbour_cache.omit_na_aro_success) {
1447-
buf->ack_receive_cb = rpl_control_address_register_done;
1462+
buf->ack_receive_cb = icmpv6_aro_cb;
14481463
}
14491464
}
14501465
if (unicast && (!aro && cur->ipv6_neighbour_cache.omit_na)) {

source/RPL/rpl_control.c

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -171,47 +171,32 @@ void rpl_control_unpublish_address(rpl_domain_t *domain, const uint8_t addr[16])
171171
}
172172
}
173173

174-
static if_address_entry_t *rpl_instance_reg_addr_get(protocol_interface_info_entry_t *interface)
174+
void rpl_control_request_parent_link_confirmation(bool requested)
175175
{
176-
ns_list_foreach(if_address_entry_t, address, &interface->ip_addresses) {
177-
if (!address->addr_reg_done && !addr_is_ipv6_link_local(address->address)) {
178-
return address;
179-
}
180-
}
181-
182-
return NULL;
176+
rpl_policy_set_parent_confirmation_request(requested);
183177
}
184178

185179
/* Send address registration to either specified address, or to non-registered address */
186-
void rpl_control_register_address(protocol_interface_info_entry_t *interface, if_address_entry_t *addr)
180+
void rpl_control_register_address(protocol_interface_info_entry_t *interface, const uint8_t addr[16])
187181
{
188-
if_address_entry_t *reg_addr = addr;
189-
190-
if (!reg_addr) {
191-
reg_addr = rpl_instance_reg_addr_get(interface);
192-
193-
if (!reg_addr) {
194-
return;
195-
}
182+
if (!rpl_policy_parent_confirmation_requested()) {
183+
return;
196184
}
197185
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
198-
rpl_instance_send_address_registration(interface, instance, reg_addr);
186+
rpl_instance_send_address_registration(instance, addr);
199187
}
200188
}
201189

202-
void rpl_control_address_register_done(struct buffer *buf, uint8_t status)
190+
void rpl_control_address_register_done(protocol_interface_info_entry_t *interface, const uint8_t ll_addr[16], uint8_t status)
203191
{
204-
ns_list_foreach(if_address_entry_t, addr, &buf->interface->ip_addresses) {
205-
206-
/* Optimize, ll addresses are not registered anyway.. */
207-
if (!addr->addr_reg_pend) {
208-
continue;
209-
}
192+
if (!rpl_policy_parent_confirmation_requested()) {
193+
return;
194+
}
210195

211-
ns_list_foreach(struct rpl_instance, instance, &buf->interface->rpl_domain->instances) {
212-
if (rpl_instance_address_registration_done(buf->interface, instance, addr, status)) {
213-
return;
214-
}
196+
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
197+
rpl_neighbour_t *neighbour = rpl_lookup_neighbour_by_ll_address(instance, ll_addr, interface->id);
198+
if (neighbour) {
199+
rpl_instance_address_registration_done(interface, instance, neighbour, status);
215200
}
216201
}
217202
}
@@ -226,13 +211,17 @@ bool rpl_control_is_dodag_parent(protocol_interface_info_entry_t *interface, con
226211
}
227212
return false;
228213
}
214+
229215
void rpl_control_neighbor_delete(protocol_interface_info_entry_t *interface, const uint8_t ll_addr[16])
230216
{
231217
// go through instances and delete address.
232218
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
233-
rpl_instance_neighbor_delete(instance, ll_addr);
219+
220+
rpl_neighbour_t *neighbour = rpl_lookup_neighbour_by_ll_address(instance, ll_addr, interface->id);
221+
if (neighbour) {
222+
rpl_delete_neighbour(instance, neighbour);
223+
}
234224
}
235-
return;
236225
}
237226

238227
/* Address changes need to trigger DAO target re-evaluation */

source/RPL/rpl_control.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ void rpl_control_set_callback(rpl_domain_t *domain, rpl_domain_callback_t callba
147147
/* Target publishing */
148148
void rpl_control_publish_host_address(rpl_domain_t *domain, const uint8_t addr[16], uint32_t lifetime);
149149
void rpl_control_unpublish_address(rpl_domain_t *domain, const uint8_t addr[16]);
150-
void rpl_control_register_address(struct protocol_interface_info_entry *interface, if_address_entry_t *addr);
151-
void rpl_control_address_register_done(struct buffer *buf, uint8_t status);
152150
bool rpl_control_is_dodag_parent(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]);
153151
void rpl_control_neighbor_delete(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]);
152+
/* Parent link confirmation API extension */
153+
void rpl_control_request_parent_link_confirmation(bool requested);
154+
void rpl_control_register_address(struct protocol_interface_info_entry *interface, const uint8_t addr[16]);
155+
void rpl_control_address_register_done(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16], uint8_t status);
154156

155157
/* Configure and return the routing lookup predicate for a specified RPL instance ID */
156158
ipv6_route_predicate_fn_t *rpl_control_get_route_predicate(rpl_domain_t *domain, uint8_t instance_id, const uint8_t src[16], const uint8_t dst[16]);
@@ -172,7 +174,7 @@ uint16_t rpl_control_current_rank(const struct rpl_instance *instance);
172174
#define rpl_control_slow_timer(seconds) ((void) 0)
173175
#define rpl_control_remove_domain_from_interface(cur) ((void) 0)
174176
#define rpl_control_register_address(interface, addr) ((void) 0)
175-
#define rpl_control_address_register_done NULL
177+
#define rpl_control_address_register_done(interface, ll_addr, status) ((void) 0)
176178

177179
#endif /* HAVE_RPL */
178180

0 commit comments

Comments
 (0)