From 9bb91d38efd0bff3b3eb2b11290cf45e6cc9b496 Mon Sep 17 00:00:00 2001 From: laranjeiro Date: Wed, 7 Jul 2010 15:24:04 +0000 Subject: cesar/cp/{fsm, cco/action, beacon}: end discover procedure, closes #1709 When the CCo receives the discover beacon from a station and the updated flag in the discover info beacon entry is set, it must require a cc_discover_list.cnf from the station. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7276 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/cp/beacon/src/beacon.c | 15 ++++++ cesar/cp/cco/action/cco_action.h | 10 ++++ cesar/cp/cco/action/src/cco_action.c | 10 ++++ cesar/cp/cco/action/test/utest/Makefile | 2 +- cesar/cp/cco/action/test/utest/inc/scenario_defs.h | 5 ++ cesar/cp/cco/action/test/utest/src/discover_list.c | 56 ++++++++++++++++++++++ cesar/cp/cco/action/test/utest/src/msg_stub.c | 1 + .../cco/action/test/utest/src/scenario_actions.c | 3 ++ .../cp/cco/action/test/utest/src/test_cco_action.c | 4 ++ cesar/cp/fsm/src/fsm/cp.fsm | 2 + 10 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 cesar/cp/cco/action/test/utest/src/discover_list.c diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c index e6d7461875..c3a07859ad 100644 --- a/cesar/cp/beacon/src/beacon.c +++ b/cesar/cp/beacon/src/beacon.c @@ -751,6 +751,21 @@ cp_beacon_get_and_process_beacon (cp_t *ctx) /** Program the timer. */ cp_beacon_reconfigure_timer (ctx, false); } + /* Discover beacons from our AVLN. */ + else if (cp_sta_own_data_get_tei (ctx) + && type == CP_BEACON_DISCOVER_BEACON + && nid == cp_sta_own_data_get_nid (ctx) + && snid == cp_sta_own_data_get_snid (ctx)) + { + bool updated = bitstream_direct_read ( + &beacon_data.bmis.discover_info.info_data, 0, 1); + if (updated) + { + cp_fsm_event_t *event = cp_fsm_event_sta_new ( + ctx, CP_FSM_EVENT_TYPE_discover_info_updated, net, sta); + cp_fsm_post (ctx, event); + } + } else if (cp_sta_own_data_get_tei (ctx)) { /* Is the SNID in conflict. */ diff --git a/cesar/cp/cco/action/cco_action.h b/cesar/cp/cco/action/cco_action.h index b1dcb9313e..e6e3d1a016 100644 --- a/cesar/cp/cco/action/cco_action.h +++ b/cesar/cp/cco/action/cco_action.h @@ -350,6 +350,16 @@ cp_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme); void cp_cco_action_nek_change_prevent (cp_t *ctx); +/** + * Request a CC_DISCOVER_LIST.REQ to a station. + * \param ctx the module context. + * \param net the concerned network. + * \param sta the station to request the list. + */ +void +cp_cco_action_cco__cc_discover_list_req (cp_t *ctx, cp_net_t *net, + cp_sta_t *sta); + 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 d64978e9de..3ad82ec189 100644 --- a/cesar/cp/cco/action/src/cco_action.c +++ b/cesar/cp/cco/action/src/cco_action.c @@ -1396,3 +1396,13 @@ cp_cco_action_nek_change_prevent (cp_t *ctx) CP_CCO_ACTION_EKS_NEXT(ctx->cco_action.eks_current); } } + +void +cp_cco_action_cco__cc_discover_list_req (cp_t *ctx, cp_net_t *net, + cp_sta_t *sta) +{ + dbg_assert (ctx); + cp_mme_peer_t peer; + cp_sta_get_peer (sta, &peer); + cp_msg_cc_discover_list_req_send (ctx, &peer); +} diff --git a/cesar/cp/cco/action/test/utest/Makefile b/cesar/cp/cco/action/test/utest/Makefile index 32a9048dce..f1fffa950c 100644 --- a/cesar/cp/cco/action/test/utest/Makefile +++ b/cesar/cp/cco/action/test/utest/Makefile @@ -3,7 +3,7 @@ BASE = ../../../../.. INCLUDES = cp/cco/action/test/utest cp/cco/action/test/utest/override HOST_PROGRAMS = test_cco_action -test_cco_action_SOURCES = test_cco_action.c handover.c nek.c \ +test_cco_action_SOURCES = test_cco_action.c handover.c nek.c discover_list.c \ msg_stub.c fsm_stub.c \ cp_stub.c scenario_actions.c \ dataplane_stub.c beacon_stub.c \ diff --git a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h b/cesar/cp/cco/action/test/utest/inc/scenario_defs.h index 81bc2f6dc1..680cd77cbf 100644 --- a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h +++ b/cesar/cp/cco/action/test/utest/inc/scenario_defs.h @@ -34,6 +34,7 @@ handover__timeout_cc_handover_info_rsp, \ handover__hoip_countdown_expired, \ handover__discover_done, \ + cco__cc_discover_list_req, \ \ drv_mac_stop, \ gen_nek, \ @@ -78,6 +79,7 @@ __m (handover__cc_handover_info_rsp_receive) __0 (handover__timeout_cc_handover_info_rsp) __0 (handover__hoip_countdown_expired) __0 (handover__discover_done) +__n (cco__cc_discover_list_req, cp_net_t *net, cp_sta_t *sta) __0 (drv_mac_stop) __0 (gen_nek) __0 (nek_provide) @@ -105,6 +107,8 @@ __0 (nek_change_timeout_wait) cp_msg_cc_handover_req_send, \ cp_msg_cc_handover_info_rsp_receive, \ \ + cp_msg_cc_discover_list_req_send, \ + \ cp_beacon_handover, \ cp_beacon_discover_init, \ cp_beacon_discover_uninit, \ @@ -192,6 +196,7 @@ __msk (cp_msg_cm_set_key_req_send, u8 new_eks, cp_key_t new_key) __mrk (cp_msg_cm_set_key_cnf_receive, enum cp_msg_cm_set_key_cnf_result_t result, u8 cco_cap); +__ms (cp_msg_cc_discover_list_req_send); #undef __ms #undef __msk diff --git a/cesar/cp/cco/action/test/utest/src/discover_list.c b/cesar/cp/cco/action/test/utest/src/discover_list.c new file mode 100644 index 0000000000..c1fcc60e43 --- /dev/null +++ b/cesar/cp/cco/action/test/utest/src/discover_list.c @@ -0,0 +1,56 @@ +/* Cesar project {{{ + * + * Copyright (C) 2010 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file src/discover_list.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ +#include "common/std.h" +#include "lib/scenario/scenario.h" +#include "inc/test_cco_action.h" +#include "cp/cco/action/cco_action.h" + +void +cc_discover_list_test_suite (test_t t) +{ + test_suite_begin (t, "CC_DISCOVER_LIST"); + cp_sta_t *sta; + cp_net_t *net; + test_cco_action_t ctx; + test_cco_action_init (&ctx); + cp_cco_action_init (&ctx.cp); + scenario_globals_t globals = { + .cp = &ctx.cp, + }; + cp_mme_tx_t mme_to_send; + globals.mme = &mme_to_send; + test_case_begin (t, "Send CC_DISCOVER_LIST.REQ"); + /* Add the station to send the request. */ + test_cco_action_create_our_net (&ctx, 1, 1); + net = cp_sta_mgr_get_our_avln (&ctx.cp); + sta = cp_sta_mgr_sta_add (&ctx.cp, net, 4, 4); + cp_sta_set_authenticated (&ctx.cp, sta, true); + sta->cco_cap = CP_CCO_LEVEL; + scenario_entry_t entries[] = { + SCENARIO_ACTION (cco__cc_discover_list_req, + .net = net, + .sta = sta), + SCENARIO_EVENT (cp_msg_cc_discover_list_req_send, + .peer = CP_MME_PEER (4, 4)), + SCENARIO_END + }; + test_begin (t, "Discover list.") + { + scenario_run (t, entries, &globals); + } + test_end; + slab_release (sta); + test_cco_action_uninit (&ctx); +} diff --git a/cesar/cp/cco/action/test/utest/src/msg_stub.c b/cesar/cp/cco/action/test/utest/src/msg_stub.c index 512b6329ef..2da62eccb7 100644 --- a/cesar/cp/cco/action/test/utest/src/msg_stub.c +++ b/cesar/cp/cco/action/test/utest/src/msg_stub.c @@ -274,3 +274,4 @@ __msk (cp_msg_cm_set_key_req_send, __mrk (cp_msg_cm_set_key_cnf_receive, cp_msg_cm_set_key_cnf_t, (enum cp_msg_cm_set_key_cnf_result_t, result, assign), (u8, cco_cap, assign)) +__ms (cp_msg_cc_discover_list_req_send) diff --git a/cesar/cp/cco/action/test/utest/src/scenario_actions.c b/cesar/cp/cco/action/test/utest/src/scenario_actions.c index 391b5e7199..2c250c310a 100644 --- a/cesar/cp/cco/action/test/utest/src/scenario_actions.c +++ b/cesar/cp/cco/action/test/utest/src/scenario_actions.c @@ -77,6 +77,9 @@ __m (handover__cc_handover_info_rsp_receive) __0 (handover__timeout_cc_handover_info_rsp) __0 (handover__hoip_countdown_expired) __0 (handover__discover_done) +__n (cco__cc_discover_list_req, + (cp_net_t *, net), + (cp_sta_t *, sta)) __0 (drv_mac_stop) __0 (gen_nek) __0 (nek_provide) diff --git a/cesar/cp/cco/action/test/utest/src/test_cco_action.c b/cesar/cp/cco/action/test/utest/src/test_cco_action.c index 823100fe2f..1e8335b99f 100644 --- a/cesar/cp/cco/action/test/utest/src/test_cco_action.c +++ b/cesar/cp/cco/action/test/utest/src/test_cco_action.c @@ -21,6 +21,9 @@ handover_test_suite (test_t t); void nek_change (test_t t); +void +cc_discover_list_test_suite (test_t t); + void test_cco_action_init (test_cco_action_t *ctx) { @@ -84,6 +87,7 @@ main (int argc, char **argv) handover_test_suite (t); nek_change (t); + cc_discover_list_test_suite (t); test_result (t); return test_nb_failed (t) == 0 ? 0 : 1; diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/fsm/src/fsm/cp.fsm index a0dd9b93e1..0240335e43 100644 --- a/cesar/cp/fsm/src/fsm/cp.fsm +++ b/cesar/cp/fsm/src/fsm/cp.fsm @@ -101,6 +101,7 @@ Events: become_cco become_sta sta_status_changed + discover_info_updated DRV_STA_SET_MAC_ADDR_REQ DRV_STA_SET_CCO_PREF_REQ @@ -501,6 +502,7 @@ CCO: join_timeout: no sta no avln -> UCCO all_sta_leaved -> . [cp_sta_action_poweron__cco__all_sta_leaved] to_stop -> CCO_LEAVING [cp_cco_action_drv_mac_stop] + discover_info_updated -> . [cp_cco_action_cco__cc_discover_list_req] change_nek -> . [cp_cco_action_gen_nek] snid_conflict -> . [cp_cco_action_snid_change] -- cgit v1.2.3