Skip to content

Commit 7a138f7

Browse files
author
Mika Tervonen
committed
Added IID for border router info structure
Get IID from Wi-SUN RF interface using the Global prefix Added domain check for network size to prevent reset if Wrong interface ID is used
1 parent 4021b0c commit 7a138f7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

nanostack/ws_bbr_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ typedef struct bbr_information {
4040
uint8_t dodag_id[16];
4141
/** Address prefix given to devices in network set to 0 if not available*/
4242
uint8_t prefix[8];
43+
/** Address IID of the border router set to 0 if not available*/
44+
uint8_t IID[8];
4345
/** Amount of devices in the network. */
4446
uint16_t devices_in_network;
4547
/** Border router instance identifier defined in RPL */

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "ns_types.h"
2121
#include "ns_trace.h"
2222
#include "net_interface.h"
23+
#include "socket_api.h"
2324
#include "eventOS_event.h"
2425
#include "NWK_INTERFACE/Include/protocol.h"
2526
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h"
@@ -641,6 +642,11 @@ uint16_t test_pan_size_override = 0xffff;
641642
uint16_t ws_bbr_pan_size(protocol_interface_info_entry_t *cur)
642643
{
643644
uint16_t result = 0;
645+
646+
if (!cur || !cur->rpl_domain) {
647+
return 0;
648+
}
649+
644650
if (test_pan_size_override != 0xffff) {
645651
return test_pan_size_override;
646652
}
@@ -773,6 +779,13 @@ int ws_bbr_info_get(int8_t interface_id, bbr_information_t *info_ptr)
773779
memcpy(info_ptr->dodag_id, current_dodag_id, 16);
774780
memcpy(info_ptr->prefix, current_global_prefix, 8);
775781

782+
// Get the Wi-SUN interface generated address that is used in the RF interface.
783+
const uint8_t *wisun_if_addr = addr_select_with_prefix(cur, current_global_prefix, 64, SOCKET_IPV6_PREFER_SRC_PUBLIC);
784+
785+
if (wisun_if_addr) {
786+
memcpy(info_ptr->IID, wisun_if_addr + 8, 8);
787+
}
788+
776789
info_ptr->devices_in_network = ws_bbr_pan_size(cur);
777790
info_ptr->instance_id = current_instance_id;
778791
info_ptr->version = dodag_info.version_num;

0 commit comments

Comments
 (0)