From 1350bc5fc9a6da0641241f12b78fa7ea8d9ba1fe Mon Sep 17 00:00:00 2001 From: Juha Heiskanen Date: Mon, 25 Jun 2018 10:13:37 +0300 Subject: [PATCH] mac_neighbor_info() macro defned for simplify code --- .../Bootstraps/Generic/protocol_6lowpan.c | 18 +++---- .../Generic/protocol_6lowpan_bootstrap.c | 44 ++++++++-------- .../Generic/protocol_6lowpan_interface.c | 2 +- source/6LoWPAN/MAC/mac_data_poll.c | 2 +- source/6LoWPAN/MAC/mac_pairwise_key.c | 16 +++--- source/6LoWPAN/MAC/mac_response_handler.c | 2 +- source/6LoWPAN/ND/nd_router_object.c | 2 +- source/6LoWPAN/Thread/thread_bootstrap.c | 16 +++--- .../6LoWPAN/Thread/thread_border_router_api.c | 2 +- source/6LoWPAN/Thread/thread_common.c | 10 ++-- source/6LoWPAN/Thread/thread_diagnostic.c | 2 +- source/6LoWPAN/Thread/thread_extension.c | 6 +-- source/6LoWPAN/Thread/thread_host_bootstrap.c | 20 +++---- source/6LoWPAN/Thread/thread_management_if.c | 2 +- .../Thread/thread_mle_message_handler.c | 22 ++++---- source/6LoWPAN/Thread/thread_nd.c | 6 +-- source/6LoWPAN/Thread/thread_network_synch.c | 4 +- .../6LoWPAN/Thread/thread_router_bootstrap.c | 52 +++++++++---------- source/6LoWPAN/Thread/thread_routing.c | 2 +- source/6LoWPAN/Thread/thread_test_api.c | 4 +- source/6LoWPAN/adaptation_interface.c | 12 ++--- source/6LoWPAN/ws/ws_bootstrap.c | 22 ++++---- source/6LoWPAN/ws/ws_common.c | 6 +-- source/6LoWPAN/ws/ws_llc_data_service.c | 2 +- source/BorderRouter/border_router.c | 4 +- source/MLE/mle.c | 10 ++-- source/NWK_INTERFACE/protocol_core.c | 2 +- source/Service_Libs/etx/etx.c | 2 +- .../mac_neighbor_table/mac_neighbor_table.h | 2 + source/Service_Libs/mle_service/mle_service.c | 2 +- 30 files changed, 150 insertions(+), 148 deletions(-) diff --git a/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c b/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c index f252cebc291..daab2ab7b4a 100644 --- a/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c +++ b/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c @@ -437,12 +437,12 @@ static int8_t mle_set_link_priority(protocol_interface_info_entry_t *cur, const uint8_t mac64[8]; mac_neighbor_table_entry_t *entry; if (!memcmp(address, ADDR_SHORT_ADR_SUFFIC, 6)) { - entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, address + 6, ADDR_802_15_4_SHORT); + entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), address + 6, ADDR_802_15_4_SHORT); } else { memcpy(mac64, address, 8); mac64[0] ^= 2; - entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, mac64, ADDR_802_15_4_LONG); + entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), mac64, ADDR_802_15_4_LONG); } if (!entry) { @@ -483,7 +483,7 @@ uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t return 0; } - mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, addr_ptr + PAN_ID_LEN, addr_type); + mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type); if (entry) { etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index); @@ -516,7 +516,7 @@ uint16_t protocol_6lowpan_neighbor_second_priority_set(int8_t interface_id, addr return 0; } - mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, addr_ptr + PAN_ID_LEN, addr_type); + mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type); if (entry) { etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index); @@ -542,7 +542,7 @@ void protocol_6lowpan_neighbor_priority_clear_all(int8_t interface_id, neighbor_ if (!cur) { return; } - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach(mac_neighbor_table_entry_t, entry, mac_table_list) { if (priority == PRIORITY_1ST && entry->link_role == PRIORITY_PARENT_NEIGHBOUR) { @@ -566,7 +566,7 @@ int8_t protocol_6lowpan_neighbor_address_state_synch(protocol_interface_info_ent { int8_t ret_val = -1; - mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, eui64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), eui64, ADDR_802_15_4_LONG); if (entry) { if (memcmp(iid, ADDR_SHORT_ADR_SUFFIC, 6) == 0) { iid += 6; @@ -575,7 +575,7 @@ int8_t protocol_6lowpan_neighbor_address_state_synch(protocol_interface_info_ent } if (!entry->ffd_device) { if (entry->connected_device) { - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry, entry->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry, entry->link_lifetime); } ret_val = 1; } else { @@ -587,9 +587,9 @@ int8_t protocol_6lowpan_neighbor_address_state_synch(protocol_interface_info_ent int8_t protocol_6lowpan_neighbor_remove(protocol_interface_info_entry_t *cur, uint8_t *address_ptr, addrtype_t type) { - mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, address_ptr, type); + mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), address_ptr, type); if (entry) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry); } return 0; } diff --git a/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c b/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c index 044c0648406..f30570a334d 100644 --- a/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c +++ b/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c @@ -208,7 +208,7 @@ static bool protocol_6lowpan_challenge_callback(int8_t interface_id, uint16_t ms memcpy(mac64, ll64_ptr + 8, 8); mac64[0] ^= 2; - mac_neighbor_table_entry_t * neig_info = mac_neighbor_table_address_discover(cur_interface->mac_parameters->mac_neighbor_table, mac64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t * neig_info = mac_neighbor_table_address_discover(mac_neighbor_info(cur_interface), mac64, ADDR_802_15_4_LONG); if (!neig_info) { return false;//Why entry is removed before timeout?? @@ -222,7 +222,7 @@ static bool protocol_6lowpan_challenge_callback(int8_t interface_id, uint16_t ms if (usedAllRetries) { //GET entry - mac_neighbor_table_neighbor_remove(cur_interface->mac_parameters->mac_neighbor_table, neig_info); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur_interface), neig_info); return false; } @@ -407,7 +407,7 @@ static uint8_t *mle_table_set_neighbours(protocol_interface_info_entry_t *cur, u // defaults: complete, 2 bytes long link-layer address link_flags_ptr = ptr++; *link_flags_ptr = 0x81; - if (mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, short_temp,ADDR_802_15_4_SHORT)) { + if (mac_neighbor_table_address_discover(mac_neighbor_info(cur), short_temp,ADDR_802_15_4_SHORT)) { *link_flags_ptr |= 0x07; neigh_count_max = mle_advert_neigh_cnt(cur, false); } else { @@ -490,7 +490,7 @@ static int protocol_6lowpan_mle_neigh_advertise(protocol_interface_info_entry_t return 0; } - if (mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, short_temp,ADDR_802_15_4_SHORT)) { + if (mac_neighbor_table_address_discover(mac_neighbor_info(cur), short_temp,ADDR_802_15_4_SHORT)) { neig_cache_size += mle_advert_neigh_cnt(cur, false) * 10; } else { neig_cache_size += mle_advert_neigh_cnt(cur, true) << 2; @@ -565,7 +565,7 @@ static void mle_neigh_time_and_mode_update(mac_neighbor_table_entry_t *entry_tem timeout_tlv = mle_6lowpan_data->host_lifetime; } } - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, timeout_tlv); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout_tlv); } static void mle_neigh_entry_update_by_mle_tlv_list(int8_t interface_id, mac_neighbor_table_entry_t *entry_temp, uint8_t *tlv_ptr, uint16_t tlv_length, uint8_t *mac64, uint16_t short_address) @@ -729,10 +729,10 @@ static int mle_router_accept_request_build(protocol_interface_info_entry_t *cur, static void protocol_6lowpan_link_reject_handler(protocol_interface_info_entry_t *cur, uint8_t *ll64) { - mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, ll64, false, NULL); + mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), ll64, false, NULL); tr_debug("MLE link reject"); if (mac_entry) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, mac_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), mac_entry); } } @@ -1048,7 +1048,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml mle_6lowpan_data->link_req_token_bucket--; } else { //Update only old information based on link request - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (entry_temp) { mle_neigh_time_and_mode_update(entry_temp,mle_msg); mle_neigh_entry_update_by_mle_tlv_list(interface_id, entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur->mac, own_mac16); @@ -1084,11 +1084,11 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml } tr_debug("Accept & Request"); - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (!entry_temp) { // If there is space for neighbors try to allocate new entry if (mle_6lowpan_neighbor_limit_check(mle_msg, true)) { - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, true, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, true, NULL); } } @@ -1148,7 +1148,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml t_ptr = mle_tlv_info.dataPtr; mode = *t_ptr; } - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (!entry_temp) { if ((mode & MLE_DEV_MASK) == MLE_FFD_DEV) { // If there is space for neighbors synchronizes to new router @@ -1183,7 +1183,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml //Possible remove if ((mode & MLE_DEV_MASK) == MLE_RFD_DEV) { //Remove Entry - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, entry_temp); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp); tr_error("MLE adv: Own address not found"); return; } @@ -1196,7 +1196,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml mle_neigh_entry_update_by_mle_tlv_list(cur->id,entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur->mac, own_mac16); mle_neigh_entry_frame_counter_update(entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur, security_headers->KeyIndex); if (entry_temp->connected_device) { - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, entry_temp->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, entry_temp->link_lifetime); } } break; @@ -1294,7 +1294,7 @@ static void protocol_6lowpan_mle_purge_neighbors(struct protocol_interface_info_ // Sends REJECT mle_service_reject_message_build(cur_interface->id, ll64, false); - mac_neighbor_table_neighbor_remove(cur_interface->mac_parameters->mac_neighbor_table, entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur_interface), entry); // Adds purged neighbor to blacklist so that it is not added right away back from advertisement blacklist_update(ll64, false); @@ -1679,16 +1679,16 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode cur->mac_security_key_usage_update_cb = arm_6lowpan_security_key_update_cb; //Allocate MLE class here //Deallocate old here - mac_neighbor_table_delete(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_delete(mac_neighbor_info(cur)); mac_description_storage_size_t buffer; //Read MAC device table sizes if (cur->mac_api->mac_storage_sizes_get(cur->mac_api, &buffer) != 0) { return -1; } - cur->mac_parameters->mac_neighbor_table = mac_neighbor_table_create(buffer.device_decription_table_size, lowpan_neighbor_entry_remove_notify + mac_neighbor_info(cur) = mac_neighbor_table_create(buffer.device_decription_table_size, lowpan_neighbor_entry_remove_notify , lowpan_neighbor_entry_nud_notify, cur); - if (!cur->mac_parameters->mac_neighbor_table) { + if (!mac_neighbor_info(cur)) { return -1; } @@ -1973,7 +1973,7 @@ static void protocol_6lowpan_nd_ready(protocol_interface_info_entry_t *cur) addrtype_t addrType; uint8_t tempAddr[8]; addrType = mac_helper_coordinator_address_get(cur, tempAddr); - mac_neighbor_table_entry_t * neig_info = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, tempAddr, addrType); + mac_neighbor_table_entry_t * neig_info = mac_neighbor_table_address_discover(mac_neighbor_info(cur), tempAddr, addrType); if (neig_info) { if (neig_info->lifetime > MLE_TABLE_CHALLENGE_TIMER) { @@ -2798,10 +2798,10 @@ static void lowpan_comm_status_indication_cb(int8_t if_id, const mlme_comm_statu break; case MLME_DATA_POLL_NOTIFICATION: - entry_ptr = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, status->SrcAddr, status->SrcAddrMode); + entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), status->SrcAddr, status->SrcAddrMode); if (entry_ptr) { // Refresh Timeout - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_ptr, entry_ptr->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_ptr, entry_ptr->link_lifetime); } break; default: @@ -2817,13 +2817,13 @@ bool lowpan_neighbour_data_clean(int8_t interface_id, const uint8_t *link_local_ return false; } bool return_value = false; - mac_neighbor_table_entry_t *neigh_entry = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, link_local_address, false, NULL); + mac_neighbor_table_entry_t *neigh_entry = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), link_local_address, false, NULL); if (neigh_entry) { //Remove entry if (neigh_entry->link_role == PRIORITY_PARENT_NEIGHBOUR || neigh_entry->link_role == SECONDARY_PARENT_NEIGHBOUR) { return_value = true; } - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, neigh_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), neigh_entry); } return return_value; } diff --git a/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c b/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c index 210a6c662c7..409d0bbfabd 100644 --- a/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c +++ b/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c @@ -82,7 +82,7 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur) /* Change Active -> Idle */ /* Disable Protocols Timers */ if (!thread_info(cur)) { - mac_neighbor_table_neighbor_list_clean(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(cur)); #ifndef NO_MLE if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_MLE) { diff --git a/source/6LoWPAN/MAC/mac_data_poll.c b/source/6LoWPAN/MAC/mac_data_poll.c index 7cf1c1cbeaf..963f8795911 100644 --- a/source/6LoWPAN/MAC/mac_data_poll.c +++ b/source/6LoWPAN/MAC/mac_data_poll.c @@ -284,7 +284,7 @@ void mac_poll_timer_trig(uint32_t poll_time, protocol_interface_info_entry_t *cu } static mac_neighbor_table_entry_t *neighbor_data_poll_referesh(protocol_interface_info_entry_t *cur, uint8_t *address, addrtype_t type) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, address, type); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), address, type); if (!entry) { return NULL; } diff --git a/source/6LoWPAN/MAC/mac_pairwise_key.c b/source/6LoWPAN/MAC/mac_pairwise_key.c index b1565e96675..be4d3cda5c5 100644 --- a/source/6LoWPAN/MAC/mac_pairwise_key.c +++ b/source/6LoWPAN/MAC/mac_pairwise_key.c @@ -175,9 +175,9 @@ static void mac_pairwise_key_list_free(protocol_interface_info_entry_t *interfac mac_neighbor_table_entry_t *cur_entry; mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table; for (uint8_t i = 0; i< main_list->key_table_size; i++) { - cur_entry = mac_neighbor_table_attribute_discover(interface->mac_parameters->mac_neighbor_table, cur->device_descriptor_attribute); + cur_entry = mac_neighbor_table_attribute_discover(mac_neighbor_info(interface), cur->device_descriptor_attribute); if (cur_entry) { - mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, cur_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), cur_entry); } mac_helper_security_pairwisekey_set(interface, NULL, NULL, cur->key_decriptor_attribute); } @@ -267,12 +267,12 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui } //Allocate mle entry - mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(interface->mac_parameters->mac_neighbor_table, eui64, true, &new_entry_created); + mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(mac_neighbor_info(interface), eui64, true, &new_entry_created); if (!mac_entry) { return -1; } - mac_neighbor_table_trusted_neighbor(interface->mac_parameters->mac_neighbor_table, mac_entry, true); + mac_neighbor_table_trusted_neighbor(mac_neighbor_info(interface), mac_entry, true); mac_entry->mac16 = 0xffff; //Allocate key description @@ -280,7 +280,7 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui mac_pairwise_key_info_t *key_desc = mac_pairwise_key_info_get(main_list, mac_entry->index); if (!key_desc) { - mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, mac_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), mac_entry); return -1; } @@ -291,7 +291,7 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui //set key descriptor if (mac_helper_security_pairwisekey_set(interface, key, eui64, key_desc->key_decriptor_attribute) != 0) { main_list->key_table_size--; - mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, mac_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), mac_entry); return -1; } @@ -312,7 +312,7 @@ int mac_pairwise_key_del(int8_t interface_id, const uint8_t eui64[static 8]) return -1; } //Get from mac - mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(interface->mac_parameters->mac_neighbor_table, eui64, true, NULL); + mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(mac_neighbor_info(interface), eui64, true, NULL); if (!mac_entry) { return -1; } @@ -327,7 +327,7 @@ int mac_pairwise_key_del(int8_t interface_id, const uint8_t eui64[static 8]) //kill Entry & overwrite key mac_helper_security_pairwisekey_set(interface, NULL, NULL, key_attribute); - mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, mac_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), mac_entry); return 0; } diff --git a/source/6LoWPAN/MAC/mac_response_handler.c b/source/6LoWPAN/MAC/mac_response_handler.c index b0cbfe60b33..5e6825d52de 100644 --- a/source/6LoWPAN/MAC/mac_response_handler.c +++ b/source/6LoWPAN/MAC/mac_response_handler.c @@ -49,7 +49,7 @@ static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_en if (confirmation->status == MLME_SUCCESS) { //GET ME table by extended mac64 address - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(info_entry->mac_parameters->mac_neighbor_table, descpription->ExtAddress, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(info_entry), descpription->ExtAddress, ADDR_802_15_4_LONG); if (!entry) { return; diff --git a/source/6LoWPAN/ND/nd_router_object.c b/source/6LoWPAN/ND/nd_router_object.c index e8e99fcdedd..8b0dd2bae1d 100644 --- a/source/6LoWPAN/ND/nd_router_object.c +++ b/source/6LoWPAN/ND/nd_router_object.c @@ -852,7 +852,7 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac * what to do without MLE - might need special external/non-external prioritisation at root. * This "publish for RFD" rule comes from ZigBee IP. */ - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur_interface->mac_parameters->mac_neighbor_table, ipv6_neighbour_eui64(&cur_interface->ipv6_neighbour_cache, neigh), ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur_interface), ipv6_neighbour_eui64(&cur_interface->ipv6_neighbour_cache, neigh), ADDR_802_15_4_LONG); if (entry && !entry->ffd_device) { rpl_control_publish_host_address(protocol_6lowpan_rpl_domain, neigh->ip_address, neigh->lifetime); diff --git a/source/6LoWPAN/Thread/thread_bootstrap.c b/source/6LoWPAN/Thread/thread_bootstrap.c index f11c30a111d..f832fce8c12 100644 --- a/source/6LoWPAN/Thread/thread_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_bootstrap.c @@ -181,10 +181,10 @@ int8_t thread_mle_class_init(int8_t interface_id) return -1; } - if (!cur->mac_parameters->mac_neighbor_table ) { - cur->mac_parameters->mac_neighbor_table = mac_neighbor_table_create(buffer.device_decription_table_size, thread_neighbor_remove + if (!mac_neighbor_info(cur) ) { + mac_neighbor_info(cur) = mac_neighbor_table_create(buffer.device_decription_table_size, thread_neighbor_remove , thread_neighbor_entry_nud_notify, cur); - if (!cur->mac_parameters->mac_neighbor_table) { + if (!mac_neighbor_info(cur)) { return -1; } } @@ -1204,12 +1204,12 @@ void thread_bootstrap_ready(protocol_interface_info_entry_t *cur) void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach_safe(mac_neighbor_table_entry_t, cur_entry, mac_table_list) { if (!thread_addr_is_equal_or_child(cur->thread_info->routerShortAddress, cur_entry->mac16)) { tr_debug("Free ID %x", cur_entry->mac16); - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, cur_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), cur_entry); } } } @@ -1492,7 +1492,7 @@ int thread_bootstrap_reset(protocol_interface_info_entry_t *cur) neighbor_cache_flush(&cur->neigh_cache); thread_bootstrap_stop(cur); - mac_neighbor_table_neighbor_list_clean(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(cur)); cur->bootsrap_state_machine_cnt = 0; mac_helper_free_scan_confirm(&cur->mac_parameters->nwk_scan_params); //tr_debug( "--> idle"); @@ -2906,7 +2906,7 @@ void thread_bootstrap_clear_neighbor_entries(protocol_interface_info_entry_t *cu ipv6_neighbour_entry_remove(&cur->ipv6_neighbour_cache, neighbour); } } - mac_neighbor_table_neighbor_list_clean(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(cur)); } void thread_bootstrap_dynamic_configuration_save(protocol_interface_info_entry_t *cur) @@ -2918,7 +2918,7 @@ void thread_bootstrap_dynamic_configuration_save(protocol_interface_info_entry_t if (thread_i_am_router(cur)) { /* Store information of our children to the dynamic storage */ - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach_safe(mac_neighbor_table_entry_t, entry, mac_table_list) { if (thread_addr_is_child(mac_helper_mac16_address_get(cur), entry->mac16)) { thread_dynamic_storage_child_info_store(cur, entry); diff --git a/source/6LoWPAN/Thread/thread_border_router_api.c b/source/6LoWPAN/Thread/thread_border_router_api.c index 3fc7d982a5b..4a998c63ccc 100644 --- a/source/6LoWPAN/Thread/thread_border_router_api.c +++ b/source/6LoWPAN/Thread/thread_border_router_api.c @@ -302,7 +302,7 @@ static void thread_border_router_child_network_data_clean(protocol_interface_inf uint8_t addr16_buf[2]; common_write_16_bit(child_id, addr16_buf); - if (mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, addr16_buf, ADDR_802_15_4_SHORT)) { + if (mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr16_buf, ADDR_802_15_4_SHORT)) { /* Child is available in mle, do nothing */ return; } diff --git a/source/6LoWPAN/Thread/thread_common.c b/source/6LoWPAN/Thread/thread_common.c index 0cd81c93935..781f46c7dbb 100644 --- a/source/6LoWPAN/Thread/thread_common.c +++ b/source/6LoWPAN/Thread/thread_common.c @@ -670,7 +670,7 @@ thread_mcast_child_t *thread_child_mcast_entry_find(thread_mcast_children_list_t bool thread_stable_context_check(protocol_interface_info_entry_t *cur, buffer_t *buf) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table,buf->dst_sa.address + 2 , buf->dst_sa.addr_type); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur),buf->dst_sa.address + 2 , buf->dst_sa.addr_type); if (entry && thread_addr_is_child(mac_helper_mac16_address_get(cur), entry->mac16)) { /* Check if the child can handle only stable network data (e.g. sleepy device) */ @@ -681,7 +681,7 @@ bool thread_stable_context_check(protocol_interface_info_entry_t *cur, buffer_t thread_mcast_child_t *thread_child_mcast_entry_get(protocol_interface_info_entry_t *cur, const uint8_t *mcast_addr, const uint8_t *mac64) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, mac64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), mac64, ADDR_802_15_4_LONG); if (!entry) { tr_error("No MLE entry."); @@ -1141,7 +1141,7 @@ static uint8_t *thread_linkquality_write(int8_t interface_id, uint8_t *buffer) uint8_t lqi1 = 0, lqi2 = 0, lqi3 = 0; thread_link_quality_e thread_link_quality; - mac_neighbor_table_list_t *mac_table_list = &interface_ptr->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(interface_ptr)->neighbour_list; ns_list_foreach(mac_neighbor_table_entry_t, cur, mac_table_list) { if (thread_is_router_addr(cur->mac16)) { @@ -1858,13 +1858,13 @@ static void thread_tx_failure_handler(int8_t nwk_id, uint8_t accumulated_failure return; } - mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_attribute_discover(cur->mac_parameters->mac_neighbor_table, attribute_index); + mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_attribute_discover(mac_neighbor_info(cur), attribute_index); if (!neighbor) { return; } if (accumulated_failures >= THREAD_MAC_TRANSMISSIONS*THREAD_FAILED_CHILD_TRANSMISSIONS) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, neighbor); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), neighbor); } } diff --git a/source/6LoWPAN/Thread/thread_diagnostic.c b/source/6LoWPAN/Thread/thread_diagnostic.c index 004f9f05521..4e87492e5e9 100644 --- a/source/6LoWPAN/Thread/thread_diagnostic.c +++ b/source/6LoWPAN/Thread/thread_diagnostic.c @@ -95,7 +95,7 @@ static uint8_t *thread_diagnostic_child_table_tlv_build(uint8_t *data_ptr, proto uint8_t child_count = 0; uint8_t calculated_timeout; - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; child_count = thread_router_bootstrap_child_count_get(cur); diff --git a/source/6LoWPAN/Thread/thread_extension.c b/source/6LoWPAN/Thread/thread_extension.c index 51f62cb8738..cf605b9f881 100644 --- a/source/6LoWPAN/Thread/thread_extension.c +++ b/source/6LoWPAN/Thread/thread_extension.c @@ -376,7 +376,7 @@ void thread_extension_address_registration(struct protocol_interface_info_entry tr_info("domain prefix Primary bbr present"); if (child_mac64) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, child_mac64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(interface), child_mac64, ADDR_802_15_4_LONG); if (!entry) { tr_error("No MLE entry."); @@ -421,7 +421,7 @@ void thread_extension_address_registration(struct protocol_interface_info_entry if (mac_helper_mac16_address_get(interface) == br->routerID) { if (child_mac64) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, child_mac64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(interface), child_mac64, ADDR_802_15_4_LONG); if (entry) { rloc16 = entry->mac16; @@ -539,7 +539,7 @@ void thread_extension_address_registration_trigger(protocol_interface_info_entry // Send notification on behalf of children ns_list_foreach(ipv6_neighbour_t, n, &interface->ipv6_neighbour_cache.list) { if (n->type == IP_NEIGHBOUR_REGISTERED && addr_ipv6_scope(n->ip_address, interface) > IPV6_SCOPE_REALM_LOCAL) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, &n->ll_address[2], ADDR_802_15_4_SHORT); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(interface), &n->ll_address[2], ADDR_802_15_4_SHORT); if (entry) { thread_extension_address_registration(interface, n->ip_address, entry->mac64); } diff --git a/source/6LoWPAN/Thread/thread_host_bootstrap.c b/source/6LoWPAN/Thread/thread_host_bootstrap.c index 6ee343ce2d3..0de2af36dde 100644 --- a/source/6LoWPAN/Thread/thread_host_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_host_bootstrap.c @@ -158,7 +158,7 @@ static bool thread_parent_discover_timeout_cb(int8_t interface_id, uint16_t msgI memcpy(ll64, ADDR_LINK_LOCAL_PREFIX , 8); memcpy(&ll64[8], parent->mac64 , 8); ll64[8] ^= 2; - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, ll64, true, &new_entry_created); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), ll64, true, &new_entry_created); if (entry_temp == NULL) { return false; } @@ -176,7 +176,7 @@ static bool thread_parent_discover_timeout_cb(int8_t interface_id, uint16_t msgI mlme_device_descriptor_t device_desc; mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16,parent->linLayerFrameCounter, false); mac_helper_devicetable_set(&device_desc, cur,entry_temp->index, mac_helper_default_key_index_get(cur), new_entry_created); - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, THREAD_DEFAULT_LINK_LIFETIME); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, THREAD_DEFAULT_LINK_LIFETIME); if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) { nwk_thread_host_control(cur, NET_HOST_FAST_POLL_MODE, 50); @@ -329,7 +329,7 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent } //Update parent link information - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, src_address, true, &new_entry_created); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), src_address, true, &new_entry_created); if (!entry_temp) { tr_debug("Neighbor allocate fail"); @@ -346,7 +346,7 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent common_write_16_bit(entry_temp->mac16, shortAddress); mac_helper_coordinator_address_set(cur, ADDR_802_15_4_SHORT, shortAddress); - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, thread_info(cur)->host_link_timeout); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, thread_info(cur)->host_link_timeout); mlme_device_descriptor_t device_desc; mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16,llFrameCounter, false); @@ -786,7 +786,7 @@ static void thread_mle_child_request_receive_cb(int8_t interface_id, mle_message thread_merge_prepare(cur); // Create entry for new parent - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, true, &new_entry_created); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, true, &new_entry_created); if (entry_temp == NULL) { // todo: what to do here? return; @@ -842,7 +842,7 @@ static void thread_mle_child_request_receive_cb(int8_t interface_id, mle_message entry_temp->link_role = PRIORITY_PARENT_NEIGHBOUR; mac_helper_coordinator_address_set(cur, ADDR_802_15_4_SHORT, shortAddress); - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, thread_info(cur)->host_link_timeout); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, thread_info(cur)->host_link_timeout); if (scan_result->security_key_index != security_headers->KeyIndex) { // KeyIndex has been changed between parent_response and child_id_response, reset link layer frame counter @@ -948,7 +948,7 @@ void thread_endevice_synch_start(protocol_interface_info_entry_t *cur) bool new_entry_created; // Add the parent to the MLE neighbor table - mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(cur->mac_parameters->mac_neighbor_table, cur->thread_info->thread_endnode_parent->mac64, true, &new_entry_created); + mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(mac_neighbor_info(cur), cur->thread_info->thread_endnode_parent->mac64, true, &new_entry_created); if (mac_entry) { //Add link margin 64 thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, mac_entry->index,64, new_entry_created); @@ -959,7 +959,7 @@ void thread_endevice_synch_start(protocol_interface_info_entry_t *cur) // In case we don't get response to sync; use temporary timeout here, // Child ID Response handler will set correct value later - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, mac_entry, mac_entry->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), mac_entry, mac_entry->link_lifetime); // Add the parent to the MAC table (for e.g. secured/fragmented Child Update Response) mlme_device_descriptor_t device_desc; @@ -1017,9 +1017,9 @@ static bool thread_child_id_req_timeout(int8_t interface_id, uint16_t msgId, boo /* If scanned parent is from other partition, delete from MLE table */ if (scanned_parent->leader_data.partitionId != thread_info(cur)->thread_leader_data->partitionId) { - entry_temp = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, scanned_parent->mac64, ADDR_802_15_4_LONG); + entry_temp = mac_neighbor_table_address_discover(mac_neighbor_info(cur), scanned_parent->mac64, ADDR_802_15_4_LONG); if (entry_temp) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, entry_temp); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp); } } diff --git a/source/6LoWPAN/Thread/thread_management_if.c b/source/6LoWPAN/Thread/thread_management_if.c index cb6cde26c56..3c5f72a1fc2 100644 --- a/source/6LoWPAN/Thread/thread_management_if.c +++ b/source/6LoWPAN/Thread/thread_management_if.c @@ -795,7 +795,7 @@ int thread_dhcpv6_server_delete(int8_t interface_id, uint8_t *prefix_ptr) #ifdef HAVE_THREAD static mac_neighbor_table_entry_t *neighbor_data_poll_referesh(protocol_interface_info_entry_t *cur, const uint8_t *address, addrtype_t type) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, address, type); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), address, type); if (!entry || !entry->connected_device) { return NULL; } diff --git a/source/6LoWPAN/Thread/thread_mle_message_handler.c b/source/6LoWPAN/Thread/thread_mle_message_handler.c index 7816ee4af83..25ed7305693 100644 --- a/source/6LoWPAN/Thread/thread_mle_message_handler.c +++ b/source/6LoWPAN/Thread/thread_mle_message_handler.c @@ -101,9 +101,9 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg, case MLE_COMMAND_REJECT: { mac_neighbor_table_entry_t *entry_temp; tr_warn("Reject Link"); - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (entry_temp) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, entry_temp); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp); } break; } @@ -284,7 +284,7 @@ static void thread_update_mle_entry(protocol_interface_info_entry_t *cur, mle_me thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index); if (!thread_attach_active_router(cur) && !thread_check_is_this_my_parent(cur, entry_temp)) { - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, entry_temp->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, entry_temp->link_lifetime); } if (short_address != entry_temp->mac16) { @@ -343,7 +343,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle } // Get MLE entry - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (entry_temp) { thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index, linkMargin, false); thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index); @@ -360,7 +360,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle if (entry_temp && !adv_from_my_partition && !my_parent ) { // Remove MLE entry that are located in other partition and is not my parent - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, entry_temp); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp); entry_temp = NULL; } @@ -449,7 +449,7 @@ static void thread_parse_accept(protocol_interface_info_entry_t *cur, mle_messag /* Call to determine whether or not we should create a new link */ createNew = thread_bootstrap_link_create_check(cur, shortAddress); - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, createNew, &new_entry_created); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, createNew, &new_entry_created); if (!entry_temp) { thread_link_reject_send(cur, mle_msg->packet_src_address); @@ -482,7 +482,7 @@ static void thread_parse_accept(protocol_interface_info_entry_t *cur, mle_messag timeout = entry_temp->link_lifetime; } - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, timeout); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout); if (thread_i_am_router(cur) && thread_is_router_addr(entry_temp->mac16)) { // If we both are routers, mark the link as 2-way @@ -570,7 +570,7 @@ static void thread_parse_data_response(protocol_interface_info_entry_t *cur, mle return; } - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (entry_temp) { thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index, linkMargin, false); @@ -724,7 +724,7 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent bool data_request_needed = false; tr_debug("Child update request"); - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (!thread_leader_data_parse(mle_msg->data_ptr, mle_msg->data_length, &leaderData) || !entry_temp || @@ -799,7 +799,7 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t * //mle_service_buffer_find leader_data_received = thread_leader_data_parse(mle_msg->data_ptr, mle_msg->data_length, &leaderData); - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status) && status == 1 && thread_check_is_this_my_parent(cur, entry_temp)) { @@ -836,7 +836,7 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t * } tr_debug("Keep-Alive -->Respond from Parent"); - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, timeout); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout); //Save possible new Leader Data if (leader_data_received) { diff --git a/source/6LoWPAN/Thread/thread_nd.c b/source/6LoWPAN/Thread/thread_nd.c index 42a860a0ee6..c5a3bb1bd7d 100644 --- a/source/6LoWPAN/Thread/thread_nd.c +++ b/source/6LoWPAN/Thread/thread_nd.c @@ -200,7 +200,7 @@ bool thread_nd_ns_transmit(protocol_interface_info_entry_t *cur, ipv6_neighbour_ static mac_neighbor_table_entry_t *thread_nd_child_mleid_get(protocol_interface_info_entry_t *cur, uint8_t *childAddress, uint8_t *mlmeid_ptr) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, childAddress, ADDR_802_15_4_SHORT); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), childAddress, ADDR_802_15_4_SHORT); if (entry && !entry->ffd_device) { uint8_t *ptr = thread_neighbor_class_get_mleid(&cur->thread_info->neighbor_class, entry->index); if (ptr) { @@ -370,7 +370,7 @@ buffer_t *thread_nd_snoop(protocol_interface_info_entry_t *cur, buffer_t *buf, c return buffer_free(buf); } - if (!mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, &ll_dst->address[2], ADDR_802_15_4_SHORT)) { + if (!mac_neighbor_table_address_discover(mac_neighbor_info(cur), &ll_dst->address[2], ADDR_802_15_4_SHORT)) { /* We now know this was a packet for a non-existent child */ goto bounce; } @@ -436,7 +436,7 @@ buffer_t *thread_nd_special_forwarding(protocol_interface_info_entry_t *cur, buf return buf; } - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, &ll_src->address[2], ADDR_802_15_4_SHORT); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), &ll_src->address[2], ADDR_802_15_4_SHORT); /* Due to note 1 and 1b above, full-function children / neighbor routers * who did resolve to an RLOC16 may have optimised out the mesh header. diff --git a/source/6LoWPAN/Thread/thread_network_synch.c b/source/6LoWPAN/Thread/thread_network_synch.c index 1e25e6f6d04..df0777c171e 100644 --- a/source/6LoWPAN/Thread/thread_network_synch.c +++ b/source/6LoWPAN/Thread/thread_network_synch.c @@ -253,7 +253,7 @@ void thread_dynamic_storage_build_mle_table(int8_t interface_id) return; } - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; if (!mac_table_list) { return; @@ -268,7 +268,7 @@ void thread_dynamic_storage_build_mle_table(int8_t interface_id) uint8_t *mac64 = storeEntry->networ_dynamic_data_parameters.children[i].long_addr; tr_debug("Child: %04x, %s", storeEntry->networ_dynamic_data_parameters.children[i].short_addr, trace_array(mac64, 8)); - mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(cur->mac_parameters->mac_neighbor_table, mac64, true, &new_entry_created); + mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(mac_neighbor_info(cur), mac64, true, &new_entry_created); if (mac_entry) { mac_entry->mac16 = storeEntry->networ_dynamic_data_parameters.children[i].short_addr; diff --git a/source/6LoWPAN/Thread/thread_router_bootstrap.c b/source/6LoWPAN/Thread/thread_router_bootstrap.c index 185e3648760..0f1d3914a4b 100644 --- a/source/6LoWPAN/Thread/thread_router_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_router_bootstrap.c @@ -227,7 +227,7 @@ static void clone_multicast_to_unicast(protocol_interface_info_entry_t *cur, mac static void mle_multicast_push_to_sleep_child(protocol_interface_info_entry_t *cur, buffer_t *buf) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) { if (!cur_entry->rx_on_idle) { @@ -249,7 +249,7 @@ static void thread_registered_mcast_forward_to_child(protocol_interface_info_ent tr_debug("Forwarding to registered multicast address: %s", trace_ipv6(addr->address)); ns_list_foreach(thread_mcast_child_t, child, &addr->children) { - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, child->mac64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), child->mac64, ADDR_802_15_4_LONG); if (entry && !entry->rx_on_idle) { clone_multicast_to_unicast(cur, entry, buffer); } @@ -339,7 +339,7 @@ static void thread_router_synch_receive_cb(int8_t interface_id, mle_message_t *m return; } //Allocate neighbor entry - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, true, &new_neigbour); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, true, &new_neigbour); if (!entry_temp) { return; } @@ -366,7 +366,7 @@ static void thread_router_synch_receive_cb(int8_t interface_id, mle_message_t *m } } - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, timeout_tlv); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout_tlv); if (thread_is_router_addr(shortAddress)) { entry_temp->connected_device = 1; @@ -982,11 +982,11 @@ void thread_router_bootstrap_child_information_clear(protocol_interface_info_ent } // Remove mle neighbour entries for children in previous partition - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach_safe(mac_neighbor_table_entry_t, table_entry, mac_table_list) { if (table_entry->mac16 < 0xfffe && !thread_is_router_addr(table_entry->mac16)) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, table_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), table_entry); } } } @@ -995,14 +995,14 @@ static void thread_router_bootstrap_invalid_child_information_clear(protocol_int tr_debug("Thread Short address changed old: %x new: %x", cur->thread_info->routerShortAddress, router_rloc); - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; // scrub neighbours with child addresses that are not ours ns_list_foreach_safe(mac_neighbor_table_entry_t, table_entry, mac_table_list) { if (table_entry->mac16 < 0xfffe && !thread_is_router_addr(table_entry->mac16) && thread_router_addr_from_addr(table_entry->mac16) != router_rloc) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, table_entry); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), table_entry); } } } @@ -1200,7 +1200,7 @@ uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t if (router_address >= 0xfffe) { return 0; } - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) { if (thread_router_addr_from_addr(cur_entry->mac16) == router_address) { @@ -1212,7 +1212,7 @@ uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t static uint16_t thread_router_bootstrap_child_address_generate(protocol_interface_info_entry_t *cur) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; if (thread_router_bootstrap_child_count_get(cur) >= cur->thread_info->maxChildCount) { tr_info("Maximum count %d reached", cur->thread_info->maxChildCount); @@ -1292,7 +1292,7 @@ void thread_router_bootstrap_child_id_handler(protocol_interface_info_entry_t *c memcpy(&ll64[8], req->euid64 , 8); ll64[8] ^= 2; //Allocate entry - mac_neighbor_table_entry_t *entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, ll64, true, &new_neigbour); + mac_neighbor_table_entry_t *entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), ll64, true, &new_neigbour); if (!entry_temp) { //Send link reject @@ -1306,7 +1306,7 @@ void thread_router_bootstrap_child_id_handler(protocol_interface_info_entry_t *c // If mac frame couter is less than previous we need to leave the old one //Update or set neigh info - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, req->timeout); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, req->timeout); mle_mode_parse_to_mac_entry(entry_temp, req->mode); thread_neighbor_class_mode_parse_to_entry(&cur->thread_info->neighbor_class, entry_temp->index, req->mode); entry_temp->connected_device = 1; @@ -1314,7 +1314,7 @@ void thread_router_bootstrap_child_id_handler(protocol_interface_info_entry_t *c if (req->shortAddressReq) { if (!thread_child_id_request(cur, entry_temp)) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, entry_temp); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp); thread_link_reject_send(cur, ll64); goto free_request; } @@ -1454,7 +1454,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * } // parent request received - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (entry_temp) { //Set MAC modes mle_mode_parse_to_mac_entry(entry_temp, (MLE_FFD_DEV | MLE_RX_ON_IDLE)); @@ -1713,7 +1713,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * return; } - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (!mle_tlv_read_16_bit_tlv(MLE_TYPE_SRC_ADDRESS, mle_msg->data_ptr, mle_msg->data_length, &shortAddress)) { @@ -1726,7 +1726,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * */ if (entry_temp && entry_temp->connected_device) { - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, entry_temp->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, entry_temp->link_lifetime); thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index,linkMargin, false); thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index); thread_router_synch_accept_request_build(cur, mle_msg, entry_temp->mac16, challengeTlv.dataPtr, challengeTlv.tlvLen, requestTlv.dataPtr, requestTlv.tlvLen); @@ -1770,7 +1770,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * } } - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, entry_temp->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, entry_temp->link_lifetime); thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index,linkMargin, false); thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index); if (!mle_neigh_entry_frame_counter_update(entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur, security_headers->KeyIndex) && update_mac_mib) { @@ -1845,7 +1845,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * //Send Response - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, createNew, &new_entry); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, createNew, &new_entry); if (entry_temp) { thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index,linkMargin, new_entry); @@ -1867,7 +1867,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * link_lifetime = entry_temp->link_lifetime; } - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, link_lifetime); if (thread_is_router_addr(shortAddress)) { entry_temp->connected_device = 1; @@ -1899,7 +1899,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * mle_tlv_info_t addressRegisterTlv = {0}; mle_tlv_info_t challengeTlv = {0}; mle_tlv_info_t tlv_req = {0}; - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status)) { if (1 == status && thread_check_is_this_my_parent(cur, entry_temp)) { @@ -1944,9 +1944,9 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * if (mle_tlv_read_32_bit_tlv(MLE_TYPE_TIMEOUT, mle_msg->data_ptr, mle_msg->data_length, &timeout)) { tr_debug("Setting child timeout, value=%"PRIu32, timeout); - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, timeout); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, timeout); } else { - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, entry_temp, entry_temp->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, entry_temp->link_lifetime); } if (!leaderDataReceived) { @@ -1972,7 +1972,7 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * mle_tlv_info_t requestTlv; tr_info("Recv Router Data Request"); - entry_temp = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, mle_msg->packet_src_address, false, NULL); + entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL); if (!entry_temp || !mle_tlv_read_tlv(MLE_TYPE_TLV_REQUEST, mle_msg->data_ptr, mle_msg->data_length, &requestTlv)) { return; } @@ -2191,9 +2191,9 @@ void thread_router_bootstrap_child_id_reject(protocol_interface_info_entry_t *cu while (req) { tr_debug("Remove entry from list"); //Remove entry from list - mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, req->euid64, ADDR_802_15_4_LONG); + mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(cur), req->euid64, ADDR_802_15_4_LONG); if (neighbor) { - mac_neighbor_table_neighbor_remove(cur->mac_parameters->mac_neighbor_table, neighbor); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), neighbor); } ns_dyn_mem_free(req); @@ -2669,7 +2669,7 @@ static int thread_router_bootstrap_network_data_propagation(protocol_interface_i static void thread_router_bootstrap_network_data_push_to_sleep_child(protocol_interface_info_entry_t *cur, bool stableDataUpdate) { uint8_t childLinkLocalAddress[16]; - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; memcpy(childLinkLocalAddress, ADDR_LINK_LOCAL_PREFIX, 8); ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) { diff --git a/source/6LoWPAN/Thread/thread_routing.c b/source/6LoWPAN/Thread/thread_routing.c index 7ea470c8ce3..311cee2e4e3 100644 --- a/source/6LoWPAN/Thread/thread_routing.c +++ b/source/6LoWPAN/Thread/thread_routing.c @@ -266,7 +266,7 @@ static int_fast8_t thread_route_fn( uint16_t dest_router_addr = thread_router_addr_from_addr(dest); if (dest_router_addr == mac16) { /* We're this device's parent - transmit direct to it */ - mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, dest_addr, ADDR_802_15_4_SHORT); + mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), dest_addr, ADDR_802_15_4_SHORT); if (!entry || !entry->ffd_device) { /* To cover some of draft-kelsey-thread-network-data-00, we send the * packet up to our own IP layer in the case where it's addressed to diff --git a/source/6LoWPAN/Thread/thread_test_api.c b/source/6LoWPAN/Thread/thread_test_api.c index 6cc4b61e61b..d2019c5e9ef 100644 --- a/source/6LoWPAN/Thread/thread_test_api.c +++ b/source/6LoWPAN/Thread/thread_test_api.c @@ -1120,7 +1120,7 @@ int8_t thread_test_child_info_get(int8_t interface_id, uint8_t index, uint16_t * return -1; } uint16_t mac16 = mac_helper_mac16_address_get(cur); - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; if (!mac_table_list) { return -1; } @@ -1158,7 +1158,7 @@ int8_t thread_test_neighbour_info_get(int8_t interface_id, uint8_t index, uint16 return -1; } uint16_t mac16 = mac_helper_mac16_address_get(cur); - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; if (!mac_table_list) { return -1; } diff --git a/source/6LoWPAN/adaptation_interface.c b/source/6LoWPAN/adaptation_interface.c index 4a4901e896d..19a6d4bf7f6 100644 --- a/source/6LoWPAN/adaptation_interface.c +++ b/source/6LoWPAN/adaptation_interface.c @@ -147,7 +147,7 @@ static void lowpan_adaptation_etx_update_cb(protocol_interface_info_entry_t *cur success = true; } // Gets table entry - mac_neighbor_table_entry_t *neigh_table_ptr = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, buf->dst_sa.address + PAN_ID_LEN, buf->dst_sa.addr_type); + mac_neighbor_table_entry_t *neigh_table_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + PAN_ID_LEN, buf->dst_sa.addr_type); if (neigh_table_ptr) { etx_transm_attempts_update(cur->id, 1 + confirm->tx_retries , success, neigh_table_ptr->index); // Updates ETX statistics @@ -618,10 +618,10 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_ /* If MLE is enabled, we will talk if we have an MLE association */ if (buf->dst_sa.addr_type == ADDR_802_15_4_LONG ) { - neigh_entry_ptr = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, buf->dst_sa.address + 2, buf->dst_sa.addr_type); + neigh_entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + 2, buf->dst_sa.addr_type); } else if(buf->dst_sa.addr_type == ADDR_802_15_4_SHORT && (common_read_16_bit(buf->dst_sa.address + 2)) != 0xffff) { - neigh_entry_ptr = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, buf->dst_sa.address + 2, buf->dst_sa.addr_type); + neigh_entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + 2, buf->dst_sa.addr_type); } //Validate neighbour @@ -795,7 +795,7 @@ static void lowpan_adaptation_make_room_for_small_packet(protocol_interface_info uint_fast16_t count = 0; ns_list_foreach_reverse_safe(fragmenter_tx_entry_t, tx_entry, &interface_ptr->indirect_tx_queue) { - mac_neighbor_table_entry_t *tx_neighbour = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, tx_entry->buf->dst_sa.address + 2, tx_entry->buf->dst_sa.addr_type); + mac_neighbor_table_entry_t *tx_neighbour = mac_neighbor_table_address_discover(mac_neighbor_info(cur), tx_entry->buf->dst_sa.address + 2, tx_entry->buf->dst_sa.addr_type); if (tx_neighbour == neighbour_to_count && buffer_data_length(tx_entry->buf) <= interface_ptr->indirect_big_packet_threshold) { if (++count >= interface_ptr->max_indirect_small_packets_per_child) { lowpan_adaptation_indirect_queue_free_message(cur, interface_ptr, tx_entry); @@ -917,7 +917,7 @@ int8_t lowpan_adaptation_interface_tx(protocol_interface_info_entry_t *cur, buff if (indirect) { //Add to indirectQUue fragmenter_tx_entry_t *tx_ptr_cached; - mac_neighbor_table_entry_t *neigh_entry_ptr = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, buf->dst_sa.address + PAN_ID_LEN, buf->dst_sa.addr_type); + mac_neighbor_table_entry_t *neigh_entry_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + PAN_ID_LEN, buf->dst_sa.addr_type); if (neigh_entry_ptr) { buf->link_specific.ieee802_15_4.indirectTTL = (uint32_t) neigh_entry_ptr->link_lifetime * 1000; } else { @@ -1160,7 +1160,7 @@ static bool mac_data_is_broadcast_addr(const sockaddr_t *addr) static bool mcps_data_indication_neighbor_validate(protocol_interface_info_entry_t *cur, const sockaddr_t *addr) { - mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, addr->address + 2, addr->addr_type); + mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr->address + 2, addr->addr_type); if (neighbor && (neighbor->connected_device || neighbor->trusted_device)) { return true; } diff --git a/source/6LoWPAN/ws/ws_bootstrap.c b/source/6LoWPAN/ws/ws_bootstrap.c index 24b8e26adbe..b074e123edb 100644 --- a/source/6LoWPAN/ws/ws_bootstrap.c +++ b/source/6LoWPAN/ws/ws_bootstrap.c @@ -83,12 +83,12 @@ static uint16_t ws_bootstrap_get_min_rank_inc(protocol_interface_info_entry_t *c mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64) { - mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, src64, MAC_ADDR_MODE_64_BIT); + mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT); if (neighbor) { return neighbor; } - neighbor = mac_neighbor_table_entry_allocate(interface->mac_parameters->mac_neighbor_table, src64); + neighbor = mac_neighbor_table_entry_allocate(mac_neighbor_info(interface), src64); if (!neighbor) { return NULL; } @@ -110,7 +110,7 @@ static void ws_bootstrap_neighbor_delete(struct protocol_interface_info_entry *i static void ws_bootstrap_neighbor_list_clean(struct protocol_interface_info_entry *interface) { - mac_neighbor_table_neighbor_list_clean(interface->mac_parameters->mac_neighbor_table); + mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(interface)); } static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_entry *interface, const struct if_address_entry *addr, if_address_callback_t reason) @@ -158,10 +158,10 @@ static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t static fhss_ws_neighbor_timing_info_t *ws_get_neighbor_info(const fhss_api_t *api, uint8_t eui64[8]) { protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_fhss_api(api); - if (!cur || !cur->mac_parameters || !cur->mac_parameters->mac_neighbor_table) { + if (!cur || !cur->mac_parameters || !mac_neighbor_info(cur)) { return NULL; } - mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(cur->mac_parameters->mac_neighbor_table, eui64, MAC_ADDR_MODE_64_BIT); + mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(cur), eui64, MAC_ADDR_MODE_64_BIT); if (!mac_neighbor) { return NULL; } @@ -724,7 +724,7 @@ static void ws_bootstrap_asynch_confirm(struct protocol_interface_info_entry *in static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t * neighbor_buffer, bool request_new) { - neighbor_buffer->neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, mac_64, ADDR_802_15_4_LONG); + neighbor_buffer->neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), mac_64, ADDR_802_15_4_LONG); if (neighbor_buffer->neighbor) { neighbor_buffer->ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_buffer->neighbor->index); if (!neighbor_buffer->ws_neighbor) { @@ -745,7 +745,7 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en neighbor_buffer->ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_buffer->neighbor->index); if (!neighbor_buffer->ws_neighbor) { mac_helper_devicetable_remove(interface->mac_api, neighbor_buffer->neighbor->index); - mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, neighbor_buffer->neighbor); + mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), neighbor_buffer->neighbor); return false; } return true; @@ -849,10 +849,10 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode) //Disable allways by default lowpan_adaptation_interface_mpx_register(interface_id, NULL, 0); - mac_neighbor_table_delete(cur->mac_parameters->mac_neighbor_table); - cur->mac_parameters->mac_neighbor_table = mac_neighbor_table_create(buffer.device_decription_table_size, ws_neighbor_entry_remove_notify + mac_neighbor_table_delete(mac_neighbor_info(cur)); + mac_neighbor_info(cur) = mac_neighbor_table_create(buffer.device_decription_table_size, ws_neighbor_entry_remove_notify , ws_neighbor_entry_nud_notify, cur); - if (!cur->mac_parameters->mac_neighbor_table) { + if (!mac_neighbor_info(cur)) { ret_val = -1; goto init_fail; } @@ -902,7 +902,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode) //Error handling and free memory init_fail: lowpan_adaptation_interface_mpx_register(interface_id, NULL, 0); - mac_neighbor_table_delete(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_delete(mac_neighbor_info(cur)); etx_storage_list_allocate(cur->id, 0); ws_neighbor_class_dealloc(&neigh_info); ws_llc_delete(cur); diff --git a/source/6LoWPAN/ws/ws_common.c b/source/6LoWPAN/ws/ws_common.c index 87640f4882d..4ff2fcb9eee 100644 --- a/source/6LoWPAN/ws/ws_common.c +++ b/source/6LoWPAN/ws/ws_common.c @@ -168,14 +168,14 @@ void ws_common_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seco void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8_t *ll_address) { //Neighbor connectected update - mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_by_ll64(cur->mac_parameters->mac_neighbor_table, ll_address, false, NULL); + mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), ll_address, false, NULL); if (mac_neighbor) { if (mac_neighbor->nud_active) { tr_debug("NUD Response %u", mac_neighbor->index); - mac_neighbor_table_neighbor_refresh(cur->mac_parameters->mac_neighbor_table, mac_neighbor, mac_neighbor->link_lifetime); + mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), mac_neighbor, mac_neighbor->link_lifetime); } - mac_neighbor_table_neighbor_connected(cur->mac_parameters->mac_neighbor_table, mac_neighbor); + mac_neighbor_table_neighbor_connected(mac_neighbor_info(cur), mac_neighbor); } } diff --git a/source/6LoWPAN/ws/ws_llc_data_service.c b/source/6LoWPAN/ws/ws_llc_data_service.c index 7cfabd973c0..b02e1b38ddc 100644 --- a/source/6LoWPAN/ws/ws_llc_data_service.c +++ b/source/6LoWPAN/ws/ws_llc_data_service.c @@ -535,7 +535,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t if (data->Key.SecurityLevel) { //SET trusted state - mac_neighbor_table_trusted_neighbor(interface->mac_parameters->mac_neighbor_table, neighbor_info.neighbor, true); + mac_neighbor_table_trusted_neighbor(mac_neighbor_info(interface), neighbor_info.neighbor, true); } } diff --git a/source/BorderRouter/border_router.c b/source/BorderRouter/border_router.c index a83b4485c08..09a4994bba8 100644 --- a/source/BorderRouter/border_router.c +++ b/source/BorderRouter/border_router.c @@ -506,7 +506,7 @@ void border_router_start(protocol_interface_info_entry_t *cur, bool warm_link_re if (warm_link_restart) { return; } - mac_neighbor_table_neighbor_list_clean(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(cur)); #ifndef NO_MLE blacklist_clear(); #endif @@ -707,7 +707,7 @@ static int8_t arm_border_router_interface_down(protocol_interface_info_entry_t * cur->nwk_wpan_nvm_api->nvm_params_update_cb(cur->nwk_wpan_nvm_api, true); } cur->if_lowpan_security_params->mle_security_frame_counter = mle_service_security_get_frame_counter(cur->id); - mac_neighbor_table_neighbor_list_clean(cur->mac_parameters->mac_neighbor_table); + mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(cur)); #ifndef NO_MLE blacklist_clear(); #endif diff --git a/source/MLE/mle.c b/source/MLE/mle.c index 64a3b473cd5..7203cdeb344 100644 --- a/source/MLE/mle.c +++ b/source/MLE/mle.c @@ -52,14 +52,14 @@ int16_t mle_class_free_entry_count_get(struct protocol_interface_info_entry *cur) { - mac_neighbor_table_list_t *mac_table_free_list = &cur->mac_parameters->mac_neighbor_table->free_list; + mac_neighbor_table_list_t *mac_table_free_list = &mac_neighbor_info(cur)->free_list; return ns_list_count(mac_table_free_list); } int16_t mle_class_sleepy_entry_count_get(struct protocol_interface_info_entry *cur) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; uint16_t count = 0; @@ -74,7 +74,7 @@ int16_t mle_class_sleepy_entry_count_get(struct protocol_interface_info_entry *c int16_t mle_class_rfd_entry_count_get(struct protocol_interface_info_entry *cur) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; uint16_t count = 0; @@ -89,7 +89,7 @@ int16_t mle_class_rfd_entry_count_get(struct protocol_interface_info_entry *cur) uint16_t mle_class_active_neigh_counter(protocol_interface_info_entry_t *cur) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; return ns_list_count(mac_table_list); } @@ -98,7 +98,7 @@ uint16_t mle_class_active_neigh_counter(protocol_interface_info_entry_t *cur) int8_t mle_class_set_new_key_pending(struct protocol_interface_info_entry *cur) { - mac_neighbor_table_list_t *mac_table_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list; + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; ns_list_foreach_safe(mac_neighbor_table_entry_t, cur_entry, mac_table_list) { mle_service_frame_counter_entry_new_key_pending_set(cur->id, cur_entry->index); diff --git a/source/NWK_INTERFACE/protocol_core.c b/source/NWK_INTERFACE/protocol_core.c index 5c622360052..7c706a0f231 100644 --- a/source/NWK_INTERFACE/protocol_core.c +++ b/source/NWK_INTERFACE/protocol_core.c @@ -251,7 +251,7 @@ void core_timer_event_handle(uint16_t ticksUpdate) } if (cur->mac_parameters) { - mac_neighbor_table_neighbor_timeout_update(cur->mac_parameters->mac_neighbor_table, seconds); + mac_neighbor_table_neighbor_timeout_update(mac_neighbor_info(cur), seconds); } if (cur->nwk_wpan_nvm_api) { diff --git a/source/Service_Libs/etx/etx.c b/source/Service_Libs/etx/etx.c index 00413d26225..2ada5698415 100644 --- a/source/Service_Libs/etx/etx.c +++ b/source/Service_Libs/etx/etx.c @@ -194,7 +194,7 @@ uint16_t etx_read(int8_t interface_id, addrtype_t addr_type, const uint8_t *addr } //Must Support old MLE table and new still same time - mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, addr_ptr + PAN_ID_LEN, addr_type); + mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), addr_ptr + PAN_ID_LEN, addr_type); if (!mac_neighbor) { return 0xffff; } diff --git a/source/Service_Libs/mac_neighbor_table/mac_neighbor_table.h b/source/Service_Libs/mac_neighbor_table/mac_neighbor_table.h index 9694f0a0ae4..923a396c739 100644 --- a/source/Service_Libs/mac_neighbor_table/mac_neighbor_table.h +++ b/source/Service_Libs/mac_neighbor_table/mac_neighbor_table.h @@ -50,6 +50,8 @@ typedef struct mac_neighbor_table_entry { typedef NS_LIST_HEAD(mac_neighbor_table_entry_t, link) mac_neighbor_table_list_t; +#define mac_neighbor_info(interface) ((interface)->mac_parameters->mac_neighbor_table) /*!< Helper macro for give mac neighbor class pointer from interface pointer. */ + /** * Remove entry notify * diff --git a/source/Service_Libs/mle_service/mle_service.c b/source/Service_Libs/mle_service/mle_service.c index baecc61738b..1b67460e0c2 100644 --- a/source/Service_Libs/mle_service/mle_service.c +++ b/source/Service_Libs/mle_service/mle_service.c @@ -657,7 +657,7 @@ static int mle_service_build_packet_send(service_instance_t *srv_ptr, mle_securi static mle_neighbor_security_counter_info_t *mle_service_get_neighbour_info(protocol_interface_info_entry_t *cur_interface, uint8_t *ll64) { - mac_neighbor_table_entry_t *neighbour = mac_neighbor_entry_get_by_ll64(cur_interface->mac_parameters->mac_neighbor_table,ll64, false, NULL); + mac_neighbor_table_entry_t *neighbour = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur_interface),ll64, false, NULL); if (!neighbour) { return NULL; }