Skip to content

Commit c5f5fa7

Browse files
author
Mika Tervonen
committed
omit NA messages from NS
Added configuration boolean to omit NA answers to NS messages Consider MAC level ACK as success for NS Configured Wi-SUN to use this feature
1 parent 5d29046 commit c5f5fa7

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,9 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
693693
/* Disable SLLAO send/mandatory receive with the ARO */
694694
cur->ipv6_neighbour_cache.use_eui64_as_slla_in_aro = true;
695695
/* Omit sending of NA if ARO SUCCESS */
696-
cur->ipv6_neighbour_cache.omit_aro_success = true;
696+
cur->ipv6_neighbour_cache.omit_na_aro_success = true;
697+
/* Omit sending of NA and consider ACK to be success */
698+
cur->ipv6_neighbour_cache.omit_na = true;
697699
// do not process AROs from NA. This is overriden by Wi-SUN specific failure handling
698700
cur->ipv6_neighbour_cache.recv_na_aro = false;
699701
/* Disable NUD Probes */

source/Common_Protocols/icmpv6.c

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,40 @@ uint8_t *icmpv6_write_mtu_option(uint32_t mtu, uint8_t *dptr)
13201320
return dptr;
13211321
}
13221322

1323+
void ack_receive_cb(struct buffer *buffer_ptr, uint8_t status)
1324+
{
1325+
/*icmpv6_na_handler functionality based on ACK*/
1326+
ipv6_neighbour_t *neighbour_entry;
1327+
uint8_t ll_target[16];
1328+
1329+
if (status != SOCKET_TX_DONE) {
1330+
/*NS failed*/
1331+
return;
1332+
}
1333+
1334+
if (buffer_ptr->dst_sa.addr_type == ADDR_IPV6) {
1335+
/*Full IPv6 address*/
1336+
memcpy(ll_target, buffer_ptr->dst_sa.address, 16);
1337+
} else if (buffer_ptr->dst_sa.addr_type == ADDR_802_15_4_LONG) {
1338+
// Build link local address from long MAC address
1339+
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
1340+
memcpy(ll_target + 8, &buffer_ptr->dst_sa.address[2], 8);
1341+
ll_target[8] ^= 2;
1342+
} else {
1343+
tr_warn("wrong address %d %s", buffer_ptr->dst_sa.addr_type, trace_array(buffer_ptr->dst_sa.address, 16));
1344+
return;
1345+
}
1346+
1347+
neighbour_entry = ipv6_neighbour_lookup(&buffer_ptr->interface->ipv6_neighbour_cache, ll_target);
1348+
if (neighbour_entry) {
1349+
ipv6_neighbour_update_from_na(&buffer_ptr->interface->ipv6_neighbour_cache, neighbour_entry, NA_S, buffer_ptr->dst_sa.addr_type, buffer_ptr->dst_sa.address);
1350+
}
1351+
1352+
if (ws_info(buffer_ptr->interface)) {
1353+
ws_common_neighbor_update(buffer_ptr->interface, ll_target);
1354+
}
1355+
}
1356+
13231357
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)
13241358
{
13251359
if (!cur || addr_is_ipv6_multicast(target_addr)) {
@@ -1394,10 +1428,15 @@ buffer_t *icmpv6_build_ns(protocol_interface_info_entry_t *cur, const uint8_t ta
13941428
}
13951429
/* If ARO Success sending is omitted, MAC ACK is used instead */
13961430
/* Setting callback for receiving ACK from adaptation layer */
1397-
if (aro && cur->ipv6_neighbour_cache.omit_aro_success) {
1431+
if (aro && cur->ipv6_neighbour_cache.omit_na_aro_success) {
13981432
buf->ack_receive_cb = rpl_control_address_register_done;
13991433
}
14001434
}
1435+
if (!aro && cur->ipv6_neighbour_cache.omit_na) {
1436+
/*MAC ACK is processed as success response*/
1437+
buf->ack_receive_cb = ack_receive_cb;
1438+
}
1439+
14011440
buf->src_sa.addr_type = ADDR_IPV6;
14021441

14031442
/* NS packets are implicitly on-link. If we ever find ourselves sending an
@@ -1530,11 +1569,16 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
15301569

15311570
tr_debug("Build NA");
15321571

1533-
/* Check if ARO status == success, then sending can be omitted with flag */
1534-
if (aro && cur->ipv6_neighbour_cache.omit_aro_success && aro->status == ARO_SUCCESS) {
1535-
tr_debug("Omit success reply");
1572+
/* Check if ARO response and status == success, then sending can be omitted with flag */
1573+
if (aro && cur->ipv6_neighbour_cache.omit_na_aro_success && aro->status == ARO_SUCCESS) {
1574+
tr_debug("Omit NA ARO success");
15361575
return NULL;
15371576
}
1577+
/* All other than ARO NA messages are omitted and MAC ACK is considered as success */
1578+
if (!aro && cur->ipv6_neighbour_cache.omit_na) {
1579+
return NULL;
1580+
}
1581+
15381582

15391583
buffer_t *buf = buffer_get(8 + 16 + 16 + 16); /* fixed, target addr, target ll addr, aro */
15401584
if (!buf) {

source/ipv6_stack/ipv6_routing_table.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ typedef struct ipv6_neighbour_cache {
123123
bool recv_ns_aro : 1;
124124
bool recv_na_aro : 1;
125125
bool use_eui64_as_slla_in_aro : 1;
126-
bool omit_aro_success : 1;
126+
bool omit_na_aro_success : 1;
127+
bool omit_na : 1; // except for ARO successes which have a separate flag
127128
int8_t interface_id;
128129
uint8_t max_ll_len;
129130
uint8_t gc_timer;

0 commit comments

Comments
 (0)