summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNicolas Schodet2011-02-15 11:16:36 +0100
committerNicolas Schodet2011-02-15 11:16:36 +0100
commit4eefd09b217ade356f68696faca9ae5e978efd25 (patch)
tree783095cab690e7fa0bb208b92db3eab093377a5c /cesar
parent5ca52877b8b48cb0f1a220127e18ae885ed8c646 (diff)
parentfe81eb7d148ead4a73f372c0afe2b008305d5928 (diff)
Merge branch 'master' into av
Conflicts: cesar/cp/cco/action/src/cco_action.c
Diffstat (limited to 'cesar')
-rw-r--r--cesar/common/make/default.mk4
-rw-r--r--cesar/common/std.h2
-rw-r--r--cesar/common/tests/tests6
-rw-r--r--cesar/cp/cco/action/src/cco_action.c23
-rw-r--r--cesar/cp/cco/action/test/utest/src/nek.c6
-rw-r--r--cesar/lib/defs.h7
-rw-r--r--cesar/tools/sniffer_phy/inc/lowlevel.h10
-rw-r--r--cesar/tools/sniffer_phy/inc/mme.h2
-rw-r--r--cesar/tools/sniffer_phy/src/lowlevel.c26
-rw-r--r--cesar/tools/sniffer_phy/src/mme.c11
-rw-r--r--cesar/tools/sniffer_phy/src/test_mme.c41
11 files changed, 104 insertions, 34 deletions
diff --git a/cesar/common/make/default.mk b/cesar/common/make/default.mk
index 9bf325be0e..290dfb62e7 100644
--- a/cesar/common/make/default.mk
+++ b/cesar/common/make/default.mk
@@ -7,7 +7,7 @@ HOST_INCLUDES := $(HOST_INCLUDES:%=-I$(BASE)/%) $(INCLUDES)
HOST_DEFS := $(HOST_DEFS) $(DEFS)
HOST_COMPILE_DEPS := $(HOST_COMPILE_DEPS) $(COMPILE_DEPS)
HOST_CPPFLAGS = $(EXTRA_HOST_CPPFLAGS) $(HOST_DEFS) $(HOST_INCLUDES)
-HOST_OPTIMIZE ?= $(call isdebug,-O,-O2)
+HOST_OPTIMIZE ?= $(call isdebug,,-O2)
HOST_CFLAGS := $(EXTRA_HOST_CFLAGS) -g $(HOST_OPTIMIZE) -finline \
-W -Wall -Wundef -Wno-unused-parameter
ifneq ($(HOST_COV)$(COV),)
@@ -23,7 +23,7 @@ TARGET_INCLUDES := $(TARGET_INCLUDES:%=-I$(BASE)/%) $(INCLUDES)
TARGET_DEFS := $(TARGET_DEFS) $(DEFS)
TARGET_COMPILE_DEPS := $(TARGET_COMPILE_DEPS) $(COMPILE_DEPS)
TARGET_CPPFLAGS = $(EXTRA_TARGET_CPPFLAGS) $(TARGET_DEFS) $(TARGET_INCLUDES)
-TARGET_OPTIMIZE ?= $(call isdebug,-O,-O2)
+TARGET_OPTIMIZE ?= $(call isdebug,,-O2)
TARGET_CFLAGS := $(EXTRA_TARGET_CFLAGS) -g $(TARGET_OPTIMIZE) -finline \
-W -Wall -Wundef -Wno-unused-parameter
ifneq ($(TARGET_COV)$(COV),)
diff --git a/cesar/common/std.h b/cesar/common/std.h
index d4387ead82..35fddc0951 100644
--- a/cesar/common/std.h
+++ b/cesar/common/std.h
@@ -23,8 +23,8 @@
# define END_DECLS
#endif
-#include "lib/types.h"
#include "lib/defs.h"
+#include "lib/types.h"
#include "lib/utils.h"
#include "lib/dbg.h"
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index c2c8e787ab..46cdc1aee7 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -43,7 +43,7 @@ make: make COV=y
cov test_maximus_timer: ./obj/test_maximus_timer
lib/test/bitstream:
-make: make COV=y
+make: make HOST_COV=y
cov test_bitstream: ./obj/test_bitstream
lib/test/blk:
@@ -119,7 +119,7 @@ make
!run: ./obj/test_test
lib/test/trace:
-make: make COV=y
+make: make HOST_COV=y
cov test_trace: ./obj/test_trace
lib/test/try:
@@ -128,7 +128,7 @@ cov test_try: ./obj/test_try
lib/test/utils:
make: make COV=y
-cov test_utils: ./obj/test_try
+cov test_utils: ./obj/test_utils
lib/scenario/test:
make: make COV=y
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index 6681775a0b..ad28ec7d5a 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -51,6 +51,20 @@
#include "bsu/bsu.h"
/**
+ * Progam a timer to post a change_nek event
+ * \param ctx the module context.
+ */
+static void
+cp_cco_action_nek_change_timer_program (cp_t *ctx)
+{
+ /* Prepare next change. */
+ cp_fsm_event_t *event =
+ cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_change_nek);
+ cp_sta_core_gen_timed_event (ctx, &ctx->cco_action.nek_change,
+ event, HPAV_NEK_CHANGE_MS);
+}
+
+/**
* Choose a SNID between the ones available.
* \param ctx the CP context.
*/
@@ -286,9 +300,10 @@ cp_cco_action_gen_nek (cp_t *ctx)
/* POST the FSM event. */
cp_fsm_post_new_event (ctx, bare, nek_provide);
+ /* Prepare next change. */
+ cp_cco_action_nek_change_timer_program (ctx);
}
-
/**
* Send the SET tei map IND to all the station with the TEI of the new one.
* \param ctx the CP context.
@@ -837,7 +852,6 @@ cp_cco_action_start (cp_t *ctx)
cp_net_t *net;
cp_nid_t nid;
cp_snid_t snid;
- cp_fsm_event_t *event;
cp_sta_own_data_t *own;
dbg_assert (ctx);
/* Verify if the station does not already have a TEI. */
@@ -864,10 +878,7 @@ cp_cco_action_start (cp_t *ctx)
cp_sta_own_data_set_authenticated_status (ctx, true);
cp_sta_own_data_set_cco_status (ctx, true);
// Program the timer to change the NEKs.
- event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_change_nek);
- cp_sta_core_gen_cyclic_event (ctx, &ctx->cco_action.nek_change,
- event,
- HPAV_NEK_CHANGE_MS);
+ cp_cco_action_nek_change_timer_program (ctx);
cp_beacon_process_untracked_avln (ctx);
cp_beacon_cco_update_beacon_data (ctx);
/* trigger the event for the assoc FSM */
diff --git a/cesar/cp/cco/action/test/utest/src/nek.c b/cesar/cp/cco/action/test/utest/src/nek.c
index 140450540d..96c03f3e30 100644
--- a/cesar/cp/cco/action/test/utest/src/nek.c
+++ b/cesar/cp/cco/action/test/utest/src/nek.c
@@ -42,6 +42,8 @@ nek_change (test_t t)
SCENARIO_ACTION (gen_nek),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_nek_provide),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_change_nek),
SCENARIO_ACTION (nek_provide),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (CCO_NEK_CHANGE_IDLE,
@@ -68,6 +70,8 @@ nek_change (test_t t)
SCENARIO_ACTION (gen_nek),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_nek_provide),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_change_nek),
/* First Message exchange. */
SCENARIO_ACTION (nek_provide),
SCENARIO_EVENT (cp_msg_cm_set_key_req_send,
@@ -163,6 +167,8 @@ nek_change (test_t t)
SCENARIO_ACTION (gen_nek),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_nek_provide),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_change_nek),
/* First Message exchange. */
SCENARIO_ACTION (nek_provide),
SCENARIO_EVENT (cp_msg_cm_set_key_req_send,
diff --git a/cesar/lib/defs.h b/cesar/lib/defs.h
index 695b8d8832..a55850bf12 100644
--- a/cesar/lib/defs.h
+++ b/cesar/lib/defs.h
@@ -38,4 +38,11 @@
# define warn_unused_result
#endif
+#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
+ && defined (__NO_INLINE__))
+/* We really really want inlining. GCC 4.4 will not inline if optimization is
+ * disable. */
+# define inline inline __attribute__ ((always_inline))
+#endif
+
#endif /* lib_defs_h */
diff --git a/cesar/tools/sniffer_phy/inc/lowlevel.h b/cesar/tools/sniffer_phy/inc/lowlevel.h
index b21b2d30f2..7776dc3ea0 100644
--- a/cesar/tools/sniffer_phy/inc/lowlevel.h
+++ b/cesar/tools/sniffer_phy/inc/lowlevel.h
@@ -65,6 +65,8 @@ struct lowlevel_t
{
/* Phy context. */
phy_t *phy;
+ /** Receive payload. */
+ bool rx_pb;
/** Block pool head. */
blk_t *pool_head;
/** Block pool tail. */
@@ -101,6 +103,14 @@ lowlevel_init (sniffer_phy_t *ctx);
void
lowlevel_activate (sniffer_phy_t *ctx, bool state);
+/**
+ * Activate payload reception.
+ * \param ctx sniffer context
+ * \param rx_pb payload reception status
+ */
+void
+lowlevel_rx_pb (sniffer_phy_t *ctx, bool rx_pb);
+
END_DECLS
#endif /* inc_lowlevel_h */
diff --git a/cesar/tools/sniffer_phy/inc/mme.h b/cesar/tools/sniffer_phy/inc/mme.h
index 613e8bd734..b7b081727b 100644
--- a/cesar/tools/sniffer_phy/inc/mme.h
+++ b/cesar/tools/sniffer_phy/inc/mme.h
@@ -22,6 +22,8 @@ struct mme_t
mac_t mac;
/** MAC address to send sniffed data to. */
mac_t mac_sniffer;
+ /** Current sniffing status. */
+ u8 status;
/** Take PB content. */
bool pb;
};
diff --git a/cesar/tools/sniffer_phy/src/lowlevel.c b/cesar/tools/sniffer_phy/src/lowlevel.c
index 1b79f412f0..4a38e52374 100644
--- a/cesar/tools/sniffer_phy/src/lowlevel.c
+++ b/cesar/tools/sniffer_phy/src/lowlevel.c
@@ -47,8 +47,8 @@ lowlevel_fc_analyse (sniffer_phy_t *ctx, const u32 *fc_av,
MAC_DX417_TCK, MAC_DX567_TCK, MAC_DX3534_TCK };
pbproc_fc_t *fc = (pbproc_fc_t *) fc_av;
mpdu->pb_nb = 0;
- /* CRC OK and enough pool? */
- if (fc_av && ctx->lowlevel.pool_size > 1)
+ /* CRC OK, payload requested and enough pool? */
+ if (fc_av && ctx->lowlevel.rx_pb && ctx->lowlevel.pool_size > 1)
{
/* Decode FC. */
switch (fc->generic.dt_av)
@@ -90,8 +90,12 @@ lowlevel_fc_analyse (sniffer_phy_t *ctx, const u32 *fc_av,
/ symbol_tck[mpdu->tm->gil] + 2);
/* Compute number of PB. */
uint bits_per_pb = mpdu->tm->bits_per_pb[PHY_PB_SIZE_520];
- mpdu->pb_nb = ((symb_nb - 1) * mpdu->tm->bits_per_symbol
- + bits_per_pb) / bits_per_pb;
+ uint bits_per_symbol = mpdu->tm->bits_per_symbol;
+ if (bits_per_pb >= bits_per_symbol)
+ mpdu->pb_nb = symb_nb * bits_per_symbol / bits_per_pb;
+ else
+ mpdu->pb_nb = ((symb_nb - 1) * bits_per_symbol
+ + bits_per_pb) / bits_per_pb;
}
break;
default:
@@ -102,8 +106,9 @@ lowlevel_fc_analyse (sniffer_phy_t *ctx, const u32 *fc_av,
if (mpdu->pb_nb)
{
uint bits_per_pb = mpdu->tm->bits_per_pb[mpdu->pb_size];
- mpdu->symbol_nb = (1 * bits_per_pb + mpdu->tm->bits_per_symbol -
- 1) / mpdu->tm->bits_per_symbol;
+ uint bits_per_symbol = mpdu->tm->bits_per_symbol;
+ mpdu->symbol_nb = (mpdu->pb_nb * bits_per_pb
+ + bits_per_symbol - 1) / bits_per_symbol;
}
}
}
@@ -257,6 +262,7 @@ lowlevel_init (sniffer_phy_t *ctx)
static tonemask_info_t tonemask_info;
dbg_assert (ctx);
/* Initialise context. */
+ ctx->lowlevel.rx_pb = false;
slist_init (ctx->lowlevel.pool_, paste_size);
slist_init (ctx->lowlevel.rx_, paste);
ctx->lowlevel.rxing = NULL;
@@ -294,3 +300,11 @@ lowlevel_activate (sniffer_phy_t *ctx, bool state)
phy_rx_activate (ctx->lowlevel.phy, true, 0, state);
}
+void
+lowlevel_rx_pb (sniffer_phy_t *ctx, bool rx_pb)
+{
+ dbg_assert (ctx);
+ /* Keep setting. */
+ ctx->lowlevel.rx_pb = rx_pb;
+}
+
diff --git a/cesar/tools/sniffer_phy/src/mme.c b/cesar/tools/sniffer_phy/src/mme.c
index 31b6d0f61c..c90d88bf4a 100644
--- a/cesar/tools/sniffer_phy/src/mme.c
+++ b/cesar/tools/sniffer_phy/src/mme.c
@@ -174,9 +174,7 @@ mme_send_vs_sniffer_cnf (sniffer_phy_t *ctx, mme_buffer_t *mme, u8 result)
{
/* Write MME. */
bitstream_write (&cnf.bitstream, result, 8);
- bitstream_write (&cnf.bitstream,
- ctx->mme.mac_sniffer ? MME_SNIFFER_MODE_RX_FC : 0,
- 8);
+ bitstream_write (&cnf.bitstream, ctx->mme.status, 8);
bitstream_write_large (&cnf.bitstream, ctx->mme.mac_sniffer, 48);
/* Send MME. */
mme_send (ctx, &cnf);
@@ -209,10 +207,13 @@ mme_handle_vs_sniffer_req (sniffer_phy_t *ctx, mme_buffer_t *mme)
result = 0;
bool was_activated = ctx->mme.mac_sniffer != 0;
bool is_activated = command != 0;
+ bool is_rx_pb = (command & MME_SNIFFER_MODE_RX_PB) != 0;
+ ctx->mme.mac_sniffer = is_activated ? mme->sa : 0;
+ ctx->mme.pb = is_rx_pb;
+ ctx->mme.status = command;
if (was_activated != is_activated)
lowlevel_activate (ctx, is_activated);
- ctx->mme.mac_sniffer = is_activated ? mme->sa : 0;
- ctx->mme.pb = (command & MME_SNIFFER_MODE_RX_PB) != 0;
+ lowlevel_rx_pb (ctx, is_rx_pb);
} while (0);
/* Send feedback. */
mme_send_vs_sniffer_cnf (ctx, mme, result);
diff --git a/cesar/tools/sniffer_phy/src/test_mme.c b/cesar/tools/sniffer_phy/src/test_mme.c
index 914e08b452..f1cb0bdda5 100644
--- a/cesar/tools/sniffer_phy/src/test_mme.c
+++ b/cesar/tools/sniffer_phy/src/test_mme.c
@@ -84,6 +84,12 @@ static bool rx_activate_expect;
/* Expected activation status. */
static bool rx_activate_state_expect;
+/* Expect payload receiving status set, reset when done. */
+static bool rx_pb_expect;
+
+/* Expected payload receiving status. */
+static bool rx_pb_state_expect;
+
void
lowlevel_activate (sniffer_phy_t *ctx, bool state)
{
@@ -93,6 +99,15 @@ lowlevel_activate (sniffer_phy_t *ctx, bool state)
rx_activate_expect = false;
}
+void
+lowlevel_rx_pb (sniffer_phy_t *ctx, bool rx_pb)
+{
+ dbg_assert (ctx);
+ dbg_assert (rx_pb_expect);
+ dbg_assert (rx_pb == rx_pb_state_expect);
+ rx_pb_expect = false;
+}
+
/* Test unhandled frames reception. */
static void
mme_unhandled_test_case (test_t t, sniffer_phy_t *ctx)
@@ -282,6 +297,7 @@ mme_sniffer_test (test_t t, sniffer_phy_t *ctx, const char *test_name,
mac_t s_sa, u8 s_command,
u8 r_result, u8 r_status, mac_t r_da,
bool rx_activate, bool rx_activate_state,
+ bool rx_pb, bool rx_pb_state,
mac_t sniffer_before, mac_t sniffer_after,
bool pb_before, bool pb_after)
{
@@ -322,10 +338,13 @@ mme_sniffer_test (test_t t, sniffer_phy_t *ctx, const char *test_name,
send_unexpected = false;
rx_activate_expect = rx_activate;
rx_activate_state_expect = rx_activate_state;
+ rx_pb_expect = rx_pb;
+ rx_pb_state_expect = rx_pb_state;
mme_handle (ctx, (u8 *) buffer, length);
test_fail_unless (!send_expect.buffer);
test_fail_if (send_unexpected);
test_fail_unless (!rx_activate_expect);
+ test_fail_unless (!rx_pb_expect);
test_fail_unless (ctx->mme.mac_sniffer == sniffer_after);
test_fail_unless (ctx->mme.pb == pb_after);
} test_end;
@@ -340,49 +359,49 @@ mme_sniffer_test_case (test_t t, sniffer_phy_t *ctx)
mme_sniffer_test (t, ctx, "req subscribe ok",
TEST_MME_MAC_PEER, 0x20,
0x00, 0x20, TEST_MME_MAC_PEER,
- true, true,
+ true, true, true, false,
0, TEST_MME_MAC_PEER,
false, false);
mme_sniffer_test (t, ctx, "req subscribe again ok",
TEST_MME_MAC_PEER, 0x20,
0x00, 0x20, TEST_MME_MAC_PEER,
- false, false,
+ false, false, true, false,
TEST_MME_MAC_PEER, TEST_MME_MAC_PEER,
false, false);
mme_sniffer_test (t, ctx, "req subscribe change ok",
TEST_MME_MAC_PEER, 0xa0,
- 0x00, 0x20, TEST_MME_MAC_PEER,
- false, false,
+ 0x00, 0xa0, TEST_MME_MAC_PEER,
+ false, false, true, true,
TEST_MME_MAC_PEER, TEST_MME_MAC_PEER,
false, true);
mme_sniffer_test (t, ctx, "req subscribe another nok",
TEST_MME_MAC_OTHER, 0x20,
- 0x01, 0x20, TEST_MME_MAC_PEER,
- false, false,
+ 0x01, 0xa0, TEST_MME_MAC_PEER,
+ false, false, false, false,
TEST_MME_MAC_PEER, TEST_MME_MAC_PEER,
true, true);
mme_sniffer_test (t, ctx, "req unsubscribe another nok",
TEST_MME_MAC_OTHER, 0x00,
- 0x01, 0x20, TEST_MME_MAC_PEER,
- false, false,
+ 0x01, 0xa0, TEST_MME_MAC_PEER,
+ false, false, false, false,
TEST_MME_MAC_PEER, TEST_MME_MAC_PEER,
true, true);
mme_sniffer_test (t, ctx, "req unsubscribe ok",
TEST_MME_MAC_PEER, 0x00,
0x00, 0x00, 0,
- true, false,
+ true, false, true, false,
TEST_MME_MAC_PEER, 0,
true, false);
mme_sniffer_test (t, ctx, "req bad command",
TEST_MME_MAC_PEER, 0x10,
0x01, 0x00, 0,
- false, false,
+ false, false, false, false,
0, 0,
false, false);
mme_sniffer_test (t, ctx, "req bad mme",
TEST_MME_MAC_PEER, 0xff,
0x01, 0x00, 0,
- false, false,
+ false, false, false, false,
0, 0,
false, false);
}