summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-02-24 15:16:23 +0100
committerNélio Laranjeiro2011-03-03 14:41:08 +0100
commitb0cfa562a62b205a32d3be5ac9c3b86ee8e3356a (patch)
tree13a0f1bbe4caf5ccbf7cf61bedab2c3f15f7de4e
parentf647bbd20f560e02e8ca9587dc5bfdde2fea7003 (diff)
cesar/cp/sta/action: restore sc get cco functionality, refs #2222
-rw-r--r--cesar/cp/cco/action/cco_action.h8
-rw-r--r--cesar/cp/cco/action/src/cco_action.c30
-rw-r--r--cesar/cp/cco/action/stub/src/cco_action.c15
-rw-r--r--cesar/cp/cco/action/test/utest/src/assoc.c4
-rw-r--r--cesar/cp/cco/action/test/utest/src/handover.c2
-rw-r--r--cesar/cp/fsm/src/fsm/cp.fsm13
-rw-r--r--cesar/cp/sta/action/src/sc.c4
-rw-r--r--cesar/cp/sta/action/test/utest/src/sc.c11
8 files changed, 76 insertions, 11 deletions
diff --git a/cesar/cp/cco/action/cco_action.h b/cesar/cp/cco/action/cco_action.h
index f62c4474b7..8547d82070 100644
--- a/cesar/cp/cco/action/cco_action.h
+++ b/cesar/cp/cco/action/cco_action.h
@@ -374,6 +374,14 @@ void
cp_cco_action_beacon_with_same_nid (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta);
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
+
END_DECLS
#endif /* cp_cco_action_h */
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index a827925ae6..4359d2f930 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -811,13 +811,10 @@ cp_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
cp_cco_action_manage_sta_assoc_common (ctx, assoc_req, &assoc);
}
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CC_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+static void
+cp_cco_action_ucco__cc_assoc_req_common (
+ cp_t *ctx, cp_mme_rx_t * assoc_req, cp_fsm_branch_t branch_ok,
+ cp_fsm_branch_t branch_nok)
{
cp_msg_cc_assoc_req_t assoc;
dbg_assert (ctx);
@@ -836,7 +833,26 @@ cp_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
cp_cco_action_ucco__to_cco (ctx);
/* Continue the association procedure. */
cp_cco_action_manage_sta_assoc_common (ctx, assoc_req, &assoc);
+ cp_fsm_branch_ (ctx, branch_ok);
}
+ else
+ cp_fsm_branch_ (ctx, branch_nok);
+}
+
+void
+cp_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+ cp_cco_action_ucco__cc_assoc_req_common (
+ ctx, assoc_req, CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, ok),
+ CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, nok));
+}
+
+void
+cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+ cp_cco_action_ucco__cc_assoc_req_common (
+ ctx, assoc_req, CP_FSM_BRANCH (SC_UCCO, CC_ASSOC_REQ, ok),
+ CP_FSM_BRANCH (SC_UCCO, CC_ASSOC_REQ, nok));
}
/**
diff --git a/cesar/cp/cco/action/stub/src/cco_action.c b/cesar/cp/cco/action/stub/src/cco_action.c
index 0989a08939..8ddfa10213 100644
--- a/cesar/cp/cco/action/stub/src/cco_action.c
+++ b/cesar/cp/cco/action/stub/src/cco_action.c
@@ -111,6 +111,21 @@ cp_cco_action_ucco__cc_assoc_req (cp_t *ctx,
}
/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req) __attribute__((weak));
+void
+cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req)
+{
+}
+
+
+/**
* manage authentication of a station.
* \param ctx the module context.
* \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
diff --git a/cesar/cp/cco/action/test/utest/src/assoc.c b/cesar/cp/cco/action/test/utest/src/assoc.c
index 6ae13689ff..b7316f5300 100644
--- a/cesar/cp/cco/action/test/utest/src/assoc.c
+++ b/cesar/cp/cco/action/test/utest/src/assoc.c
@@ -62,6 +62,8 @@ assoc_test_case_cco (test_t t)
.nid = our_nid + 1,
.cco_cap = CP_CCO_LEVEL,
.proxy_cap = false),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, nok)),
SCENARIO_END,
};
/* station is still Ucco. */
@@ -88,6 +90,8 @@ assoc_test_case_cco (test_t t)
.snid = cp_sta_own_data_get_snid (&ctx.cp),
.sta_tei = 2,
.lease_time_min = CP_LEASE_ASSOC_MIN),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, ok)),
SCENARIO_END,
};
scenario_run (t, sta_assoc_good_request, &globals);
diff --git a/cesar/cp/cco/action/test/utest/src/handover.c b/cesar/cp/cco/action/test/utest/src/handover.c
index 3b98af8947..cae1fccb07 100644
--- a/cesar/cp/cco/action/test/utest/src/handover.c
+++ b/cesar/cp/cco/action/test/utest/src/handover.c
@@ -407,7 +407,7 @@ handover__cco_leave (test_t test)
SCENARIO_ACTION (handover__ended),
SCENARIO_EVENT (cp_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
- .type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
+ .type = CP_FSM_EVENT_TYPE_assoc_become_sta),
SCENARIO_END
};
diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/fsm/src/fsm/cp.fsm
index f3f8e4ec9a..ea3a4148c8 100644
--- a/cesar/cp/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/fsm/src/fsm/cp.fsm
@@ -168,6 +168,9 @@ Events:
When the SC FSM has finished with a failure.
sc_succeed
When the SC FSM has finished with a success.
+ sc_get_cco_functionality
+ When the SC FSM need the main FSM to move to a state to get CCo
+ functionalities.
HANDOVER_DISCOVER_PROCESS_DONE
Post by the beacon module to indicate the discover process is done.
@@ -420,6 +423,8 @@ SC_USTA:
track AVLN.
net_list_empty -> SC_UCCO [NULL]
no more AVLN to track, go to SC_UCCO.
+ sc_get_cco_functionality -> SC_CCO [cp_cco_action_cco__unassoc_start]
+ Get CCo functionality.
sc_succeed -> SC_USTA_JOINING [NULL]
SC procedure finished, start association.
sc_failed -> USTA [NULL]
@@ -453,7 +458,8 @@ UCCO:
to_stop -> USTA [cp_cco_action_ucco__to_stop]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- CC_ASSOC_REQ -> . [cp_cco_action_ucco__cc_assoc_req]
+ CC_ASSOC_REQ:ok -> CCO [cp_cco_action_ucco__cc_assoc_req]
+ CC_ASSOC_REQ:nok -> .
DRV_STA_SC_REQ -> SC_UCCO [cp_sta_action_drv__ucco__drv_sta_sc]
Start the SC FSM.
@@ -463,11 +469,14 @@ SC_UCCO:
Still doing SC procedure, but in SC_USTA.
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
to_stop -> IDLE [cp_sta_action_poweron__many__to_idle]
+ sc_get_cco_functionality -> SC_CCO [cp_cco_action_ucco__to_cco]
+ Get CCo functionality.
sc_failed -> UCCO [NULL]
SC failed, go back to normal.
sc_succeed -> SC_USTA_JOINING [NULL]
SC procedure finished, start association.
- CC_ASSOC_REQ -> . [cp_cco_action_ucco__cc_assoc_req]
+ CC_ASSOC_REQ:nok -> . [cp_cco_action_sc_ucco__cc_assoc_req]
+ CC_ASSOC_REQ:ok -> CCO
STA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
diff --git a/cesar/cp/sta/action/src/sc.c b/cesar/cp/sta/action/src/sc.c
index 6891663a2c..3b513ee0f6 100644
--- a/cesar/cp/sta/action/src/sc.c
+++ b/cesar/cp/sta/action/src/sc.c
@@ -128,6 +128,10 @@ cp_sta_action_sc__start_sc_in_add (cp_t *ctx, cp_mme_peer_t *peer)
{
/* We are not on an AVLN, we must create one and become CCo. */
cnf.cco_status = true;
+ /* Make the main CP FSM move to CCo. */
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_sc_get_cco_functionality);
+ cp_fsm_trigger (ctx, event);
}
/* Send the reply. */
cp_msg_cm_sc_join_cnf_send (ctx, peer, &cnf);
diff --git a/cesar/cp/sta/action/test/utest/src/sc.c b/cesar/cp/sta/action/test/utest/src/sc.c
index 5cd362d469..32a6350a99 100644
--- a/cesar/cp/sta/action/test/utest/src/sc.c
+++ b/cesar/cp/sta/action/test/utest/src/sc.c
@@ -553,7 +553,10 @@ sc_basic_test_cases (test_t t)
SCENARIO_ACTION (sc__sc_join__cm_sc_join_req, .peer = sc_join_peer),
/* Decode is ok. */
SCENARIO_EVENT (cp_msg_cm_sc_join_req_receive, .ok = true,
- .cco_cap = 0),
+ .cco_cap = 0),
+ /* Our CCo cap are greater, let's become CCo. */
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_sc_get_cco_functionality),
/* Send the SC_JOIN.CNF. */
SCENARIO_EVENT (cp_msg_cm_sc_join_cnf_send,
.peer = sc_join_peer, .nid = nid,
@@ -602,6 +605,9 @@ sc_basic_test_cases (test_t t)
/* Decode is ok. */
SCENARIO_EVENT (cp_msg_cm_sc_join_req_receive, .ok = true,
.cco_cap = 0),
+ /* Our CCo cap are greater, let's become CCo. */
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_sc_get_cco_functionality),
/* Send the SC_JOIN.CNF. */
SCENARIO_EVENT (cp_msg_cm_sc_join_cnf_send,
.peer = sc_join_peer, .nid = nid,
@@ -734,6 +740,9 @@ sc_basic_test_cases (test_t t)
* should be ignored). */
SCENARIO_EVENT (cp_msg_cm_sc_join_req_receive, .ok = true,
.cco_cap = 1),
+ /* We need to become CCo. */
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_sc_get_cco_functionality),
/* Send the SC_JOIN.CNF. */
SCENARIO_EVENT (cp_msg_cm_sc_join_cnf_send,
.peer = sc_join_peer, .nid = nid,