aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/l1_if.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-02-21 09:27:52 +0100
committerHarald Welte <laforge@gnumonks.org>2015-09-06 14:47:32 +0200
commit5f53a55dde13a25e59a04ed4445e4ef94bd40d45 (patch)
tree5ace7994f357375f200e0d5bb248a118400d4ead /src/osmo-bts-trx/l1_if.c
parent10022fdba882853f57cc9a92c30e6dcf85e8c940 (diff)
TRX: Ciphering
Diffstat (limited to 'src/osmo-bts-trx/l1_if.c')
-rw-r--r--src/osmo-bts-trx/l1_if.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 51b1f439..58c2587b 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -357,9 +357,29 @@ static uint8_t trx_set_ts(struct gsm_bts_trx_ts *ts)
/* enable ciphering */
static int l1if_set_ciphering(struct trx_l1h *l1h, struct gsm_lchan *lchan,
- int downlink)
+ uint8_t chan_nr, int downlink)
{
- // FIXME
+ /* ciphering already enabled in both directions */
+ if (lchan->ciph_state == LCHAN_CIPH_TXRX_CONF)
+ return -EINVAL;
+
+ if (!downlink) {
+ /* set uplink */
+ trx_sched_set_cipher(l1h, chan_nr, 0, lchan->encr.alg_id - 1,
+ lchan->encr.key, lchan->encr.key_len);
+ lchan->ciph_state = LCHAN_CIPH_RX_CONF;
+ } else {
+ /* set downlink and also set uplink, if not already */
+ if (lchan->ciph_state != LCHAN_CIPH_RX_CONF) {
+ trx_sched_set_cipher(l1h, chan_nr, 0,
+ lchan->encr.alg_id - 1, lchan->encr.key,
+ lchan->encr.key_len);
+ }
+ trx_sched_set_cipher(l1h, chan_nr, 1, lchan->encr.alg_id - 1,
+ lchan->encr.key, lchan->encr.key_len);
+ lchan->ciph_state = LCHAN_CIPH_TXRX_CONF;
+ }
+
return 0;
}
@@ -423,14 +443,10 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
tn = L1SAP_CHAN2TS(chan_nr);
ss = l1sap_chan2ss(chan_nr);
lchan = &trx->ts[tn].lchan[ss];
- if (l1sap->u.info.u.ciph_req.downlink) {
- l1if_set_ciphering(l1h, lchan, 1);
- lchan->ciph_state = LCHAN_CIPH_RX_REQ;
- }
- if (l1sap->u.info.u.ciph_req.uplink) {
- l1if_set_ciphering(l1h, lchan, 0);
- lchan->ciph_state = LCHAN_CIPH_TXRX_REQ;
- }
+ if (l1sap->u.info.u.ciph_req.uplink)
+ l1if_set_ciphering(l1h, lchan, chan_nr, 0);
+ if (l1sap->u.info.u.ciph_req.downlink)
+ l1if_set_ciphering(l1h, lchan, chan_nr, 1);
break;
case PRIM_INFO_ACTIVATE:
case PRIM_INFO_DEACTIVATE: