diff options
author | Harald Welte <laforge@osmocom.org> | 2021-02-22 09:55:44 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-02-22 09:58:00 +0100 |
commit | 48f22b0e87c34266fad227d0a44d6da991375d2d (patch) | |
tree | 6136eca8fc5a2c9379375a7d95feca417a2a54f6 | |
parent | support for stats static userspace probes via systemtap (diff) | |
download | libosmocore-48f22b0e87c34266fad227d0a44d6da991375d2d.tar.xz libosmocore-48f22b0e87c34266fad227d0a44d6da991375d2d.zip |
CBSP: fix encoding/decoding of keep-alive repetition period
Even though the value is only between 0..120s, they didn't encode
it 1:1 in the uint8_t, but 3GPP chose to use the same encoding
as for the warning period (which has a much larger range).
Let's fix this in our implementation.
Before this patch, osmo-cbc wanted to send 30s keep-alive repetition
period, but a spec-compliant receiver actually decoded this as 80s.
Change-Id: I04baa6b6b99b092fa0512b3b6138a363c7f3a13d
-rw-r--r-- | src/gsm/cbsp.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c index 2c7a7b72..fa599c53 100644 --- a/src/gsm/cbsp.c +++ b/src/gsm/cbsp.c @@ -352,7 +352,12 @@ static int cbsp_enc_reset_fail(struct msgb *msg, const struct osmo_cbsp_reset_fa /* 8.1.3.18a KEEP ALIVE */ static int cbsp_enc_keep_alive(struct msgb *msg, const struct osmo_cbsp_keep_alive *in) { - msgb_tv_put(msg, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, in->repetition_period); + int rperiod = encode_wperiod(in->repetition_period); + if (in->repetition_period > 120) + return -EINVAL; + if (rperiod < 0) + return -EINVAL; + msgb_tv_put(msg, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, rperiod); return 0; } @@ -1083,12 +1088,14 @@ static int cbsp_dec_reset_fail(struct osmo_cbsp_reset_failure *out, const struct static int cbsp_dec_keep_alive(struct osmo_cbsp_keep_alive *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx) { + uint8_t rperiod; if (!TLVP_PRES_LEN(tp, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, 1)) { osmo_cbsp_errstr = "missing/short mandatory IE"; return -EINVAL; } - out->repetition_period = *TLVP_VAL(tp, CBSP_IEI_KEEP_ALIVE_REP_PERIOD); + rperiod = *TLVP_VAL(tp, CBSP_IEI_KEEP_ALIVE_REP_PERIOD); + out->repetition_period = decode_wperiod(rperiod); return 0; } |