From 7df2148dacdbdc1b32996d9796253e86525a81a6 Mon Sep 17 00:00:00 2001 From: laranjeiro Date: Mon, 17 May 2010 10:02:32 +0000 Subject: 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 --- cesar/bsu/beacon/src/beacon.c | 58 +++++++++++++++++++++++++++++++++++++++- cesar/bsu/test/utest/src/tests.c | 2 +- 2 files changed, 58 insertions(+), 2 deletions(-) (limited to 'cesar') 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. */ -- cgit v1.2.3