<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12839">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm/gsm0480: introduce gsm0480_create_release_complete[_cause]() API<br><br>In OsmoMSC, it's required to be able to specify a particular GSM 04.07<br>transaction ID for GSM 04.80 Release complete message instead of the<br>hard-coded value, that is used gsm0480_create_ussd_release_complete().<br><br>Let's finally deprecate gsm0480_create_ussd_release_complete(), and<br>introduce two new functions without USSD prefix, as this message<br>is also used in other "structured" supplementary services:<br><br>  - gsm0480_create_release_complete,<br>  - gsm0480_create_release_complete_cause.<br><br>The second one can be used to encode optional Cause IE (see 2.5.1).<br><br>Change-Id: Ie3ac85fcef90a5e532334ba3482804d5305c88d7<br>---<br>M include/osmocom/gsm/gsm0480.h<br>M src/gsm/gsm0480.c<br>M src/gsm/libosmogsm.map<br>3 files changed, 65 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/12839/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h</span><br><span>index 827464e..9d6d67d 100644</span><br><span>--- a/include/osmocom/gsm/gsm0480.h</span><br><span>+++ b/include/osmocom/gsm/gsm0480.h</span><br><span>@@ -117,7 +117,11 @@</span><br><span> struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char *text);</span><br><span> struct msgb *gsm0480_create_notifySS(const char *text);</span><br><span> struct msgb *gsm0480_create_ussd_notify(int level, const char *text);</span><br><span style="color: hsl(0, 100%, 40%);">-struct msgb *gsm0480_create_ussd_release_complete(void);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0480_create_ussd_release_complete(void)</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_DEPRECATED("Use gsm0480_create_release_complete() instead.");</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0480_create_release_complete(uint8_t tid);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0480_create_release_complete_cause(uint8_t tid, uint8_t cause_loc,</span><br><span style="color: hsl(120, 100%, 40%);">+                                             uint8_t cause_value);</span><br><span> </span><br><span> int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id);</span><br><span> int gsm0480_wrap_facility(struct msgb *msg);</span><br><span>diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c</span><br><span>index b5c9844..e9c148a 100644</span><br><span>--- a/src/gsm/gsm0480.c</span><br><span>+++ b/src/gsm/gsm0480.c</span><br><span>@@ -921,6 +921,7 @@</span><br><span>       return msg;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Deprecated, use gsm0480_create_release_complete[_cause]() instead. */</span><br><span> struct msgb *gsm0480_create_ussd_release_complete(void)</span><br><span> {</span><br><span>      struct msgb *msg;</span><br><span>@@ -936,3 +937,59 @@</span><br><span> </span><br><span>         return msg;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Create a GSM 04.80 Release complete (see 2.5) message, prefixed</span><br><span style="color: hsl(120, 100%, 40%);">+ *  by GSM 04.08 L3 header with a given transaction ID.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] tid  GSM 04.07 transaction identifier (and TI flag)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return  message buffer containing the Release complete message</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0480_create_release_complete(uint8_t tid)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   msg = gsm0480_msgb_alloc_name("TS 04.80 USSD REL COMPL");</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!msg)</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Push the L3 header */</span><br><span style="color: hsl(120, 100%, 40%);">+      gsm48_push_l3hdr_tid(msg, GSM48_PDISC_NC_SS,</span><br><span style="color: hsl(120, 100%, 40%);">+                       tid, GSM0480_MTYPE_RELEASE_COMPLETE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  return msg;</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%);">+/*! Create a GSM 04.80 Release complete (see 2.5) message, prefixed</span><br><span style="color: hsl(120, 100%, 40%);">+ *  by GSM 04.08 L3 header with a given transaction ID, containing</span><br><span style="color: hsl(120, 100%, 40%);">+ *  additional Cause IE (see 2.5.1), encoded according to GSM 04.80,</span><br><span style="color: hsl(120, 100%, 40%);">+ *  section 10.5.4.11 (without diagnostic info).</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] tid  GSM 04.07 transaction identifier (and TI flag)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] cause_loc  cause location (see GSM 04.08, table 10.85)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] cause_value  cause value (see GSM 04.08, table 10.86)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return  message buffer containing the Release complete message</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0480_create_release_complete_cause(uint8_t tid, uint8_t cause_loc,</span><br><span style="color: hsl(120, 100%, 40%);">+                                             uint8_t cause_value)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    uint8_t *cause_ie;</span><br><span style="color: hsl(120, 100%, 40%);">+    struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   msg = gsm0480_create_release_complete(tid);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!msg)</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Encode cause IE (see GSM 04.08, section 10.5.4.11)</span><br><span style="color: hsl(120, 100%, 40%);">+  * with fixed length (2 bytes of TL, 2 bytes of payload).</span><br><span style="color: hsl(120, 100%, 40%);">+      * NOTE: we don't use gsm48_encode_cause() API because</span><br><span style="color: hsl(120, 100%, 40%);">+     * it wants gsm_mncc_cause struct from us. */</span><br><span style="color: hsl(120, 100%, 40%);">+ cause_ie = msgb_put(msg, 2 + 2);</span><br><span style="color: hsl(120, 100%, 40%);">+      cause_ie[0] = GSM48_IE_CAUSE;</span><br><span style="color: hsl(120, 100%, 40%);">+ cause_ie[1] = 2;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Coding standard defined for the GSM PLMNs,</span><br><span style="color: hsl(120, 100%, 40%);">+  * Location and cause: as given by caller,</span><br><span style="color: hsl(120, 100%, 40%);">+     * No extension. */</span><br><span style="color: hsl(120, 100%, 40%);">+   cause_ie[2] = (1 << 7) | (0x03 << 5) | (cause_loc & 0x0f);</span><br><span style="color: hsl(120, 100%, 40%);">+    cause_ie[3] = (1 << 7) | cause_value;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map</span><br><span>index 602c7a6..fcf977d 100644</span><br><span>--- a/src/gsm/libosmogsm.map</span><br><span>+++ b/src/gsm/libosmogsm.map</span><br><span>@@ -89,6 +89,9 @@</span><br><span> gsm0480_create_ussd_resp;</span><br><span> gsm0480_create_ussd_notify;</span><br><span> gsm0480_create_ussd_release_complete;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm0480_create_release_complete;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm0480_create_release_complete_cause;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> gsm0480_extract_ie_by_tag;</span><br><span> gsm0480_parse_facility_ie;</span><br><span> gsm0480_decode_ussd_request;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12839">change 12839</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/12839"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie3ac85fcef90a5e532334ba3482804d5305c88d7 </div>
<div style="display:none"> Gerrit-Change-Number: 12839 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>