Skip to content

Commit 561aefa

Browse files
author
Mika Tervonen
committed
Created Wi-SUN specific NA handler
When NA failure for ARO is sent neighbor is deleted Created public API to Wi-SUN to delete neighbor by Link Local address
1 parent 318ab48 commit 561aefa

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,11 +1634,6 @@ int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_rf_chan
16341634

16351635
int ws_bootstrap_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
16361636
{
1637-
tr_warn("ARO registration Failure %s", trace_ipv6(ll_address));
1638-
1639-
blacklist_update(ll_address, false);
1640-
rpl_control_neighbor_delete(cur, ll_address);
1641-
16421637
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), ll_address, false, NULL);
16431638

16441639
if (mac_neighbor) {
@@ -1647,7 +1642,12 @@ int ws_bootstrap_neighbor_remove(protocol_interface_info_entry_t *cur, const uin
16471642
return 0;
16481643
}
16491644

1650-
1645+
int ws_bootstrap_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
1646+
{
1647+
blacklist_update(ll_address, false);
1648+
rpl_control_neighbor_delete(cur, ll_address);
1649+
return ws_bootstrap_neighbor_remove(cur, ll_address);
1650+
}
16511651

16521652
static void ws_bootstrap_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid, bool coordinator)
16531653
{

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_rf_chan
4343

4444
int ws_bootstrap_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
4545

46+
int ws_bootstrap_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
47+
4648
/*State machine transactions*/
4749
void ws_bootstrap_event_discovery_start(protocol_interface_info_entry_t *cur);
4850

@@ -82,6 +84,7 @@ void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur,
8284
#define ws_bootstrap_state_machine(cur)
8385
#define ws_bootstrap_restart(cur)
8486
#define ws_bootstrap_neighbor_remove(cur, ll_address)
87+
#define ws_bootstrap_aro_failure(cur, ll_address)
8588
#define ws_primary_parent_update(interface, neighbor)
8689
#define ws_secondary_parent_update(interface)
8790

source/6LoWPAN/ws/ws_common.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,15 @@ void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8
354354

355355
void ws_common_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
356356
{
357-
//Neighbor connectected update
358-
ws_bootstrap_neighbor_remove(cur, ll_address);
357+
tr_warn("ARO registration Failure %s", trace_ipv6(ll_address));
358+
ws_bootstrap_aro_failure(cur, ll_address);
359359
}
360360

361+
void ws_common_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
362+
{
363+
tr_debug("neighbor remove %s", trace_ipv6(ll_address));
364+
ws_bootstrap_neighbor_remove(cur, ll_address);
365+
}
361366
bool ws_common_allow_child_registration(protocol_interface_info_entry_t *interface)
362367
{
363368
uint8_t child_count = 0;

source/6LoWPAN/ws/ws_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8
119119

120120
void ws_common_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
121121

122+
void ws_common_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
123+
122124
bool ws_common_allow_child_registration(protocol_interface_info_entry_t *cur);
123125

124126
#define ws_info(cur) ((cur)->ws_info)
@@ -127,6 +129,7 @@ bool ws_common_allow_child_registration(protocol_interface_info_entry_t *cur);
127129
#define ws_common_seconds_timer(cur, seconds)
128130
#define ws_common_neighbor_update(cur, ll_address) ((void) 0)
129131
#define ws_common_aro_failure(cur, ll_address)
132+
#define ws_common_neighbor_remove(cur, ll_address)
130133
#define ws_common_fast_timer(cur, ticks) ((void) 0)
131134
#define ws_common_allow_child_registration(cur) (false)
132135

source/Common_Protocols/icmpv6.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,29 @@ void ack_receive_cb(struct buffer *buffer_ptr, uint8_t status)
13531353
ws_common_neighbor_update(buffer_ptr->interface, ll_target);
13541354
}
13551355
}
1356+
void ack_remove_neighbour_cb(struct buffer *buffer_ptr, uint8_t status)
1357+
{
1358+
/*icmpv6_na_handler functionality based on ACK*/
1359+
uint8_t ll_target[16];
1360+
(void)status;
1361+
1362+
if (buffer_ptr->dst_sa.addr_type == ADDR_IPV6) {
1363+
/*Full IPv6 address*/
1364+
memcpy(ll_target, buffer_ptr->dst_sa.address, 16);
1365+
} else if (buffer_ptr->dst_sa.addr_type == ADDR_802_15_4_LONG) {
1366+
// Build link local address from long MAC address
1367+
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
1368+
memcpy(ll_target + 8, &buffer_ptr->dst_sa.address[2], 8);
1369+
ll_target[8] ^= 2;
1370+
} else {
1371+
tr_warn("wrong address %d %s", buffer_ptr->dst_sa.addr_type, trace_array(buffer_ptr->dst_sa.address, 16));
1372+
return;
1373+
}
1374+
if (ws_info(buffer_ptr->interface)) {
1375+
ws_common_neighbor_remove(buffer_ptr->interface, ll_target);
1376+
}
1377+
1378+
}
13561379

13571380
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)
13581381
{
@@ -1660,6 +1683,11 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
16601683
memcpy(ptr, aro->eui64, 8);
16611684
ptr += 8;
16621685
}
1686+
if (ws_info(cur) && aro && aro->status != ARO_SUCCESS) {
1687+
/*If Aro failed we will kill the neigbour after we have succeeded in sending message*/
1688+
buf->ack_receive_cb = ack_remove_neighbour_cb;
1689+
}
1690+
16631691
//Force Next Hop is destination
16641692
ipv6_buffer_route_to(buf, buf->dst_sa.address, cur);
16651693

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,9 @@ void ws_common_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t *
7171
{
7272
(void) cur;
7373
(void) ll_address;
74-
74+
}
75+
void ws_common_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
76+
{
77+
(void) cur;
78+
(void) ll_address;
7579
}

0 commit comments

Comments
 (0)