Skip to content

Commit

Permalink
link-local multicast group registration (ARMmbed#1880)
Browse files Browse the repository at this point in the history
Added possibility for rx-off-when idle devices to register link-local multicast groups to parent.
  • Loading branch information
deepakvenugopal authored Oct 26, 2018
1 parent d4c95f2 commit e7a8d45
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
31 changes: 20 additions & 11 deletions source/6LoWPAN/Thread/thread_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,7 @@ bool thread_addresses_needs_to_be_registered(protocol_interface_info_entry_t *cu
{
lowpan_context_t *ctx;
uint8_t thread_realm_local_mcast_addr[16];
uint8_t thread_ll_unicast_prefix_based_mcast_addr[16];
if (thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
// No address registration for others than MED or SED
Expand All @@ -1768,18 +1769,22 @@ bool thread_addresses_needs_to_be_registered(protocol_interface_info_entry_t *cu
}

// check for multicast groups
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 3);
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups)
{
if (addr_ipv6_multicast_scope(entry->group) < IPV6_SCOPE_REALM_LOCAL) {
/* Skip Link Local multicast address */
if (!memcmp((entry->group), ADDR_MULTICAST_SOLICITED, 13)) {
/* Skip solicited node multicast address */
continue;
}

if (addr_ipv6_equal(entry->group, thread_realm_local_mcast_addr)) {
/* Skip well-known realm-local all Thread nodes multicast address */
continue;
}
if (addr_ipv6_equal(entry->group, thread_ll_unicast_prefix_based_mcast_addr)) {
/* Skip well-known link-local all Thread nodes multicast address */
continue;
}
if (addr_ipv6_equal(entry->group, ADDR_ALL_MPL_FORWARDERS)) {
/* Skip All MPL Forwarders address */
continue;
Expand Down Expand Up @@ -1835,6 +1840,7 @@ uint8_t *thread_ml_address_tlv_write(uint8_t *ptr, protocol_interface_info_entry
uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_info_entry_t *cur)
{
uint8_t thread_realm_local_mcast_addr[16];
uint8_t thread_ll_unicast_prefix_based_mcast_addr[16];
lowpan_context_t *ctx;
uint8_t *address_len_ptr;

Expand All @@ -1850,7 +1856,6 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_

// Register all global addressess
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {

if (*address_len_ptr > 148 ) {
// Maximum length of address registrations
continue;
Expand All @@ -1874,23 +1879,27 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_
}

/* Registers multicast addresses to the parent */
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 3);

thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups)
{
if (*address_len_ptr > 148) {
// Maximum length of address registrations
continue;
}
if (addr_ipv6_multicast_scope(entry->group) < IPV6_SCOPE_REALM_LOCAL) {
/* Skip Link Local multicast address */

if (!memcmp((entry->group), ADDR_MULTICAST_SOLICITED, 13)) {
/* Skip solicited node multicast address */
continue;
}

if (addr_ipv6_equal(entry->group, thread_realm_local_mcast_addr)) {
/* Skip well-known realm-local all Thread nodes multicast address */
continue;
}
if (addr_ipv6_equal(entry->group, thread_ll_unicast_prefix_based_mcast_addr)) {
/* Skip well-known link-local all Thread nodes multicast address */
continue;
}
if (addr_ipv6_equal(entry->group, ADDR_ALL_MPL_FORWARDERS)) {
/* Skip All MPL Forwarders address */
continue;
Expand Down Expand Up @@ -2058,7 +2067,7 @@ void thread_mcast_group_change(struct protocol_interface_info_entry *interface,

if (thread_bootstrap_should_register_address(interface)) {
/* Trigger Child Update Request only if MTD child's multicast address change */
if (addr_ipv6_multicast_scope(group->group) > IPV6_SCOPE_LINK_LOCAL) {
if (addr_ipv6_multicast_scope(group->group) >= IPV6_SCOPE_LINK_LOCAL) {
interface->thread_info->childUpdateReqTimer = 1;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions source/6LoWPAN/Thread/thread_router_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,8 @@ static void thread_address_registration_tlv_parse(uint8_t *ptr, uint16_t data_le
tr_debug("Register %s", trace_ipv6(ptr));

if (addr_is_ipv6_multicast(ptr)) {
// Register multicast address (higher scope than link-local)
if (addr_ipv6_multicast_scope(ptr) > IPV6_SCOPE_LINK_LOCAL) {
// Register multicast address (link-local & higher)
if (addr_ipv6_multicast_scope(ptr) >= IPV6_SCOPE_LINK_LOCAL) {
addr_add_group(cur, ptr);
if (thread_child_mcast_entry_get(cur, ptr, mac64)) {
tr_debug("Added sleepy multicast registration entry.");
Expand Down

0 comments on commit e7a8d45

Please sign in to comment.