summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-03-01 16:54:12 +0100
committerNélio Laranjeiro2011-03-03 14:41:11 +0100
commit65da0099ae4a5bfdfc9dc817ef64999abd5905a1 (patch)
tree330636a6fb6d725330ae1e59f975f8fc75ebd1a0
parent5071d0fc42fba4e2e5433518f7ead4d4df253e3c (diff)
cesar/cp: add ASSOC_UCCO state in assoc FSM, closes #2222
With old code, when the FSM leaved ASSOC_CCO to UNASSOCIATED it leaved the AVLN and posted an left event. UCCo is a CCo with a special behavior.
-rw-r--r--cesar/cp/cco/action/src/cco_action.c8
-rw-r--r--cesar/cp/cco/action/test/src/action-test.c4
-rw-r--r--cesar/cp/cco/action/test/src/status.c7
-rw-r--r--cesar/cp/cco/action/test/utest/src/assoc.c7
-rw-r--r--cesar/cp/fsm/src/fsm/cp.fsm12
5 files changed, 21 insertions, 17 deletions
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index 4359d2f930..56ac6dc15c 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -361,6 +361,7 @@ cp_cco_action_ucco_stop (cp_t *ctx)
cp_sta_mgr_set_our_avln (ctx, NULL);
/* Leave our TEI. */
cp_sta_own_data_set_tei (ctx, MAC_TEI_UNASSOCIATED);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
}
void
@@ -374,7 +375,7 @@ void
cp_cco_action_cco__to_ucco (cp_t *ctx)
{
dbg_assert (ctx);
- cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_become_ucco);
}
void
@@ -405,11 +406,6 @@ cp_cco_action_cco__unassoc_stop (cp_t *ctx)
{
dbg_assert (ctx);
cp_cco_action_stop (ctx);
- /* Set our AVLN as null. */
- cp_sta_mgr_set_our_avln (ctx, NULL);
- cp_sta_own_data_set_authenticated_status (ctx, false);
- /* Leave our TEI. */
- cp_sta_own_data_set_tei (ctx, MAC_TEI_UNASSOCIATED);
cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
}
diff --git a/cesar/cp/cco/action/test/src/action-test.c b/cesar/cp/cco/action/test/src/action-test.c
index 6abd12a4db..66b816656d 100644
--- a/cesar/cp/cco/action/test/src/action-test.c
+++ b/cesar/cp/cco/action/test/src/action-test.c
@@ -333,9 +333,9 @@ test_case_cco_action_start (test_t test)
nid = cp_sta_own_data_get_nid (&cp);
net = cp_sta_mgr_get_avln (&cp, snid, nid);
test_fail_unless (net);
+ /* check only CCo status, the TEI and our AVLN are reseted by
+ * UNASSOCIATED enter function. */
test_fail_if (cp_sta_own_data_get_cco_status (&cp) != false);
- test_fail_if (cp_sta_own_data_get_tei (&cp) != 0x0);
- test_fail_if (cp.sta_mgr.our_avln != NULL);
test_fail_if (cp.cl->mactotei != NULL);
}
test_end;
diff --git a/cesar/cp/cco/action/test/src/status.c b/cesar/cp/cco/action/test/src/status.c
index 846cebd911..c625c8ffa9 100644
--- a/cesar/cp/cco/action/test/src/status.c
+++ b/cesar/cp/cco/action/test/src/status.c
@@ -263,12 +263,9 @@ test_suite__cco_action__case__cco_to_unassociated_station (test_t test)
/* Launch the test. */
cp_cco_action_cco__unassoc_stop (&cp);
- test_fail_unless (cp_sta_own_data_get_tei (&cp) ==
- MAC_TEI_UNASSOCIATED);
+ /* TEI, auth and OUR AVLN are reseted by UNASSOCIATED enter function.
+ */
test_fail_unless (cp_sta_own_data_get_cco_status (&cp) == false);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&cp) ==
- false);
- test_fail_unless (cp.sta_mgr.our_avln == NULL);
test_fail_unless (!cp_net_is_empty (&cp, net));
cp_sta_mgr_uninit (&cp);
diff --git a/cesar/cp/cco/action/test/utest/src/assoc.c b/cesar/cp/cco/action/test/utest/src/assoc.c
index b7316f5300..21204561be 100644
--- a/cesar/cp/cco/action/test/utest/src/assoc.c
+++ b/cesar/cp/cco/action/test/utest/src/assoc.c
@@ -163,7 +163,7 @@ assoc_test_case_cco (test_t t)
scenario_entry_t cco_to_ucco [] = {
SCENARIO_ACTION (cco__to_ucco),
SCENARIO_EVENT (cp_fsm_event_bare_new,
- .type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
+ .type = CP_FSM_EVENT_TYPE_assoc_become_ucco),
SCENARIO_END
};
scenario_run (t, cco_to_ucco, &globals);
@@ -179,13 +179,16 @@ assoc_test_case_cco (test_t t)
SCENARIO_END
};
scenario_run (t, cco_unassoc, &globals);
+ /* Unassoc stop makes the FSM goes to UNASSOCIATED status. The reset
+ * of data are done in enter function of UNASSOCIATED state. */
test_fail_unless (!cp_sta_own_data_get_cco_status (&ctx.cp));
- test_fail_unless (!MAC_TEI_IS_STA (cp_sta_own_data_get_tei (&ctx.cp)));
/* UCCo STOP. */
assoc_test_set_own_sta_as_cco (&ctx.cp, net, 1);
scenario_entry_t ucco_stop [] = {
SCENARIO_ACTION (ucco_stop),
SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
SCENARIO_END
};
scenario_run (t, ucco_stop, &globals);
diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/fsm/src/fsm/cp.fsm
index ea3a4148c8..67cd828a46 100644
--- a/cesar/cp/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/fsm/src/fsm/cp.fsm
@@ -9,6 +9,7 @@ States:
LEAVING
LEAVE_WAIT [enter=cp_sta_action_assoc__leave_wait__enter]
ASSOC_CCO
+ ASSOC_UCCO
SC_WAIT_ASSOC_CONF [enter=cp_sta_action_assoc__start_retry_timer leave=cp_sta_action_assoc__stop_retry_timer]
SC_ASSOCIATED [enter=cp_sta_action_assoc__start_retry_timer leave=cp_sta_action_assoc__stop_retry_timer]
@@ -100,6 +101,7 @@ Events:
discover_info_updated
assoc_become_cco
+ assoc_become_ucco
assoc_become_sta
assoc_cco_leave
@@ -256,9 +258,15 @@ WAIT_ASSOC_CONF:
assoc_timeout: no retry -> UNASSOCIATED
to_leave -> UNASSOCIATED [NULL]
+ASSOC_CCO, ASSOC_UCCO:
+ assoc_cco_leave -> UNASSOCIATED [NULL]
+
ASSOC_CCO:
assoc_become_sta -> AUTHENTICATED [NULL]
- assoc_cco_leave -> UNASSOCIATED [NULL]
+ assoc_become_ucco -> ASSOC_UCCO [NULL]
+
+ASSOC_UCCO:
+ assoc_become_cco -> ASSOC_CCO [NULL]
SC_WAIT_ASSOC_CONF:
CC_ASSOC_CNF: ok -> SC_ASSOCIATED [cp_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf]
@@ -454,7 +462,7 @@ UCCO:
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
BEACON: nid match -> USTA_JOINING [cp_sta_action_poweron__ucco__beacon]
BEACON: no nid match -> USTA
- BEACON_WITH_SAME_NID -> USTA [NULL]
+ BEACON_WITH_SAME_NID -> USTA [cp_cco_action_ucco_stop]
to_stop -> USTA [cp_cco_action_ucco__to_stop]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]