<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13484">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">msc/gsm_data.h: fix and clarify GSM 03.40 TP-UD Length<br><br>As per 3GPP TS 03.40, section 9.2.3.16 "TP-User-Data-Length (TP-UDL)",<br>if the TP-User-Data is coded using the GSM 7-bit default alphabet,<br>the TP-User-Data-Length field indicates the *number of septets*<br>within the TP-User-Data field to follow. Otherwise, e.g. in case<br>of 8-bit or UCS-2 encoded data, the *number of octets* is indicated.<br><br>It's a good question from where does this value come from:<br><br>  #define SMS_TEXT_SIZE 256<br><br>Let's replace it with two new definitions:<br><br>  #define GSM340_UDL_OCT_MAX 140<br>  #define GSM340_UDL_SPT_MAX 160<br><br>which correspond to the maximum TP-UD field length indicated<br>in octets and septets respectively.<br><br>Change-Id: I2a49f9d24cd075234190b3b92999256bce01ca77<br>---<br>M include/osmocom/msc/gsm_data.h<br>1 file changed, 14 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/84/13484/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h</span><br><span>index 1a0d144..77f76b7 100644</span><br><span>--- a/include/osmocom/msc/gsm_data.h</span><br><span>+++ b/include/osmocom/msc/gsm_data.h</span><br><span>@@ -239,7 +239,9 @@</span><br><span>      SMS_SOURCE_SMPP,        /* received via SMPP */</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define SMS_TEXT_SIZE  256</span><br><span style="color: hsl(120, 100%, 40%);">+/* TODO: Move these defines to libosmogsm (gsm/protocol/gsm_03_40.h) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM340_UDL_OCT_MAX 140  /*!< Maximum TP-UD length (in octets) for 7-bit encoding */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM340_UDL_SPT_MAX 160  /*!< Maximum TP-UD length (in seplets) for 8-bit and UCS-2 encoding */</span><br><span> </span><br><span> struct gsm_sms_addr {</span><br><span>         uint8_t ton;</span><br><span>@@ -274,10 +276,18 @@</span><br><span>         uint8_t protocol_id;</span><br><span>         uint8_t data_coding_scheme;</span><br><span>  uint8_t msg_ref;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint8_t user_data_len;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint8_t user_data[SMS_TEXT_SIZE];</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   char text[SMS_TEXT_SIZE];</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Depending on DCS value in use, TP-UDL may indicate the length of</span><br><span style="color: hsl(120, 100%, 40%);">+    * TP-UD either in septets, or in octets. See 3GPP TS 03.40,</span><br><span style="color: hsl(120, 100%, 40%);">+   * section 9.2.3.16 "TP-User-Data-Length (TP-UDL)" for details. */</span><br><span style="color: hsl(120, 100%, 40%);">+  uint8_t user_data_len;</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Since we always store TP-UD in octets, even if it does contain</span><br><span style="color: hsl(120, 100%, 40%);">+      * data encoded in septets (i.e. 7-bit default encoding), this</span><br><span style="color: hsl(120, 100%, 40%);">+         * buffer is limited to 140 bytes. */</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t user_data[GSM340_UDL_OCT_MAX];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /* Up to 160 symbols decoded from TP-UD + '\0' */</span><br><span style="color: hsl(120, 100%, 40%);">+     char text[GSM340_UDL_SPT_MAX + 1];</span><br><span> };</span><br><span> </span><br><span> /* control interface handling */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13484">change 13484</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/13484"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-msc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2a49f9d24cd075234190b3b92999256bce01ca77 </div>
<div style="display:none"> Gerrit-Change-Number: 13484 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>