63
63
#include "Service_Libs/nd_proxy/nd_proxy.h"
64
64
#include "Service_Libs/blacklist/blacklist.h"
65
65
#include "platform/topo_trace.h"
66
+ #include "dhcp_service_api.h"
66
67
#include "libDHCPv6/libDHCPv6.h"
67
68
#include "DHCPv6_client/dhcpv6_client_api.h"
68
69
#include "ws_management_api.h"
@@ -136,21 +137,54 @@ mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interf
136
137
}
137
138
// TODO only call these for new neighbour
138
139
mlme_device_descriptor_t device_desc ;
139
- neighbor -> lifetime = WS_NEIGHBOR_LINK_TIMEOUT ;
140
- neighbor -> link_lifetime = WS_NEIGHBOR_LINK_TIMEOUT ;
141
- tr_debug ("Added new neighbor %s : index:%u" , trace_array (src64 , 8 ), neighbor -> index );
140
+ neighbor -> lifetime = WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME ;
141
+ neighbor -> link_lifetime = WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME ;
142
142
mac_helper_device_description_write (interface , & device_desc , neighbor -> mac64 , neighbor -> mac16 , 0 , false);
143
143
mac_helper_devicetable_set (& device_desc , interface , neighbor -> index , interface -> mac_parameters -> mac_default_key_index , true);
144
+
144
145
return neighbor ;
145
146
}
146
147
148
+ void ws_bootstrap_neighbor_set_stable (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
149
+ {
150
+ mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), src64 , MAC_ADDR_MODE_64_BIT );
151
+
152
+ if (neighbor && neighbor -> link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT ) {
153
+ neighbor -> lifetime = WS_NEIGHBOR_LINK_TIMEOUT ;
154
+ neighbor -> link_lifetime = WS_NEIGHBOR_LINK_TIMEOUT ;
155
+ tr_info ("Added new neighbor %s : index:%u" , trace_array (src64 , 8 ), neighbor -> index );
156
+ }
157
+ }
158
+
159
+ void ws_bootstrap_mac_neighbor_short_time_set (struct protocol_interface_info_entry * interface , const uint8_t * src64 , uint32_t valid_time )
160
+ {
161
+ mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), src64 , MAC_ADDR_MODE_64_BIT );
162
+
163
+ if (neighbor && neighbor -> link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT ) {
164
+ //mlme_device_descriptor_t device_desc;
165
+ neighbor -> lifetime = valid_time ;
166
+ neighbor -> link_lifetime = valid_time ;
167
+ tr_debug ("Set short response neighbor %s : index:%u" , trace_array (src64 , 8 ), neighbor -> index );
168
+ }
169
+ }
170
+
147
171
static void ws_bootstrap_neighbor_delete (struct protocol_interface_info_entry * interface , mac_neighbor_table_entry_t * entry_ptr )
148
172
{
149
173
mac_helper_devicetable_remove (interface -> mac_api , entry_ptr -> index , entry_ptr -> mac64 );
150
174
etx_neighbor_remove (interface -> id , entry_ptr -> index , entry_ptr -> mac64 );
151
175
ws_neighbor_class_entry_remove (& interface -> ws_info -> neighbor_storage , entry_ptr -> index );
152
176
}
153
177
178
+ void ws_bootstrap_mac_neighbor_temporary_remove (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
179
+ {
180
+ mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), src64 , MAC_ADDR_MODE_64_BIT );
181
+
182
+ if (neighbor && neighbor -> link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT ) {
183
+ tr_debug ("Remove temporary neighbour %s" , trace_array (src64 , 8 ));
184
+ mac_neighbor_table_neighbor_remove (mac_neighbor_info (interface ), neighbor );
185
+ }
186
+ }
187
+
154
188
static void ws_bootstap_eapol_neigh_entry_allocate (struct protocol_interface_info_entry * interface )
155
189
{
156
190
uint8_t mac_64 [8 ];
@@ -161,6 +195,7 @@ static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_inf
161
195
if (!mac_entry ) {
162
196
return ;
163
197
}
198
+ ws_bootstrap_neighbor_set_stable (interface , mac_64 );
164
199
mac_entry -> lifetime = 0xffffffff ;
165
200
mac_entry -> link_lifetime = 0xffffffff ;
166
201
ws_neighbor_class_entry_t * ws_neigh = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , mac_entry -> index );
@@ -838,6 +873,23 @@ bool ws_bootstrap_nd_ns_transmit(protocol_interface_info_entry_t *cur, ipv6_neig
838
873
return true;
839
874
}
840
875
876
+ static void ws_bootstrap_dhcp_neighbour_update_cb (int8_t interface_id , uint8_t ll_addr [static 16 ])
877
+ {
878
+ if (memcmp (ll_addr , ADDR_LINK_LOCAL_PREFIX , 8 )) {
879
+ return ;
880
+ }
881
+
882
+ protocol_interface_info_entry_t * cur = protocol_stack_interface_info_get_by_id (interface_id );
883
+ if (!cur ) {
884
+ return ;
885
+ }
886
+
887
+ uint8_t mac64 [8 ];
888
+ memcpy (mac64 , ll_addr + 8 , 8 );
889
+ mac64 [0 ] ^= 2 ;
890
+ ws_bootstrap_mac_neighbor_short_time_set (cur , mac64 , WS_NEIGHBOUR_DHCP_ENTRY_LIFETIME );
891
+ }
892
+
841
893
static int8_t ws_bootstrap_up (protocol_interface_info_entry_t * cur )
842
894
{
843
895
int8_t ret_val = -1 ;
@@ -886,6 +938,7 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
886
938
cur -> if_ns_transmit = ws_bootstrap_nd_ns_transmit ;
887
939
888
940
dhcp_client_init (cur -> id , DHCPV6_DUID_HARDWARE_IEEE_802_NETWORKS_TYPE );
941
+ dhcp_service_link_local_rx_cb_set (cur -> id , ws_bootstrap_dhcp_neighbour_update_cb );
889
942
dhcp_client_configure (cur -> id , true, true, true); //RENEW uses SOLICIT, Interface will use 1 instance for address get, IAID address hint is not used.
890
943
dhcp_client_solicit_timeout_set (cur -> id , WS_DHCP_SOLICIT_TIMEOUT , WS_DHCP_SOLICIT_MAX_RT , WS_DHCP_SOLICIT_MAX_RC );
891
944
@@ -1434,6 +1487,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
1434
1487
if (!neighbour_pointer_valid ) {
1435
1488
return ;
1436
1489
}
1490
+ ws_bootstrap_neighbor_set_stable (cur , data -> SrcAddr );
1437
1491
}
1438
1492
1439
1493
if (neighbour_pointer_valid ) {
@@ -1707,6 +1761,10 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
1707
1761
continue ;
1708
1762
}
1709
1763
1764
+ if (cur -> link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT ) {
1765
+ continue ;
1766
+ }
1767
+
1710
1768
if (cur -> link_role == PRIORITY_PARENT_NEIGHBOUR ) {
1711
1769
//This is our primary parent we cannot delete
1712
1770
continue ;
@@ -1834,7 +1892,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
1834
1892
ws_neighbor_class_entry_t * ws_neighbor = ws_neighbor_class_entry_get (& cur -> ws_info -> neighbor_storage , entry_ptr -> index );
1835
1893
etx_storage_t * etx_entry = etx_storage_entry_get (cur -> id , entry_ptr -> index );
1836
1894
1837
- if (!entry_ptr -> trusted_device || !ws_neighbor || !etx_entry || ws_neighbor -> negative_aro_send ) {
1895
+ if (!entry_ptr -> trusted_device || !ws_neighbor || !etx_entry || ws_neighbor -> negative_aro_send || entry_ptr -> link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT ) {
1838
1896
return false;
1839
1897
}
1840
1898
@@ -2515,6 +2573,7 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
2515
2573
bool create_ok = ws_bootstrap_neighbor_info_request (cur , entry -> mac64 , & neigh_buffer , true);
2516
2574
if (create_ok ) {
2517
2575
ws_neighbor_class_entry_t * ws_neigh = neigh_buffer .ws_neighbor ;
2576
+ ws_bootstrap_neighbor_set_stable (cur , entry -> mac64 );
2518
2577
//Copy fhss temporary data
2519
2578
* ws_neigh = entry -> neigh_info_list ;
2520
2579
//ETX Create here
@@ -3226,7 +3285,7 @@ static int8_t ws_bootstrap_neighbor_set(protocol_interface_info_entry_t *cur, pa
3226
3285
ns_list_add_to_end (& cur -> ws_info -> parent_list_free , parent_ptr );
3227
3286
return -1 ;
3228
3287
}
3229
-
3288
+ ws_bootstrap_neighbor_set_stable ( cur , parent_ptr -> addr );
3230
3289
ws_neighbor_class_neighbor_unicast_time_info_update (neighbor_info .ws_neighbor , & parent_ptr -> ws_utt , parent_ptr -> timestamp );
3231
3290
ws_neighbor_class_neighbor_unicast_schedule_set (neighbor_info .ws_neighbor , & parent_ptr -> ws_us , & cur -> ws_info -> hopping_schdule );
3232
3291
return 0 ;
0 commit comments