summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorDavid Mercadie2011-02-09 19:32:32 +0100
committerDavid Mercadie2011-02-10 15:05:52 +0100
commit5ca52877b8b48cb0f1a220127e18ae885ed8c646 (patch)
tree69ce74cc7aa2f148f78a73efb8ccd15f3d23ba1c /cesar
parentb2c0ceab29afddc0a8cc272c0eea4e095a84a13a (diff)
cesar/cp/sta/action: don't associate with a wrong snid, closes #1857
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/sta/action/src/action.c1
-rw-r--r--cesar/cp/sta/action/test/utest/src/poweron.c51
-rw-r--r--cesar/cp/sta/action/test/utest/src/sc.c18
3 files changed, 69 insertions, 1 deletions
diff --git a/cesar/cp/sta/action/src/action.c b/cesar/cp/sta/action/src/action.c
index 2d65a9fc59..6c8cebc2e7 100644
--- a/cesar/cp/sta/action/src/action.c
+++ b/cesar/cp/sta/action/src/action.c
@@ -79,6 +79,7 @@ cp_sta_action_beacon_match_and_join (cp_t *ctx,
}
/* Should we associate? */
if (its_nid == our_nid
+ && its_snid == cp_sta_own_data_get_snid (ctx)
&& !net->blacklisted
&& cp_beacon_synchronised (ctx))
{
diff --git a/cesar/cp/sta/action/test/utest/src/poweron.c b/cesar/cp/sta/action/test/utest/src/poweron.c
index 7d6d16ebba..1bf0e54613 100644
--- a/cesar/cp/sta/action/test/utest/src/poweron.c
+++ b/cesar/cp/sta/action/test/utest/src/poweron.c
@@ -272,6 +272,57 @@ poweron_test_cases (test_t t)
test_fail_unless (own_data->nid_track == nid);
test_fail_unless (cp_sta_own_data_get_snid (cp) == 1);
test_fail_unless (cp_sta_own_data_get_nid (cp) == nid);
+ test_sta_action_reset (&ctx);
+ } test_end;
+ /* NID do match but snid do not. */
+ test_begin (t, "nid match cco, snid don't")
+ {
+ cp_snid_t snid = 1;
+ cp_snid_t other_snid = 2;
+
+ cp_net_t *net = cp_sta_mgr_add_avln (cp, snid, nid);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (cp, net, 1, 0x0123456789abull);
+
+ cp_net_t *other_net = cp_sta_mgr_add_avln (cp, other_snid, nid);
+ cp_sta_t *other_sta = cp_sta_mgr_sta_add (cp, other_net, 1,
+ 0x112233445576ull);
+
+ cp_net_set_cco (cp, net, 1);
+ cp_net_set_cco (cp, other_net, 1);
+ cp_sta_own_data_set_nid (cp, nid);
+
+ slab_release (sta);
+ slab_release (other_sta);
+
+ scenario_entry_t entries[] = {
+ /* POWERON SPOC not updated. */
+ SCENARIO_ACTION (poweron__poweron__beacon, .beacon = beacon,
+ .net = net, .sta = sta),
+ SCENARIO_EVENT (cp_beacon_process_tracked_avln, .beacon = beacon,
+ .net = net),
+ SCENARIO_EVENT (cp_beacon_synchronised, .ok = false),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (POWERON, BEACON,
+ no_nid_match)),
+ /* other net and cco. */
+ SCENARIO_ACTION (poweron__poweron__beacon, .beacon = beacon,
+ .net = other_net, .sta = other_sta),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (POWERON, BEACON,
+ no_nid_match)),
+ /* USTA. */
+ SCENARIO_ACTION (poweron__usta__beacon, .beacon = beacon,
+ .net = other_net, .sta = other_sta),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (USTA, BEACON,
+ no_nid_match)),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (cp);
+ test_fail_unless (own_data->nid_track == nid);
+ test_fail_unless (cp_sta_own_data_get_snid (cp) == snid);
+ test_fail_unless (cp_sta_own_data_get_nid (cp) == nid);
} test_end;
/* BTT timeout. */
test_case_begin (t, "poweron btt");
diff --git a/cesar/cp/sta/action/test/utest/src/sc.c b/cesar/cp/sta/action/test/utest/src/sc.c
index 2e0069b0a3..d9c015c66d 100644
--- a/cesar/cp/sta/action/test/utest/src/sc.c
+++ b/cesar/cp/sta/action/test/utest/src/sc.c
@@ -33,6 +33,7 @@ sc_basic_test_cases (test_t t)
const mac_t my_mac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01);
cp_sta_own_data_set_mac_address (&ctx.cp, my_mac);
const mac_t sc_add_mac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x02);
+ const mac_t sc_add_mac2 = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x04);
const mac_t sc_join_mac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x03);
const cp_nid_t nid = 0xF11111111111ull;
cp_mme_peer_t all_sta = CP_MME_PEER (MAC_BROADCAST,
@@ -289,11 +290,15 @@ sc_basic_test_cases (test_t t)
test_sta_action_create_our_net (&ctx, nid, 0);
cp_net_t *net = cp_sta_mgr_get_avln (&ctx.cp, 0, nid);
cp_net_t *other_net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_net_t *other_net2 = cp_sta_mgr_add_avln (&ctx.cp, 1, nid);
/* A STA in SC add. */
cp_mme_peer_t sc_add_peer = CP_MME_PEER (sc_add_mac, 1);
cp_sta_t *sc_add_sta = cp_sta_mgr_sta_add (&ctx.cp, net, 1,
sc_add_mac);
+ cp_sta_t *sc_add_sta2 = cp_sta_mgr_sta_add (&ctx.cp, other_net2, 1,
+ sc_add_mac2);
cp_net_set_cco (&ctx.cp, net, 1);
+ cp_net_set_cco (&ctx.cp, other_net2, 1);
/* STA replies to SC.JOIN.REQ. */
scenario_entry_t sc_join_reply[] = {
/* Run start of SC join procedure. */
@@ -336,7 +341,7 @@ sc_basic_test_cases (test_t t)
.beacon = beacon,
.net = net,
.sta = sc_add_sta),
- /* Beacon is ok, SPOC is not update, do not start assoc. */
+ /* Beacon is ok, SPOC is not updated, do not start assoc. */
/* Track it. */
SCENARIO_EVENT (cp_beacon_process_tracked_avln, .beacon = beacon,
.net = net),
@@ -344,6 +349,15 @@ sc_basic_test_cases (test_t t)
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (SC_WAIT_BEACON, BEACON,
nid_differs)),
+ /* A third beacon has arrived. */
+ SCENARIO_ACTION (sc__sc_wait_beacon__beacon,
+ .beacon = beacon,
+ .net = other_net2,
+ .sta = sc_add_sta2),
+ /* Beacon is not ok, snid is wrong. */
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (SC_WAIT_BEACON, BEACON,
+ nid_differs)),
/* Beacon is ok, start assoc. */
SCENARIO_ACTION (sc__sc_wait_beacon__beacon,
.beacon = beacon,
@@ -373,7 +387,9 @@ sc_basic_test_cases (test_t t)
scenario_run (t, sc_join_reply, &globals);
/* Clean. */
cp_sta_mgr_sta_remove (&ctx.cp, sc_add_sta);
+ cp_sta_mgr_sta_remove (&ctx.cp, sc_add_sta2);
slab_release (sc_add_sta);
+ slab_release (sc_add_sta2);
} test_end;
/* SC_JOIN with associated STA. */