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

Commit 33398ef

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Added Neighbor connected and trusted state update for wisun
NA message handler automatically added connected state when wisun bootstrap is enabled. LLC layer add trusted state to neighbor when received secured message. Change-Id: Ia950532a3bcbe7bf1238857396fdcf945f8dd1f0
1 parent 24aa802 commit 33398ef

File tree

8 files changed

+49
-12
lines changed

8 files changed

+49
-12
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void protocol_6lowpan_stack(buffer_t *b)
167167
case B_TO_PHY:
168168
b = lowpan_adaptation_data_process_tx_preprocess(cur, b);
169169
if (lowpan_adaptation_interface_tx(cur, b) != 0) {
170-
tr_error("Adaptaion Layer Data req fail");
170+
tr_error("Adaptation Layer Data req fail");
171171
}
172172
b = NULL;
173173
break;

source/6LoWPAN/MAC/mac_pairwise_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui
272272
return -1;
273273
}
274274

275-
mac_entry->trusted_device = true;
275+
mac_neighbor_table_trusted_neighbor(interface->mac_parameters->mac_neighbor_table, mac_entry, true);
276276
mac_entry->mac16 = 0xffff;
277277

278278
//Allocate key description

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,10 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
776776
{
777777
uint32_t time_from_start = entry_ptr->link_lifetime - entry_ptr->lifetime;
778778
bool activate_nud = false;
779-
if ((WS_NEIGHBOR_NUD_TIMEOUT > entry_ptr->link_lifetime) && (time_from_start > entry_ptr->link_lifetime / 2)) {
780-
//Trig allways at middle way
781-
activate_nud = true;
782-
} else if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT) {
779+
if ((entry_ptr->link_role == PRIORITY_PARENT_NEIGHBOUR || entry_ptr->link_role == SECONDARY_PARENT_NEIGHBOUR) && time_from_start > WS_NEIGHBOR_NUD_TIMEOUT) {
783780
activate_nud = true;
784781
}
782+
785783
if (!activate_nud) {
786784
return false;
787785
}
@@ -793,7 +791,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
793791
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
794792
memcpy(ll_target + 8, entry_ptr->mac64, 8);
795793
ll_target[8] ^= 2;
796-
tr_debug("NUD generate NS");
794+
tr_debug("NUD generate NS %u", entry_ptr->index);
797795
buffer_t * buffer = icmpv6_build_ns(cur, ll_target, NULL, true, false, NULL);
798796
if (!buffer) {
799797
return false;

source/6LoWPAN/ws/ws_common.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string.h>
1818
#include "nsconfig.h"
1919
#include "ns_types.h"
20+
#include "ns_trace.h"
2021
#include "randLIB.h"
2122
#include <ns_list.h>
2223
#include <nsdynmemLIB.h>
@@ -25,6 +26,7 @@
2526
#include "6LoWPAN/ws/ws_common.h"
2627
#include "6LoWPAN/ws/ws_bootstrap.h"
2728
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
29+
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
2830
#include "ws_management_api.h"
2931

3032
#ifdef HAVE_WS
@@ -163,6 +165,20 @@ void ws_common_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seco
163165
ws_bootstrap_seconds_timer(cur, seconds);
164166
}
165167

168+
void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
169+
{
170+
//Neighbor connectected update
171+
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, ll_address, false, NULL);
172+
if (mac_neighbor) {
173+
if (mac_neighbor->nud_active) {
174+
tr_debug("NUD Response %u", mac_neighbor->index);
175+
mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, mac_neighbor, mac_neighbor->link_lifetime);
176+
}
177+
178+
mac_neighbor_table_neighbor_connected(cur->mac_parameters->mac_neighbor_table, mac_neighbor);
179+
}
180+
}
181+
166182

167183
#endif // HAVE_WS
168184

source/6LoWPAN/ws/ws_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur);
7070

7171
void ws_common_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
7272

73+
void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
74+
7375
#define ws_info(cur) ((cur)->ws_info)
7476
#else
75-
7677
#define ws_info(cur) ((ws_info_t *) NULL)
7778
#define ws_common_seconds_timer(cur, seconds)
79+
#define ws_common_neighbor_update(cur, ll_address) ((void) 0)
7880

7981

8082
#endif //HAVE_WS

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
383383
case MLME_SUCCESS:
384384
case MLME_TX_NO_ACK:
385385
case MLME_NO_DATA:
386-
if (data->status == MLME_SUCCESS ) {
386+
if (data->status == MLME_SUCCESS || data->status == MLME_NO_DATA) {
387387
success = true;
388388
}
389389

@@ -393,7 +393,10 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
393393
ws_utt_ie_t ws_utt;
394394
if (ws_wh_utt_read(conf_data->headerIeList, conf_data->headerIeListLength, &ws_utt)) {
395395
//UTT header
396-
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor_info.neighbor, neighbor_info.neighbor->link_lifetime);
396+
if (success) {
397+
neighbor_info.neighbor->lifetime = neighbor_info.neighbor->link_lifetime;
398+
}
399+
397400
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, &ws_utt, data->timestamp);
398401
}
399402

@@ -436,6 +439,7 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
436439

437440
static void ws_llc_ack_data_req_ext(const mac_api_t* api, mcps_ack_data_payload_t *data, int8_t rssi, uint8_t lqi)
438441
{
442+
(void) lqi;
439443
llc_data_base_t *base = ws_llc_discover_by_mac(api);
440444
if (!base) {
441445
return;
@@ -522,13 +526,17 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
522526

523527
//Refresh Neighbor if unicast
524528
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
525-
//tr_debug("Refresh neigh index %u", neighbor_info.neighbor->index);
526-
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor_info.neighbor, neighbor_info.neighbor->link_lifetime);
529+
neighbor_info.neighbor->lifetime = neighbor_info.neighbor->link_lifetime;
527530
etx_lqi_dbm_update(interface->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
528531
}
529532
if (ws_utt.message_type == WS_FT_DATA) {
530533
// Calculate RSL for all UDATA packages heard
531534
ws_neighbor_class_rsl_in_calculate(neighbor_info.ws_neighbor, data->signal_dbm);
535+
536+
if (data->Key.SecurityLevel) {
537+
//SET trusted state
538+
mac_neighbor_table_trusted_neighbor(interface->mac_parameters->mac_neighbor_table, neighbor_info.neighbor, true);
539+
}
532540
}
533541

534542
// Discover MPX

source/Common_Protocols/icmpv6.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include "common_functions.h"
4545
#include "6LoWPAN/ND/nd_router_object.h"
4646
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h"
47+
#include "6LoWPAN/ws/ws_common_defines.h"
48+
#include "6LoWPAN/ws/ws_common.h"
4749

4850
#define TRACE_GROUP "icmp"
4951

@@ -1588,7 +1590,12 @@ static buffer_t *icmpv6_na_handler(buffer_t *buf)
15881590
buf->dst_sa.addr_type = ADDR_NONE;
15891591
}
15901592

1593+
15911594
ipv6_neighbour_update_from_na(&cur->ipv6_neighbour_cache, neighbour_entry, flags, buf->dst_sa.addr_type, buf->dst_sa.address);
1595+
if (ws_info(cur) && neighbour_entry->state == IP_NEIGHBOUR_REACHABLE) {
1596+
tr_debug("NA neigh update");
1597+
ws_common_neighbor_update(cur, target);
1598+
}
15921599

15931600
drop:
15941601
return buffer_free(buf);

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur)
4141
{
4242
return ws_common_stub.int8_value;
4343
}
44+
45+
void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
46+
{
47+
(void) cur;
48+
(void) ll_address;
49+
}

0 commit comments

Comments
 (0)