Skip to content

Commit 5972bc3

Browse files
author
Juha Heiskanen
authored
Merge pull request #1959 from ARMmbed/ws_eapol_ie_update
Ws eapol ie update
2 parents 98af118 + ed87161 commit 5972bc3

File tree

12 files changed

+113
-11
lines changed

12 files changed

+113
-11
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,15 @@ void ws_dhcp_client_address_delete(protocol_interface_info_entry_t *cur, uint8_t
17501750
dhcp_client_global_address_delete(cur->id, NULL, prefix);
17511751
}
17521752

1753+
bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur)
1754+
{
1755+
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER || cur->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
1756+
return true;
1757+
}
1758+
1759+
return false;
1760+
}
1761+
17531762
static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t *parent_link_local)
17541763
{
17551764
protocol_interface_info_entry_t *cur = (protocol_interface_info_entry_t *) handle;
@@ -2156,6 +2165,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
21562165
uint8_t ll_addr[16];
21572166
addr_interface_get_ll_address(cur, ll_addr, 1);
21582167

2168+
//SET EAPOL authenticator EUI64
2169+
ws_pae_controller_border_router_addr_write(cur, cur->mac);
2170+
21592171
// Set EAPOL relay to port 10255 and authenticator relay to 10253 (and to own ll address)
21602172
ws_eapol_relay_start(cur, BR_EAPOL_RELAY_SOCKET_PORT, ll_addr, EAPOL_RELAY_SOCKET_PORT);
21612173

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ void ws_dhcp_client_address_request(protocol_interface_info_entry_t *cur, uint8_
7070

7171
void ws_dhcp_client_address_delete(protocol_interface_info_entry_t *cur, uint8_t *prefix);
7272

73+
bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur);
74+
7375
#else
7476

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

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define WH_IE_RSL_TYPE 4 /**< Received Signal Level information */
2828
#define WH_IE_MHDS_TYPE 5 /**< MHDS information for mesh routing */
2929
#define WH_IE_VH_TYPE 6 /**< Vendor header information */
30+
#define WH_IE_EA_TYPE 9 /**< Eapol Auhtenticator EUI-64 header information */
3031

3132
#define WS_WP_NESTED_IE 4 /**< WS nested Payload IE element'selement could include mltiple sub payload IE */
3233

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ uint8_t *ws_wh_rsl_write(uint8_t *ptr, int8_t rssi)
118118
return ptr;
119119
}
120120

121+
uint8_t *ws_wh_ea_write(uint8_t *ptr, uint8_t *eui64)
122+
{
123+
ptr = ws_wh_header_base_write(ptr, 8, WH_IE_EA_TYPE);
124+
memcpy(ptr, eui64, 8);
125+
ptr += 8;
126+
return ptr;
127+
}
128+
121129
uint8_t *ws_wh_vh_write(uint8_t *ptr, uint8_t *vendor_header, uint8_t vendor_header_length)
122130
{
123131
ptr = ws_wh_header_base_write(ptr, vendor_header_length, WH_IE_VH_TYPE);
@@ -300,6 +308,18 @@ bool ws_wh_rsl_read(uint8_t *data, uint16_t length, int8_t *rsl)
300308
return true;
301309
}
302310

311+
bool ws_wh_ea_read(uint8_t *data, uint16_t length, uint8_t *eui64)
312+
{
313+
mac_header_IE_t rsl_ie_data;
314+
rsl_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
315+
if (8 != mac_ie_header_sub_id_discover(data, length, &rsl_ie_data, WH_IE_EA_TYPE)) {
316+
return false;
317+
}
318+
memcpy(eui64, rsl_ie_data.content_ptr, 8);
319+
320+
return true;
321+
}
322+
303323
static uint8_t *ws_channel_plan_zero_read(uint8_t *ptr, ws_channel_plan_zero_t *plan)
304324
{
305325
plan->regulator_domain = *ptr++;

source/6LoWPAN/ws/ws_ie_lib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ uint8_t *ws_wh_bt_write(uint8_t *ptr);
3838
uint8_t *ws_wh_fc_write(uint8_t *ptr, uint8_t flow_ctrl);
3939
uint8_t *ws_wh_rsl_write(uint8_t *ptr, int8_t rssi);
4040
uint8_t *ws_wh_vh_write(uint8_t *ptr, uint8_t *vendor_header, uint8_t vendor_header_length);
41+
uint8_t *ws_wh_ea_write(uint8_t *ptr, uint8_t *eui64);
4142

4243
bool ws_wh_utt_read(uint8_t *data, uint16_t length, struct ws_utt_ie *utt_ie);
4344
bool ws_wh_bt_read(uint8_t *data, uint16_t length, struct ws_bt_ie *bt_ie);
4445
bool ws_wh_rsl_read(uint8_t *data, uint16_t length, int8_t *rsl);
46+
bool ws_wh_ea_read(uint8_t *data, uint16_t length, uint8_t *eui64);
4547

4648
/* WS_WP_NESTED PAYLOD IE */
4749
uint8_t *ws_wp_base_write(uint8_t *ptr, uint16_t length);

source/6LoWPAN/ws/ws_llc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef struct wh_ie_sub_list_s {
4141
bool fc_ie: 1; /**< Flow Control for Extended Direct Frame Exchange */
4242
bool rsl_ie: 1; /**< Received Signal Level information */
4343
bool vh_ie: 1; /**< Vendor header information */
44+
bool ea_ie: 1; /**< EAPOL autheticator EUI-64 header information */
4445
} wh_ie_sub_list_t;
4546

4647
/**

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
#include "6LoWPAN/MAC/mac_ie_lib.h"
3232
#include "6LoWPAN/ws/ws_common_defines.h"
3333
#include "6LoWPAN/ws/ws_common.h"
34+
#include "6LoWPAN/ws/ws_bootstrap.h"
3435
#include "6LoWPAN/ws/ws_ie_lib.h"
3536
#include "6LoWPAN/ws/ws_llc.h"
3637
#include "6LoWPAN/ws/ws_mpx_header.h"
38+
#include "6LoWPAN/ws/ws_pae_controller.h"
3739
#include "Service_Libs/etx/etx.h"
3840
#include "fhss_ws_extension.h"
3941

@@ -282,6 +284,10 @@ static uint16_t ws_wh_headers_length(wh_ie_sub_list_t requested_list, llc_ie_par
282284
length += WH_IE_ELEMENT_HEADER_LENGTH + params->vendor_header_length;
283285
}
284286

287+
if (requested_list.ea_ie) {
288+
length += WH_IE_ELEMENT_HEADER_LENGTH + 8;
289+
}
290+
285291
return length;
286292
}
287293

@@ -521,6 +527,15 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
521527
if (us_ie_inline) {
522528
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, &us_ie);
523529
}
530+
531+
if (ws_utt.message_type == WS_FT_EAPOL) {
532+
uint8_t auth_eui64[8];
533+
//Discover and write Auhtenticator EUI-64
534+
if (ws_wh_ea_read(ie_ext->headerIeList, ie_ext->headerIeListLength, auth_eui64)) {
535+
ws_pae_controller_border_router_addr_write(base->interface_ptr, auth_eui64);
536+
}
537+
}
538+
524539
//Update BT if it is part of message
525540
ws_bt_ie_t ws_bt;
526541
if (ws_wh_bt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_bt)) {
@@ -620,13 +635,23 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
620635
wp_nested_ie_sub_list_t nested_wp_id;
621636
memset(&nested_wp_id, 0, sizeof(wp_nested_ie_sub_list_t));
622637
ie_header_mask.utt_ie = true;
623-
ie_header_mask.bt_ie = true;
624-
if (base->ie_params.vendor_header_length && user_id == MPX_LOWPAN_ENC_USER_ID) {
625-
ie_header_mask.vh_ie = true;
626-
}
627638

628-
if (base->ie_params.vendor_payload_length && user_id == MPX_LOWPAN_ENC_USER_ID) {
629-
nested_wp_id.vp_ie = true;
639+
if (user_id == MPX_LOWPAN_ENC_USER_ID) {
640+
ie_header_mask.bt_ie = true;
641+
if (base->ie_params.vendor_header_length) {
642+
ie_header_mask.vh_ie = true;
643+
}
644+
645+
if (base->ie_params.vendor_payload_length) {
646+
nested_wp_id.vp_ie = true;
647+
}
648+
} else if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
649+
650+
if (*data->msdu == 1) { //Only when KMP_ID is 1
651+
ie_header_mask.ea_ie = ws_eapol_relay_state_active(base->interface_ptr);
652+
ie_header_mask.bt_ie = ie_header_mask.ea_ie;
653+
}
654+
630655
}
631656

632657
nested_wp_id.us_ie = true;
@@ -681,12 +706,24 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
681706
//Write UTT
682707

683708
ptr = ws_wh_utt_write(ptr, message->messsage_type);
684-
ptr = ws_wh_bt_write(ptr);
709+
if (ie_header_mask.bt_ie) {
710+
ptr = ws_wh_bt_write(ptr);
711+
}
685712

686-
if (user_id == MPX_LOWPAN_ENC_USER_ID && ie_header_mask.vh_ie) {
687-
ptr = ws_wh_vh_write(ptr, base->ie_params.vendor_header_data, base->ie_params.vendor_header_length);
713+
if (user_id == MPX_LOWPAN_ENC_USER_ID) {
714+
if (ie_header_mask.vh_ie) {
715+
ptr = ws_wh_vh_write(ptr, base->ie_params.vendor_header_data, base->ie_params.vendor_header_length);
716+
}
717+
} else if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
718+
if (ie_header_mask.ea_ie) {
719+
uint8_t eapol_auth_eui64[8];
720+
ws_pae_controller_border_router_addr_read(base->interface_ptr, eapol_auth_eui64);
721+
ptr = ws_wh_ea_write(ptr, eapol_auth_eui64);
722+
}
688723
}
689724

725+
726+
690727
message->ie_vector_list[0].iovLen = ie_header_length;
691728
message->ie_ext.headerIeVectorList = &message->ie_vector_list[0];
692729
message->ie_ext.headerIovLength = 1;

source/6LoWPAN/ws/ws_pae_controller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int8_t ws_pae_controller_certificate_chain_set(const arm_certificate_chain_entry
114114
int8_t ws_pae_controller_border_router_addr_write(protocol_interface_info_entry_t *interface_ptr, uint8_t *eui_64);
115115

116116
/**
117-
* ws_pae_controller_bored_router_addr_read read border router address
117+
* ws_pae_controller_border_router_addr_read read border router address
118118
*
119119
* \param interface_ptr interface
120120
* \param eui_64 pointer to EUI-64
@@ -123,7 +123,7 @@ int8_t ws_pae_controller_border_router_addr_write(protocol_interface_info_entry_
123123
* \return >= 0 success
124124
*
125125
*/
126-
int8_t ws_pae_controller_bored_router_addr_read(protocol_interface_info_entry_t *interface_ptr, uint8_t *eui_64);
126+
int8_t ws_pae_controller_border_router_addr_read(protocol_interface_info_entry_t *interface_ptr, uint8_t *eui_64);
127127

128128
/**
129129
* ws_pae_controller_key_insert new GTK key available callback

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ TEST_SRC_FILES = \
2828
../../stub/adaptation_interface_stub.c \
2929
../../stub/mac_ie_lib_stub.c \
3030
../../stub/ws_ie_lib_stub.c \
31+
../../stub/ws_bootstrap_stub.c \
3132
../../stub/ws_mpx_header_stub.c \
3233
../../stub/ws_neighbour_class_stub.c \
34+
../../stub/ws_pae_controller_stub.c \
3335
../../stub/mac_neighbor_table_stub.c \
3436
../../stub/iphc_decompress_stub.c \
3537
../../stub/fhss_config_stub.c \

test/nanostack/unittest/stub/ws_bootstrap_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ void ws_secondary_parent_update(protocol_interface_info_entry_t *interface)
6666
{
6767

6868
}
69+
70+
bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur)
71+
{
72+
return false;
73+
}

test/nanostack/unittest/stub/ws_ie_lib_stub.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ bool ws_wh_utt_read(uint8_t *data, uint16_t length, struct ws_utt_ie *utt_ie)
164164
return ws_ie_lib_stub.utt_bool_value;
165165
}
166166

167+
bool ws_wh_ea_read(uint8_t *data, uint16_t length, uint8_t *eui64)
168+
{
169+
return ws_ie_lib_stub.utt_bool_value;
170+
}
171+
172+
uint8_t *ws_wh_ea_write(uint8_t *ptr, uint8_t *eui64)
173+
{
174+
return ptr + 11;
175+
}
176+
167177
bool ws_wh_bt_read(uint8_t *data, uint16_t length, struct ws_bt_ie *bt_ie)
168178
{
169179
*bt_ie = ws_ie_lib_stub.bt_ie;

test/nanostack/unittest/stub/ws_pae_controller_stub.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,13 @@ void ws_pae_controller_timer(uint16_t ticks)
4343
{
4444

4545
}
46+
47+
int8_t ws_pae_controller_border_router_addr_write(protocol_interface_info_entry_t *interface_ptr, uint8_t *eui_64)
48+
{
49+
return 0;
50+
}
51+
52+
int8_t ws_pae_controller_border_router_addr_read(protocol_interface_info_entry_t *interface_ptr, uint8_t *eui_64)
53+
{
54+
return 0;
55+
}

0 commit comments

Comments
 (0)