<p>Max <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/12955">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Rewrite Packet Uplink IA Rest Octets for SBA<br><br>Use bitvec_set_*() directly without external write pointer tracking to<br>simplify the code. This is part of IA Rest Octets (3GPP TS 44.018<br>§10.5.2.16) which is the last part of the message so it should not<br>interfere with the rest of encoding functions.<br><br>The difference in the expected test output is due to proper handling of<br>TAI which should not be transmitted for SBA according to the Note in<br>Table 10.5.2.16.1 in 3GPP TS 44.018.<br><br>The change was manually tested against real mobile phone using options<br>'gprs mode gprs' in osmo-bsc.cfg and 'two-phase-access' in osmo-pcu.cfg<br>to make sure appropriate code path is actually triggered.<br><br>That's partially based on reverted commit 93d947f5e8a30acc9250c124bf9d5bb6a8863526.<br><br>Change-Id: I97d53c27c1ca9e032d431b3aa7f915027d63ddc0<br>Related: OS#3014<br>---<br>M src/encoding.cpp<br>M tests/types/TypesTest.cpp<br>M tests/types/TypesTest.ok<br>3 files changed, 24 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/encoding.cpp b/src/encoding.cpp</span><br><span>index 769e049..55838fb 100644</span><br><span>--- a/src/encoding.cpp</span><br><span>+++ b/src/encoding.cpp</span><br><span>@@ -233,25 +233,31 @@</span><br><span>         return rc;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static int write_ia_rest_uplink_sba(bitvec *dest, uint32_t fn, uint8_t alpha, uint8_t gamma, int8_t ta_idx,</span><br><span style="color: hsl(0, 100%, 40%);">-                              unsigned& wp)</span><br><span style="color: hsl(120, 100%, 40%);">+/* 3GPP TS 44.018 Table 10.5.2.16.1 < Packet Uplink Assignment > -- Single Block Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+static int write_ia_rest_uplink_sba(bitvec *dest, uint32_t fn, uint8_t alpha, uint8_t gamma)</span><br><span> {</span><br><span>       int rc = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- bitvec_write_field(dest, &wp, 0, 1); // Block Allocation: Single Block Allocation</span><br><span style="color: hsl(120, 100%, 40%);">+ SET_0(dest); /* Single Block Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = write_alpha_gamma(dest, alpha, gamma);</span><br><span style="color: hsl(120, 100%, 40%);">+   CHECK(rc);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  if (alpha) {</span><br><span style="color: hsl(0, 100%, 40%);">-            bitvec_write_field(dest, &wp, 0x1, 1);   // ALPHA = present</span><br><span style="color: hsl(0, 100%, 40%);">-         bitvec_write_field(dest, &wp, alpha, 4);</span><br><span style="color: hsl(0, 100%, 40%);">-    } else</span><br><span style="color: hsl(0, 100%, 40%);">-          bitvec_write_field(dest, &wp, 0x0, 1);   // ALPHA = not present</span><br><span style="color: hsl(120, 100%, 40%);">+   /* A 'Timing Advance index' shall not be allocated at a Single Block allocation.</span><br><span style="color: hsl(120, 100%, 40%);">+         A 'TBF Starting Time' shall be allocated at a Single Block allocation. */</span><br><span style="color: hsl(120, 100%, 40%);">+  SET_0(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+  SET_1(dest);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        bitvec_write_field(dest, &wp, gamma, 5);       // GAMMA power control parameter</span><br><span style="color: hsl(0, 100%, 40%);">-     write_tai(dest, wp, ta_idx);</span><br><span style="color: hsl(0, 100%, 40%);">-    bitvec_write_field(dest, &wp, 1, 1);         // TBF_STARTING_TIME_FLAG</span><br><span style="color: hsl(0, 100%, 40%);">-      bitvec_write_field(dest, &wp, (fn / (26 * 51)) % 32, 5); // T1'</span><br><span style="color: hsl(0, 100%, 40%);">- bitvec_write_field(dest, &wp, fn % 51, 6);               // T3</span><br><span style="color: hsl(0, 100%, 40%);">-      bitvec_write_field(dest, &wp, fn % 26, 5);               // T2</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = write_tbf_start_time(dest, fn);</span><br><span style="color: hsl(120, 100%, 40%);">+  CHECK(rc);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* No P0 nor PR_MODE */</span><br><span style="color: hsl(120, 100%, 40%);">+      SET_L(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* No Additions for R99 */</span><br><span style="color: hsl(120, 100%, 40%);">+    SET_L(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+         /* No Additions for Rel-6 */</span><br><span style="color: hsl(120, 100%, 40%);">+ SET_L(dest);</span><br><span> </span><br><span>     return rc;</span><br><span> }</span><br><span>@@ -523,7 +529,8 @@</span><br><span>                        dest->cur_bit = wp;</span><br><span>                       rc = write_ia_rest_uplink_mba(as_ul_tbf(tbf), dest, usf, alpha, gamma);</span><br><span>              } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                        rc = write_ia_rest_uplink_sba(dest, fn, alpha, gamma, ta_idx, wp);</span><br><span style="color: hsl(120, 100%, 40%);">+                    dest->cur_bit = wp;</span><br><span style="color: hsl(120, 100%, 40%);">+                        rc = write_ia_rest_uplink_sba(dest, fn, alpha, gamma);</span><br><span>               }</span><br><span>    }</span><br><span> </span><br><span>diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp</span><br><span>index 4879424..822bd51 100644</span><br><span>--- a/tests/types/TypesTest.cpp</span><br><span>+++ b/tests/types/TypesTest.cpp</span><br><span>@@ -514,7 +514,7 @@</span><br><span>                                  0x23, /* TA */</span><br><span>                               0x00, /* 0-length §10.5.2.21 Mobile Allocation */</span><br><span>                           /* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */</span><br><span style="color: hsl(0, 100%, 40%);">-                                 0xc5, 0xd1, 0x08, 0x0b, 0x5b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };</span><br><span style="color: hsl(120, 100%, 40%);">+                            0xc5, 0xd0, 0x80, 0xb5, 0xab, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };</span><br><span> </span><br><span>      check_imm_ass(NULL, false, GSM_L1_BURST_TYPE_ACCESS_0, res, sizeof(res), "ia_rest_uplink(SBA)");</span><br><span> }</span><br><span>diff --git a/tests/types/TypesTest.ok b/tests/types/TypesTest.ok</span><br><span>index dd7dc4c..c6974d5 100644</span><br><span>--- a/tests/types/TypesTest.ok</span><br><span>+++ b/tests/types/TypesTest.ok</span><br><span>@@ -11,7 +11,7 @@</span><br><span> [11] UL Immediate Assignment <ia_rest_uplink(MBA)>:</span><br><span>        06 3f 10 0d 23 6d 0d 03 18 23 00 c8 02 1b a0 2b 2b 2b 2b 2b 2b 2b 2b </span><br><span> [11] UL Immediate Assignment <ia_rest_uplink(SBA)>:</span><br><span style="color: hsl(0, 100%, 40%);">-      06 3f 10 0d 23 6d 0d 03 18 23 00 c5 d1 08 0b 5b 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(120, 100%, 40%);">+ 06 3f 10 0d 23 6d 0d 03 18 23 00 c5 d0 80 b5 ab 2b 2b 2b 2b 2b 2b 2b </span><br><span> [11] UL Immediate Assignment <ia_rest_egprs_uplink(MBA)>:</span><br><span>     06 3f 10 0d 23 6d 7f 03 18 23 00 46 97 40 0b 58 2b 2b 2b 2b 2b 2b 2b </span><br><span> [11] UL Immediate Assignment <ia_rest_egprs_uplink(SBA)>:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12955">change 12955</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/12955"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I97d53c27c1ca9e032d431b3aa7f915027d63ddc0 </div>
<div style="display:none"> Gerrit-Change-Number: 12955 </div>
<div style="display:none"> Gerrit-PatchSet: 17 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Max <msuraev@sysmocom.de> </div>