aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-04-19 10:06:00 +0200
committerHarald Welte <laforge@gnumonks.org>2012-04-19 10:06:00 +0200
commitf5a0a439e931113863ac3da54f309b1a9ce42d66 (patch)
tree921edbd3f8d44238ee6c5e70b0e7dc866187c295
parentbf91f06ecaffe311c821c705c98fd3287f343e34 (diff)
ciphering: Make sure to initialize lchan to no ciphering when activating
The ciphering parameters in L1 are persistent accross MPH deactivate/activate, so we need to make sure to always initialize them cleanly at RSL CHAN ACT time. This has the added benefit that we can also activate channels that have encryption enabled from the very beginning (required for encrypted handover).
-rw-r--r--src/osmo-bts-sysmo/l1_if.c4
-rw-r--r--src/osmo-bts-sysmo/oml.c17
2 files changed, 13 insertions, 8 deletions
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 353ff59..8824532 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -329,7 +329,7 @@ static int check_for_ciph_cmd(struct femtol1_hdl *fl1h,
return 0;
lchan->ciph_state = LCHAN_CIPH_RX_REQ;
- l1if_enable_ciphering(fl1h, lchan, 0);
+ l1if_set_ciphering(fl1h, lchan, 0);
return 1;
}
@@ -629,7 +629,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i
* before decryption was enabled */
if (data_ind->msgUnitParam.u8Buffer[0] == 0x01 &&
(data_ind->msgUnitParam.u8Buffer[1] & 0x01) == 0) {
- l1if_enable_ciphering(fl1, lchan, 1);
+ l1if_set_ciphering(fl1, lchan, 1);
lchan->ciph_state = LCHAN_CIPH_TXRX_REQ;
}
}
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 5dc9733..e4dcf33 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -678,11 +678,13 @@ int lchan_activate(struct gsm_lchan *lchan)
/* send the primitive for all GsmL1_Sapi_* that match the LCHAN */
l1if_req_compl(fl1h, msg, 0, lchan_act_compl_cb, lchan);
- /* FIXME: check if encryption parameters are present, and issue
- * MPH-CONFIG.req */
}
lchan_set_state(lchan, LCHAN_S_ACT_REQ);
+ /* set the initial ciphering parameters for both directions */
+ l1if_set_ciphering(fl1h, lchan, 0);
+ l1if_set_ciphering(fl1h, lchan, 1);
+
lchan_init_lapdm(lchan);
return 0;
@@ -818,16 +820,13 @@ const enum GsmL1_CipherId_t rsl2l1_ciph[] = {
[4] = GsmL1_CipherId_A53,
};
-int l1if_enable_ciphering(struct femtol1_hdl *fl1h,
+int l1if_set_ciphering(struct femtol1_hdl *fl1h,
struct gsm_lchan *lchan,
int dir_downlink)
{
struct msgb *msg = l1p_msgb_alloc();
struct GsmL1_MphConfigReq_t *cfgr;
- LOGP(DL1C, LOGL_NOTICE, "%s enable_ciphering(dir_downlink=%u)\n",
- gsm_lchan_name(lchan), dir_downlink);
-
cfgr = prim_init(msgb_l1prim(msg), GsmL1_PrimId_MphConfigReq, fl1h);
cfgr->cfgParamId = GsmL1_ConfigParamId_SetCipheringParams;
@@ -843,6 +842,12 @@ int l1if_enable_ciphering(struct femtol1_hdl *fl1h,
return -EINVAL;
cfgr->cfgParams.setCipheringParams.cipherId = rsl2l1_ciph[lchan->encr.alg_id];
+ LOGP(DL1C, LOGL_NOTICE, "%s SET_CIPHERING (ALG=%u %s)\n",
+ gsm_lchan_name(lchan),
+ cfgr->cfgParams.setCipheringParams.cipherId,
+ get_value_string(femtobts_dir_names,
+ cfgr->cfgParams.setCipheringParams.dir));
+
memcpy(cfgr->cfgParams.setCipheringParams.u8Kc,
lchan->encr.key, lchan->encr.key_len);