summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorJean-Philippe SAVE2011-04-14 14:29:00 +0200
committerJean-Philippe SAVE2011-04-14 14:29:00 +0200
commitab757cebd85f7dd3c964cb181231ae42f5bec66f (patch)
tree3db998dd86ecb3a4c1cc90325b8a42a75c2ec10f /cesar/cp
parent2d3ac8784db8a1452dade45d51053f7bb0695a34 (diff)
Revert "cesar/cp/{beacon, cco/action}: merge two avlns"
This reverts commit 2d3ac8784db8a1452dade45d51053f7bb0695a34.
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/beacon/src/beacon.c7
-rw-r--r--cesar/cp/beacon/test/inc/scenario_defs.h4
-rw-r--r--cesar/cp/beacon/test/src/beacon_scenario.c80
-rw-r--r--cesar/cp/beacon/test/src/fsm_stub.c21
-rw-r--r--cesar/cp/beacon/test/src/sta_mgr_stub.c7
-rw-r--r--cesar/cp/cco/action/src/cco_action.c12
-rw-r--r--cesar/cp/cco/action/test/utest/inc/scenario_defs.h4
-rw-r--r--cesar/cp/cco/action/test/utest/src/assoc.c108
-rw-r--r--cesar/cp/cco/action/test/utest/src/fsm_stub.c6
-rw-r--r--cesar/cp/cco/action/test/utest/src/scenario_actions.c10
10 files changed, 10 insertions, 249 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 2131f25840..658d2cdfd2 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -811,7 +811,7 @@ cp_beacon_process_beacon (cp_t *ctx, bsu_beacon_t *beacon)
&& ctx->beacon.snids.snidcd == 0)
cp_fsm_post_new_event (ctx, bare, cco__snid_conflict);
}
- /* Raise the events in the FSM for station action. */
+ /* Raise the event in the FSM for station action. */
if (beacon->vf.bt == BSU_BEACON_TYPE_CENTRAL
|| beacon->vf.bt == BSU_BEACON_TYPE_PROXY)
{
@@ -819,9 +819,8 @@ cp_beacon_process_beacon (cp_t *ctx, bsu_beacon_t *beacon)
if (sta)
cp_fsm_post_new_event (
ctx, beacon, BEACON, beacon, net, sta);
-
- if (cp_sta_own_data_get_cco_status (ctx) &&
- (cp_sta_own_data_get_nid (ctx) == beacon->vf.nid))
+ /* The beacon comes from another ALVN. */
+ else
cp_fsm_post_new_event (
ctx, beacon, BEACON_WITH_SAME_NID, beacon, net, NULL);
}
diff --git a/cesar/cp/beacon/test/inc/scenario_defs.h b/cesar/cp/beacon/test/inc/scenario_defs.h
index 9d4711305e..273eaa35f5 100644
--- a/cesar/cp/beacon/test/inc/scenario_defs.h
+++ b/cesar/cp/beacon/test/inc/scenario_defs.h
@@ -40,7 +40,6 @@ __0 (get_and_process_beacon)
/* Scenario events. */
/* Scenario events. */
#define SCENARIO_DEFS_EVENTS \
- cp_fsm_event_beacon_new, \
cp_fsm_event_bare_new
/* Any event. */
@@ -53,9 +52,6 @@ typedef struct \
} scenario_event_ ## event ## _t;
__e (cp_fsm_event_bare_new, cp_fsm_event_type_t type)
-__e (cp_fsm_event_beacon_new, cp_fsm_event_type_t type,
- bsu_beacon_t *beacon, cp_net_t *net,
- cp_sta_t *sta)
#undef __p_
#undef __e
diff --git a/cesar/cp/beacon/test/src/beacon_scenario.c b/cesar/cp/beacon/test/src/beacon_scenario.c
index 7c201694cc..586acdc191 100644
--- a/cesar/cp/beacon/test/src/beacon_scenario.c
+++ b/cesar/cp/beacon/test/src/beacon_scenario.c
@@ -20,87 +20,12 @@
#include "cp/inc/context.h"
bsu_beacon_t beacon_data;
-extern bool cco_status;
-extern cp_net_t our_avln;
void
cp_beacon_receive (void *ul, bsu_beacon_t *beacon);
void
-beacon_same_nid_test_case (test_t test)
-{
- cp_t cp;
- bsu_beacon_t *beacon;
- scenario_globals_t globals = { .cp = &cp, };
-
- /** Init the context. */
- memset (&cp, 0, sizeof (cp_t));
- mac_config_t mac_config;
- memset (&mac_config, 0, sizeof (mac_config_t));
- cp.mac_config = &mac_config;
- cp_sta_mgr_init (&cp);
- /* This device is cco */
- cco_status = true;
-
- mac_eks_t ref_eks_current = MAC_EKS_MIN + 2;
- mac_eks_t ref_eks_next = MAC_EKS_MIN + 3;
-
- mac_config.nek[bsu_nek_index_current ()].eks = ref_eks_current;
- mac_config.nek[bsu_nek_index_next ()].eks = ref_eks_next;
-
- test_case_begin (test, "get_and_process_beacon");
-
- beacon = (bsu_beacon_t *) blk_alloc ();
- beacon->vf.stei = 1;
- beacon->vf.nid = 1;
- beacon->params.rx_parameters.snid = 2;
- /* the beacon is sent by an other cco than our */
- beacon->bmis.mac_address.present = true;
- beacon->bmis.mac_address.mac_address =
- MAC_ADDRESS(0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC);
- beacon->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
- cp_beacon_receive (&cp, beacon);
-
- test_begin (test, "cco receives beacon with same nid")
- {
- scenario_entry_t entries[] =
- {
- SCENARIO_ACTION (get_and_process_beacon),
- SCENARIO_EVENT (cp_fsm_event_beacon_new,
- .type = CP_FSM_EVENT_TYPE_BEACON_WITH_SAME_NID,
- beacon, &our_avln, NULL),
- SCENARIO_END
- };
- scenario_run (test, entries, &globals);
- }
- test_end;
-
- beacon = (bsu_beacon_t *) blk_alloc ();
- beacon->vf.stei = 4;
- beacon->vf.nid = 1;
- beacon->params.rx_parameters.snid = 1;
- /* the beacon is sent by an other cco than our */
- beacon->bmis.mac_address.present = true;
- beacon->bmis.mac_address.mac_address =
- MAC_ADDRESS(0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC);
- beacon->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
- cp_beacon_receive (&cp, beacon);
- cco_status = false;
-
- test_begin (test, "sta receives beacon")
- {
- scenario_entry_t entries[] =
- {
- SCENARIO_ACTION (get_and_process_beacon),
- SCENARIO_END
- };
- scenario_run (test, entries, &globals);
- }
- test_end;
-}
-
-void
-beacon_nek_request_test_case (test_t test)
+beacon_test_case (test_t test)
{
cp_t cp;
bsu_beacon_t *beacon;
@@ -285,8 +210,7 @@ main (int argc, char **argv)
test_t t;
test_init (t, argc, argv);
- beacon_same_nid_test_case (t);
- beacon_nek_request_test_case (t);
+ beacon_test_case (t);
test_result (t);
return test_nb_failed (t) == 0 ? 0 : 1;
diff --git a/cesar/cp/beacon/test/src/fsm_stub.c b/cesar/cp/beacon/test/src/fsm_stub.c
index 6d09863df4..4432c97679 100644
--- a/cesar/cp/beacon/test/src/fsm_stub.c
+++ b/cesar/cp/beacon/test/src/fsm_stub.c
@@ -40,24 +40,3 @@ cp_fsm_event_bare_new (cp_t *ctx, cp_fsm_event_type_t type)
test_fail_unless (type == param->type);
return INVALID_PTR;
}
-
-cp_fsm_event_t *
-cp_fsm_event_beacon_new (cp_t *ctx, cp_fsm_event_type_t type,
- bsu_beacon_t *beacon, cp_net_t *net,
- cp_sta_t *sta){
- dbg_assert (ctx);
- switch (type)
- {
- case CP_FSM_EVENT_TYPE_BEACON:
- /* Ignore. */
- return INVALID_PTR;
- default:
- ;
- }
- scenario_event (cp_fsm_event_beacon_new, param);
- test_fail_unless (type == param->type);
- test_fail_unless (beacon == param->beacon);
- test_fail_unless (net == param->net);
- test_fail_unless (sta == param->sta);
- return INVALID_PTR;
-}
diff --git a/cesar/cp/beacon/test/src/sta_mgr_stub.c b/cesar/cp/beacon/test/src/sta_mgr_stub.c
index 7c6a83db04..58ee9dbf92 100644
--- a/cesar/cp/beacon/test/src/sta_mgr_stub.c
+++ b/cesar/cp/beacon/test/src/sta_mgr_stub.c
@@ -23,8 +23,6 @@
cp_sta_own_data_t own_data;
cp_net_t our_avln;
-bool cco_status;
-
void
cp_sta_mgr_init (cp_t *ctx)
@@ -34,7 +32,6 @@ cp_sta_mgr_init (cp_t *ctx)
own_data.nid_track = 1;
own_data.tei_track = 1;
own_data.cco_mac_addr_track = MAC_ZERO;
- cco_status = false;
memset (&ctx->sta_mgr, 0, sizeof (cp_sta_mgr_t));
@@ -56,7 +53,7 @@ cp_sta_mgr_get_sta_own_data (cp_t *ctx)
bool
cp_sta_own_data_get_cco_status (cp_t *ctx)
{
- return cco_status;
+ return false;
}
bool
@@ -199,7 +196,7 @@ cp_net_sta_get_next (cp_t *ctx, cp_net_t *net, cp_sta_t *prev_sta)
mac_t
cp_sta_own_data_get_mac_address (cp_t *ctx)
{
- return MAC_ADDRESS(0x12, 0x34, 0x56, 0x78, 0x9A, 0xBD);
+ return 0;
}
cp_sta_t *
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index 99807cd004..02e0c5f198 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -1525,15 +1525,5 @@ void
cp_cco_action_beacon_with_same_nid (
cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
{
- dbg_assert (beacon);
-
- /* If we have the highest mac address we do nothing. */
- if (beacon->bmis.mac_address.present)
- if (MAC_REVERSE (beacon->bmis.mac_address.mac_address) <
- MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx)))
- return;
-
- /* To merge the two avlns we shut our network by turning the cco into
- * an unassociated sta. */
- cp_cco_action_cco__unassoc_stop (ctx);
+ /* TODO: try to merge the AVLN. */
}
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 59304d33a3..415a2b4b26 100644
--- a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/cco/action/test/utest/inc/scenario_defs.h
@@ -58,8 +58,7 @@
cco__unassoc_start, \
cco__unassoc_stop, \
cco__assoc_start, \
- cco__assoc_stop, \
- BEACON_WITH_SAME_NID
+ cco__assoc_stop
/* Actions without parameter. */
#define __0(action) \
@@ -119,7 +118,6 @@ __0 (cco__unassoc_start)
__0 (cco__unassoc_stop)
__0 (cco__assoc_start)
__0 (cco__assoc_stop)
-__n (BEACON_WITH_SAME_NID, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
#undef __0
#undef __n
diff --git a/cesar/cp/cco/action/test/utest/src/assoc.c b/cesar/cp/cco/action/test/utest/src/assoc.c
index 0f9533866c..28f1e5e77d 100644
--- a/cesar/cp/cco/action/test/utest/src/assoc.c
+++ b/cesar/cp/cco/action/test/utest/src/assoc.c
@@ -366,117 +366,9 @@ assoc_test_case_nek_request (test_t t)
}
void
-assoc_test_case_beacon_with_same_nid (test_t t)
-{
- test_cco_action_t ctx;
- test_cco_action_init (&ctx);
- cp_cco_action_init (&ctx.cp);
-
- scenario_globals_t globals = {
- .cp = &ctx.cp,
- };
-
- /* create the avln */
- cp_nid_t nid = 1;
- cp_snid_t snid = 1;
- bsu_beacon_t *beacon;
- test_cco_action_create_our_net(&ctx, nid, snid);
- cp_net_t *net = cp_sta_mgr_get_our_avln (&ctx.cp);
- cp_sta_t *cco = cp_net_get_cco (&ctx.cp, net);
-
- /* create an authenticated station in the avln */
- const cp_tei_t sta_tei = 2;
- const mac_t sta_mac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01);
- cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx.cp, net, sta_tei, sta_mac);
- cp_sta_set_authenticated (&ctx.cp, sta, true);
-
- test_case_begin (t, "CCO receives a BEACON_WITH_SAME_NID");
- test_begin (t, "the mac address is smaller than our own")
- {
- beacon = (bsu_beacon_t *) blk_alloc ();
- beacon->bmis.mac_address.present = true;
- beacon->bmis.mac_address.mac_address =
- cp_sta_own_data_get_mac_address (&ctx.cp) - 1;
-
- scenario_entry_t entry[] = {
- SCENARIO_ACTION (BEACON_WITH_SAME_NID, .beacon = beacon, .net = net,
- .sta = NULL),
- SCENARIO_END
- };
- scenario_run (t, entry, &globals);
- test_fail_unless (cp_sta_own_data_get_cco_status (&ctx.cp));
- test_fail_unless (cp_net_get_cco (&ctx.cp, net) == cco);
- blk_release (beacon);
- }
- test_end;
-
- test_begin (t, "there is no bmi mac address")
- {
- beacon = (bsu_beacon_t *) blk_alloc ();
- beacon->bmis.mac_address.present = false;
-
- scenario_entry_t entry[] = {
- SCENARIO_ACTION (BEACON_WITH_SAME_NID, .beacon = beacon, .net = net,
- .sta = NULL),
- SCENARIO_EVENT (cp_fsm_event_bare_new,
- .type = CP_FSM_EVENT_TYPE_sta_status_changed),
- 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, entry, &globals);
- test_fail_unless (!cp_sta_own_data_get_cco_status (&ctx.cp));
- test_fail_unless (cp_net_get_cco (&ctx.cp, net) == NULL);
- int i;
- for (i = 0; i < CP_CCO_ACTION_TEI_FLAGS_ROW; i++)
- test_fail_unless (ctx.cp.cco_action.tei_flags[i] == 0);
- blk_release (beacon);
- }
- test_end;
- slab_release (sta);
-
- test_cco_action_create_our_net(&ctx, nid, snid);
- net = cp_sta_mgr_get_our_avln (&ctx.cp);
- /* create an authenticated station in the avln */
- sta = cp_sta_mgr_sta_add (&ctx.cp, net, sta_tei, sta_mac);
- cp_sta_set_authenticated (&ctx.cp, sta, true);
-
- test_begin (t, "the mac address is bigger than our")
- {
- beacon = (bsu_beacon_t *) blk_alloc ();
- beacon->bmis.mac_address.mac_address =
- cp_sta_own_data_get_mac_address (&ctx.cp) + 1;
-
- scenario_entry_t entry[] = {
- SCENARIO_ACTION (BEACON_WITH_SAME_NID, .beacon = beacon, .net = net,
- .sta = NULL),
- SCENARIO_EVENT (cp_fsm_event_bare_new,
- .type = CP_FSM_EVENT_TYPE_sta_status_changed),
- 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, entry, &globals);
- test_fail_unless (!cp_sta_own_data_get_cco_status (&ctx.cp));
- test_fail_unless (cp_net_get_cco (&ctx.cp, net) == NULL);
- int i;
- for (i = 0; i < CP_CCO_ACTION_TEI_FLAGS_ROW; i++)
- test_fail_unless (ctx.cp.cco_action.tei_flags[i] == 0);
- blk_release (beacon);
- }
- test_end;
-
- slab_release (sta);
- test_cco_action_uninit (&ctx);
-}
-
-void
assoc_test_suite (test_t t)
{
test_suite_begin (t, "Association");
assoc_test_case_cco (t);
assoc_test_case_nek_request (t);
- assoc_test_case_beacon_with_same_nid (t);
}
diff --git a/cesar/cp/cco/action/test/utest/src/fsm_stub.c b/cesar/cp/cco/action/test/utest/src/fsm_stub.c
index c453b3bf30..2d2c3218ff 100644
--- a/cesar/cp/cco/action/test/utest/src/fsm_stub.c
+++ b/cesar/cp/cco/action/test/utest/src/fsm_stub.c
@@ -27,13 +27,9 @@ cp_fsm_event_bare_new (cp_t *ctx, cp_fsm_event_type_t type)
case CP_FSM_EVENT_TYPE_join_timeout:
case CP_FSM_EVENT_TYPE_assoc_timeout:
case CP_FSM_EVENT_TYPE_renew:
+ case CP_FSM_EVENT_TYPE_sta_status_changed:
/* Ignore. */
return INVALID_PTR;
- case CP_FSM_EVENT_TYPE_sta_status_changed:
- if (!scenario.current ||
- (scenario.current->params.event_cp_fsm_event_bare_new.type != type))
- return INVALID_PTR;
-
default:
;
}
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 1f3edc27d2..a42b6be5f7 100644
--- a/cesar/cp/cco/action/test/utest/src/scenario_actions.c
+++ b/cesar/cp/cco/action/test/utest/src/scenario_actions.c
@@ -99,13 +99,3 @@ __0 (cco__unassoc_start)
__0 (cco__unassoc_stop)
__0 (cco__assoc_start)
__0 (cco__assoc_stop)
-
-void
-scenario_action_BEACON_WITH_SAME_NID_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- scenario_action_BEACON_WITH_SAME_NID_t *p =
- &params->action_BEACON_WITH_SAME_NID;
- cp_cco_action_beacon_with_same_nid (globals->cp, p->beacon, p->net, p->sta);
-}
-