4343#include "RPL/rpl_data.h"
4444#include "Common_Protocols/icmpv6.h"
4545#include "Common_Protocols/icmpv6_radv.h"
46+ #include "Common_Protocols/ipv6_constants.h"
4647#include "6LoWPAN/ws/ws_common_defines.h"
4748#include "Service_Libs/Trickle/trickle.h"
4849#include "6LoWPAN/ws/ws_common_defines.h"
@@ -854,14 +855,34 @@ static void ws_bootstrap_network_configuration_learn(protocol_interface_info_ent
854855 return ;
855856}
856857
858+ static void ws_bootstrap_ip_stack_addr_clear (protocol_interface_info_entry_t * cur )
859+ {
860+ tr_debug ("ip stack address clear" );
861+ ns_list_foreach_safe (if_address_entry_t , addr , & cur -> ip_addresses ) {
862+ if (addr -> source != ADDR_SOURCE_STATIC &&
863+ addr_ipv6_scope (addr -> address ,cur ) > IPV6_SCOPE_LINK_LOCAL ) {
864+ // Remove all exept User set address
865+ addr_delete_entry (cur , addr );
866+ }
867+ }
868+ }
869+
870+ static void ws_bootstrap_ip_stack_reset (protocol_interface_info_entry_t * cur )
871+ {
872+ tr_debug ("ip stack reset" );
873+ // Delete all temporary cached information
874+ ipv6_neighbour_cache_flush (& cur -> ipv6_neighbour_cache );
875+ lowpan_context_list_free (& cur -> lowpan_contexts );
876+ }
877+
857878static void ws_bootstrap_ip_stack_activate (protocol_interface_info_entry_t * cur )
858879{
859880 tr_debug ("ip stack init" );
860881 clear_power_state (ICMP_ACTIVE );
861882 cur -> lowpan_info |= INTERFACE_NWK_BOOTSRAP_ACTIVE ;
862- ipv6_neighbour_cache_flush (& cur -> ipv6_neighbour_cache );
863-
883+ ws_bootstrap_ip_stack_reset (cur );
864884}
885+
865886static void ws_bootstrap_rpl_callback (rpl_event_t event , void * handle )
866887{
867888
@@ -874,12 +895,13 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
874895 // Trigger statemachine check
875896 cur -> bootsrap_state_machine_cnt = 1 ;
876897 } else if (event == RPL_EVENT_LOCAL_REPAIR_NO_MORE_DIS ) {
877- // RPL gave up so we need to re-trigger network scan.
878- // TODO is this correct?
879- // TODO no! ws_bootstrap_event_configuration_start(cur); causes failure to
880- // We could send solicit for configuration and then select new parent when those arrive
881- /* This is done after address deletion, so RPL can act on them */
882- ws_bootstrap_event_configuration_start (cur );
898+ /*
899+ * RPL goes to passive mode, but does not require any extra changed
900+ *
901+ * We could remove our current addresses learned from RPL
902+ * We could send solicit for configuration and then select new parent when those arrive
903+ *
904+ */
883905
884906 }
885907 cur -> ws_info -> rpl_state = event ;
@@ -900,6 +922,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
900922
901923 cur -> ws_info -> rpl_state = 0xff ; // Set invalid state and learn from event
902924 if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER ) {
925+ // TODO RPL should have function to reset DIS trickle and it should be called here
903926 rpl_control_transmit_dis (cur -> rpl_domain , cur , 0 , 0 , NULL , 0 , ADDR_LINK_LOCAL_ALL_RPL_NODES );
904927 }
905928}
@@ -940,6 +963,14 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
940963 // Clear learned neighbours
941964 ws_bootstrap_neighbor_list_clean (cur );
942965
966+ // Clear RPL information
967+ rpl_control_remove_domain_from_interface (cur );
968+
969+ // Clear ip stack from old information
970+ ws_bootstrap_ip_stack_reset (cur );
971+ // New network scan started old addresses not assumed valid anymore
972+ ws_bootstrap_ip_stack_addr_clear (cur );
973+
943974 // Reset advertisement solicit trickle to start discovering network
944975 trickle_start (& cur -> ws_info -> trickle_pan_advertisement_solicit , & trickle_params_pan_configuration );
945976 trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_advertisement_solicit , & trickle_params_pan_configuration );
@@ -952,20 +983,18 @@ static void ws_bootstrap_start_configuration_learn(protocol_interface_info_entry
952983 ws_bootstrap_state_change (cur , ER_SCAN );
953984
954985 cur -> ws_info -> configuration_learned = false;
955- cur -> ws_info -> pan_version_timeout_timer = 0 ;
956- rpl_control_remove_domain_from_interface (cur );
957- ipv6_neighbour_cache_flush (& cur -> ipv6_neighbour_cache );
958986 // Clear parent info
959987 memset (cur -> ws_info -> parent_info .addr ,0 ,8 );
960988
989+ // Clear all temporary information
990+ ws_bootstrap_ip_stack_reset (cur );
991+
961992 // Clear learned neighbours
962993 ws_bootstrap_neighbor_list_clean (cur );
963994
964995 // Reset advertisement solicit trickle to start discovering network
965996 trickle_start (& cur -> ws_info -> trickle_pan_config_solicit , & trickle_params_pan_configuration );
966997 trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_config_solicit , & trickle_params_pan_configuration );
967-
968-
969998}
970999
9711000/*
0 commit comments