Skip to content

Commit

Permalink
Wi-sun border router enable global prefix with DHCP address allocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juha Heiskanen committed Oct 22, 2018
1 parent 6d2af0b commit fe9ba3b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "net_rpl.h"
#include "Service_Libs/nd_proxy/nd_proxy.h"
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
#include "libDHCPv6/libDHCPv6.h"
#include "DHCPv6_Server/DHCPv6_server_service.h"

#define TRACE_GROUP "wsbs"

Expand Down Expand Up @@ -237,22 +239,30 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
if (memcmp(global_dodag_id, ADDR_UNSPECIFIED,16) != 0) {
// TODO remove old global prefix
tr_info("RPL GUA deactivate %s", trace_ipv6(global_dodag_id));
addr_delete_matching(cur, global_dodag_id, 64, ADDR_SOURCE_SLAAC);

rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, global_dodag_id, 64, 0, 7200, 0, false);
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, global_dodag_id, 64, 0, 7200, false);
ipv6_route_add_with_info(global_dodag_id, 64, backbone_interface_id, NULL, ROUTE_THREAD_BBR, NULL, 0, 7200, 0);
}
// TODO add global prefix
if (memcmp(global_id, ADDR_UNSPECIFIED,16) != 0) {
// TODO Add new prefix
tr_info("RPL GUA activate %s", trace_ipv6(global_id));
if_address_entry_t *add_entry = icmpv6_slaac_address_add(cur, global_id, 64, 0xffffffff, 0xffffffff, true, SLAAC_IID_OPAQUE);
if (!add_entry) {
//DHCPv6 Server set here
//Interface LL64 address
uint8_t ll[16];
memcpy(ll, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(&ll[8], cur->mac, 8);
ll[8] ^= 2;

if (DHCPv6_server_service_init(cur->id, global_id, cur->mac, DHCPV6_DUID_HARDWARE_EUI64_TYPE) != 0) {
tr_error("DHCPv6 Server create fail");
return;
}

rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, global_id, 64, PIO_A, 0xffffffff, 0xffffffff, false);
DHCPv6_server_service_set_address_autonous_flag(cur->id, global_id, false);
tr_info("RPL GUA activate %s", trace_ipv6(global_id));
ws_dhcp_client_address_request(cur, global_id, ll);

rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, global_id, 64, 0, 0xffffffff, 0xffffffff, false);
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, global_id, 64, 0, 0xffffffff, false);
ipv6_route_add_with_info(global_id, 64, backbone_interface_id, NULL, ROUTE_THREAD_BBR, NULL, 0, 0xffffffff, 0);
}
Expand Down

0 comments on commit fe9ba3b

Please sign in to comment.