summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 10:02:32 +0000
committerlaranjeiro2010-05-17 10:02:32 +0000
commit7df2148dacdbdc1b32996d9796253e86525a81a6 (patch)
tree4be6530af7a5df5a2d2d97b6f1ea939444b7553e /cesar
parentd8192f658601b966b814dd78040249c311678de7 (diff)
cesar/bsu: add a function to compute the nbe in the beacon
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7066 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/beacon/src/beacon.c58
-rw-r--r--cesar/bsu/test/utest/src/tests.c2
2 files changed, 58 insertions, 2 deletions
diff --git a/cesar/bsu/beacon/src/beacon.c b/cesar/bsu/beacon/src/beacon.c
index 6658368e6c..d6e8323714 100644
--- a/cesar/bsu/beacon/src/beacon.c
+++ b/cesar/bsu/beacon/src/beacon.c
@@ -407,6 +407,60 @@ bsu_beacon_write_bmi_mac_address (bitstream_t *stream,
}
}
+/**
+ * Compute the number of beacon entries are present in the beacon.
+ * \param beacon the beacon data to store in the beacon.
+ * \param type the beacon type.
+ * \param mac_config the MAC configuration structure to get the TEI.
+ * \return the number of Beacon entries present in the beacon.
+ */
+static inline uint
+bsu_beacon_write_nbe_nb (bsu_beacon_t *beacon, bsu_beacon_type_t type,
+ mac_config_t *mac_config)
+{
+ uint nbe = 1;
+ dbg_assert (beacon->bmis.region.nb);
+ dbg_assert ((type == BSU_BEACON_TYPE_DISCOVER &&
+ beacon->bmis.discover_info.present)
+ || type != BSU_BEACON_TYPE_DISCOVER);
+ dbg_assert ((type == BSU_BEACON_TYPE_CENTRAL
+ && ((mac_config->tei == beacon->bmis.discover.tei
+ && beacon->bmis.discover_info.present)
+ || mac_config->tei != beacon->bmis.discover.tei))
+ || type != BSU_BEACON_TYPE_CENTRAL);
+ dbg_assert ((beacon->vf.nm == BSU_BEACON_NM_CSMA_ONLY &&
+ beacon->bmis.bpsto.present)
+ || (beacon->vf.nm != BSU_BEACON_NM_CSMA_ONLY &&
+ !beacon->bmis.bpsto.present));
+ if (beacon->bmis.ps.nb)
+ nbe += beacon->bmis.ps.nb;
+ nbe += beacon->bmis.nps.ns ? 1 : 0;
+ if (beacon->bmis.discover.present && type == BSU_BEACON_TYPE_CENTRAL)
+ nbe++;
+ if (beacon->bmis.bpsto.present)
+ nbe++;
+ if (beacon->bmis.discover_info.present
+ && type == BSU_BEACON_TYPE_DISCOVER)
+ nbe++;
+ if (beacon->bmis.eks.present)
+ nbe++;
+ if (beacon->bmis.handover.present)
+ nbe++;
+ if (beacon->bmis.relocation.present)
+ nbe++;
+ if (beacon->bmis.aclsc.present)
+ nbe++;
+ if (beacon->bmis.cns.present)
+ nbe++;
+ if (beacon->bmis.change_hm.present)
+ nbe++;
+ if (beacon->bmis.change_snid.present)
+ nbe++;
+ if (beacon->bmis.mac_address_present.present)
+ nbe++;
+ return nbe;
+}
+
pb_beacon_t*
bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
mac_config_t *mac_config, pbproc_tx_beacon_params_t *params)
@@ -423,7 +477,9 @@ bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
bitstream_write_init (&stream, pbbeacon->data, BSU_BEACON_SIZE);
bsu_beacon_write_variant_fields (
pbbeacon, &stream, mac_config, beacon, type);
- bitstream_write (&stream, beacon->bmis.nbe, 8);
+ uint nbe = bsu_beacon_write_nbe_nb (beacon, type, mac_config);
+ dbg_assert (nbe);
+ bitstream_write (&stream, nbe, 8);
bsu_beacon_write_bmi_region (&stream, &beacon->bmis.region);
bsu_beacon_write_bmi_non_persistent (&stream, &beacon->bmis.nps,
pbbeacon->data);
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index 530371a857..b82f3d0126 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -132,7 +132,7 @@ bsu_test_create_beacon (bsu_test_t *ctx, bsu_beacon_t *beacon)
beacon->vf.aclsss = true;
beacon->vf.hoip = false;
beacon->vf.rtsbf = false;
- beacon->vf.nm = false;
+ beacon->vf.nm = BSU_BEACON_NM_CSMA_ONLY;
beacon->vf.ccocap = 0;
beacon->vf.rsvd = 0;
/* Regions. */