Skip to content

Commit 34cdafe

Browse files
author
Juha Heiskanen
committed
Temporary EAPOL neighbour entry Update and MAC MLME update
Multicast and EAPOL have 1 common temporary pool 15 for EAPOL and 5 for multicast. EAPOL relay allocate 1 neighbour table entry for relay. Relay agent allocate joiners fhss data to temporary list and use allocated 1 entry for TX. Bootstarp have a API for set and clear Temporary allocated Neighbour TX entry which is called by LLC. Agent release temporary entry if it hear Config, Config SOL and Advertisment Asynch or secured Data message or after configured timeout period. RX side is accepted when Relay agent have temporary entry allocated for joiner. RX is enabled by new MAC MLME SET operation. LLC Data Indication is splitted for own function for EAPOL, Lowpan and Asynch messages. LLC Data confirmation for EAPOL now call temporary neighbour clear.
1 parent d092f83 commit 34cdafe

File tree

17 files changed

+865
-216
lines changed

17 files changed

+865
-216
lines changed

nanostack/mlme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef enum {
264264
macAutoRequestKeyIndex = 0x7b, /*<The index of the key used for automatic data*/
265265
macDefaultKeySource = 0x7c, /*<Default key source*/
266266
//NON standard extension
267+
macDevicePendingAckTrig = 0xf5, /*< Trig Pending ACK for Accepted Data packet for temporary neighbour */
267268
mac802_15_4Mode = 0xf6, /*<IEEE 802.15.4 mode*/
268269
macDeviceDescriptionPanIDUpdate = 0xf7, /*<Thread pending link update case this will update device descrioton list pan-id to new one*/
269270
macTXPower = 0xf8, /*<TX output power*/

source/6LoWPAN/MAC/mac_helper.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -900,11 +900,13 @@ void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index,
900900
set_req.attr_index = attribute_index;
901901
set_req.value_pointer = (void *)&device_desc;
902902
set_req.value_size = sizeof(mlme_device_descriptor_t);
903-
tr_debug("Unregister Device %u, mac64: %s", attribute_index, trace_array(mac64, 8));
903+
if (mac64) {
904+
tr_debug("Unregister Device %u, mac64: %s", attribute_index, trace_array(mac64, 8));
905+
}
904906
mac_api->mlme_req(mac_api, MLME_SET, &set_req);
905907
}
906908

907-
void mac_helper_device_description_write(protocol_interface_info_entry_t *cur, mlme_device_descriptor_t *device_desc, uint8_t *mac64, uint16_t mac16, uint32_t frame_counter, bool exempt)
909+
void mac_helper_device_description_write(protocol_interface_info_entry_t *cur, mlme_device_descriptor_t *device_desc, const uint8_t *mac64, uint16_t mac16, uint32_t frame_counter, bool exempt)
908910
{
909911
memcpy(device_desc->ExtAddress, mac64, 8);
910912
device_desc->ShortAddress = mac16;
@@ -914,14 +916,19 @@ void mac_helper_device_description_write(protocol_interface_info_entry_t *cur, m
914916
}
915917

916918
void mac_helper_devicetable_set(const mlme_device_descriptor_t *device_desc, protocol_interface_info_entry_t *cur, uint8_t attribute_index, uint8_t keyID, bool force_set)
917-
918919
{
919-
if (!cur->mac_api) {
920+
if (!force_set && cur->mac_parameters->SecurityEnabled && cur->mac_parameters->mac_default_key_index != keyID) {
921+
tr_debug("Do not set counter by index %u != %u", cur->mac_parameters->mac_default_key_index, keyID);
920922
return;
921923
}
922924

923-
if (!force_set && cur->mac_parameters->SecurityEnabled && cur->mac_parameters->mac_default_key_index != keyID) {
924-
tr_debug("Do not set counter by index %u != %u", cur->mac_parameters->mac_default_key_index, keyID);
925+
tr_debug("Register Device %u, mac16 %x mac64: %s, %"PRIu32, attribute_index, device_desc->ShortAddress, trace_array(device_desc->ExtAddress, 8), device_desc->FrameCounter);
926+
mac_helper_devicetable_direct_set(cur->mac_api, device_desc, attribute_index);
927+
}
928+
929+
void mac_helper_devicetable_direct_set(struct mac_api_s *mac_api, const mlme_device_descriptor_t *device_desc, uint8_t attribute_index)
930+
{
931+
if (!mac_api) {
925932
return;
926933
}
927934

@@ -930,7 +937,20 @@ void mac_helper_devicetable_set(const mlme_device_descriptor_t *device_desc, pro
930937
set_req.attr_index = attribute_index;
931938
set_req.value_pointer = (void *)device_desc;
932939
set_req.value_size = sizeof(mlme_device_descriptor_t);
933-
tr_debug("Register Device %u, mac16 %x mac64: %s, %"PRIu32, attribute_index, device_desc->ShortAddress, trace_array(device_desc->ExtAddress, 8), device_desc->FrameCounter);
940+
mac_api->mlme_req(mac_api, MLME_SET, &set_req);
941+
}
942+
943+
void mac_helper_devicetable_ack_trig(const mlme_device_descriptor_t *device_desc, protocol_interface_info_entry_t *cur)
944+
{
945+
if (!cur->mac_api) {
946+
return;
947+
}
948+
949+
mlme_set_t set_req;
950+
set_req.attr = macDevicePendingAckTrig;
951+
set_req.attr_index = 0;
952+
set_req.value_pointer = (void *)device_desc;
953+
set_req.value_size = sizeof(mlme_device_descriptor_t);
934954
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);
935955
}
936956

source/6LoWPAN/MAC/mac_helper.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ int8_t mac_helper_key_link_frame_counter_set(int8_t interface_id, uint32_t seq_p
121121

122122
void mac_helper_devicetable_remove(struct mac_api_s *mac_api, uint8_t attribute_index, uint8_t *mac64);
123123

124-
void mac_helper_device_description_write(struct protocol_interface_info_entry *cur, mlme_device_descriptor_t *device_desc, uint8_t *mac64, uint16_t mac16, uint32_t frame_counter, bool exempt);
124+
void mac_helper_device_description_write(struct protocol_interface_info_entry *cur, mlme_device_descriptor_t *device_desc, const uint8_t *mac64, uint16_t mac16, uint32_t frame_counter, bool exempt);
125125

126126
void mac_helper_devicetable_set(const mlme_device_descriptor_t *device_dec, struct protocol_interface_info_entry *cur, uint8_t attribute_index, uint8_t keyID, bool force_set);
127+
128+
void mac_helper_devicetable_direct_set(struct mac_api_s *mac_api, const mlme_device_descriptor_t *device_desc, uint8_t attribute_index);
129+
130+
void mac_helper_devicetable_ack_trig(const mlme_device_descriptor_t *device_desc, struct protocol_interface_info_entry *cur);
131+
127132
int8_t mac_helper_mac_mlme_max_retry_set(int8_t interface_id, uint8_t mac_retry_set);
128133

129134
int8_t mac_helper_mac_device_description_pan_id_update(int8_t interface_id, uint16_t pan_id);

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,68 @@ static void ws_bootstrap_neighbor_delete(struct protocol_interface_info_entry *i
150150
ws_neighbor_class_entry_remove(&interface->ws_info->neighbor_storage, entry_ptr->index);
151151
}
152152

153+
static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_info_entry *interface)
154+
{
155+
uint8_t mac_64[8];
156+
memset(mac_64, 0, sizeof(mac_64));
157+
158+
mac_neighbor_table_entry_t *mac_entry = ws_bootstrap_mac_neighbor_add(interface, mac_64);
159+
160+
if (!mac_entry) {
161+
return;
162+
}
163+
mac_entry->lifetime = 0xffffffff;
164+
mac_entry->link_lifetime = 0xffffffff;
165+
ws_neighbor_class_entry_t *ws_neigh = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, mac_entry->index);
166+
if (!ws_neigh) {
167+
return;
168+
}
169+
interface->ws_info->eapol_tx_index = mac_entry->index;
170+
tr_debug("Allocated Eapol Index TX %u", interface->ws_info->eapol_tx_index);
171+
}
172+
173+
void ws_bootstrap_eapol_rx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
174+
{
175+
mlme_device_descriptor_t device_desc;
176+
177+
mac_helper_device_description_write(interface, &device_desc, src64, 0xffff, 0, false);
178+
mac_helper_devicetable_ack_trig(&device_desc, interface);
179+
}
180+
181+
ws_neighbor_class_entry_t *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
182+
{
183+
mlme_device_descriptor_t device_desc;
184+
mac_neighbor_table_entry_t *mac_entry = mac_neighbor_table_attribute_discover(mac_neighbor_info(interface), interface->ws_info->eapol_tx_index);
185+
if (!mac_entry) {
186+
return NULL;
187+
}
188+
189+
memcpy(mac_entry->mac64, src64, 8);
190+
191+
tr_debug("EAPOL Temporary TX neighbor %s : index:%u", trace_array(src64, 8), interface->ws_info->eapol_tx_index);
192+
mac_helper_device_description_write(interface, &device_desc, src64, 0xffff, 0, false);
193+
mac_helper_devicetable_direct_set(interface->mac_api, &device_desc, interface->ws_info->eapol_tx_index);
194+
return ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, mac_entry->index);
195+
}
196+
197+
void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface)
198+
{
199+
mac_neighbor_table_entry_t *mac_entry = mac_neighbor_table_attribute_discover(mac_neighbor_info(interface), interface->ws_info->eapol_tx_index);
200+
if (!mac_entry) {
201+
return;
202+
}
203+
204+
memset(mac_entry->mac64, 0xff, 8);
205+
mac_helper_devicetable_remove(interface->mac_api, interface->ws_info->eapol_tx_index, NULL);
206+
tr_debug("Clear EAPOL-Temporary");
207+
}
208+
153209
static void ws_bootstrap_neighbor_list_clean(struct protocol_interface_info_entry *interface)
154210
{
155211

156212
mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(interface));
213+
//Allocate EAPOL TX temporary neigh entry
214+
ws_bootstap_eapol_neigh_entry_allocate(interface);
157215
}
158216

159217
static void ws_address_reregister_trig(struct protocol_interface_info_entry *interface)
@@ -1348,6 +1406,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
13481406
tr_error("No broadcast schedule");
13491407
return;
13501408
}
1409+
13511410
llc_neighbour_req_t neighbor_info;
13521411
bool neighbour_pointer_valid;
13531412

@@ -1608,6 +1667,10 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
16081667
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur, &mac_neighbor_info(interface)->neighbour_list) {
16091668
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, cur->index);
16101669

1670+
if (cur->index == interface->ws_info->eapol_tx_index) {
1671+
continue;
1672+
}
1673+
16111674
if (cur->link_role == PRIORITY_PARENT_NEIGHBOUR) {
16121675
//This is our primary parent we cannot delete
16131676
continue;
@@ -3308,6 +3371,8 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
33083371
}
33093372
}
33103373

3374+
ws_llc_timer_seconds(cur, seconds);
3375+
33113376
}
33123377

33133378
void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor)

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef enum {
3131

3232
struct llc_neighbour_req;
3333
struct ws_us_ie;
34+
struct ws_neighbor_class_entry;
3435

3536
int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);
3637

@@ -81,6 +82,12 @@ void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur,
8182

8283
bool ws_bootstrap_validate_channel_plan(struct ws_us_ie *ws_us, struct protocol_interface_info_entry *cur);
8384

85+
void ws_bootstrap_eapol_rx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);
86+
87+
struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);
88+
89+
void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface);
90+
8491
#else
8592

8693
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ static void ws_cfg_network_size_config_set_small(ws_cfg_nw_size_t *cfg)
359359
cfg->timing.disc_trickle_k = 1;
360360
cfg->timing.pan_timeout = PAN_VERSION_SMALL_NETWORK_TIMEOUT;
361361
cfg->timing.temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_SMALL;
362+
cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_SMALL_TIMEOUT;
362363

363364
// RPL configuration
364365
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_SMALL; // 15; 32s seconds
@@ -388,6 +389,7 @@ static void ws_cfg_network_size_config_set_medium(ws_cfg_nw_size_t *cfg)
388389
cfg->timing.disc_trickle_k = 1;
389390
cfg->timing.pan_timeout = PAN_VERSION_MEDIUM_NETWORK_TIMEOUT;
390391
cfg->timing.temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_SMALL;
392+
cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_MEDIUM_TIMEOUT;
391393

392394
// RPL configuration
393395
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_MEDIUM; // 15; 32s
@@ -417,6 +419,7 @@ static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg)
417419
cfg->timing.disc_trickle_k = 1;
418420
cfg->timing.pan_timeout = PAN_VERSION_LARGE_NETWORK_TIMEOUT;
419421
cfg->timing.temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_LARGE;
422+
cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_LARGE_TIMEOUT;
420423

421424
// RPL configuration
422425
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_LARGE; // 19; 524s, 9min
@@ -446,6 +449,7 @@ static void ws_cfg_network_size_config_set_certificate(ws_cfg_nw_size_t *cfg)
446449
cfg->timing.disc_trickle_k = 1;
447450
cfg->timing.pan_timeout = PAN_VERSION_SMALL_NETWORK_TIMEOUT;
448451
cfg->timing.temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_SMALL;
452+
cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_SMALL_TIMEOUT;
449453

450454
// RPL configuration (small)
451455
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_SMALL; // 15; 32s seconds
@@ -618,6 +622,7 @@ static int8_t ws_cfg_timing_default_set(ws_timing_cfg_t *cfg)
618622
cfg->disc_trickle_k = 1;
619623
cfg->pan_timeout = PAN_VERSION_MEDIUM_NETWORK_TIMEOUT;
620624
cfg->temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_SMALL;
625+
cfg->temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_MEDIUM_TIMEOUT;
621626

622627
return CFG_SETTINGS_OK;
623628
}

source/6LoWPAN/ws/ws_cfg_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef struct ws_timing_cfg_s {
4949
uint8_t disc_trickle_k; /**< Discovery trickle k; DISC_K; default 1 */
5050
uint16_t pan_timeout; /**< PAN timeout; PAN_TIMEOUT; seconds; range 60-15300; default 3840 */
5151
uint16_t temp_link_min_timeout; /**< Temporary neighbor link minimum timeout; seconds; default 260 */
52+
uint16_t temp_eapol_min_timeout; /**< Temporary neighbor link minimum timeout; seconds; default 330 */
5253
} ws_timing_cfg_t;
5354

5455
/**

source/6LoWPAN/ws/ws_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ typedef struct ws_info_s {
8282
trickle_params_t trickle_params_pan_discovery;
8383
uint8_t rpl_state; // state from rpl_event_t
8484
uint8_t pas_requests; // Amount of PAN solicits sent
85+
uint8_t eapol_tx_index;
8586
parent_info_t parent_info[WS_PARENT_LIST_SIZE];
8687
parent_info_list_t parent_list_free;
8788
parent_info_list_t parent_list_reserved;

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ typedef struct ws_bs_ie {
236236
#define WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_SMALL 260
237237
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2
238238

239+
#define WS_EAPOL_TEMPORARY_ENTRY_SMALL_TIMEOUT 330
240+
#define WS_EAPOL_TEMPORARY_ENTRY_MEDIUM_TIMEOUT WS_EAPOL_TEMPORARY_ENTRY_SMALL_TIMEOUT
241+
#define WS_EAPOL_TEMPORARY_ENTRY_LARGE_TIMEOUT 750
242+
239243
#define WS_NEIGHBOR_ETX_SAMPLE_MAX 3
240244
#define WS_NEIGHBOR_FIRST_ETX_SAMPLE_MIN_COUNT 3 //This can't be bigger than WS_NEIGHBOR_ETX_SAMPLE_MAX
241245
#define WS_NEIGHBOUR_MAX_CANDIDATE_PROBE 5

source/6LoWPAN/ws/ws_llc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef struct ws_neighbor_temp_class_s {
8686
uint8_t mac64[8];
8787
uint8_t mpduLinkQuality;
8888
int8_t signal_dbm;
89+
uint16_t eapol_timeout;
8990
ns_list_link_t link;
9091
} ws_neighbor_temp_class_t;
9192

@@ -217,6 +218,8 @@ void ws_llc_set_pan_information_pointer(struct protocol_interface_info_entry *in
217218
*/
218219
void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hopping_schedule_s *hopping_schedule);
219220

221+
void ws_llc_timer_seconds(struct protocol_interface_info_entry *interface, uint16_t seconds_update);
222+
220223
ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64);
221224

222225
void ws_llc_free_multicast_temp_entry(struct protocol_interface_info_entry *interface, ws_neighbor_temp_class_t *neighbor);

0 commit comments

Comments
 (0)