Skip to content

Commit a00a3c0

Browse files
author
Juha Heiskanen
committed
Wi-SUN FAN 1.1 PCAP IE update
Advertisment and storage support for PA messages. Added Parser for Data frame and storage.
1 parent 2d063d3 commit a00a3c0

File tree

15 files changed

+112
-43
lines changed

15 files changed

+112
-43
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,6 +2967,9 @@ static void ws_bootstrap_pan_advert(protocol_interface_info_entry_t *cur)
29672967
async_req.wp_requested_nested_ie_list.us_ie = true;
29682968
async_req.wp_requested_nested_ie_list.pan_ie = true;
29692969
async_req.wp_requested_nested_ie_list.net_name_ie = true;
2970+
if (ws_version_1_1(cur)) {
2971+
async_req.wp_requested_nested_ie_list.phy_cap_ie = true;
2972+
}
29702973

29712974
ws_set_asynch_channel_list(cur, &async_req);
29722975
async_req.security.SecurityLevel = 0;
@@ -2998,11 +3001,9 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
29983001
async_req.wp_requested_nested_ie_list.pan_version_ie = true;
29993002
async_req.wp_requested_nested_ie_list.gtkhash_ie = true;
30003003
async_req.wp_requested_nested_ie_list.vp_ie = true;
3001-
#ifdef HAVE_WS_VERSION_1_1
30023004
if (ws_version_1_1(cur)) {
3003-
async_req.wp_requested_nested_ie_list.lfn_gtk_version_ie = cur->ws_info->lfngtk.lfn_version_learned;
3005+
async_req.wp_requested_nested_ie_list.lfn_gtk_version_ie = ws_lfn_version_learned(cur);
30043006
}
3005-
#endif
30063007

30073008
ws_set_asynch_channel_list(cur, &async_req);
30083009

source/6LoWPAN/ws/ws_bootstrap_ffn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ static void ws_bootstrap_ffn_pan_advertisement_analyse(struct protocol_interface
323323
neighbor_info.neighbor = NULL;
324324
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
325325
neighbor_info.ws_neighbor->routing_cost = pan_information.routing_cost;
326+
//Store and search neighbour PCAP info
327+
if (ws_version_1_1(cur)) {
328+
ws_wp_nested_pcap_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, ws_neighbour_cap_pointer(neighbor_info.ws_neighbor));
329+
}
326330
}
327331

328332
ws_bootstrap_ffn_pan_advertisement_analyse_active(cur, &pan_information);

source/6LoWPAN/ws/ws_common.c

Lines changed: 2 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 "randLIB.h"
23+
#include "common_functions.h"
2324
#include <ns_list.h>
2425
#include <nsdynmemLIB.h>
2526
#include "Common_Protocols/icmpv6.h"
@@ -39,6 +40,7 @@
3940
#include "6LoWPAN/ws/ws_pae_controller.h"
4041
#include "6LoWPAN/ws/ws_cfg_settings.h"
4142
#include "6LoWPAN/ws/ws_stats.h"
43+
#include "6LoWPAN/ws/ws_ie_lib.h"
4244
#include "Service_Libs/etx/etx.h"
4345
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
4446
#include "Service_Libs/blacklist/blacklist.h"

source/6LoWPAN/ws/ws_common.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct ws_pan_information_s;
3737
struct ws_neighbor_class_s;
3838
struct ws_excluded_channel_data_s;
3939
struct ws_cfg_s;
40+
struct ws_neighbor_class_entry;
41+
struct mcps_data_ie_list;
4042

4143
typedef struct parent_info_s {
4244
uint16_t pan_id; /**< PAN ID */
@@ -102,10 +104,6 @@ typedef struct {
102104
uint8_t lgtkhash[24];
103105
} ws_lfn_lgtk_t;
104106

105-
typedef struct {
106-
unsigned length_of_list: 3;
107-
ws_pcab_ie_t pcab[7];
108-
} ws_phy_cap_info_t;
109107

110108
typedef NS_LIST_HEAD(ws_nud_table_entry_t, link) ws_nud_table_list_t;
111109

@@ -229,15 +227,21 @@ void ws_common_state_machine(protocol_interface_info_entry_t *cur);
229227
#ifdef HAVE_WS_VERSION_1_1
230228
#define ws_version_1_0(cur) (((cur)->ws_info) && ((cur)->ws_info)->version == 1)
231229
#define ws_version_1_1(cur) (((cur)->ws_info) && ((cur)->ws_info)->version > 1)
230+
#define ws_lfn_version_learned(cur) ((cur)->ws_info->lfngtk.lfn_version_learned == true)
231+
#define ws_neighbour_cap_pointer(neighbour) (&neighbour->pcap_info)
232232
#else
233233
#define ws_version_1_1(cur) (false)
234234
#define ws_version_1_0(cur) ((cur)->ws_info)
235+
#define ws_lfn_version_learned(cur) (false)
236+
#define ws_neighbour_cap_pointer(neighbour) NULL
235237
#endif
236238
#define ws_test_proc_auto_trg(cur) ((cur)->ws_info->test_proc_trg.auto_trg_enabled == true)
237239
#else
238240
#define ws_info(cur) ((ws_info_t *) NULL)
239241
#define ws_version_1_1(cur) (false)
240242
#define ws_version_1_0(cur) (false)
243+
#define ws_lfn_version_learned(cur) (false)
244+
#define ws_neighbour_cap_pointer(neighbour) NULL
241245
#define ws_test_proc_auto_trg(cur) (false)
242246
#define ws_common_seconds_timer(cur, seconds)
243247
#define ws_common_neighbor_update(cur, ll_address) ((void) 0)

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,17 @@ typedef struct ws_panid_ie {
241241
} ws_panid_ie_t;
242242

243243
/**
244-
* @brief ws_pcab_ie_t WS PCAB-IE
244+
* @brief ws_pcap_ie_t WS PCAB-IE
245245
*/
246-
typedef struct ws_pcab_ie {
246+
typedef struct ws_pcap_ie {
247247
unsigned phy_type: 3;
248248
uint16_t operation_mode;
249-
} ws_pcab_ie_t;
249+
} ws_pcap_ie_t;
250250

251-
/**
252-
* @brief ws_pcab_read_ie_t WS PCAB-IE
253-
*/
254-
typedef struct ws_pcab_read_ie {
255-
unsigned length_of_pcab: 3;
256-
uint8_t *pcab_start;
257-
} ws_pcab_read_ie_t;
251+
typedef struct ws_phy_cap_info {
252+
unsigned length_of_list: 3;
253+
ws_pcap_ie_t pcap[7];
254+
} ws_phy_cap_info_t;
258255

259256
/**
260257
* @brief ws_bt_ie_t WS BT-IE read

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -547,23 +547,21 @@ uint8_t *ws_wp_nested_gtkhash_write(uint8_t *ptr, uint8_t *gtkhash, uint8_t gtkh
547547
return ptr;
548548
}
549549

550-
uint16_t ws_wp_nested_pcab_length(uint8_t list_length)
550+
uint16_t ws_wp_nested_pcap_length(uint8_t list_length)
551551
{
552552
uint16_t lenght = (list_length * 3) + 1;
553553
return lenght;
554554
}
555555

556-
uint8_t *ws_wp_nested_pcap_write(uint8_t *ptr, uint8_t list_length, struct ws_pcab_ie *pcab_list)
556+
uint8_t *ws_wp_nested_pcap_write(uint8_t *ptr, struct ws_phy_cap_info *pcap_list)
557557
{
558-
uint16_t lenght = ws_wp_nested_pcab_length(list_length);
558+
uint16_t lenght = ws_wp_nested_pcap_length(pcap_list->length_of_list);
559559

560560
ptr = mac_ie_nested_ie_short_base_write(ptr, WP_PAYLOAD_IE_PCAP_TYPE, lenght);
561-
*ptr++ = list_length;
562-
while (list_length) {
563-
*ptr++ = pcab_list->phy_type;
564-
ptr = common_write_16_bit_inverse(pcab_list->operation_mode, ptr);
565-
list_length--;
566-
pcab_list++;
561+
*ptr++ = pcap_list->length_of_list;
562+
for (int i = 0; i < pcap_list->length_of_list; i++) {
563+
*ptr++ = pcap_list->pcap[i].phy_type;
564+
ptr = common_write_16_bit_inverse(pcap_list->pcap[i].operation_mode, ptr);
567565
}
568566
return ptr;
569567
}
@@ -1157,23 +1155,38 @@ bool ws_wp_nested_network_name_read(uint8_t *data, uint16_t length, ws_wp_networ
11571155
return true;
11581156
}
11591157

1160-
bool ws_wp_nested_pcab_read(uint8_t *data, uint16_t length, struct ws_pcab_read_ie *ws_pcab_list)
1158+
bool ws_wp_nested_pcap_read(uint8_t *data, uint16_t length, struct ws_phy_cap_info *ws_pcap_list)
11611159
{
1160+
#ifdef HAVE_WS_VERSION_1_1
11621161
mac_nested_payload_IE_t nested_payload_ie;
11631162
nested_payload_ie.id = WP_PAYLOAD_IE_PCAP_TYPE;
11641163
nested_payload_ie.type_long = false;
11651164
if (4 > mac_ie_nested_discover(data, length, &nested_payload_ie)) {
11661165
return false;
11671166
}
1168-
//Validate length
1167+
//Read & Validate length
11691168
data = nested_payload_ie.content_ptr;
1170-
ws_pcab_list->length_of_pcab = *data & 0x07;
1171-
if (nested_payload_ie.length < ws_pcab_list->length_of_pcab * 3) {
1169+
uint8_t length_of_cap = *data++ & 0x07;
1170+
1171+
if (nested_payload_ie.length < length_of_cap * 3) {
11721172
return false;
11731173
}
1174+
ws_pcap_list->length_of_list = length_of_cap;
1175+
1176+
for (uint8_t i = 0; i < length; length_of_cap++) {
1177+
ws_pcap_list->pcap[i].phy_type = *data++ & 7;
1178+
ws_pcap_list->pcap[i].operation_mode = common_read_16_bit_inverse(data);
1179+
data += 2;
1180+
}
1181+
11741182

1175-
ws_pcab_list->pcab_start = data + 1;
11761183
return true;
1184+
#else
1185+
(void) data;
1186+
(void) length;
1187+
(void) ws_pcap_list;
1188+
return false;
1189+
#endif
11771190
}
11781191

11791192

source/6LoWPAN/ws/ws_ie_lib.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct ws_bt_ie;
2424
struct ws_us_ie;
2525
struct ws_hopping_schedule_s;
2626
struct ws_fc_ie;
27+
struct ws_phy_cap_info;
2728

2829
/**
2930
* @brief ws_wp_network_name_t WS nested payload network name
@@ -89,9 +90,9 @@ uint8_t *ws_wp_nested_pan_ver_write(uint8_t *ptr, struct ws_pan_information_s *p
8990
uint8_t *ws_wp_nested_gtkhash_write(uint8_t *ptr, uint8_t *gtkhash, uint8_t gtkhash_length);
9091
uint16_t ws_wp_nested_hopping_schedule_length(struct ws_hopping_schedule_s *hopping_schedule, bool unicast_schedule);
9192
/* Wi-SUN FAN 1.1 */
92-
/* WS PCAB */
93-
uint8_t *ws_wp_nested_pcap_write(uint8_t *ptr, uint8_t list_length, struct ws_pcab_ie *pcab_list);
94-
uint16_t ws_wp_nested_pcab_length(uint8_t list_length);
93+
/* WS PCAP */
94+
uint8_t *ws_wp_nested_pcap_write(uint8_t *ptr, struct ws_phy_cap_info *pcap_list);
95+
uint16_t ws_wp_nested_pcap_length(uint8_t list_length);
9596
/* WS LFN version */
9697
uint8_t *ws_wp_nested_lfn_version_write(uint8_t *ptr, struct ws_lfnver_ie *ws_lfnver);
9798
/* WS LFN GTK HAS */
@@ -109,7 +110,7 @@ bool ws_wp_nested_pan_version_read(uint8_t *data, uint16_t length, uint16_t *pan
109110
bool ws_wp_nested_network_name_read(uint8_t *data, uint16_t length, ws_wp_network_name_t *network_name);
110111
uint8_t *ws_wp_nested_gtkhash_read(uint8_t *data, uint16_t length);
111112
/* Wi-SUN FAN 1.1 */
112-
bool ws_wp_nested_pcab_read(uint8_t *data, uint16_t length, struct ws_pcab_read_ie *ws_pcab_list);
113+
bool ws_wp_nested_pcap_read(uint8_t *data, uint16_t length, struct ws_phy_cap_info *ws_pcap_list);
113114
bool ws_wp_nested_lfn_version_read(uint8_t *data, uint16_t length, struct ws_lfnver_ie *ws_lfnver);
114115
bool ws_wp_nested_lgtk_hash_read(uint8_t *data, uint16_t length, struct ws_lgtkhash_ie *ws_lgtkhash);
115116
bool ws_wp_nested_lfn_channel_plan_read(uint8_t *data, uint16_t length, struct ws_generic_channel_info *ws_lcp, uint8_t plan_tag_id);

source/6LoWPAN/ws/ws_llc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ typedef struct wp_nested_ie_sub_list_s {
5656
bool net_name_ie: 1; /**< Network Name information */
5757
bool pan_version_ie: 1; /**< Pan configuration version */
5858
bool gtkhash_ie: 1; /**< GTK Hash information */
59-
bool lfn_gtk_version_ie: 1; /**< LFN Version & GTK Hash */
59+
bool lfn_gtk_version_ie: 1; /**< LFN Version & GTK Hash */
60+
bool phy_cap_ie: 1; /** < Phy Cap information for MDR */
6061
} wp_nested_ie_sub_list_t;
6162

6263
/**

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,20 @@ static uint16_t ws_wp_nested_message_length(wp_nested_ie_sub_list_t requested_li
413413
}
414414
}
415415
#ifdef HAVE_WS_VERSION_1_1
416-
if (requested_list.lfn_gtk_version_ie) {
416+
if (ws_version_1_1(llc_base->interface_ptr)) {
417+
if (requested_list.lfn_gtk_version_ie) {
418+
419+
length += WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH + ws_wp_nested_lfn_version_length();
420+
ws_lgtkhash_ie_t ws_lgtkhash;
421+
ws_lgtkhash.lgtk0 = llc_base->interface_ptr->ws_info->lfngtk.active_hash_1;
422+
ws_lgtkhash.lgtk1 = llc_base->interface_ptr->ws_info->lfngtk.active_hash_2;
423+
ws_lgtkhash.lgtk2 = llc_base->interface_ptr->ws_info->lfngtk.active_hash_3;
424+
length += WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH + ws_wp_lgtk_hash_length(&ws_lgtkhash);
425+
}
417426

418-
length += WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH + ws_wp_nested_lfn_version_length();
419-
ws_lgtkhash_ie_t ws_lgtkhash;
420-
ws_lgtkhash.lgtk0 = llc_base->interface_ptr->ws_info->lfngtk.active_hash_1;
421-
ws_lgtkhash.lgtk1 = llc_base->interface_ptr->ws_info->lfngtk.active_hash_2;
422-
ws_lgtkhash.lgtk2 = llc_base->interface_ptr->ws_info->lfngtk.active_hash_3;
423-
length += WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH + ws_wp_lgtk_hash_length(&ws_lgtkhash);
427+
if (requested_list.phy_cap_ie) {
428+
length += WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH + ws_wp_nested_pcap_length(llc_base->interface_ptr->ws_info->phy_cap_info.length_of_list);
429+
}
424430
}
425431
#endif
426432

@@ -786,6 +792,11 @@ static void ws_llc_data_indication_cb(const mac_api_t *api, const mcps_data_ind_
786792
//SET trusted state
787793
mac_neighbor_table_trusted_neighbor(mac_neighbor_info(interface), neighbor_info.neighbor, true);
788794
}
795+
//
796+
//Phy CAP info read and store
797+
if (ws_version_1_1(interface)) {
798+
ws_wp_nested_pcap_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, ws_neighbour_cap_pointer(neighbor_info.ws_neighbor));
799+
}
789800
}
790801

791802
mcps_data_ind_t data_ind = *data;
@@ -1911,6 +1922,10 @@ int8_t ws_llc_asynch_request(struct protocol_interface_info_entry *interface, as
19111922
ws_lgtkhash.lgtk2_hash = base->interface_ptr->ws_info->lfngtk.lgtkhash + 16;
19121923
ptr = ws_wp_nested_lgtk_hash_write(ptr, &ws_lgtkhash);
19131924
}
1925+
1926+
if (request->wp_requested_nested_ie_list.phy_cap_ie) {
1927+
ptr = ws_wp_nested_pcap_write(ptr, &base->interface_ptr->ws_info->phy_cap_info);
1928+
}
19141929
}
19151930
#endif
19161931

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
#include "6LoWPAN/ws/ws_config.h"
2727
#include "6LoWPAN/ws/ws_neighbor_class.h"
2828
#include "6LoWPAN/ws/ws_common.h"
29+
#include "6LoWPAN/ws/ws_ie_lib.h"
2930
#include "ws_management_api.h"
31+
#include "mac_api.h"
3032

3133
#ifdef HAVE_WS
3234

@@ -393,6 +395,14 @@ bool ws_neighbor_class_neighbor_duplicate_packet_check(ws_neighbor_class_entry_t
393395
return true;
394396
}
395397

398+
#ifdef HAVE_WS_VERSION_1_1
399+
void ws_neighbor_class_pcap_ie_store(struct ws_neighbor_class_entry *ws_neighbor, const struct mcps_data_ie_list *ie_ext)
400+
{
401+
ws_wp_nested_pcap_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &ws_neighbor->pcap_info);
402+
403+
}
404+
#endif
405+
396406

397407
#endif /* HAVE_WS */
398408

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "fhss_ws_extension.h"
2222
#include "6LoWPAN/ws/ws_common_defines.h"
2323

24+
struct mcps_data_ie_list;
25+
2426
#define RSL_UNITITIALIZED 0x7fff
2527

2628
typedef struct ws_neighbor_class_entry {
@@ -34,6 +36,9 @@ typedef struct ws_neighbor_class_entry {
3436
bool broadcast_shedule_info_stored: 1;
3537
bool synch_done : 1;
3638
bool unicast_data_rx : 1;
39+
#ifdef HAVE_WS_VERSION_1_1
40+
ws_phy_cap_info_t pcap_info;
41+
#endif
3742
} ws_neighbor_class_entry_t;
3843

3944
/**

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ TEST_SRC_FILES = \
2929
../../stub/mac_ie_lib_stub.c \
3030
../../stub/ws_ie_lib_stub.c \
3131
../../stub/ws_bootstrap_stub.c \
32+
../../stub/ws_common_stub.c \
3233
../../stub/ws_mpx_header_stub.c \
3334
../../stub/ws_neighbour_class_stub.c \
3435
../../stub/ws_pae_controller_stub.c \

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <string.h>
1819
#include "nsconfig.h"
1920
#include "ns_types.h"
2021
#include "ns_trace.h"

test/nanostack/unittest/stub/ws_ie_lib_stub.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,14 @@ uint8_t *ws_wp_nested_lfn_version_write(uint8_t *ptr, struct ws_lfnver_ie *ws_lf
216216
ptr += 2 + 2;
217217
return ptr;
218218
}
219+
220+
uint16_t ws_wp_nested_pcap_length(uint8_t list_length)
221+
{
222+
return 1;
223+
}
224+
225+
uint8_t *ws_wp_nested_pcap_write(uint8_t *ptr, struct ws_phy_cap_info *pcap_list)
226+
{
227+
ptr += 2 + 1;
228+
return ptr;
229+
}

test/nanostack/unittest/stub/ws_neighbour_class_stub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include "ns_trace.h"
2323
#include "nsdynmemLIB.h"
2424
#include "6LoWPAN/ws/ws_neighbor_class.h"
25+
#include "6LoWPAN/ws/ws_ie_lib.h"
26+
#include "ws_management_api.h"
27+
#include "mac_api.h"
2528
#include "ws_neighbour_class_stub.h"
2629

2730
ws_neighbor_stub_def ws_neighbor_stub;

0 commit comments

Comments
 (0)