summaryrefslogtreecommitdiff
path: root/cesar/bsu
diff options
context:
space:
mode:
authorlaranjeiro2010-06-04 07:46:32 +0000
committerlaranjeiro2010-06-04 07:46:32 +0000
commitcc25b773870176a18a841de98223c0f89dde5adf (patch)
treed30281be8da1f2acc4aa1b95ceeb30827e691afc /cesar/bsu
parentb820b3d7437b1d0d0149877a683a85ea03b3f442 (diff)
cesar/bsu: does not provide crc false beacons to upper layers
When bsu process a beacon, if the crc is false, the beacon is released. So if the beacon is provided to upper layer, it will work on a freed block git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7161 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/bsu')
-rw-r--r--cesar/bsu/inc/bsu.h3
-rw-r--r--cesar/bsu/src/bsu.c7
-rw-r--r--cesar/bsu/src/interface.c12
-rw-r--r--cesar/bsu/test/utest/src/interface.c8
4 files changed, 20 insertions, 10 deletions
diff --git a/cesar/bsu/inc/bsu.h b/cesar/bsu/inc/bsu.h
index 6b81623833..d4aec8a338 100644
--- a/cesar/bsu/inc/bsu.h
+++ b/cesar/bsu/inc/bsu.h
@@ -21,8 +21,9 @@ BEGIN_DECLS
* \param ctx the bsu context.
* \param beacon the beacon received.
* \param params the phy rx params.
+ * \return true if the beacon is valid.
*/
-void
+bool
bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
pbproc_rx_beacon_params_t *params);
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index dc7623433e..952bd9b1db 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -467,7 +467,7 @@ bsu_uninit (bsu_t *ctx)
bsu_trace_uninit (ctx);
}
-void
+bool
bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
pbproc_rx_beacon_params_t *params)
{
@@ -475,7 +475,9 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
dbg_assert (beacon);
dbg_assert (params);
/* Check the CRC. */
- if (!((pb_t *) beacon)->phy_pb.pb_rx.pb_measurement.crc_error)
+ bool crc_ok =
+ !((pb_t *) beacon)->phy_pb.pb_rx.pb_measurement.crc_error;
+ if (crc_ok)
{
bsu_beacon_track_info_t tinfo;
bsu_beacon_read_track_info (beacon, &tinfo);
@@ -540,6 +542,7 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
blk_release_desc ((blk_t*) beacon);
BSU_TRACE (BEACON_CRC_ERROR, phy_date ());
}
+ return crc_ok;
}
/**
diff --git a/cesar/bsu/src/interface.c b/cesar/bsu/src/interface.c
index 8c0d488506..d4540f36aa 100644
--- a/cesar/bsu/src/interface.c
+++ b/cesar/bsu/src/interface.c
@@ -123,9 +123,11 @@ bsu_beacon_recv (bsu_t *ctx, pb_beacon_t *beacon,
arch_load_cache (&beacon->first_data_word, 1);
arch_load_cache ((u32*) beacon->data, BLK_SIZE / 4);
/* Process the beacon received from the SAR. */
- bsu_beacon_process (ctx, beacon, params);
- /* Send it to the upper layer. */
- bsu_params_t * bsu_params = bsu_params_store (
- ctx, beacon, BSU_BEACON_DIRECTION_FROM_PLC, ctx->sta_avln);
- (*ctx->ul_cb) (ctx->ul_data, beacon, bsu_params);
+ if (bsu_beacon_process (ctx, beacon, params))
+ {
+ /* Send it to the upper layer. */
+ bsu_params_t * bsu_params = bsu_params_store (
+ ctx, beacon, BSU_BEACON_DIRECTION_FROM_PLC, ctx->sta_avln);
+ (*ctx->ul_cb) (ctx->ul_data, beacon, bsu_params);
+ }
}
diff --git a/cesar/bsu/test/utest/src/interface.c b/cesar/bsu/test/utest/src/interface.c
index b718426948..f050ad83eb 100644
--- a/cesar/bsu/test/utest/src/interface.c
+++ b/cesar/bsu/test/utest/src/interface.c
@@ -85,7 +85,7 @@ void
test_case_bsu_interface_rx (test_t t)
{
test_case_begin (t, "Beacon Reception");
- test_begin (t, "Receive")
+ test_begin (t, "Receive CRC Ok, CRC False")
{
bsu_test_t test;
pb_beacon_t *beacon;
@@ -112,8 +112,12 @@ test_case_bsu_interface_rx (test_t t)
BSU_NTB_FIXED_POINT));
test_fail_unless (test.ul.bparams->ntb_offset_tck
== test.bsu->avlns[0].sync.ntb_offset_tck);
+ memset (&test.ul, 0, sizeof (bsu_test_ul_t));
+ beacon->phy_pb.pb_rx.pb_measurement.crc_error = true;
+ bsu_beacon_recv (test.bsu, beacon, &rx_params);
+ test_fail_unless (test.ul.beacon == NULL);
+ test_fail_unless (test.ul.bparams == NULL);
bsu_test_uninit (&test);
- blk_release_desc ((blk_t*) beacon);
}
test_end;
}