summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cp/beacon/src/beacons.c3
-rw-r--r--cp/beacon/test/central_beacon/src/bentry_test.c1
-rw-r--r--mac/ca/ca.h4
-rw-r--r--mac/ca/src/access.c2
-rw-r--r--mac/ca/src/alloc.c1
-rw-r--r--mac/ca/test/ca/src/test_access.c7
-rw-r--r--mac/ca/test/ca/src/test_alloc.c4
-rw-r--r--mac/common/config.h4
-rw-r--r--mac/common/defs.h24
-rw-r--r--mac/common/src/config.c3
-rw-r--r--mac/common/src/sta.c2
-rw-r--r--mac/common/sta.h9
-rw-r--r--mac/pbproc/test/maximus/src/add_beacon_period.c1
-rw-r--r--mac/pbproc/test/pbproc/inc/scenario_defs.h1
-rw-r--r--mac/pbproc/test/pbproc/src/ca.c1
-rw-r--r--test_general/station/src/int_station.c3
16 files changed, 64 insertions, 6 deletions
diff --git a/cp/beacon/src/beacons.c b/cp/beacon/src/beacons.c
index 4a40fa11e4..bf15089949 100644
--- a/cp/beacon/src/beacons.c
+++ b/cp/beacon/src/beacons.c
@@ -238,6 +238,7 @@ cp_beacon_create_default_schedule (cp_beacon_t *ctx)
{
sched = ca_alloc_get_schedule (ctx->ca, 0);
sched->coexistence_mode = ctx->hm;
+ sched->nek_switch = 0; //TODO
sched->allocations_nb = 1;
sched->allocations[0].end_offset_tck = 0xFFFFFF;
sched->allocations[0].glid = 0xFF;
@@ -577,6 +578,7 @@ cp_beacon_process_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
// Store the coexistence mode
sched.ca_sched = ca_alloc_get_schedule (ctx->ca, ctx->schedule_index);
sched.ca_sched->coexistence_mode = ctx->hm;
+ sched.ca_sched->nek_switch = 0; //TODO
bentry = beacon->payload->bmis;
for (nbe = beacon->payload->nbe; nbe; nbe --)
@@ -836,6 +838,7 @@ cp_beacon_cco_beacon_central_generate (cp_beacon_t *ctx,
sched.next_alloc = 0;
sched.ca_sched = ca_alloc_get_schedule (ctx->ca, ctx->schedule_index);
sched.ca_sched->coexistence_mode = ctx->hm;
+ sched.ca_sched->nek_switch = 0; //TODO
beacon->payload->fc.bts = ctx->cbeacon.btse_ntb[0];
*beacon->payload->fc.bto = *ctx->cbeacon.bto_bpsto.bto;
diff --git a/cp/beacon/test/central_beacon/src/bentry_test.c b/cp/beacon/test/central_beacon/src/bentry_test.c
index 6d2476d73c..da2327bbd4 100644
--- a/cp/beacon/test/central_beacon/src/bentry_test.c
+++ b/cp/beacon/test/central_beacon/src/bentry_test.c
@@ -750,6 +750,7 @@ ca_alloc_update_beacon_periods (ca_t *ctx,
test_begin (test, "Checking schedules")
{
test_fail_if (ca_sched.coexistence_mode != 0x0, "Wrong coexistence mode");
+ test_fail_if (ca_sched.nek_switch != 0, "Wrong NEK switch"); //TODO
test_fail_if (ca_sched.allocations[0].end_offset_tck / 256 != 3906, "Wrong schedule");
test_fail_if (ca_sched.allocations[0].glid != 0xFF, "Wrong GLID");
}
diff --git a/mac/ca/ca.h b/mac/ca/ca.h
index 8de7a4551d..38fec6d2f0 100644
--- a/mac/ca/ca.h
+++ b/mac/ca/ca.h
@@ -93,6 +93,8 @@ struct ca_schedule_t
{
/** Coexistence mode for this schedule. */
mac_coexistence_mode_t coexistence_mode;
+ /** EKS/NEK pair to use. */
+ uint nek_switch;
/** Number of used allocations in this schedule. */
uint allocations_nb;
/** Table of allocations. */
@@ -133,6 +135,8 @@ struct ca_access_alloc_param_t
mac_coexistence_mode_t coexistence_mode;
/** Hybrid frame control. */
bool hybrid;
+ /** EKS/NEK pair to use. */
+ uint nek_switch;
};
typedef struct ca_access_alloc_param_t ca_access_alloc_param_t;
diff --git a/mac/ca/src/access.c b/mac/ca/src/access.c
index 1af804d079..a312f047f1 100644
--- a/mac/ca/src/access.c
+++ b/mac/ca/src/access.c
@@ -47,6 +47,7 @@ ca_access_activate (ca_t *ctx, u32 date, uint anticipation_tck)
/* Return current allocation parameters. */
ctx->current_allocation_param.coexistence_mode = sched->coexistence_mode;
ctx->current_allocation_param.hybrid = hybrid;
+ ctx->current_allocation_param.nek_switch = sched->nek_switch;
return &ctx->current_allocation_param;
}
@@ -365,6 +366,7 @@ ca_access_aifs (ca_t *ctx)
ctx->current_allocation_param.hybrid = CA_ALLOC_IS_HYBRID (
sched->coexistence_mode,
sched->allocations[ctx->current_allocation_index].glid);
+ ctx->current_allocation_param.nek_switch = sched->nek_switch;
return &ctx->current_allocation_param;
}
diff --git a/mac/ca/src/alloc.c b/mac/ca/src/alloc.c
index f270c4b32f..0206100a57 100644
--- a/mac/ca/src/alloc.c
+++ b/mac/ca/src/alloc.c
@@ -121,6 +121,7 @@ ca_alloc_update_beacon_periods (ca_t *ctx,
ca_schedule_t *sched =
&ctx->schedules[beacon_periods[j].schedule_index];
dbg_assert (sched->coexistence_mode < MAC_COEXISTENCE_NB
+ && sched->nek_switch < 2
&& sched->allocations_nb > 0
&& sched->allocations[0].end_offset_tck > 0);
}
diff --git a/mac/ca/test/ca/src/test_access.c b/mac/ca/test/ca/src/test_access.c
index d5f4622a6c..32efca34a1 100644
--- a/mac/ca/test/ca/src/test_access.c
+++ b/mac/ca/test/ca/src/test_access.c
@@ -36,8 +36,9 @@ access_random_schedule (lib_rnd_t *rnd, ca_schedule_t *sched, uint length_tck)
uint i;
const uint mini_tck = MAC_PREAMBLE_TCK + MAC_FC_AV_TCK + MAC_AIFS_TCK;
const uint nb = lib_rnd_uniform (rnd, CA_SCHEDULE_SIZE - 3) + 3;
- /* Coexistence mode. */
+ /* Coexistence mode and encryption. */
sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
+ sched->nek_switch = 0;
/* Random allocations. */
uint zoffset_tck = 0;
sched->allocations_nb = nb;
@@ -87,6 +88,7 @@ access_check_vcs_restart (test_t t, ca_t *ca, u32 date, uint duration_tck,
ca_beacon_period_t *bp = &ca->beacon_periods[bp_i];
ca_schedule_t *sched = &ca->schedules[bp->schedule_index];
dbg_assert (sched->coexistence_mode < MAC_COEXISTENCE_NB);
+ dbg_assert (sched->nek_switch < 2);
dbg_assert (sched->allocations_nb);
uint alloc_i = ca_alloc_find (sched, date - bp->start_date);
dbg_assert (alloc_i < sched->allocations_nb);
@@ -101,6 +103,7 @@ access_check_vcs_restart (test_t t, ca_t *ca, u32 date, uint duration_tck,
test_fail_unless (ap->coexistence_mode == sched->coexistence_mode);
test_fail_unless (ap->hybrid == CA_ALLOC_IS_HYBRID
(sched->coexistence_mode, alloc->glid));
+ test_fail_unless (ap->nek_switch == sched->nek_switch);
}
if (a->mfs)
{
@@ -158,7 +161,7 @@ access_basic_test_case (test_t t)
#else
phy->date = MAC_MS_TO_TCK (500 / 50);
#endif
- mac_config_init (&mac_config);
+ mac_config_init (&config);
config.tei = 1;
store = mac_store_init ();
ca = ca_init (phy, &config, store);
diff --git a/mac/ca/test/ca/src/test_alloc.c b/mac/ca/test/ca/src/test_alloc.c
index 2aed3417d7..ff563015cd 100644
--- a/mac/ca/test/ca/src/test_alloc.c
+++ b/mac/ca/test/ca/src/test_alloc.c
@@ -35,7 +35,7 @@ alloc_basic_test_case (test_t t)
test_case_begin (t, "basic");
/* Initialise. */
phy = phy_init (NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- mac_config_init (&mac_config);
+ mac_config_init (&config);
config.tei = 1;
store = mac_store_init ();
ca = ca_init (phy, &config, store);
@@ -94,6 +94,7 @@ alloc_basic_test_case (test_t t)
{
ca_schedule_t *sched = ca_alloc_get_schedule (ca, i);
sched->coexistence_mode = MAC_COEXISTENCE_AV_ONLY_MODE;
+ sched->nek_switch = 0;
sched->allocations_nb = 1;
sched->allocations[0].end_offset_tck = beacon_period_length;
sched->allocations[0].glid = MAC_LID_SPC_HOLE;
@@ -178,6 +179,7 @@ alloc_basic_test_case (test_t t)
for (i = 0; i < NB_ITER / CA_SCHEDULE_SIZE; i++)
{
schedule.coexistence_mode = MAC_COEXISTENCE_AV_ONLY_MODE;
+ schedule.nek_switch = 0;
schedule.allocations_nb = lib_rnd_uniform (rnd, CA_SCHEDULE_SIZE);
end = 0;
for (j = 0; j < schedule.allocations_nb; j++)
diff --git a/mac/common/config.h b/mac/common/config.h
index 0a888607e8..b20478c767 100644
--- a/mac/common/config.h
+++ b/mac/common/config.h
@@ -28,6 +28,10 @@ struct mac_config_t
u8 snid;
/** RTS broadcast flag. */
bool rts_broadcast;
+ /** Is this STA authenticated. */
+ bool authenticated;
+ /** EKS/NEK pairs, used for broadcast. */
+ mac_nek_t nek[2];
/** Number of FC symbol. */
uint fc_symbols_nb;
/** Tonemask. */
diff --git a/mac/common/defs.h b/mac/common/defs.h
index 39ad35c3e0..26509f22a3 100644
--- a/mac/common/defs.h
+++ b/mac/common/defs.h
@@ -98,4 +98,28 @@ enum mac_coexistence_mode_t
};
typedef enum mac_coexistence_mode_t mac_coexistence_mode_t;
+/** Encryption Key Select. */
+enum mac_eks_t
+{
+ MAC_EKS_MIN = 0,
+ MAC_EKS_MAX = 7,
+ MAC_EKS_NB = MAC_EKS_MAX - MAC_EKS_MIN + 1,
+ MAC_EKS_CLEAR = 0xf,
+};
+
+/** EKS/NEK pair.
+ * This pair is valid if EKS is less than MAC_EKS_NB.
+ *
+ * To update a pair, first set EKS to MAC_EKS_CLEAR, then change the key, and
+ * finally, write the EKS.
+ */
+struct mac_nek_t
+{
+ /** Encryption Key Select. */
+ u8 eks;
+ /** Network encryption Key. */
+ u32 nek[4];
+};
+typedef struct mac_nek_t mac_nek_t;
+
#endif /* mac_common_defs_h */
diff --git a/mac/common/src/config.c b/mac/common/src/config.c
index b8d15e1fad..d7133d0e96 100644
--- a/mac/common/src/config.c
+++ b/mac/common/src/config.c
@@ -20,6 +20,9 @@ mac_config_init (mac_config_t *config)
config->tei = 0;
config->snid = 0;
config->rts_broadcast = false;
+ config->authenticated = false;
+ config->nek[0].eks = MAC_EKS_CLEAR;
+ config->nek[1].eks = MAC_EKS_CLEAR;
config->fc_symbols_nb = 1;
tonemask_default (config->tonemask_info.tonemask);
tonemask_update (&config->tonemask_info);
diff --git a/mac/common/src/sta.c b/mac/common/src/sta.c
index a117ae9422..ac1f708e1a 100644
--- a/mac/common/src/sta.c
+++ b/mac/common/src/sta.c
@@ -24,6 +24,8 @@ sta_init (sta_t *sta, uint tei)
dbg_assert (MAC_TEI_IS_STA (tei));
memset (sta, 0, sizeof (sta_t));
sta->tei = tei;
+ sta->authenticated = false;
+ sta->nek = NULL;
//todo : make eventually rx_tonemaps and tx_tonemaps in sta_t.
sta->rx_tonemaps = tonemaps_alloc ();
sta->tx_tonemaps = tonemaps_alloc ();
diff --git a/mac/common/sta.h b/mac/common/sta.h
index b58de5cc85..24c5ca209c 100644
--- a/mac/common/sta.h
+++ b/mac/common/sta.h
@@ -13,13 +13,18 @@
* \ingroup mac_common
*/
#include "mac/common/tonemap.h"
+#include "mac/common/defs.h"
#include "ce/rxce_stats.h"
/** Station information. Must be < BLK_SIZE. */
struct sta_t
{
- /** terminal equipment id */
- uint tei;
+ /** Terminal equipment identifier. */
+ u8 tei;
+ /** Is this STA authenticated. */
+ bool authenticated;
+ /** EKS/NEK pairs pointer, used for unicast. */
+ mac_nek_t (*nek)[2];
/** Tonemaps for transmission. */
tonemaps_t *tx_tonemaps;
/** Tonemaps for reception. */
diff --git a/mac/pbproc/test/maximus/src/add_beacon_period.c b/mac/pbproc/test/maximus/src/add_beacon_period.c
index 517e771023..21f1550925 100644
--- a/mac/pbproc/test/maximus/src/add_beacon_period.c
+++ b/mac/pbproc/test/maximus/src/add_beacon_period.c
@@ -46,6 +46,7 @@ test_pbproc_add_beacon_period (test_pbproc_t *ctx, u32 start_date, uint glid,
% (TEST_PBPROC_NB_BEACON_PERIOD + 1));
ca_schedule_t *sched = ca_alloc_get_schedule (ctx->ca, schedule_index);
sched->coexistence_mode = coex;
+ sched->nek_switch = 0;
sched->allocations_nb = 1;
sched->allocations[0].end_offset_tck = beacon_period_tck
? beacon_period_tck : MAC_MS_TO_TCK (1000) / 50;
diff --git a/mac/pbproc/test/pbproc/inc/scenario_defs.h b/mac/pbproc/test/pbproc/inc/scenario_defs.h
index 85eba96303..c0da64e18f 100644
--- a/mac/pbproc/test/pbproc/inc/scenario_defs.h
+++ b/mac/pbproc/test/pbproc/inc/scenario_defs.h
@@ -170,6 +170,7 @@ typedef struct
typedef struct
{
mac_coexistence_mode_t coexistence_mode;
+ uint nek_switch;
bool hybrid;
} scenario_event_ca_access_aifs_t;
diff --git a/mac/pbproc/test/pbproc/src/ca.c b/mac/pbproc/test/pbproc/src/ca.c
index cc511d6a04..bdfc20dd98 100644
--- a/mac/pbproc/test/pbproc/src/ca.c
+++ b/mac/pbproc/test/pbproc/src/ca.c
@@ -91,6 +91,7 @@ ca_access_aifs (ca_t *ctx)
{
scenario_event (ca_access_aifs, params);
ctx->current_allocation_param.coexistence_mode = params->coexistence_mode;
+ ctx->current_allocation_param.nek_switch = params->nek_switch;
ctx->current_allocation_param.hybrid = params->hybrid;
return &ctx->current_allocation_param;
}
diff --git a/test_general/station/src/int_station.c b/test_general/station/src/int_station.c
index c53f720aec..feca2c7a78 100644
--- a/test_general/station/src/int_station.c
+++ b/test_general/station/src/int_station.c
@@ -391,7 +391,8 @@ void create_schedule_csma_only (int_station_t *int_sta, uint beacon_period_nb)
ca_schedule_t *sched = ca_alloc_get_schedule (pbproc_get_ca (pbproc),
int_sta->sched_index);
- sched->coexistence_mode = 0x1;
+ sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
+ sched->nek_switch = 0; //TODO
sched->allocations_nb = 1;
sched->allocations[0].end_offset_tck = 10000000;
sched->allocations[0].glid = 0xff;