43
43
#include "RPL/rpl_data.h"
44
44
#include "Common_Protocols/icmpv6.h"
45
45
#include "Common_Protocols/icmpv6_radv.h"
46
+ #include "Common_Protocols/ipv6_constants.h"
46
47
#include "6LoWPAN/ws/ws_common_defines.h"
47
48
#include "Service_Libs/Trickle/trickle.h"
48
49
#include "6LoWPAN/ws/ws_common_defines.h"
@@ -854,14 +855,34 @@ static void ws_bootstrap_network_configuration_learn(protocol_interface_info_ent
854
855
return ;
855
856
}
856
857
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
+
857
878
static void ws_bootstrap_ip_stack_activate (protocol_interface_info_entry_t * cur )
858
879
{
859
880
tr_debug ("ip stack init" );
860
881
clear_power_state (ICMP_ACTIVE );
861
882
cur -> lowpan_info |= INTERFACE_NWK_BOOTSRAP_ACTIVE ;
862
- ipv6_neighbour_cache_flush (& cur -> ipv6_neighbour_cache );
863
-
883
+ ws_bootstrap_ip_stack_reset (cur );
864
884
}
885
+
865
886
static void ws_bootstrap_rpl_callback (rpl_event_t event , void * handle )
866
887
{
867
888
@@ -874,12 +895,13 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
874
895
// Trigger statemachine check
875
896
cur -> bootsrap_state_machine_cnt = 1 ;
876
897
} 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
+ */
883
905
884
906
}
885
907
cur -> ws_info -> rpl_state = event ;
@@ -900,6 +922,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
900
922
901
923
cur -> ws_info -> rpl_state = 0xff ; // Set invalid state and learn from event
902
924
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
903
926
rpl_control_transmit_dis (cur -> rpl_domain , cur , 0 , 0 , NULL , 0 , ADDR_LINK_LOCAL_ALL_RPL_NODES );
904
927
}
905
928
}
@@ -940,6 +963,14 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
940
963
// Clear learned neighbours
941
964
ws_bootstrap_neighbor_list_clean (cur );
942
965
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
+
943
974
// Reset advertisement solicit trickle to start discovering network
944
975
trickle_start (& cur -> ws_info -> trickle_pan_advertisement_solicit , & trickle_params_pan_configuration );
945
976
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
952
983
ws_bootstrap_state_change (cur , ER_SCAN );
953
984
954
985
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 );
958
986
// Clear parent info
959
987
memset (cur -> ws_info -> parent_info .addr ,0 ,8 );
960
988
989
+ // Clear all temporary information
990
+ ws_bootstrap_ip_stack_reset (cur );
991
+
961
992
// Clear learned neighbours
962
993
ws_bootstrap_neighbor_list_clean (cur );
963
994
964
995
// Reset advertisement solicit trickle to start discovering network
965
996
trickle_start (& cur -> ws_info -> trickle_pan_config_solicit , & trickle_params_pan_configuration );
966
997
trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_config_solicit , & trickle_params_pan_configuration );
967
-
968
-
969
998
}
970
999
971
1000
/*
0 commit comments