45
45
#include "6LoWPAN/Thread/thread_leader_service.h"
46
46
#include "6LoWPAN/Thread/thread_tmfcop_lib.h"
47
47
#include "6LoWPAN/Thread/thread_host_bootstrap.h"
48
+ #include "6LoWPAN/Thread/thread_extension.h"
48
49
#include "6LoWPAN/Thread/thread_router_bootstrap.h"
49
50
#include "6LoWPAN/Thread/thread_network_synch.h"
50
51
#include "6LoWPAN/MAC/mac_helper.h"
@@ -238,6 +239,29 @@ static bool thread_router_leader_data_process(protocol_interface_info_entry_t *c
238
239
return true;
239
240
}
240
241
242
+ static bool thread_reed_partitions_merge (protocol_interface_info_entry_t * cur , uint16_t shortAddress , thread_leader_data_t heard_partition_leader_data )
243
+ {
244
+ if (thread_is_router_addr (shortAddress )) {
245
+ return false;
246
+ }
247
+ if (thread_extension_version_check (thread_info (cur )-> version )) {
248
+ // lower weighting heard
249
+ if (thread_info (cur )-> thread_leader_data -> weighting > heard_partition_leader_data .weighting ) {
250
+ return false;
251
+ }
252
+ // lower/same partition id heard
253
+ if (thread_info (cur )-> thread_leader_data -> weighting == heard_partition_leader_data .weighting &&
254
+ thread_info (cur )-> thread_leader_data -> partitionId >= heard_partition_leader_data .partitionId ) {
255
+ return false;
256
+ }
257
+ } else if (thread_info (cur )-> thread_leader_data -> partitionId >= heard_partition_leader_data .partitionId ){
258
+ return false;
259
+ }
260
+ // can merge to a higher weighting/partition id
261
+ thread_bootstrap_connection_error (cur -> id , CON_ERROR_PARTITION_MERGE , NULL );
262
+ return true;
263
+ }
264
+
241
265
static bool thread_router_advertiment_tlv_analyze (uint8_t * ptr , uint16_t data_length , thread_leader_data_t * leaderData , uint16_t * shortAddress , mle_tlv_info_t * routeTlv )
242
266
{
243
267
//Read Leader Data and verify connectivity
@@ -347,7 +371,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
347
371
// REED and FED
348
372
if (!entry_temp && thread_bootstrap_link_create_check (cur , shortAddress ) && thread_bootstrap_link_create_allowed (cur , shortAddress , mle_msg -> packet_src_address )) {
349
373
if ((thread_info (cur )-> thread_leader_data -> partitionId == leaderData .partitionId ) &&
350
- (thread_info (cur )-> thread_leader_data -> weighting == leaderData .weighting )) {
374
+ (thread_info (cur )-> thread_leader_data -> weighting == leaderData .weighting )) {
351
375
// Create link to new neighbor no other processing allowed
352
376
thread_link_request_start (cur , mle_msg -> packet_src_address );
353
377
return ;
@@ -357,6 +381,10 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
357
381
return ;
358
382
}
359
383
}
384
+ // process REED advertisement from higher partition
385
+ if (thread_reed_partitions_merge (cur , shortAddress , leaderData )) {
386
+ return ;
387
+ }
360
388
} else {
361
389
//Router
362
390
if (!thread_router_leader_data_process (cur , mle_msg -> packet_src_address , & leaderData , & routeTlv , entry_temp ) ) {
0 commit comments