summaryrefslogtreecommitdiff
path: root/cesar/cp/sta
diff options
context:
space:
mode:
authorlaranjeiro2008-10-03 14:54:00 +0000
committerlaranjeiro2008-10-03 14:54:00 +0000
commit48d08abfe63192542603223b1fbad2b0bb6f6f9e (patch)
treea87aaab795f237c0da151b2234b25013a9116d78 /cesar/cp/sta
parent093dbc33fe64292e144c552f35ab1980d5f976f6 (diff)
cp/sta/mgr: Update the station manager to handle an it's own AVLN only when the
station is associated to it. * The station slab cache is present in the station manager. * Station own data handle the nid and the snid of the station AVLN. * Added a pointer in sta_mgr to our AVLN. * Added missing APIs. * Fix the set pco status and pco glid in station own data. * Rewrote the unit test to cover all the possibilities. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@3155 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp/sta')
-rw-r--r--cesar/cp/sta/mgr/inc/net.h9
-rw-r--r--cesar/cp/sta/mgr/inc/net_list.h3
-rw-r--r--cesar/cp/sta/mgr/inc/sta_mgr.h8
-rw-r--r--cesar/cp/sta/mgr/inc/sta_own_data.h19
-rw-r--r--cesar/cp/sta/mgr/net.h38
-rw-r--r--cesar/cp/sta/mgr/net_list.h33
-rw-r--r--cesar/cp/sta/mgr/src/net.c199
-rw-r--r--cesar/cp/sta/mgr/src/net_list.c72
-rw-r--r--cesar/cp/sta/mgr/src/sta.c8
-rw-r--r--cesar/cp/sta/mgr/src/sta_mgr.c129
-rw-r--r--cesar/cp/sta/mgr/src/sta_own_data.c80
-rw-r--r--cesar/cp/sta/mgr/sta_mgr.h48
-rw-r--r--cesar/cp/sta/mgr/sta_own_data.h42
-rw-r--r--cesar/cp/sta/mgr/test/overide/cp/inc/context.h4
-rw-r--r--cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h23
-rw-r--r--cesar/cp/sta/mgr/test/src/cl_stub.c30
-rw-r--r--cesar/cp/sta/mgr/test/src/net_list_test.c108
-rw-r--r--cesar/cp/sta/mgr/test/src/net_test.c1643
-rw-r--r--cesar/cp/sta/mgr/test/src/sar_stub.c35
-rw-r--r--cesar/cp/sta/mgr/test/src/sta-test.c582
-rw-r--r--cesar/cp/sta/mgr/test/src/station_test.c2
21 files changed, 1383 insertions, 1732 deletions
diff --git a/cesar/cp/sta/mgr/inc/net.h b/cesar/cp/sta/mgr/inc/net.h
index 9af36b05e1..8acc1573b0 100644
--- a/cesar/cp/sta/mgr/inc/net.h
+++ b/cesar/cp/sta/mgr/inc/net.h
@@ -31,10 +31,6 @@ enum cp_mactotei_tags_t
struct cp_net_t
{
- /** Indicate if it is the station's AVLN. If not the commit to
- * dataplane will not have any effect. */
- bool station_avln;
-
/** AVLN's SNID. */
cp_snid_t snid;
@@ -88,11 +84,6 @@ struct cp_net_t
* The network mode.
*/
cp_net_network_mode_t network_mode;
-
- /**
- * Slab cache.
- */
- slab_cache_t *sta_slab_cache;
};
diff --git a/cesar/cp/sta/mgr/inc/net_list.h b/cesar/cp/sta/mgr/inc/net_list.h
index 5322fd0be3..5c4f388d9f 100644
--- a/cesar/cp/sta/mgr/inc/net_list.h
+++ b/cesar/cp/sta/mgr/inc/net_list.h
@@ -30,9 +30,6 @@ struct cp_net_list_t
* The possibles AVLN, index 0 corresponds to our AVLN.
*/
cp_net_t networks [8];
-
- /** Slab Cache. */
- slab_cache_t sta_slab_cache;
};
#endif /* cp_sta_mgr_inc_net_list_h */
diff --git a/cesar/cp/sta/mgr/inc/sta_mgr.h b/cesar/cp/sta/mgr/inc/sta_mgr.h
index 1fc3788fde..ac77ac4130 100644
--- a/cesar/cp/sta/mgr/inc/sta_mgr.h
+++ b/cesar/cp/sta/mgr/inc/sta_mgr.h
@@ -26,6 +26,14 @@ struct cp_sta_mgr_t
/** Stations own data. */
cp_sta_own_data_private_t sta_own_data;
+
+ /** Our AVLN.
+ * This pointer points to our AVLN when the station is associated, NULL
+ * in the other case. */
+ cp_net_t *our_avln;
+
+ /** Slab Cache. */
+ slab_cache_t sta_slab_cache;
};
diff --git a/cesar/cp/sta/mgr/inc/sta_own_data.h b/cesar/cp/sta/mgr/inc/sta_own_data.h
index c44aca1085..26972b0d17 100644
--- a/cesar/cp/sta/mgr/inc/sta_own_data.h
+++ b/cesar/cp/sta/mgr/inc/sta_own_data.h
@@ -76,17 +76,16 @@ struct cp_sta_own_data_private_t
* Indicate if the station is authenticated or not.
*/
bool authenticated;
-};
-/**
- * Set the HFID.
- *
- * \param hfid the HFID to set.
- * \param sta the station own data.
- * \param data the human identifier.
- */
-void
-cp_sta_own_data_set_hfid (const char *hfid, const char *data);
+ /**
+ * The Station NID.
+ */
+ cp_nid_t nid;
+ /**
+ * The station SNID.
+ */
+ cp_snid_t snid;
+};
#endif /* cp_sta_data_inc_sta_own_data_h */
diff --git a/cesar/cp/sta/mgr/net.h b/cesar/cp/sta/mgr/net.h
index 27e61a10c3..81c39bd9cf 100644
--- a/cesar/cp/sta/mgr/net.h
+++ b/cesar/cp/sta/mgr/net.h
@@ -45,12 +45,9 @@ BEGIN_DECLS
* Initialise the net.
* \param ctx the CP context.
* \param net the net to initialise.
- * \param station_avln Indicate if it corresponds to the station's avln.
- * \param cache the slab cache to allocate station memory space.
*/
void
-cp_net_init (cp_t *ctx, cp_net_t *net, bool station_avln,
- slab_cache_t *cache);
+cp_net_init (cp_t *ctx, cp_net_t *net);
/**
* Uninitialise the net.
@@ -72,49 +69,28 @@ void
cp_net_garbage_stations (cp_t *ctx, cp_net_t *net, u32 date_ms);
/**
- * Set the CCo or the PCo in the AVLN.
- * \param ctx the module context.
- * \param net the network module.
- * \param cp the control plane context (set only if cco is true).
- * \param tei the station's TEI.
- * \param cco inform if it is the CCo (true) or the PCo (false).
- */
-void
-cp_net_set_xco (cp_t *ctx, cp_net_t *net, cp_tei_t tei, bool cco);
-
-/**
* Set the CCo in the Network list.
* \param ctx the module context.
* \param net the network.
* \param tei The Station's TEI which is the CCo.
+ * \param status the station's CCo status.
*
* Shall update the data bases.
*/
-extern inline void
-cp_net_set_cco (cp_t *ctx, cp_net_t *net, cp_tei_t tei)
-{
- dbg_assert (ctx);
- dbg_assert (net);
- dbg_assert (tei);
- cp_net_set_xco (ctx, net, tei, true);
-}
+void
+cp_net_set_cco (cp_t *ctx, cp_net_t *net, cp_tei_t tei, bool status);
/**
* Set the PCo for this station.
* \param ctx the module context.
* \param net the network.
* \param tei PCo's tei.
+ * \param status the station's CCo status.
*
* Set the PCo for this network to communicate to another network.
*/
-extern inline void
-cp_net_set_pco (cp_t *ctx, cp_net_t *net, cp_tei_t tei)
-{
- dbg_assert (ctx);
- dbg_assert (net);
- dbg_assert (tei);
- cp_net_set_xco (ctx, net, tei, false);
-}
+void
+cp_net_set_pco (cp_t *ctx, cp_net_t *net, cp_tei_t tei, bool status);
/**
* Get the CCo of this AVLN.
diff --git a/cesar/cp/sta/mgr/net_list.h b/cesar/cp/sta/mgr/net_list.h
index 93d83a150a..a4c7c64139 100644
--- a/cesar/cp/sta/mgr/net_list.h
+++ b/cesar/cp/sta/mgr/net_list.h
@@ -20,6 +20,8 @@
/** Forward declaration. */
typedef struct cp_net_list_t cp_net_list_t;
+BEGIN_DECLS
+
/**
* Initialise the lists.
* \param ctx the module context.
@@ -80,35 +82,6 @@ cp_net_list_get_avln (cp_t *ctx, cp_net_list_t *network,
cp_snid_t snid, cp_nid_t nid);
/**
- * Return a new reference on our avln.
- * \param ctx the module context.
- * \param network the network list.
- * \return return the network.
- */
-cp_net_t *
-cp_net_list_get_our_avln (cp_t *ctx, cp_net_list_t *network);
-
-/**
- * Update our AVLN snid.
- * \param ctx the module context.
- * \param network the network list.
- * \param snid Our AVLN new SNID.
- */
-void
-cp_net_list_update_our_avln_snid (cp_t *ctx, cp_net_list_t *network,
- cp_snid_t snid);
-
-/**
- * Update our AVLN NID.
- * \param ctx the module context.
- * \param network the network list.
- * \param nid Our AVLN new NID.
- */
-void
-cp_net_list_update_our_avln_nid (cp_t *ctx, cp_net_list_t *network,
- cp_nid_t nid);
-
-/**
* Verify if the network list is empty and return true if it is.
* \param ctx the module context.
* \param network the network module.
@@ -155,4 +128,6 @@ cp_net_list_get_num_discovered_stas (cp_t *ctx, cp_net_list_t *network);
u8
cp_net_list_get_num_discovered_net (cp_t *ctx, cp_net_list_t *network);
+END_DECLS
+
#endif /* cp_sta_mgr_net_list_h */
diff --git a/cesar/cp/sta/mgr/src/net.c b/cesar/cp/sta/mgr/src/net.c
index 049df41fd4..c83da6277b 100644
--- a/cesar/cp/sta/mgr/src/net.c
+++ b/cesar/cp/sta/mgr/src/net.c
@@ -90,22 +90,16 @@ cp_net_station_unassoc_less (set_node_t *left, set_node_t *right)
* Initialise the net.
* \param ctx the CP context.
* \param net the net to initialise.
- * \param station_avln Indicate if it corresponds to the station's avln.
- * \param cache the slab cache to allocate station memory space.
*/
void
-cp_net_init (cp_t *ctx, cp_net_t *net, bool station_avln,
- slab_cache_t *cache)
+cp_net_init (cp_t *ctx, cp_net_t *net)
{
dbg_assert (net);
memset (net, 0, sizeof (cp_net_t));
- net->station_avln = station_avln;
- net->present = station_avln;
net->expiration_ms = MAC_SEC_TO_MS(CP_NET_EXPIRATION_DELAY_S);
net->network_mode = CP_NET_NM_CSMA_ONLY;
- net->sta_slab_cache = cache;
set_init (&net->associated_stas, cp_net_station_assoc_less);
set_init (&net->unassociated_stas, cp_net_station_unassoc_less);
@@ -120,31 +114,21 @@ void
cp_net_uninit (cp_t *ctx, cp_net_t *net)
{
cp_sta_t *sta;
- cp_net_t *our_avln;
+ cp_sta_t *sta_next;
+ uint i;
dbg_assert (net);
+ dbg_assert (ctx);
- while (!set_empty (&net->unassociated_stas))
- {
- sta = PARENT_OF (cp_sta_t, node,
- set_begin (&net->unassociated_stas));
-
- set_remove (&net->unassociated_stas, &sta->node);
- slab_release (sta);
- }
-
- our_avln = cp_sta_mgr_get_our_avln (ctx);
- while (!set_empty (&net->associated_stas))
+ for (i = 0; i < CP_NET_STA_NB; i++)
{
- sta = PARENT_OF (cp_sta_t, node,
- set_begin (&net->associated_stas));
-
- if (net == our_avln)
- dbg_check (mac_store_sta_remove (ctx->mac_store,
- cp_sta_get_tei (sta)));
-
- set_remove (&net->associated_stas, &sta->node);
- slab_release (sta);
+ sta = cp_net_get_first (ctx, net, i);
+ while (sta)
+ {
+ sta_next = cp_net_get_next (ctx, net, sta);
+ cp_net_sta_remove (ctx, net, sta);
+ sta = sta_next;
+ }
}
// Uninitialise the slabs cache.
@@ -203,7 +187,10 @@ cp_net_garbage_stations (cp_t *ctx, cp_net_t *net, u32 date_ms)
dbg_assert (net);
cp_net_garbage_station_list (ctx, net, date_ms, false /* Unassoc. */);
- cp_net_garbage_station_list (ctx, net, date_ms, true /* Assoc. */);
+
+ // Does not expire the station in our AVLN.
+ if (net != ctx->sta_mgr.our_avln)
+ cp_net_garbage_station_list (ctx, net, date_ms, true /* Assoc. */);
// Verify if the list not empty.
if (set_empty (&net->associated_stas)
@@ -215,53 +202,75 @@ cp_net_garbage_stations (cp_t *ctx, cp_net_t *net, u32 date_ms)
}
/**
- * Set the CCo or the PCo in the AVLN.
+ * set the CCo in the avln.
* \param ctx the module context.
- * \param cp the control plane context (set only if cco is true).
- * \param tei the station's TEI.
- * \param cco inform if it is the CCo (true) or the PCo (false).
+ * \param tei the station's tei.
+ * \param status inform if it is the cco.
*/
void
-cp_net_set_xco (cp_t *ctx, cp_net_t *net, cp_tei_t tei, bool cco)
+cp_net_set_cco (cp_t *ctx, cp_net_t *net, cp_tei_t tei, bool status)
{
- cp_sta_t *sta = NULL;
- bool not_my_sta = true;
-
dbg_assert (ctx);
dbg_assert (net);
- dbg_assert (tei);
- if (net->station_avln && cco)
+ // for any avln, reset the current cco.
+ if (net->cco)
+ {
+ ((cp_sta_private_t *)net->cco)->is_cco = false;
+ net->cco = NULL;
+ }
+
+ if (status)
{
- if (cp_sta_own_data_get_tei (ctx) == tei)
+ // if our net.
+ if ((ctx->sta_mgr.our_avln == net)
+ && (tei == cp_sta_own_data_get_tei (ctx))
+ && tei)
{
- cp_sta_own_data_set_cco_status (ctx, true);
- not_my_sta = false;
+ cp_sta_own_data_set_cco_status (ctx, status);
}
else
{
- cp_sta_own_data_set_cco_status (ctx, false);
+ cp_sta_t *sta;
+
+ dbg_assert (tei);
+ sta = cp_net_get_sta (ctx, net, tei);
+ ((cp_sta_private_t *)sta)->is_cco = true;
+ net->cco = sta;
+ slab_release (sta);
}
}
+}
- if (not_my_sta)
- sta = cp_net_get_sta (ctx, net, tei);
+/**
+ * set the PCo in the avln.
+ * \param ctx the module context.
+ * \param tei the station's tei.
+ * \param status inform if it is the cco.
+ */
+void
+cp_net_set_pco (cp_t *ctx, cp_net_t *net, cp_tei_t tei, bool status)
+{
+ dbg_assert (ctx);
+ dbg_assert (net);
- if (cco)
+ // for any avln, reset the current cco.
+ if (net->pco)
{
- net->cco = sta;
- if (not_my_sta)
- ((cp_sta_private_t *) sta)->is_cco = cco;
+ ((cp_sta_private_t *)net->pco)->pco_glid = 0x0;
+ net->pco = NULL;
}
- else
+
+ if (status)
{
- net->pco = sta;
- if (not_my_sta)
- ((cp_sta_private_t*)sta)->pco_glid = (0x80);
- }
+ cp_sta_t *sta;
- if (sta)
+ dbg_assert (tei);
+ sta = cp_net_get_sta (ctx, net, tei);
+ ((cp_sta_private_t *)sta)->pco_glid = 0x80;
+ net->pco = sta;
slab_release (sta);
+ }
}
/**
@@ -373,7 +382,7 @@ cp_net_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei, mac_t mac_address)
if (!sta)
{
- sta = (cp_sta_private_t *) cp_sta_init (net->sta_slab_cache);
+ sta = (cp_sta_private_t *) cp_sta_init (&ctx->sta_mgr.sta_slab_cache);
already_exists = false;
}
else
@@ -408,8 +417,14 @@ cp_net_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei, mac_t mac_address)
&((cp_sta_t *)sta)->node);
dbg_check (state);
- if (net == cp_sta_mgr_get_our_avln (ctx))
+ if (net == ctx->sta_mgr.our_avln)
+ {
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->cl);
+
mac_store_sta_add (ctx->mac_store, tei);
+ cp_net_commit_to_dataplane (ctx, net);
+ }
}
// Add a reference on the station.
@@ -444,20 +459,6 @@ cp_net_sta_remove_assoc (cp_t *ctx, cp_net_t *net, cp_tei_t tei)
// Verify the node and delete the node from the set.
if (sta)
{
- sta_t *sta_store;
- bool result;
-
- if (net == cp_sta_mgr_get_our_avln (ctx))
- {
- sta_store = mac_store_sta_get (ctx->mac_store, tei);
- if (sta_store)
- {
- result = mac_store_sta_remove (ctx->mac_store, tei);
- dbg_assert (result);
- blk_release (sta_store);
- }
- }
-
// The get STA returns another reference on the station which we
// want to release this reference is not useful, this release
// allows to remove the reference just added by the get STA.
@@ -479,6 +480,13 @@ cp_net_sta_remove_assoc (cp_t *ctx, cp_net_t *net, cp_tei_t tei)
set_remove (&net->associated_stas, &((cp_sta_t *)sta)->node);
net->num_stas --;
+
+ if (net == ctx->sta_mgr.our_avln)
+ {
+ sar_sta_remove (ctx->sar, tei);
+ cp_net_commit_to_dataplane (ctx, net);
+ }
+
//release the station.
slab_release (sta);
}
@@ -684,34 +692,39 @@ cp_net_commit_to_dataplane (cp_t *ctx, cp_net_t *net)
cl_mactotei_blk_t *mactotei;
dbg_assert (ctx);
+ dbg_assert (ctx->cl);
dbg_assert (net);
// If the net does not correspond to the AVLN, do not commit.
- if (!net->station_avln)
+ if (net != ctx->sta_mgr.our_avln)
return;
// Get the first station from the set.
if (set_empty (&net->associated_stas))
- return;
+ {
+ cl_mactotei_release_table (ctx->cl);
+ }
+ else
+ {
+ // There is at least a station in the network list.
+ mactotei = cl_mactotei_new ();
- // There is at least a station in the network list.
- mactotei = cl_mactotei_new ();
+ for (sta = cp_net_get_first (ctx, net, true /* Assoc. */ );
+ sta; sta = cp_net_get_next (ctx, net, sta))
+ {
+ cp_sta_private_t *sta_private = (cp_sta_private_t *) sta;
+ // Copy all the bridge table from the previous list.
+ cl_mactotei_copy_tei_and_tag (ctx->cl, mactotei, sta_private->tei,
+ CP_MACTOTEI_TAGS_BRIDGE);
+ // Add the current station.
+ cl_mactotei_addr_add (mactotei, sta_private->mac_address,
+ sta_private->tei, CP_MACTOTEI_TAGS_LIST);
- for (sta = cp_net_get_first (ctx, net, true /* Assoc. */ );
- sta; sta = cp_net_get_next (ctx, net, sta))
- {
- cp_sta_private_t *sta_private = (cp_sta_private_t *) sta;
- // Copy all the bridge table from the previous list.
- cl_mactotei_copy_tei_and_tag (ctx->cl, mactotei, sta_private->tei,
- CP_MACTOTEI_TAGS_BRIDGE);
- // Add the current station.
- cl_mactotei_addr_add (mactotei, sta_private->mac_address,
- sta_private->tei, CP_MACTOTEI_TAGS_LIST);
+ }
+ // Request the CL to use the table.
+ cl_mactotei_use_table (ctx->cl, mactotei);
}
-
- // Request the CL to use the table.
- cl_mactotei_use_table (ctx->cl, mactotei);
}
/**
@@ -1035,13 +1048,15 @@ cp_net_sta_set_authenticated (cp_t *ctx, cp_net_t *net,
dbg_assert (ctx);
dbg_assert (net);
dbg_assert (sta);
- dbg_assert (ctx->mac_store);
- dbg_assert (ctx->mac_config);
/* If our AVLN. */
- if (net->station_avln)
+ if (net == ctx->sta_mgr.our_avln)
{
sta_t *sta_store;
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->mac_config);
+ dbg_assert (cp_sta_get_tei (sta));
+
sta_store = mac_store_sta_get (ctx->mac_store, cp_sta_get_tei (sta));
dbg_check (sta_store);
@@ -1066,7 +1081,7 @@ cp_net_sta_get_authenticated (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
dbg_assert (ctx->mac_store);
/* If our AVLN. */
- if (net->station_avln)
+ if ((net == ctx->sta_mgr.our_avln) && (ctx->sta_mgr.our_avln))
{
sta_t *sta_store;
diff --git a/cesar/cp/sta/mgr/src/net_list.c b/cesar/cp/sta/mgr/src/net_list.c
index 1a3589bca3..4faadbc6b7 100644
--- a/cesar/cp/sta/mgr/src/net_list.c
+++ b/cesar/cp/sta/mgr/src/net_list.c
@@ -20,6 +20,7 @@
#include "cp/sta/mgr/inc/net_list.h"
#include "cp/sta/mgr/inc/sta.h"
+#include "cp/inc/context.h"
/**
* Initialise the lists.
* \param ctx the module context.
@@ -33,16 +34,9 @@ cp_net_list_init (cp_t *ctx, cp_net_list_t *network)
dbg_assert (ctx);
dbg_assert (network);
- slab_cache_init (&network->sta_slab_cache,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
-
-
for (i = 0; i < CP_NET_LIST_NB_AVLN; i++)
{
- cp_net_init (ctx, &network->networks[i], i == 0 ? true : false,
- &network->sta_slab_cache);
+ cp_net_init (ctx, &network->networks[i]);
}
}
@@ -104,7 +98,7 @@ cp_net_list_add_avln (cp_t *ctx, cp_net_list_t *network,
if (!net)
{
- for (i = 1; i < CP_NET_LIST_NB_AVLN; i++)
+ for (i = 0; i < CP_NET_LIST_NB_AVLN; i++)
{
if (network->networks[i].present == false)
{
@@ -119,9 +113,12 @@ cp_net_list_add_avln (cp_t *ctx, cp_net_list_t *network,
return NULL;
// Insert it as present.
- net->present = true;
- net->snid = snid;
- net->nid = nid;
+ if (!net->present)
+ {
+ net->present = true;
+ net->snid = snid;
+ net->nid = nid;
+ }
net->expiration_ms = MAC_SEC_TO_MS(CP_NET_EXPIRATION_DELAY_S);
return net;
@@ -186,50 +183,6 @@ cp_net_list_get_avln (cp_t *ctx, cp_net_list_t *network,
}
/**
- * Return a new reference on our avln.
- * \param ctx the module context.
- * \param network the network list.
- * \return return the network.
- */
-cp_net_t *
-cp_net_list_get_our_avln (cp_t *ctx, cp_net_list_t *network)
-{
- dbg_assert (network);
-
- return &network->networks[0];
-}
-
-/**
- * Update our AVLN snid.
- * \param ctx the module context.
- * \param network the network list.
- * \param snid Our AVLN new SNID.
- */
-void
-cp_net_list_update_our_avln_snid (cp_t *ctx, cp_net_list_t *network,
- cp_snid_t snid)
-{
- dbg_assert (ctx);
-
- network->networks[0].snid = snid;
-}
-
-/**
- * Update our AVLN NID.
- * \param ctx the module context.
- * \param network the network list.
- * \param nid Our AVLN new NID.
- */
-void
-cp_net_list_update_our_avln_nid (cp_t *ctx, cp_net_list_t *network,
- cp_nid_t nid)
-{
- dbg_assert (network);
-
- network->networks[0].nid = nid;
-}
-
-/**
* Verify if the network list is empty and return true if it is.
* \param ctx the module context.
* \param network the network module.
@@ -241,7 +194,7 @@ cp_net_list_is_empty (cp_t *ctx, cp_net_list_t *network)
uint i;
dbg_assert (ctx);
- for (i = 1; i < CP_NET_LIST_NB_AVLN; i++)
+ for (i = 0; i < CP_NET_LIST_NB_AVLN; i++)
{
if (network->networks[i].present == true)
return false;
@@ -336,9 +289,10 @@ cp_net_list_get_num_discovered_net (cp_t *ctx, cp_net_list_t *network)
dbg_assert (network);
- for (i = 1; i < CP_NET_LIST_NB_AVLN; i++)
+ for (i = 0; i < CP_NET_LIST_NB_AVLN; i++)
{
- if (network->networks[i].present)
+ if ((ctx->sta_mgr.our_avln != &network->networks[i])
+ && network->networks[i].present)
num ++;
}
diff --git a/cesar/cp/sta/mgr/src/sta.c b/cesar/cp/sta/mgr/src/sta.c
index 1adbde3ce9..74af4794e6 100644
--- a/cesar/cp/sta/mgr/src/sta.c
+++ b/cesar/cp/sta/mgr/src/sta.c
@@ -120,7 +120,7 @@ cp_sta_set_pco_status (cp_sta_t *ctx, bool pco)
{
dbg_assert (ctx);
- ((cp_sta_private_t *)ctx)->pco_glid = (pco << 7);
+ ((cp_sta_private_t *)ctx)->pco_glid |= (pco << 7);
}
/**
@@ -147,7 +147,7 @@ cp_sta_get_pco_glid (cp_sta_t *ctx)
{
dbg_assert (ctx);
- return ((cp_sta_private_t *)ctx)->pco_glid;
+ return (((cp_sta_private_t *)ctx)->pco_glid & ~MAC_GLID_MIN);
}
/**
@@ -159,8 +159,8 @@ void
cp_sta_set_pco_glid (cp_sta_t *ctx, u8 glid)
{
dbg_assert (ctx);
- dbg_assert (glid >> 7);
+ dbg_assert (glid < MAC_GLID_MIN);
- ((cp_sta_private_t *)ctx)->pco_glid = glid;
+ ((cp_sta_private_t *)ctx)->pco_glid |= glid;
}
diff --git a/cesar/cp/sta/mgr/src/sta_mgr.c b/cesar/cp/sta/mgr/src/sta_mgr.c
index 57d7a69719..6fb8c8c879 100644
--- a/cesar/cp/sta/mgr/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/src/sta_mgr.c
@@ -20,9 +20,12 @@
#include "cp/sta/mgr/net_list.h"
#include "cp/sta/mgr/sta_own_data.h"
#include "cp/sta/core/core.h"
+#include "cl/cl_mactotei.h"
+#include "mac/sar/sar.h"
#include "cp/inc/context.h"
+#include "cp/sta/mgr/inc/sta.h"
#include "cp/sta/mgr/inc/sta_mgr.h"
#include "cp/sta/mgr/inc/net_list.h"
#include "cp/sta/mgr/inc/sta_own_data.h"
@@ -36,11 +39,19 @@ cp_sta_mgr_init (cp_t *ctx)
{
dbg_assert (ctx);
+ memset (&ctx->sta_mgr, 0, sizeof (cp_sta_mgr_t));
+
// Initialise the network list.
cp_net_list_init (ctx, &ctx->sta_mgr.network_list);
// Initialise the station own data.
cp_sta_own_data_init (ctx);
+
+ // Initialise the slab cache.
+ slab_cache_init (&ctx->sta_mgr.sta_slab_cache,
+ "Station cache",
+ sizeof (cp_sta_private_t),
+ (slab_object_destructor_t) cp_sta_uninit);
}
/**
@@ -69,17 +80,13 @@ cp_sta_mgr_uninit (cp_t *ctx)
cp_net_t *
cp_sta_mgr_add_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
{
- cp_net_t *our_sta_net;
-
dbg_assert (ctx);
dbg_assert (nid);
- // Check SNID conflict.
- our_sta_net = cp_net_list_get_our_avln (ctx, &ctx->sta_mgr.network_list);
-
// Verify SNID collisions.
- if ((cp_net_get_nid (ctx, our_sta_net) != nid)
- && (cp_net_get_snid (ctx, our_sta_net) == snid))
+ if (ctx->sta_mgr.our_avln
+ && (cp_net_get_nid (ctx, ctx->sta_mgr.our_avln) != nid)
+ && (cp_net_get_snid (ctx, ctx->sta_mgr.our_avln) == snid))
{
cp_fsm_event_t *event;
event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_snid_conflict);
@@ -127,21 +134,6 @@ cp_sta_mgr_get_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
}
/**
- * Get our AVLN network.
- * \param ctx the module context.
- * \return Return a reference on the station AVLN. DO not release the
- * reference.
- *
- */
-cp_net_t *
-cp_sta_mgr_get_our_avln (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- return cp_net_list_get_our_avln (ctx, &ctx->sta_mgr.network_list);
-}
-
-/**
* Lookup and return all the snids already in use in the different AVLN.
* \param ctx the module context.
* \return A bit field u16 corresponding to the SNID in use.
@@ -171,34 +163,6 @@ cp_sta_mgr_garbage (cp_t *ctx)
}
/**
- * Update the our avln's snid.
- * \param ctx the module context.
- * \param snid Our AVLN new SNID.
- */
-void
-cp_sta_mgr_update_our_avln_snid (cp_t *ctx, cp_snid_t snid)
-{
- dbg_assert (ctx);
-
- cp_net_list_update_our_avln_snid (ctx, &ctx->sta_mgr.network_list, snid);
-}
-
-/**
- * Update the AVLN's NID.
- * \param ctx the module context.
- * \param nid The AVLN's NID.
- *
- */
-void
-cp_sta_mgr_update_our_avln_nid (cp_t *ctx, cp_nid_t nid)
-{
- dbg_assert (ctx);
- dbg_assert (nid);
-
- cp_net_list_update_our_avln_nid (ctx, &ctx->sta_mgr.network_list, nid);
-}
-
-/**
* Returns a reference on our own station data.
* \param ctx the module context.
* \return A reference on the sta own data. Do not release It it not a block.
@@ -265,36 +229,57 @@ 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.
+ * Get our AVLN.
+ * \param ctx the CP context.
+ * \return Our AVLN.
+ *
+ * \warn this function assert if the station is not associated.
*/
-void
-cp_sta_mgr_merge_net (cp_t *ctx, cp_net_t *net)
+cp_net_t *
+cp_sta_mgr_get_our_avln (cp_t *ctx)
{
- cp_net_t *our_net;
- cp_sta_t *sta;
+ dbg_assert (ctx);
+ dbg_assert (ctx->sta_mgr.our_avln);
+
+ return ctx->sta_mgr.our_avln;
+}
+/**
+ * Set our AVLN.
+ * \param ctx the CP context.
+ * \param net the net to add as our net.
+ */
+void
+cp_sta_mgr_set_our_avln (cp_t *ctx, cp_net_t *net)
+{
dbg_assert (ctx);
dbg_assert (net);
+ dbg_assert (ctx->cl);
+ dbg_assert (ctx->sar);
- our_net = cp_sta_mgr_get_our_avln (ctx);
-
- if (net != our_net)
+ /* If our AVLN was already setted, remove the station from the store. */
+ if (ctx->sta_mgr.our_avln)
{
- *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);
- net->present = false;
+ cp_sta_t *sta;
+ /* Release the CL's mac to tei table. */
+ cl_mactotei_release_table (ctx->cl);
+
+ /* Release the station from the mac store. */
+ sta = cp_net_get_first (ctx, ctx->sta_mgr.our_avln, CP_NET_STA_ASSOC);
+ while (sta)
+ {
+ sar_sta_remove (ctx->sar, cp_sta_get_tei (sta));
+ sta = cp_net_get_next (ctx, net, sta);
+ }
+ slab_release (sta);
}
- sta = cp_net_get_first (ctx, our_net, CP_NET_STA_ASSOC);
- while (sta)
- {
- mac_store_sta_add (ctx->mac_store, cp_sta_get_tei (sta));
- sta = cp_net_get_next (ctx, net, sta);
- }
+ ctx->sta_mgr.our_avln = net;
+ // Store the nid and the snid to the station own data.
+ cp_sta_own_data_set_nid (ctx, cp_net_get_nid (ctx, net));
+ cp_sta_own_data_set_snid (ctx, cp_net_get_snid (ctx, net));
+
+ /* Commit the new list. */
+ cp_net_commit_to_dataplane (ctx, net);
}
diff --git a/cesar/cp/sta/mgr/src/sta_own_data.c b/cesar/cp/sta/mgr/src/sta_own_data.c
index 010a4a2ed1..f4a1998bbc 100644
--- a/cesar/cp/sta/mgr/src/sta_own_data.c
+++ b/cesar/cp/sta/mgr/src/sta_own_data.c
@@ -94,6 +94,7 @@ cp_sta_own_data_set_mac_address (cp_t *ctx, mac_t mac_addr)
{
dbg_assert (ctx);
dbg_assert (mac_addr);
+ dbg_assert (ctx->mac_config);
// Add the mac address to the sta own data.
ctx->sta_mgr.sta_own_data.mac_addr = mac_addr;
@@ -276,7 +277,7 @@ cp_sta_own_data_get_was_cco (cp_t *ctx)
* \param hfid the HFID to set.
* \param data the human identifier.
*/
-void
+static void
cp_sta_own_data_set_hfid (const char *hfid, const char *data)
{
dbg_assert (data);
@@ -342,9 +343,9 @@ void
cp_sta_own_data_set_pco_glid (cp_t *ctx, u8 glid)
{
dbg_assert (ctx);
- dbg_assert (glid >> 7);
+ dbg_assert (glid < MAC_GLID_MIN);
- ctx->sta_mgr.sta_own_data.pco_glid = glid;
+ ctx->sta_mgr.sta_own_data.pco_glid |= glid;
}
/**
@@ -357,7 +358,7 @@ cp_sta_own_data_get_pco_glid (cp_t *ctx)
{
dbg_assert (ctx);
- return ctx->sta_mgr.sta_own_data.pco_glid;
+ return (ctx->sta_mgr.sta_own_data.pco_glid & ~MAC_GLID_MIN);
}
/**
@@ -385,7 +386,7 @@ cp_sta_own_data_set_pco_status (cp_t *ctx, bool pco)
{
dbg_assert (ctx);
- ctx->sta_mgr.sta_own_data.pco_glid = (pco << 7);
+ ctx->sta_mgr.sta_own_data.pco_glid |= (pco << 7);
}
/**
@@ -395,9 +396,21 @@ cp_sta_own_data_set_pco_status (cp_t *ctx, bool pco)
void
cp_sta_own_data_set_cco_status (cp_t *ctx, bool cco)
{
+ cp_sta_t *sta;
+ cp_net_t *net;
dbg_assert (ctx);
+ dbg_assert (ctx->sta_mgr.sta_own_data.tei != MAC_TEI_UNASSOCIATED);
ctx->sta_mgr.sta_own_data.is_cco = cco;
+
+ // If the net has already a CCo.
+ net = cp_sta_mgr_get_our_avln (ctx);
+ sta = cp_net_get_cco (ctx, net);
+ if (sta)
+ {
+ cp_net_set_cco (ctx, net, MAC_TEI_UNASSOCIATED, false);
+ slab_release (sta);
+ }
}
@@ -444,3 +457,60 @@ cp_sta_own_data_get_authenticated_status (cp_t *ctx)
return ctx->sta_mgr.sta_own_data.authenticated;
}
+
+/**
+ * Set the Station NID.
+ * \param ctx the Control plane context.
+ * \param nid the station NID.
+ */
+void
+cp_sta_own_data_set_nid (cp_t *ctx, cp_nid_t nid)
+{
+ dbg_assert (ctx);
+ dbg_assert (nid);
+
+ ctx->sta_mgr.sta_own_data.nid = nid;
+}
+
+/**
+ * Get the Station NID.
+ * \param ctx the Control plane context.
+ * \param nid the station NID.
+ */
+cp_nid_t
+cp_sta_own_data_get_nid (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->sta_mgr.sta_own_data.nid;
+}
+
+/**
+ * Set the Station SNID.
+ * \param ctx the Control plane context.
+ * \param snid the station SNID.
+ */
+void
+cp_sta_own_data_set_snid (cp_t *ctx, cp_snid_t snid)
+{
+ dbg_assert (ctx);
+
+ ctx->sta_mgr.sta_own_data.snid = snid;
+
+ if (ctx->sta_mgr.our_avln)
+ ctx->sta_mgr.our_avln->snid = snid;
+}
+
+/**
+ * Get the Station SNID.
+ * \param ctx the Control plane context.
+ * \return the station SNID.
+ */
+cp_snid_t
+cp_sta_own_data_get_snid (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->sta_mgr.sta_own_data.snid;
+}
+
diff --git a/cesar/cp/sta/mgr/sta_mgr.h b/cesar/cp/sta/mgr/sta_mgr.h
index 74e108e4e2..bc1cf4b809 100644
--- a/cesar/cp/sta/mgr/sta_mgr.h
+++ b/cesar/cp/sta/mgr/sta_mgr.h
@@ -20,6 +20,8 @@
/* Forward declaration. */
typedef struct cp_sta_mgr_t cp_sta_mgr_t;
+BEGIN_DECLS
+
/**
* Add a AVLN to the manager list.
* \param ctx the module context.
@@ -50,15 +52,6 @@ cp_net_t *
cp_sta_mgr_get_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid);
/**
- * Get our AVLN network.
- * \param ctx the module context.
- * \return \todo fill this
- *
- */
-cp_net_t *
-cp_sta_mgr_get_our_avln (cp_t *ctx);
-
-/**
* Initialise the sta manager.
* \param ctx the module context.
*/
@@ -92,23 +85,6 @@ void
cp_sta_mgr_garbage (cp_t *ctx);
/**
- * Update the our avln's snid.
- * \param ctx the module context.
- * \param snid Our AVLN new SNID.
- */
-void
-cp_sta_mgr_update_our_avln_snid (cp_t *ctx, cp_snid_t snid);
-
-/**
- * Update the AVLN's NID.
- * \param ctx the module context.
- * \param nid The AVLN's NID.
- *
- */
-void
-cp_sta_mgr_update_our_avln_nid (cp_t *ctx, cp_nid_t nid);
-
-/**
* Returns a reference on our own station data.
* \param ctx the module context.
* \return A reference on the sta own data. Do not release It it not a block.
@@ -149,11 +125,23 @@ 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.
+ * Get our AVLN.
+ * \param ctx the CP context.
+ * \return Our AVLN.
+ *
+ * \warn this function assert if the station is not associated.
+ */
+cp_net_t *
+cp_sta_mgr_get_our_avln (cp_t *ctx);
+
+/**
+ * Set our AVLN.
+ * \param ctx the CP context.
+ * \param net the net to add as our net.
*/
void
-cp_sta_mgr_merge_net (cp_t *ctx, cp_net_t *net);
+cp_sta_mgr_set_our_avln (cp_t *ctx, cp_net_t *net);
+
+END_DECLS
#endif /* cp_sta_mgr_h */
diff --git a/cesar/cp/sta/mgr/sta_own_data.h b/cesar/cp/sta/mgr/sta_own_data.h
index 93e626c04b..72b51048fb 100644
--- a/cesar/cp/sta/mgr/sta_own_data.h
+++ b/cesar/cp/sta/mgr/sta_own_data.h
@@ -30,11 +30,6 @@ typedef struct cp_sta_own_data_private_t cp_sta_own_data_private_t;
struct cp_sta_own_data_t
{
/**
- * Date to change the NEK in eCos ticks.
- */
- uint nek_change_rtc;
-
- /**
* Indicate if the station was CCo preferred.
*/
bool cco_prefered;
@@ -70,11 +65,6 @@ struct cp_sta_own_data_t
cp_nid_t nid_track;
/**
- * The current EKS.
- */
- u8 eks_current;
-
- /**
* The PCo to discuss with.
*/
cp_sta_t * pco;
@@ -322,6 +312,38 @@ cp_sta_own_data_set_authenticated_status (cp_t *ctx, bool authenticated);
bool
cp_sta_own_data_get_authenticated_status (cp_t *ctx);
+/**
+ * Update the Station NID.
+ * \param ctx the Control plane context.
+ * \param nid the station NID.
+ */
+void
+cp_sta_own_data_set_nid (cp_t *ctx, cp_nid_t nid);
+
+/**
+ * Get the Station NID.
+ * \param ctx the Control plane context.
+ * \param nid the station NID.
+ */
+cp_nid_t
+cp_sta_own_data_get_nid (cp_t *ctx);
+
+/**
+ * Update the Station SNID.
+ * \param ctx the Control plane context.
+ * \param nid the station NID.
+ */
+void
+cp_sta_own_data_set_snid (cp_t *ctx, cp_snid_t snid);
+
+/**
+ * Get the Station SNID.
+ * \param ctx the Control plane context.
+ * \return the station SNID.
+ */
+cp_snid_t
+cp_sta_own_data_get_snid (cp_t *ctx);
+
END_DECLS
#endif /* cp_sta_data_sta_own_data_h */
diff --git a/cesar/cp/sta/mgr/test/overide/cp/inc/context.h b/cesar/cp/sta/mgr/test/overide/cp/inc/context.h
index 38d5597dff..69afd67322 100644
--- a/cesar/cp/sta/mgr/test/overide/cp/inc/context.h
+++ b/cesar/cp/sta/mgr/test/overide/cp/inc/context.h
@@ -19,6 +19,7 @@
#include "cp/sta/mgr/sta_mgr.h"
#include "cl/cl.h"
#include "mac/common/config.h"
+#include "mac/sar/sar.h"
/* Private interfaces. */
#include "cp/sta/mgr/inc/sta_mgr.h"
@@ -36,6 +37,9 @@ struct cp_t
/** Mac store. */
mac_store_t *mac_store;
+
+ /** SAR layer context pointer. */
+ sar_t *sar;
};
#endif /* cp_inc_cp_h */
diff --git a/cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h b/cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h
new file mode 100644
index 0000000000..9e7c6f07ca
--- /dev/null
+++ b/cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h
@@ -0,0 +1,23 @@
+#ifndef overide_mac_sar_inc_context_h
+#define overide_mac_sar_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/mac/sar/inc/context.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+struct sar_t
+{
+ mac_store_t *mac_store;
+};
+
+#endif /* overide_mac_sar_inc_context_h */
diff --git a/cesar/cp/sta/mgr/test/src/cl_stub.c b/cesar/cp/sta/mgr/test/src/cl_stub.c
index e9ff2f1556..88f39f170d 100644
--- a/cesar/cp/sta/mgr/test/src/cl_stub.c
+++ b/cesar/cp/sta/mgr/test/src/cl_stub.c
@@ -26,11 +26,7 @@
cl_mactotei_blk_t *
cl_mactotei_new (void)
{
- u8 *my_data;
-
- my_data = blk_alloc ();
- my_data[0] = 0;
- return (cl_mactotei_blk_t *) my_data;
+ return NULL;
}
/**
@@ -44,24 +40,6 @@ cl_mactotei_new (void)
void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr,
uint tei, uint tag)
{
- bitstream_t bitstream;
- u8 *data;
- uint pos;
-
- dbg_assert (table);
- dbg_assert (tei);
-
- data = (u8 *) table;
- pos = 8 * data[0] + 1;
-
- bitstream_init (&bitstream, &data[pos],
- 8, BITSTREAM_WRITE);
- bitstream_access (&bitstream, &tag, 8);
- bitstream_access (&bitstream, &tei, 8);
- bitstream_access (&bitstream, &mac_addr, 48);
- bitstream_finalise (&bitstream);
-
- data[0] ++;
}
/**
@@ -100,12 +78,6 @@ cl_mactotei_copy_tei_and_tag (cl_t *ctx,
void
cl_mactotei_use_table (cl_t *ctx, cl_mactotei_blk_t *table)
{
- dbg_assert (ctx);
- dbg_assert (table);
-
- memcpy ((u8 *) ctx, (u8 *)table, 512) ;
-
- blk_release (table);
}
/**
diff --git a/cesar/cp/sta/mgr/test/src/net_list_test.c b/cesar/cp/sta/mgr/test/src/net_list_test.c
index 75a30fbab1..154f7d52af 100644
--- a/cesar/cp/sta/mgr/test/src/net_list_test.c
+++ b/cesar/cp/sta/mgr/test/src/net_list_test.c
@@ -58,10 +58,8 @@ test_case_network_init (test_t test)
for (i = 0; i < CP_NET_LIST_NB_AVLN; i++)
{
net = &network.networks[i];
- test_fail_if (net->present != (i == 0 ? true : false),
+ test_fail_if (net->present != false,
"Present flag wrong.");
- test_fail_if (net->station_avln != (i == 0 ? true : false),
- "Station AVLN flag false");
test_fail_if (net->snid != 0, "Wrong SNID");
test_fail_if (net->nid != 0, "Wrong NID");
test_fail_if (net->cco != 0, "Wrong CCo");
@@ -109,37 +107,30 @@ test_case_network_uninit (test_t test)
{
cp_t cp;
uint i;
- cp_net_list_t network;
cp_net_t *net;
cp_sta_t *sta;
test_case_begin (test, "Initialise");
- cp_net_list_init (&cp, &network);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
// Add station to the station AVLN.
- net = cp_net_list_get_our_avln (&cp, &network);
- net->snid = 1;
- net->nid = 1;
-
sta = cp_net_sta_add (&cp, net, 1 , 11);
- cp_net_set_cco (&cp, net, 1);
+ cp_net_set_cco (&cp, net, 1, true);
slab_release (sta);
sta = cp_net_sta_add (&cp, net, 2 , 12);
- cp_net_set_pco (&cp, net, 2);
+ cp_net_set_pco (&cp, net, 2, true);
slab_release (sta);
// Add station to the next AVLN.
- net = &network.networks[1];
- net->snid = 2;
- net->nid = 2;
- net->present = true;
+ net = cp_sta_mgr_add_avln (&cp, 2, 2);
sta = cp_net_sta_add (&cp, net, 1, 21);
- cp_net_set_cco (&cp, net, 1);
+ cp_net_set_cco (&cp, net, 1, true);
slab_release (sta);
sta = cp_net_sta_add (&cp, net, 2, 22);
- cp_net_set_pco (&cp, net, 2);
+ cp_net_set_pco (&cp, net, 2, true);
slab_release (sta);
sta = cp_net_sta_add (&cp, net, 3, 23);
slab_release (sta);
@@ -147,13 +138,10 @@ test_case_network_uninit (test_t test)
slab_release (sta);
// Add station to the next AVLN.
- net = &network.networks[2];
- net->snid = 3;
- net->nid = 3;
- net->present = true;
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
sta = cp_net_sta_add (&cp, net, 1, 31);
- cp_net_set_cco (&cp, net, 1);
+ cp_net_set_cco (&cp, net, 1, true);
slab_release (sta);
sta = cp_net_sta_add (&cp, net, 2, 32);
slab_release (sta);
@@ -164,34 +152,38 @@ test_case_network_uninit (test_t test)
test_begin (test, "verify the environment")
{
- test_fail_if (network.networks[0].cco == NULL, "Wrong CCo value");
- test_fail_if (cp_sta_get_cco_status(network.networks[0].cco) != true,
+ net = cp_sta_mgr_get_avln (&cp, 1, 1);
+ test_fail_if (net->cco == NULL, "Wrong CCo value");
+ test_fail_if (cp_sta_get_cco_status(net->cco) != true,
"Station CCo flag not setted");
- test_fail_if (network.networks[0].pco == NULL, "Wrong PCo value");
- test_fail_if (cp_sta_get_pco_status(network.networks[0].pco) != true,
+ test_fail_if (net->pco == NULL, "Wrong PCo value");
+ test_fail_if (cp_sta_get_pco_status(net->pco) != true,
"Station PCo flag not setted");
- test_fail_if (network.networks[1].cco == NULL, "Wrong CCo value");
- test_fail_if (cp_sta_get_cco_status(network.networks[1].cco) != true,
+
+ net = cp_sta_mgr_get_avln (&cp, 2, 2);
+ test_fail_if (net->cco == NULL, "Wrong CCo value");
+ test_fail_if (cp_sta_get_cco_status(net->cco) != true,
"Station CCo flag not setted");
- test_fail_if (network.networks[1].pco == NULL, "Wrong PCo value");
- test_fail_if (cp_sta_get_pco_status(network.networks[1].pco) != true,
+ test_fail_if (net->pco == NULL, "Wrong PCo value");
+ test_fail_if (cp_sta_get_pco_status(net->pco) != true,
"Station PCo flag not setted");
- test_fail_if (network.networks[2].cco == NULL, "Wrong CCo value");
- test_fail_if (cp_sta_get_cco_status(network.networks[2].cco) != true,
+ net = cp_sta_mgr_get_avln (&cp, 3, 3);
+ test_fail_if (net->cco == NULL, "Wrong CCo value");
+ test_fail_if (cp_sta_get_cco_status(net->cco) != true,
"Station CCo flag not setted");
}
test_end;
- cp_net_list_uninit (&cp, &network);
+ cp_sta_mgr_uninit (&cp);
test_begin (test, "verify")
{
for (i = 0; i < CP_NET_LIST_NB_AVLN; i++)
{
- test_fail_if (network.networks[i].cco != NULL, "Wrong CCo value");
- test_fail_if (network.networks[i].pco != NULL, "Wrong CCo value");
+ test_fail_if (cp.sta_mgr.network_list.networks[i].cco != NULL, "Wrong CCo value");
+ test_fail_if (cp.sta_mgr.network_list.networks[i].pco != NULL, "Wrong CCo value");
}
}
test_end;
@@ -237,7 +229,6 @@ test_case_network_add_avln (test_t test)
test_fail_if (net->snid != 1, "Wrong SNID");
test_fail_if (net->nid != 1, "Wrong NID");
test_fail_if (net->present != true, "Wrong presence state flag");
- test_fail_if (net->station_avln != false, "Wong stations AVLN flag");
test_fail_if (net->cco != NULL, "CCo should not exists yet");
test_fail_if (net->pco != NULL, "PCo should not exists yet");
test_fail_if (set_empty (&net->associated_stas) != true,
@@ -301,32 +292,6 @@ test_case_network_remove_avln (test_t test)
test_end;
}
-/** Update Station's SNID
- *
- * \param test the test object.
- *
- * Modify the AVLN's SNID.
- */
-void
-test_case_network_update_snid (test_t test)
-{
- cp_t cp;
- cp_net_list_t network;
-
- cp_net_list_init (&cp, &network);
-
- network.networks[0].snid = 1;
-
- test_case_begin (test, "updating the station's AVLN SNID");
-
- cp_net_list_update_our_avln_snid (&cp, &network, 2);
- test_begin (test, "verifying data")
- {
- test_fail_if (network.networks[0].snid != 2, "Wrong SNID value");
- }
- test_end;
-}
-
/** Is empty
*
* \param test the test object.
@@ -334,7 +299,7 @@ test_case_network_update_snid (test_t test)
* Verify the presence of others AVLN on the medium.
*/
void
-test_case_network_is_empyt (test_t test)
+test_case_network_is_empty (test_t test)
{
cp_t cp;
cp_net_list_t network;
@@ -379,7 +344,7 @@ test_case_network_snid_present (test_t test)
test_case_begin (test, "Getting present SNID");
- cp_net_list_update_our_avln_snid (&cp, &network, 1);
+ cp_net_list_add_avln (&cp, &network, 1, 1);
cp_net_list_add_avln (&cp, &network, 5, 5);
cp_net_list_add_avln (&cp, &network, 10, 10);
@@ -411,26 +376,26 @@ void
test_case_network_slot_usage (test_t test)
{
cp_t cp;
- cp_net_list_t network;
cp_net_t *net;
- cp_net_list_init (&cp, &network);
+ cp_sta_mgr_init (&cp);
test_case_begin (test, "Getting the slot usage");
// Add the first AVLN.
- net = cp_net_list_get_our_avln (&cp, &network);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
cp_net_set_slot_id_and_usage (&cp, net, 4, 5);
- net = cp_net_list_add_avln (&cp, &network, 0x2, 0x2);
+ net = cp_sta_mgr_add_avln (&cp, 2, 2);
cp_net_set_slot_id_and_usage (&cp, net, 7, 7);
- net = cp_net_list_add_avln (&cp, &network, 0x3, 0x3);
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
cp_net_set_slot_id_and_usage (&cp, net, 2, 3);
test_begin (test, "Verify")
{
- test_fail_if (cp_net_list_get_slot_usage (&cp, &network) != 0x94,
+ test_fail_if (cp_net_list_get_slot_usage (&cp,
+ &cp.sta_mgr.network_list) != 0x94,
"Wrong Slot usage bit fields");
}
test_end;
@@ -477,8 +442,7 @@ main (void)
test_case_network_uninit (test);
test_case_network_add_avln (test);
test_case_network_remove_avln (test);
- test_case_network_update_snid (test);
- test_case_network_is_empyt (test);
+ test_case_network_is_empty (test);
test_case_network_snid_present (test);
test_case_network_slot_usage (test);
test_case_network_add_existing_avln (test);
diff --git a/cesar/cp/sta/mgr/test/src/net_test.c b/cesar/cp/sta/mgr/test/src/net_test.c
index efe05dc0f6..4ba43b2b87 100644
--- a/cesar/cp/sta/mgr/test/src/net_test.c
+++ b/cesar/cp/sta/mgr/test/src/net_test.c
@@ -12,1292 +12,900 @@
*
*/
#include "common/std.h"
-#include "string.h"
-
#include "lib/test.h"
-#include "lib/blk.h"
-#include "lib/bitstream.h"
+#include "string.h"
-#include "mac/common/ntb.h"
-#include "mac/common/timings.h"
+#include "cp/cp.h"
+#include "cp/sta/mgr/sta_mgr.h"
-#include "cp/sta/mgr/net.h"
+#include "cp/inc/context.h"
#include "cp/sta/mgr/inc/net.h"
-#include "cp/sta/mgr/inc/sta.h"
-#include "cp/inc/context.h"
+#include "cl/inc/context.h"
+#include "mac/sar/inc/context.h"
-/**
- * Add an unassociated station to the net.
- *
- * \param test the test object result.
- *
- * Add some station to the network and verify the data.
- */
void
-test_case_network_add_unassoc_stations (test_t test)
+test_case_cp_net_init (test_t test)
{
- cp_t cp;
+ cp_t ctx;
cp_net_t net;
- cp_sta_t *sta[4];
- mac_t mac_addr[3];
- uint i;
- slab_cache_t slab;
-
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ cp_net_t cmp;
- cp_net_init (&cp, &net, 0, &slab);
+ test_case_begin (test, "NET init");
- for (i = 0; i < 3 ; i++)
+ test_begin (test, "init")
{
- mac_addr[i] = 0x12345678 + i;
- }
+ cp_net_init (&ctx, &net);
- test_case_begin (test, "Add unassociated stations");
+ memset (&cmp, 0, sizeof (cp_net_t));
- for (i = 0; i < 3; i++)
- {
- sta[i] = cp_net_sta_add (&cp, &net, 0x0, mac_addr[i]);
- }
+ cmp.expiration_ms = MAC_SEC_TO_MS(CP_NET_EXPIRATION_DELAY_S);
+ cmp.network_mode = CP_NET_NM_CSMA_ONLY;
- // Verify the station add.
- test_begin (test, "Unassoc stas added")
- {
- test_fail_if (set_empty (&net.unassociated_stas) == true,
- "List shall not be empty");
-
- for (i = 0; i < 3; i++)
- {
- test_fail_if (sta[i] == NULL, "Station should exist");
- test_fail_if (cp_sta_get_mac_address(sta[i]) != mac_addr[i],
- "Station mac address is wrong");
- test_fail_if (cp_sta_get_tei (sta[i]) != 0, "Wrong TEI");
- test_fail_if (cp_sta_get_cco_status (sta[i]) != false,
- "Wrong CCo status");
- test_fail_if (cp_sta_get_pco_status (sta[i]) != false,
- "Wrong PCo status");
- slab_release (sta[i]);
- }
- }
- test_end;
+ set_init (&cmp.associated_stas, cp_net_station_assoc_less);
+ set_init (&cmp.unassociated_stas, cp_net_station_unassoc_less);
- sta[3] = cp_net_sta_add (&cp, &net, 0x0, mac_addr[1]);
- test_begin (test, "Duplicated Sta")
- {
- test_fail_if (sta[3] != sta[1]);
+ test_fail_if (memcmp (&net, &cmp, sizeof (cp_net_t)) != 0);
}
test_end;
- slab_release (sta[3]);
-
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
}
-/**
- * Add an associated station to the net.
- *
- * \param test the test object result.
- *
- * Add some station to the network and verify the data.
- */
void
-test_case_network_add_assoc_stations (test_t test)
+test_case_cp_net_uninit (test_t test)
{
cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[3];
- mac_t mac_addr[3];
- uint i;
- slab_cache_t slab;
-
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
- cp_net_init (&cp, &net, 0, &slab);
- cp.mac_store = mac_store_init ();
+ test_case_begin (test, "uninit");
- for (i = 0; i < 3 ; i++)
+ test_begin (test, "Net empty")
{
- mac_addr[i] = 0x12345678 + i;
- }
+ cp_net_t net;
+ cp_net_t net_uninit;
- test_case_begin (test, "Add associated stations");
+ /* Initialise the comparison net. */
+ memset (&net_uninit, 0, sizeof (cp_net_t));
+ net_uninit.expiration_ms = MAC_SEC_TO_MS(CP_NET_EXPIRATION_DELAY_S);
+ net_uninit.network_mode = CP_NET_NM_CSMA_ONLY;
+ set_init (&net_uninit.associated_stas, cp_net_station_assoc_less);
+ set_init (&net_uninit.unassociated_stas, cp_net_station_unassoc_less);
- for (i = 0; i < 3; i++)
- {
- sta[i] = cp_net_sta_add (&cp, &net, i + 1, mac_addr[i]);
- cp_net_sta_set_authenticated (&cp, &net, sta[i], true);
- }
+ cp_net_init (&cp, &net);
+ cp_net_uninit (&cp, &net);
- // Verify the station add.
- test_begin (test, "assoc stas added")
- {
- test_fail_if (set_empty (&net.associated_stas) != false,
- "List shall not be empty");
-
- for (i = 0; i < 3; i++)
- {
- test_fail_if (sta[i] == NULL, "Station should exist");
- test_fail_if (cp_sta_get_mac_address(sta[i]) != mac_addr[i],
- "Station mac address is wrong");
- test_fail_if (cp_sta_get_tei (sta[i]) != i + 1, "Wrong TEI");
- test_fail_if (cp_sta_get_cco_status (sta[i]) != false,
- "Wrong CCo status");
- test_fail_if (cp_sta_get_pco_status (sta[i]) != false,
- "Wrong PCo status");
- test_fail_if (cp_net_sta_get_authenticated (&cp, &net, sta[i])
- != false,
- "Wrong station state");
- slab_release (sta[i]);
-
- cp_net_sta_remove_assoc (&cp, &net, i + 1);
- }
-
- test_fail_if (set_empty (&net.associated_stas) != true,
- "List shall be empty");
+ test_fail_if (memcmp (&net, &net_uninit, sizeof (cp_net_t)) != 0);
}
test_end;
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
-}
-
-/**
- * Add an authenticated station to the net.
- *
- * \param test the test object result.
- *
- * Add some station to the network and verify the data.
- */
-void
-test_case_network_add_auth_stations (test_t test)
-{
- cp_t cp;
- cp_net_t *net;
- cp_sta_t *sta[3];
- mac_t mac_addr[3];
- uint i;
-
- cp_sta_mgr_init (&cp);
- net = cp_sta_mgr_get_our_avln (&cp);
- cp.mac_store = mac_store_init ();
-
- for (i = 0; i < 3 ; i++)
+ test_begin (test, "NET empty with NID SNID")
{
- mac_addr[i] = 0x12345678 + i;
- }
+ cp_net_t *net;
+ cp_net_t net_cmp;
- test_case_begin (test, "Add authenticated stations");
+ /* Initialise the comparison net. */
+ memset (&net_cmp, 0, sizeof (cp_net_t));
+ net_cmp.expiration_ms = MAC_SEC_TO_MS(CP_NET_EXPIRATION_DELAY_S);
+ net_cmp.network_mode = CP_NET_NM_CSMA_ONLY;
+ set_init (&net_cmp.associated_stas, cp_net_station_assoc_less);
+ set_init (&net_cmp.unassociated_stas, cp_net_station_unassoc_less);
+ net_cmp.snid = 1;
+ net_cmp.nid = 1;
- for (i = 0; i < 3; i++)
- {
- sta[i] = cp_net_sta_add (&cp, net, i + 1, mac_addr[i]);
- cp_net_sta_set_authenticated (&cp, net, sta[i],
- true);
- }
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_net_uninit (&cp, net);
- // Verify the station add.
- test_begin (test, "assoc stas added")
- {
- test_fail_if (set_empty (&net->associated_stas) != false,
- "List shall not be empty");
-
- for (i = 0; i < 3; i++)
- {
- test_fail_if (sta[i] == NULL, "Station should exist");
- test_fail_if (cp_sta_get_mac_address(sta[i]) != mac_addr[i],
- "Station mac address is wrong");
- test_fail_if (cp_sta_get_tei (sta[i]) != i + 1, "Wrong TEI");
- test_fail_if (cp_sta_get_cco_status (sta[i]) != false,
- "Wrong CCo status");
- test_fail_if (cp_sta_get_pco_status (sta[i]) != false,
- "Wrong PCo status");
- test_fail_if (cp_net_sta_get_authenticated(&cp, net, sta[i])!= true,
- "Wrong station state");
- slab_release (sta[i]);
-
- cp_net_sta_remove_assoc (&cp, net, i + 1);
- }
-
- test_fail_if (set_empty (&net->associated_stas) != true,
- "List shall be empty");
+ test_fail_if (memcmp (net, &net_cmp, sizeof (cp_net_t)) != 0);
}
test_end;
- cp_net_uninit (&cp, net);
- cp_sta_mgr_uninit (&cp);
- mac_store_uninit (cp.mac_store);
-}
-/**
- * Add three authenticated station to the net.
- * The last station is the CCo.
- *
- * \param test the test object result.
- *
- * Add some station to the network and verify the data.
- */
-void
-test_case_network_add_auth_stations_last_is_cco (test_t test)
-{
- cp_t cp;
- cp_net_t *net;
- cp_sta_t *sta[3];
- mac_t mac_addr[3];
- mac_config_t mac_config;
- uint i;
-
- cp_sta_mgr_init (&cp);
- cp.mac_store = mac_store_init ();
- net = cp_sta_mgr_get_our_avln (&cp);
- cp.mac_config = &mac_config;
-
- for (i = 0; i < 3 ; i++)
+ test_begin (test, "NET not empty with NID SNID")
{
- mac_addr[i] = 0x12345678 + i;
- }
+ cp_net_t *net;
+ cp_net_t net_cmp;
+ cp_sta_t *sta;
+ cl_t cl;
- test_case_begin (test, "Add authenticated stations last is CCo");
+ /* Initialise the comparison net. */
+ memset (&net_cmp, 0, sizeof (cp_net_t));
+ net_cmp.expiration_ms = MAC_SEC_TO_MS(CP_NET_EXPIRATION_DELAY_S);
+ net_cmp.network_mode = CP_NET_NM_CSMA_ONLY;
+ set_init (&net_cmp.associated_stas, cp_net_station_assoc_less);
+ set_init (&net_cmp.unassociated_stas, cp_net_station_unassoc_less);
+ net_cmp.snid = 1;
+ net_cmp.nid = 1;
- for (i = 0; i < 3; i++)
- {
- sta[i] = cp_net_sta_add (&cp, net, i + 1, mac_addr[i]);
- cp_net_sta_set_authenticated (&cp, net, sta[i], true);
- }
- cp_net_set_cco (&cp, net, 3);
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ cp.cl = &cl;
- // Verify the station add.
- test_begin (test, "assoc stas added")
- {
- test_fail_if (set_empty (&net->associated_stas) != false,
- "List shall not be empty");
-
- for (i = 0; i < 3; i++)
- {
- test_fail_if (sta[i] == NULL, "Station should exist");
- test_fail_if (cp_sta_get_mac_address(sta[i]) != mac_addr[i],
- "Station mac address is wrong");
- test_fail_if (cp_sta_get_tei (sta[i]) != i + 1, "Wrong TEI");
- test_fail_if (cp_sta_get_pco_status (sta[i]) != false,
- "Wrong PCo status");
- test_fail_if (cp_net_sta_get_authenticated(&cp, net, sta[i])!= true,
- "Wrong station state");
-
- test_fail_if (i == 2 ? net->cco != sta[i] : net->cco == sta[i],
- "Wrong CCo sta[%d]", i);
- test_fail_if (i == 2 ? cp_sta_get_cco_status (sta[i]) != true :
- cp_sta_get_cco_status (sta[i]) != false,
- "wrong CCo status sta[%d]", i);
-
- slab_release (sta[i]);
- cp_net_sta_remove_assoc (&cp, net, i + 1);
- }
-
- test_fail_if (set_empty (&net->associated_stas) != true,
- "List shall be empty");
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ slab_release (sta);
+ cp_net_uninit (&cp, net);
+
+ test_fail_if (memcmp (net, &net_cmp, sizeof (cp_net_t)) != 0);
+
+ mac_store_uninit (cp.mac_store);
}
test_end;
- cp_sta_mgr_uninit (&cp);
- mac_store_uninit (cp.mac_store);
}
-/**
- * Add three authenticated station to the net.
- * The last station is the PCo.
- *
- * \param test the test object result.
- *
- * Add some station to the network and verify the data.
- */
void
-test_case_network_add_auth_stations_last_is_pco (test_t test)
+test_case_cp_net_garbage_stations (test_t test)
{
- cp_t cp;
- cp_net_t *net;
- cp_sta_t *sta[3];
- mac_t mac_addr[3];
- mac_config_t mac_config;
- uint i;
+ test_case_begin (test, "Garbage");
- cp_sta_mgr_init (&cp);
- cp.mac_store = mac_store_init ();
- cp.mac_config = &mac_config;
+ test_begin (test, "An AVLN, our AVLN not defined")
+ {
+ cp_t cp;
+ cl_t cl;
+ cp_net_t *net;
+ cp_sta_t *sta;
- net = cp_sta_mgr_get_our_avln (&cp);
+ memset (&cl, 0, sizeof (cl_t));
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ cp.cl = &cl;
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
- for (i = 0; i < 3 ; i++)
- {
- mac_addr[i] = 0x12345678 + i;
- }
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ sta->last_seen_ms = 0;
+ slab_release (sta);
- test_case_begin (test, "Add authenticated stations last is CCo");
+ sta = cp_net_sta_add (&cp, net, 2, 2);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- for (i = 0; i < 3; i++)
- {
- sta[i] = cp_net_sta_add (&cp, net, i + 1, mac_addr[i]);
- cp_net_sta_set_authenticated (&cp, net, sta[i], true);
- }
- cp_net_set_pco (&cp, net, 3);
+ sta = cp_net_sta_add (&cp, net, 0, 3);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- // Verify the station add.
- test_begin (test, "assoc stas added")
- {
- test_fail_if (set_empty (&net->associated_stas) != false,
- "List shall not be empty");
-
- for (i = 0; i < 3; i++)
- {
- test_fail_if (sta[i] == NULL, "Station should exist");
- test_fail_if (cp_sta_get_mac_address(sta[i]) != mac_addr[i],
- "Station mac address is wrong");
- test_fail_if (cp_sta_get_tei (sta[i]) != i + 1, "Wrong TEI");
- test_fail_if (cp_sta_get_cco_status (sta[i]) != false,
- "Wrong CCo status");
- test_fail_if (cp_net_sta_get_authenticated (&cp, net, sta[i])!=
- true,
- "Wrong station state");
-
- test_fail_if (i == 2 ? net->pco != sta[i] : net->pco == sta[i],
- "Wrong PCo sta[%d]", i);
- test_fail_if (i == 2 ? cp_sta_get_pco_status (sta[i]) != true :
- cp_sta_get_pco_status (sta[i]) != false,
- "wrong PCo status sta[%d]", i);
-
- slab_release (sta[i]);
- cp_net_sta_remove_assoc (&cp, net, i + 1);
- }
-
- test_fail_if (set_empty (&net->associated_stas) != true,
- "List shall be empty");
- }
- test_end;
- cp_sta_mgr_uninit (&cp);
- mac_store_uninit (cp.mac_store);
-}
+ sta = cp_net_sta_add (&cp, net, 4, 3);
+ sta->last_seen_ms = 100;
+ slab_release (sta);
-/** Removing a Associated station (not CCo, not PCo)
- *
- * \param test the test object.
- */
-void
-test_case_remove_stations (test_t test)
-{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[10];
- uint i;
- slab_cache_t slab;
+ cp_net_garbage_stations (&cp, net,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 2);
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ sta = cp_net_get_sta (&cp, net, 1);
+ test_fail_if (sta != NULL);
- cp_net_init (&cp, &net, 0, &slab);
+ cp_net_garbage_stations (&cp, net,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 12);
- for (i = 0; i < 10; i++)
- {
- sta[i] = cp_net_sta_add (&cp, &net, i + 1, i + 1);
- slab_release (sta[i]);
- }
+ sta = cp_net_get_sta (&cp, net, 2);
+ test_fail_if (sta != NULL);
- test_case_begin (test, "Remove stations");
+ sta = cp_net_get_sta_unassoc (&cp, net, 3);
+ test_fail_if (sta != NULL);
- test_begin (test, "Verify if list is empty")
- {
- test_fail_if (set_empty (&net.associated_stas) != false,
- "List shall not be empty");
+ sta = cp_net_get_sta (&cp, net, 4);
+ test_fail_if (sta == NULL);
+ cp_net_sta_remove (&cp, net, sta);
+ slab_release (sta);
+
+ mac_store_uninit (cp.mac_store);
}
test_end;
- for (i = 0; i < 10; i++)
+ test_begin (test, "One AVLNs, our AVLN defined")
{
- cp_net_sta_remove_assoc (&cp, &net, i + 1);
- }
+ cp_t cp;
+ cl_t cl;
+ sar_t sar;
+ cp_net_t *net;
+ cp_sta_t *sta;
- test_begin (test, "Verify if list is empty")
- {
- test_fail_if (set_empty (&net.associated_stas) != true,
- "List shall be empty");
- }
- test_end;
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
-}
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&sar, 0, sizeof (sar_t));
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ cp.cl = &cl;
+ cp.sar = &sar;
+ sar.mac_store = cp.mac_store;
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
-/** Removing the CCo station of the net.
- *
- * \param test the test object.
- *
- * Add some station in the net list as associated, one of those stations is
- * the CCo (TEI = 3 for examples).
- *
- * At the beginning of the test, the station with the TEI = 3, shall have its
- * status cco flag setted and the network has its cco pointer corresponding to
- * this station.
- *
- * At the end, the station shall not exist in the network and the pointer
- * to the CCo in the network shall be null.
- * The other stations of the AVLN shall remain present.
- */
-void
-test_case_remove_sta_cco_station (test_t test)
-{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[10], *s;
- uint i;
- slab_cache_t slab;
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ sta->last_seen_ms = 0;
+ slab_release (sta);
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ sta = cp_net_sta_add (&cp, net, 2, 2);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- cp_net_init (&cp, &net, 0, &slab);
+ sta = cp_net_sta_add (&cp, net, 0, 3);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- for (i = 0; i < 10; i++)
- {
- sta[i] = cp_net_sta_add (&cp, &net, i + 1, i + 1);
- }
- cp_net_set_cco (&cp, &net, 3);
+ sta = cp_net_sta_add (&cp, net, 4, 3);
+ sta->last_seen_ms = 100;
+ slab_release (sta);
- test_case_begin (test, "Remove sta : Remove CCo station");
+ cp_net_garbage_stations (&cp, net,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 2);
- test_begin (test, "Verify begin data")
- {
- test_fail_if (net.cco != sta[2], "Wrong CCo pointer value");
-
- for (i = 0; i < 10; i++)
- {
- test_fail_if (cp_sta_get_tei (sta[i]) != i + 1,
- "Wrong TEI");
- test_fail_if (cp_sta_get_cco_status (sta[i]) != (i == 2 ? true :
- false), "Wrong station CCo status");
- slab_release (sta[i]);
- }
- }
- test_end;
+ sta = cp_net_get_sta (&cp, net, 1);
+ test_fail_if (sta == NULL);
+ slab_release (sta);
+ cp_net_garbage_stations (&cp, net,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 12);
- // remove the CCo.
- cp_net_sta_remove_assoc (&cp, &net, 3);
+ sta = cp_net_get_sta (&cp, net, 2);
+ test_fail_if (sta == NULL);
+ slab_release (sta);
- test_begin (test, "Verifying the absence of CCo in the AVLN")
- {
- for (i = 0, s = cp_net_get_first (&cp, &net, true /* Assoc. */);
- s;
- i++, s = cp_net_get_next (&cp, &net, s))
- {
- test_fail_if (cp_sta_get_tei (s) != (i < 2 ? i + 1 : i + 2),
- "Wrong tei");
- }
+ sta = cp_net_get_sta_unassoc (&cp, net, 3);
+ test_fail_if (sta != NULL);
+
+ sta = cp_net_get_sta (&cp, net, 4);
+ test_fail_if (sta == NULL);
+ slab_release (sta);
+
+ // Remove the stations.
+ cp_net_sta_remove_assoc (&cp, net, 1);
+ cp_net_sta_remove_assoc (&cp, net, 2);
+ cp_net_sta_remove_assoc (&cp, net, 4);
+ mac_store_uninit (cp.mac_store);
}
test_end;
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
-}
+ test_begin (test, "Two AVLN, our AVLN defined")
+ {
+ cp_t cp;
+ cl_t cl;
+ sar_t sar;
+ cp_net_t *net;
+ cp_net_t *net2;
+ cp_sta_t *sta;
-/** Removing the PCo Station of the net.
- *
- * \param test the object test
- *
- * Add some station in the net list as associated, one of those stations is
- * the PCo (TEI = 3 for examples).
- *
- * At the beginning of the test, the station with the TEI = 3, shall have
- * its status pco flag setted and the network has its pco pointer
- * corresponding to this station.
- *
- * At the end, the station shall not exist in the network and the pointer
- * to the PCo in the network shall be null.
- * The other stations of the AVLN shall remain present.
- */
-void
-test_case_remove_sta_pco_station (test_t test)
-{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[10], *s;
- uint i;
- slab_cache_t slab;
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&sar, 0, sizeof (sar_t));
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ cp.cl = &cl;
+ cp.sar = &sar;
+ sar.mac_store = cp.mac_store;
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ sta->last_seen_ms = 0;
+ slab_release (sta);
- cp_net_init (&cp, &net, 0, &slab);
+ sta = cp_net_sta_add (&cp, net, 2, 2);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- for (i = 0; i < 10; i++)
- {
- sta[i] = cp_net_sta_add (&cp, &net, i + 1, i + 1);
- }
- cp_net_set_pco(&cp, &net, 3);
+ sta = cp_net_sta_add (&cp, net, 0, 3);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- test_case_begin (test, "Remove sta : Remove PCo station");
+ sta = cp_net_sta_add (&cp, net, 4, 3);
+ sta->last_seen_ms = 100;
+ slab_release (sta);
- test_begin (test, "Verify begin data")
- {
- test_fail_if (net.pco != sta[2], "Wrong PCo pointer value");
-
- for (i = 0; i < 10; i++)
- {
- test_fail_if (cp_sta_get_tei (sta[i]) != i + 1,
- "Wrong TEI");
- test_fail_if (cp_sta_get_pco_status (sta[i]) != (i == 2 ? true :
- false), "Wrong station CCo status");
- slab_release (sta[i]);
- }
- }
- test_end;
+ net2 = cp_sta_mgr_add_avln (&cp, 2, 2);
+ sta = cp_net_sta_add (&cp, net2, 1, 1);
+ sta->last_seen_ms = 0;
+ slab_release (sta);
- // remove the PCo.
- cp_net_sta_remove_assoc (&cp, &net, 3);
+ sta = cp_net_sta_add (&cp, net2, 2, 2);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- test_begin (test, "Verifying the absence of PCo in the AVLN")
- {
- for (i = 0, s = cp_net_get_first (&cp, &net, CP_NET_STA_ASSOC);
- s;
- i++, s = cp_net_get_next (&cp, &net, s))
- {
- test_fail_if (cp_sta_get_tei (s) != (i < 2 ? i + 1 : i + 2),
- "Wrong tei");
- }
- }
- test_end;
+ sta = cp_net_sta_add (&cp, net2, 0, 3);
+ sta->last_seen_ms = 10;
+ slab_release (sta);
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
-}
+ sta = cp_net_sta_add (&cp, net2, 4, 3);
+ sta->last_seen_ms = 100;
+ slab_release (sta);
-/** Add a CCo station to the net.
- *
- * \param test the test object.
- *
- * Add a station to be the CCo it will test the get_cco and set CCo
- * functions.
- */
-void
-test_case_cco (test_t test)
-{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[2];
- cp_sta_t *cco;
- cp_mme_peer_t peer;
- slab_cache_t slab;
+ cp_net_garbage_stations (&cp, net,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 2);
+ cp_net_garbage_stations (&cp, net2,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 2);
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
- cp_net_init (&cp, &net, 0, &slab);
+ sta = cp_net_get_sta (&cp, net, 1);
+ test_fail_if (sta == NULL);
+ slab_release (sta);
- // the cco station.
- sta[0] = cp_net_sta_add (&cp, &net, 1, 11);
- cp_net_set_cco (&cp, &net, 1);
+ cp_net_garbage_stations (&cp, net,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 12);
+ cp_net_garbage_stations (&cp, net2,
+ MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 12);
- // another station in the avln.
- sta[1] = cp_net_sta_add (&cp, &net, 2, 22);
- test_case_begin (test, "set and get cco");
+ sta = cp_net_get_sta (&cp, net, 2);
+ test_fail_if (sta == NULL);
+ slab_release (sta);
- test_begin (test, "get cco")
- {
- cco = cp_net_get_cco (&cp, &net);
- test_fail_if (cco != sta[0], "wrong cco station");
- cp_net_get_cco_peer (&cp, &net, &peer);
- test_fail_if (!cp_mme_peer_cmp (&peer, &CP_MME_PEER (11, 1)));
- }
- test_end;
- slab_release (cco);
+ sta = cp_net_get_sta_unassoc (&cp, net, 3);
+ test_fail_if (sta != NULL);
- // remove the cco.
- cp_net_sta_remove_assoc (&cp, &net, 1);
+ sta = cp_net_get_sta (&cp, net, 4);
+ test_fail_if (sta == NULL);
+ slab_release (sta);
- test_begin (test, "get cco, cco doesn't exists anymore")
- {
- cco = cp_net_get_cco (&cp, &net);
- test_fail_if (cco != NULL, "wrong cco station");
- }
- test_end;
+ sta = cp_net_get_sta (&cp, net2, 1);
+ test_fail_if (sta != NULL);
- // set the new cco.
- cp_net_set_cco (&cp, &net, 2);
+ sta = cp_net_get_sta (&cp, net2, 2);
+ test_fail_if (sta != NULL);
- test_begin (test, "get cco")
- {
- cco = cp_net_get_cco (&cp, &net);
- test_fail_if (cco != sta[1], "wrong cco station");
- cp_net_get_cco_peer (&cp, &net, &peer);
- test_fail_if (!cp_mme_peer_cmp (&peer, &CP_MME_PEER (22, 2)));
+ sta = cp_net_get_sta_unassoc (&cp, net2, 3);
+ test_fail_if (sta != NULL);
+
+ sta = cp_net_get_sta (&cp, net2, 4);
+ test_fail_if (sta == NULL);
+ cp_net_sta_remove (&cp, net2, sta);
+ slab_release (sta);
+
+ // Remove the stations.
+ cp_net_sta_remove_assoc (&cp, net, 1);
+ cp_net_sta_remove_assoc (&cp, net, 2);
+ cp_net_sta_remove_assoc (&cp, net, 4);
+ mac_store_uninit (cp.mac_store);
}
test_end;
- slab_release (cco);
-
- slab_release (sta[0]);
- slab_release (sta[1]);
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
}
-/** Add a PCo station to the net.
- *
- * \param test the test object.
- *
- * Add a station to be the PCo it will test the get_pco function.
- */
void
-test_case_pco (test_t test)
+test_case_cp_net_set_xco (test_t test)
{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[2];
- cp_sta_t *pco;
- cp_mme_peer_t peer;
- slab_cache_t slab;
+ test_case_begin (test, "Set XCo In an AVLN");
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
-
- cp_net_init (&cp, &net, 0, &slab);
+ test_begin (test, "Set CCo and PCo")
+ {
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cl_t cl;
- // the pco station.
- sta[0] = cp_net_sta_add (&cp, &net, 1, 11);
- cp_net_set_pco (&cp, &net, 1);
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ memset (&cl, 0, sizeof (cl_t));
+ cp.cl = &cl;
- // another station in the avln.
- sta[1] = cp_net_sta_add (&cp, &net, 2, 22);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
- test_case_begin (test, "set and get pco");
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ cp_net_set_pco (&cp, net, 1, true);
+ test_fail_if (cp_sta_get_pco_status (sta) == false);
+ test_fail_if (cp_net_get_pco (&cp, net) != sta);
+ slab_release (sta);
- test_begin (test, "get pco")
- {
- pco = cp_net_get_pco (&cp, &net);
- test_fail_if (pco != sta[0], "wrong pco station");
- cp_net_get_pco_peer (&cp, &net, &peer);
- test_fail_if (!cp_mme_peer_cmp (&peer, &CP_MME_PEER (11, 1)));
- }
- test_end;
- slab_release (pco);
+ cp_net_sta_remove (&cp, net, sta);
+ slab_release (sta);
+ test_fail_if (cp_net_get_pco (&cp, net) != NULL);
+
+ sta = cp_net_sta_add (&cp, net, 1, 2);
+ cp_net_set_cco (&cp, net, 1, true /* CCo */);
+ test_fail_if (cp_sta_get_cco_status (sta) == false);
+ test_fail_if (cp_net_sta_get_authenticated (&cp, net, sta)
+ == false);
+ test_fail_if (cp_net_get_cco (&cp, net) != sta);
+ slab_release (sta);
+ cp_net_sta_remove (&cp, net, sta);
- // remove the pco.
- cp_net_sta_remove_assoc (&cp, &net, 1);
+ // Release the station reference added by the net.
+ slab_release (sta);
- test_begin (test, "get pco, pco doesn't exists anymore")
- {
- pco = cp_net_get_pco (&cp, &net);
- test_fail_if (pco != NULL, "wrong cco station");
+ cp_sta_mgr_uninit (&cp);
+ mac_store_uninit (cp.mac_store);
}
test_end;
- // set the new pco.
- cp_net_set_pco (&cp, &net, 2);
-
- test_begin (test, "get pco")
+ test_begin (test, "Set CCo and PCo in our AVLN.")
{
- pco = cp_net_get_pco (&cp, &net);
- test_fail_if (pco != sta[1], "wrong pco station");
- cp_net_get_pco_peer (&cp, &net, &peer);
- test_fail_if (!cp_mme_peer_cmp (&peer, &CP_MME_PEER (22, 2)));
- }
- test_end;
- slab_release (pco);
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cl_t cl;
+ sar_t sar;
+ mac_config_t mac_config;
- slab_release (sta[0]);
- slab_release (sta[1]);
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
-}
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&sar, 0, sizeof (sar_t));
+ cp.cl = &cl;
+ cp.sar = &sar;
+ sar.mac_store = cp.mac_store;
+ cp.mac_config = &mac_config;
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
-/** Add twice the same station.
- *
- * \param test the test object.
- */
-void
-test_case_add_twice_same_sta (test_t test)
-{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta[2];
- slab_cache_t slab;
-
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ cp_net_set_pco (&cp, net, 1, true);
+ test_fail_if (cp_sta_get_pco_status (sta) == false);
+ test_fail_if (cp_net_get_pco (&cp, net) != sta);
+ slab_release (sta);
- test_case_begin (test, "Add twice the same station");
+ cp_net_sta_remove (&cp, net, sta);
+ slab_release (sta);
+ test_fail_if (cp_net_get_pco (&cp, net) != NULL);
+
+ sta = cp_net_sta_add (&cp, net, 1, 2);
+ cp_net_set_cco (&cp, net, 1, true /* CCo */);
+ test_fail_if (cp_sta_get_cco_status (sta) == false);
+ test_fail_if (cp_net_sta_get_authenticated (&cp, net, sta)
+ == true);
+ test_fail_if (cp_net_get_cco (&cp, net) != sta);
+ slab_release (sta);
+ cp_net_sta_remove (&cp, net, sta);
+ test_fail_if (cp_net_get_cco (&cp, net) != NULL);
+ // Release the station reference added by the net.
+ slab_release (sta);
- test_begin (test, "verify")
- {
- cp_net_init (&cp, &net, 0, &slab);
- sta[0] = cp_net_sta_add (&cp, &net, 1, 1);
- sta[1] = cp_net_sta_add (&cp, &net, 1, 1);
+ // Add a sta to set it as CCo and change to our own station.
+ sta = cp_net_sta_add (&cp, net, 4, 4);
+ cp_net_set_cco (&cp, net, 4, true /* CCo */);
+ test_fail_if (cp_sta_get_cco_status (sta) == false);
+ test_fail_if (cp_net_get_cco (&cp, net) != sta);
+ slab_release (sta);
+ cp_sta_own_data_set_tei (&cp, 2);
+ cp_sta_own_data_set_cco_status (&cp, true);
- test_fail_if (sta[0] != sta[1], "Shall be equal");
+ test_fail_if (cp_sta_get_cco_status (sta) != false);
+ test_fail_if (cp_net_get_cco (&cp, net) != NULL);
+ slab_release (sta);
- slab_release (sta[0]);
- slab_release (sta[1]);
- cp_net_uninit (&cp, &net);
+ cp_sta_mgr_uninit (&cp);
+ mac_store_uninit (cp.mac_store);
}
test_end;
- slab_cache_uninit (&slab);
}
-/** Test the commit function.
- *
- * \param test the test object.
- */
void
-test_case_commit (test_t test)
+test_case_cp_net_sta_add (test_t test)
{
- bitstream_t bitstream;
- cp_net_t net;
- cp_sta_t *sta[2];
- cp_t cp;
- uint sta1_tag;
- uint sta1_tei;
- u64 sta1_mac_addr;
- uint sta2_tag;
- uint sta2_tei;
- u64 sta2_mac_addr;
- slab_cache_t slab;
-
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
-
- cp.cl = blk_alloc();
- cp_net_init (&cp, &net, 0, &slab);
- net.station_avln = true;
-
- // the CCo station.
- sta[0] = cp_net_sta_add (&cp, &net, 1, 1);
-
- // another station in the AVLN.
- sta[1] = cp_net_sta_add (&cp, &net, 2, 2);
-
- test_case_begin (test, "commit function");
-
- cp_net_commit_to_dataplane (&cp, &net);
-
- // Get the table.
- bitstream_init (&bitstream, ((u8*) cp.cl + 1), 2*8, BITSTREAM_READ);
- bitstream_access (&bitstream, &sta1_tag, 8);
- bitstream_access (&bitstream, &sta1_tei, 8);
- bitstream_access (&bitstream, &sta1_mac_addr, 48);
- bitstream_access (&bitstream, &sta2_tag, 8);
- bitstream_access (&bitstream, &sta2_tei, 8);
- bitstream_access (&bitstream, &sta2_mac_addr, 48);
- bitstream_finalise (&bitstream);
-
- test_begin (test, "Verify commit")
+ test_case_begin (test, "Station Add");
+
+ test_begin (test, "Adding a station in an AVLN")
{
- test_fail_if (((u8*)cp.cl)[0] != 2, "Wrong qte of mac sta");
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
- test_fail_if (sta1_tag != CP_MACTOTEI_TAGS_LIST, "Wrong tag");
- test_fail_if (sta1_tei != cp_sta_get_tei(sta[0]),
- "Wrong station TEI");
- test_fail_if (sta1_mac_addr != cp_sta_get_mac_address(sta[0]),
- "Wrong station mac address");
+ sta = cp_net_sta_add (&cp, net, 0, 1);
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_tei (sta) != 0);
+ test_fail_if (cp_net_get_num_stas (&cp, net) != 1);
+ test_fail_if (cp_net_get_num_discovered_stas (&cp, net) != 1);
+ slab_release (sta);
- test_fail_if (sta2_tag != CP_MACTOTEI_TAGS_LIST, "Wrong tag");
- test_fail_if (sta2_tei != cp_sta_get_tei(sta[1]),
- "Wrong station TEI");
- test_fail_if (sta2_mac_addr != cp_sta_get_mac_address(sta[1]),
- "Wrong station mac address");
+ cp_net_sta_remove_unassoc (&cp, net, 1);
+ sta = cp_net_get_sta_unassoc (&cp, net, 1);
+ test_fail_if (sta != NULL);
+ test_fail_if (cp_net_get_num_stas (&cp, net) != 0);
+ test_fail_if (cp_net_get_num_discovered_stas (&cp, net) != 0);
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- slab_release (sta[0]);
- slab_release (sta[1]);
- blk_release (cp.cl);
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
-}
+ test_begin (test, "Adding a station in our AVLN")
+ {
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cl_t cl;
+ sar_t sar;
+ sta_t *sta_mac;
-/**
- * Verify the garbage function.
- *
- * \param test the test object
- *
- *
- * Shall create some station and modify the last seen date to be deleted by
- * the garbage collector of the net.
- */
-void
-test_case_garbage (test_t test, phy_t *phy)
-{
- cp_t cp;
- cp_sta_t *sta;
- cp_net_t net;
- mac_config_t mac_config;
- uint i;
- slab_cache_t slab;
-
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
- test_case_begin (test, "Garbage");
+ cp_sta_mgr_init (&cp);
+ cp.mac_store = mac_store_init ();
+ cl.mactotei = 0;
+ cp.cl = &cl;
+ sar.mac_store = cp.mac_store;
+ cp.sar = &sar;
- cp.mac_config = &mac_config;
- cp_net_init (&cp, &net, false, &slab);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
- for (i = 0; i < 3; i++)
- {
- // unassoc sta.
- sta = cp_net_sta_add (&cp, &net, 0, i + 1);
- sta->last_seen_ms = 2 * i + 5;
- cp_net_sta_set_authenticated (&cp, &net, sta, false);
- slab_release (sta);
+ sta = cp_net_sta_add (&cp, net, 0, 1);
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_tei (sta) != 0);
+ test_fail_if (cp_net_get_num_stas (&cp, net) != 1);
+ test_fail_if (cp_net_get_num_discovered_stas (&cp, net) != 1);
- // assoc sta.
- sta = cp_net_sta_add (&cp, &net, i + 1, 4*i + 1);
- sta->last_seen_ms = 2 * i + 6;
- cp_net_sta_set_authenticated (&cp, &net, sta, true);
+ sta_mac = mac_store_sta_get (cp.mac_store, 1);
+ test_fail_if (sta_mac != NULL);
slab_release (sta);
+
+ cp_net_sta_remove_unassoc (&cp, net, 1);
+ sta = cp_net_get_sta_unassoc (&cp, net, 1);
+ sta_mac = mac_store_sta_get (cp.mac_store, 1);
+ test_fail_if (sta_mac != NULL);
+ test_fail_if (sta != NULL);
+ test_fail_if (cp_net_get_num_stas (&cp, net) != 0);
+ test_fail_if (cp_net_get_num_discovered_stas (&cp, net) != 0);
+
+ cp_sta_mgr_uninit (&cp);
+ mac_store_uninit (cp.mac_store);
}
+ test_end;
+}
+
- *((uint*)phy) = MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 8;
- cp_net_garbage_stations (&cp, &net,
- MAC_SEC_TO_MS(CP_STA_EXPIRATION_DELAY_S) + 8);
+void
+test_case_cp_net_get_first (test_t test)
+{
+ test_case_begin (test, "Get first station of the AVLN");
- test_begin (test, "Expiration of 2 stations")
+ test_begin (test, "first sta")
{
- sta = cp_net_get_first(&cp, &net, CP_NET_STA_ASSOC);
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
- test_fail_if (sta == NULL,
- "list shall not be empty");
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
- test_fail_if (cp_sta_get_tei (sta) != 2,
- "Station 1 has not been expired");
+ sta = cp_net_sta_add (&cp, net, 1, 1);
slab_release (sta);
- sta = cp_net_get_first(&cp, &net, CP_NET_STA_UNASSOC);
+ sta = cp_net_sta_add (&cp, net, 0, 3);
+ slab_release (sta);
+
+ sta = cp_net_get_first (&cp, net, CP_NET_STA_UNASSOC);
+ test_fail_if (cp_sta_get_mac_address (sta) != 3);
+ test_fail_if (cp_sta_get_tei (sta) != 0);
+ slab_release (sta);
- test_fail_if (cp_sta_get_mac_address (sta) == 1,
- "Station with Mac@ 1 has not been expired");
+ sta = cp_net_get_first (&cp, net, CP_NET_STA_ASSOC);
+ test_fail_if (cp_sta_get_mac_address (sta) != 1);
+ test_fail_if (cp_sta_get_tei (sta) != 1);
slab_release (sta);
+ cp_sta_mgr_uninit (&cp);
}
test_end;
-
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
}
-/** Set slot id
- * \param test the test object.
- *
- * Add an AVLN and set the slot id to 5.
- *
- * Result
- * The slot id shall be equal to 5.
- */
void
-test_case_network_set_slot_id (test_t test)
+test_case_cp_net_get_next (test_t test)
{
- cp_net_t net;
- cp_t cp;
- slab_cache_t slab;
+ test_case_begin (test, "Get next station of the AVLN");
+
+ test_begin (test, "Get next sta")
+ {
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
- cp_net_init (&cp, &net, false, &slab);
+ sta = cp_net_sta_add (&cp, net, 0, 1);
+ slab_release (sta);
+ sta = cp_net_sta_add (&cp, net, 0, 2);
+ slab_release (sta);
- test_case_begin (test, "Set slot id");
+ sta = cp_net_get_first (&cp, net, CP_NET_STA_UNASSOC);
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_mac_address (sta) != 1);
+ sta = cp_net_get_next (&cp, net, sta);
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_mac_address (sta) != 2);
+ slab_release (sta);
- cp_net_set_slot_id_and_usage (&cp, &net, 5, 10);
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ slab_release (sta);
+ sta = cp_net_sta_add (&cp, net, 2, 2);
+ slab_release (sta);
- test_begin (test, "verify")
- {
- test_fail_if (net.avln_slot_id != 5, "Wrong slot id");
- test_fail_if (net.avln_slot_usage != 10, "Wrong slot usage mask");
+ sta = cp_net_get_first (&cp, net, CP_NET_STA_ASSOC);
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_mac_address (sta) != 1);
+ test_fail_if (cp_sta_get_tei (sta) != 1);
+ sta = cp_net_get_next (&cp, net, sta);
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_mac_address (sta) != 2);
+ test_fail_if (cp_sta_get_tei (sta) != 2);
+ slab_release (sta);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- slab_cache_uninit (&slab);
}
-/** Verify if use of the counter of visible stations.
- * \param test the test object.
- */
void
-test_case_network_get_num_discovered_sta (test_t test)
+test_case_cp_net_get_snid_nid (test_t test)
{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta;
- slab_cache_t slab;
+ test_case_begin (test, "Get snid");
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
-
- cp_net_init (&cp, &net, false, &slab);
+ test_begin (test, "Get snid and nid from a NET")
+ {
+ cp_t cp;
+ cp_net_t *net;
- test_case_begin (test, "Get number discovered stations");
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 2, 2);
- sta = cp_net_sta_add (&cp, &net, 1, 1);
+ test_fail_if (cp_net_get_snid (&cp, net) != 2);
+ test_fail_if (cp_net_get_nid (&cp, net) != 2);
- test_begin (test, "verify")
- {
- test_fail_if (net.num_visible_stas != 1, "One station discovered");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- cp_net_sta_remove (&cp, &net, sta);
-
- test_begin (test, "verify")
+ test_begin (test, "Get net form nid and snid")
{
- test_fail_if (net.num_visible_stas != 0, "No station discovered");
- }
- test_end;
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_get_avln (&cp, 2, 2);
- slab_release (sta);
+ test_fail_if (net != NULL);
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
+ cp_sta_mgr_uninit (&cp);
+ }
+ test_end;
}
-/**
- * Network mode function test.
- * \param test the test object.
- */
void
-test_case_network_mode (test_t test)
+test_case_cp_net_slot_usage (test_t test)
{
- cp_t cp;
- cp_net_t net;
- slab_cache_t slab;
+ test_case_begin (test, "Set, get slots and get slot mask");
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ test_begin (test, "Set slot id and mask")
+ {
+ cp_t cp;
+ cp_net_t *net;
- cp_net_init (&cp, &net, true, &slab);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
- test_case_begin (test, "Network mode");
+ cp_net_set_slot_id_and_usage (&cp, net, 1, 2);
- test_begin (test, "First mode read")
- {
- test_fail_if (cp_net_get_nm (&cp, &net) != CP_NET_NM_CSMA_ONLY,
- "Network mode is wrong");
- }
- test_end;
+ test_fail_if (cp_net_get_slot_id (&cp, net) != 1);
+ test_fail_if (cp_net_get_slot_usage_mask (&cp, net) != 2);
- cp_net_set_nm (&cp, &net, CP_NET_NM_COORDINATED);
-
- test_begin (test, "First mode read")
- {
- test_fail_if (cp_net_get_nm (&cp, &net) != CP_NET_NM_COORDINATED,
- "Network mode is wrong");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
-
-
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
}
-/**
- * Test the set station visible status.
- * \param test the test object.
- */
void
-test_case_sta_visible_status (test_t test)
+test_case_cp_net_nm (test_t test)
{
- cp_t cp;
- cp_net_t net;
- cp_sta_t *sta;
- slab_cache_t slab;
+ test_case_begin (test, "Network mode");
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
+ test_begin (test, "Set the NM and GET it.")
+ {
+ cp_t cp;
+ cp_net_t *net;
- test_case_begin (test, "STA set visible status");
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
- cp_net_init (&cp, &net, false, &slab);
+ cp_net_set_nm (&cp, net, CP_NET_NM_COORDINATED);
- sta = cp_net_sta_add (&cp, &net, 0x1, 0x1);
- cp_net_sta_set_visible_status (&cp, &net, sta, CP_STA_VISIBLE_STATE_VISIBLE);
+ test_fail_if (cp_net_get_nm (&cp, net) != CP_NET_NM_COORDINATED);
- test_begin (test, "Verify the visibility of the station")
- {
- test_fail_if (cp_net_get_num_discovered_stas (&cp, &net) != 1,
- "Wrong discovered sta");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- slab_release (sta);
+}
- sta = cp_net_sta_add (&cp, &net, 0x2, 0x2);
- cp_net_sta_set_visible_status (&cp, &net, sta, CP_STA_VISIBLE_STATE_HIDDEN);
+void
+test_case_cp_net_sta_visible (test_t test)
+{
+ test_case_begin (test, "visible stations");
- test_begin (test, "Verify the hidden status")
+ test_begin (test, "Set")
{
- test_fail_if (cp_net_get_num_discovered_stas (&cp, &net) != 1,
- "Wrong discovered sta");
- test_fail_if (cp_net_get_num_stas (&cp, &net) != 2,
- "Wrong number of stations");
- }
- test_end;
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
- slab_release (sta);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
+ sta = cp_net_sta_add (&cp, net, 1, 1);
+ cp_net_sta_set_visible_status (&cp, net, sta,
+ CP_STA_VISIBLE_STATE_VISIBLE);
- test_begin (test, "Remove stations")
- {
- cp_net_sta_remove_assoc (&cp, &net, 0x1);
+ test_fail_if (net->num_visible_stas != 1);
- test_fail_if (cp_net_get_num_discovered_stas (&cp, &net) != 0,
- "Wrong discovered sta");
- test_fail_if (cp_net_get_num_stas (&cp, &net) != 1,
- "Wrong number of stations");
+ cp_net_sta_set_visible_status (&cp, net, sta,
+ CP_STA_VISIBLE_STATE_HIDDEN);
+ test_fail_if (net->num_visible_stas != 0);
- cp_net_sta_remove_assoc (&cp, &net, 0x2);
+ slab_release (sta);
- test_fail_if (cp_net_get_num_discovered_stas (&cp, &net) != 0,
- "Wrong discovered sta");
- test_fail_if (cp_net_get_num_stas (&cp, &net) != 0,
- "Wrong number of stations");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
-
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
}
void
-test_case_get_sta_from_mac (test_t test)
+test_case_cp_net_is_empty (test_t test)
{
- cp_t cp;
- cp_sta_t *sta;
- cp_net_t *net;
- uint i;
-
- test_case_begin (test, "Get station from mac address associated");
+ test_case_begin (test, "Net empty");
- cp_sta_mgr_init (&cp);
+ test_begin (test, "Net not empty, one sta assoc")
+ {
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
- net = cp_sta_mgr_get_our_avln (&cp);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
- for (i = 1; i < 10; i++)
- {
- sta = cp_net_sta_add (&cp, net, i, i);
+ sta = cp_net_sta_add (&cp, net, 1, 1);
slab_release (sta);
- }
- sta = cp_net_get_sta_from_mac (&cp, net, 0x5);
- test_begin (test, "verify")
- {
- test_fail_if (sta == NULL, "Station shall exist");
- test_fail_if (cp_sta_get_tei (sta) != 5, "Wrong TEI");
- test_fail_if (cp_sta_get_mac_address (sta) != 5, "Wrong Mac @");
+ test_fail_if (cp_net_is_empty (&cp, net) == true);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- slab_release (sta);
-
- cp_sta_mgr_uninit (&cp);
-}
-/** Verify if the net_empty function.
- * \param test the test object.
- *
- * The function shall return true if the associated set is empty even if the
- * unassociated set is not empty.
- */
-void
-test_case_net_empty (test_t test)
-{
- cp_net_t net;
- cp_t cp;
- cp_sta_t *sta;
- slab_cache_t slab;
-
- slab_cache_init (&slab,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
-
- cp_net_init (&cp, &net, true, &slab);
- test_case_begin (test, "Network empty");
-
- test_begin (test, "verify, assoc list empty, unassoc empty")
+ test_begin (test, "Net not empty, one sta unassoc")
{
- test_fail_if (cp_net_is_empty (&cp, &net) != true,
- "net is empty function shall return true");
- }
- test_end;
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
- sta = cp_net_sta_add (&cp, &net, 0x1, 0x1);
- slab_release (sta);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 3, 3);
- test_begin (test, "verify, assoc list not empty, unassoc not empty")
- {
- test_fail_if (cp_net_is_empty (&cp, &net) != false,
- "net is empty function shall return false");
- }
- test_end;
- cp_net_sta_remove_assoc (&cp, &net, 0x1);
+ sta = cp_net_sta_add (&cp, net, 0, 1);
+ slab_release (sta);
- sta = cp_net_sta_add (&cp, &net, 0x0, 0x1);
- slab_release (sta);
+ test_fail_if (cp_net_is_empty (&cp, net) == false);
- test_begin (test, "verify, assoc list empty, unassoc not empty")
- {
- test_fail_if (cp_net_is_empty (&cp, &net) != true,
- "net is empty function shall return true");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
-
- cp_net_uninit (&cp, &net);
- slab_cache_uninit (&slab);
}
void
-test_case_ucco (test_t test)
+test_case_cp_net_ucco (test_t test)
{
- cp_t cp;
- cp_sta_t *sta1;
- cp_sta_t *sta2;
- cp_net_t *net;
+ test_case_begin (test, "Set the net ucco");
- test_case_begin (test, "Set and Get the UCCo from the NET");
+ test_begin (test, "set UCCo")
+ {
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cp_sta_t *ucco;
- cp_sta_mgr_init (&cp);
- net = cp_sta_mgr_get_our_avln (&cp);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
- test_begin (test, "set the UCCo")
- {
+ sta = cp_net_sta_add (&cp, net, 0, 3);
+ cp_net_set_ucco (&cp, net, sta);
+
+ test_fail_if (sta == NULL);
+ test_fail_if (cp_sta_get_cco_status (sta) == false);
+ test_fail_if (cp_sta_get_tei (sta) != 0);
- sta1 = cp_net_sta_add (&cp, net, 0x0, 0x1);
- test_fail_if (sta1 == NULL);
+ ucco = cp_net_get_ucco (&cp, net);
- cp_net_set_ucco (&cp, net, sta1);
- slab_release (sta1);
+ test_fail_if (sta != ucco);
- sta1 = cp_net_get_ucco (&cp, net);
- test_fail_if (cp_sta_get_cco_status (sta1) == false);
+ slab_release (ucco);
+ slab_release (sta);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- test_begin (test, "set another UCC0")
+ test_begin (test, "Change the UCCo")
{
- sta2 = cp_net_sta_add (&cp, net, 0x0, 0x2);
- test_fail_if (sta2 == NULL);
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cp_sta_t *sta2;
+ cp_sta_t *ucco;
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+
+ sta = cp_net_sta_add (&cp, net, 0, 3);
+ cp_net_set_ucco (&cp, net, sta);
+
+ sta2 = cp_net_sta_add (&cp, net, 0, 2);
cp_net_set_ucco (&cp, net, sta2);
- slab_release (sta2);
- sta2 = cp_net_get_ucco (&cp, net);
+ test_fail_if (sta == NULL);
+ test_fail_if (sta2 == NULL);
+ test_fail_if (cp_sta_get_tei (sta) != 0);
+ test_fail_if (cp_sta_get_tei (sta2) != 0);
+ test_fail_if (cp_sta_get_cco_status (sta) == true);
test_fail_if (cp_sta_get_cco_status (sta2) == false);
- test_fail_if (cp_sta_get_cco_status (sta1) == true);
+ ucco = cp_net_get_ucco (&cp, net);
+ test_fail_if (ucco != sta2);
+
+ slab_release (sta);
+ slab_release (sta2);
+ slab_release (ucco);
+ cp_sta_mgr_uninit (&cp);
}
test_end;
- slab_release (sta1);
- slab_release (sta2);
- cp_sta_mgr_uninit (&cp);
+}
- cp_sta_mgr_init (&cp);
- net = cp_sta_mgr_get_our_avln (&cp);
- test_begin (test, "NET with CCo and UCCo")
+void
+test_case_cp_net_sta_authenticated (test_t test)
+{
+ test_case_begin (test, "Authenticated");
+
+ test_begin (test, "one sta")
{
- sta1 = cp_net_sta_add (&cp, net, 0x1, 0x1);
- sta2 = cp_net_sta_add (&cp, net, 0x0, 0x2);
- test_fail_if (sta2 == NULL);
+ cp_t cp;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ mac_config_t mac_config;
+ cl_t cl;
+ sar_t sar;
- cp_net_set_cco (&cp, net, 0x1);
- cp_net_set_ucco (&cp, net, sta2);
+ cl.mactotei = NULL;
- test_fail_if (cp_sta_get_cco_status (sta2) == false);
- test_fail_if (cp_sta_get_cco_status (sta1) == false);
+ cp.mac_store = mac_store_init ();
+ cp.mac_config = &mac_config;
+ cp.cl = &cl;
+ cp.sar = &sar;
+ sar.mac_store = cp.mac_store;
- slab_release (sta1);
- slab_release (sta2);
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
- sta1 = cp_net_get_cco (&cp, net);
- sta2 = cp_net_get_ucco (&cp, net);
+ sta = cp_net_sta_add (&cp, net, 1, 3);
+ cp_net_sta_set_authenticated (&cp, net, sta, true);
- test_fail_if (cp_sta_get_cco_status (sta2) == false);
- test_fail_if (cp_sta_get_cco_status (sta1) == false);
- test_fail_if (net->ucco != sta2);
- test_fail_if (net->cco != sta1);
+ test_fail_if (cp_net_sta_get_authenticated (&cp, net, sta) == false);
- cp_net_sta_remove (&cp, net, sta1);
- test_fail_if (cp_sta_get_cco_status (sta2) == false);
- test_fail_if (net->ucco != sta2);
- test_fail_if (net->cco != NULL);
+ cp_net_sta_set_authenticated (&cp, net, sta, false);
+ test_fail_if (cp_net_sta_get_authenticated (&cp, net, sta) == true);
- cp_net_sta_remove (&cp, net, sta2);
+ slab_release (sta);
- test_fail_if (net->ucco != NULL);
- test_fail_if (net->cco != NULL);
+ cp_sta_mgr_uninit (&cp);
+ mac_store_uninit (cp.mac_store);
}
test_end;
-
- slab_release (sta1);
- slab_release (sta2);
- cp_sta_mgr_uninit (&cp);
}
int
main (void)
{
test_t test;
- uint phy = 0;
- mac_config_t mac_config;
-
test_init (test, 0, NULL);
- mac_ntb_init ((phy_t*) &phy, &mac_config);
-
- test_case_network_add_unassoc_stations (test);
- test_case_network_add_assoc_stations (test);
- test_case_network_add_auth_stations (test);
- test_case_network_add_auth_stations_last_is_cco (test);
- test_case_network_add_auth_stations_last_is_pco (test);
- test_case_remove_stations (test);
- test_case_remove_sta_cco_station (test);
- test_case_remove_sta_pco_station (test);
- test_case_cco (test);
- test_case_pco (test);
- test_case_commit (test);
- test_case_add_twice_same_sta (test);
- test_case_garbage (test, (phy_t *) &phy);
- test_case_network_set_slot_id (test);
- test_case_network_get_num_discovered_sta (test);
- test_case_network_mode (test);
- test_case_sta_visible_status (test);
- test_case_get_sta_from_mac (test);
- test_case_net_empty (test);
- test_case_ucco (test);
- test_case_begin (test, "Memory allocation");
+ test_case_cp_net_init (test);
+ test_case_cp_net_uninit (test);
+ test_case_cp_net_garbage_stations (test);
+ test_case_cp_net_set_xco (test);
+ test_case_cp_net_sta_add (test);
+ test_case_cp_net_get_first (test);
+ test_case_cp_net_get_next (test);
+ test_case_cp_net_get_snid_nid (test);
+ test_case_cp_net_slot_usage (test);
+ test_case_cp_net_nm (test);
+ test_case_cp_net_sta_visible (test);
+ test_case_cp_net_is_empty (test);
+ test_case_cp_net_ucco (test);
+ test_case_cp_net_sta_authenticated (test);
+ test_case_begin (test, "Memory allocation");
test_begin (test, "memory leaks")
{
test_fail_if (blk_check_memory () != true, "Memory leaks");
@@ -1308,18 +916,3 @@ main (void)
return test_nb_failed (test) == 0 ? 0 : 1;
}
-/**
- * Create a phy_date weak function to do not have to include the phy on test
- * when it is not necessary.
- *
- * \param phy the phy context.
- * \return the phy date.
- */
-u32
-phy_date (phy_t *phy)
-{
- dbg_assert (phy);
-
- return *((uint*) phy);
-}
-
diff --git a/cesar/cp/sta/mgr/test/src/sar_stub.c b/cesar/cp/sta/mgr/test/src/sar_stub.c
new file mode 100644
index 0000000000..6999c04bd6
--- /dev/null
+++ b/cesar/cp/sta/mgr/test/src/sar_stub.c
@@ -0,0 +1,35 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/sar_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "mac/sar/sar.h"
+#include "mac/sar/inc/context.h"
+
+/**
+ * Remove a station from the SAR and the mac store.
+ * \param ctx the CP context.
+ * \param tei the station tei.
+ *
+ * Remove all the MFS from the expiration mechanism of the SAR and ends to
+ * remove the station from the mac store.
+ */
+void
+sar_sta_remove (sar_t *ctx, u8 tei)
+{
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_store);
+ dbg_assert (tei);
+
+ dbg_check (mac_store_sta_remove (ctx->mac_store, tei));
+}
diff --git a/cesar/cp/sta/mgr/test/src/sta-test.c b/cesar/cp/sta/mgr/test/src/sta-test.c
index fbc484f20a..711fe78933 100644
--- a/cesar/cp/sta/mgr/test/src/sta-test.c
+++ b/cesar/cp/sta/mgr/test/src/sta-test.c
@@ -21,372 +21,446 @@
#include "cp/inc/context.h"
#include "cp/sta/mgr/inc/sta_own_data.h"
-/**
- * Test the init of the module.
- *
- * \param test the test object.
- */
+#include "cl/inc/context.h"
+#include "mac/sar/inc/context.h"
+#include <string.h>
+
void
-test_case_sta_own_data_init (test_t test)
+test_case_cp_sta_own_data_init (test_t test)
{
- cp_t cp;
- cp_sta_own_data_private_t *data;
+ test_case_begin (test, "init");
- test_case_begin (test, "Station own data init");
+ test_begin (test, "init")
+ {
+ cp_t cp;
+ cp_sta_own_data_private_t cmp;
+ cp_sta_own_data_private_t *real;
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ memset (&cmp, 0, sizeof (cp_sta_own_data_private_t));
+ cmp.public.hybrid_mode = 0x2;
- test_begin (test, "Initialise")
- {
- /* Public data. */
- test_fail_if (data->public.nek_change_rtc != 0, "Wrong nek rtc");
- test_fail_if (data->public.cco_prefered != 0, "Wrong cco preferred");
- test_fail_if (data->public.hfid_avln[0] != 0, "Wrong hfid AVLN");
- test_fail_if (data->public.hfid_user[0] != 0, "Wrong hfid user");
- test_fail_if (data->public.hfid_manufacturer [0] != 0,
- "Wrong hfid manufacturer");
- test_fail_if (data->public.hybrid_mode != 2, "Wrong hybrid mode");
- test_fail_if (data->public.snid_track != 0, "Wrong snid track");
- test_fail_if (data->public.nid_track != 0, "Wrong nid track");
- test_fail_if (data->public.eks_current != 0, "Wrong EKS");
- test_fail_if (data->pco_glid != 0, "Wrong PCo status");
- test_fail_if (data->public.pco != 0, "Wrong Pco");
- test_fail_if (data->authenticated != false,
- "Wrong authenticated status");
-
- /* Private data. */
- test_fail_if (data->tei != 0, "Wrong tei");
- test_fail_if (data->mac_addr != 0, "Wrong Mac Address");
- test_fail_if (data->npw[0] != 0, "Wrong NPW");
- test_fail_if (data->nmk.key[0] != 0, "Wrong NMK");
- test_fail_if (data->dpw[0] != 0, "Wrong DPW");
- test_fail_if (data->was_cco != 0, "Wrong Was CCo");
- test_fail_if (data->security_level != 0, "Wrong Was SL");
+ cp_sta_mgr_init (&cp);
+
+ real = (cp_sta_own_data_private_t*) cp_sta_mgr_get_sta_own_data(&cp);
+ test_fail_if (
+ memcmp(&cmp, real, sizeof (cp_sta_own_data_private_t)) != 0);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
-/**
- * Test the set and get TEI procedure.
- *
- * \param test the test object.
- *
- * This function will test that the TEI is correctly stored in both ma config
- * and station own data.
- */
void
-test_case_sta_tei (test_t test)
+test_case_cp_sta_own_data__set_and_get_tei (test_t test)
{
- mac_config_t mac_config;
- cp_t cp;
- cp_sta_own_data_private_t *data;
+ test_case_begin (test, "Set Get tei");
- test_case_begin (test, "TEI");
+ test_begin (test, "Set")
+ {
+ cp_t cp;
+ cp_net_t *net;
+ mac_config_t mac_config;
+ cl_t cl;
+ sar_t sar;
- // initialise.
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ cp.mac_config = &mac_config;
+ cp_sta_mgr_init (&cp);
- // Add the mac config to the CP.
- cp.mac_config = &mac_config;
+ cp.cl = &cl;
+ cp.sar = &sar;
+ sar.mac_store = NULL;
+ cl.mactotei = NULL;
- mac_config.tei = 0xb;
- data->tei = 0xb;
+ // Add an AVLN.
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
- cp_sta_own_data_set_tei (&cp, 0xA);
+ cp_sta_own_data_set_tei (&cp, 2);
- test_begin (test, "verify data->stored")
- {
- test_fail_if (data->tei != 0xA, "Wrong tei");
- test_fail_if (mac_config.tei != 0xA, "Wrong tei");
- }
- test_end;
+ test_fail_if (cp_sta_own_data_get_tei (&cp) != 2);
- test_begin (test, "get the TEI with accessor")
- {
- test_fail_if (cp_sta_own_data_get_tei (&cp) !=
- 0xA, "Wrong tei");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
-/**
- * Test the set and get Mac Address procedure.
- *
- * \param test the test object.
- *
- * This function will test that the mac address is correctly stored in
- * both ma config and station own data.
- */
void
-test_case_sta_mac_address (test_t test)
+test_case_cp_sta_own_data__mac_address (test_t test)
{
- mac_config_t mac_config;
- mac_t mac_addr;
- cp_t cp;
- cp_sta_own_data_private_t *data;
-
test_case_begin (test, "Mac address");
- // initialise.
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ test_begin (test, "Set and Get the mac address")
+ {
+ cp_t cp;
- // Add the mac config to the CP.
- cp.mac_config = &mac_config;
+ mac_config_t mac_config;
+ cp.mac_config = &mac_config;
- mac_addr = 0x123456789abcull;
- mac_config.sta_mac_address = mac_addr;
- data->tei = mac_addr;
+ cp_sta_mgr_init (&cp);
+ cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
- mac_addr = 0x9876543210abull;
- cp_sta_own_data_set_mac_address (&cp, mac_addr);
+ test_fail_if (cp_sta_own_data_get_mac_address (&cp) !=
+ 0x123456789ABCull);
- test_begin (test, "verify data stored")
- {
- test_fail_if (data->mac_addr != mac_addr, "Wrong tei");
- test_fail_if (mac_config.sta_mac_address != mac_addr, "Wrong tei");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+}
- test_begin (test, "get the Mac address with accessor")
+void
+test_case_cp_sta_own_data__npw (test_t test)
+{
+ test_case_begin (test, "Set and get the NPW");
+
+ test_begin (test, "NPW")
{
- test_fail_if (cp_sta_own_data_get_mac_address (&cp) !=
- mac_addr, "Wrong Mac address");
+ cp_t cp;
+
+ cp_sta_mgr_init (&cp);
+ cp_sta_own_data_set_npw (&cp, "Hello world");
+
+ test_fail_if (
+ strcmp (cp_sta_own_data_get_npw (&cp), "Hello world") != 0);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
-/**
- * Test the set and get NPW procedure.
- *
- * \param test the test object.
- *
- * This function will test that the NPW is correctly stored in
- * station own data.
- */
void
-test_case_sta_npw (test_t test)
+test_case_cp_sta_own_data__nmk (test_t test)
{
- cp_t cp;
- u8 npw [CP_NPW_MAX_SIZE] = "HPAV_1.1\0";
- cp_sta_own_data_private_t *data;
+ test_case_begin (test, "Set and get the NMK");
- // initialise.
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ test_begin (test, "NMK")
+ {
+ cp_t cp;
+ cp_key_t key;
+ cp_key_t res;
- test_case_begin (test, "NPW");
+ key.key[0] = 0x1234;
+ key.key[1] = 0x5678;
+ key.key[2] = 0x9abc;
+ key.key[3] = 0xdef0;
- cp_sta_own_data_set_npw (&cp, (char*) npw);
+ cp_sta_mgr_init (&cp);
+ cp_sta_own_data_set_nmk (&cp, key);
- test_begin (test, "store of the NPW")
- {
- test_fail_if (memcmp(data->npw, npw, sizeof(npw)) != 0,
- "wrong NPW");
+ res = cp_sta_own_data_get_nmk (&cp);
+ test_fail_if (memcmp (&res, &key, sizeof (cp_key_t)) != 0);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+}
- test_begin (test, "get the NPW")
+void
+test_case_cp_sta_own_data__dpw (test_t test)
+{
+ test_case_begin (test, "Set and get the DPW");
+
+ test_begin (test, "DPW")
{
- test_fail_if (memcmp (
- (u8 *) cp_sta_own_data_get_npw(&cp),
- npw, sizeof (npw)) != 0, "Wrong NPW");
+ cp_t cp;
+
+ cp_sta_mgr_init (&cp);
+ cp_sta_own_data_set_dpw (&cp, "Hello world");
+
+ test_fail_if (
+ strcmp (cp_sta_own_data_get_dpw (&cp), "Hello world") != 0);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
-/**
- * Test the set and get NMK procedure.
- *
- * \param test the test object.
- *
- * This function will test that the NMK is correctly stored in
- * station own data.
- */
void
-test_case_sta_nmk (test_t test)
+test_case_cp_sta_own_data__security_level (test_t test)
{
- cp_t cp;
- cp_key_t nmk;
- cp_sta_own_data_private_t *data;
+ test_case_begin (test, "Set and get the SL");
- // initialise.
- cp_sta_own_data_init (&cp);
+ test_begin (test, "SL")
+ {
+ cp_t cp;
- test_case_begin (test, "NMK");
+ cp_sta_mgr_init (&cp);
+ cp_sta_own_data_set_security_level (&cp, CP_SECURITY_LEVEL_SC);
- nmk.key[0] = 0x5426;
- cp_sta_own_data_set_nmk (&cp, nmk);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ test_fail_if (cp_sta_own_data_get_security_level (&cp) !=
+ CP_SECURITY_LEVEL_SC);
- test_begin (test, "store of the NMK")
- {
- test_fail_if (data->nmk.key[0] != nmk.key[0],
- "wrong NMK");
+ cp_sta_own_data_set_security_level (&cp, CP_SECURITY_LEVEL_HS);
+
+ test_fail_if (cp_sta_own_data_get_security_level (&cp) !=
+ CP_SECURITY_LEVEL_HS);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+}
- test_begin (test, "get the NMK")
+void
+test_case_cp_sta_own_data__was_cco (test_t test)
+{
+ test_case_begin (test, "Set and get was_cco");
+
+ test_begin (test, "was_cco")
{
- test_fail_if (cp_sta_own_data_get_nmk(&cp).key[0] !=
- nmk.key[0], "Wrong NMK");
+ cp_t cp;
+
+ cp_sta_mgr_init (&cp);
+ cp_sta_own_data_set_was_cco (&cp, true);
+ test_fail_if (cp_sta_own_data_get_was_cco(&cp) != true);
+ cp_sta_own_data_set_was_cco (&cp, false);
+ test_fail_if (cp_sta_own_data_get_was_cco (&cp) != false);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+
}
-/**
- * Test the set and get DPW procedure.
- *
- * \param test the test object.
- *
- * This function will test that the DPW is correctly stored in
- * station own data.
- */
void
-test_case_sta_dpw (test_t test)
+test_case_cp_sta_own_data__hfid_avln (test_t test)
{
- cp_t cp;
- u8 dpw [CP_DPW_MAX_SIZE] = "HPAV_1.1\0";
- cp_sta_own_data_private_t *data;
+ test_case_begin (test, "Set and get the AVLN HFID");
- // initialise.
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ test_begin (test, "AVLN HFID")
+ {
+ cp_t cp;
+ cp_sta_own_data_t *sta;
- test_case_begin (test, "DPW");
+ cp_sta_mgr_init (&cp);
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_hfid_avln (&cp, "Hello world");
- cp_sta_own_data_set_dpw (&cp, (char*)dpw);
+ test_fail_if (
+ strcmp (sta->hfid_avln, "Hello world") != 0);
- test_begin (test, "store of the DPW")
- {
- test_fail_if (memcmp(data->dpw, dpw, sizeof(dpw)) != 0,
- "wrong DPW");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+}
+
+void
+test_case_cp_sta_own_data__hfid_user (test_t test)
+{
+ test_case_begin (test, "Set and get the USER HFID");
- test_begin (test, "get the DPW")
+ test_begin (test, "USER HFID")
{
- test_fail_if (memcmp (
- (u8 *) cp_sta_own_data_get_dpw(&cp),
- dpw, sizeof (dpw)) != 0, "Wrong NMK");
+ cp_t cp;
+ cp_sta_own_data_t *sta;
+
+ cp_sta_mgr_init (&cp);
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_hfid_user (&cp, "Hello world");
+
+ test_fail_if (
+ strcmp (sta->hfid_user, "Hello world") != 0);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
-/**
- * Test the security level APIs set and get.
- *
- * \param test the test object.
- */
void
-test_case_security_level (test_t test)
+test_case_cp_sta_own_data__hfid_manufacturer (test_t test)
{
- cp_t cp;
- uint sl;
- cp_sta_own_data_private_t *data;
-
- // initialise.
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ test_case_begin (test, "Set and get the MANUFACTURER HFID");
- test_case_begin (test, "SL");
+ test_begin (test, "MANUFACTURER HFID")
+ {
+ cp_t cp;
+ cp_sta_own_data_t *sta;
- data->security_level = 0xF;
- sl = 1;
+ cp_sta_mgr_init (&cp);
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_hfid_manufacturer (&cp, "Hello world");
- cp_sta_own_data_set_security_level (&cp, sl);
+ test_fail_if (
+ strcmp (sta->hfid_manufacturer, "Hello world") != 0);
- test_begin (test, "Security level storage")
- {
- test_fail_if (sl != data->security_level, "Wrong SL");
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+}
- test_begin (test, "get Security level")
+void
+test_case_cp_sta_own_data__pco_glid (test_t test)
+{
+ test_case_begin (test, "Set and get the PCO glid");
+
+ test_begin (test, "PCo")
{
- test_fail_if (sl != cp_sta_own_data_get_security_level(&cp),
- "Wrong SL");
+ cp_t cp;
+ cp_sta_own_data_t *sta;
+
+ cp_sta_mgr_init (&cp);
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_pco_glid (&cp, 0x70);
+ test_fail_if (cp_sta_own_data_get_pco_glid (&cp) != 0x70);
+ cp_sta_own_data_set_pco_glid (&cp, 0x0);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
-/**
- * Test the was CCo APIs set and get.
- *
- * \param test the test object.
- */
void
-test_case_was_cco (test_t test)
+test_case_cp_sta_own_data__pco_status (test_t test)
{
- cp_t cp;
- bool was_cco;
- cp_sta_own_data_private_t *data;
+ test_case_begin (test, "Set and get the PCO status");
- // initialise.
- cp_sta_own_data_init (&cp);
- data = (cp_sta_own_data_private_t *) cp_sta_mgr_get_sta_own_data (&cp);
+ test_begin (test, "PCo")
+ {
+ cp_t cp;
+ cp_sta_own_data_t *sta;
+
+ cp_sta_mgr_init (&cp);
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_pco_status (&cp, true);
+ test_fail_if (cp_sta_own_data_get_pco_status (&cp) != true);
+ cp_sta_own_data_set_pco_status (&cp, false);
+
+ cp_sta_mgr_uninit (&cp);
+ }
+ test_end;
- test_case_begin (test, "Was CCo");
+ test_begin (test, "PCo and glid")
+ {
+ cp_t cp;
+ cp_sta_own_data_t *sta;
- data->was_cco = false;
- was_cco = true;
+ cp_sta_mgr_init (&cp);
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_pco_status (&cp, true);
+ cp_sta_own_data_set_pco_glid (&cp, 0x45);
- cp_sta_own_data_set_was_cco (&cp, was_cco);
+ test_fail_if (cp_sta_own_data_get_pco_status (&cp) != true);
+ test_fail_if (cp_sta_own_data_get_pco_glid (&cp) != 0x45);
- test_begin (test, "Was CCo storage")
+ cp_sta_mgr_uninit (&cp);
+ }
+ test_end;
+}
+
+void
+test_case_cp_sta_own_data__cco_status (test_t test)
+{
+ test_case_begin (test, "Set and get the CCo status");
+
+ test_begin (test, "CCo")
{
- test_fail_if (was_cco != data->was_cco, "Wrong Was CCo status");
+ cp_t cp;
+ cp_net_t *net;
+ mac_config_t mac_config;
+ cp_sta_own_data_t *sta;
+ cl_t cl;
+ sar_t sar;
+
+ cp.mac_config = &mac_config;
+ cl.mactotei = NULL;
+ cp.cl = &cl;
+ cp.sar = &sar;
+ cp.mac_store = mac_store_init ();
+ sar.mac_store = cp.mac_store;
+
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
+
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_tei (&cp, 1);
+ cp_sta_own_data_set_cco_status (&cp, true);
+ test_fail_if (cp_sta_own_data_get_cco_status (&cp) != true);
+ cp_sta_own_data_set_cco_status (&cp, false);
+
+ cp_sta_mgr_uninit (&cp);
+ mac_store_uninit (cp.mac_store);
}
test_end;
+}
+
+void
+test_case_cp_sta_own_data__authenticated_status (test_t test)
+{
+ test_case_begin (test, "Set and get the CCo authenticated");
- test_begin (test, "get Security level")
+ test_begin (test, "CCo")
{
- test_fail_if (was_cco != cp_sta_own_data_get_was_cco (&cp),
- "Wrong Was cco status");
+ cp_t cp;
+ cp_net_t *net;
+ mac_config_t mac_config;
+ cp_sta_own_data_t *sta;
+ cl_t cl;
+ sar_t sar;
+
+ cp.mac_config = &mac_config;
+ cl.mactotei = NULL;
+ cp.cl = &cl;
+ cp.sar = &sar;
+ cp.mac_store = mac_store_init ();
+ sar.mac_store = cp.mac_store;
+
+ cp_sta_mgr_init (&cp);
+ net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
+
+ sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_tei (&cp, 1);
+ cp_sta_own_data_set_authenticated_status (&cp, true);
+ test_fail_if (cp_sta_own_data_get_authenticated_status (&cp) != true);
+
+ cp_sta_mgr_uninit (&cp);
+ mac_store_uninit (cp.mac_store);
}
test_end;
}
-/**
- * Test the is CCo APIs set and get.
- *
- * \param test the test object.
- */
void
-test_case_is_cco (test_t test)
+test_case_cp_sta_own_data__nid (test_t test)
{
- cp_t cp;
- cp_sta_own_data_t *data;
+ test_case_begin (test, "Set and GET NID");
- // initialise.
- cp_sta_own_data_init (&cp);
+ test_begin (test, "")
+ {
+ cp_t cp;
- test_case_begin (test, "Is CCo");
+ cp_sta_mgr_init (&cp);
- data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_cco_status (&cp, true);
+ cp_sta_own_data_set_nid (&cp, 0x12345);
+ test_fail_if (cp_sta_own_data_get_nid (&cp) != 0x12345);
+ cp_sta_own_data_set_nid (&cp, 0x12346);
+ test_fail_if (cp_sta_own_data_get_nid (&cp) != 0x12346);
- test_begin (test, "Is CCo storage")
- {
- test_fail_if (cp_sta_own_data_get_cco_status (&cp) == false);
- test_fail_if (((cp_sta_own_data_private_t*)data)->is_cco != true);
+ cp_sta_mgr_uninit (&cp);
}
test_end;
+}
- data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_cco_status (&cp, false);
+void
+test_case_cp_sta_own_data__snid (test_t test)
+{
+ test_case_begin (test, "Set and GET SNID");
- test_begin (test, "Is CCo storage")
+ test_begin (test, "")
{
- test_fail_if (cp_sta_own_data_get_cco_status (&cp) == true);
- test_fail_if (((cp_sta_own_data_private_t*)data)->is_cco != false);
+ cp_t cp;
+
+ cp_sta_mgr_init (&cp);
+
+ cp_sta_own_data_set_snid (&cp, 0x2);
+ test_fail_if (cp_sta_own_data_get_snid (&cp) != 0x2);
+ cp_sta_own_data_set_snid (&cp, 0x1);
+ test_fail_if (cp_sta_own_data_get_snid (&cp) != 0x1);
+
+ cp_sta_mgr_uninit (&cp);
}
test_end;
-
}
+
int
main (void)
{
@@ -394,15 +468,23 @@ main (void)
test_init (test, 0, NULL);
- test_case_sta_own_data_init (test);
- test_case_sta_tei (test);
- test_case_sta_mac_address (test);
- test_case_sta_npw (test);
- test_case_sta_nmk (test);
- test_case_sta_dpw (test);
- test_case_security_level (test);
- test_case_was_cco (test);
- test_case_is_cco (test);
+ test_case_cp_sta_own_data_init (test);
+ test_case_cp_sta_own_data__set_and_get_tei (test);
+ test_case_cp_sta_own_data__mac_address (test);
+ test_case_cp_sta_own_data__npw (test);
+ test_case_cp_sta_own_data__nmk (test);
+ test_case_cp_sta_own_data__dpw (test);
+ test_case_cp_sta_own_data__security_level (test);
+ test_case_cp_sta_own_data__was_cco (test);
+ test_case_cp_sta_own_data__hfid_avln (test);
+ test_case_cp_sta_own_data__hfid_user (test);
+ test_case_cp_sta_own_data__hfid_manufacturer (test);
+ test_case_cp_sta_own_data__pco_glid (test);
+ test_case_cp_sta_own_data__pco_status (test);
+ test_case_cp_sta_own_data__cco_status (test);
+ test_case_cp_sta_own_data__authenticated_status (test);
+ test_case_cp_sta_own_data__nid (test);
+ test_case_cp_sta_own_data__snid (test);
test_result (test);
return test_nb_failed (test) == 0 ? 0 : 1;
diff --git a/cesar/cp/sta/mgr/test/src/station_test.c b/cesar/cp/sta/mgr/test/src/station_test.c
index 88e314dbf1..23960afba6 100644
--- a/cesar/cp/sta/mgr/test/src/station_test.c
+++ b/cesar/cp/sta/mgr/test/src/station_test.c
@@ -38,8 +38,6 @@ test_case_station_init (test_t test)
test_case_begin (test, "Station init");
test_begin (test, "verify data")
{
-
-
slab_cache_init (&sta_slab_cache,
"Station cache",
sizeof (cp_sta_private_t),