summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNélio Laranjeiro2013-05-17 13:33:21 +0200
committerNélio Laranjeiro2013-05-24 15:38:33 +0200
commit0d0c903eb051d845cbbb47554caa7855f5e6d39c (patch)
tree3a2efd1f501ed72278ba6e8af21f52f024b3ca6b /cesar
parent1ed5a82ca996f65a6b8e20191e239cc1cb88d27a (diff)
cesar/cp/av/sta/action: compute the TEI renew date, closes #3968
HPAV allows the TEI lease to be configurable on a range from 0x0001 to 0xffff (1 minute to approximatively 45days). As we used a renew margin of 5 minutes, we were not able to renew our TEI if the lease time was lesser of equal to 5 minutes, it had for consequence in our product to program the renew event in a far future. Another change in this commit concerns the behavior of the renew when the station is authenticated. To detect a request failure, a timer was programmed with the MARGIN value divided by 2 i.e. 2.5 minutes. From now the request is considered failed after the half of the calculated margin i.e. 15s if the lease was a minute, 30s if the lease was greater than a minute (see cp_av_sta_action_lease_renew function). Note: This bug has been confirmed during the Interoperability certification tests with the Gigle Test Matrix plugs when it acts as a CCo. Gigle's CCo provides a lease of 5 minutes value at the first CC_ASSOC.REQ (i.e. Join) request.
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/av/sta/action/src/assoc.c41
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/assoc.c52
-rw-r--r--cesar/cp/sta/action/inc/context.h3
3 files changed, 82 insertions, 14 deletions
diff --git a/cesar/cp/av/sta/action/src/assoc.c b/cesar/cp/av/sta/action/src/assoc.c
index 547aaf959f..4102a141d3 100644
--- a/cesar/cp/av/sta/action/src/assoc.c
+++ b/cesar/cp/av/sta/action/src/assoc.c
@@ -26,10 +26,38 @@
#include "cp/av/sta/mgr/sta_own_data.h"
#define RETRY_TIMEOUT_MS 1000
-#define RENEW_MARGIN_MS (5 * 60 * 1000)
#define LEAVING_TIMEOUT_MS (40 * 3)
#define LEAVE_WAIT_TIMEOUT_MS 1000
+/**
+ * Compute the date to renew the TEI lease depending on the lease provided by
+ * the CCo.
+ * \param ctx the module context
+ * \param lease_min the lease value received in the cc_assoc_cnf MME
+ * \return the date to use to program the renew event
+ */
+static u32
+cp_av_sta_action_lease_renew (cp_t *ctx, uint lease_min)
+{
+ u32 renew_ms = 0;
+ u32 lease_threshold_ms = 60 * 1000;
+ u32 lease_ms = lease_min * 60 * 1000;
+ if (lease_ms > lease_threshold_ms)
+ {
+ renew_ms = lease_ms - lease_threshold_ms;
+ ctx->sta_action.assoc.tei_renew_retry_timeout_ms =
+ lease_threshold_ms / 2;
+ }
+ else
+ {
+ renew_ms = lease_ms / 2;
+ ctx->sta_action.assoc.tei_renew_retry_timeout_ms =
+ renew_ms / 2;
+ }
+ dbg_claim (renew_ms);
+ return renew_ms;
+}
+
void
cp_av_sta_action_assoc_init (cp_t *ctx)
{
@@ -161,7 +189,8 @@ cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (cp_t *ctx,
cp_net_t *our_net;
/* Start lease timer, it can not expire before we go to authenticated
* state because authentication timeout is shorter. */
- int lease_time_ms = cnf.lease_time_min * 60 * 1000 - RENEW_MARGIN_MS;
+ int lease_time_ms =
+ cp_av_sta_action_lease_renew (ctx, cnf.lease_time_min);
if (lease_time_ms > 0)
{
cp_fsm_event_t *event = cp_fsm_event_bare_new (
@@ -528,8 +557,9 @@ cp_av_sta_action_assoc__authenticated__renew (cp_t *ctx)
/* Restart timer. */
cp_fsm_event_t *event = cp_fsm_event_bare_new (
ctx, CP_FSM_EVENT_TYPE_renew);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.lease_timer,
- event, RENEW_MARGIN_MS / 2);
+ cp_sta_core_gen_timed_event (
+ ctx, &ctx->sta_action.assoc.lease_timer, event,
+ ctx->sta_action.assoc.tei_renew_retry_timeout_ms);
/* Get our CCo. */
cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
cp_mme_peer_t peer;
@@ -563,7 +593,8 @@ cp_av_sta_action_assoc__authenticated__cc_assoc_cnf (cp_t *ctx,
/* Update lease. */
cp_sta_core_stop_timed_or_cyclic_event (
ctx, &ctx->sta_action.assoc.lease_timer);
- int lease_time_ms = cnf.lease_time_min * 60 * 1000 - RENEW_MARGIN_MS;
+ int lease_time_ms =
+ cp_av_sta_action_lease_renew (ctx, cnf.lease_time_min);
if (lease_time_ms > 0)
{
cp_fsm_event_t *event = cp_fsm_event_bare_new (
diff --git a/cesar/cp/av/sta/action/test/utest/src/assoc.c b/cesar/cp/av/sta/action/test/utest/src/assoc.c
index 27f8f7b59f..cf48859c6a 100644
--- a/cesar/cp/av/sta/action/test/utest/src/assoc.c
+++ b/cesar/cp/av/sta/action/test/utest/src/assoc.c
@@ -82,8 +82,25 @@ assoc_basic_test_cases (test_t t)
.nid = nid, .snid = snid, .sta_tei = sta_tei,
.lease_time_min = 15),
SCENARIO_EVENT (cp_sta_core_gen_timed_event,
- .delay_min_ms = 10 * 60 * 1000,
- .delay_max_ms = 10 * 60 * 1000),
+ .delay_min_ms = 14 * 60 * 1000,
+ .delay_max_ms = 14 * 60 * 1000),
+ SCENARIO_EVENT (cp_msg_cm_get_key_req_send,
+ .peer = cco_peer, .peks = CP_MME_PEKS_NMK,
+ .pid = 0, .pmn = 1, .relayed = false,
+ .key_type = CP_MSG_KEY_NEK, .nid = nid),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (WAIT_ASSOC_CONF,
+ CC_ASSOC_CNF, ok)),
+ /* Lease of 1 minute. */
+ SCENARIO_ACTION (assoc__wait_assoc_cnf__cc_assoc_cnf,
+ .peer = cco_peer),
+ SCENARIO_EVENT (cp_msg_cc_assoc_cnf_receive, .ok = true,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
+ .nid = nid, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 1),
+ SCENARIO_EVENT (cp_sta_core_gen_timed_event,
+ .delay_min_ms = (60 * 1000) / 2,
+ .delay_max_ms = (60 * 1000) / 2),
SCENARIO_EVENT (cp_msg_cm_get_key_req_send,
.peer = cco_peer, .peks = CP_MME_PEKS_NMK,
.pid = 0, .pmn = 1, .relayed = false,
@@ -417,8 +434,8 @@ assoc_basic_test_cases (test_t t)
/* Renew. */
SCENARIO_ACTION (assoc__authenticated__renew),
SCENARIO_EVENT (cp_sta_core_gen_timed_event,
- .delay_min_ms = 5 * 60 * 1000 / 2,
- .delay_max_ms = 5 * 60 * 1000 / 2),
+ .delay_min_ms = (1 * 60 * 1000 / 2) / 2,
+ .delay_max_ms = (1 * 60 * 1000 / 2) / 2),
SCENARIO_EVENT (cp_msg_cc_assoc_req_send, .peer = cco_peer,
.request_type = CP_MSG_CC_ASSOC_REQ_TYPE_RENEW,
.nid = nid, .cco_cap = CP_CCO_LEVEL,
@@ -431,14 +448,31 @@ assoc_basic_test_cases (test_t t)
.lease_time_min = 48 * 60),
SCENARIO_EVENT (cp_sta_core_stop_timed_or_cyclic_event),
SCENARIO_EVENT (cp_sta_core_gen_timed_event,
- .delay_min_ms = (48 * 60 - 5) * 60 * 1000,
- .delay_max_ms = (48 * 60 - 5) * 60 * 1000),
+ .delay_min_ms = (48 * 60 - 1) * 60 * 1000,
+ .delay_max_ms = (48 * 60 - 1) * 60 * 1000),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ test_fail_unless (ctx.cp.sta_action.assoc.tei_renew_retry_timeout_ms
+ == 1 * 60 * 1000 / 2);
+ scenario_entry_t entries2[] = {
+ /* Lease of 1 minute. */
+ SCENARIO_ACTION (assoc__authenticated__cc_assoc_cnf,
+ .peer = cco_peer),
+ SCENARIO_EVENT (cp_msg_cc_assoc_cnf_receive, .ok = true,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
+ .nid = nid, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 1),
+ SCENARIO_EVENT (cp_sta_core_stop_timed_or_cyclic_event),
+ SCENARIO_EVENT (cp_sta_core_gen_timed_event,
+ .delay_min_ms = (60 * 1000) / 2,
+ .delay_max_ms = (60 * 1000) / 2),
/* Test timer stop here. */
SCENARIO_ACTION (assoc__authenticated__leave),
SCENARIO_EVENT (cp_sta_core_stop_timed_or_cyclic_event),
SCENARIO_END
};
- scenario_run (t, entries, &globals);
+ scenario_run (t, entries2, &globals);
} test_end;
test_begin (t, "renew error")
{
@@ -1012,8 +1046,8 @@ assoc_basic_test_cases_cco_unknow_mac_addr (test_t t)
.nid = nid, .snid = snid, .sta_tei = sta_tei,
.lease_time_min = 15),
SCENARIO_EVENT (cp_sta_core_gen_timed_event,
- .delay_min_ms = 10 * 60 * 1000,
- .delay_max_ms = 10 * 60 * 1000),
+ .delay_min_ms = 14 * 60 * 1000,
+ .delay_max_ms = 14 * 60 * 1000),
SCENARIO_EVENT (cp_msg_cm_get_key_req_send,
.peer = cco_peer, .peks = CP_MME_PEKS_NMK,
.pid = 0, .pmn = 1, .relayed = false,
diff --git a/cesar/cp/sta/action/inc/context.h b/cesar/cp/sta/action/inc/context.h
index fb65f0d47e..fba7e34d5d 100644
--- a/cesar/cp/sta/action/inc/context.h
+++ b/cesar/cp/sta/action/inc/context.h
@@ -34,6 +34,9 @@ struct cp_sta_action_assoc_t
cp_sta_core_timed_event_def_t lease_timer;
/** Number of lost central beacons since the last beacon reception. */
uint beacon_loss;
+ /** Retry TEI lease timeout, only used to program an event timer to resent
+ * the renew request in case the first request has not been confirmed. */
+ uint tei_renew_retry_timeout_ms;
};