@@ -97,6 +97,14 @@ typedef struct {
97
97
#define RFC6106_DNS_SEARCH_LIST_OPTION 31
98
98
static NS_LIST_DEFINE (bbr_instance_list , thread_bbr_t , link ) ;
99
99
100
+ struct ipv6_route * thread_bbr_dua_entry_find (int8_t interface_id , const uint8_t * addr_data_ptr ) {
101
+ ipv6_route_t * route = ipv6_route_choose_next_hop (addr_data_ptr , interface_id , NULL );
102
+ if (!route || route -> prefix_len < 128 || !route -> on_link || route -> info .source != ROUTE_THREAD_PROXIED_DUA_HOST ) {
103
+ //Not found
104
+ return NULL ;
105
+ }
106
+ return route ;
107
+ }
100
108
101
109
static thread_bbr_t * thread_bbr_find_by_interface (int8_t interface_id )
102
110
{
@@ -979,25 +987,33 @@ int thread_bbr_nd_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
979
987
int thread_bbr_dua_entry_add (int8_t interface_id , const uint8_t * addr_data_ptr , uint32_t lifetime , const uint8_t * mleid_ptr )
980
988
{
981
989
thread_bbr_t * this = thread_bbr_find_by_interface (interface_id );
990
+ thread_pbbr_dua_info_t * map ;
982
991
if (!this || this -> backbone_interface_id < 0 ) {
983
992
return -1 ;
984
993
}
985
- thread_pbbr_dua_info_t * map = ns_dyn_mem_alloc (sizeof (thread_pbbr_dua_info_t ));
986
- if (!map ) {
987
- goto error ;
994
+ ipv6_route_t * route = thread_bbr_dua_entry_find (this -> interface_id , addr_data_ptr );
995
+ if (!route ){
996
+ map = ns_dyn_mem_alloc (sizeof (thread_pbbr_dua_info_t ));
997
+ if (!map ) {
998
+ goto error ;
999
+ }
1000
+ // We are using route info field to store BBR MLEID map
1001
+ route = ipv6_route_add_with_info (addr_data_ptr , 128 , interface_id , NULL , ROUTE_THREAD_PROXIED_DUA_HOST , map , 0 , lifetime , 0 );
1002
+ if (!route ) {
1003
+ // Direct route to host allows ND proxying to work
1004
+ ns_dyn_mem_free (map );
1005
+ goto error ;
1006
+ }
1007
+ // Route info autofreed
1008
+ route -> info_autofree = true;
988
1009
}
1010
+
1011
+ map = route -> info .info ;
989
1012
memcpy (map -> mleid_ptr , mleid_ptr , 8 );
990
1013
map -> last_contact_time = protocol_core_monotonic_time ;
1014
+ route -> info .info = map ;
1015
+
991
1016
992
- // We are using route info field to store BBR MLEID map
993
- ipv6_route_t * route = ipv6_route_add_with_info (addr_data_ptr , 128 , interface_id , NULL , ROUTE_THREAD_PROXIED_DUA_HOST , map , 0 , lifetime , 0 );
994
- if (!route ) {
995
- // Direct route to host allows ND proxying to work
996
- ns_dyn_mem_free (map );
997
- goto error ;
998
- }
999
- // Route info autofreed
1000
- route -> info_autofree = true;
1001
1017
// send NA
1002
1018
thread_bbr_na_send (this -> backbone_interface_id , addr_data_ptr );
1003
1019
@@ -1007,15 +1023,6 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
1007
1023
return -2 ;
1008
1024
}
1009
1025
1010
- struct ipv6_route * thread_bbr_dua_entry_find (int8_t interface_id , const uint8_t * addr_data_ptr ) {
1011
- ipv6_route_t * route = ipv6_route_choose_next_hop (addr_data_ptr , interface_id , NULL );
1012
- if (!route || route -> prefix_len < 128 || !route -> on_link || route -> info .source != ROUTE_THREAD_PROXIED_DUA_HOST ) {
1013
- //Not found
1014
- return NULL ;
1015
- }
1016
- return route ;
1017
- }
1018
-
1019
1026
int thread_bbr_proxy_state_update (int8_t caller_interface_id , int8_t handler_interface_id , bool status )
1020
1027
{
1021
1028
protocol_interface_info_entry_t * cur = protocol_stack_interface_info_get_by_id (handler_interface_id );
0 commit comments