@@ -1736,6 +1736,96 @@ uint8_t *thread_leader_data_tlv_write(uint8_t *ptr, protocol_interface_info_entr
1736
1736
return ptr ;
1737
1737
}
1738
1738
1739
+ bool thread_addresses_needs_to_be_registered (protocol_interface_info_entry_t * cur )
1740
+ {
1741
+ lowpan_context_t * ctx ;
1742
+ uint8_t thread_realm_local_mcast_addr [16 ];
1743
+ if (thread_info (cur )-> thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
1744
+ thread_info (cur )-> thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE ) {
1745
+ // No address registration for others than MED or SED
1746
+ return false;
1747
+ }
1748
+
1749
+ // check for addresses
1750
+ ns_list_foreach (if_address_entry_t , e , & cur -> ip_addresses ) {
1751
+ if (addr_ipv6_scope (e -> address , cur ) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope (e -> address , cur ) == IPV6_SCOPE_REALM_LOCAL
1752
+ && !thread_addr_is_mesh_local_16 (e -> address , cur ))) {
1753
+ ctx = lowpan_context_get_by_address (& cur -> lowpan_contexts , e -> address );
1754
+ if (!ctx ) {
1755
+ return true;
1756
+ }
1757
+ if (ctx -> cid != 0 ) {
1758
+ return true;
1759
+
1760
+ }
1761
+ }
1762
+ }
1763
+
1764
+ // check for multicast groups
1765
+ thread_bootstrap_all_nodes_address_generate (thread_realm_local_mcast_addr , cur -> thread_info -> threadPrivatePrefixInfo .ulaPrefix , 3 );
1766
+ ns_list_foreach (if_group_entry_t , entry , & cur -> ip_groups )
1767
+ {
1768
+ if (addr_ipv6_multicast_scope (entry -> group ) < IPV6_SCOPE_REALM_LOCAL ) {
1769
+ /* Skip Link Local multicast address */
1770
+ continue ;
1771
+ }
1772
+
1773
+ if (addr_ipv6_equal (entry -> group , thread_realm_local_mcast_addr )) {
1774
+ /* Skip well-known realm-local all Thread nodes multicast address */
1775
+ continue ;
1776
+ }
1777
+ if (addr_ipv6_equal (entry -> group , ADDR_ALL_MPL_FORWARDERS )) {
1778
+ /* Skip All MPL Forwarders address */
1779
+ continue ;
1780
+ }
1781
+ if (addr_ipv6_equal (entry -> group , ADDR_REALM_LOCAL_ALL_NODES )) {
1782
+ /* Skip Mesh local all nodes */
1783
+ continue ;
1784
+ }
1785
+ if (addr_ipv6_equal (entry -> group , ADDR_REALM_LOCAL_ALL_ROUTERS )) {
1786
+ /* Skip Mesh local all routers */
1787
+ continue ;
1788
+ }
1789
+ return true;
1790
+ }
1791
+ return false;
1792
+ }
1793
+
1794
+ uint8_t * thread_ml_address_tlv_write (uint8_t * ptr , protocol_interface_info_entry_t * cur )
1795
+ {
1796
+ lowpan_context_t * ctx ;
1797
+ uint8_t * address_len_ptr ;
1798
+
1799
+ if (thread_info (cur )-> thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
1800
+ thread_info (cur )-> thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE ) {
1801
+ // No address registration for others than MED or SED
1802
+ return ptr ;
1803
+ }
1804
+ * ptr ++ = MLE_TYPE_ADDRESS_REGISTRATION ;
1805
+ address_len_ptr = ptr ++ ;
1806
+
1807
+ * address_len_ptr = 0 ;
1808
+
1809
+ ns_list_foreach (if_address_entry_t , e , & cur -> ip_addresses ) {
1810
+
1811
+ if (* address_len_ptr > 148 ) {
1812
+ // Maximum length of address registrations
1813
+ continue ;
1814
+ }
1815
+ if (!thread_addr_is_mesh_local_16 (e -> address , cur )) {
1816
+ ctx = lowpan_context_get_by_address (& cur -> lowpan_contexts , e -> address );
1817
+ if (ctx && ctx -> cid == 0 ) {
1818
+ //Write TLV to list
1819
+ * ptr ++ = (ctx -> cid | 0x80 );
1820
+ memcpy (ptr , e -> address + 8 , 8 );
1821
+ ptr += 8 ;
1822
+ * address_len_ptr += 9 ;
1823
+ }
1824
+ }
1825
+ }
1826
+ return ptr ;
1827
+ }
1828
+
1739
1829
uint8_t * thread_address_registration_tlv_write (uint8_t * ptr , protocol_interface_info_entry_t * cur )
1740
1830
{
1741
1831
uint8_t thread_realm_local_mcast_addr [16 ];
0 commit comments