<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/22926">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm: Fix encoding of gsm0808_cell_id_list2 with CGI-PS types<br><br>CGI-PS type doesn't exist in GSM 08.08 Cell Id lists. That type of cell<br>id is osmocom-specific and used internally. In here CGI-PS is<br>automatically converted to CGI (since the later is an extension of this<br>one).<br><br>The encode/decode_cell_id_u are left intact (comment added) since those<br>can still be used (and are used by RIM code) to encode/decode TS 48.018<br>Cell Identifiers.<br><br>Related: SYS#4909<br>Change-Id: Id74f4577c397c1ba696f00395858311bd82cb2c8<br>---<br>M src/gsm/gsm0808_utils.c<br>M tests/gsm0808/gsm0808_test.c<br>2 files changed, 63 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/22926/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c</span><br><span>index e0f0c28..dda73ad 100644</span><br><span>--- a/src/gsm/gsm0808_utils.c</span><br><span>+++ b/src/gsm/gsm0808_utils.c</span><br><span>@@ -877,6 +877,7 @@</span><br><span>               /* Does not have any list items */</span><br><span>           break;</span><br><span>       case CELL_IDENT_WHOLE_GLOBAL_PS:</span><br><span style="color: hsl(120, 100%, 40%);">+              /* 3GPP TS 48.018 sec 11.3.9 "Cell Identifier" */</span><br><span>          if (len < 8)</span><br><span>                      return -EINVAL;</span><br><span>              decode_lai(buf, (struct osmo_location_area_id *)&out->global_ps.rai); /* rai contains lai + non-decoded rac */</span><br><span>@@ -925,6 +926,7 @@</span><br><span>          /* Does not have any list items */</span><br><span>           break;</span><br><span>       case CELL_IDENT_WHOLE_GLOBAL_PS: {</span><br><span style="color: hsl(120, 100%, 40%);">+            /* 3GPP TS 48.018 sec 11.3.9 "Cell Identifier" */</span><br><span>          const struct osmo_cell_global_id_ps *id = &u->global_ps;</span><br><span>              struct gsm48_loc_area_id lai;</span><br><span>                gsm48_generate_lai2(&lai, &id->rai.lac);</span><br><span>@@ -949,6 +951,7 @@</span><br><span>    uint8_t *old_tail;</span><br><span>   uint8_t *tlv_len;</span><br><span>    unsigned int i;</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t id_discr;</span><br><span> </span><br><span>        OSMO_ASSERT(msg);</span><br><span>    OSMO_ASSERT(cil);</span><br><span>@@ -957,11 +960,25 @@</span><br><span>    tlv_len = msgb_put(msg, 1);</span><br><span>  old_tail = msg->tail;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    msgb_put_u8(msg, cil->id_discr & 0x0f);</span><br><span style="color: hsl(120, 100%, 40%);">+        /* CGI-PS is an osmocom-specific type. In here we don't care about the</span><br><span style="color: hsl(120, 100%, 40%);">+     * PS part, only the CS one. */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (cil->id_discr == CELL_IDENT_WHOLE_GLOBAL_PS)</span><br><span style="color: hsl(120, 100%, 40%);">+           id_discr = CELL_IDENT_WHOLE_GLOBAL;</span><br><span style="color: hsl(120, 100%, 40%);">+   else</span><br><span style="color: hsl(120, 100%, 40%);">+          id_discr = cil->id_discr & 0x0f;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_put_u8(msg, id_discr);</span><br><span> </span><br><span>      OSMO_ASSERT(cil->id_list_len <= GSM0808_CELL_ID_LIST2_MAXLEN);</span><br><span style="color: hsl(0, 100%, 40%);">-    for (i = 0; i < cil->id_list_len; i++)</span><br><span style="color: hsl(0, 100%, 40%);">-            gsm0808_msgb_put_cell_id_u(msg, cil->id_discr, &cil->id_list[i]);</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = 0; i < cil->id_list_len; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                if (cil->id_discr == CELL_IDENT_WHOLE_GLOBAL_PS) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 union gsm0808_cell_id_u u;</span><br><span style="color: hsl(120, 100%, 40%);">+                    cell_id_to_cgi(&u.global, cil->id_discr, &cil->id_list[i]);</span><br><span style="color: hsl(120, 100%, 40%);">+                     gsm0808_msgb_put_cell_id_u(msg, CELL_IDENT_WHOLE_GLOBAL, &u);</span><br><span style="color: hsl(120, 100%, 40%);">+             } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      gsm0808_msgb_put_cell_id_u(msg, cil->id_discr, &cil->id_list[i]);</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span> </span><br><span>        *tlv_len = (uint8_t) (msg->tail - old_tail);</span><br><span>      return *tlv_len + 2;</span><br><span>diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c</span><br><span>index 7eb53c2..04b3b72 100644</span><br><span>--- a/tests/gsm0808/gsm0808_test.c</span><br><span>+++ b/tests/gsm0808/gsm0808_test.c</span><br><span>@@ -1760,6 +1760,48 @@</span><br><span>   msgb_free(msg);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void test_gsm0808_enc_dec_cell_id_global_ps()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     struct gsm0808_cell_id enc_cgi = {</span><br><span style="color: hsl(120, 100%, 40%);">+            .id_discr = CELL_IDENT_WHOLE_GLOBAL,</span><br><span style="color: hsl(120, 100%, 40%);">+          .id.global = {</span><br><span style="color: hsl(120, 100%, 40%);">+                        .lai = {</span><br><span style="color: hsl(120, 100%, 40%);">+                              .plmn = { .mcc = 123, .mnc = 456 },</span><br><span style="color: hsl(120, 100%, 40%);">+                           .lac = 0x2342</span><br><span style="color: hsl(120, 100%, 40%);">+                 },</span><br><span style="color: hsl(120, 100%, 40%);">+                    .cell_identity = 0x423,</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span style="color: hsl(120, 100%, 40%);">+     };</span><br><span style="color: hsl(120, 100%, 40%);">+    struct gsm0808_cell_id enc_cgi_ps = {</span><br><span style="color: hsl(120, 100%, 40%);">+         .id_discr = CELL_IDENT_WHOLE_GLOBAL_PS,</span><br><span style="color: hsl(120, 100%, 40%);">+               .id.global_ps = {</span><br><span style="color: hsl(120, 100%, 40%);">+                     .rai = {</span><br><span style="color: hsl(120, 100%, 40%);">+                              .lac = {</span><br><span style="color: hsl(120, 100%, 40%);">+                                      .plmn = { .mcc = 123, .mnc = 456 },</span><br><span style="color: hsl(120, 100%, 40%);">+                                   .lac = 0x2342</span><br><span style="color: hsl(120, 100%, 40%);">+                         },</span><br><span style="color: hsl(120, 100%, 40%);">+                            .rac = 0xcc,</span><br><span style="color: hsl(120, 100%, 40%);">+                  },</span><br><span style="color: hsl(120, 100%, 40%);">+                    .cell_identity = 0x423,</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span style="color: hsl(120, 100%, 40%);">+     };</span><br><span style="color: hsl(120, 100%, 40%);">+    struct msgb *msg_cgi, *msg_cgi_ps;</span><br><span style="color: hsl(120, 100%, 40%);">+    uint8_t rc_enc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     msg_cgi = msgb_alloc(1024, "output buffer (CGI)");</span><br><span style="color: hsl(120, 100%, 40%);">+  rc_enc = gsm0808_enc_cell_id(msg_cgi, &enc_cgi);</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_ASSERT(rc_enc > 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ msg_cgi_ps = msgb_alloc(1024, "output buffer (CGI-PS)");</span><br><span style="color: hsl(120, 100%, 40%);">+    rc_enc = gsm0808_enc_cell_id(msg_cgi_ps, &enc_cgi_ps);</span><br><span style="color: hsl(120, 100%, 40%);">+    OSMO_ASSERT(rc_enc > 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(msgb_eq(msg_cgi, msg_cgi_ps));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  msgb_free(msg_cgi);</span><br><span style="color: hsl(120, 100%, 40%);">+   msgb_free(msg_cgi_ps);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(struct gsm48_multi_rate_conf *cfg)</span><br><span> {</span><br><span>      uint16_t s15_s0;</span><br><span>@@ -2462,6 +2504,7 @@</span><br><span>     test_gsm0808_enc_dec_cell_id_ci();</span><br><span>   test_gsm0808_enc_dec_cell_id_lac_and_ci();</span><br><span>   test_gsm0808_enc_dec_cell_id_global();</span><br><span style="color: hsl(120, 100%, 40%);">+        test_gsm0808_enc_dec_cell_id_global_ps();</span><br><span>    test_gsm0808_sc_cfg_from_gsm48_mr_cfg();</span><br><span>     test_gsm48_mr_cfg_from_gsm0808_sc_cfg();</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/22926">change 22926</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/+/22926"/><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: Id74f4577c397c1ba696f00395858311bd82cb2c8 </div>
<div style="display:none"> Gerrit-Change-Number: 22926 </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>