<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bsc/+/17138">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bssap: Avoid logging error if no optional Global Call Ref IE received<br><br>Also take the chance to simplify related code and print erroneous IE<br>data.<br><br>Change-Id: I27ee9c6112f96d6839b8b6141888ac8fe377db65<br>---<br>M src/osmo-bsc/osmo_bsc_bssap.c<br>1 file changed, 14 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/38/17138/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c</span><br><span>index 74faae1..1ba490f 100644</span><br><span>--- a/src/osmo-bsc/osmo_bsc_bssap.c</span><br><span>+++ b/src/osmo-bsc/osmo_bsc_bssap.c</span><br><span>@@ -568,20 +568,24 @@</span><br><span> static void bssmap_handle_ass_req_lcls(struct gsm_subscriber_connection *conn,</span><br><span>                                   const struct tlv_parsed *tp)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-       const uint8_t *config, *control, *gcr, gcr_len = TLVP_LEN(tp, GSM0808_IE_GLOBAL_CALL_REF);</span><br><span style="color: hsl(120, 100%, 40%);">+    const uint8_t *config, *control, *gcr;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t gcr_len;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    if (gcr_len > sizeof(conn->lcls.global_call_ref))</span><br><span style="color: hsl(0, 100%, 40%);">-         LOGPFSML(conn->fi, LOGL_ERROR, "Global Call Ref IE of %u bytes is too long\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                      gcr_len);</span><br><span style="color: hsl(0, 100%, 40%);">-      else {</span><br><span style="color: hsl(0, 100%, 40%);">-          gcr = TLVP_VAL_MINLEN(tp, GSM0808_IE_GLOBAL_CALL_REF, 13);</span><br><span style="color: hsl(0, 100%, 40%);">-              if (gcr) {</span><br><span style="color: hsl(120, 100%, 40%);">+    /* TS 48.008 sec 3.2.2.115 Global Call Reference */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (TLVP_PRESENT(tp, GSM0808_IE_GLOBAL_CALL_REF)) {</span><br><span style="color: hsl(120, 100%, 40%);">+           gcr = TLVP_VAL(tp, GSM0808_IE_GLOBAL_CALL_REF);</span><br><span style="color: hsl(120, 100%, 40%);">+               gcr_len = TLVP_LEN(tp, GSM0808_IE_GLOBAL_CALL_REF);</span><br><span style="color: hsl(120, 100%, 40%);">+           if (gcr_len > sizeof(conn->lcls.global_call_ref)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     LOGPFSML(conn->fi, LOGL_ERROR, "Global Call Ref IE of %u bytes is too long: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                gcr_len, osmo_hexdump_nospc(gcr, gcr_len));</span><br><span style="color: hsl(120, 100%, 40%);">+          } else if (gcr_len < 13) { /* FIXME: document this magic value 13 */</span><br><span style="color: hsl(120, 100%, 40%);">+                       LOGPFSML(conn->fi, LOGL_ERROR, "Global Call Ref IE of %u bytes is too short: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                               gcr_len, osmo_hexdump_nospc(gcr, gcr_len));</span><br><span style="color: hsl(120, 100%, 40%);">+          } else {</span><br><span>                     LOGPFSM(conn->fi, "Setting GCR to %s\n", osmo_hexdump_nospc(gcr, gcr_len));</span><br><span>                     memcpy(&conn->lcls.global_call_ref, gcr, gcr_len);</span><br><span>                    conn->lcls.global_call_ref_len = gcr_len;</span><br><span style="color: hsl(0, 100%, 40%);">-            } else</span><br><span style="color: hsl(0, 100%, 40%);">-                  LOGPFSML(conn->fi, LOGL_ERROR, "Global Call Ref IE of %u bytes is too short\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                             gcr_len);</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span>    }</span><br><span> </span><br><span>        config = TLVP_VAL_MINLEN(tp, GSM0808_IE_LCLS_CONFIG, 1);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bsc/+/17138">change 17138</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/osmo-bsc/+/17138"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I27ee9c6112f96d6839b8b6141888ac8fe377db65 </div>
<div style="display:none"> Gerrit-Change-Number: 17138 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>