summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-07-10 15:47:12 +0000
committerlaranjeiro2008-07-10 15:47:12 +0000
commitc62d7431823f4f7aa4ba140efefc115170dddfe2 (patch)
treec0818ec479d13297500c42e8041a7f82de6eb26b
parente509560ef6ac31428540575695b471f604470cc1 (diff)
cp2/sta/mgr: Adding a function to merge a net to our network.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2593 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/cp2/sta/mgr/src/sta_mgr.c23
-rw-r--r--cesar/cp2/sta/mgr/sta_mgr.h8
-rw-r--r--cesar/cp2/sta/mgr/test/src/sta_mgr_test.c56
3 files changed, 87 insertions, 0 deletions
diff --git a/cesar/cp2/sta/mgr/src/sta_mgr.c b/cesar/cp2/sta/mgr/src/sta_mgr.c
index 8393726241..e9384ea151 100644
--- a/cesar/cp2/sta/mgr/src/sta_mgr.c
+++ b/cesar/cp2/sta/mgr/src/sta_mgr.c
@@ -264,4 +264,27 @@ cp_sta_mgr_net_list_is_empty (cp_t *ctx)
return cp_net_list_is_empty (ctx, &ctx->sta_mgr.network_list);
}
+/**
+ * Merge the network to our net.
+ * \param ctx the module context.
+ * \param net the network to merge.
+ */
+void
+cp_sta_mgr_merge_net (cp_t *ctx, cp_net_t *net)
+{
+ cp_net_t *our_net;
+
+ dbg_assert (ctx);
+ dbg_assert (net);
+
+ our_net = cp_sta_mgr_get_our_avln (ctx);
+
+ *our_net = *net;
+
+ /* Initialise the sets of unassociated and associated stations. */
+ set_init (&net->associated_stas, cp_net_station_assoc_less);
+ set_init (&net->unassociated_stas, cp_net_station_unassoc_less);
+
+ cp_net_init (ctx, net, false);
+}
diff --git a/cesar/cp2/sta/mgr/sta_mgr.h b/cesar/cp2/sta/mgr/sta_mgr.h
index 66c80e1ca4..6a3af39bc4 100644
--- a/cesar/cp2/sta/mgr/sta_mgr.h
+++ b/cesar/cp2/sta/mgr/sta_mgr.h
@@ -148,4 +148,12 @@ cp_sta_mgr_get_num_discovered_net (cp_t *ctx);
bool
cp_sta_mgr_net_list_is_empty (cp_t *ctx);
+/**
+ * Merge the network to our net.
+ * \param ctx the module context.
+ * \param net the network to merge.
+ */
+void
+cp_sta_mgr_merge_net (cp_t *ctx, cp_net_t *net);
+
#endif /* cp_sta_mgr_h */
diff --git a/cesar/cp2/sta/mgr/test/src/sta_mgr_test.c b/cesar/cp2/sta/mgr/test/src/sta_mgr_test.c
index 86c3f3b4ca..84de91a257 100644
--- a/cesar/cp2/sta/mgr/test/src/sta_mgr_test.c
+++ b/cesar/cp2/sta/mgr/test/src/sta_mgr_test.c
@@ -217,6 +217,61 @@ test_case_sta_mgr_set_cco_as_our_own_sta (test_t test)
cp_sta_mgr_uninit (&cp);
}
+void
+test_case_sta_mgr_merge_net (test_t test)
+{
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+
+ cp_sta_mgr_init (&cp);
+
+ test_case_begin (test, "Merge nets");
+
+ net = cp_sta_mgr_get_our_avln (&cp);
+ test_begin (test, "Verify current net")
+ {
+ test_fail_if (net->present != true, "Net shall be present");
+ test_fail_if (set_empty (&net->associated_stas) != true,
+ "Set shall be empty");
+ test_fail_if (set_empty (&net->unassociated_stas) != true,
+ "Set shall be empty");
+ }
+ test_end;
+
+ net = cp_sta_mgr_add_avln (&cp, 0x1, 0x12345679);
+ sta = cp_net_sta_add (&cp, net, 0x0, 0x1);
+ slab_release (sta);
+
+ sta = cp_net_sta_add (&cp, net, 0x1, 0x2);
+ slab_release (sta);
+
+ cp_sta_mgr_merge_net (&cp, net);
+
+ test_begin (test, "Verify current net")
+ {
+ test_fail_if (net->present != false, "Net shall not be present");
+ test_fail_if (set_empty (&net->associated_stas) != true,
+ "Set shall be empty");
+ test_fail_if (set_empty (&net->unassociated_stas) != true,
+ "Set shall be empty");
+ }
+ test_end;
+
+ net = cp_sta_mgr_get_our_avln (&cp);
+ test_begin (test, "Verify our net")
+ {
+ test_fail_if (net->present != true , "Net shall be present");
+ test_fail_if (set_empty (&net->associated_stas) != false,
+ "Set shall be empty");
+ test_fail_if (set_empty (&net->unassociated_stas) != false,
+ "Set shall be empty");
+ }
+ test_end;
+
+ cp_sta_mgr_uninit (&cp);
+}
+
int
main (void)
{
@@ -226,6 +281,7 @@ main (void)
test_sta_mgr_init (test);
test_case_sta_mgr_uninit (test);
test_case_sta_mgr_set_cco_as_our_own_sta (test);
+ test_case_sta_mgr_merge_net (test);
test_result (test);
return test_nb_failed (test) == 0 ? 0 : 1;