Skip to content

Commit fb1b163

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Pan coordinator blacklist update
Added support to clean coordinator blacklist Integrated free call to stack after pana if NO_MLE is true and after link request state Added blacklist coordinator also after MLE link request fail state. (cherry picked from commit 7911211e72305ec7cd104bfcbeed89cea0d44b24)
1 parent 39fe6ba commit fb1b163

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static void protocol_6lowpan_neighbor_information_remove(int8_t interface_id, ml
100100
static int8_t protocol_6lowpan_host_challenge(int8_t interface_id, const uint8_t *mac64);
101101
static int8_t protocol_6lowpan_router_challenge(int8_t interface_id, const uint8_t *mac64);
102102
static void protocol_6lowpan_address_reg_ready(protocol_interface_info_entry_t *cur_interface);
103+
static void coordinator_black_list(protocol_interface_info_entry_t *cur);
103104

104105
static mle_6lowpan_data_t *mle_6lowpan_data;
105106

@@ -814,6 +815,7 @@ static bool mle_parent_link_req_cb(int8_t interface_id, uint16_t msgId, bool use
814815
if (cur->nwk_bootstrap_state == ER_MLE_LINK_REQ) {
815816
//Enter ND scan
816817
bootsrap_next_state_kick(ER_SCAN, cur);
818+
pan_coordinator_blacklist_free(&cur->pan_cordinator_black_list);
817819
}
818820
#ifdef HAVE_RPL
819821
else if (cur->nwk_bootstrap_state == ER_ROUTER_SYNCH) {
@@ -842,6 +844,9 @@ static bool mle_parent_link_req_cb(int8_t interface_id, uint16_t msgId, bool use
842844
case ER_MLE_LINK_REQ:
843845
case ER_MLE_LINK_ADDRESS_SYNCH:
844846
case ER_MLE_LINK_SHORT_SYNCH:
847+
if (cur->nwk_bootstrap_state == ER_MLE_LINK_REQ) {
848+
coordinator_black_list(cur);
849+
}
845850
tr_debug("Link synch fail %u", cur->nwk_bootstrap_state);
846851
bootsrap_next_state_kick(ER_BOOTSTRAP_CONNECTION_DOWN, cur);
847852
break;
@@ -2283,15 +2288,8 @@ static void nwk_6lowpan_bootsrap_pana_authentication_start(protocol_interface_in
22832288

22842289
#endif
22852290

2286-
static void nwk_6lowpan_network_authentication_fail(protocol_interface_info_entry_t *cur)
2291+
static void coordinator_black_list(protocol_interface_info_entry_t *cur)
22872292
{
2288-
nwk_scan_params_t *scan_params =
2289-
&cur->mac_parameters->nwk_scan_params;
2290-
2291-
tr_warn("Pana Auhth er");
2292-
2293-
scan_params->nwk_cur_active = mac_helper_free_pan_descriptions(scan_params->nwk_cur_active);
2294-
//Black List coordinator
22952293
uint8_t coord_pan_address[10];
22962294
addrtype_t cord_adr_type = mac_helper_coordinator_address_get(cur, coord_pan_address +2);
22972295

@@ -2304,6 +2302,18 @@ static void nwk_6lowpan_network_authentication_fail(protocol_interface_info_entr
23042302

23052303
pan_cordinator_blacklist_pan_set(&cur->pan_cordinator_black_list, coord_pan_address, 300);
23062304
}
2305+
}
2306+
2307+
static void nwk_6lowpan_network_authentication_fail(protocol_interface_info_entry_t *cur)
2308+
{
2309+
nwk_scan_params_t *scan_params =
2310+
&cur->mac_parameters->nwk_scan_params;
2311+
2312+
tr_warn("Pana Auhth er");
2313+
2314+
scan_params->nwk_cur_active = mac_helper_free_pan_descriptions(scan_params->nwk_cur_active);
2315+
//Black List coordinator
2316+
coordinator_black_list(cur);
23072317

23082318
nwk_bootsrap_state_update(ARM_NWK_AUHTENTICATION_FAIL, cur);
23092319
}
@@ -2379,6 +2389,7 @@ static void nwk_6lowpan_network_authentication_done(protocol_interface_info_entr
23792389
tr_debug("Link request start fail");
23802390
}
23812391
#else
2392+
pan_coordinator_blacklist_free(&cur->pan_cordinator_black_list);
23822393
cur->nwk_bootstrap_state = ER_SCAN;
23832394
nwk_6lowpan_router_scan_state(cur);
23842395
#endif

source/Service_Libs/pan_blacklist/pan_blacklist.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ void pan_coordinator_blacklist_time_update(pan_coordinator_blaclist_cache_s *lis
9191
}
9292
}
9393

94-
94+
void pan_coordinator_blacklist_free(pan_coordinator_blaclist_cache_s *list_ptr)
95+
{
96+
ns_list_foreach_safe(pan_coordinator_blacklist_entry_t, cur_ptr, &list_ptr->head) {
97+
ns_list_remove(&list_ptr->head, cur_ptr);
98+
ns_dyn_mem_free(cur_ptr);
99+
}
100+
}
95101

96102
bool pan_blacklist_filter(pan_blaclist_cache_s *list_ptr, uint16_t panid)
97103
{

source/Service_Libs/pan_blacklist/pan_blacklist_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ void pan_blacklist_cache_init(pan_blaclist_cache_s *blacklist_cache);
5757

5858
void pan_coordinator_blacklist_cache_init(pan_coordinator_blaclist_cache_s *blacklist_cache);
5959

60+
void pan_coordinator_blacklist_free(pan_coordinator_blaclist_cache_s *list_ptr);
61+
6062
void pan_blacklist_pan_set(pan_blaclist_cache_s *list_ptr, uint16_t panid, uint16_t timeout);
6163

6264
void pan_cordinator_blacklist_pan_set(pan_coordinator_blaclist_cache_s *list_ptr, uint8_t *cordinator_data, uint16_t timeout);

test/nanostack/unittest/stub/pan_blacklist_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ void pan_cordinator_blacklist_pan_set(pan_coordinator_blaclist_cache_s *list_ptr
6363
{
6464

6565
}
66+
67+
void pan_coordinator_blacklist_free(pan_coordinator_blaclist_cache_s *list_ptr)
68+
{
69+
70+
}

0 commit comments

Comments
 (0)