summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-04-14 18:12:10 +0200
committerNélio Laranjeiro2011-04-20 18:06:21 +0200
commitf39d2baf181a50539c68247211de7f21cabc2203 (patch)
tree5dbb02ea7d47910e27d282d5716aa885574b87a1 /cesar/cp
parent0623d2b5eb6666d6eb1f0f3e67e306726c674406 (diff)
cesar/cp/cl_interf: update station expired date on MME reception, refs #2196
Get the station from the sta mgr, if it exists the expired date in ms is updated, otherwise nothing is done.
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/cl_interf/src/cl_interf.c12
-rw-r--r--cesar/cp/cl_interf/test/src/test-cl-interf.c64
2 files changed, 76 insertions, 0 deletions
diff --git a/cesar/cp/cl_interf/src/cl_interf.c b/cesar/cp/cl_interf/src/cl_interf.c
index cf7b92376c..f08d8542e5 100644
--- a/cesar/cp/cl_interf/src/cl_interf.c
+++ b/cesar/cp/cl_interf/src/cl_interf.c
@@ -139,6 +139,18 @@ cp_cl_interf_process_mme (cp_t *ctx)
CP_TRACE (CL_INTERF_MME_NOT_CORRECT, msg->buffer);
else
{
+ /* The MME header is correct, try to get the station to update the
+ * expired date. */
+ if (MAC_IS_VALID (mme->peer.mac))
+ {
+ cp_sta_t *sta = cp_sta_mgr_sta_get_from_mac (ctx, mme->peer.mac);
+ if (sta)
+ {
+ sta->expired_date_ms = cp_sta_core_get_date_ms (ctx)
+ + HPAV_DISCOVERED_LIST_EXPIRE_TIME_MS;
+ slab_release (sta);
+ }
+ }
// Verify if the MME is a segmented MME.
if (fmi)
{
diff --git a/cesar/cp/cl_interf/test/src/test-cl-interf.c b/cesar/cp/cl_interf/test/src/test-cl-interf.c
index fdc68d7889..9f5c4c56ee 100644
--- a/cesar/cp/cl_interf/test/src/test-cl-interf.c
+++ b/cesar/cp/cl_interf/test/src/test-cl-interf.c
@@ -26,6 +26,7 @@
#include "cp/cl_interf/cl_interf.h"
#include "cp/cl_interf/inc/cl_interf.h"
#include "cp/cl_interf/inc/cl_interf_msg.h"
+#include "cp/sta/core/core.h"
static cp_mme_rx_t *dispatch_mme_rx;
@@ -288,6 +289,68 @@ test_case_cl_interf_send_mme (test_t test)
test_end;
}
+void
+test_case_cl_interf_mme_rx_update_sta_expired_date_run (
+ test_t test, cp_t *cp, mac_t itsmac)
+{
+ test_within (test);
+ u8 buffer [ETH_PACKET_MAX_SIZE];
+ mac_t mymac = cp_sta_own_data_get_mac_address (cp);
+ bitstream_t stream;
+ bitstream_write_init (&stream, buffer, 23);
+ bitstream_write_large (&stream, mymac, 48);
+ bitstream_write_large (&stream, itsmac, 48);
+ bitstream_write (&stream, swap16(HPAV_MTYPE_MME), 16);
+ bitstream_write (&stream, 1, 8);
+ bitstream_write (&stream, 0x3245, 16);
+ bitstream_write (&stream, 0, 4);
+ bitstream_write (&stream, 0, 4);
+ bitstream_write (&stream, 0, 4);
+ bitstream_finalise (&stream);
+ dispatch_mme_rx = NULL;
+ cp_cl_interf_rx_mme (cp, 1, buffer, 60, INVALID_PTR, true);
+ cp_cl_interf_process_mme (cp);
+ test_fail_unless (dispatch_mme_rx);
+ blk_release (dispatch_mme_rx);
+}
+
+void
+test_case_cl_interf_mme_rx_update_sta_expired_date (test_t test)
+{
+ mac_t mymac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01);
+ cp_t cp;
+ test_cl_interf_init (&cp);
+ cp_net_t *net = cp_sta_mgr_add_avln (&cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&cp, net);
+ cp_sta_own_data_set_tei (&cp, 254);
+ cp_sta_own_data_set_mac_address (&cp, mymac);
+ test_case_begin (test, "Receive an MME and update STA expired date");
+ test_begin (test, "station does not exists in station manager")
+ {
+ mac_t itsmac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x02);
+ test_case_cl_interf_mme_rx_update_sta_expired_date_run (
+ test, &cp, MAC_BROADCAST);
+ cp_sta_t *sta = cp_sta_mgr_sta_get_from_mac (&cp, itsmac);
+ test_fail_unless (!sta);
+ test_case_cl_interf_mme_rx_update_sta_expired_date_run (
+ test, &cp, itsmac);
+ sta = cp_sta_mgr_sta_get_from_mac (&cp, itsmac);
+ test_fail_unless (!sta);
+ sta = cp_sta_mgr_sta_add (
+ &cp, net, 1, itsmac);
+ u32 expired_date_ms = sta->expired_date_ms =
+ cp_sta_core_get_date_ms (&cp) -
+ HPAV_DISCOVERED_LIST_EXPIRE_TIME_MS;
+ test_case_cl_interf_mme_rx_update_sta_expired_date_run (
+ test, &cp, itsmac);
+ test_fail_unless (sta->expired_date_ms != expired_date_ms);
+ cp_sta_mgr_sta_remove (&cp, sta);
+ slab_release (sta);
+ }
+ test_end;
+ test_cl_interf_uninit (&cp);
+}
+
int
main (int argc, char **argv)
{
@@ -299,6 +362,7 @@ main (int argc, char **argv)
test_case_cl_intef_process_mme (test);
test_case_cl_interf_add_and_get_tx_buffer (test);
test_case_cl_interf_send_mme (test);
+ test_case_cl_interf_mme_rx_update_sta_expired_date (test);
test_case_begin (test, "Memory allocation");
test_begin (test, "memory leaks")