Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit b4059b8

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
WS neighbor class integrated to use new FHSS structures
Added new functions for store brodcast and unicast time info and schedules Refactor ws_utt_ie_t ws_bs_ie_t and ws_bt_ie_t parameters. Integrated new functions to llc andbootstrap. Change-Id: I814f8b21932386a683f1b00cfffcd0323656e525
1 parent c1b0d96 commit b4059b8

File tree

7 files changed

+139
-74
lines changed

7 files changed

+139
-74
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,8 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
321321
return;
322322
}
323323

324-
ws_neighbor->fhss_data.utt_timestamp = data->timestamp;
325-
ws_neighbor->fhss_data.ufsi = ws_utt.ut;
326-
ws_neighbor->fhss_data.channel_function = ws_us.channle_function;
327-
ws_neighbor->fhss_data.unicast_dwell = ws_us.dwell_interval;
328-
329-
324+
ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor, &ws_utt, data->timestamp);
325+
ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor, &ws_us);
330326

331327
// This parent is selected and used for authentication.
332328
if (memcmp(cur->ws_info->parent_info.addr, ADDR_UNSPECIFIED,8) != 0) {
@@ -338,7 +334,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
338334

339335

340336
// Parent valid store information
341-
cur->ws_info->parent_info.ufsi = ws_utt.ut;
337+
cur->ws_info->parent_info.ufsi = ws_utt.ufsi;
342338
// Saved from unicast IE
343339
cur->ws_info->parent_info.dwell_interval = ws_us.dwell_interval;
344340

@@ -396,10 +392,8 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
396392
return;
397393
}
398394

399-
ws_neighbor->fhss_data.utt_timestamp = data->timestamp;
400-
ws_neighbor->fhss_data.ufsi = ws_utt.ut;
401-
ws_neighbor->fhss_data.channel_function = ws_us.channle_function;
402-
ws_neighbor->fhss_data.unicast_dwell = ws_us.dwell_interval;
395+
ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor, &ws_utt, data->timestamp);
396+
ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor, &ws_us);
403397

404398
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_advertisement);
405399
}

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ typedef struct ws_hopping_schedule_s {
9090
*/
9191
typedef struct ws_utt_ie {
9292
uint8_t message_type;
93-
uint_fast24_t ut;
93+
uint_fast24_t ufsi;
9494
} ws_utt_ie_t;
9595

9696
/**
9797
* @brief ws_bt_ie_t WS BT-IE read
9898
*/
9999
typedef struct ws_bt_ie {
100100
uint16_t broadcast_slot_number;
101-
uint_fast24_t bsi;
101+
uint_fast24_t broadcast_interval_offset;
102102
} ws_bt_ie_t;
103103

104104

@@ -141,8 +141,8 @@ typedef struct ws_us_ie {
141141
uint8_t dwell_interval;
142142
uint8_t clock_drift;
143143
uint8_t timing_accurancy;
144-
unsigned channle_plan:3;
145-
unsigned channle_function:3;
144+
unsigned channel_plan:3;
145+
unsigned channel_function:3;
146146
unsigned excluded_channel_ctrl:2;
147147
union {
148148
ws_channel_plan_zero_t zero;
@@ -159,12 +159,12 @@ typedef struct ws_us_ie {
159159
*/
160160
typedef struct ws_bs_ie {
161161
uint32_t broadcast_interval;
162-
uint16_t bsi;
162+
uint16_t broadcast_schedule_identifier;
163163
uint8_t dwell_interval;
164164
uint8_t clock_drift;
165165
uint8_t timing_accurancy;
166-
unsigned channle_plan:3;
167-
unsigned channle_function:3;
166+
unsigned channel_plan:3;
167+
unsigned channel_function:3;
168168
unsigned excluded_channel_ctrl:2;
169169
union {
170170
ws_channel_plan_zero_t zero;

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ bool ws_wh_utt_read(uint8_t *data, uint16_t length, struct ws_utt_ie *utt_ie)
255255
}
256256
data = utt_ie_data.content_ptr;
257257
utt_ie->message_type = *data++;
258-
utt_ie->ut = common_read_24_bit_inverse(data + 1);
258+
utt_ie->ufsi = common_read_24_bit_inverse(data + 1);
259259
return true;
260260
}
261261

@@ -268,7 +268,7 @@ bool ws_wh_bt_read(uint8_t *data, uint16_t length, struct ws_bt_ie * bt_ie)
268268
}
269269
data = btt_ie_data.content_ptr;
270270
bt_ie->broadcast_slot_number = common_read_16_bit_inverse(data);
271-
bt_ie->bsi = common_read_24_bit_inverse(data + 2);
271+
bt_ie->broadcast_interval_offset = common_read_24_bit_inverse(data + 2);
272272
return true;
273273
}
274274

@@ -314,19 +314,19 @@ bool ws_wp_nested_us_read(uint8_t *data, uint16_t length, struct ws_us_ie *us_ie
314314
us_ie->dwell_interval = *data++;
315315
us_ie->clock_drift = *data++;
316316
us_ie->timing_accurancy = *data++;
317-
us_ie->channle_plan = (*data & 3);
318-
us_ie->channle_function = (*data & 0x38) >> 3;
317+
us_ie->channel_plan = (*data & 3);
318+
us_ie->channel_function = (*data & 0x38) >> 3;
319319
us_ie->excluded_channel_ctrl = (*data & 0xc0) >> 6;
320320
data++;
321321
uint16_t info_length = 0;
322322
nested_payload_ie.length -= 4;
323-
info_length = ws_channel_plan_length(us_ie->channle_plan);
323+
info_length = ws_channel_plan_length(us_ie->channel_plan);
324324
if (nested_payload_ie.length < info_length) {
325325
return false;
326326
}
327327

328328
nested_payload_ie.length -= info_length;
329-
switch ( us_ie->channle_plan) {
329+
switch ( us_ie->channel_plan) {
330330
case 0:
331331
data = ws_channel_plan_zero_read(data, &us_ie->plan.zero);
332332
break;
@@ -339,15 +339,15 @@ bool ws_wp_nested_us_read(uint8_t *data, uint16_t length, struct ws_us_ie *us_ie
339339

340340
}
341341

342-
info_length = ws_channel_function_length(us_ie->channle_function, 0);
342+
info_length = ws_channel_function_length(us_ie->channel_function, 0);
343343

344344
if (nested_payload_ie.length < info_length) {
345345
return false;
346346
}
347347
nested_payload_ie.length -= info_length;
348348

349349

350-
switch (us_ie->channle_function) {
350+
switch (us_ie->channel_function) {
351351
case 0:
352352
data = ws_channel_function_zero_read(data, &us_ie->function.zero);
353353
break;
@@ -383,25 +383,25 @@ bool ws_wp_nested_bs_read(uint8_t *data, uint16_t length, struct ws_bs_ie *bs_ie
383383
}
384384
data = nested_payload_ie.content_ptr;
385385
bs_ie->broadcast_interval = common_read_32_bit_inverse(data);
386-
bs_ie->bsi = common_read_16_bit_inverse(data + 4);
386+
bs_ie->broadcast_schedule_identifier = common_read_16_bit_inverse(data + 4);
387387
data += 6;
388388
bs_ie->dwell_interval = *data++;
389389
bs_ie->clock_drift = *data++;
390390
bs_ie->timing_accurancy = *data++;
391391

392-
bs_ie->channle_plan = (*data & 3);
393-
bs_ie->channle_function = (*data & 0x38) >> 3;
392+
bs_ie->channel_plan = (*data & 3);
393+
bs_ie->channel_function = (*data & 0x38) >> 3;
394394
bs_ie->excluded_channel_ctrl = (*data & 0xc0) >> 6;
395395
data++;
396396
nested_payload_ie.length -= 10;
397397
uint16_t info_length = 0;
398398

399-
info_length = ws_channel_plan_length(bs_ie->channle_plan);
399+
info_length = ws_channel_plan_length(bs_ie->channel_plan);
400400
if (nested_payload_ie.length < info_length) {
401401
return false;
402402
}
403403
nested_payload_ie.length -= info_length;
404-
switch ( bs_ie->channle_plan) {
404+
switch ( bs_ie->channel_plan) {
405405
case 0:
406406
data = ws_channel_plan_zero_read(data, &bs_ie->plan.zero);
407407
break;
@@ -414,13 +414,13 @@ bool ws_wp_nested_bs_read(uint8_t *data, uint16_t length, struct ws_bs_ie *bs_ie
414414

415415
}
416416

417-
info_length = ws_channel_function_length(bs_ie->channle_function,0);
417+
info_length = ws_channel_function_length(bs_ie->channel_function,0);
418418
if (nested_payload_ie.length < info_length) {
419419
return false;
420420
}
421421
nested_payload_ie.length -= info_length;
422422

423-
switch (bs_ie->channle_function) {
423+
switch (bs_ie->channel_function) {
424424
case 0:
425425
data = ws_channel_function_zero_read(data, &bs_ie->function.zero);
426426
break;

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -409,33 +409,29 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
409409

410410
protocol_interface_info_entry_t *interface = base->interface_ptr;
411411

412-
ws_neighbor_class_entry_t * ws_neighbor = NULL;
413-
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, data->SrcAddr, data->SrcAddrMode);
414-
if (neighbor) {
415-
ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
416-
}
417-
418-
if (ws_neighbor) {
419-
ws_neighbor->fhss_data.utt_timestamp = data->timestamp;
420-
ws_neighbor->fhss_data.ufsi = ws_utt.ut;
421-
//Update BT if it is part of message
422-
ws_bt_ie_t ws_bt;
423-
if (ws_wh_bt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_bt)) {
424-
ws_neighbor->fhss_data.bt_timestamp = data->timestamp;
425-
ws_neighbor->fhss_data.broadcast_slot_number = ws_bt.broadcast_slot_number;
426-
ws_neighbor->fhss_data.broadcast_interval = ws_bt.bsi;
427-
}
412+
//Discover 2 Payload Heder
413+
if (ws_utt.message_type == WS_FT_DATA || ws_utt.message_type == WS_FT_EAPOL) {
428414

429-
//Refresh Neighbor if unicast
430-
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
431-
tr_debug("Refresh neigh index %u", neighbor->index);
432-
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor, neighbor->link_lifetime);
415+
ws_neighbor_class_entry_t * ws_neighbor = NULL;
416+
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, data->SrcAddr, data->SrcAddrMode);
417+
if (neighbor) {
418+
ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
433419
}
434-
}
435420

421+
if (ws_neighbor) {
422+
ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor, &ws_utt, data->timestamp);
423+
//Update BT if it is part of message
424+
ws_bt_ie_t ws_bt;
425+
if (ws_wh_bt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_bt)) {
426+
ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor, &ws_bt, data->timestamp);
427+
}
436428

437-
//Discover 2 Payload Heder
438-
if (ws_utt.message_type == WS_FT_DATA || ws_utt.message_type == WS_FT_EAPOL) {
429+
//Refresh Neighbor if unicast
430+
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
431+
tr_debug("Refresh neigh index %u", neighbor->index);
432+
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor, neighbor->link_lifetime);
433+
}
434+
}
439435

440436
mac_payload_IE_t mpx_ie;
441437
mpx_ie.id = MAC_PAYLOAD_MPX_IE_GROUP_ID;
@@ -478,7 +474,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
478474
asynch_ie_list.headerIeListLength = ie_ext->headerIeListLength;
479475
asynch_ie_list.payloadIeList = ws_wp_nested.content_ptr;
480476
asynch_ie_list.payloadIeListLength = ws_wp_nested.length;
481-
base->acynch_ind(base->interface_ptr,data, &asynch_ie_list, ws_utt.message_type);
477+
base->acynch_ind(interface,data, &asynch_ie_list, ws_utt.message_type);
482478
}
483479

484480
}

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,31 @@ void ws_neighbor_class_entry_remove(ws_neighbor_class_t *class_data, uint8_t att
6666
memset(entry, 0, sizeof(ws_neighbor_class_entry_t));
6767
}
6868
}
69+
70+
void ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_utt_ie_t *ws_utt, uint32_t timestamp)
71+
{
72+
ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp = timestamp;
73+
ws_neighbor->fhss_data.uc_timing_info.ufsi = ws_utt->ufsi;
74+
}
75+
76+
void ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_us_ie_t *ws_us)
77+
{
78+
ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function = ws_us->channel_function;
79+
ws_neighbor->fhss_data.uc_timing_info.unicast_dwell_interval = ws_us->dwell_interval;
80+
}
81+
82+
83+
void ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_bt_ie_t *ws_bt_ie, uint32_t timestamp)
84+
{
85+
ws_neighbor->fhss_data.bc_timing_info.bt_rx_timestamp = timestamp;
86+
ws_neighbor->fhss_data.bc_timing_info.broadcast_slot = ws_bt_ie->broadcast_slot_number;
87+
ws_neighbor->fhss_data.bc_timing_info.broadcast_interval_offset = ws_bt_ie->broadcast_interval_offset;
88+
}
89+
90+
91+
void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_bs_ie_t *ws_bs_ie)
92+
{
93+
ws_neighbor->fhss_data.bc_timing_info.broadcast_dwell_interval = ws_bs_ie->dwell_interval;
94+
ws_neighbor->fhss_data.bc_timing_info.broadcast_interval = ws_bs_ie->broadcast_interval;
95+
ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id = ws_bs_ie->broadcast_schedule_identifier;
96+
}

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,11 @@
1818
#ifndef WS_NEIGHBOR_CLASS_H_
1919
#define WS_NEIGHBOR_CLASS_H_
2020

21-
/**
22-
* Neighbour Channel hopping information
23-
*/
24-
typedef struct ws_fhss_s {
25-
uint32_t utt_timestamp; /*!< Timestamp from MAC for Unicast time UTT-IE */
26-
uint32_t bt_timestamp; /*!< Timestamp from MAC for Broadcast time BT-IE */
27-
uint32_t broadcast_interval;
28-
uint32_t ufsi; /*!< Unicast Fractional Sequence Interval 24-bit */
29-
uint32_t bti; /*!< Broadcast Interval_offset 24-bit */
30-
uint16_t broadcast_slot_number; /*!< Broadcast Slot number */
31-
uint16_t bsi; /*!< Broadcast schedule identifier */
32-
uint8_t broadcast_dwell;
33-
uint8_t unicast_dwell;
34-
unsigned channel_function:3;
35-
} ws_fhss_t;
36-
21+
#include "fhss_ws_extension.h"
22+
#include "6LoWPAN/ws/ws_common_defines.h"
3723

3824
typedef struct ws_neighbor_class_entry_s {
39-
ws_fhss_t fhss_data;
25+
fhss_ws_neighbor_timing_info_t fhss_data;
4026
} ws_neighbor_class_entry_t;
4127

4228
/**
@@ -87,4 +73,43 @@ ws_neighbor_class_entry_t * ws_neighbor_class_entry_get(ws_neighbor_class_t *cla
8773
*/
8874
void ws_neighbor_class_entry_remove(ws_neighbor_class_t *class_data, uint8_t attribute_index);
8975

76+
/**
77+
* ws_neighbor_class_neighbor_unicast_time_info_update a function for update neighbor unicast time information
78+
*
79+
* \param ws_neighbor pointer to neighbor
80+
* \param ws_utt Unicast time IE data
81+
* \param timestamp timestamp for received data
82+
*
83+
*/
84+
void ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_utt_ie_t *ws_utt, uint32_t timestamp);
85+
86+
/**
87+
* ws_neighbor_class_neighbor_unicast_schedule_set a function for update neighbor unicast shedule information
88+
*
89+
* \param ws_neighbor pointer to neighbor
90+
* \param ws_us Unicast schedule IE data
91+
*
92+
*/
93+
void ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_us_ie_t *ws_us);
94+
95+
96+
/**
97+
* ws_neighbor_class_neighbor_broadcast_time_info_update a function for update neighbor broadcast time information
98+
*
99+
* \param ws_neighbor pointer to neighbor
100+
* \param ws_bt_ie Broadcast time IE data
101+
* \param timestamp timestamp for received data
102+
*
103+
*/
104+
void ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_bt_ie_t *ws_bt_ie, uint32_t timestamp);
105+
106+
/**
107+
* ws_neighbor_class_neighbor_broadcast_schedule_set a function for update neighbor broadcast shedule information
108+
*
109+
* \param ws_neighbor pointer to neighbor
110+
* \param ws_bs_ie Broadcast schedule IE data
111+
*
112+
*/
113+
void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_bs_ie_t *ws_bs_ie);
114+
90115
#endif /* WS_NEIGHBOR_CLASS_H_ */

test/nanostack/unittest/stub/ws_neighbour_class_stub.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,25 @@ void ws_neighbor_class_entry_remove(ws_neighbor_class_t *class_data, uint8_t att
6262
{
6363

6464
}
65+
66+
void ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_utt_ie_t *ws_utt, uint32_t timestamp)
67+
{
68+
69+
}
70+
71+
void ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_us_ie_t *ws_us)
72+
{
73+
74+
}
75+
76+
77+
void ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_bt_ie_t *ws_bt_ie, uint32_t timestamp)
78+
{
79+
80+
}
81+
82+
83+
void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_bs_ie_t *ws_bs_ie)
84+
{
85+
86+
}

0 commit comments

Comments
 (0)