static void thread_nd_coap_notification_callback(int8_t interface_id, const uint8_t ip_addr[16], uint16_t loc_addr, const uint8_t ml_eid[8]) { protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id); if (!cur) { return; } /* First check to see if we have an existing entry with different RLOC - we need to unicast error * notification to that old entry if so. */ ipv6_neighbour_t *entry = ipv6_neighbour_lookup(&cur->ipv6_neighbour_cache, ip_addr); if (entry && entry->ll_type == ADDR_802_15_4_SHORT) { uint16_t old_entry_rloc = common_read_16_bit(entry->ll_address + 2); if (old_entry_rloc != loc_addr) { uint8_t old_entry_ip[16]; thread_addr_write_mesh_local_16(old_entry_ip, common_read_16_bit(entry->ll_address + 2), cur->thread_info); tr_warn("Proactive address change %s %04x->%04x", trace_ipv6(ip_addr), old_entry_rloc, loc_addr); thread_resolution_client_address_error(interface_id, old_entry_ip, ip_addr, ml_eid); } } /* Now treat as an unsolicited update (by address, because entry may be NULL) */ uint8_t ll_addr[4]; common_write_16_bit(cur->mac_parameters->pan_id, ll_addr + 0); common_write_16_bit(loc_addr, ll_addr + 2); ipv6_neighbour_update_unsolicited(&cur->ipv6_neighbour_cache, ip_addr, ADDR_802_15_4_SHORT, ll_addr); if (nd_proxy_enabled_for_upstream(cur->id)) { ipv6_route_add(ip_addr, 128, cur->id, NULL, ROUTE_THREAD_PROXIED_HOST, 3600, 0); } }
int thread_management_get_leader_aloc(int8_t interface_id, uint8_t *address_buffer) { #ifdef HAVE_THREAD protocol_interface_info_entry_t *cur; cur = protocol_stack_interface_info_get_by_id(interface_id); if (cur) { if ((cur->thread_info) && (thread_attach_ready(cur) == 0) && (cur->thread_info->threadPrivatePrefixInfo.ulaValid)) { thread_addr_write_mesh_local_16(address_buffer, 0xfc00, cur->thread_info); return 0; } } return -1; #else (void) interface_id; (void) address_buffer; return -1; #endif }