<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/23017">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CBSP: fix encoding/decoding of keep-alive repetition period<br><br>Even though the value is only between 0..120s, they didn't encode<br>it 1:1 in the uint8_t, but 3GPP chose to use the same encoding<br>as for the warning period (which has a much larger range).<br><br>Let's fix this in our implementation.<br><br>Before this patch, osmo-cbc wanted to send 30s keep-alive repetition<br>period, but a spec-compliant receiver actually decoded this as 80s.<br><br>Change-Id: I04baa6b6b99b092fa0512b3b6138a363c7f3a13d<br>---<br>M src/gsm/cbsp.c<br>1 file changed, 9 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c</span><br><span>index 2c7a7b7..fa599c5 100644</span><br><span>--- a/src/gsm/cbsp.c</span><br><span>+++ b/src/gsm/cbsp.c</span><br><span>@@ -352,7 +352,12 @@</span><br><span> /* 8.1.3.18a KEEP ALIVE */</span><br><span> static int cbsp_enc_keep_alive(struct msgb *msg, const struct osmo_cbsp_keep_alive *in)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-   msgb_tv_put(msg, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, in->repetition_period);</span><br><span style="color: hsl(120, 100%, 40%);">+   int rperiod = encode_wperiod(in->repetition_period);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (in->repetition_period > 120)</span><br><span style="color: hsl(120, 100%, 40%);">+                return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       if (rperiod < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+           return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_tv_put(msg, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, rperiod);</span><br><span>   return 0;</span><br><span> }</span><br><span> </span><br><span>@@ -1083,12 +1088,14 @@</span><br><span> static int cbsp_dec_keep_alive(struct osmo_cbsp_keep_alive *out, const struct tlv_parsed *tp,</span><br><span>                                struct msgb *in, void *ctx)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t rperiod;</span><br><span>     if (!TLVP_PRES_LEN(tp, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, 1)) {</span><br><span>                 osmo_cbsp_errstr = "missing/short mandatory IE";</span><br><span>           return -EINVAL;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   out->repetition_period = *TLVP_VAL(tp, CBSP_IEI_KEEP_ALIVE_REP_PERIOD);</span><br><span style="color: hsl(120, 100%, 40%);">+    rperiod = *TLVP_VAL(tp, CBSP_IEI_KEEP_ALIVE_REP_PERIOD);</span><br><span style="color: hsl(120, 100%, 40%);">+      out->repetition_period = decode_wperiod(rperiod);</span><br><span>         return 0;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/23017">change 23017</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/23017"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I04baa6b6b99b092fa0512b3b6138a363c7f3a13d </div>
<div style="display:none"> Gerrit-Change-Number: 23017 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>