aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-06-16 13:26:14 +0200
committerHarald Welte <laforge@gnumonks.org>2015-09-22 16:39:04 +0200
commit75caaf294980e258b63d300284f9b7bf26fd35c9 (patch)
treef9604f00187fdca2648fa9a51d8f9c16933d5700 /src/osmo-bts-sysmo
parent5027e122a885eab21772706d39915464c887150d (diff)
sysmobts: Clean up transitions for lchan cipher state
There are three transitions: 1. LCHAN_CIPH_NONE -> LCHAN_CIPH_RX_REQ -> LCHAN_CIPH_RX_CONF It is used to enable ciphering in RX (uplink) direction only. 2. LCHAN_CIPH_RX_CONF -> LCHAN_CIPH_RX_CONF_TX_REQ -> LCHAN_CIPH_RXTX_CONF It is used to additionally enable ciphering in TX (downlink) direction. 3. LCHAN_CIPH_NONE -> LCHAN_CIPH_RXTX_REQ -> LCHAN_CIPH_RX_CONF_TX_REQ -> LCHAN_CIPH_RXTX_CONF It is used to enable ciphering in both TX and RX directions. This is used when the channel is activated with encryption already enabled. (assignment or handover) In order to follow the order of these transitions, the RX direction must always be set before the TX direction. If no cipher key is set (A5/0), ciphering is set to ALG 0, but lchan cipher state remains at LCHAN_CIPH_NONE.
Diffstat (limited to 'src/osmo-bts-sysmo')
-rw-r--r--src/osmo-bts-sysmo/l1_if.c5
-rw-r--r--src/osmo-bts-sysmo/oml.c19
2 files changed, 19 insertions, 5 deletions
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 810ec6d4..83fe5049 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -616,8 +616,11 @@ static int mph_info_req(struct gsm_bts_trx *trx, struct msgb *msg,
}
if (l1sap->u.info.u.ciph_req.downlink) {
l1if_set_ciphering(fl1, lchan, 1);
- lchan->ciph_state = LCHAN_CIPH_TXRX_REQ;
+ lchan->ciph_state = LCHAN_CIPH_RX_CONF_TX_REQ;
}
+ if (l1sap->u.info.u.ciph_req.downlink
+ && l1sap->u.info.u.ciph_req.uplink)
+ lchan->ciph_state = LCHAN_CIPH_RXTX_REQ;
break;
case PRIM_INFO_ACTIVATE:
case PRIM_INFO_DEACTIVATE:
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 8c701642..c5810898 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -1004,8 +1004,12 @@ static int sapi_activate_cb(struct gsm_lchan *lchan, int status)
mph_info_chan_confirm(lchan, PRIM_INFO_ACTIVATE, 0);
/* set the initial ciphering parameters for both directions */
- l1if_set_ciphering(fl1h, lchan, 0);
l1if_set_ciphering(fl1h, lchan, 1);
+ l1if_set_ciphering(fl1h, lchan, 0);
+ if (lchan->encr.alg_id)
+ lchan->ciph_state = LCHAN_CIPH_RXTX_REQ;
+ else
+ lchan->ciph_state = LCHAN_CIPH_NONE;
return 0;
}
@@ -1154,9 +1158,16 @@ static int chmod_modif_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg,
LOGPC(DL1C, LOGL_INFO, "RX_REQ -> RX_CONF\n");
lchan->ciph_state = LCHAN_CIPH_RX_CONF;
break;
- case LCHAN_CIPH_TXRX_REQ:
- LOGPC(DL1C, LOGL_INFO, "TX_REQ -> TX_CONF\n");
- lchan->ciph_state = LCHAN_CIPH_TXRX_CONF;
+ case LCHAN_CIPH_RX_CONF_TX_REQ:
+ LOGPC(DL1C, LOGL_INFO, "RX_CONF_TX_REQ -> RXTX_CONF\n");
+ lchan->ciph_state = LCHAN_CIPH_RXTX_CONF;
+ break;
+ case LCHAN_CIPH_RXTX_REQ:
+ LOGPC(DL1C, LOGL_INFO, "RXTX_REQ -> RX_CONF_TX_REQ\n");
+ lchan->ciph_state = LCHAN_CIPH_RX_CONF_TX_REQ;
+ break;
+ case LCHAN_CIPH_NONE:
+ LOGPC(DL1C, LOGL_INFO, "\n");
break;
default:
LOGPC(DL1C, LOGL_INFO, "unhandled state %u\n", lchan->ciph_state);