@@ -98,7 +98,7 @@ static int thread_extension_dua_registration_cb(int8_t service_id, uint8_t sourc
98
98
(void ) source_port ;
99
99
100
100
uint16_t addr_len ;
101
- uint8_t * bbr_status ;
101
+ uint8_t bbr_status ;
102
102
uint8_t * addr_data_ptr = NULL ;
103
103
104
104
protocol_interface_info_entry_t * cur = protocol_stack_interface_info_get_by_id (thread_management_client_get_interface_id_by_service_id (service_id ));
@@ -112,28 +112,30 @@ static int thread_extension_dua_registration_cb(int8_t service_id, uint8_t sourc
112
112
return -2 ;
113
113
}
114
114
115
- if (1 > thread_meshcop_tlv_find (response_ptr -> payload_ptr , response_ptr -> payload_len , TMFCOP_TLV_STATUS , & bbr_status )) {
116
- return -3 ;
117
- }
118
-
119
- if (* bbr_status == 0 ) {
120
- // registration successful
115
+ if (1 > thread_meshcop_tlv_data_get_uint8 (response_ptr -> payload_ptr , response_ptr -> payload_len , TMFCOP_TLV_STATUS , & bbr_status )) {
121
116
return 0 ;
122
117
}
123
118
124
119
addr_len = thread_meshcop_tlv_find (response_ptr -> payload_ptr , response_ptr -> payload_len , TMFCOP_TLV_TARGET_EID , & addr_data_ptr );
125
120
126
121
if (addr_len < 16 ) {
127
122
tr_warn ("Invalid target eid in DUA.rsp cb message" );
128
- return -4 ;
123
+ return 0 ;
129
124
}
130
125
131
- // registration unsuccessful
132
- // processing for ourselves - if we have the address re register
133
126
if_address_entry_t * addr_entry = addr_get_entry (cur , addr_data_ptr );
134
127
if (addr_entry ) {
135
- cur -> dad_failures ++ ;
136
- thread_extension_dua_address_generate (cur , addr_data_ptr , 64 );
128
+ // Own processing
129
+ if (bbr_status == THREAD_EXTENSION_ST_DUA_SUCCESS ) {
130
+ addr_entry -> preferred_lifetime = 0xffffffff ;
131
+ } else if (bbr_status == THREAD_EXTENSION_ST_DUA_DUPLICATE ) {
132
+ cur -> dad_failures ++ ;
133
+ thread_extension_dua_address_generate (cur , addr_data_ptr , 64 );
134
+ } else if (bbr_status == THREAD_EXTENSION_ST_DUA_INVALID ) {
135
+ addr_delete (cur , addr_data_ptr );
136
+ } else {
137
+ addr_entry -> preferred_lifetime = 0 ;
138
+ }
137
139
return 0 ;
138
140
}
139
141
@@ -142,20 +144,30 @@ static int thread_extension_dua_registration_cb(int8_t service_id, uint8_t sourc
142
144
uint16_t nce_short_addr ;
143
145
uint8_t destination_address [16 ] = {0 };
144
146
147
+ if (bbr_status == THREAD_EXTENSION_ST_DUA_SUCCESS ) {
148
+ // registration successful
149
+ return 0 ;
150
+ }
151
+
145
152
neighbour_entry = ipv6_neighbour_lookup (& cur -> ipv6_neighbour_cache , addr_data_ptr );
146
153
if (!neighbour_entry ) {
147
154
return 0 ;
148
155
}
149
156
150
157
nce_short_addr = common_read_16_bit (neighbour_entry -> ll_address + 2 );
151
158
if (!thread_addr_is_child (cur -> thread_info -> routerShortAddress , nce_short_addr )) {
159
+ ipv6_neighbour_entry_remove (& cur -> ipv6_neighbour_cache , neighbour_entry );
152
160
return 0 ;
153
161
}
154
- thread_addr_write_mesh_local_16 (destination_address , nce_short_addr , cur -> thread_info );
155
162
156
- thread_extension_addr_ntf_send (cur , destination_address , addr_data_ptr , * bbr_status );
163
+ if (bbr_status == THREAD_EXTENSION_ST_DUA_DUPLICATE || bbr_status == THREAD_EXTENSION_ST_DUA_INVALID ) {
164
+ // remove invalid or duplicate child entry
165
+ ipv6_neighbour_entry_remove (& cur -> ipv6_neighbour_cache , neighbour_entry );
166
+ }
167
+
168
+ thread_addr_write_mesh_local_16 (destination_address , nce_short_addr , cur -> thread_info );
157
169
158
- ipv6_neighbour_entry_remove ( & cur -> ipv6_neighbour_cache , neighbour_entry );
170
+ thread_extension_addr_ntf_send ( cur , destination_address , addr_data_ptr , bbr_status );
159
171
160
172
return 0 ;
161
173
}
0 commit comments