diff --git a/features/nanostack/sal-stack-nanostack/nanostack/net_ws_test.h b/features/nanostack/sal-stack-nanostack/nanostack/net_ws_test.h index 3dfe75d875..6bd20c658a 100644 --- a/features/nanostack/sal-stack-nanostack/nanostack/net_ws_test.h +++ b/features/nanostack/sal-stack-nanostack/nanostack/net_ws_test.h @@ -204,6 +204,19 @@ void ws_test_skip_edfe_data_send(int8_t interface_id, bool skip); */ int8_t ws_test_drop_edfe_data_frames(int8_t interface_id, uint8_t number_of_dropped_frames); +/** + * Set neighbour temporary timeout value. + * + * Made only for test purpose for test EDFE certificatiomn test harness. + * + * \param interface_id Network interface ID. + * \param temporary_lifetime 0 to disable test harness, 240-2200 enable longer temporary neighbour lifetime. Values bigger than 2200 will be capped to 2200. + * + * \return 0 Success + * \return <0 Failure + */ +int ws_test_neighbour_temporary_lifetime_set(int8_t interface_id, uint32_t temporary_lifetime); + #ifdef __cplusplus } #endif diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bootstrap.c b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bootstrap.c index 808acb7bf2..c0b6d5ffc5 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bootstrap.c +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bootstrap.c @@ -139,8 +139,8 @@ mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interf } // TODO only call these for new neighbour mlme_device_descriptor_t device_desc; - neighbor->lifetime = WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME; - neighbor->link_lifetime = WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME; + neighbor->lifetime = ws_cfg_neighbour_temporary_lifetime_get(); + neighbor->link_lifetime = ws_cfg_neighbour_temporary_lifetime_get(); mac_helper_device_description_write(interface, &device_desc, neighbor->mac64, neighbor->mac16, 0, false); mac_helper_devicetable_set(&device_desc, interface, neighbor->index, interface->mac_parameters->mac_default_key_index, true); @@ -1828,7 +1828,7 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent continue; } - if (cur->link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT) { + if (cur->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) { continue; } @@ -1959,7 +1959,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, entry_ptr->index); etx_storage_t *etx_entry = etx_storage_entry_get(cur->id, entry_ptr->index); - if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || ws_neighbor->negative_aro_send || entry_ptr->link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT) { + if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || ws_neighbor->negative_aro_send || entry_ptr->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) { return false; } diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.c b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.c index 8eacf4802d..0423ce654b 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.c +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.c @@ -55,6 +55,7 @@ typedef struct ws_cfg_nw_size_s { ws_sec_prot_cfg_t sec_prot; /**< Security protocols configuration */ } ws_cfg_nw_size_t; +static uint32_t ws_test_temporary_entry_lifetime = 0; typedef int8_t (*ws_cfg_default_set)(void *cfg); typedef int8_t (*ws_cfg_validate)(void *cfg, void *new_cfg); typedef int8_t (*ws_cfg_set)(protocol_interface_info_entry_t *cur, void *cfg, void *new_cfg, uint8_t *flags); @@ -1275,4 +1276,21 @@ int8_t ws_cfg_settings_set(protocol_interface_info_entry_t *cur, ws_cfg_t *new_c return ret_value; } +uint32_t ws_cfg_neighbour_temporary_lifetime_get(void) +{ + if (ws_test_temporary_entry_lifetime) { + return ws_test_temporary_entry_lifetime; + } + return WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME; +} +void ws_cfg_neighbour_temporary_lifetime_set(uint32_t lifetime) +{ + if (lifetime >= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME || lifetime == 0) { + if (lifetime > WS_NEIGHBOR_LINK_TIMEOUT) { + lifetime = WS_NEIGHBOR_LINK_TIMEOUT; + } + ws_test_temporary_entry_lifetime = lifetime; + } +} + #endif //HAVE_WS diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.h b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.h index bc46336229..5e0e8c34c8 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.h +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_cfg_settings.h @@ -187,4 +187,7 @@ int8_t ws_cfg_sec_prot_get(ws_sec_prot_cfg_t *cfg, uint8_t *flags); int8_t ws_cfg_sec_prot_validate(ws_sec_prot_cfg_t *cfg, ws_sec_prot_cfg_t *new_cfg); int8_t ws_cfg_sec_prot_set(protocol_interface_info_entry_t *cur, ws_sec_prot_cfg_t *cfg, ws_sec_prot_cfg_t *new_cfg, uint8_t *flags); +uint32_t ws_cfg_neighbour_temporary_lifetime_get(void); +void ws_cfg_neighbour_temporary_lifetime_set(uint32_t lifetime); + #endif // WS_CFG_STORAGE_H_ diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h index 58f570f871..c6e84d13bd 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h @@ -241,6 +241,7 @@ typedef struct ws_bs_ie { #define WS_NEIGHBOR_LINK_TIMEOUT 2200 +#define WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME 240 #define WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME 5 #define WS_NEIGHBOUR_DHCP_ENTRY_LIFETIME 60 #define WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_LARGE 520 diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_empty_functions.c b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_empty_functions.c index 942eb00e40..990c423df8 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_empty_functions.c +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_empty_functions.c @@ -422,4 +422,26 @@ int ws_device_min_sens_set( return -1; } +int ws_test_neighbour_temporary_lifetime_set(int8_t interface_id, uint32_t temporary_lifetime) +{ + (void) interface_id; + (void) temporary_lifetime; + return -1; +} + +void ws_test_skip_edfe_data_send(int8_t interface_id, bool skip) +{ + (void) interface_id; + (void) skip; +} + + +int8_t ws_test_drop_edfe_data_frames(int8_t interface_id, uint8_t number_of_dropped_frames) +{ + (void) interface_id; + (void) number_of_dropped_frames; + return -1; +} + + #endif // no HAVE_WS diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc_data_service.c b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc_data_service.c index d20f9980c9..098f1a4b1e 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc_data_service.c +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc_data_service.c @@ -537,7 +537,7 @@ static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t * ws_llc_mpx_eapol_send(base, message); } } else { - if (neighbor_info.ws_neighbor && neighbor_info.neighbor && neighbor_info.neighbor->link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT) { + if (neighbor_info.ws_neighbor && neighbor_info.neighbor && neighbor_info.neighbor->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) { //Remove temp neighbour tr_debug("Remove Temp Entry by TX confirm"); mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), neighbor_info.neighbor); diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_test_api.c b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_test_api.c index 2e7cc97259..682bbf7dd1 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_test_api.c +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_test_api.c @@ -164,4 +164,17 @@ int ws_test_6lowpan_fragmentation_mtu_size_set(int8_t interface_id, uint16_t mtu return 0; } +int ws_test_neighbour_temporary_lifetime_set(int8_t interface_id, uint32_t temporary_lifetime) +{ + protocol_interface_info_entry_t *cur; + + cur = protocol_stack_interface_info_get_by_id(interface_id); + if (!cur || !ws_info(cur)) { + return -1; + } + + ws_cfg_neighbour_temporary_lifetime_set(temporary_lifetime); + return 0; +} + #endif // HAVE_WS diff --git a/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.c b/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.c index 2a814d3fd0..38924cba93 100644 --- a/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.c +++ b/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.c @@ -1794,6 +1794,9 @@ int8_t mcps_generic_edfe_frame_init(protocol_interface_rf_mac_setup_s *rf_ptr, c //Data Here mac_pre_build_frame_t *buffer; if (response->wait_response) { + if (rf_ptr->active_pd_data_request == NULL) { + return -1; + } buffer = rf_ptr->active_pd_data_request; buffer->message_builded = false; } else { diff --git a/features/nanostack/sal-stack-nanostack/source/libNET/src/net_dns.c b/features/nanostack/sal-stack-nanostack/source/libNET/src/net_dns.c index b7c7c3eec5..434bd4d6d3 100644 --- a/features/nanostack/sal-stack-nanostack/source/libNET/src/net_dns.c +++ b/features/nanostack/sal-stack-nanostack/source/libNET/src/net_dns.c @@ -150,15 +150,17 @@ int8_t net_dns_server_search_list_set(int8_t interface_id, const uint8_t address info_ptr->dns_search_list_ptr = NULL; } - if (!info_ptr->dns_search_list_ptr) { - info_ptr->dns_search_list_ptr = ns_dyn_mem_alloc(dns_search_list_len); + if (dns_search_list_len) { + if (!info_ptr->dns_search_list_ptr) { + info_ptr->dns_search_list_ptr = ns_dyn_mem_alloc(dns_search_list_len); + } + + if (!info_ptr->dns_search_list_ptr) { + return -2; + } + memcpy(info_ptr->dns_search_list_ptr, dns_search_list_ptr, dns_search_list_len); } - if (!info_ptr->dns_search_list_ptr) { - return -2; - } - - memcpy(info_ptr->dns_search_list_ptr, dns_search_list_ptr, dns_search_list_len); info_ptr->dns_search_list_len = dns_search_list_len; tr_info("DNS Search List: %s Lifetime: %lu", trace_array(info_ptr->dns_search_list_ptr, info_ptr->dns_search_list_len), (unsigned long) info_ptr->lifetime);