Skip to content

Commit 057b6ec

Browse files
author
Tero Heinonen
authored
Omit NA sending in ARO success cases. Use ACK instead. (ARMmbed#1587)
When "omit_aro_success" - flag is set, success response is not send to request. MAC ack is used to indicate success address registration.
1 parent 4686668 commit 057b6ec

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,16 @@ static void ws_bootstrap_address_registration_ns_send(struct protocol_interface_
7272
aro_t aro;
7373
buffer_t *buf;
7474

75+
tr_debug("Send ARO");
76+
7577
aro.status = ARO_SUCCESS;
7678
aro.present = true;
7779
aro.lifetime = addr->preferred_lifetime;
7880
memcpy(aro.eui64, interface->mac, 8);
7981

82+
/* Fill address to be registered */
83+
memcpy(&interface->if_6lowpan_dad_process.address, addr->address, 16);
84+
8085
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
8186
const uint8_t *preferred_parent = rpl_control_preferred_parent_addr(instance, false);
8287
if (preferred_parent) {
@@ -153,6 +158,8 @@ static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t
153158
}
154159
/* Disable SLLAO send/mandatory receive with the ARO */
155160
cur->ipv6_neighbour_cache.use_eui64_as_slla_in_aro = true;
161+
/* Omit sending of NA if ARO SUCCESS */
162+
cur->ipv6_neighbour_cache.omit_aro_success = true;
156163

157164
ws_bootstrap_event_discovery_start(cur);
158165

source/Common_Protocols/icmpv6.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,25 @@ uint8_t *icmpv6_write_mtu_option(uint32_t mtu, uint8_t *dptr)
12141214
return dptr;
12151215
}
12161216

1217+
static void icmpv6_ns_ack_cb(struct buffer *buf, uint8_t status)
1218+
{
1219+
(void) buf;
1220+
1221+
if (status == SOCKET_TX_DONE) {
1222+
tr_debug("NS ARO ack received %s", trace_ipv6(buf->interface->if_6lowpan_dad_process.address));
1223+
1224+
if_address_entry_t *addr_entry = addr_get_entry(buf->interface, buf->interface->if_6lowpan_dad_process.address);
1225+
if (!addr_entry) {
1226+
return;
1227+
}
1228+
/* State_timer is 1/10 s. Set renewal to 75-85% of lifetime */
1229+
addr_entry->state_timer = (addr_entry->preferred_lifetime * randLIB_get_random_in_range(75, 85) / 10);
1230+
} else {
1231+
// todo: What to do when address registration fails?
1232+
tr_debug("NS ARO send failed");
1233+
}
1234+
}
1235+
12171236
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)
12181237
{
12191238
if (!cur || addr_is_ipv6_multicast(target_addr)) {
@@ -1286,6 +1305,11 @@ buffer_t *icmpv6_build_ns(protocol_interface_info_entry_t *cur, const uint8_t ta
12861305
if (!cur->ipv6_neighbour_cache.use_eui64_as_slla_in_aro) {
12871306
ptr = icmpv6_write_icmp_lla(cur, ptr, ICMPV6_OPT_SRC_LL_ADDR, aro, buf->src_sa.address);
12881307
}
1308+
/* If ARO Success sending is omitted, MAC ACK is used instead */
1309+
/* Setting callback for receiving ACK from adaptation layer */
1310+
if (aro && cur->ipv6_neighbour_cache.omit_aro_success) {
1311+
buf->ack_receive_cb = icmpv6_ns_ack_cb;
1312+
}
12891313
}
12901314
buf->src_sa.addr_type = ADDR_IPV6;
12911315

@@ -1419,6 +1443,12 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
14191443

14201444
tr_debug("Build NA");
14211445

1446+
/* Check if ARO status == success, then sending can be omitted with flag */
1447+
if (aro && cur->ipv6_neighbour_cache.omit_aro_success && aro->status == ARO_SUCCESS) {
1448+
tr_debug("Omit success reply");
1449+
return NULL;
1450+
}
1451+
14221452
buffer_t *buf = buffer_get(8 + 16 + 16 + 16); /* fixed, target addr, target ll addr, aro */
14231453
if (!buf) {
14241454
return NULL;

source/Core/include/ns_buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ typedef struct buffer {
228228
uint8_t trickle_data_field[4];
229229
buffer_options_t options; /*!< Additional signal info etc */
230230
buffer_routing_info_t *route; /* A pointer last to try to get neat alignment for data */
231+
void (*ack_receive_cb)(struct buffer *buffer_ptr, uint8_t status); /*!< ACK receive callback. If set, will be called when TX is done */
231232
uint8_t buf[]; /*!< Trailing buffer data */
232233
} buffer_t;
233234

source/Core/ns_socket.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,10 @@ buffer_t *socket_tx_buffer_event(buffer_t *buf, uint8_t status)
13961396
* and we mapped straight to MAC address).
13971397
*/
13981398

1399+
if (buf->ack_receive_cb) {
1400+
buf->ack_receive_cb(buf, status);
1401+
}
1402+
13991403
/* Suppress events once socket orphaned */
14001404
if (!buf->socket || (buf->socket->flags & (SOCKET_FLAG_PENDING|SOCKET_FLAG_CLOSED))) {
14011405
return buf;

source/ipv6_stack/ipv6_routing_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ typedef struct ipv6_neighbour_cache {
120120
bool recv_ns_aro : 1;
121121
bool recv_na_aro : 1;
122122
bool use_eui64_as_slla_in_aro : 1;
123+
bool omit_aro_success : 1;
123124
int8_t interface_id;
124125
uint8_t max_ll_len;
125126
uint8_t gc_timer;

0 commit comments

Comments
 (0)