Skip to content

Commit cea03d6

Browse files
author
Juha Heiskanen
committed
DHCPc6 client cancel support
ws-bootstrap will cancel dhcpv client if address registration fail and trigger again when learn new parent. Change-Id: Id99b723c72915b516562ce3c055ce3e2e8a04749
1 parent f562de5 commit cea03d6

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,10 @@ int ws_bootstrap_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t
16681668
{
16691669
blacklist_update(ll_address, false);
16701670
rpl_control_neighbor_delete(cur, ll_address);
1671-
return ws_bootstrap_neighbor_remove(cur, ll_address);
1671+
ws_bootstrap_neighbor_remove(cur, ll_address);
1672+
//Cancel DHCPV6 If it is active but not finished yest
1673+
dhcp_client_address_cancel(cur->id, NULL);
1674+
return 0;
16721675
}
16731676

16741677
static void ws_bootstrap_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid, bool coordinator)

source/DHCPv6_client/dhcpv6_client_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void dhcp_client_global_address_delete(int8_t interface, uint8_t *dhcp_addr, uin
100100

101101
void dhcp_relay_agent_enable(int8_t interface, uint8_t border_router_address[static 16]);
102102

103+
int dhcp_client_address_cancel(int8_t interface, uint8_t prefix[static 16]);
104+
103105

104106

105107
#endif /* DHCPV6_CLIENT_API_H_ */

source/DHCPv6_client/dhcpv6_client_service.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,31 @@ int dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16
303303
return 0;
304304
}
305305

306+
int dhcp_client_address_cancel(int8_t interface, uint8_t prefix[static 16])
307+
{
308+
dhcpv6_client_server_data_t *srv_data_ptr = NULL;
309+
310+
if (dhcp_client.interface != interface) {
311+
return -1;
312+
}
313+
314+
if (prefix) {
315+
srv_data_ptr = libdhcpv6_nonTemporal_entry_get_by_prefix(interface, prefix);
316+
} else if (dhcp_client.one_instance_interface) {
317+
srv_data_ptr = libdhcpv6_nonTemporal_entry_get_by_instance(dhcp_client.libDhcp_instance);
318+
}
319+
320+
if (srv_data_ptr && !srv_data_ptr->iaNonTemporalStructValid) {
321+
tr_debug("Cancel Address request");
322+
dhcp_service_req_remove(srv_data_ptr->transActionId);// remove all pending retransmissions
323+
libdhcvp6_nontemporalAddress_server_data_free(srv_data_ptr);
324+
return 0;
325+
}
326+
return -1;
327+
}
328+
329+
330+
306331
void dhcp_client_global_address_renew(int8_t interface)
307332
{
308333
(void)interface;

test/nanostack/unittest/stub/dhcpv6_client_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ void dhcp_client_configure(int8_t interface, bool renew_uses_solicit, bool one_c
9393
{
9494

9595
}
96+
97+
int dhcp_client_address_cancel(int8_t interface, uint8_t prefix[static 16])
98+
{
99+
return 0;
100+
}

0 commit comments

Comments
 (0)