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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm0808: fix endieness of call identifier<br><br>The call identifier in the ASSIGNMENT COMMAND is encoded in the wrong<br>endieness. 3GPP TS 48.008, section 3.2.2.105 specifies that the least<br>significant byte should be transmitted first, which means that the<br>endieness here is little endian. Lets make sure that the endieness is<br>correctly transmitted, regardless of the host byte order.<br><br>Change-Id: I6468e502f552f99ab54aec9d4b1c169fdc0adfb8<br>Related: OS#4582<br>---<br>M src/gsm/gsm0808.c<br>M tests/gsm0808/gsm0808_test.c<br>2 files changed, 14 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c</span><br><span>index 23468c3..9fdf379 100644</span><br><span>--- a/src/gsm/gsm0808.c</span><br><span>+++ b/src/gsm/gsm0808.c</span><br><span>@@ -24,6 +24,7 @@</span><br><span> #include <string.h></span><br><span> </span><br><span> #include <osmocom/core/byteswap.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/endian.h></span><br><span> #include <osmocom/gsm/gsm0808.h></span><br><span> #include <osmocom/gsm/gsm0808_utils.h></span><br><span> #include <osmocom/gsm/protocol/gsm_08_08.h></span><br><span>@@ -515,7 +516,16 @@</span><br><span> </span><br><span>  /* AoIP: Call Identifier 3.2.2.105 */</span><br><span>        if (ci) {</span><br><span style="color: hsl(0, 100%, 40%);">-               ci_sw = osmo_htonl(*ci);</span><br><span style="color: hsl(120, 100%, 40%);">+              /* NOTE: 3GPP TS 48.008, section 3.2.2.105 specifies that</span><br><span style="color: hsl(120, 100%, 40%);">+                the least significant byte should be transmitted first.</span><br><span style="color: hsl(120, 100%, 40%);">+               On x86, this would mean that the endieness is already</span><br><span style="color: hsl(120, 100%, 40%);">+                 correct, however a platform independed implementation</span><br><span style="color: hsl(120, 100%, 40%);">+                 is required: */</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef OSMO_IS_LITTLE_ENDIAN</span><br><span style="color: hsl(120, 100%, 40%);">+             ci_sw = osmo_swab32(*ci);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+              ci_sw = *ci;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>                 msgb_tv_fixed_put(msg, GSM0808_IE_CALL_ID, sizeof(ci_sw),</span><br><span>                              (uint8_t *) & ci_sw);</span><br><span>  }</span><br><span>diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c</span><br><span>index d9640aa..5c1a931 100644</span><br><span>--- a/tests/gsm0808/gsm0808_test.c</span><br><span>+++ b/tests/gsm0808/gsm0808_test.c</span><br><span>@@ -438,8 +438,8 @@</span><br><span>               0x04, GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17,</span><br><span>              0x04, 0xd2, GSM0808_IE_SPEECH_CODEC_LIST, 0x07,</span><br><span>              GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f,</span><br><span style="color: hsl(0, 100%, 40%);">-       GSM0808_SCT_CSD | 0x90, 0xc0, GSM0808_IE_CALL_ID, 0xaa, 0xbb,</span><br><span style="color: hsl(0, 100%, 40%);">-           0xcc, 0xdd };</span><br><span style="color: hsl(120, 100%, 40%);">+         GSM0808_SCT_CSD | 0x90, 0xc0, GSM0808_IE_CALL_ID, 0xdd, 0xcc,</span><br><span style="color: hsl(120, 100%, 40%);">+         0xbb, 0xaa };</span><br><span> </span><br><span>      struct msgb *msg;</span><br><span>    struct gsm0808_channel_type ct;</span><br><span>@@ -499,7 +499,7 @@</span><br><span>                GSM0808_SCT_CSD | 0x90,</span><br><span>              0xc0,</span><br><span>                GSM0808_IE_CALL_ID,</span><br><span style="color: hsl(0, 100%, 40%);">-             0xde, 0xad, 0xfa, 0xce, /* CallID */</span><br><span style="color: hsl(120, 100%, 40%);">+          0xce, 0xfa, 0xad, 0xde, /* CallID */            </span><br><span>             0x83, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, /* Kc */</span><br><span>               GSM0808_IE_GLOBAL_CALL_REF, 0x0d, /* GCR, length */</span><br><span>          0x03, 0x44, 0x44, 0x44, /* GCR, Net ID */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/18694">change 18694</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/+/18694"/><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: I6468e502f552f99ab54aec9d4b1c169fdc0adfb8 </div>
<div style="display:none"> Gerrit-Change-Number: 18694 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </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>