Merge commit 'ab953a0d782c8121aaf9b6c952410fa695841781' into PR14164

* commit 'ab953a0d782c8121aaf9b6c952410fa695841781':
  Squashed 'features/nanostack/sal-stack-nanostack/' changes from 3183d87e41..f8ae0e9bc9
pull/14164/head
Arto Kinnunen 2021-01-21 14:11:58 +02:00
commit e1fbfb682b
19 changed files with 177 additions and 47 deletions

View File

@ -70,7 +70,7 @@ int_fast8_t arm_nwk_6lowpan_thread_test_add_neighbour(
const uint8_t *id_mask, const uint8_t *id_mask,
const uint8_t *route_data) const uint8_t *route_data)
{ {
#ifdef HAVE_THREAD #ifdef HAVE_THREAD_ROUTER
protocol_interface_info_entry_t *cur; protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id); cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur) { if (!cur) {
@ -94,7 +94,7 @@ int_fast8_t arm_nwk_6lowpan_thread_test_remove_neighbour(
int8_t interface_id, int8_t interface_id,
uint16_t neighbour_short_addr) uint16_t neighbour_short_addr)
{ {
#ifdef HAVE_THREAD #ifdef HAVE_THREAD_ROUTER
protocol_interface_info_entry_t *cur; protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id); cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur) { if (!cur) {
@ -1220,7 +1220,7 @@ int8_t thread_test_initial_slaac_iid_set(int8_t interface_id, uint8_t *iid)
int8_t thread_test_router_id_request_send(int8_t interface_id, uint8_t status) int8_t thread_test_router_id_request_send(int8_t interface_id, uint8_t status)
{ {
#ifdef HAVE_THREAD #ifdef HAVE_THREAD_ROUTER
protocol_interface_info_entry_t *cur; protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id); cur = protocol_stack_interface_info_get_by_id(interface_id);

View File

@ -1086,6 +1086,32 @@ cleanup:
return ret_val; return ret_val;
} }
void ws_bootstrap_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type)
{
if (cur->nwk_bootstrap_state == ER_RPL_NETWORK_LEAVING) {
//Already moved to leaving state.
return;
}
if (cur->rpl_domain && cur->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
//Stop Asych Timer
ws_bootstrap_asynch_trickle_stop(cur);
tr_debug("Start Network soft leaving");
if (event_type == WS_FAST_DISCONNECT) {
rpl_control_instant_poison(cur, cur->rpl_domain);
cur->bootsrap_state_machine_cnt = 80; //Give 8 seconds time to send Poison
} else {
rpl_control_poison(cur->rpl_domain, 1);
cur->bootsrap_state_machine_cnt = 6000; //Give 10 minutes time for poison if RPL is not report
}
} else {
ws_bootstrap_event_discovery_start(cur);
}
cur->nwk_bootstrap_state = ER_RPL_NETWORK_LEAVING;
}
static void ws_bootstrap_asynch_trickle_stop(protocol_interface_info_entry_t *cur) static void ws_bootstrap_asynch_trickle_stop(protocol_interface_info_entry_t *cur)
{ {
cur->ws_info->trickle_pas_running = false; cur->ws_info->trickle_pas_running = false;
@ -1638,7 +1664,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
tr_debug("NEW Brodcast Schedule %u...BR rebooted", ws_bs_ie.broadcast_schedule_identifier); tr_debug("NEW Brodcast Schedule %u...BR rebooted", ws_bs_ie.broadcast_schedule_identifier);
cur->ws_info->ws_bsi_block.block_time = cur->ws_info->cfg->timing.pan_timeout; cur->ws_info->ws_bsi_block.block_time = cur->ws_info->cfg->timing.pan_timeout;
cur->ws_info->ws_bsi_block.old_bsi = cur->ws_info->hopping_schdule.fhss_bsi; cur->ws_info->ws_bsi_block.old_bsi = cur->ws_info->hopping_schdule.fhss_bsi;
ws_bootstrap_event_discovery_start(cur); ws_bootstrap_event_disconnect(cur, WS_NORMAL_DISCONNECT);
} }
return; return;
} }
@ -2364,7 +2390,11 @@ int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_rf_chan
set_request.value_size = sizeof(phy_rf_channel_configuration_s); set_request.value_size = sizeof(phy_rf_channel_configuration_s);
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_request); cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_request);
// Set Ack wait duration // Set Ack wait duration
uint16_t ack_wait_symbols = WS_ACK_WAIT_SYMBOLS + (WS_TACK_MAX_MS * (rf_configs.datarate / 1000)); uint8_t bits_per_symbol = 1;
if (rf_configs.modulation == M_OFDM) {
bits_per_symbol = 4;
}
uint16_t ack_wait_symbols = WS_ACK_WAIT_SYMBOLS + (WS_TACK_MAX_MS * (rf_configs.datarate / 1000) / bits_per_symbol);
set_request.attr = macAckWaitDuration; set_request.attr = macAckWaitDuration;
set_request.value_pointer = &ack_wait_symbols; set_request.value_pointer = &ack_wait_symbols;
set_request.value_size = sizeof(ack_wait_symbols); set_request.value_size = sizeof(ack_wait_symbols);
@ -2553,6 +2583,15 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) { if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) {
return; return;
} }
if (event == RPL_EVENT_POISON_FINISHED) {
//If we are waiting poison we will trig Discovery after couple seconds
if (cur->nwk_bootstrap_state == ER_RPL_NETWORK_LEAVING) {
cur->bootsrap_state_machine_cnt = 80; //Give 8 seconds time to send Poison
}
return;
}
// if waiting for RPL and // if waiting for RPL and
if (event == RPL_EVENT_DAO_DONE) { if (event == RPL_EVENT_DAO_DONE) {
// Trigger statemachine check // Trigger statemachine check
@ -2832,6 +2871,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
rpl_control_set_dao_retry_count(WS_MAX_DAO_RETRIES); rpl_control_set_dao_retry_count(WS_MAX_DAO_RETRIES);
rpl_control_set_initial_dao_ack_wait(WS_MAX_DAO_INITIAL_TIMEOUT); rpl_control_set_initial_dao_ack_wait(WS_MAX_DAO_INITIAL_TIMEOUT);
rpl_control_set_mrhof_parent_set_size(WS_MAX_PARENT_SET_COUNT); rpl_control_set_mrhof_parent_set_size(WS_MAX_PARENT_SET_COUNT);
rpl_control_set_force_tunnel(true);
if (cur->bootsrap_mode != ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) { if (cur->bootsrap_mode != ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
rpl_control_set_memory_limits(WS_NODE_RPL_SOFT_MEM_LIMIT, WS_NODE_RPL_HARD_MEM_LIMIT); rpl_control_set_memory_limits(WS_NODE_RPL_SOFT_MEM_LIMIT, WS_NODE_RPL_HARD_MEM_LIMIT);
} }
@ -3132,6 +3172,12 @@ void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur)
{ {
ws_bootsrap_event_trig(WS_ROUTING_READY, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL); ws_bootsrap_event_trig(WS_ROUTING_READY, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
} }
void ws_bootstrap_event_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type)
{
ws_bootsrap_event_trig(event_type, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
}
void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur) void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur)
{ {
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config, &cur->ws_info->trickle_params_pan_discovery); trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config, &cur->ws_info->trickle_params_pan_discovery);
@ -3315,6 +3361,7 @@ static int8_t ws_bootstrap_backbone_ip_addr_get(protocol_interface_info_entry_t
return -1; return -1;
} }
static void ws_bootstrap_event_handler(arm_event_s *event) static void ws_bootstrap_event_handler(arm_event_s *event)
{ {
ws_bootsrap_event_type_e event_type; ws_bootsrap_event_type_e event_type;
@ -3331,7 +3378,6 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
break; break;
case WS_DISCOVERY_START: case WS_DISCOVERY_START:
tr_info("Discovery start"); tr_info("Discovery start");
protocol_mac_reset(cur); protocol_mac_reset(cur);
ws_llc_reset(cur); ws_llc_reset(cur);
lowpan_adaptation_interface_reset(cur->id); lowpan_adaptation_interface_reset(cur->id);
@ -3467,6 +3513,12 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
ws_bootstrap_advertise_start(cur); ws_bootstrap_advertise_start(cur);
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE); ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
break; break;
case WS_FAST_DISCONNECT:
ws_bootstrap_disconnect(cur, WS_FAST_DISCONNECT);
break;
case WS_NORMAL_DISCONNECT:
ws_bootstrap_disconnect(cur, WS_NORMAL_DISCONNECT);
break;
default: default:
tr_err("Invalid event received"); tr_err("Invalid event received");
@ -3658,6 +3710,10 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
// Bootstrap_done event to application // Bootstrap_done event to application
nwk_bootsrap_state_update(ARM_NWK_BOOTSTRAP_READY, cur); nwk_bootsrap_state_update(ARM_NWK_BOOTSTRAP_READY, cur);
break; break;
case ER_RPL_NETWORK_LEAVING:
tr_debug("WS SM:RPL Leaving ready trigger discovery");
ws_bootstrap_event_discovery_start(cur);
break;
default: default:
tr_warn("WS SM:Invalid state %d", cur->nwk_bootstrap_state); tr_warn("WS SM:Invalid state %d", cur->nwk_bootstrap_state);
} }
@ -3743,9 +3799,10 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
} }
} else { } else {
// Border router has timed out // Border router has timed out
//Clear Timeout timer
cur->ws_info->pan_timeout_timer = 0; cur->ws_info->pan_timeout_timer = 0;
tr_warn("Border router has timed out"); tr_warn("Border router has timed out");
ws_bootstrap_event_discovery_start(cur); ws_bootstrap_event_disconnect(cur, WS_FAST_DISCONNECT);
} }
} }
if (cur->ws_info->aro_registration_timer) { if (cur->ws_info->aro_registration_timer) {

View File

@ -24,7 +24,9 @@ typedef enum {
WS_DISCOVERY_START, /**< discovery start*/ WS_DISCOVERY_START, /**< discovery start*/
WS_CONFIGURATION_START, /**< configuration learn start*/ WS_CONFIGURATION_START, /**< configuration learn start*/
WS_OPERATION_START, /**< active operation start*/ WS_OPERATION_START, /**< active operation start*/
WS_ROUTING_READY /**< RPL routing connected to BR*/ WS_ROUTING_READY, /**< RPL routing connected to BR*/
WS_FAST_DISCONNECT, /**< Do fast timeout after Border router timeout*/
WS_NORMAL_DISCONNECT /**< Border have been rebooted so Slow poison Process*/
} ws_bootsrap_event_type_e; } ws_bootsrap_event_type_e;
#ifdef HAVE_WS #ifdef HAVE_WS
@ -60,6 +62,8 @@ void ws_bootstrap_event_operation_start(protocol_interface_info_entry_t *cur);
void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur); void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur);
void ws_bootstrap_event_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type);
void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur); void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur);
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds); void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);

View File

@ -272,7 +272,7 @@ typedef struct protocol_interface_rf_mac_setup {
int8_t bc_timer_id; int8_t bc_timer_id;
uint32_t mlme_tick_count; uint32_t mlme_tick_count;
uint32_t symbol_rate; uint32_t symbol_rate;
uint32_t symbol_time_us; uint32_t symbol_time_ns;
uint32_t datarate; uint32_t datarate;
uint8_t max_ED; uint8_t max_ED;
uint16_t mlme_ED_counter; uint16_t mlme_ED_counter;

View File

@ -652,11 +652,11 @@ void mac_extended_mac_set(protocol_interface_rf_mac_setup_s *rf_mac_setup, const
static uint32_t mac_calc_ack_wait_duration(protocol_interface_rf_mac_setup_s *rf_mac_setup, uint16_t symbols) static uint32_t mac_calc_ack_wait_duration(protocol_interface_rf_mac_setup_s *rf_mac_setup, uint16_t symbols)
{ {
uint32_t AckWaitDuration = 0; uint32_t AckWaitDuration_us = 0;
if (rf_mac_setup->rf_csma_extension_supported) { if (rf_mac_setup->rf_csma_extension_supported) {
AckWaitDuration = symbols * rf_mac_setup->symbol_time_us; AckWaitDuration_us = (symbols * rf_mac_setup->symbol_time_ns) / 1000;
} }
return AckWaitDuration; return AckWaitDuration_us;
} }
static int8_t mac_mlme_set_ack_wait_duration(protocol_interface_rf_mac_setup_s *rf_mac_setup, const mlme_set_t *set_req) static int8_t mac_mlme_set_ack_wait_duration(protocol_interface_rf_mac_setup_s *rf_mac_setup, const mlme_set_t *set_req)
@ -1107,8 +1107,8 @@ static int mac_mlme_set_symbol_rate(protocol_interface_rf_mac_setup_s *rf_mac_se
{ {
if (rf_mac_setup->rf_csma_extension_supported) { if (rf_mac_setup->rf_csma_extension_supported) {
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_SYMBOLS_PER_SECOND, (uint8_t *) &rf_mac_setup->symbol_rate); rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_SYMBOLS_PER_SECOND, (uint8_t *) &rf_mac_setup->symbol_rate);
rf_mac_setup->symbol_time_us = 1000000 / rf_mac_setup->symbol_rate; rf_mac_setup->symbol_time_ns = 1000000000 / rf_mac_setup->symbol_rate;
tr_debug("SW-MAC driver support rf extension %"PRIu32" symbol/seconds %"PRIu32" us symbol time length", rf_mac_setup->symbol_rate, rf_mac_setup->symbol_time_us); tr_debug("SW-MAC driver support rf extension %"PRIu32" symbol/seconds %"PRIu32" ns symbol time length", rf_mac_setup->symbol_rate, rf_mac_setup->symbol_time_ns);
return 0; return 0;
} }
return -1; return -1;

View File

@ -97,7 +97,7 @@ uint32_t mac_csma_backoff_get(protocol_interface_rf_mac_setup_s *rf_mac_setup)
uint32_t backoff_in_us; uint32_t backoff_in_us;
//Multiple aUnitBackoffPeriod symbol time //Multiple aUnitBackoffPeriod symbol time
if (rf_mac_setup->rf_csma_extension_supported) { if (rf_mac_setup->rf_csma_extension_supported) {
backoff_in_us = backoff * rf_mac_setup->aUnitBackoffPeriod * rf_mac_setup->symbol_time_us; backoff_in_us = backoff * rf_mac_setup->aUnitBackoffPeriod * (rf_mac_setup->symbol_time_ns / 1000);
} else { } else {
backoff_in_us = backoff * rf_mac_setup->backoff_period_in_10us * 10; backoff_in_us = backoff * rf_mac_setup->backoff_period_in_10us * 10;
} }

View File

@ -124,6 +124,7 @@ typedef enum icmp_state {
ER_BOOTSTRAP_NEW_FRAGMENT_START, ER_BOOTSTRAP_NEW_FRAGMENT_START,
ER_WAIT_RESTART, ER_WAIT_RESTART,
ER_RPL_LOCAL_REPAIR, ER_RPL_LOCAL_REPAIR,
ER_RPL_NETWORK_LEAVING,
} icmp_state_t; } icmp_state_t;
typedef enum { typedef enum {

View File

@ -204,6 +204,12 @@ void rpl_control_set_mrhof_parent_set_size(uint16_t parent_set_size)
rpl_policy_set_mrhof_parent_set_size(parent_set_size); rpl_policy_set_mrhof_parent_set_size(parent_set_size);
} }
/* True Force RPL to use IPv6 tunneling when it send and forward data to Border router direction, This feature is disabled by default */
void rpl_control_set_force_tunnel(bool requested)
{
rpl_policy_force_tunnel_set(requested);
}
/* Send address registration to either specified address, or to non-registered address */ /* Send address registration to either specified address, or to non-registered address */
void rpl_control_register_address(protocol_interface_info_entry_t *interface, const uint8_t addr[16]) void rpl_control_register_address(protocol_interface_info_entry_t *interface, const uint8_t addr[16])
{ {
@ -399,6 +405,7 @@ static void rpl_control_etx_change_callback(int8_t nwk_id, uint16_t previous_et
if (!cur || !cur->rpl_domain) { if (!cur || !cur->rpl_domain) {
return; return;
} }
(void) attribute_index;
// ETX is "better" if now lower, or previous was "unknown" and new isn't infinite // ETX is "better" if now lower, or previous was "unknown" and new isn't infinite
bool better = current_etx < previous_etx || (previous_etx == 0 && current_etx != 0xffff); bool better = current_etx < previous_etx || (previous_etx == 0 && current_etx != 0xffff);

View File

@ -36,6 +36,7 @@ typedef enum rpl_event {
RPL_EVENT_LOCAL_REPAIR_START, /* RPL start scanning new parent by multicast DIS user can disable beacon request responser here*/ RPL_EVENT_LOCAL_REPAIR_START, /* RPL start scanning new parent by multicast DIS user can disable beacon request responser here*/
RPL_EVENT_LOCAL_REPAIR_NO_MORE_DIS, /* RPL not sending DIS anymore user can report bootstrap error */ RPL_EVENT_LOCAL_REPAIR_NO_MORE_DIS, /* RPL not sending DIS anymore user can report bootstrap error */
RPL_EVENT_DAO_PARENT_ADD, /* RPL indicate that DAO downward Parent has been added */ RPL_EVENT_DAO_PARENT_ADD, /* RPL indicate that DAO downward Parent has been added */
RPL_EVENT_POISON_FINISHED, /* RPL have finished Dodag Poison proces */
} rpl_event_t; } rpl_event_t;
typedef void rpl_domain_callback_t(rpl_event_t event, void *handle); typedef void rpl_domain_callback_t(rpl_event_t event, void *handle);
@ -176,6 +177,7 @@ bool rpl_control_find_worst_neighbor(struct protocol_interface_info_entry *inter
/* Parent link confirmation API extension */ /* Parent link confirmation API extension */
void rpl_control_request_parent_link_confirmation(bool requested); void rpl_control_request_parent_link_confirmation(bool requested);
void rpl_control_set_force_tunnel(bool requested);
void rpl_control_set_dio_multicast_min_config_advertisment_count(uint8_t min_count); void rpl_control_set_dio_multicast_min_config_advertisment_count(uint8_t min_count);
void rpl_control_set_address_registration_timeout(uint16_t timeout_in_minutes); void rpl_control_set_address_registration_timeout(uint16_t timeout_in_minutes);
void rpl_control_set_dao_retry_count(uint8_t count); void rpl_control_set_dao_retry_count(uint8_t count);
@ -200,6 +202,7 @@ const rpl_dodag_conf_t *rpl_control_get_dodag_config(const struct rpl_instance *
const uint8_t *rpl_control_preferred_parent_addr(const struct rpl_instance *instance, bool global); const uint8_t *rpl_control_preferred_parent_addr(const struct rpl_instance *instance, bool global);
uint16_t rpl_control_current_rank(const struct rpl_instance *instance); uint16_t rpl_control_current_rank(const struct rpl_instance *instance);
uint8_t rpl_policy_mrhof_parent_set_size_get(const rpl_domain_t *domain); uint8_t rpl_policy_mrhof_parent_set_size_get(const rpl_domain_t *domain);
void rpl_control_instant_poison(struct protocol_interface_info_entry *cur, rpl_domain_t *domain);
#else /* HAVE_RPL */ #else /* HAVE_RPL */
@ -211,6 +214,7 @@ uint8_t rpl_policy_mrhof_parent_set_size_get(const rpl_domain_t *domain);
#define rpl_control_address_register_done(interface, ll_addr, status) (false) #define rpl_control_address_register_done(interface, ll_addr, status) (false)
#define rpl_policy_mrhof_parent_set_size_get(domain) (0) #define rpl_policy_mrhof_parent_set_size_get(domain) (0)
#define rpl_control_set_mrhof_parent_set_size(parent_set_size) #define rpl_control_set_mrhof_parent_set_size(parent_set_size)
#define rpl_control_instant_poison(cur, domain) ((void) 0)
#endif /* HAVE_RPL */ #endif /* HAVE_RPL */
#endif /* RPL_CONTROL_H_ */ #endif /* RPL_CONTROL_H_ */

View File

@ -334,8 +334,24 @@ static buffer_t *rpl_data_exthdr_provider_hbh_2(buffer_t *buf, rpl_instance_t *i
bool destination_in_instance = false; bool destination_in_instance = false;
uint16_t ext_size = 0; uint16_t ext_size = 0;
if (addr_ipv6_equal(route_info->next_hop_addr, buf->dst_sa.address) ||
addr_ipv6_equal(buf->dst_sa.address, dodag->id)) { // Limit creation of multi-hop RPL packets
// Previous code created multi-hop RPL packets as much as possible,
// sending direct to border router in particular.
// This has caused WiSUN interop problems, so limit this.
// a) When creating a basic packet, have a policy option that prevents
// direct RPL header insertion, forcing tunnelling. This means
// we never put a RPL header on the innermost packet. Option is
// off by default, except for WiSUN, as it increases packet size
// when talking to the border router (eg DAOs).
// b) When putting a packet into a tunnel, set the tunnel exit to the
// next hop always, rather than having a special case for exiting
// at the border router. This is probably a net benefit to packet
// size because of the LL addresses used on the outer header, so
// this is an unconditional change. Exception remains for local
// DODAGs, where the destination address must be the DODAGID.
if (addr_ipv6_equal(route_info->next_hop_addr, buf->dst_sa.address) || (!rpl_policy_force_tunnel() &&
addr_ipv6_equal(buf->dst_sa.address, dodag->id))) {
destination_in_instance = true; destination_in_instance = true;
if (buf->rpl_option) { if (buf->rpl_option) {
@ -409,10 +425,12 @@ static buffer_t *rpl_data_exthdr_provider_hbh_2(buffer_t *buf, rpl_instance_t *i
rpl_data_locate_info(buf, &opt, NULL); rpl_data_locate_info(buf, &opt, NULL);
if (!opt) { if (!opt) {
*result = IPV6_EXTHDR_MODIFY_TUNNEL; *result = IPV6_EXTHDR_MODIFY_TUNNEL;
// Tunnel to next hop in general case, but if going to DODAGID, // Tunnel to next hop always, even if we could tunnel all
// it can tunnel all the way (and it HAS to if it is a local // the way to DODAG root (this may be better for
// DODAG). // packet compression, and it was found to be necessary for
if (!addr_ipv6_equal(buf->dst_sa.address, dodag->id)) { // Wi-SUN interoperability). Except for local DODAGs the
// destination must be the DODAGID, so retain that in dst_sa.
if (!rpl_instance_id_is_local(instance->id)) {
memcpy(buf->dst_sa.address, route_info->next_hop_addr, 16); memcpy(buf->dst_sa.address, route_info->next_hop_addr, 16);
} }
buf->src_sa.addr_type = ADDR_NONE; // force auto-selection buf->src_sa.addr_type = ADDR_NONE; // force auto-selection
@ -427,18 +445,20 @@ static buffer_t *rpl_data_exthdr_provider_hbh_2(buffer_t *buf, rpl_instance_t *i
* strictly less for Down packets and strictly greater for Up. * strictly less for Down packets and strictly greater for Up.
*/ */
sender_rank = common_read_16_bit(opt + 4); sender_rank = common_read_16_bit(opt + 4);
rpl_cmp_t cmp = rpl_rank_compare_dagrank_rank(dodag, sender_rank, instance->current_rank); if (sender_rank != 0) {
rpl_cmp_t expected_cmp = (opt[2] & RPL_OPT_DOWN) ? RPL_CMP_LESS : RPL_CMP_GREATER; rpl_cmp_t cmp = rpl_rank_compare_dagrank_rank(dodag, sender_rank, instance->current_rank);
if (cmp != expected_cmp) { rpl_cmp_t expected_cmp = (opt[2] & RPL_OPT_DOWN) ? RPL_CMP_LESS : RPL_CMP_GREATER;
/* Set the Rank-Error bit; if already set, drop */ if (cmp != expected_cmp) {
if (opt[2] & RPL_OPT_RANK_ERROR) { /* Set the Rank-Error bit; if already set, drop */
protocol_stats_update(STATS_RPL_ROUTELOOP, 1); if (opt[2] & RPL_OPT_RANK_ERROR) {
tr_info("Forwarding inconsistency R"); protocol_stats_update(STATS_RPL_ROUTELOOP, 1);
rpl_instance_inconsistency(instance); tr_info("Forwarding inconsistency R");
*result = -1; rpl_instance_inconsistency(instance);
return buf; *result = -1;
} else { return buf;
opt[2] |= RPL_OPT_RANK_ERROR; } else {
opt[2] |= RPL_OPT_RANK_ERROR;
}
} }
} }
} }

View File

@ -48,6 +48,17 @@ static uint8_t rpl_policy_mrhof_parent_set_size_conf = 3; // default parent set
static uint16_t rpl_policy_minimum_dao_target_refresh_conf = 0; // by default follow the configuration static uint16_t rpl_policy_minimum_dao_target_refresh_conf = 0; // by default follow the configuration
static uint16_t rpl_policy_address_registration_timeout_value = 0; // Address registration timeouts in minutes 0 use address lifetime static uint16_t rpl_policy_address_registration_timeout_value = 0; // Address registration timeouts in minutes 0 use address lifetime
static bool rpl_policy_force_tunnel_to_BR = false;
bool rpl_policy_force_tunnel(void)
{
return rpl_policy_force_tunnel_to_BR;
}
void rpl_policy_force_tunnel_set(bool enable)
{
rpl_policy_force_tunnel_to_BR = enable;
}
/* TODO - application API to control when to join new instances / DODAGs /* TODO - application API to control when to join new instances / DODAGs
* *
* Eg, allow application to ignore local DODAGs, or specify known instance IDs, * Eg, allow application to ignore local DODAGs, or specify known instance IDs,

View File

@ -21,6 +21,9 @@
#include "Core/include/ns_address_internal.h" #include "Core/include/ns_address_internal.h"
#include "rpl_control.h" #include "rpl_control.h"
bool rpl_policy_force_tunnel(void);
void rpl_policy_force_tunnel_set(bool enable);
bool rpl_policy_join_instance(rpl_domain_t *domain, uint8_t instance_id, const uint8_t *dodagid); bool rpl_policy_join_instance(rpl_domain_t *domain, uint8_t instance_id, const uint8_t *dodagid);
bool rpl_policy_join_dodag(rpl_domain_t *domain, uint8_t g_mop_prf, uint8_t instance_id, const uint8_t *dodagid); bool rpl_policy_join_dodag(rpl_domain_t *domain, uint8_t g_mop_prf, uint8_t instance_id, const uint8_t *dodagid);
bool rpl_policy_join_config(rpl_domain_t *domain, const rpl_dodag_conf_t *conf, bool *leaf_only); bool rpl_policy_join_config(rpl_domain_t *domain, const rpl_dodag_conf_t *conf, bool *leaf_only);

View File

@ -347,6 +347,14 @@ void rpl_instance_poison(rpl_instance_t *instance, uint8_t count)
rpl_instance_inconsistency(instance); rpl_instance_inconsistency(instance);
} }
void rpl_control_instant_poison(protocol_interface_info_entry_t *cur, rpl_domain_t *domain)
{
ns_list_foreach(rpl_instance_t, instance, &domain->instances) {
rpl_instance_poison(instance, 1);
rpl_instance_dio_trigger(instance, cur, NULL);
}
}
void rpl_instance_force_leaf(rpl_instance_t *instance) void rpl_instance_force_leaf(rpl_instance_t *instance)
{ {
instance->current_rank = RPL_RANK_INFINITE; instance->current_rank = RPL_RANK_INFINITE;
@ -363,7 +371,7 @@ void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t de
} }
} }
if (instance->parent_selection_timer == 0 || instance->parent_selection_timer > delay) { if (instance->parent_selection_timer == 0 || instance->parent_selection_timer > delay) {
instance->parent_selection_timer = randLIB_randomise_base(delay, 0x8000, 0x999A) /* Random between delay * 1.0-1.2 */; instance->parent_selection_timer = randLIB_randomise_base(delay, 0x8000, 0xc000) /* Random between delay * 1.0-1.5 */;
tr_debug("Timed parent triggered %u", instance->parent_selection_timer); tr_debug("Timed parent triggered %u", instance->parent_selection_timer);
} }
} }
@ -1620,6 +1628,10 @@ void rpl_instance_dio_trigger(rpl_instance_t *instance, protocol_interface_info_
instance->poison_count--; instance->poison_count--;
rank = RPL_RANK_INFINITE; rank = RPL_RANK_INFINITE;
tr_debug("Poison count -> set RPL_RANK_INFINITE"); tr_debug("Poison count -> set RPL_RANK_INFINITE");
if (instance->poison_count == 0) {
//Report RPL user that Poison message is triggered
rpl_control_event(instance->domain, RPL_EVENT_POISON_FINISHED);
}
} }
// Always send config in unicasts (as required), never in multicasts (optional) // Always send config in unicasts (as required), never in multicasts (optional)

View File

@ -128,6 +128,10 @@ void tls_server_hash_copy(uint8_t *ptr, tls_msg_t *tmp_msg, sec_suite_t *suite)
tls_build_server_hello_msg(ptr, suite->tls_session); tls_build_server_hello_msg(ptr, suite->tls_session);
tls_handshake_copy(tmp_msg, t_heap); tls_handshake_copy(tmp_msg, t_heap);
tr_debug("Pana server S-Hello,Cert hash"); tr_debug("Pana server S-Hello,Cert hash");
#else
(void) ptr;
(void) tmp_msg;
(void) suite;
#endif #endif
} }
#endif #endif

View File

@ -1721,6 +1721,8 @@ static void pana_client_authentication_fail(sec_suite_t *suite)
int8_t pana_server_nvm_callback_set(pana_server_update_cb *update_cb, pana_server_session_get_cb *nvm_get, pana_server_session_get_by_id_cb *nvm_session_get, uint8_t *nvm_static_buffer) int8_t pana_server_nvm_callback_set(pana_server_update_cb *update_cb, pana_server_session_get_cb *nvm_get, pana_server_session_get_by_id_cb *nvm_session_get, uint8_t *nvm_static_buffer)
{ {
(void)update_cb; (void)update_cb;
(void)nvm_get;
(void)nvm_session_get;
(void)nvm_static_buffer; (void)nvm_static_buffer;
return -1; return -1;
} }

View File

@ -68,7 +68,9 @@ static uint8_t tls_parse_server_key_exchange(uint8_t *ptr, uint16_t len, sec_sui
static uint8_t *tls_set_client_key_excange(uint8_t *ptr, sec_suite_t *tls_suite); static uint8_t *tls_set_client_key_excange(uint8_t *ptr, sec_suite_t *tls_suite);
static uint8_t tls_parse_server_hello(uint8_t *ptr, sec_suite_t *tls_suite); static uint8_t tls_parse_server_hello(uint8_t *ptr, sec_suite_t *tls_suite);
#ifdef PANA_SERVER_API
static uint8_t tls_parse_client_hello(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite); static uint8_t tls_parse_client_hello(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite);
#endif
static tls_psk_key_t *tls_get_key(uint16_t key_id); static tls_psk_key_t *tls_get_key(uint16_t key_id);
tls_session_t *amr_tls_session_allocate(void) tls_session_t *amr_tls_session_allocate(void)
@ -171,7 +173,7 @@ void tls_finnish_copy(uint8_t *ptr, tls_heap_t *heap_ptr)
} }
uint8_t tls_parse_client_hello(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite) static uint8_t tls_parse_client_hello(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite)
{ {
uint8_t ret_val = 0, i = 0; uint8_t ret_val = 0, i = 0;
uint16_t tls_version; uint16_t tls_version;
@ -548,6 +550,7 @@ uint8_t tls_parse_server_key_exchange(uint8_t *ptr, uint16_t len, sec_suite_t *t
return 0; return 0;
} }
#ifdef ECC
static uint8_t tls_parse_client_key_exchange(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite) static uint8_t tls_parse_client_key_exchange(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite)
{ {
(void)len; (void)len;
@ -567,6 +570,7 @@ static uint8_t tls_parse_client_key_exchange(uint8_t *ptr, uint16_t len, sec_sui
return 0; return 0;
} }
#endif
void tls_read_certi_signature(tls_heap_t *theap, uint8_t certificate) void tls_read_certi_signature(tls_heap_t *theap, uint8_t certificate)
@ -589,8 +593,8 @@ void tls_read_certi_signature(tls_heap_t *theap, uint8_t certificate)
} }
#ifdef ECC
uint8_t tls_parse_certificate_verify(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite) static uint8_t tls_parse_certificate_verify(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suite)
{ {
(void)len; (void)len;
uint16_t sig_algh, sig_len; uint16_t sig_algh, sig_len;
@ -653,7 +657,7 @@ uint8_t tls_parse_certificate_verify(uint8_t *ptr, uint16_t len, sec_suite_t *tl
} }
return 1; return 1;
} }
#endif
tls_ecc_heap_t *ecc_allocate_ram(void) tls_ecc_heap_t *ecc_allocate_ram(void)
{ {
@ -1690,6 +1694,7 @@ buffer_t *tls_server_up(buffer_t *buf, sec_suite_t *tls_suite)
buf = tls_certificate_buffer_store(buf, certi_rx, tls_suite); buf = tls_certificate_buffer_store(buf, certi_rx, tls_suite);
} }
#else #else
(void)tls_suite;
if (buf) { if (buf) {
buf = buffer_free(buf); buf = buffer_free(buf);
} }

View File

@ -22,7 +22,7 @@
// Max TX/RX slot length in milliseconds. Is used when datarate is not given by PHY or calculated slot length exceeds maximum allowed. // Max TX/RX slot length in milliseconds. Is used when datarate is not given by PHY or calculated slot length exceeds maximum allowed.
#define WS_TXRX_SLOT_LEN_MS_MAX 100 #define WS_TXRX_SLOT_LEN_MS_MAX 100
// Min TX/RX slot length in milliseconds. Is used when calculated slot length is under minimum allowed. // Min TX/RX slot length in milliseconds. Is used when calculated slot length is under minimum allowed.
#define WS_TXRX_SLOT_LEN_MS_MIN 10 #define WS_TXRX_SLOT_LEN_MS_MIN 13
// Default minimum broadcast synchronization interval in seconds // Default minimum broadcast synchronization interval in seconds
#define DEFAULT_MIN_SYNCH_INTERVAL 60 #define DEFAULT_MIN_SYNCH_INTERVAL 60
// Drift compensation allowed if at least SYNCH_COMPENSATION_MIN_INTERVAL (seconds) since last synchronization // Drift compensation allowed if at least SYNCH_COMPENSATION_MIN_INTERVAL (seconds) since last synchronization

View File

@ -142,9 +142,9 @@ bool nd_proxy_upstream_route_onlink(int8_t downstream_id, uint8_t *address);
NS_DUMMY_DEFINITIONS_OK NS_DUMMY_DEFINITIONS_OK
#define nd_proxy_downstream_interface_register(interface_id, nd_proxy_req, bridge_state_update) -1 #define nd_proxy_downstream_interface_register(interface_id, nd_proxy_req, bridge_state_update) -1
#define nd_proxy_downstream_interface_unregister(interface_id) -1 #define nd_proxy_downstream_interface_unregister(interface_id) (-1)
#define nd_proxy_upstream_interface_register(interface_id, route_validation_req) -1 #define nd_proxy_upstream_interface_register(interface_id, route_validation_req) (-1)
#define nd_proxy_upstream_interface_unregister(interface_id) -1 #define nd_proxy_upstream_interface_unregister(interface_id) (-1)
#define nd_proxy_enabled_for_downstream(interface_id) false #define nd_proxy_enabled_for_downstream(interface_id) false
#define nd_proxy_enabled_for_upstream(interface_id) false #define nd_proxy_enabled_for_upstream(interface_id) false
#define nd_proxy_target_address_validation(upstream_id, address) false #define nd_proxy_target_address_validation(upstream_id, address) false

View File

@ -1072,7 +1072,7 @@ int8_t arm_network_certificate_revocation_list_remove(const arm_cert_revocation_
*/ */
int8_t arm_network_key_get(int8_t interface_id, ns_keys_t *key) int8_t arm_network_key_get(int8_t interface_id, ns_keys_t *key)
{ {
#ifndef PANA #ifndef PANA_SERVER
(void)interface_id; (void)interface_id;
(void)key; (void)key;
#endif #endif
@ -1081,7 +1081,7 @@ int8_t arm_network_key_get(int8_t interface_id, ns_keys_t *key)
int8_t arm_pana_server_library_init(int8_t interface_id, net_tls_cipher_e cipher_mode, const uint8_t *key_material, uint32_t time_period_before_activate_key) int8_t arm_pana_server_library_init(int8_t interface_id, net_tls_cipher_e cipher_mode, const uint8_t *key_material, uint32_t time_period_before_activate_key)
{ {
#ifndef PANA #ifndef PANA_SERVER
(void)interface_id; (void)interface_id;
(void)cipher_mode; (void)cipher_mode;
(void)key_material; (void)key_material;
@ -1092,7 +1092,7 @@ int8_t arm_pana_server_library_init(int8_t interface_id, net_tls_cipher_e cipher
int8_t arm_pana_activate_new_key(int8_t interface_id) int8_t arm_pana_activate_new_key(int8_t interface_id)
{ {
#ifndef PANA #ifndef PANA_SERVER
(void)interface_id; (void)interface_id;
#endif #endif
return pana_server_trig_new_key(interface_id); return pana_server_trig_new_key(interface_id);
@ -1100,7 +1100,7 @@ int8_t arm_pana_activate_new_key(int8_t interface_id)
int8_t arm_pana_server_key_update(int8_t interface_id, const uint8_t *network_key_material) int8_t arm_pana_server_key_update(int8_t interface_id, const uint8_t *network_key_material)
{ {
#ifndef PANA #ifndef PANA_SERVER
(void)interface_id; (void)interface_id;
(void)network_key_material; (void)network_key_material;
#endif #endif
@ -1199,7 +1199,7 @@ int8_t arm_6lowpan_bootsrap_set_for_selected_interface(int8_t interface_id)
int8_t arm_nwk_interface_configure_6lowpan_bootstrap_set(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode, net_6lowpan_mode_extension_e net_6lowpan_mode_extension) int8_t arm_nwk_interface_configure_6lowpan_bootstrap_set(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode, net_6lowpan_mode_extension_e net_6lowpan_mode_extension)
{ {
int8_t ret_val; int8_t ret_val;
(void)bootstrap_mode;
ret_val = arm_6lowpan_bootsrap_set_for_selected_interface(interface_id); ret_val = arm_6lowpan_bootsrap_set_for_selected_interface(interface_id);
if (ret_val == 0) { if (ret_val == 0) {