@@ -77,7 +77,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
7777static bool ws_bootstrap_state_active (struct protocol_interface_info_entry * cur );
7878static bool ws_bootstrap_state_discovery (struct protocol_interface_info_entry * cur );
7979static bool ws_bootstrap_state_wait_rpl (struct protocol_interface_info_entry * cur );
80-
80+ 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 );
8181static mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
8282{
8383 mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover (interface -> mac_parameters -> mac_neighbor_table , src64 , MAC_ADDR_MODE_64_BIT );
@@ -94,30 +94,6 @@ static mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_in
9494}
9595
9696
97- static void ws_bootstrap_address_registration_ns_send (struct protocol_interface_info_entry * interface , const struct if_address_entry * addr )
98- {
99- aro_t aro ;
100- buffer_t * buf ;
101-
102- tr_debug ("Send ARO" );
103-
104- aro .status = ARO_SUCCESS ;
105- aro .present = true;
106- aro .lifetime = addr -> preferred_lifetime ;
107- memcpy (aro .eui64 , interface -> mac , 8 );
108-
109- /* Fill address to be registered */
110- memcpy (& interface -> if_6lowpan_dad_process .address , addr -> address , 16 );
111-
112- ns_list_foreach (struct rpl_instance , instance , & interface -> rpl_domain -> instances ) {
113- const uint8_t * preferred_parent = rpl_control_preferred_parent_addr (instance , false);
114- if (preferred_parent ) {
115- buf = icmpv6_build_ns (interface , preferred_parent , addr -> address , true, false, & aro );
116- protocol_push (buf );
117- }
118- }
119- }
120-
12197
12298static void ws_bootstrap_address_notification_cb (struct protocol_interface_info_entry * interface , const struct if_address_entry * addr , if_address_callback_t reason )
12399{
@@ -127,12 +103,12 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
127103 }
128104
129105 if (reason == ADDR_CALLBACK_DAD_COMPLETE ) {
130- // When SLAAC address is created, send NS with ARO to parent
131- ws_bootstrap_address_registration_ns_send (interface , addr );
106+ ws_bootsrap_event_trig (WS_ADDRESS_ADDED , interface -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT , (void * )addr );
132107 } else if (reason == ADDR_CALLBACK_DELETED ) {
133108 // What to do?
134109 }
135110}
111+
136112static int ws_bootstrap_tasklet_init (protocol_interface_info_entry_t * cur )
137113{
138114 if (cur -> bootStrapId < 0 ) {
@@ -149,13 +125,14 @@ static int ws_bootstrap_tasklet_init(protocol_interface_info_entry_t *cur)
149125 return 0 ;
150126}
151127
152- static int8_t ws_bootsrap_event_trig (ws_bootsrap_event_type_e event_type , int8_t interface_id , arm_library_event_priority_e priority )
128+ 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 )
153129{
154130 arm_event_s event = {
155131 .receiver = interface_id ,
156132 .sender = 0 ,
157133 .event_type = event_type ,
158134 .priority = priority ,
135+ .data_ptr = event_data ,
159136 };
160137 return eventOS_event_send (& event );
161138}
@@ -912,23 +889,23 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
912889 * */
913890void ws_bootstrap_event_discovery_start (protocol_interface_info_entry_t * cur )
914891{
915- ws_bootsrap_event_trig (WS_DISCOVERY_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT );
892+ ws_bootsrap_event_trig (WS_DISCOVERY_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT , NULL );
916893}
917894void ws_bootstrap_event_configuration_start (protocol_interface_info_entry_t * cur )
918895{
919- ws_bootsrap_event_trig (WS_CONFIGURATION_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT );
896+ ws_bootsrap_event_trig (WS_CONFIGURATION_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT , NULL );
920897}
921898void ws_bootstrap_event_authentication_start (protocol_interface_info_entry_t * cur )
922899{
923- ws_bootsrap_event_trig (WS_AUTHENTICATION_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT );
900+ ws_bootsrap_event_trig (WS_AUTHENTICATION_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT , NULL );
924901}
925902void ws_bootstrap_event_operation_start (protocol_interface_info_entry_t * cur )
926903{
927- ws_bootsrap_event_trig (WS_OPERATION_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT );
904+ ws_bootsrap_event_trig (WS_OPERATION_START , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT , NULL );
928905}
929906void ws_bootstrap_event_routing_ready (protocol_interface_info_entry_t * cur )
930907{
931- ws_bootsrap_event_trig (WS_ROUTING_READY , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT );
908+ ws_bootsrap_event_trig (WS_ROUTING_READY , cur -> bootStrapId , ARM_LIB_LOW_PRIORITY_EVENT , NULL );
932909}
933910
934911
@@ -1010,6 +987,17 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
1010987 ws_llc_asynch_request (cur , & async_req );
1011988}
1012989
990+ static bool ws_bootstrap_address_registration_ongoing (protocol_interface_info_entry_t * cur )
991+ {
992+ ns_list_foreach (if_address_entry_t , addr , & cur -> ip_addresses ) {
993+ if (addr -> addr_reg_pend != 0 ) {
994+ return true;
995+ }
996+ }
997+
998+ return false;
999+ }
1000+
10131001static void ws_bootstrap_event_handler (arm_event_s * event )
10141002{
10151003 ws_bootsrap_event_type_e event_type ;
@@ -1085,6 +1073,11 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
10851073 tr_info ("Routing ready" );
10861074 ws_bootstrap_state_change (cur , ER_BOOTSRAP_DONE );
10871075 break ;
1076+ case WS_ADDRESS_ADDED :
1077+ if (!ws_bootstrap_address_registration_ongoing (cur )) {
1078+ rpl_control_register_address (cur , (if_address_entry_t * ) event -> data_ptr );
1079+ }
1080+ break ;
10881081 default :
10891082 tr_err ("Invalid event received" );
10901083 break ;
0 commit comments