summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormercadie2010-05-17 09:14:32 +0000
committermercadie2010-05-17 09:14:32 +0000
commit5e6de1250b1e23da48ae9ff6aae853bce0020a67 (patch)
tree0f96f6576aa0595453ce72c46fee4871efc2649d
parent355d09a7cfdec230b660ff10faebc7f2f9553dbe (diff)
cesar/cp/beacon: add update beacon data slot
- compose share memory for bsu only - manage share memory for bsu - remove old send beacon mechanism git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7024 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/cp/beacon/beacon.h34
-rw-r--r--cesar/cp/beacon/inc/beacon.h30
-rw-r--r--cesar/cp/beacon/src/beacon.c559
-rw-r--r--cesar/cp/beacon/stub/src/beacon.c16
-rwxr-xr-x[-rw-r--r--]cesar/cp/beacon/test/Makefile6
-rw-r--r--cesar/cp/beacon/test/override/cp/inc/context.h20
-rw-r--r--cesar/cp/beacon/test/src/beacon.c920
-rw-r--r--cesar/cp/beacon/test/src/bentry.c581
-rw-r--r--cesar/cp/beacon/test/src/bsu_stub.c17
-rw-r--r--cesar/cp/cco/action/src/cco_action.c4
-rw-r--r--cesar/cp/cco/action/test/src/status.c2
-rw-r--r--cesar/cp/cp.h1
-rw-r--r--cesar/cp/fsm/src/fsm/cp.fsm8
-rw-r--r--cesar/cp/inc/context.h20
-rw-r--r--cesar/cp/sta/action/src/poweron.c1
-rw-r--r--cesar/cp/sta/action/test/utest/src/beacon_stub.c9
16 files changed, 682 insertions, 1546 deletions
diff --git a/cesar/cp/beacon/beacon.h b/cesar/cp/beacon/beacon.h
index a6a93b4a43..1d66670e3e 100644
--- a/cesar/cp/beacon/beacon.h
+++ b/cesar/cp/beacon/beacon.h
@@ -21,6 +21,7 @@
#include "cp/beacon/beacon_desc.h"
#include "cp/sta/mgr/net.h"
+#include "beacon/beacon.h"
#define CP_BEACON_PERIOD_TIMER_OFFSET_TCK 10000
#define CP_BEACON_SIZE 136
@@ -42,35 +43,15 @@ void
cp_beacon_uninit (cp_t *ctx);
/**
- * Generate and send a beacon when the station acts as a CCo or Unassociated
- * CCo.
+ * Generate beacon data
* \param ctx the module context.
- * \param beacon_type The beacon type to send (central, discover or proxy).
- *
- */
-void
-cp_beacon_cco_send_beacon (cp_t *ctx, uint beacon_type);
-
-/**
- * Generate and send a discover beacon.
- * \param ctx the module context.
- *
*/
void
-cp_beacon_cco_send_central_beacon (cp_t *ctx);
-
-/**
- * Generate and send a discover beacon.
- * \param ctx the module context.
- *
- */
-void
-cp_beacon_cco_send_discover_beacon (cp_t *ctx);
+cp_beacon_update_beacon_data (cp_t *ctx);
/**
* Create default schedules and provide it to the Channel Access.
* \param ctx the module context.
- *
*/
void
cp_beacon_create_default_schedules (cp_t *ctx);
@@ -199,6 +180,15 @@ cp_beacon_reconfigure_timer (cp_t *ctx);
bool
cp_beacon_any_countdown_active (cp_t *ctx);
+/**
+ * Get the next beacon slot to update.
+ * \param ctx the control plane context.
+ * \return a pointer on the next slot.
+ */
+beacon_t *
+cp_get_next_beacon_slot(cp_t *ctx);
+
+
END_DECLS
#endif /* cp_beacon_beacon_h */
diff --git a/cesar/cp/beacon/inc/beacon.h b/cesar/cp/beacon/inc/beacon.h
index 56d17c0fd6..09104adb09 100644
--- a/cesar/cp/beacon/inc/beacon.h
+++ b/cesar/cp/beacon/inc/beacon.h
@@ -31,6 +31,27 @@
#define CP_BEACON_COUNTDOWN_HOIP CP_BEACON_COUNTDOWN_DEFAULT
#define CP_BEACON_COUNTDOWN_EKS CP_BEACON_COUNTDOWN_DEFAULT
+struct cp_beacon_discover_info_t
+{
+ /* Discover info data. */
+ BITFIELDS_WORD
+ (
+ u32 updated:1;,
+ u32 cco_cap:2;,
+ u32 proxy_net_cap:1;,
+ u32 backup_cco_cap:1;,
+ u32 cco_status:1;,
+ u32 pco_status:1;,
+ u32 backup_cco_status:1;,
+ u32 num_dis_sta:8;,
+ u32 num_dis_net:8;,
+ u32 authentication:1;,
+ u32 status_user_ap_cco:1;,
+ u32 rsvd:6;
+ )
+};
+typedef struct cp_beacon_discover_info_t cp_beacon_discover_info_t;
+
struct cp_beacon_snid_t
{
/** The new SNID of the AVLN. */
@@ -103,7 +124,7 @@ struct cp_beacon_t
/**
* Discover process use by the CCo. */
cp_beacon_discover_t discover;
- cp_beacon_bentry_discover_info_t discover_info_last;
+ cp_beacon_discover_info_t discover_info_last;
/** Snid countdown structure. */
struct cp_beacon_snid_t snids;
@@ -119,4 +140,11 @@ struct cp_beacon_t
};
typedef struct cp_beacon_t cp_beacon_t;
+BEGIN_DECLS
+
+beacon_t *
+cp_beacon_fill_share_memory (cp_t *ctx);
+
+END_DECLS
+
#endif /* cp_beacon_inc_beacon_h */
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 1f369f2685..b8b698f602 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -36,36 +36,176 @@
#include "cp/inc/context.h"
#include "cp/inc/trace.h"
#include "hal/gpio/gpio.h"
+#include "beacon/beacon.h"
+#include "bsu/bsu.h"
-/**
- * Compare the discover info bentry with the previous one.
- * \param disc1 discover bentry one.
- * \param disc2 discover bentry two.
- * \return true if different.
- */
-static inline bool
-cp_beacon_discover_info_struct_updated (
- cp_beacon_bentry_discover_info_t *disc1,
- cp_beacon_bentry_discover_info_t *disc2)
+
+beacon_t *
+cp_beacon_fill_share_memory (cp_t *ctx)
{
- dbg_assert (disc1);
- dbg_assert (disc2);
-
- if ((disc1->cco_cap == disc2->cco_cap)
- && (disc1->proxy_net_cap == disc2->proxy_net_cap)
- && (disc1->backup_cco_cap == disc2->backup_cco_cap)
- && (disc1->cco_status == disc2->cco_status)
- && (disc1->pco_status == disc2->pco_status)
- && (disc1->backup_cco_status == disc2->backup_cco_status)
- && (disc1->num_dis_sta == disc2->num_dis_sta)
- && (disc1->num_dis_net == disc2->num_dis_net)
- && (disc1->authentication == disc2->authentication)
- && (disc1->status_user_ap_cco == disc2->status_user_ap_cco))
+ beacon_t *beacon;
+ cp_sta_own_data_t *sta;
+ cp_net_t *net = NULL;
+ uint nb, ns;
+
+ beacon = cp_get_next_beacon_slot (ctx);
+ dbg_assert (beacon);
+
+ sta = cp_sta_mgr_get_sta_own_data (ctx);
+ if (cp_sta_own_data_get_tei (ctx))
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ beacon->vf.nid = cp_sta_own_data_get_nid (ctx);
+ beacon->vf.hm = sta->hybrid_mode;
+ beacon->vf.ncnr = CP_BEACON_NON_COORDINATED_NETWORK;
+ beacon->vf.npsm = CP_BEACON_NPSM_NOT_ACTIVE;
+ beacon->vf.numslots = 1;
+ beacon->vf.slotusage = cp_sta_mgr_get_slot_usage (ctx);
+ beacon->vf.slotid = net == NULL ? 0 : cp_net_get_slot_id (ctx, net);
+ beacon->vf.aclsss = 0;
+ beacon->vf.hoip = ctx->beacon.hoip.hoip_flag;
+ beacon->vf.rstbf = false;
+ beacon->vf.nm = CP_BEACON_NM_CSMA_ONLY;
+ beacon->vf.ccocap = CP_CCO_LEVEL;
+
+ /* regions. */
+ cp_cco_region_alloc_t *region;
+
+ for (nb = 0, region = cp_cco_region_alloc_get_first (ctx,
+ &ctx->region.region_list);
+ region;
+ region = cp_cco_region_alloc_get_next (ctx,
+ &ctx->region.region_list, region),
+ nb++)
+ {
+ beacon->bmis.region.region[nb].rt = region->type;
+ beacon->bmis.region.region[nb].end_time_atu = region->end_time_atu;
+ }
+ beacon->bmis.region.nb = nb;
+
+ /* Store the persistent schedules. */
+ uint sched_id = 0;
+ cp_cco_bw_alloc_t *sched;
+
+ for (nb = 0; nb < 8; nb++)
+ {
+ for (ns = 0, sched = cp_cco_bw_alloc_get_first_persistent (ctx,
+ &ctx->bw.alloc_list, nb);
+ sched;
+ sched = cp_cco_bw_alloc_get_next_persistent (ctx,
+ &ctx->bw.alloc_list, sched),
+ ns++)
+ {
+ dbg_assert (sched_id < BSU_BEACON_BMI_PERSISTENT_SCHEDULE_MAX);
+
+ beacon->bmis.ps.ps[sched_id].sais[ns].stpf = sched->stpf;
+ beacon->bmis.ps.ps[sched_id].sais[ns].glid = sched->glid;
+ beacon->bmis.ps.ps[sched_id].sais[ns].start_time_atu =
+ sched->start_time_atu;
+ beacon->bmis.ps.ps[sched_id].sais[ns].end_time_atu =
+ sched->end_time_atu;
+
+ if (ns == 0)
+ {
+ beacon->bmis.ps.ps[sched_id].pscd = sched->pscd;
+ beacon->bmis.ps.ps[sched_id].cscd = sched->cscd;
+ }
+ }
+
+ if (ns)
+ {
+ beacon->bmis.ps.ps[sched_id].ns = ns;
+ sched_id++;
+ }
+ }
+ beacon->bmis.ps.nb = sched_id;
+
+ /* Store the not persistent schedules. */
+ for (ns = 0, sched = cp_cco_bw_alloc_get_first_with_persistence (ctx,
+ &ctx->bw.alloc_list,
+ CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT);
+ sched;
+ sched = cp_cco_bw_alloc_get_next_with_persistence (ctx,
+ &ctx->bw.alloc_list, sched),
+ ns++)
+ {
+ dbg_assert (ns < BSU_BEACON_BMIS_SCHEDULES_SAI_MAX);
+ beacon->bmis.nps.sais[ns].stpf = sched->stpf;
+ beacon->bmis.nps.sais[ns].glid = sched->glid;
+ beacon->bmis.nps.sais[ns].start_time_atu = sched->start_time_atu;
+ beacon->bmis.nps.sais[ns].end_time_atu = sched->end_time_atu;
+ }
+ beacon->bmis.nps.ns = ns;
+
+ uint tei;
+ if (cp_beacon_discover_need_to_request (ctx, &tei))
+ {
+ beacon->bmis.discover.present = true;
+ beacon->bmis.discover.tei = tei;
+ }
+
+ cp_beacon_discover_info_t discover_info;
+
+ discover_info.updated = ctx->beacon.discover_info_last.updated;
+ discover_info.cco_cap = CP_CCO_LEVEL;
+ discover_info.proxy_net_cap = CP_PCO_CAP;
+ discover_info.backup_cco_cap = CP_BACKUP_CCO_CAP;
+ discover_info.cco_status = cp_sta_own_data_get_cco_status (ctx);
+ discover_info.pco_status = cp_sta_own_data_get_pco_status (ctx);
+ discover_info.backup_cco_status = false;
+ discover_info.num_dis_sta = cp_sta_mgr_get_num_discovered_stas (ctx);
+ discover_info.num_dis_net = cp_sta_mgr_get_num_discovered_net (ctx);
+ discover_info.authentication = cp_sta_own_data_get_authenticated_status (ctx);
+ discover_info.status_user_ap_cco = false;
+ discover_info.rsvd = 0;
+
+ discover_info.updated = (*((u32*)&ctx->beacon.discover_info_last) !=
+ *((u32*)&discover_info));
+
+ beacon->bmis.discover_info.info_data = *((u32*)&discover_info);
+ *((u32*)&ctx->beacon.discover_info_last) = *((u32*)&discover_info);
+
+ beacon->bmis.discover_info.present = true;
+
+ /* If the EKS countdown is not 0. */
+ if (ctx->beacon.eks.kccd)
+ {
+ beacon->bmis.eks.present = true;
+ beacon->bmis.eks.kccd = ctx->beacon.eks.kccd;
+ beacon->bmis.eks.kbc = ctx->beacon.eks.kbc;
+ beacon->bmis.eks.new_eks = ctx->beacon.eks.new_eks;
+ }
+
+ /* If the handover countdown is not 0. */
+ if (ctx->beacon.hoip.hoipcd)
{
- return false;
+ beacon->bmis.handover.present = true;
+ beacon->bmis.handover.hcd = ctx->beacon.hoip.hoipcd;
+ beacon->bmis.handover.tei = ctx->beacon.hoip.cco;
}
- return true;
+ /* If the hybrid mode countdown is not 0. */
+ if (ctx->beacon.hm.hmcd)
+ {
+ beacon->bmis.change_hm.present = true;
+ beacon->bmis.change_hm.hmccd = ctx->beacon.hm.hmcd;
+ beacon->bmis.change_hm.newhm = ctx->beacon.hm.hm;
+ }
+
+ /* If the snid countdown is not 0. */
+ if (ctx->beacon.snids.snidcd)
+ {
+ beacon->bmis.change_snid.present = true;
+ beacon->bmis.change_snid.snidccd = ctx->beacon.snids.snidcd;
+ beacon->bmis.change_snid.new_snid = ctx->beacon.snids.snid;
+ }
+
+ beacon->bmis.bpsto.present = false;
+ beacon->bmis.relocation.present = false;
+ beacon->bmis.aclsc.present = false;
+ beacon->bmis.cns.present = false;
+
+ return beacon;
}
/** Timer expires.
@@ -80,6 +220,18 @@ cp_beacon_timer_expires (cp_t *ctx)
cp_fsm_post_urgent_new_event (ctx, bare, BEACON_TIMER_EXPIRES);
}
+beacon_t *
+cp_get_next_beacon_slot(cp_t *ctx)
+{
+ ctx->shared_mem_slot_id++;
+ ctx->shared_mem_slot_id %= CP_SHARED_MEM_SLOT_NB;
+
+ memset(&ctx->shared_mem[ctx->shared_mem_slot_id].bsu, 0,
+ sizeof (beacon_t));
+
+ return &ctx->shared_mem[ctx->shared_mem_slot_id].bsu;
+}
+
/**
* The beacon received from the AVLN.
* \param ctx the module context.
@@ -111,127 +263,6 @@ cp_beacon_receive (cp_t *ctx, cp_beacon_desc_t * beacon)
}
/**
- * Fill the unpack structure to send a beacon.
- * \param ctx the module context.
- * \param unpack the unpack structure.
- * \param schedules the schedule set for the CA.
- * \param beacon_type the beacon type.
- */
-void
-cp_beacon__cco__unpack_fill (cp_t *ctx, cp_beacon_unpack_t *unpack,
- uint beacon_type)
-{
- cp_nid_t nid;
- cp_sta_own_data_t *sta;
- cp_net_t *net = NULL;
-
- dbg_assert (ctx);
- dbg_assert (unpack);
-
- nid = cp_sta_own_data_get_nid (ctx);
- sta = cp_sta_mgr_get_sta_own_data (ctx);
- if (cp_sta_own_data_get_tei (ctx))
- net = cp_sta_mgr_get_our_avln (ctx);
-
- dbg_assert (((unpack->variant_fields.stei == MAC_TEI_UNASSOCIATED)
- && (unpack->variant_fields.bt == CP_BEACON_CENTRAL_BEACON))
- || (MAC_TEI_IS_STA (unpack->variant_fields.stei))
- || ((unpack->variant_fields.stei == MAC_TEI_UNASSOCIATED)
- && (unpack->variant_fields.bt == CP_BEACON_CENTRAL_BEACON)));
-
- unpack->variant_fields.nid_lsb = nid & BITS_ONES (32);
- unpack->variant_fields.nid_msb = nid >> 32;
- unpack->variant_fields.hm = sta->hybrid_mode;
- unpack->variant_fields.stei = cp_sta_own_data_get_tei (ctx);
- unpack->variant_fields.bt = beacon_type;
- unpack->variant_fields.ncnr = CP_BEACON_NON_COORDINATED_NETWORK;
- unpack->variant_fields.npsm = CP_BEACON_NPSM_NOT_ACTIVE;
- unpack->variant_fields.num_slots = 1;
- unpack->variant_fields.slot_usage = cp_sta_mgr_get_slot_usage (ctx);
- unpack->variant_fields.slot_id = net == NULL ? 0 : cp_net_get_slot_id (ctx, net);
- unpack->variant_fields.aclss = 0;
- unpack->variant_fields.hoip = ctx->beacon.hoip.hoip_flag;
- unpack->variant_fields.rtsbf = false;
- unpack->variant_fields.nm = CP_BEACON_NM_CSMA_ONLY;
- unpack->variant_fields.cco_cap = CP_CCO_LEVEL;
-
- unpack->bmis.regions.present = true;
- unpack->bmis.schedules.present = true;
- unpack->bmis.mac_address.present = true;
- unpack->bmis.mac_address.mac_addr = cp_sta_own_data_get_mac_address (ctx);
- unpack->bmis.bpsto.present = true;
-
- if (beacon_type == CP_BEACON_DISCOVER_BEACON)
- {
- unpack->bmis.discover_info.present = true;
- unpack->bmis.discover_info.cco_cap = CP_CCO_LEVEL;
- unpack->bmis.discover_info.proxy_net_cap = CP_PCO_CAP;
- unpack->bmis.discover_info.backup_cco_cap = CP_BACKUP_CCO_CAP;
- unpack->bmis.discover_info.cco_status =
- cp_sta_own_data_get_cco_status(ctx);
- unpack->bmis.discover_info.pco_status =
- cp_sta_own_data_get_pco_status(ctx);
- unpack->bmis.discover_info.backup_cco_status = false;
- unpack->bmis.discover_info.num_dis_sta =
- cp_sta_mgr_get_num_discovered_stas (ctx);
- unpack->bmis.discover_info.num_dis_net =
- cp_sta_mgr_get_num_discovered_stas (ctx);
- unpack->bmis.discover_info.authentication =
- cp_sta_own_data_get_authenticated_status(ctx);
- unpack->bmis.discover_info.status_user_ap_cco = false;
-
- /* Verify if the current data are the same as the last one sent. */
- unpack->bmis.discover_info.updated =
- cp_beacon_discover_info_struct_updated (
- &unpack->bmis.discover_info,
- &ctx->beacon.discover_info_last);
- ctx->beacon.discover_info_last = unpack->bmis.discover_info;
- }
-
- /* If the unpack is a central one, check if a discover beacon is can be
- * requested to a station. */
- if ((beacon_type == CP_BEACON_CENTRAL_BEACON)
- && (cp_beacon_discover_need_to_request (ctx,
- &unpack->bmis.discover.tei)))
- {
- unpack->bmis.discover.present = true;
- }
-
- /* If the snid countdown is not 0. */
- if (ctx->beacon.snids.snidcd)
- {
- unpack->bmis.snids.present = true;
- unpack->bmis.snids.snid_cd = ctx->beacon.snids.snidcd;
- unpack->bmis.snids.snid = ctx->beacon.snids.snid;
- }
-
- /* If the hybrid mode countdown is not 0. */
- if (ctx->beacon.hm.hmcd)
- {
- unpack->bmis.hm.present = true;
- unpack->bmis.hm.hmcd = ctx->beacon.hm.hmcd;
- unpack->bmis.hm.hm = ctx->beacon.hm.hm;
- }
-
- /* If the handover countdown is not 0. */
- if (ctx->beacon.hoip.hoipcd)
- {
- unpack->bmis.hoip.present = true;
- unpack->bmis.hoip.hoipcd = ctx->beacon.hoip.hoipcd;
- unpack->bmis.hoip.cco = ctx->beacon.hoip.cco;
- }
-
- /* If the EKS countdown is not 0. */
- if (ctx->beacon.eks.kccd)
- {
- unpack->bmis.eks.present = true;
- unpack->bmis.eks.kbc = ctx->beacon.eks.kbc;
- unpack->bmis.eks.kccd = ctx->beacon.eks.kccd;
- unpack->bmis.eks.new_eks = ctx->beacon.eks.new_eks;
- }
-}
-
-/**
* Describe the current allocation for the Channel access schedule.
* \param ctx the module context.
* \param sched the CA schedule.
@@ -378,73 +409,6 @@ cp_beacon_sta_compute_schedules (cp_t *ctx,
}
/**
- * Send the beacon over the PWL.
- * TODO Implement the proxy beacon part
- *
- * \param ctx the cp beacon context
- * \param beacon the beacon to send
- * \param beacon_type the beacon type.
- * \param mac_address the station own mac address.
- */
-static void
-cp_beacon_send_beacon (cp_t *ctx, cp_beacon_desc_t *beacon,
- uint beacon_type, mac_t mac_address)
-{
- bool added;
- cp_beacon_common_t *common;
-
- dbg_assert (ctx);
- dbg_assert (ctx->ca);
- dbg_assert (beacon);
-
- /* Create the MFS
- * see http://pessac/cesar/trac/wiki/SoftMacBeacons#BeaconMFS
- * for more details.
- */
- switch (beacon_type)
- {
- case CP_BEACON_CENTRAL_BEACON:
- common = &ctx->beacon.common[0];
- dbg_assert (ctx->mac_store);
- common->mfs = mac_store_mfs_add_tx (ctx->mac_store, true,
- false,
- MAC_LID_SPC_CENTRAL,
- MAC_TEI_BCAST, &added);
- break;
- case CP_BEACON_DISCOVER_BEACON:
- common = &ctx->beacon.common[1];
- dbg_assert (ctx->mac_store);
- common->mfs = mac_store_mfs_add_tx (ctx->mac_store, true,
- false,
- MAC_LID_DISCOVER,
- MAC_TEI_BCAST, &added);
- break;
- default:
- dbg_assert_default ();
- }
-
- if (added)
- {
- common->mfs->cap = 0x3;
- blk_addref (common->mfs);
- common->mfs->beacon = true;
- common->mfs->common.ats = false;
-
- // Add the MFS to the CA
- blk_addref (common->mfs);
- ca_mfs_add (ctx->ca, common->mfs);
- }
-
- ca_mfs_hold (ctx->ca, common->mfs);
- dbg_assert (ctx->interface);
- interface_beacon_prepare (ctx->interface, (pb_beacon_t *)
- beacon, common->mfs,
- &common->bpsto);
-
- blk_release (common->mfs);
-}
-
-/**
* Update the station in the station manager with the data contained in the
* beacon.
* \param ctx the module context.
@@ -477,7 +441,7 @@ cp_beacon_update_sta_peer (cp_t *ctx,
dbg_assert (sta);
/* Is the station UCCo. */
- if ((unpack->variant_fields.bt == CP_BEACON_DISCOVER_BEACON)
+ if ((bt == CP_BEACON_DISCOVER_BEACON)
&& (unpack->variant_fields.stei == MAC_TEI_UNASSOCIATED))
{
cp_net_set_ucco (ctx, net, sta);
@@ -516,60 +480,6 @@ cp_beacon_update_sta_peer (cp_t *ctx,
return sta;
}
-/** Generate and send a discover beacon from the central or proxy beacon.
- * \param ctx the CP context.
- * \param unpack the unpack structure.
- */
-static void
-cp_beacon_sta_send_discover_beacon (cp_t *ctx, cp_beacon_unpack_t *unpack)
-{
- cp_beacon_desc_t *beacon;
- dbg_assert (ctx);
- dbg_assert (unpack);
-
- unpack->variant_fields.stei = cp_sta_own_data_get_tei (ctx);
- unpack->variant_fields.bt = CP_BEACON_DISCOVER_BEACON;
-
- /* Mac address. */
- unpack->bmis.mac_address.present = true;
- unpack->bmis.mac_address.mac_addr = cp_sta_own_data_get_mac_address (ctx);
-
- /* discover info bentry. */
- unpack->bmis.discover_info.present = true;
- unpack->bmis.discover_info.cco_cap = CP_CCO_LEVEL;
- unpack->bmis.discover_info.proxy_net_cap = CP_PCO_CAP;
- unpack->bmis.discover_info.backup_cco_cap = CP_BACKUP_CCO_CAP;
- unpack->bmis.discover_info.cco_status =
- cp_sta_own_data_get_cco_status (ctx);
- unpack->bmis.discover_info.pco_status =
- cp_sta_own_data_get_pco_status(ctx);
- unpack->bmis.discover_info.backup_cco_status = false;
- unpack->bmis.discover_info.num_dis_sta =
- cp_sta_mgr_get_num_discovered_stas (ctx);
- unpack->bmis.discover_info.num_dis_net =
- cp_sta_mgr_get_num_discovered_net (ctx);
- unpack->bmis.discover_info.authentication =
- cp_sta_own_data_get_authenticated_status(ctx);
- unpack->bmis.discover_info.status_user_ap_cco = false;
-
- /* Verify if the current data are the same as the last one sent. */
- unpack->bmis.discover_info.updated =
- cp_beacon_discover_info_struct_updated (&unpack->bmis.discover_info,
- &ctx->beacon.discover_info_last);
- ctx->beacon.discover_info_last = unpack->bmis.discover_info;
-
- /* Generate the beacon and send. */
- beacon = cp_beacon_unpack__pack (ctx, unpack);
-
- if (unpack->bmis.bpsto.present)
- ctx->beacon.common[unpack->variant_fields.bt].bpsto.bpsto =
- unpack->bmis.bpsto.bpsto_addr;
- cp_beacon_send_beacon (ctx, beacon, CP_BEACON_DISCOVER_BEACON,
- cp_sta_own_data_get_mac_address (ctx));
-
- CP_TRACE (BEACON_BEACON_SEND, phy_date (), CP_BEACON_DISCOVER_BEACON);
-}
-
/**
* Countdown decrement and process the necessary data.
* \param ctx the CP context.
@@ -714,29 +624,12 @@ cp_beacon_uninit (cp_t *ctx)
}
void
-cp_beacon_cco_send_beacon (cp_t *ctx, uint beacon_type)
+cp_beacon_update_beacon_data (cp_t *ctx)
{
- uint i;
- cp_beacon_common_t *common;
- cp_beacon_unpack_t beacon;
- cp_beacon_desc_t *beacon_real;
-
dbg_assert (ctx);
- dbg_assert (beacon_type < CP_BEACON_TYPE_NB);
- // Beacon generated. Provide it to the CA.
- common = &ctx->beacon.common[beacon_type];
cp_beacon_countdowns (ctx);
- /* Initialise the unpack structure. */
- cp_beacon_unpack_init (&beacon, &ctx->bw.alloc_list,
- &ctx->region.region_list);
- cp_beacon__cco__unpack_fill (ctx, &beacon, beacon_type);
-
- // Compute the PWL beacon period.
- cp_pwl__tracker__compute_beacon_period_start_time_ntb (ctx);
- cp_beacon_compute_ca_schedules (ctx);
-
// Program the timer to awake and send another central beacon.
hal_timer_instance_cancel (ctx->hal_timer, &ctx->beacon.leon_timer);
hal_timer_instance_program (ctx->hal_timer, &ctx->beacon.leon_timer,
@@ -744,96 +637,14 @@ cp_beacon_cco_send_beacon (cp_t *ctx, uint beacon_type)
CP_TRACE_VERBOSE (BEACON_TIMER_PRGM, phy_date (),
cp_pwl_get_next_timer_date (ctx, true));
- common->nb_beacon_sent ++;
- beacon_real = cp_beacon_unpack__pack (ctx, &beacon);
-
- if (beacon.bmis.bpsto.present)
- ctx->beacon.common[beacon.variant_fields.bt].bpsto.bpsto =
- beacon.bmis.bpsto.bpsto_addr;
-
- for (i = 0; i < CP_PWL_BTO_NB; i++)
- common->bpsto.bto[i] = ctx->pwl.bto[i];
-
- cp_beacon_send_beacon (ctx, beacon_real, beacon_type,
- cp_sta_own_data_get_mac_address (ctx));
-
- /* If the CCo has been choose to send the discover beacon. */
- if ((beacon.bmis.discover.tei == cp_sta_own_data_get_tei (ctx))
- && (beacon_type == CP_BEACON_CENTRAL_BEACON))
- {
- uint i;
- /* Remove the discover bentry.*/
- beacon.bmis.discover.present = false;
- beacon.variant_fields.bt = CP_BEACON_DISCOVER_BEACON;
-
- beacon.bmis.discover_info.present = true;
- beacon.bmis.discover_info.cco_cap = CP_CCO_LEVEL;
- beacon.bmis.discover_info.proxy_net_cap = CP_PCO_CAP;
- beacon.bmis.discover_info.backup_cco_cap = CP_BACKUP_CCO_CAP;
- beacon.bmis.discover_info.cco_status =
- cp_sta_own_data_get_cco_status(ctx);
- beacon.bmis.discover_info.pco_status =
- cp_sta_own_data_get_pco_status(ctx);
- beacon.bmis.discover_info.backup_cco_status = false;
- beacon.bmis.discover_info.num_dis_sta =
- cp_sta_mgr_get_num_discovered_stas (ctx);
- beacon.bmis.discover_info.num_dis_net =
- cp_sta_mgr_get_num_discovered_stas (ctx);
- beacon.bmis.discover_info.authentication =
- cp_sta_own_data_get_authenticated_status(ctx);
- beacon.bmis.discover_info.status_user_ap_cco = false;
-
- beacon_real = cp_beacon_unpack__pack (ctx, &beacon);
- if (beacon.bmis.bpsto.present)
- ctx->beacon.common[beacon.variant_fields.bt].bpsto.bpsto =
- beacon.bmis.bpsto.bpsto_addr;
-
- // Copy the BTOs.
- for (i = 0; i < CP_PWL_BTO_NB; i++)
- {
- ctx->beacon.common[beacon.variant_fields.bt].bpsto.bto[i] =
- ctx->pwl.bto[i];
- }
-
- cp_beacon_send_beacon (ctx, beacon_real, CP_BEACON_DISCOVER_BEACON,
- cp_sta_own_data_get_mac_address (ctx));
- }
-
+ /* Generate the beacon and send. */
+ beacon_t *beacon = cp_beacon_fill_share_memory (ctx);
+ bsu_update (beacon, cp_sta_own_data_get_cco_status (ctx));
GPIO_TOGGLE (LED_BEACON_TX_RX);
- cp_beacon_unpack_uninit (ctx, &beacon);
CP_TRACE_VERBOSE (BEACON_BEACON_SEND, phy_date (), beacon_type);
}
-/**
- * Generate and send a discover beacon.
- * \param ctx the module context.
- *
- */
-void
-cp_beacon_cco_send_central_beacon (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- cp_beacon_cco_send_beacon (ctx,
- CP_BEACON_CENTRAL_BEACON);
-}
-
-/**
- * Generate and send a discover beacon.
- * \param ctx the module context.
- *
- */
-void
-cp_beacon_cco_send_discover_beacon (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- cp_beacon_cco_send_beacon (ctx,
- CP_BEACON_DISCOVER_BEACON);
-}
-
-
void
cp_beacon_create_default_schedules (cp_t *ctx)
{
@@ -1025,10 +836,6 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
ctx->beacon.eks.new_eks = unpack.bmis.eks.new_eks;
}
- /* If the CCo request the station to send a discover beacon. */
- if (cp_sta_own_data_get_tei (ctx) == unpack.bmis.discover.tei)
- cp_beacon_sta_send_discover_beacon (ctx, &unpack);
-
cp_beacon_ntb_clk_sync(ctx, beacon->payload->fc.bts,
beacon->payload->fc.preamble_sysdate,
beacon->payload->fc.preamble_date);
@@ -1101,8 +908,6 @@ cp_beacon_process_central_read_regions (cp_t *ctx, cp_beacon_desc_t *beacon,
dbg_assert (beacon_vf);
}
-
-
/**
* Process a tracked network using the central beacon or the proxy beacon.
* \param ctx the CP module context.
diff --git a/cesar/cp/beacon/stub/src/beacon.c b/cesar/cp/beacon/stub/src/beacon.c
index dcfd30fd1c..9d0c1fbe02 100644
--- a/cesar/cp/beacon/stub/src/beacon.c
+++ b/cesar/cp/beacon/stub/src/beacon.c
@@ -29,22 +29,10 @@ void
cp_beacon_uninit (cp_t *ctx){}
void
-cp_beacon_cco_send_beacon (cp_t *ctx, uint beacon_type) __attribute__((weak));
+cp_beacon_update_beacon_data (cp_t *ctx) __attribute__((weak));
void
-cp_beacon_cco_send_beacon (cp_t *ctx, uint beacon_type){}
-
-void
-cp_beacon_cco_send_central_beacon (cp_t *ctx) __attribute__((weak));
-
-void
-cp_beacon_cco_send_central_beacon (cp_t *ctx){}
-
-void
-cp_beacon_cco_send_discover_beacon (cp_t *ctx) __attribute__((weak));
-
-void
-cp_beacon_cco_send_discover_beacon (cp_t *ctx){}
+cp_beacon_update_beacon_data (cp_t *ctx){}
void
cp_beacon_create_default_schedules (cp_t *ctx) __attribute__((weak));
diff --git a/cesar/cp/beacon/test/Makefile b/cesar/cp/beacon/test/Makefile
index 7bb5c60f02..2dc21af092 100644..100755
--- a/cesar/cp/beacon/test/Makefile
+++ b/cesar/cp/beacon/test/Makefile
@@ -7,7 +7,7 @@ ECOS = y
TARGET_PROGRAMS = beacon bentry discover_process schedules
beacon_SOURCES = beacon.c \
- ca_stub.c ntb_stub.c secu_stub.c
+ ca_stub.c ntb_stub.c secu_stub.c bsu_stub.c
beacon_MODULES = lib cp/beacon cp/sta/mgr mac/common cp/cco/bw \
cp/pwl cp/cco/region \
cp/fsm/stub cp/cco/action/stub hal/timer/stub \
@@ -22,7 +22,7 @@ bentry_MODULES = lib cp/beacon cp/sta/mgr mac/common cp/cco/bw \
cp/sta/core/stub mac/sar/stub cl/stub cp/fsm/stub
discover_process_SOURCES = discover.c ntb_stub.c \
- interface_stub.c ca_stub.c secu_stub.c
+ interface_stub.c ca_stub.c secu_stub.c bsu_stub.c
discover_process_MODULES = lib cp/beacon mac/common cp/sta/mgr cp/pwl \
cp/cco/region \
cp/fsm/stub cp/cco/action/stub hal/timer/stub \
@@ -30,7 +30,7 @@ discover_process_MODULES = lib cp/beacon mac/common cp/sta/mgr cp/pwl \
schedules_SOURCES = schedules.c \
interface_stub.c ca_stub.c ntb_stub.c \
- sar_stub.c secu_stub.c
+ sar_stub.c secu_stub.c bsu_stub.c
schedules_MODULES = lib cp/beacon cp/sta/mgr cp/cco/bw mac/common cp/pwl \
cp/cco/region \
hal/timer/stub cp/sta/core/stub cp/fsm/stub \
diff --git a/cesar/cp/beacon/test/override/cp/inc/context.h b/cesar/cp/beacon/test/override/cp/inc/context.h
index dd98294eb0..5a9296e3cc 100644
--- a/cesar/cp/beacon/test/override/cp/inc/context.h
+++ b/cesar/cp/beacon/test/override/cp/inc/context.h
@@ -38,6 +38,22 @@
#include "cl/cl.h"
#include "mac/common/config.h"
#include "mac/sar/sar.h"
+#include "beacon/beacon.h"
+
+enum cp_shared_mem_slot_id_t
+{
+ CP_SHARED_MEM_SLOT_1 = 0,
+ CP_SHARED_MEM_SLOT_2,
+ CP_SHARED_MEM_SLOT_NB
+};
+typedef enum cp_shared_mem_slot_id_t cp_shared_mem_slot_id_t;
+
+struct shared_mem_t
+{
+ beacon_t bsu;
+};
+typedef struct shared_mem_t shared_mem_t;
+
struct cp_t
{
@@ -56,6 +72,10 @@ struct cp_t
cl_t *cl;
mac_config_t *mac_config;
sar_t *sar;
+
+ /** Shared memory. */
+ shared_mem_t shared_mem[CP_SHARED_MEM_SLOT_NB];
+ cp_shared_mem_slot_id_t shared_mem_slot_id;
};
#endif /* overide_cp_inc_context_h */
diff --git a/cesar/cp/beacon/test/src/beacon.c b/cesar/cp/beacon/test/src/beacon.c
index e24047d3b5..5cf9c5f3c9 100644
--- a/cesar/cp/beacon/test/src/beacon.c
+++ b/cesar/cp/beacon/test/src/beacon.c
@@ -39,10 +39,6 @@ cp_beacon_desc_t *
cp_beacon_generate_beacon (cp_t *ctx, cp_beacon_unpack_t *unpack);
void
-cp_beacon__cco__unpack_fill (cp_t *ctx, cp_beacon_unpack_t *unpack,
- uint beacon_type);
-
-void
cp_beacon_compute_ca_schedules (cp_t *ctx);
struct interface_t
@@ -226,246 +222,417 @@ test_case_beacon__deactivate (test_t test)
test_end;
}
+static
+void
+test_beacon_variant_field (test_t test, beacon_t *beacon, cp_nid_t nid,
+ mac_coexistence_mode_t hm, u8 slot_usage, u8 slot_id, bool hoipflag)
+{
+ test_begin (test, "variant field: Constant values")
+ {
+ test_fail_unless (beacon->vf.ncnr == CP_BEACON_NON_COORDINATED_NETWORK);
+ test_fail_unless (beacon->vf.npsm == CP_BEACON_NPSM_NOT_ACTIVE);
+ test_fail_unless (beacon->vf.numslots == 1);
+ test_fail_unless (beacon->vf.aclsss == 0);
+ test_fail_unless (beacon->vf.rstbf == false);
+ test_fail_unless (beacon->vf.nm == CP_BEACON_NM_CSMA_ONLY);
+ test_fail_unless (beacon->vf.ccocap == CP_CCO_LEVEL);
+ test_fail_unless (beacon->vf.rsvd == 0);
+ }
+ test_end;
+
+ test_begin (test, "Variant field: variant fields")
+ {
+ test_fail_unless (beacon->vf.nid == nid);
+ test_fail_unless (beacon->vf.hm == hm);
+ test_fail_unless (beacon->vf.slotusage == slot_usage);
+ test_fail_unless (beacon->vf.slotid == slot_id);
+ test_fail_unless (beacon->vf.hoip == hoipflag);
+ }
+ test_end;
+}
+
+static
+void
+test_beacon_discover_info (test_t test, beacon_t *beacon, bool updated,
+ bool cco_status, bool pco_status, u8 nb_sta, u8 nb_net, bool authenticated)
+{
+ test_begin (test, "Beacon entries : discover info")
+ {
+ u32 info_data;
+ bitstream_t bitstream;
+ u8 temp;
+
+ bitstream_init (&bitstream, &info_data, 4, BITSTREAM_WRITE);
+ bitstream_access (&bitstream, &updated, 1);
+ temp = CP_CCO_LEVEL; /* this value is built-in */
+ bitstream_access (&bitstream, &temp, 2);
+ temp = CP_PCO_CAP; /* this value is built-in */
+ bitstream_access (&bitstream, &temp, 1);
+ temp = CP_BACKUP_CCO_CAP; /* this value is built-in */
+ bitstream_access (&bitstream, &temp, 1);
+ bitstream_access (&bitstream, &cco_status, 1);
+ bitstream_access (&bitstream, &pco_status, 1);
+ temp = false; /* this value is built-in */
+ bitstream_access (&bitstream, &temp, 1);
+ bitstream_access (&bitstream, &nb_sta, 8);
+ bitstream_access (&bitstream, &nb_net, 8);
+ bitstream_access (&bitstream, &authenticated, 1);
+ temp = false; /* this value is built_in */
+ bitstream_access (&bitstream, &temp, 1);
+ temp = 0; /* reserved and set to 0 */
+ bitstream_access (&bitstream, &temp, 6);
+ bitstream_finalise (&bitstream);
+
+ /* discover info data are always present */
+ test_fail_unless (beacon->bmis.discover_info.present == true);
+ test_fail_unless (beacon->bmis.discover_info.info_data == info_data);
+ }
+ test_end;
+}
+static
+void
+test_beacon_bentries (test_t test, beacon_t *beacon,
+ bool disc_flag, cp_tei_t disc_tei,
+ uint hoip_cd, cp_tei_t hoip_tei,
+ uint kc_cd,enum cp_beacon_eks_kbc_t kbc, u8 eks,
+ mac_coexistence_mode_t new_hm,
+ uint snid_cd, cp_snid_t new_snid)
+{
+ test_begin (test, "Beacon entries")
+ {
+ /* Discover. */
+ test_fail_unless (beacon->bmis.discover.present == disc_flag);
+ if (disc_flag)
+ test_fail_unless (beacon->bmis.discover.tei == disc_tei);
+ else
+ test_fail_unless (beacon->bmis.discover.tei == 0);
+ test_fail_unless (beacon->bmis.discover.rsvd == 0);
+ /* Handover in progress. */
+ if (beacon->bmis.handover.present)
+ {
+ test_fail_unless (beacon->bmis.handover.hcd == hoip_cd);
+ test_fail_unless (beacon->bmis.handover.tei == hoip_tei);
+ }
+ else
+ {
+ test_fail_unless (beacon->bmis.handover.hcd == 0);
+ test_fail_unless (beacon->bmis.handover.tei == 0);
+ }
+ test_fail_unless (beacon->bmis.handover.reserved == 0);
+ /* eks. */
+ if (beacon->bmis.eks.present)
+ {
+ test_fail_unless (beacon->bmis.eks.kccd == kc_cd);
+ test_fail_unless (beacon->bmis.eks.kbc == kbc);
+ test_fail_unless (beacon->bmis.eks.new_eks == eks);
+ }
+ else
+ {
+ test_fail_unless (beacon->bmis.eks.kccd == 0);
+ test_fail_unless (beacon->bmis.eks.kbc == 0);
+ test_fail_unless (beacon->bmis.eks.new_eks == 0);
+ }
+ /* Change hm. */
+ if (beacon->bmis.change_hm.present)
+ {
+ test_fail_unless (beacon->bmis.change_hm.hmccd ==
+ CP_BEACON_COUNTDOWN_HM);
+ test_fail_unless (beacon->bmis.change_hm.newhm == new_hm);
+ }
+ else
+ {
+ test_fail_unless (beacon->bmis.change_hm.hmccd == 0);
+ test_fail_unless (beacon->bmis.change_hm.newhm == 0);
+ }
+ test_fail_unless (beacon->bmis.change_hm.rsvd == 0);
+ /* Change snid. */
+ if (beacon->bmis.change_snid.present)
+ {
+ test_fail_unless (beacon->bmis.change_snid.snidccd == snid_cd);
+ test_fail_unless (beacon->bmis.change_snid.new_snid == new_snid);
+ }
+ else
+ {
+ test_fail_unless (beacon->bmis.change_snid.snidccd == 0);
+ test_fail_unless (beacon->bmis.change_snid.new_snid == 0);
+ }
+ test_fail_unless (beacon->bmis.change_snid.rsvd == 0);
+ /* others. */
+ test_fail_unless (beacon->bmis.bpsto.present == false);
+ test_fail_unless (beacon->bmis.mac_address_present.present == false);
+ test_fail_unless (beacon->bmis.relocation.present == false);
+ test_fail_unless (beacon->bmis.aclsc.present == false);
+ test_fail_unless (beacon->bmis.cns.present == false);
+ }
+ test_end;
+}
+
void
test_suite_beacon__beacon_generation (test_t test)
{
- cp_beacon_unpack_t unpack;
- cp_beacon_unpack_t unpack2;
- cp_beacon_unpack_region_t *region;
- cp_beacon_unpack_schedule_t *sched;
- cp_beacon_desc_t *beacon;
- set_t set_schedules1;
- set_t set_regions1;
- set_t set_schedules2;
- set_t set_regions2;
- bitstream_t read;
+ beacon_t *beacon;
- test_suite_begin (test, "Beacon generation");
+ mac_config_t mac_config;
+ cl_t cl;
+ sar_t sar;
- test_case_begin (test, "central beacon");
+ /* Configure the context. */
+ memset (&mac_config, 0, sizeof (mac_config_t));
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&sar, 0, sizeof (sar_t));
+
+ cp.mac_config = &mac_config;
+ cp.cl = &cl;
+ cp.sar = &sar;
+ cp_sta_mgr_init (&cp);
+ cp_beacon_init (&cp);
cp_cco_bw_init (&cp);
cp_cco_region_init (&cp);
- set_init (&set_schedules1, cp_cco_bw_alloc_less);
- set_init (&set_regions1, cp_cco_region_alloc_less);
- set_init (&set_schedules2, cp_cco_bw_alloc_less);
- set_init (&set_regions2, cp_cco_region_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules1, &set_regions1);
- unpack.variant_fields.nid_lsb = 2;
- unpack.variant_fields.nid_msb = 1;
- unpack.variant_fields.hm = 1;
- unpack.variant_fields.stei = 0x12;
- unpack.variant_fields.bt = CP_BEACON_CENTRAL_BEACON;
- unpack.variant_fields.ncnr = false;
- unpack.variant_fields.npsm = false;
- unpack.variant_fields.num_slots = 0;
- unpack.variant_fields.slot_usage = 0;
- unpack.variant_fields.slot_id = 0;
- unpack.variant_fields.aclss = true;
- unpack.variant_fields.hoip = true;
- unpack.variant_fields.rtsbf = false;
- unpack.variant_fields.nm = CP_BEACON_NM_CSMA_ONLY;
- unpack.variant_fields.cco_cap = CP_CCO_LEVEL;
- unpack.nbe = 6;
+ cp.mac_store = mac_store_init();
+
+ /* Data set one */
+ const cp_nid_t nid_1 = 0x001456789ABCDEF0;
+ const cp_tei_t tei_1 = 42;
+ const cp_snid_t snid_1 = 0xFE;
+ const u8 slot_id_1 = 1;
+ enum cp_beacon_hoip_e hoip_flag_1 = CP_BEACON_HOIP_FALSE;
+ const bool cco_flag_1 = true;
+ const bool pco_flag_1 = false;
+ const bool authen_1 = true;
+ const mac_coexistence_mode_t hm_1 = MAC_COEXISTENCE_AV_ONLY_MODE;
+ const uint kc_cd = 0xAB;
+ const enum cp_beacon_eks_kbc_t kbc = CP_BEACON_EKS_KBC_NEK;
+ const u8 eks = 0x12;
+ const uint hoip_cd = 0xCD;
+ const cp_tei_t hoip_tei = 44;
+ const mac_coexistence_mode_t new_hm = MAC_COEXISTENCE_FULL_HYBRID_MODE;
+ const u8 snid_cd = 0xA;
+ const cp_snid_t new_snid = 0xF;
+
+ cp_net_t *net_1 = cp_sta_mgr_add_avln (&cp, snid_1, nid_1);
+ cp_sta_own_data_set_tei (&cp, tei_1);
+ cp_net_set_slot_id_and_usage (&cp, net_1, slot_id_1, 0);
+ cp_sta_mgr_set_our_avln (&cp, net_1);
+ cp_beacon_handover_hoipflag (&cp, hoip_flag_1);
+ cp_sta_own_data_set_cco_status (&cp, cco_flag_1);
+ cp_sta_own_data_set_pco_status (&cp, pco_flag_1);
+ cp_sta_own_data_set_authenticated_status (&cp, authen_1);
+ cp.beacon.discover.discover_interval_bp = 10;
+ ((cp_sta_own_data_t *)&cp.sta_mgr.sta_own_data)->hybrid_mode = hm_1;
+
+ cp_beacon_change_hm (&cp, new_hm);
+ cp.beacon.eks.kccd = kc_cd;
+ cp.beacon.eks.kbc = kbc;
+ cp.beacon.eks.new_eks = eks;
+ cp.beacon.hoip.hoipcd = hoip_cd;
+ cp.beacon.hoip.cco = hoip_tei;
+ cp.beacon.snids.snidcd = snid_cd;
+ cp.beacon.snids.snid = new_snid;
+ cp.beacon.discover.countdown_bp = 0; // so that the flag is true
/* Regions. */
- unpack.bmis.regions.present = true;
+ cp_beacon_unpack_region_t *region;
+ uint end_time_atu = 3907;
+
region = cp_cco_region_alloc_init (&cp);
region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
- region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, unpack.bmis.regions.set, region);
+ region->end_time_atu = end_time_atu;
+ cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
slab_release (region);
- /* Schedules. */
- unpack.bmis.schedules.present = true;
- sched = cp_cco_bw_alloc_init (&cp);
- sched->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
- sched->pscd = 7;
- sched->cscd = 7;
- sched->stpf = false;
- sched->glid = 0x45;
- sched->end_time_atu = 3907;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, sched);
- slab_release (sched);
-
- unpack.bmis.bpsto.present = true;
-
- unpack.bmis.mac_address.present = true;
- unpack.bmis.mac_address.mac_addr = 0x123456789ABCull;
-
- unpack.bmis.discover.present = true;
- unpack.bmis.discover.tei = 0xC;
+ /* Fill the beacon data share memory */
+ beacon = cp_beacon_fill_share_memory (&cp);
- unpack.bmis.hoip.present = true;
- unpack.bmis.hoip.hoipcd = 5;
- unpack.bmis.hoip.cco = 0xF;
-
- beacon = cp_beacon_unpack__pack (&cp, &unpack);
-
- bitstream_read_init (&read, beacon->payload, CP_BEACON_SIZE - 4);
-
- test_begin (test, "Variant fields")
+ test_suite_begin (test, "Beacon generation");
+ test_case_begin (test, "fill share memory");
+
+ /* Check the variant fields */
+ test_beacon_variant_field (test, beacon, nid_1, hm_1, (1 << slot_id_1),
+ slot_id_1, hoip_flag_1);
+ /* Check the discover info field */
+ test_beacon_discover_info (test, beacon, true, cco_flag_1, pco_flag_1,
+ 0, 0, authen_1);
+ /* Check most bentry fields */
+ test_beacon_bentries (test, beacon,
+ true, tei_1,
+ hoip_cd, hoip_tei,
+ kc_cd, kbc, eks,
+ new_hm,
+ snid_cd, new_snid);
+ /* Check regions bentries */
+ test_begin (test, "Region")
{
- test_fail_unless (beacon->nid_lsb == unpack.variant_fields.nid_lsb);
- test_fail_unless (bitstream_read (&read, 22) == unpack.variant_fields.nid_msb);
- test_fail_unless (bitstream_read (&read, 2) == unpack.variant_fields.hm);
- test_fail_unless (bitstream_read (&read, 8) == unpack.variant_fields.stei);
- test_fail_unless (bitstream_read (&read, 3) == unpack.variant_fields.bt);
- test_fail_unless (bitstream_read (&read, 1) == unpack.variant_fields.ncnr);
- test_fail_unless (bitstream_read (&read, 1) == unpack.variant_fields.npsm);
- test_fail_unless (bitstream_read (&read, 3) == unpack.variant_fields.num_slots);
- test_fail_unless (bitstream_read (&read, 8) == unpack.variant_fields.slot_usage);
- test_fail_unless (bitstream_read (&read, 3) == unpack.variant_fields.slot_id);
- test_fail_unless (bitstream_read (&read, 3) == unpack.variant_fields.aclss);
- test_fail_unless (bitstream_read (&read, 1) == unpack.variant_fields.hoip);
- test_fail_unless (bitstream_read (&read, 1) == unpack.variant_fields.rtsbf);
- test_fail_unless (bitstream_read (&read, 2) == unpack.variant_fields.nm);
- test_fail_unless (bitstream_read (&read, 2) == unpack.variant_fields.cco_cap);
- test_fail_unless (bitstream_read (&read, 4) == 0);
+ test_fail_unless (beacon->bmis.region.nb == 1);
+ test_fail_unless (beacon->bmis.region.region[0].rt ==
+ CP_BEACON_REGION_TYPE_SHARED_CSMA);
+ test_fail_unless (beacon->bmis.region.region[0].end_time_atu ==
+ end_time_atu);
}
test_end;
-
- test_begin (test, "Beacon entries.")
+ /* Check schedule bentries */
+ test_begin (test, "schedule")
{
- bool ok;
- uint header;
- uint length;
-
- test_fail_unless (bitstream_read (&read, 8) == unpack.nbe);
-
- /* Region. */
- ok = cp_beacon_unpack_header_read (&read, &header, &length);
- test_fail_unless (ok == true);
- test_fail_unless (header == CP_BENTRY_REGIONS);
- test_fail_unless (length == CP_BEACON_ENTRY_REGION (1));
- test_fail_unless (bitstream_read (&read, 6) == 1);
- test_fail_unless (bitstream_read (&read, 2) == 0);
- test_fail_unless (bitstream_read (&read, 4)
- == CP_BEACON_REGION_TYPE_SHARED_CSMA);
- test_fail_unless (bitstream_read (&read, 12) == 3907);
-
- /* Persistent schedule. */
- ok = cp_beacon_unpack_header_read (&read, &header, &length);
- test_fail_unless (ok == true);
- test_fail_unless (header == CP_BENTRY_PERSISTENT_SCHEDULE);
- test_fail_unless (length == CP_BEACON_ENTRY_PERSISTENT_SCHED (0, 1));
- test_fail_unless (bitstream_read (&read, 3) == 7);
- test_fail_unless (bitstream_read (&read, 3) == 7);
- test_fail_unless (bitstream_read (&read, 2) == 0);
- test_fail_unless (bitstream_read (&read, 6) == 1);
- test_fail_unless (bitstream_read (&read, 2) == 0);
- test_fail_unless (bitstream_read (&read, 1) == 0);
- test_fail_unless (bitstream_read (&read, 7) == 0x45);
- test_fail_unless (bitstream_read (&read, 12) == 3907);
- test_fail_unless (bitstream_read (&read, 4) == 0);
-
- /* BPSTO. */
- ok = cp_beacon_unpack_header_read (&read, &header, &length);
- test_fail_unless (ok == true);
- test_fail_unless (header == CP_BENTRY_BEACON_PERIOD_START_OFFSET);
- test_fail_unless (length == CP_BEACON_ENTRY_BPSTO);
- test_fail_unless (bitstream_read (&read, 24) == 0);
-
- /* Mac address. */
- ok = cp_beacon_unpack_header_read (&read, &header, &length);
- test_fail_unless (ok == true);
- test_fail_unless (header == CP_BENTRY_MAC_ADDRESS);
- test_fail_unless (length == CP_BEACON_ENTRY_MAC_ADDRESS);
- test_fail_unless (bitstream_read_large (&read, 48)
- == 0x123456789ABCull);
-
- /* Discover. */
- ok = cp_beacon_unpack_header_read (&read, &header, &length);
- test_fail_unless (ok == true);
- test_fail_unless (header == CP_BENTRY_DISCOVER);
- test_fail_unless (length == CP_BEACON_ENTRY_DISCOVER);
- test_fail_unless (bitstream_read (&read, 8) == 0xC);
- bitstream_finalise (&read);
-
- /* Handover in progress. */
- ok = cp_beacon_unpack_header_read (&read, &header, &length);
- test_fail_unless (ok == true);
- test_fail_unless (header == CP_BENTRY_CCO_HANDOVER);
- test_fail_unless (length == CP_BEACON_ENTRY_HOIP);
- test_fail_unless (bitstream_read (&read, 6) == 5);
- test_fail_unless (bitstream_read (&read, 2) == 0);
- test_fail_unless (bitstream_read (&read, 8) == 0xF);
+ test_fail_unless (beacon->bmis.ps.nb == 0);
+ test_fail_unless (beacon->bmis.nps.ns == 0);
}
test_end;
+ /* Change values */
+
+ /* Data set two */
+ const cp_nid_t nid_2 = 0x001567890ABCDEF0;
+ const cp_tei_t tei_2 = 43;
+ const cp_snid_t snid_2 = 0xEF;
+ const u8 slot_id_2 = 2;
+ enum cp_beacon_hoip_e hoip_flag_2 = CP_BEACON_HOIP_TRUE;
+ const bool cco_flag_2 = false;
+ const bool pco_flag_2 = true;
+ const bool authen_2 = false;
+ const mac_coexistence_mode_t hm_2 = MAC_COEXISTENCE_NB - 1;
+
+ cp_net_t *net_2 = cp_sta_mgr_add_avln (&cp, snid_2, nid_2);
+ cp_sta_own_data_set_tei (&cp, tei_2);
+ cp_net_set_slot_id_and_usage (&cp, net_2, slot_id_2, 0);
+ cp_sta_mgr_set_our_avln (&cp, net_2);
+ cp_beacon_handover_hoipflag (&cp, hoip_flag_2);
+ cp_sta_own_data_set_cco_status (&cp, cco_flag_2);
+ cp_sta_own_data_set_pco_status (&cp, pco_flag_2);
+ cp_sta_own_data_set_authenticated_status (&cp, authen_2);
+ ((cp_sta_own_data_t *)&cp.sta_mgr.sta_own_data)->hybrid_mode = hm_2;
+
+ cp.beacon.eks.kccd = 0;
+ cp.beacon.hoip.hoipcd = 0;
+ cp.beacon.snids.snidcd = 0;
+ cp.beacon.hm.hmcd = 0;
- test_suite_begin (test, "Unpacking...");
- test_case_begin (test, "Unpack - Central beacon");
-
- /* Unpack. */
- cp_beacon_unpack_init (&unpack2, &set_schedules2, &set_regions2);
-
- test_begin (test, "Unpack")
- {
- bool ok;
-
- ok = cp_beacon_unpack__unpack (&cp, &unpack2, beacon);
- test_fail_unless (ok == true);
+ /* Regions. */
+ region = cp_cco_region_alloc_init (&cp);
+ region->type = CP_BEACON_REGION_TYPE_BEACON;
+ region->end_time_atu = end_time_atu - 10;
+ cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ slab_release (region);
- test_fail_unless (memcmp (&unpack.variant_fields,
- &unpack2.variant_fields,
- sizeof (cp_beacon_variant_fields_t))
- == 0);
+ region = cp_cco_region_alloc_init (&cp);
+ region->type = CP_BEACON_REGION_TYPE_STAYOUT;
+ region->end_time_atu = end_time_atu + 10;
+ cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ slab_release (region);
- cp_beacon_unpack_region_t *region;
- cp_beacon_unpack_schedule_t *sched;
- test_fail_unless (unpack.nbe == unpack2.nbe);
+ /* Schedules. */
+ uint nb, ns;
+ int i;
+ cp_beacon_unpack_schedule_t *sched;
- /* Regions. */
- test_fail_unless (unpack2.bmis.regions.present == true);
- region = cp_cco_region_alloc_get_first (&cp, unpack2.bmis.regions.set);
- test_fail_unless (region != NULL);
- test_fail_unless (region->type == CP_BEACON_REGION_TYPE_SHARED_CSMA);
- test_fail_unless (region->end_time_atu == 3907);
- slab_release (region);
+ for (i = 1, nb = 0; i < 8; i += 2, nb++)
+ {
+ for (ns=0; ns < 2; ns++)
+ {
+ sched = cp_cco_bw_alloc_init (&cp);
+ sched->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
+ sched->pscd = i;
+ sched->cscd = i;
+ sched->stpf = false;
+ sched->glid = 0x55 + nb;
+ sched->end_time_atu = end_time_atu + nb * 10 + ns * 5;
+ sched->start_time_atu = end_time_atu + nb * 10 + ns * 5 -4;
+ cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
+ slab_release (sched);
+ }
+ }
- /* schedules */
- test_fail_unless (unpack2.bmis.schedules.present == true);
- sched = cp_cco_bw_alloc_get_first (&cp, unpack2.bmis.schedules.set);
- test_fail_unless (sched != NULL);
- test_fail_unless (sched->pscd == 7);
- test_fail_unless (sched->cscd == 7);
- test_fail_unless (sched->stpf == false);
- test_fail_unless (sched->end_time_atu == 3907);
- test_fail_unless (sched->glid == 0xc5);
+ for (ns = 0; ns < BSU_BEACON_BMIS_SCHEDULES_SAI_MAX; ns++)
+ {
+ sched = cp_cco_bw_alloc_init (&cp);
+ sched->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
+ sched->pscd = ns;
+ sched->cscd = ns;
+ sched->stpf = false;
+ sched->glid = 0x45 + ns;
+ sched->start_time_atu = end_time_atu - 10 * (ns + 1) -9;
+ sched->end_time_atu = end_time_atu - 10 * (ns + 1);
+ cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
slab_release (sched);
+ }
- /* BPSTO. */
- test_fail_unless (unpack2.bmis.bpsto.present == true);
- test_fail_unless (unpack2.bmis.bpsto.bpsto == 0x0);
-
- /* Mac address. */
- test_fail_unless (unpack2.bmis.mac_address.present == true);
- test_fail_unless (unpack2.bmis.mac_address.mac_addr ==
- 0x123456789ABCull);
-
- /* Discover. */
- test_fail_unless (unpack2.bmis.discover.present == true);
- test_fail_unless (unpack2.bmis.discover.tei == 0xC);
-
- /* Verify the others are not present. */
- test_fail_unless (unpack2.bmis.discover_info.present == false);
- test_fail_unless (unpack2.bmis.snids.present == false);
+ /* Fill the beacon data share memory */
+ beacon = cp_beacon_fill_share_memory (&cp);
+
+ test_suite_begin (test, "Beacon generation 2");
+ test_case_begin (test, "fill share memory 2");
+
+ /* Check the variant fields */
+ test_beacon_variant_field (test, beacon, nid_2, hm_2,
+ (1 << slot_id_2) + (1 << slot_id_1),
+ slot_id_2, hoip_flag_2);
+ /* Check the discover info field */
+ test_beacon_discover_info (test, beacon, true, cco_flag_2, pco_flag_2,
+ 0, 1, authen_2);
+ /* Check most bentry fields */
+ test_beacon_bentries (test, beacon,
+ false, tei_2, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ /* Check regions bentries */
+ test_begin (test, "Region 2")
+ {
+ test_fail_unless (beacon->bmis.region.nb == 3);
+ test_fail_unless (beacon->bmis.region.region[0].rt ==
+ CP_BEACON_REGION_TYPE_BEACON);
+ test_fail_unless (beacon->bmis.region.region[0].end_time_atu ==
+ end_time_atu - 10);
+ test_fail_unless (beacon->bmis.region.region[1].rt ==
+ CP_BEACON_REGION_TYPE_SHARED_CSMA);
+ test_fail_unless (beacon->bmis.region.region[1].end_time_atu ==
+ end_time_atu);
+ test_fail_unless (beacon->bmis.region.region[2].rt ==
+ CP_BEACON_REGION_TYPE_STAYOUT);
+ test_fail_unless (beacon->bmis.region.region[2].end_time_atu ==
+ end_time_atu + 10);
+ }
+ test_end;
+ /* Check schedule bentries */
+ test_begin (test, "schedule 2")
+ {
+ for (i = 1, nb = 0; i < 8; i += 2, nb++)
+ {
+ test_fail_unless (beacon->bmis.ps.ps[nb].pscd == i);
+ test_fail_unless (beacon->bmis.ps.ps[nb].cscd == i);
+ test_fail_unless (beacon->bmis.ps.ps[nb].ns == 2);
+
+ for (ns = 0; ns < 2; ns++)
+ {
+ test_fail_unless (beacon->bmis.ps.ps[nb].sais[ns].stpf ==
+ false);
+ test_fail_unless (beacon->bmis.ps.ps[nb].sais[ns].glid ==
+ 0x55 + nb);
+ test_fail_unless (
+ beacon->bmis.ps.ps[nb].sais[ns].start_time_atu ==
+ end_time_atu + nb * 10 + ns * 5 - 4);
+ test_fail_unless (
+ beacon->bmis.ps.ps[nb].sais[ns].end_time_atu ==
+ end_time_atu + nb * 10 + ns * 5);
+ }
+ }
+ test_fail_unless (beacon->bmis.ps.nb == nb);
- /* Handover in progress. */
- test_fail_unless (unpack2.bmis.hoip.present == true);
- test_fail_unless (unpack2.bmis.hoip.hoipcd == 5);
- test_fail_unless (unpack2.bmis.hoip.cco == 0xF);
+ for (i = BSU_BEACON_BMIS_SCHEDULES_SAI_MAX - 1, ns = 0; i >= 0;
+ i--, ns++)
+ {
+ test_fail_unless (beacon->bmis.nps.sais[ns].stpf ==
+ false);
+ test_fail_unless (beacon->bmis.nps.sais[ns].glid ==
+ 0x45 + i);
+ test_fail_unless (
+ beacon->bmis.nps.sais[ns].start_time_atu ==
+ end_time_atu - (i + 1) * 10 - 9);
+ test_fail_unless (
+ beacon->bmis.nps.sais[ns].end_time_atu ==
+ end_time_atu - (i + 1) * 10);
+ }
+ test_fail_unless (beacon->bmis.nps.ns == ns);
}
test_end;
- cp_beacon_unpack_uninit (&cp, &unpack2);
- cp_cco_bw_alloc_clean (&cp, &set_schedules1);
- cp_cco_region_alloc_clean (&cp, &set_regions1);
- blk_release_desc ((blk_t *) beacon);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules2);
- cp_cco_region_alloc_clean (&cp, &set_regions2);
cp_cco_bw_uninit (&cp);
cp_cco_region_uninit (&cp);
}
@@ -476,7 +643,6 @@ test_case_beacon_snid_change_cco (test_t test)
uint snid;
cp_net_t *net;
mac_config_t mac_config;
- cp_beacon_unpack_t unpack;
cl_t cl;
sar_t sar;
@@ -523,10 +689,10 @@ test_case_beacon_snid_change_cco (test_t test)
cp_cco_bw_alloc_t *alloc;
set_t set_schedules;
set_t set_regions;
+ beacon_t *beacon;
set_init (&set_schedules, cp_cco_bw_alloc_less);
set_init (&set_regions, cp_cco_region_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
cp_cco_region_init (&cp);
cp_cco_bw_init (&cp);
@@ -548,79 +714,19 @@ test_case_beacon_snid_change_cco (test_t test)
cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
slab_release (alloc);
- cp_beacon__cco__unpack_fill (&cp, &unpack,
- CP_BEACON_CENTRAL_BEACON);
+ beacon = cp_beacon_fill_share_memory (&cp);
- test_fail_unless (unpack.bmis.snids.present == true);
- test_fail_unless (unpack.bmis.snids.snid == cp.beacon.snids.snid);
- test_fail_unless (unpack.bmis.snids.snid_cd == cp.beacon.snids.snidcd);
-
- test_fail_unless (unpack.bmis.mac_address.present == true);
- test_fail_unless (unpack.bmis.mac_address.mac_addr ==
- cp_sta_own_data_get_mac_address (&cp));
+ test_fail_unless (beacon->bmis.change_snid.present == true);
+ test_fail_unless (beacon->bmis.change_snid.snidccd == cp.beacon.snids.snidcd);
+ test_fail_unless (beacon->bmis.change_snid.new_snid == cp.beacon.snids.snid);
cp_cco_region_uninit (&cp);
cp_cco_bw_uninit (&cp);
- cp_beacon_unpack_uninit (&cp, &unpack);
cp_cco_bw_alloc_clean (&cp, &set_schedules);
cp_cco_region_alloc_clean (&cp, &set_regions);
}
test_end;
- test_begin (test, "Ca schedules")
- {
- cp_cco_bw_alloc_t *sched;
- ca_schedule_t *ca_sched;
- uint i;
-
- /* Add a schedule. */
- cp_cco_bw_init (&cp);
- sched = cp_cco_bw_alloc_init (&cp);
- sched->stpf = false;
- sched->glid = 0x45;
- sched->end_time_atu = 3907;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
- slab_release (sched);
-
- cp_beacon_compute_ca_schedules (&cp);
-
- /* Verify the snid in the CA schedules it still our SNID. */
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- test_fail_unless (ca_sched->snid == 0xA);
- }
-
- /* Count down the snid countdown. */
- cp.beacon.snids.snidcd = 1;
- cp.beacon.ca_schedule_index = 0;
- cp_beacon_compute_ca_schedules (&cp);
-
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- if (i == 0)
- test_fail_unless (ca_sched->snid == 0xA);
- else
- test_fail_unless (ca_sched->snid == 0x1);
- }
-
- /* No countdown. */
- cp.beacon.snids.snidcd = 0;
- cp.beacon.snids.snid = 0xB;
- cp.beacon.ca_schedule_index = 0;
- cp_beacon_compute_ca_schedules (&cp);
-
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- test_fail_unless (ca_sched->snid == 0xA);
- }
-
- cp_cco_bw_uninit (&cp);
- }
- test_end;
-
/* Uninit all the data. */
cp_beacon_uninit (&cp);
cp_sta_mgr_uninit (&cp);
@@ -890,162 +996,6 @@ test_suite_beacon_snid_change (test_t test)
}
void
-test_case_beacon_hm_change_cco (test_t test)
-{
- uint hm;
- cp_net_t *net;
- cp_sta_own_data_t *own;
- mac_config_t mac_config;
- cp_beacon_unpack_t unpack;
- cl_t cl;
- sar_t sar;
- set_t set_schedules;
- set_t set_regions;
-
- test_case_begin (test, "CCo");
-
- /* Configure the test. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
-
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.mac_store = mac_store_init();
-
- net = cp_sta_mgr_add_avln (&cp, 0xA, 1);
- own = cp_sta_mgr_get_sta_own_data (&cp);
- own->hybrid_mode = 0xA;
- cp_sta_own_data_set_tei (&cp, 1);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp_sta_own_data_set_cco_status (&cp, true);
- cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
-
-
- test_begin (test, "Change HM")
- {
- /* Process the test. */
- test_fail_unless (cp.beacon.hm.hm == 0);
- test_fail_unless (cp.beacon.hm.hmcd == 0);
-
- hm = 1;
- cp_beacon_change_hm (&cp, hm);
-
- test_fail_unless (cp.beacon.hm.hm == hm);
- test_fail_unless (cp.beacon.hm.hmcd == CP_BEACON_COUNTDOWN_SNID);
- }
- test_end;
-
- test_begin (test, "Change HM, check bentry in Central beacon")
- {
- cp_cco_region_alloc_t *region;
- cp_cco_bw_alloc_t *alloc;
-
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- set_init (&set_regions, cp_cco_region_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
-
- /* Regions. */
- region = cp_cco_region_alloc_init (&cp);
- region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
- region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
- slab_release (region);
-
- /* Schedules. */
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->stpf = false;
- alloc->glid = 0x45;
- alloc->end_time_atu = 3907;
- alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
- slab_release (alloc);
-
- cp_beacon__cco__unpack_fill (&cp, &unpack,
- CP_BEACON_CENTRAL_BEACON);
-
- test_fail_unless (unpack.bmis.hm.present == true);
- test_fail_unless (unpack.bmis.hm.hm == cp.beacon.hm.hm);
- test_fail_unless (unpack.bmis.hm.hmcd == cp.beacon.hm.hmcd);
-
- test_fail_unless (unpack.bmis.mac_address.present == true);
- test_fail_unless (unpack.bmis.mac_address.mac_addr ==
- cp_sta_own_data_get_mac_address (&cp));
-
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- }
- test_end;
-
- test_begin (test, "Ca schedules")
- {
- cp_cco_bw_alloc_t *sched;
- ca_schedule_t *ca_sched;
- uint i;
-
- /* Add a schedule. */
- sched = cp_cco_bw_alloc_init (&cp);
- sched->stpf = false;
- sched->glid = 0x45;
- sched->end_time_atu = 3907;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
- slab_release (sched);
-
- cp_beacon_compute_ca_schedules (&cp);
-
- /* Verify the hm in the CA schedules it still our SNID. */
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- test_fail_unless (ca_sched->coexistence_mode == 0xA);
- }
-
- /* Count down the hm countdown. */
- cp.beacon.hm.hmcd = 1;
- cp.beacon.ca_schedule_index = 0;
- cp_beacon_compute_ca_schedules (&cp);
-
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- if (i == 0)
- test_fail_unless (ca_sched->coexistence_mode == 0xA);
- else
- test_fail_unless (ca_sched->coexistence_mode == 0x1);
- }
-
- /* No countdown. */
- cp.beacon.hm.hmcd = 0;
- cp.beacon.hm.hm = 0xB;
- cp.beacon.ca_schedule_index = 0;
- cp_beacon_compute_ca_schedules (&cp);
-
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- test_fail_unless (ca_sched->coexistence_mode == 0xA);
- }
-
- cp_cco_bw_uninit (&cp);
- }
- test_end;
-
- /* Uninit all the data. */
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- mac_store_uninit (cp.mac_store);
-}
-
-void
test_case_beacon_hm_change_sta (test_t test)
{
test_case_begin (test, "Station");
@@ -1267,7 +1217,6 @@ test_suite_beacon_hm_change (test_t test)
{
test_suite_begin (test, "Hybrid mode change");
- test_case_beacon_hm_change_cco (test);
test_case_beacon_hm_change_sta (test);
}
@@ -1277,11 +1226,8 @@ test_case_beacon_eks_change_cco (test_t test)
cp_key_t nek;
cp_net_t *net;
mac_config_t mac_config;
- cp_beacon_unpack_t unpack;
cl_t cl;
sar_t sar;
- set_t set_schedules;
- set_t set_regions;
test_case_begin (test, "CCo");
@@ -1323,106 +1269,6 @@ test_case_beacon_eks_change_cco (test_t test)
}
test_end;
- test_begin (test, "Change EKS, check bentry in Central beacon")
- {
- cp_cco_region_alloc_t *region;
- cp_cco_bw_alloc_t *alloc;
-
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- set_init (&set_regions, cp_cco_region_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
-
- /* Regions. */
- region = cp_cco_region_alloc_init (&cp);
- region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
- region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
- slab_release (region);
-
- /* Schedules. */
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->stpf = false;
- alloc->glid = 0x45;
- alloc->end_time_atu = 3907;
- alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
- slab_release (alloc);
-
- cp_beacon__cco__unpack_fill (&cp, &unpack,
- CP_BEACON_CENTRAL_BEACON);
-
- test_fail_unless (unpack.bmis.eks.present == true);
- test_fail_unless (unpack.bmis.eks.new_eks == cp.beacon.eks.new_eks);
- test_fail_unless (unpack.bmis.eks.kccd == cp.beacon.eks.kccd);
- test_fail_unless (unpack.bmis.eks.kbc == cp.beacon.eks.kbc);
-
- test_fail_unless (unpack.bmis.mac_address.present == true);
- test_fail_unless (unpack.bmis.mac_address.mac_addr ==
- cp_sta_own_data_get_mac_address (&cp));
-
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- }
- test_end;
-
- test_begin (test, "Ca schedules")
- {
- cp_cco_bw_alloc_t *sched;
- ca_schedule_t *ca_sched;
- uint i;
-
- /* Add a schedule. */
- sched = cp_cco_bw_alloc_init (&cp);
- sched->stpf = false;
- sched->glid = 0x45;
- sched->end_time_atu = 3907;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
- slab_release (sched);
-
- cp_beacon_compute_ca_schedules (&cp);
-
- /* Verify the EKS in the CA schedules it still our SNID. */
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- test_fail_unless (ca_sched->nek_switch == 0x0);
- }
-
- /* Count down the eks countdown. */
- cp.beacon.eks.kccd = 2;
- cp.beacon.ca_schedule_index = 0;
- cp_beacon_compute_ca_schedules (&cp);
-
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- if (i < 2)
- test_fail_unless (ca_sched->nek_switch == 0x0);
- else
- test_fail_unless (ca_sched->nek_switch == 0x1);
- }
-
- /* No countdown. */
- cp.beacon.eks.kccd = 0;
- cp.beacon.eks.new_eks = MAC_EKS_MIN + 1;
- cp.beacon.ca_schedule_index = 0;
- cp_beacon_compute_ca_schedules (&cp);
-
- for (i = 0; i < 3; i++)
- {
- ca_sched = ca_alloc_get_schedule (cp.ca, i);
- test_fail_unless (ca_sched->nek_switch == 0x0);
- }
-
- cp_cco_bw_uninit (&cp);
- }
- test_end;
-
/* Uninit all the data. */
cp_beacon_uninit (&cp);
cp_sta_mgr_uninit (&cp);
diff --git a/cesar/cp/beacon/test/src/bentry.c b/cesar/cp/beacon/test/src/bentry.c
index 2410e34090..016a43ec9b 100644
--- a/cesar/cp/beacon/test/src/bentry.c
+++ b/cesar/cp/beacon/test/src/bentry.c
@@ -24,6 +24,12 @@
#include "cp/beacon/inc/bentry_size.h"
#include "cp/beacon/inc/unpack.h"
+u32
+mac_ntb (void)
+{
+ return 0;
+}
+
bool
cp_beacon_unpack_regions_less (set_node_t * left,
set_node_t * right);
@@ -75,27 +81,6 @@ test_case_bentry_process_header (test_t test)
test_fail_unless (ok == false);
}
test_end;
-
-
- test_begin (test, "Write")
- {
- bitstream_t bitstream;
- u8 buffer_test[256];
-
- bitstream_write_init (&bitstream, buffer_test, 8);
- cp_beacon_unpack_header_write (&bitstream,
- CP_BENTRY_AC_LINE_SYNC_COUNTDOWN,
- CP_BEACON_ENTRY_ACL);
- bitstream_finalise (&bitstream);
-
- bitstream_read_init (&bitstream, buffer_test, 2);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BENTRY_AC_LINE_SYNC_COUNTDOWN);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BEACON_ENTRY_ACL);
- bitstream_finalise (&bitstream);
- }
- test_end;
}
/** Mgr Beacon - Region
@@ -240,61 +225,6 @@ test_case_bentry_region (test_t test)
cp_cco_region_uninit (&cp);
}
test_end;
-
- test_begin (test, "Write")
- {
- cp_t cp;
- u8 buffer[256];
- bitstream_t bitstream;
- cp_beacon_unpack_t unpack;
- cp_beacon_unpack_region_t *region;
- set_t set_schedules;
- set_t set_regions;
-
- cp_cco_region_init (&cp);
- bitstream_write_init (&bitstream, buffer, CP_BEACON_ENTRY_REGION(2)
- + CP_BEACON_ENTRY_HEADER);
-
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- set_init (&set_regions, cp_cco_region_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- unpack.bmis.regions.present = true;
-
- region = cp_cco_region_alloc_init (&cp);
- region->end_time_atu = 60;
- region->type = CP_CCO_REGION_TYPE_PROTECTED;
- cp_cco_region_alloc_add (&cp, unpack.bmis.regions.set, region);
- slab_release (region);
-
- region = cp_cco_region_alloc_init (&cp);
- region->end_time_atu = 3907;
- region->type = CP_CCO_REGION_TYPE_STAYOUT;
- cp_cco_region_alloc_add (&cp, unpack.bmis.regions.set, region);
- slab_release (region);
-
- cp_beacon_unpack_regions_write (&cp, &bitstream, buffer, &unpack);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- cp_cco_region_uninit (&cp);
- bitstream_finalise (&bitstream);
-
- /* Verify the data. */
- bitstream_read_init (&bitstream, buffer, CP_BEACON_ENTRY_REGION(2)
- + CP_BEACON_ENTRY_HEADER);
- test_fail_unless (bitstream_read (&bitstream, 8) == CP_BENTRY_REGIONS);
- test_fail_unless (bitstream_read (&bitstream, 8) == CP_BEACON_ENTRY_REGION(2));
- test_fail_unless (bitstream_read (&bitstream, 6) == 2);
- test_fail_unless (bitstream_read (&bitstream, 2) == 0);
- test_fail_unless (bitstream_read (&bitstream, 4) ==
- CP_CCO_REGION_TYPE_PROTECTED);
- test_fail_unless (bitstream_read (&bitstream, 12) == 60);
- test_fail_unless (bitstream_read (&bitstream, 4) ==
- CP_CCO_REGION_TYPE_STAYOUT);
- test_fail_unless (bitstream_read (&bitstream, 12) == 3907);
- bitstream_finalise (&bitstream);
- }
- test_end;
}
/** Persistent schedules
@@ -474,124 +404,6 @@ test_case_bentry_persistent_schedules (test_t test)
cp_cco_bw_uninit (&cp);
}
test_end;
-
- test_begin (test, "Write")
- {
- cp_t cp;
- bitstream_t bitstream;
- cp_beacon_unpack_schedule_t *alloc;
- cp_beacon_unpack_t unpack;
- u8 buffer[256];
- set_t set_regions;
- set_t set_schedules;
-
- cp_cco_bw_init (&cp);
-
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- set_init (&set_regions, cp_cco_region_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- unpack.bmis.schedules.present = true;
- // Create the schedules.
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
- alloc->pscd = 2;
- alloc->cscd = 1;
- alloc->stpf = true;
- alloc->glid = 1;
- alloc->start_time_atu = 0;
- alloc->end_time_atu = 10;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, alloc);
- slab_release (alloc);
-
- // Create the schedules.
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
- alloc->pscd = 3;
- alloc->cscd = 2;
- alloc->stpf = false;
- alloc->glid = 2;
- alloc->end_time_atu = 50;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, alloc);
- slab_release (alloc);
-
- // Create the schedules.
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
- alloc->pscd = 2;
- alloc->cscd = 1;
- alloc->stpf = true;
- alloc->glid = 3;
- alloc->start_time_atu = 1500;
- alloc->end_time_atu = 3000;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, alloc);
- slab_release (alloc);
-
- bitstream_write_init (&bitstream, buffer, 19);
-
- cp_beacon_unpack_schedules_write (&cp,
- &bitstream,
- buffer,
- &unpack.bmis.schedules);
- bitstream_finalise (&bitstream);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
-
- /* Verify the data. */
- bitstream_read_init (&bitstream, buffer, 19);
-
- /* First bentry. */
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BENTRY_PERSISTENT_SCHEDULE);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BEACON_ENTRY_PERSISTENT_SCHED(2,0));
-
- /* Count down. */
- test_fail_unless (bitstream_read (&bitstream, 3) == 0x2);
- test_fail_unless (bitstream_read (&bitstream, 3) == 0x1);
- test_fail_unless (bitstream_read (&bitstream, 2) == 0);
-
- /* Number of session. */
- test_fail_unless (bitstream_read (&bitstream, 6) == 2);
- test_fail_unless (bitstream_read (&bitstream, 2) == 0);
-
- /* STPF = True, GLID = 1, ST = 0; ET = 10. */
- test_fail_unless (bitstream_read (&bitstream, 1) == true);
- test_fail_unless (bitstream_read (&bitstream, 7) == 1);
- test_fail_unless (bitstream_read (&bitstream, 12) == 0);
- test_fail_unless (bitstream_read (&bitstream, 12) == 10);
-
- /* STPF = true, GLID = 3, ST = 1500, ET = 3000 */
- test_fail_unless (bitstream_read (&bitstream, 1) == true);
- test_fail_unless (bitstream_read (&bitstream, 7) == 3);
- test_fail_unless (bitstream_read (&bitstream, 12) == 1500);
- test_fail_unless (bitstream_read (&bitstream, 12) == 3000);
-
- /* Second bentry. */
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BENTRY_PERSISTENT_SCHEDULE);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BEACON_ENTRY_PERSISTENT_SCHED(0,1));
-
- /* Count down. */
- test_fail_unless (bitstream_read (&bitstream, 3) == 0x3);
- test_fail_unless (bitstream_read (&bitstream, 3) == 0x2);
- test_fail_unless (bitstream_read (&bitstream, 2) == 0);
-
- /* Number of session. */
- test_fail_unless (bitstream_read (&bitstream, 6) == 1);
- test_fail_unless (bitstream_read (&bitstream, 2) == 0);
-
- /* STPF = false, GLID = 2, ET = 50. */
- test_fail_unless (bitstream_read (&bitstream, 1) == false);
- test_fail_unless (bitstream_read (&bitstream, 7) == 2);
- test_fail_unless (bitstream_read (&bitstream, 12) == 50);
- test_fail_unless (bitstream_read (&bitstream, 4) == 0);
- bitstream_finalise (&bitstream);
-
- cp_cco_bw_uninit (&cp);
- }
- test_end;
}
/** Non Persistent schedules
@@ -761,97 +573,6 @@ test_case_bentry_non_persistent_schedules (test_t test)
cp_cco_bw_uninit (&cp);
}
test_end;
-
- test_begin (test, "Write")
- {
- bitstream_t bitstream;
- cp_beacon_unpack_schedule_t *alloc;
- cp_beacon_unpack_t unpack;
- u8 buffer[256];
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- cp_cco_bw_init (&cp);
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
-
- unpack.bmis.schedules.present = true;
- // Create the schedules.
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->stpf = true;
- alloc->glid = 1;
- alloc->start_time_atu = 0;
- alloc->end_time_atu = 10;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, alloc);
- slab_release (alloc);
-
- // Create the schedules.
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->stpf = false;
- alloc->glid = 2;
- alloc->end_time_atu = 50;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, alloc);
- slab_release (alloc);
-
- // Create the schedules.
- alloc = cp_cco_bw_alloc_init (&cp);
- alloc->stpf = true;
- alloc->glid = 3;
- alloc->start_time_atu = 1500;
- alloc->end_time_atu = 3000;
- cp_cco_bw_alloc_add (&cp, unpack.bmis.schedules.set, alloc);
- slab_release (alloc);
-
- bitstream_write_init (&bitstream, buffer,
- CP_BEACON_ENTRY_NON_PERSISTENT_SCHED(2,1) +
- CP_BEACON_ENTRY_HEADER);
-
- cp_beacon_unpack_schedules_write (&cp,
- &bitstream,
- buffer,
- &unpack.bmis.schedules);
- bitstream_finalise (&bitstream);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
-
- /* Verify the data. */
- bitstream_read_init (&bitstream, buffer,
- CP_BEACON_ENTRY_NON_PERSISTENT_SCHED(2,1) +
- CP_BEACON_ENTRY_HEADER);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BENTRY_NON_PERSISTENT_SCHEDULE);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BEACON_ENTRY_NON_PERSISTENT_SCHED(2,1));
-
- /* Number of session. */
- test_fail_unless (bitstream_read (&bitstream, 6) == 3);
- test_fail_unless (bitstream_read (&bitstream, 2) == 0);
-
- /* STPF = True, GLID = 1, ST = 0; ET = 10. */
- test_fail_unless (bitstream_read (&bitstream, 1) == true);
- test_fail_unless (bitstream_read (&bitstream, 7) == 1);
- test_fail_unless (bitstream_read (&bitstream, 12) == 0);
- test_fail_unless (bitstream_read (&bitstream, 12) == 10);
-
- /* STPF = false, GLID = 2, ET = 50. */
- test_fail_unless (bitstream_read (&bitstream, 1) == false);
- test_fail_unless (bitstream_read (&bitstream, 7) == 2);
- test_fail_unless (bitstream_read (&bitstream, 12) == 50);
- test_fail_unless (bitstream_read (&bitstream, 4) == 0);
-
- /* STPF = true, GLID = 3, ST = 1500, ET = 3000 */
- test_fail_unless (bitstream_read (&bitstream, 1) == true);
- test_fail_unless (bitstream_read (&bitstream, 7) == 3);
- test_fail_unless (bitstream_read (&bitstream, 12) == 1500);
- test_fail_unless (bitstream_read (&bitstream, 12) == 3000);
- bitstream_finalise (&bitstream);
-
- cp_cco_bw_uninit (&cp);
- }
- test_end;
}
/** Writes a mac address or read it.
@@ -957,40 +678,6 @@ test_case_bentry_mac_address (test_t test)
bitstream_finalise (&bitstream);
}
test_end;
-
- test_begin (test, "Write")
- {
- u8 buffer[256];
- bitstream_t bitstream;
- cp_beacon_unpack_t unpack;
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- bitstream_write_init (&bitstream, buffer, 8);
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
-
- unpack.bmis.mac_address.present = true;
- unpack.bmis.mac_address.mac_addr = 0x123456789ABCull;
- cp_beacon_unpack_mac_address_write (&bitstream, &unpack);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- bitstream_finalise (&bitstream);
-
-
- bitstream_read_init (&bitstream, buffer, 8);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BENTRY_MAC_ADDRESS);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BEACON_ENTRY_MAC_ADDRESS);
- test_fail_unless (bitstream_read_large (&bitstream, 48) ==
- 0x123456789ABCull);
- bitstream_finalise (&bitstream);
- }
- test_end;
}
/** Discover bentry
@@ -1072,38 +759,6 @@ test_case_bentry_discover (test_t test)
cp_cco_region_alloc_clean (&cp, &set_regions);
}
test_end;
-
- test_begin (test, "Write")
- {
- bitstream_t bitstream;
- u8 buffer[256];
- cp_beacon_unpack_t unpack;
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- bitstream_write_init (&bitstream, buffer, 3);
-
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- unpack.bmis.discover.present = true;
- unpack.bmis.discover.tei = 0xc;
- cp_beacon_unpack_discover_write (&bitstream, &unpack);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- bitstream_finalise (&bitstream);
-
- bitstream_read_init (&bitstream, buffer, 3);
- test_fail_unless (bitstream_read (&bitstream, 8)
- == CP_BENTRY_DISCOVER);
- test_fail_unless (bitstream_read (&bitstream, 8)
- == CP_BEACON_ENTRY_DISCOVER);
- test_fail_unless (bitstream_read (&bitstream, 8) == 0xC);
- bitstream_finalise (&bitstream);
- }
- test_end;
}
/** Discover bentry info
@@ -1196,62 +851,6 @@ test_case_bentry_discover_info (test_t test)
cp_cco_region_alloc_clean (&cp, &set_regions);
}
test_end;
-
- test_begin (test, "Write")
- {
- u8 buffer[256];
- bitstream_t bitstream;
- uint discover_info_last = 0;
- cp_beacon_unpack_t unpack;
- cp_t cp;
-
- set_t set_schedules;
- set_t set_regions;
-
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- unpack.bmis.discover_info.present = true;
-
- unpack.bmis.discover_info.updated = true;
- unpack.bmis.discover_info.cco_cap = 2;
- unpack.bmis.discover_info.proxy_net_cap = true;
- unpack.bmis.discover_info.backup_cco_cap = false;
- unpack.bmis.discover_info.cco_status = false;
- unpack.bmis.discover_info.pco_status = true;
- unpack.bmis.discover_info.backup_cco_status = false;
- unpack.bmis.discover_info.num_dis_sta = 20;
- unpack.bmis.discover_info.num_dis_net = 30;
- unpack.bmis.discover_info.authentication = true;
- unpack.bmis.discover_info.status_user_ap_cco = false;
-
- bitstream_write_init (&bitstream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_DISCOVER_INFO);
-
- cp_beacon_unpack_discover_info_bentry_write (&bitstream,
- &unpack);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- bitstream_finalise (&bitstream);
- discover_info_last = bitstream_direct_read (buffer, 16, 32);
-
- test_fail_unless (discover_info_last != 0);
-
- bitstream_read_init (&bitstream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_DISCOVER_INFO);
- /* Headers. */
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BENTRY_DISCOVER_INFO);
- test_fail_unless (bitstream_read (&bitstream, 8) ==
- CP_BEACON_ENTRY_DISCOVER_INFO);
-
- test_fail_unless (bitstream_read (&bitstream, 32) ==
- discover_info_last);
-
- bitstream_finalise (&bitstream);
- }
- test_end;
}
/** BPSTO.
@@ -1313,51 +912,6 @@ test_case_bentry_bpsto (test_t test)
cp_cco_region_alloc_clean (&cp, &set_regions);
}
test_end;
-
- test_begin (test, "Write")
- {
- u8 buffer [10];
- bitstream_t stream;
- cp_beacon_unpack_t unpack;
- u8 *bpsto;
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
-
- bitstream_write_init (&stream, buffer,
- CP_BEACON_ENTRY_BPSTO+
- CP_BEACON_ENTRY_HEADER);
-
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
- unpack.bmis.bpsto.present = true;
- unpack.bmis.bpsto.bpsto = 0x1234;
- cp_beacon_unpack_bpsto_write (&stream, &unpack, buffer);
-
- bpsto = unpack.bmis.bpsto.bpsto_addr;
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- bitstream_finalise (&stream);
-
- /* Verify. */
- bitstream_read_init (&stream, buffer,
- CP_BEACON_ENTRY_BPSTO+
- CP_BEACON_ENTRY_HEADER);
-
- /* Header. */
- test_fail_unless (bitstream_read (&stream, 8)
- == CP_BENTRY_BEACON_PERIOD_START_OFFSET);
- test_fail_unless (bitstream_read (&stream, 8)
- == CP_BEACON_ENTRY_BPSTO);
- /* BPSTO. */
- test_fail_unless (bpsto == buffer + 2);
- bitstream_finalise (&stream);
- }
- test_end;
}
/** SNID BENTRY.
@@ -1411,46 +965,6 @@ test_case_bentry_snid (test_t test)
bitstream_finalise (&stream);
}
test_end;
-
- test_begin (test, "Write")
- {
- u8 buffer [10];
- bitstream_t stream;
- cp_beacon_unpack_t unpack;
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
-
- bitstream_write_init (&stream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_CHANGE_SNID);
-
- unpack.bmis.snids.present = true;
- unpack.bmis.snids.snid_cd = 3;
- unpack.bmis.snids.snid = 4;
-
- cp_beacon_unpack_snid_change_write (&stream, &unpack);
- bitstream_finalise (&stream);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
-
- bitstream_read_init (&stream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_CHANGE_SNID);
- test_fail_unless (bitstream_read (&stream, 8) ==
- CP_BENTRY_CHANGE_SNID);
- test_fail_unless (bitstream_read (&stream, 8) ==
- CP_BEACON_ENTRY_CHANGE_SNID);
-
-
- test_fail_unless (bitstream_read (&stream, 4) == 3);
- test_fail_unless (bitstream_read (&stream, 4) == 4);
- bitstream_finalise (&stream);
- }
- test_end;
}
/** HM BENTRY.
@@ -1504,46 +1018,6 @@ test_case_bentry_hm (test_t test)
bitstream_finalise (&stream);
}
test_end;
-
- test_begin (test, "Write")
- {
- u8 buffer [10];
- bitstream_t stream;
- cp_beacon_unpack_t unpack;
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
-
- bitstream_write_init (&stream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_CHANGE_HM);
-
- unpack.bmis.hm.present = true;
- unpack.bmis.hm.hmcd = 3;
- unpack.bmis.hm.hm = 1;
-
- cp_beacon_unpack_hm_change_write (&stream, &unpack);
- bitstream_finalise (&stream);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
-
- bitstream_read_init (&stream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_CHANGE_HM);
- test_fail_unless (bitstream_read (&stream, 8) ==
- CP_BENTRY_CHANGE_HM);
- test_fail_unless (bitstream_read (&stream, 8) ==
- CP_BEACON_ENTRY_CHANGE_HM);
-
-
- test_fail_unless (bitstream_read (&stream, 6) == 3);
- test_fail_unless (bitstream_read (&stream, 2) == 1);
- bitstream_finalise (&stream);
- }
- test_end;
}
/** EKS BENTRY.
@@ -1601,49 +1075,6 @@ test_case_bentry_eks (test_t test)
bitstream_finalise (&stream);
}
test_end;
-
- test_begin (test, "Write")
- {
- u8 buffer [10];
- bitstream_t stream;
- cp_beacon_unpack_t unpack;
- cp_t cp;
- set_t set_schedules;
- set_t set_regions;
-
- set_init (&set_regions, cp_cco_region_alloc_less);
- set_init (&set_schedules, cp_cco_bw_alloc_less);
- cp_beacon_unpack_init (&unpack, &set_schedules, &set_regions);
-
- bitstream_write_init (&stream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_EKC);
-
- unpack.bmis.eks.present = true;
- unpack.bmis.eks.kccd = 3;
- unpack.bmis.eks.kbc = CP_BEACON_EKS_KBC_NEK;
- unpack.bmis.eks.new_eks = 2;
-
- cp_beacon_unpack_eks_write (&stream, &unpack);
- bitstream_finalise (&stream);
- cp_beacon_unpack_uninit (&cp, &unpack);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
-
- bitstream_read_init (&stream, buffer, CP_BEACON_ENTRY_HEADER +
- CP_BEACON_ENTRY_EKC);
- test_fail_unless (bitstream_read (&stream, 8) ==
- CP_BENTRY_ENCRYPTION_KEY_CHANGE);
- test_fail_unless (bitstream_read (&stream, 8) ==
- CP_BEACON_ENTRY_EKC);
-
- test_fail_unless (bitstream_read (&stream, 6) == 3);
- test_fail_unless (bitstream_read (&stream, 1) == CP_BEACON_EKS_KBC_NEK);
- test_fail_unless (bitstream_read (&stream, 1) == 0);
- test_fail_unless (bitstream_read (&stream, 4) == 2);
- test_fail_unless (bitstream_read (&stream, 4) == 0);
- bitstream_finalise (&stream);
- }
- test_end;
}
int
diff --git a/cesar/cp/beacon/test/src/bsu_stub.c b/cesar/cp/beacon/test/src/bsu_stub.c
new file mode 100644
index 0000000000..9c248af962
--- /dev/null
+++ b/cesar/cp/beacon/test/src/bsu_stub.c
@@ -0,0 +1,17 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/bsu_stub.c
+ */
+#include "common/std.h"
+#include "bsu/bsu_beacon.h"
+
+void
+bsu_update (bsu_beacon_t *beacon, bool sta)
+{
+}
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index 023b4736e3..6fcd89d484 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -907,7 +907,7 @@ cp_cco_action__assoc__cco_start (cp_t *ctx)
/* Call the beacon module to send the central beacon. */
cp_beacon_discover_compute_interval (ctx);
- cp_beacon_cco_send_central_beacon (ctx);
+ cp_beacon_update_beacon_data (ctx);
/* trigger the event for the assoc FSM */
cp_fsm_trigger_new_event (ctx, bare, become_cco);
@@ -1014,7 +1014,7 @@ cp_cco_action_drv_mac_stop (cp_t *ctx)
void
cp_cco_action_drv_mac_stop_suspend (cp_t *ctx)
{
- cp_beacon_cco_send_central_beacon (ctx);
+ cp_beacon_update_beacon_data (ctx);
cp_cco_action_drv_mac_stop (ctx);
}
diff --git a/cesar/cp/cco/action/test/src/status.c b/cesar/cp/cco/action/test/src/status.c
index 775ddc0fd0..70e2776972 100644
--- a/cesar/cp/cco/action/test/src/status.c
+++ b/cesar/cp/cco/action/test/src/status.c
@@ -36,7 +36,7 @@
static bool central_beacon;
void
-cp_beacon_cco_send_central_beacon (cp_t *ctx)
+cp_beacon_update_beacon_data (cp_t *ctx)
{
central_beacon = true;
}
diff --git a/cesar/cp/cp.h b/cesar/cp/cp.h
index 05106691bc..5929542d6d 100644
--- a/cesar/cp/cp.h
+++ b/cesar/cp/cp.h
@@ -22,6 +22,7 @@
#include "hal/timer/timer.h"
#include "cl/cl.h"
#include "ce/rx/rx.h"
+#include "bsu/bsu_beacon.h"
BEGIN_DECLS
diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/fsm/src/fsm/cp.fsm
index abeeb0132d..93bdb6abe4 100644
--- a/cesar/cp/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/fsm/src/fsm/cp.fsm
@@ -494,7 +494,7 @@ SC_STA:
sc_succeed -> STA [NULL]
CCO:
- BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_send_central_beacon]
+ BEACON_TIMER_EXPIRES -> . [cp_beacon_update_beacon_data]
join_timeout: sta -> . [cp_sta_action_poweron__cco__join_timeout]
join_timeout: no sta avln -> USTA
join_timeout: no sta no avln -> UCCO
@@ -527,13 +527,13 @@ CCO_LEAVING:
CC_LEAVE_REQ -> . [cp_cco_action__cco__cc_leave]
CCO_LEAVING_HOIP:
- BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_send_central_beacon]
+ BEACON_TIMER_EXPIRES -> . [cp_beacon_update_beacon_data]
HANDOVER_SUCCESS -> UNASSOCIATING [cp_cco_action_drv_mac_stop_ended]
HANDOVER_FAILURE -> UNASSOCIATING [cp_cco_action_drv_mac_stop_ended]
SC_CCO:
- BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_send_central_beacon]
+ BEACON_TIMER_EXPIRES -> . [cp_beacon_update_beacon_data]
to_stop -> CCO_LEAVING [cp_cco_action_drv_mac_stop]
change_nek -> . [cp_cco_action_gen_nek]
snid_conflict -> . [cp_cco_action_snid_change]
@@ -618,7 +618,7 @@ HANDOVER_CCO:
CC_ASSOC_REQ -> . [cp_cco_action__cco__cc_assoc_req]
CM_GET_KEY_REQ_PID0 -> . [cp_cco_action__cco__cm_get_key_req_pid0]
CC_LEAVE_REQ -> . [cp_cco_action__cco__cc_leave]
- BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_send_central_beacon]
+ BEACON_TIMER_EXPIRES -> . [cp_beacon_update_beacon_data]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
HANDOVER_SUCCESS -> STA [cp_cco_action_handover_ended]
diff --git a/cesar/cp/inc/context.h b/cesar/cp/inc/context.h
index ff241952b6..1cab7060c5 100644
--- a/cesar/cp/inc/context.h
+++ b/cesar/cp/inc/context.h
@@ -55,7 +55,7 @@
#include "cp/fsm/inc/context.h"
#include "cp/pwl/inc/pwl.h"
#include "ce/tx/inc/tx.h"
-
+#include "bsu/bsu_beacon.h"
enum cp_handover_reason_t
{
@@ -84,6 +84,20 @@ struct cp_handover_t
enum cp_handover_soft_hard_t soft_hard;
};
+enum cp_shared_mem_slot_id_t
+{
+ CP_SHARED_MEM_SLOT_1 = 0,
+ CP_SHARED_MEM_SLOT_2,
+ CP_SHARED_MEM_SLOT_NB
+};
+typedef enum cp_shared_mem_slot_id_t cp_shared_mem_slot_id_t;
+
+struct shared_mem_t
+{
+ bsu_beacon_t bsu;
+};
+typedef struct shared_mem_t shared_mem_t;
+
struct cp_t
{
#if CONFIG_TRACE
@@ -170,6 +184,10 @@ struct cp_t
/** Context of the CE in RX. */
ce_rx_t *ce_rx;
+
+ /** Shared memory. */
+ shared_mem_t shared_mem[CP_SHARED_MEM_SLOT_NB];
+ cp_shared_mem_slot_id_t shared_mem_slot_id;
};
#endif /* cp_inc_cp_h */
diff --git a/cesar/cp/sta/action/src/poweron.c b/cesar/cp/sta/action/src/poweron.c
index a3169ae1b8..97a1b22e03 100644
--- a/cesar/cp/sta/action/src/poweron.c
+++ b/cesar/cp/sta/action/src/poweron.c
@@ -344,7 +344,6 @@ cp_sta_action_poweron__ucco__enter (cp_t *ctx)
{
dbg_assert (ctx);
cp_cco_action_snid_change_now (ctx);
- cp_beacon_cco_send_discover_beacon (ctx);
}
void
diff --git a/cesar/cp/sta/action/test/utest/src/beacon_stub.c b/cesar/cp/sta/action/test/utest/src/beacon_stub.c
index f59edb1d83..bf9e6ce5bd 100644
--- a/cesar/cp/sta/action/test/utest/src/beacon_stub.c
+++ b/cesar/cp/sta/action/test/utest/src/beacon_stub.c
@@ -24,13 +24,6 @@ cp_beacon_create_default_schedules (cp_t *ctx)
}
void
-cp_beacon_cco_send_discover_beacon (cp_t *ctx)
-{
- dbg_assert (ctx);
- scenario_event (cp_beacon_cco_send_discover_beacon);
-}
-
-void
cp_beacon_process_tracked_avln (cp_t *ctx, cp_beacon_desc_t *beacon,
cp_net_t *net)
{
@@ -43,7 +36,7 @@ cp_beacon_process_tracked_avln (cp_t *ctx, cp_beacon_desc_t *beacon,
}
void
-cp_beacon_cco_send_central_beacon (cp_t *ctx)
+cp_beacon_update_beacon_data (cp_t *ctx)
{
dbg_assert (ctx);
}