Skip to content

Commit 4d04541

Browse files
author
Juha Heiskanen
committed
Wi-SUN header and Paylod IE element lenght future proof update.
1 parent 935898b commit 4d04541

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ bool ws_wh_utt_read(uint8_t *data, uint16_t length, struct ws_utt_ie *utt_ie)
319319
{
320320
mac_header_IE_t utt_ie_data;
321321
utt_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
322-
if (4 != mac_ie_header_sub_id_discover(data, length, &utt_ie_data, WH_IE_UTT_TYPE)) {
322+
if (4 > mac_ie_header_sub_id_discover(data, length, &utt_ie_data, WH_IE_UTT_TYPE)) {
323323
// NO UTT header
324324
return false;
325325
}
@@ -333,7 +333,7 @@ bool ws_wh_bt_read(uint8_t *data, uint16_t length, struct ws_bt_ie *bt_ie)
333333
{
334334
mac_header_IE_t btt_ie_data;
335335
btt_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
336-
if (5 != mac_ie_header_sub_id_discover(data, length, &btt_ie_data, WH_IE_BT_TYPE)) {
336+
if (5 > mac_ie_header_sub_id_discover(data, length, &btt_ie_data, WH_IE_BT_TYPE)) {
337337
return false;
338338
}
339339
data = btt_ie_data.content_ptr;
@@ -346,7 +346,7 @@ bool ws_wh_fc_read(uint8_t *data, uint16_t length, struct ws_fc_ie *fc_ie)
346346
{
347347
mac_header_IE_t fc_ie_data;
348348
fc_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
349-
if (2 != mac_ie_header_sub_id_discover(data, length, &fc_ie_data, WH_IE_FC_TYPE)) {
349+
if (2 > mac_ie_header_sub_id_discover(data, length, &fc_ie_data, WH_IE_FC_TYPE)) {
350350
return false;
351351
}
352352
data = fc_ie_data.content_ptr;
@@ -359,7 +359,7 @@ bool ws_wh_rsl_read(uint8_t *data, uint16_t length, int8_t *rsl)
359359
{
360360
mac_header_IE_t rsl_ie_data;
361361
rsl_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
362-
if (1 != mac_ie_header_sub_id_discover(data, length, &rsl_ie_data, WH_IE_RSL_TYPE)) {
362+
if (1 > mac_ie_header_sub_id_discover(data, length, &rsl_ie_data, WH_IE_RSL_TYPE)) {
363363
return false;
364364
}
365365
*rsl = *rsl_ie_data.content_ptr;
@@ -371,7 +371,7 @@ bool ws_wh_ea_read(uint8_t *data, uint16_t length, uint8_t *eui64)
371371
{
372372
mac_header_IE_t rsl_ie_data;
373373
rsl_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
374-
if (8 != mac_ie_header_sub_id_discover(data, length, &rsl_ie_data, WH_IE_EA_TYPE)) {
374+
if (8 > mac_ie_header_sub_id_discover(data, length, &rsl_ie_data, WH_IE_EA_TYPE)) {
375375
return false;
376376
}
377377
memcpy(eui64, rsl_ie_data.content_ptr, 8);
@@ -415,7 +415,7 @@ bool ws_wp_nested_us_read(uint8_t *data, uint16_t length, struct ws_us_ie *us_ie
415415
mac_nested_payload_IE_t nested_payload_ie;
416416
nested_payload_ie.id = WP_PAYLOAD_IE_US_TYPE;
417417
nested_payload_ie.type_long = true;
418-
if (mac_ie_nested_discover(data, length, &nested_payload_ie) < 4) {
418+
if (4 > mac_ie_nested_discover(data, length, &nested_payload_ie)) {
419419
return false;
420420
}
421421

@@ -517,7 +517,7 @@ bool ws_wp_nested_bs_read(uint8_t *data, uint16_t length, struct ws_bs_ie *bs_ie
517517
mac_nested_payload_IE_t nested_payload_ie;
518518
nested_payload_ie.id = WP_PAYLOAD_IE_BS_TYPE;
519519
nested_payload_ie.type_long = true;
520-
if (mac_ie_nested_discover(data, length, &nested_payload_ie) < 10) {
520+
if (10 > mac_ie_nested_discover(data, length, &nested_payload_ie)) {
521521
return false;
522522
}
523523
data = nested_payload_ie.content_ptr;
@@ -590,7 +590,7 @@ bool ws_wp_nested_pan_read(uint8_t *data, uint16_t length, struct ws_pan_informa
590590
mac_nested_payload_IE_t nested_payload_ie;
591591
nested_payload_ie.id = WP_PAYLOAD_IE_PAN_TYPE;
592592
nested_payload_ie.type_long = false;
593-
if (mac_ie_nested_discover(data, length, &nested_payload_ie) != 5) {
593+
if (5 > mac_ie_nested_discover(data, length, &nested_payload_ie)) {
594594
return false;
595595
}
596596

@@ -608,7 +608,7 @@ bool ws_wp_nested_pan_version_read(uint8_t *data, uint16_t length, uint16_t *pan
608608
mac_nested_payload_IE_t nested_payload_ie;
609609
nested_payload_ie.id = WP_PAYLOAD_IE_PAN_VER_TYPE;
610610
nested_payload_ie.type_long = false;
611-
if (mac_ie_nested_discover(data, length, &nested_payload_ie) != 2) {
611+
if (2 > mac_ie_nested_discover(data, length, &nested_payload_ie)) {
612612
return false;
613613
}
614614
*pan_version = common_read_16_bit_inverse(nested_payload_ie.content_ptr);

test/nanostack/unittest/6LoWPAN/ws_ie_lib/test_ws_ie_lib.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ bool test_ws_wh_utt_read()
193193
}
194194

195195
mac_ie_lib_stub_def.value_uint8 = 4;
196+
if (!ws_wh_utt_read(temp_buf, 8, &utt_ie)) {
197+
return false;
198+
}
199+
200+
//Future proof testing
201+
mac_ie_lib_stub_def.value_uint8 = 5;
196202
return ws_wh_utt_read(temp_buf, 8, &utt_ie);
197203
}
198204

@@ -206,6 +212,12 @@ bool test_ws_wh_bt_read()
206212
}
207213

208214
mac_ie_lib_stub_def.value_uint8 = 5;
215+
if (!ws_wh_bt_read(temp_buf, 8, &bt_ie)) {
216+
return false;
217+
}
218+
219+
//Future proof testing
220+
mac_ie_lib_stub_def.value_uint8 = 6;
209221
return ws_wh_bt_read(temp_buf, 8, &bt_ie);
210222
}
211223

@@ -353,14 +365,23 @@ bool test_ws_wp_nested_pan_read()
353365
}
354366
mac_ie_lib_stub_def.value_uint16 = 5;
355367

368+
if (!ws_wp_nested_pan_read(temp_buf, 20, &ws_pan_ie)) {
369+
return false;
370+
}
371+
//This will be par future proof part and 1.1 need to validate if version is 1.1
372+
//For LFN Window style 1.0 it is resewrved and this is BR configured
373+
374+
//Future proof validation
375+
mac_ie_lib_stub_def.value_uint16 = 6;
376+
356377
return ws_wp_nested_pan_read(temp_buf, 20, &ws_pan_ie);
357378
}
358379

359380
bool test_ws_wp_nested_pan_version_read()
360381
{
361382
uint16_t ws_pan_version;
362383
uint8_t temp_buf[20];
363-
mac_ie_lib_stub_def.value_uint16 = 4;
384+
mac_ie_lib_stub_def.value_uint16 = 1;
364385
if (ws_wp_nested_pan_version_read(temp_buf, 20, &ws_pan_version)) {
365386
return false;
366387
}
@@ -370,7 +391,9 @@ bool test_ws_wp_nested_pan_version_read()
370391
return false;
371392
}
372393

373-
return true;
394+
//test future proof accepts
395+
mac_ie_lib_stub_def.value_uint16 = 3;
396+
return ws_wp_nested_pan_version_read(temp_buf, 20, &ws_pan_version);
374397
}
375398

376399
bool test_ws_wp_nested_gtkhash_read()

0 commit comments

Comments
 (0)