@@ -84,12 +84,16 @@ static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *c
84
84
static bool ws_bootstrap_state_wait_rpl (struct protocol_interface_info_entry * cur );
85
85
static int8_t ws_bootsrap_event_trig (ws_bootsrap_event_type_e event_type , int8_t interface_id , arm_library_event_priority_e priority , void * event_data );
86
86
87
- static mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
87
+ static bool ws_bootstrap_neighbor_info_request (struct protocol_interface_info_entry * interface , const uint8_t * mac_64 , llc_neighbour_req_t * neighbor_buffer , bool request_new );
88
+
89
+ mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
88
90
{
89
91
mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover (interface -> mac_parameters -> mac_neighbor_table , src64 , MAC_ADDR_MODE_64_BIT );
90
- if (! neighbor ) {
91
- neighbor = mac_neighbor_table_entry_allocate ( interface -> mac_parameters -> mac_neighbor_table , src64 ) ;
92
+ if (neighbor ) {
93
+ return neighbor ;
92
94
}
95
+
96
+ neighbor = mac_neighbor_table_entry_allocate (interface -> mac_parameters -> mac_neighbor_table , src64 );
93
97
if (!neighbor ) {
94
98
return NULL ;
95
99
}
@@ -101,21 +105,6 @@ static mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protoco
101
105
return neighbor ;
102
106
}
103
107
104
- static ws_neighbor_class_entry_t * ws_bootstrap_neighbor_add (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
105
- {
106
- mac_neighbor_table_entry_t * neighbor = ws_bootstrap_mac_neighbor_add (interface , src64 );
107
- if (!neighbor ) {
108
- return NULL ;
109
- }
110
-
111
- ws_neighbor_class_entry_t * ws_neighbor = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , neighbor -> index );
112
- if (!ws_neighbor ) {
113
- mac_neighbor_table_neighbor_remove (interface -> mac_parameters -> mac_neighbor_table , neighbor );
114
- return NULL ;
115
- }
116
- return ws_neighbor ;
117
- }
118
-
119
108
static void ws_bootstrap_neighbor_delete (struct protocol_interface_info_entry * interface , uint8_t attribute_index )
120
109
{
121
110
mac_helper_devicetable_remove (interface -> mac_api , attribute_index );
@@ -487,18 +476,17 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
487
476
tr_error ("No broadcast schedule" );
488
477
return ;
489
478
}
490
-
491
- ws_neighbor_class_entry_t * neighbor = ws_bootstrap_neighbor_add (cur , data -> SrcAddr );
492
- if (!neighbor ) {
479
+ llc_neighbour_req_t neighbor_info ;
480
+ if (!ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , true) ) {
493
481
return ;
494
482
}
495
483
496
- etx_lqi_dbm_update (cur -> id , data -> mpduLinkQuality , data -> signal_dbm , ws_neighbor_class_entry_index_get ( & cur -> ws_info -> neighbor_storage , neighbor ) );
484
+ etx_lqi_dbm_update (cur -> id , data -> mpduLinkQuality , data -> signal_dbm , neighbor_info . neighbor -> index );
497
485
//Update Neighbor Broadcast and Unicast Parameters
498
- ws_neighbor_class_neighbor_unicast_time_info_update (neighbor , ws_utt , data -> timestamp );
499
- ws_neighbor_class_neighbor_unicast_schedule_set (neighbor , ws_us );
500
- ws_neighbor_class_neighbor_broadcast_time_info_update (neighbor , & ws_bt_ie , data -> timestamp );
501
- ws_neighbor_class_neighbor_broadcast_schedule_set (neighbor , & ws_bs_ie );
486
+ ws_neighbor_class_neighbor_unicast_time_info_update (neighbor_info . ws_neighbor , ws_utt , data -> timestamp );
487
+ ws_neighbor_class_neighbor_unicast_schedule_set (neighbor_info . ws_neighbor , ws_us );
488
+ ws_neighbor_class_neighbor_broadcast_time_info_update (neighbor_info . ws_neighbor , & ws_bt_ie , data -> timestamp );
489
+ ws_neighbor_class_neighbor_broadcast_schedule_set (neighbor_info . ws_neighbor , & ws_bs_ie );
502
490
503
491
if (cur -> ws_info -> configuration_learned &&
504
492
common_serial_number_greater_16 (cur -> ws_info -> pan_configuration .pan_version , pan_version )) {
@@ -537,7 +525,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
537
525
538
526
cur -> ws_info -> hopping_schdule .channel_function = ws_bs_ie .channel_function ;
539
527
// TODO: Restart unicast schedule if configuration changed
540
- ns_fhss_ws_set_parent (cur -> ws_info -> fhss_api , data -> SrcAddr , & neighbor -> fhss_data .bc_timing_info );
528
+ ns_fhss_ws_set_parent (cur -> ws_info -> fhss_api , data -> SrcAddr , & neighbor_info . ws_neighbor -> fhss_data .bc_timing_info );
541
529
542
530
if (!cur -> ws_info -> configuration_learned ) {
543
531
// Generate own hopping schedules Follow first parent broadcast and plans and also use same unicast dwell
@@ -563,13 +551,14 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
563
551
*
564
552
*/
565
553
566
- ws_neighbor_class_entry_t * neighbor = ws_bootstrap_neighbor_add ( cur , data -> SrcAddr ) ;
567
- if (!neighbor ) {
554
+ llc_neighbour_req_t neighbor_info ;
555
+ if (!ws_bootstrap_neighbor_info_request ( cur , data -> SrcAddr , & neighbor_info , true) ) {
568
556
return ;
569
557
}
570
558
571
- ws_neighbor_class_neighbor_unicast_time_info_update (neighbor , ws_utt , data -> timestamp );
572
- ws_neighbor_class_neighbor_unicast_schedule_set (neighbor , ws_us );
559
+ etx_lqi_dbm_update (cur -> id , data -> mpduLinkQuality , data -> signal_dbm , neighbor_info .neighbor -> index );
560
+ ws_neighbor_class_neighbor_unicast_time_info_update (neighbor_info .ws_neighbor , ws_utt , data -> timestamp );
561
+ ws_neighbor_class_neighbor_unicast_schedule_set (neighbor_info .ws_neighbor , ws_us );
573
562
574
563
/*
575
564
* A consistent transmission is defined as a PAN Configuration Solicit with
@@ -665,6 +654,35 @@ static void ws_bootstrap_asynch_confirm(struct protocol_interface_info_entry *in
665
654
(void )asynch_message ;
666
655
}
667
656
657
+ static bool ws_bootstrap_neighbor_info_request (struct protocol_interface_info_entry * interface , const uint8_t * mac_64 , llc_neighbour_req_t * neighbor_buffer , bool request_new )
658
+ {
659
+ neighbor_buffer -> neighbor = mac_neighbor_table_address_discover (interface -> mac_parameters -> mac_neighbor_table , mac_64 , ADDR_802_15_4_LONG );
660
+ if (neighbor_buffer -> neighbor ) {
661
+ neighbor_buffer -> ws_neighbor = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , neighbor_buffer -> neighbor -> index );
662
+ if (!neighbor_buffer -> ws_neighbor ) {
663
+ return false;
664
+ }
665
+ return true;
666
+ }
667
+ if (!request_new ) {
668
+ return false;
669
+ }
670
+
671
+ neighbor_buffer -> neighbor = ws_bootstrap_mac_neighbor_add (interface , mac_64 );
672
+
673
+ if (!neighbor_buffer -> neighbor ) {
674
+ return false;
675
+ }
676
+
677
+ neighbor_buffer -> ws_neighbor = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , neighbor_buffer -> neighbor -> index );
678
+ if (!neighbor_buffer -> ws_neighbor ) {
679
+ mac_helper_devicetable_remove (interface -> mac_api , neighbor_buffer -> neighbor -> index );
680
+ mac_neighbor_table_neighbor_remove (interface -> mac_parameters -> mac_neighbor_table , neighbor_buffer -> neighbor );
681
+ return false;
682
+ }
683
+ return true;
684
+ }
685
+
668
686
669
687
static void ws_neighbor_entry_remove_notify (mac_neighbor_table_entry_t * entry_ptr , void * user_data )
670
688
{
@@ -761,7 +779,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
761
779
goto init_fail ;
762
780
}
763
781
764
- ws_llc_create (cur , & ws_bootstrap_asynch_ind , & ws_bootstrap_asynch_confirm );
782
+ ws_llc_create (cur , & ws_bootstrap_asynch_ind , & ws_bootstrap_asynch_confirm , & ws_bootstrap_neighbor_info_request );
765
783
766
784
mpx_api_t * mpx_api = ws_llc_mpx_api_get (cur );
767
785
if (!mpx_api ) {
@@ -1227,13 +1245,13 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
1227
1245
tr_info ("select network" );
1228
1246
1229
1247
// Add EAPOL neighbour
1230
- ws_neighbor_class_entry_t * neighbor = ws_bootstrap_neighbor_add ( cur , cur -> ws_info -> parent_info . addr ) ;
1231
- if (!neighbor ) {
1248
+ llc_neighbour_req_t neighbor_info ;
1249
+ if (!ws_bootstrap_neighbor_info_request ( cur , cur -> ws_info -> parent_info . addr , & neighbor_info , true) ) {
1232
1250
return ;
1233
1251
}
1234
1252
1235
- ws_neighbor_class_neighbor_unicast_time_info_update (neighbor , & cur -> ws_info -> parent_info .ws_utt , cur -> ws_info -> parent_info .timestamp );
1236
- ws_neighbor_class_neighbor_unicast_schedule_set (neighbor , & cur -> ws_info -> parent_info .ws_us );
1253
+ ws_neighbor_class_neighbor_unicast_time_info_update (neighbor_info . ws_neighbor , & cur -> ws_info -> parent_info .ws_utt , cur -> ws_info -> parent_info .timestamp );
1254
+ ws_neighbor_class_neighbor_unicast_schedule_set (neighbor_info . ws_neighbor , & cur -> ws_info -> parent_info .ws_us );
1237
1255
1238
1256
ws_bootstrap_network_information_learn (cur );
1239
1257
ws_bootstrap_fhss_activate (cur );
0 commit comments