Skip to content

Commit 23a1265

Browse files
REED advertisement handling (Thread spec 5.16.3): (ARMmbed#1535)
Whenever a REED receives an MLE Advertisement from a REED in a neighboring Partition with a higher-priority than its current Thread Network Partition, it attempts to attach to a Parent in that higher-priority Thread Network Partition.
1 parent 0a32cb4 commit 23a1265

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

source/6LoWPAN/Thread/thread_mle_message_handler.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "6LoWPAN/Thread/thread_leader_service.h"
4646
#include "6LoWPAN/Thread/thread_tmfcop_lib.h"
4747
#include "6LoWPAN/Thread/thread_host_bootstrap.h"
48+
#include "6LoWPAN/Thread/thread_extension.h"
4849
#include "6LoWPAN/Thread/thread_router_bootstrap.h"
4950
#include "6LoWPAN/Thread/thread_network_synch.h"
5051
#include "6LoWPAN/MAC/mac_helper.h"
@@ -238,6 +239,29 @@ static bool thread_router_leader_data_process(protocol_interface_info_entry_t *c
238239
return true;
239240
}
240241

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+
241265
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)
242266
{
243267
//Read Leader Data and verify connectivity
@@ -347,7 +371,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
347371
// REED and FED
348372
if (!entry_temp && thread_bootstrap_link_create_check(cur, shortAddress) && thread_bootstrap_link_create_allowed(cur, shortAddress, mle_msg->packet_src_address)) {
349373
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)) {
351375
// Create link to new neighbor no other processing allowed
352376
thread_link_request_start(cur, mle_msg->packet_src_address);
353377
return;
@@ -357,6 +381,10 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
357381
return;
358382
}
359383
}
384+
// process REED advertisement from higher partition
385+
if (thread_reed_partitions_merge(cur, shortAddress, leaderData)) {
386+
return;
387+
}
360388
} else {
361389
//Router
362390
if (!thread_router_leader_data_process(cur, mle_msg->packet_src_address, &leaderData, &routeTlv, entry_temp) ) {

0 commit comments

Comments
 (0)