summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2010-06-07 15:58:32 +0000
committerlaranjeiro2010-06-07 15:58:32 +0000
commitf7ea3977e37c7abd74bfe6cf7abf7ee95e6eb163 (patch)
tree60432a396bb16493e5609717964dd845ae3c7a8b
parent4bc35cc73cbfaf21750318100c5bfd777f86d814 (diff)
cesar/cp/{beacon, cco/action, fsm}: fix handover start
- cp/beacon: remove the event post HANDOVER_DISCOVER_STA, the CCo elects the future CCo on DISCOVER_PROCESS_DONE event. - cp/cco/action: clear CCo selection heap when not used. - tests: Had a check to verify the CCo will not do a handover if the STA had not a bigger CCO_CAP (even if the STA is user cco appoint). git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7182 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/common/tests/tests1
-rw-r--r--cesar/cp/beacon/src/beacon.c5
-rw-r--r--cesar/cp/cco/action/cco_action.h7
-rw-r--r--cesar/cp/cco/action/inc/cco_action.h7
-rw-r--r--cesar/cp/cco/action/src/cco_action.c5
-rw-r--r--cesar/cp/cco/action/src/handover.c9
-rw-r--r--cesar/cp/fsm/src/fsm/cp.fsm5
-rw-r--r--cesar/test_general/station/cco0/s2/py/sc07_handover.py86
8 files changed, 105 insertions, 20 deletions
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index 58090b1890..8c14f1a602 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -426,6 +426,7 @@ sc03_ten_stations: python py/sc03_ten_stations.py -d false -t 25000000000
sc04_change_snid: python py/sc04_change_snid.py -d false -t 25000000000
sc05_change_hm: python py/sc05_change_hm.py -d false -t 25000000000
sc06_snid_conflict: python py/sc06_snid_conflict.py -d false -t 25000000000
+sc07_handover: python py/sc07_handover.py -d false -t 25000000000
sc07_handover_exception: python py/sc07_handover_exceptions.py -d false -t 25000000000
sc08_sc_two_sc_join: python py/sc08_sc_two_sc_join.py --maximus
sc08_sc_one_sc_join_one_sc_add: python py/sc08_sc_one_sc_join_one_sc_add.py --maximus
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 1da5d5071d..4c31ba206e 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -709,11 +709,6 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
sta = cp_beacon_update_sta_peer (ctx, &beacon_data, net, type, tei,
mac_address);
- /** Check handover in progress status. */
- if ((!ctx->beacon.hoip.hoipcd)
- && (cp_sta_own_data_get_cco_status (ctx)))
- cp_fsm_post_new_event (ctx, sta, HANDOVER_DISCOVERED_STA, net, sta);
-
/** Our station is associated and the beacon is from our CCo. */
own = cp_sta_mgr_get_sta_own_data (ctx);
if (cp_sta_own_data_get_tei (ctx)
diff --git a/cesar/cp/cco/action/cco_action.h b/cesar/cp/cco/action/cco_action.h
index acc085c6c9..b1dcb9313e 100644
--- a/cesar/cp/cco/action/cco_action.h
+++ b/cesar/cp/cco/action/cco_action.h
@@ -261,6 +261,13 @@ void
cp_cco_action_cco_selection__mac_stop_sta_add (cp_t *ctx, cp_sta_t *sta);
/**
+ * Clear the selection context.
+ * \param ctx the module context.
+ */
+void
+cp_cco_action_cco_selection__clear (cp_t *ctx);
+
+/**
* Add a station to the CCo selection procedure.
* \param ctx the module context.
* \param net the station's NET.
diff --git a/cesar/cp/cco/action/inc/cco_action.h b/cesar/cp/cco/action/inc/cco_action.h
index d960a533cd..35efccba91 100644
--- a/cesar/cp/cco/action/inc/cco_action.h
+++ b/cesar/cp/cco/action/inc/cco_action.h
@@ -96,13 +96,6 @@ void
cp_cco_action_cco_selection__sta_remove (cp_t *ctx, cp_sta_t *sta);
/**
- * Clear the selection context.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco_selection__clear (cp_t *ctx);
-
-/**
* Selects the Next CCo on the AVLN.
* \param ctx the module context.
* \return the station elected or NULL.
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index 463e888ab9..e7ef7c5780 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -1028,8 +1028,8 @@ cp_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
&& (cp_sta_get_authenticated (ctx, sta)))
{
own = cp_sta_mgr_get_sta_own_data (ctx);
- if ((own->cco_prefered == false)
- && ((sta->cco_cap > CP_CCO_LEVEL)))
+ if (own->cco_prefered == false
+ && sta->cco_cap > CP_CCO_LEVEL)
{
slab_addref (sta);
heap_node_init (&sta->cco_selection_node);
@@ -1160,6 +1160,7 @@ cp_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
void
cp_cco_action_handover_ended (cp_t *ctx)
{
+ cp_cco_action_cco_selection__clear (ctx);
/* trigger the event for the assoc FSM. */
cp_fsm_trigger_new_event (ctx, bare, become_sta);
}
diff --git a/cesar/cp/cco/action/src/handover.c b/cesar/cp/cco/action/src/handover.c
index 1f37e6aadc..778118d47b 100644
--- a/cesar/cp/cco/action/src/handover.c
+++ b/cesar/cp/cco/action/src/handover.c
@@ -298,13 +298,18 @@ cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx)
}
}
-
void
cp_cco_action_handover__discover_done (cp_t *ctx)
{
cp_fsm_event_t *event;
dbg_assert (ctx);
-
+ cp_sta_t *sta;
+ cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
+ cp_cco_action_cco_selection__clear (ctx);
+ for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
+ sta;
+ sta = cp_net_sta_get_next (ctx, net, sta))
+ cp_cco_action_cco_selection__sta_add (ctx, net, sta);
ctx->handover.reason = CP_HANDOVER_REASON_CCO_SELECTION;
event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_CCO_HANDOVER_START);
cp_fsm_trigger (ctx, event);
diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/fsm/src/fsm/cp.fsm
index cea84db56c..268d842905 100644
--- a/cesar/cp/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/fsm/src/fsm/cp.fsm
@@ -170,8 +170,6 @@ Events:
HANDOVER_DISCOVER_PROCESS_DONE
Post by the beacon module to indicate the discover process is done.
- HANDOVER_DISCOVERED_STA
- A new STA has sent its discover beacon.
HOIP_EXPIRED
The handover in progress countdown expired in the central beacon.
HANDOVER_TIMEOUT
@@ -510,7 +508,6 @@ CCO:
CC_LEAVE_REQ -> . [cp_cco_action__cco__cc_leave]
HANDOVER_DISCOVER_PROCESS_DONE -> HANDOVER_CCO [cp_cco_action_handover__discover_done]
- HANDOVER_DISCOVERED_STA -> . [cp_cco_action_cco_selection__sta_add]
DRV_STA_SC_REQ: sc_add -> SC_CCO [cp_sta_action_drv__cco__drv_sta_sc]
DRV_STA_SC_REQ: sc_join -> .
@@ -622,7 +619,7 @@ HANDOVER_CCO:
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
HANDOVER_SUCCESS -> STA [cp_cco_action_handover_ended]
- HANDOVER_FAILURE -> CCO [NULL]
+ HANDOVER_FAILURE -> CCO [cp_cco_action_cco_selection__clear]
CCO_HANDOVER_IDLE:
CCO_HANDOVER_START: sta -> CCO_HANDOVER_WAIT_CC_HANDOVER_CNF [cp_cco_action_handover__start]
diff --git a/cesar/test_general/station/cco0/s2/py/sc07_handover.py b/cesar/test_general/station/cco0/s2/py/sc07_handover.py
new file mode 100644
index 0000000000..d5e39c2dd5
--- /dev/null
+++ b/cesar/test_general/station/cco0/s2/py/sc07_handover.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+
+#############################################################################
+# #
+# The handover shall only occur when no other countdown is active. #
+# This test verifies it by activating a SNID collision on the AVLNS at #
+# the same time as the CCo should handover. #
+# #
+# One AVLNs, 3 stations. #
+# AVLN 1 contains three stations. #
+# #
+# Result expected: The handover should only occur after the SNID changed. #
+# #
+# Some others test will be done for the hybrid mode. #
+#############################################################################
+
+import unittest, sys, os
+sys.path.append ('../../../../maximus/python/tools/csi/')
+sys.path.append ('../../../../maximus/python/obj/')
+sys.path.append ('../../../../maximus/python/')
+sys.path.append ('../../../../maximus/python/lib/cesar')
+
+from csicore import csiCore
+from csistation import csiSta
+
+DEFAULT_MAC = '00:13:d7:00:00:%02x'
+NB_STA = 2
+DEBUG = False
+EXECUTABLE = 'obj/cco0s2.elf'
+
+csi = csiCore (1234)
+csi.process_init (sys.argv + ['-e', EXECUTABLE])
+# Creating an AVLN.
+avln = csi.avln_add ("Homeplug_AVLN1", "AVLN1")
+
+for i in range (0, NB_STA):
+ if i != NB_STA - 1:
+ avln.sta_add (DEFAULT_MAC % (i + 1), False, False,
+ "SPIDCOM_CCO_LEVEL0_STEP2_" + str (i+1),
+ "SPIDCOM_SPC_300_" + str (i+1), "SPIDCOM_SPC_300_" + str (i+1),
+ 1, DEBUG)
+ else:
+ avln.sta_add (DEFAULT_MAC % (i + 1), True, False,
+ "SPIDCOM_CCO_LEVEL0_STEP2_" + str (i+1),
+ "SPIDCOM_SPC_300_" + str (i+1), "SPIDCOM_SPC_300_" + str (i+1),
+ 1, DEBUG)
+
+class TestHandover (unittest.TestCase):
+
+ def setUp (self):
+ pass
+
+ def tearDown (self):
+ pass
+
+ def testHandover (self):
+ """Test the handover from station 1 to station NB_STA - 1.
+ Last station of the AVLN is CCO user appointed.
+ HPAV require on a handover on the CCo CAP of a station, user appointed
+ is optional.
+ """
+ from own_data import Station_own_data
+ csi.process_sta_start (avln.get_sta (0))
+ csi.process_wait_sec (4)
+ for i in range (1, NB_STA):
+ csi.process_sta_start (avln.get_sta(i))
+ csi.process_wait_association ()
+ csi.process_wait_authentication ()
+ csi.process_wait_sec (20)
+ data = Station_own_data ()
+ data.get_data (csi.get_maximus (),
+ avln.get_sta (0).get_sta_cesar ())
+ self.failUnless (data.cco_prefered == False)
+ self.failUnless (data.is_cco == True)
+ data.get_data (csi.get_maximus (),
+ avln.get_sta (NB_STA - 1).get_sta_cesar ())
+ self.failUnless (data.cco_prefered == True)
+ self.failUnless (data.is_cco == False)
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestHandover)
+testResult = unittest.TextTestRunner(verbosity=2).run(suite)
+
+csi.process_avlns_remove ()
+# For nightly build errors
+sys.exit ((1, 0)[testResult.wasSuccessful ()])
+os.system ('killall cco0s2.elf')