diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-01-25 15:43:03 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-02-09 13:59:55 +0100 |
commit | 5f17720fcd3285d75c32359fbbe35e5ffa720778 (patch) | |
tree | 601a8450a0c918d2b8a31916aff0df71be9e4452 /src | |
parent | 5d212055b7379b22da27d5c70b43e61491cd2381 (diff) |
fix migration of check_for_ciph_cmd() from sysmobts to l1sap
During the L1SAP related changes, somehow an old version of
check_for_ciph_cmd() was re-introduced, which didn't store the N(s) as
part of the lchan. To make things worse, the old code was still present
in the sysmobts specific part, but never executed.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/l1sap.c | 12 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_if.c | 45 |
2 files changed, 12 insertions, 45 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c index c899914f..80560348 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -113,6 +113,7 @@ static int l1sap_tx_ciph_req(struct gsm_bts_trx *trx, uint8_t chan_nr, static int check_for_ciph_cmd(struct msgb *msg, struct gsm_lchan *lchan, uint8_t chan_nr) { + uint8_t n_s; /* only do this if we are in the right state */ switch (lchan->ciph_state) { @@ -133,11 +134,22 @@ static int check_for_ciph_cmd(struct msgb *msg, struct gsm_lchan *lchan, if ((msg->data[4] & 0x3F) != GSM48_MT_RR_CIPH_M_CMD) return 0; + /* Remember N(S) + 1 to find the first ciphered frame */ + n_s = (msg->data[1] >> 1) & 0x7; + lchan->ciph_ns = (n_s + 1) % 8; + l1sap_tx_ciph_req(lchan->ts->trx, chan_nr, 0, 1); return 1; } +/* public helpers for the test */ +int bts_check_for_ciph_cmd(struct msgb *msg, struct gsm_lchan *lchan, + uint8_t chan_nr) +{ + return check_for_ciph_cmd(msg, lchan, chan_nr); +} + struct gsmtap_inst *gsmtap = NULL; uint32_t gsmtap_sapi_mask = 0; uint8_t gsmtap_sapi_acch = 0; diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 8457a748..ce393a4d 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -232,51 +232,6 @@ empty_req_from_rts_ind(GsmL1_Prim_t *l1p, return empty_req; } -/* check if the message is a GSM48_MT_RR_CIPH_M_CMD, and if yes, enable - * uni-directional de-cryption on the uplink. We need this ugly layering - * violation as we have no way of passing down L3 metadata (RSL CIPHERING CMD) - * to this point in L1 */ -static int check_for_ciph_cmd(struct femtol1_hdl *fl1h, - struct msgb *msg, struct gsm_lchan *lchan) -{ - uint8_t n_s; - - /* only do this if we are in the right state */ - switch (lchan->ciph_state) { - case LCHAN_CIPH_NONE: - case LCHAN_CIPH_RX_REQ: - break; - default: - return 0; - } - - /* First byte (Address Field) of LAPDm header) */ - if (msg->data[0] != 0x03) - return 0; - /* First byte (protocol discriminator) of RR */ - if ((msg->data[3] & 0xF) != GSM48_PDISC_RR) - return 0; - /* 2nd byte (msg type) of RR */ - if ((msg->data[4] & 0x3F) != GSM48_MT_RR_CIPH_M_CMD) - return 0; - - /* Remember N(S) + 1 to find the first ciphered frame */ - n_s = (msg->data[1] >> 1) & 0x7; - lchan->ciph_ns = (n_s + 1) % 8; - - lchan->ciph_state = LCHAN_CIPH_RX_REQ; - l1if_set_ciphering(fl1h, lchan, 0); - - return 1; -} - -/* public helpers for the test */ -int bts_check_for_ciph_cmd(struct femtol1_hdl *fl1h, - struct msgb *msg, struct gsm_lchan *lchan) -{ - return check_for_ciph_cmd(fl1h, msg, lchan); -} - static const uint8_t fill_frame[GSM_MACBLOCK_LEN] = { 0x03, 0x03, 0x01, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, |