diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-04-08 20:17:43 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-04-19 08:22:29 +0200 |
commit | d9ab45d1aac21c761c461659e2179d1077b5b7a5 (patch) | |
tree | 9c923824c549de2609486d8e6cacb3258e21398f /src/osmo-bts-sysmo/oml.c | |
parent | 51f9693ba634945f489523453c3bdfc07274b09d (diff) |
Support for ciphering
When the RR CIPH MODE CMD is transmitted to the MS, we need to tell the
L1 to enable decryption on RX. After the first received frame has been
decrypted successfully, we will enable encryption also on transmit.
This has been tested with A5/1 so far, but A5/2 and A5/3 should work
exactly identical.
Diffstat (limited to 'src/osmo-bts-sysmo/oml.c')
-rw-r--r-- | src/osmo-bts-sysmo/oml.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c index 3c268497..00c088cd 100644 --- a/src/osmo-bts-sysmo/oml.c +++ b/src/osmo-bts-sysmo/oml.c @@ -18,6 +18,7 @@ */ #include <stdint.h> +#include <errno.h> #include <osmocom/core/talloc.h> #include <osmocom/core/utils.h> @@ -775,6 +776,46 @@ static int tx_confreq_logchpar(struct gsm_lchan *lchan, uint8_t direction) return l1if_req_compl(fl1h, msg, 0, chmod_modif_compl_cb, lchan); } +const enum GsmL1_CipherId_t rsl2l1_ciph[] = { + [0] = GsmL1_CipherId_A50, + [1] = GsmL1_CipherId_A50, + [2] = GsmL1_CipherId_A51, + [3] = GsmL1_CipherId_A52, + [4] = GsmL1_CipherId_A53, +}; + +int l1if_enable_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_DEBUG, "%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; + cfgr->cfgParams.setCipheringParams.u8Tn = lchan->ts->nr; + cfgr->cfgParams.setCipheringParams.subCh = lchan_to_GsmL1_SubCh_t(lchan); + + if (dir_downlink) + cfgr->cfgParams.setCipheringParams.dir = GsmL1_Dir_TxDownlink; + else + cfgr->cfgParams.setCipheringParams.dir = GsmL1_Dir_RxUplink; + + if (lchan->encr.alg_id >= ARRAY_SIZE(rsl2l1_ciph)) + return -EINVAL; + cfgr->cfgParams.setCipheringParams.cipherId = rsl2l1_ciph[lchan->encr.alg_id]; + + memcpy(cfgr->cfgParams.setCipheringParams.u8Kc, + lchan->encr.key, lchan->encr.key_len); + + return l1if_req_compl(fl1h, msg, 0, chmod_modif_compl_cb, lchan); +} + + int bts_model_rsl_mode_modify(struct gsm_lchan *lchan) { /* channel mode, encryption and/or multirate have changed */ |