<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/10327">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;">libmsc/gsm_09_11.c: clean up the local GSM 04.80 API<br><br>Since we don't process SS/USSD requests in OsmoMSC anymore, there<br>are some useless GSM 04.80 functions remained from the past.<br><br>In particular, this change does the following:<br><br>  - removes both gsm0480_send_{ussd_response|return_error}<br>    functions because they are not used anymore;<br><br>  - changes symbol prefix from 'gsm0480_' to 'msc_', in order to<br>    avoid possible conflicts with the libosmogsm's GSM 04.80 API;<br><br>  - cleans up useless includes;<br><br>Change-Id: I2990d8627bce0ce6afb1dcf6b11bb194292380d3<br>---<br>M include/osmocom/msc/gsm_04_80.h<br>M src/libmsc/gsm_04_80.c<br>M src/libmsc/gsm_09_11.c<br>3 files changed, 13 insertions(+), 149 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/msc/gsm_04_80.h b/include/osmocom/msc/gsm_04_80.h</span><br><span>index 7d63088..c448c91 100644</span><br><span>--- a/include/osmocom/msc/gsm_04_80.h</span><br><span>+++ b/include/osmocom/msc/gsm_04_80.h</span><br><span>@@ -1,18 +1,10 @@</span><br><span> #pragma once</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/core/msgb.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/gsm/protocol/gsm_04_80.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/gsm/gsm0480.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span> </span><br><span> struct gsm_subscriber_connection;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(0, 100%, 40%);">-                        uint8_t transaction_id, uint8_t invoke_id,</span><br><span style="color: hsl(0, 100%, 40%);">-                              const char *response_text);</span><br><span style="color: hsl(0, 100%, 40%);">-int gsm0480_send_ussd_return_error(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(0, 100%, 40%);">-                               uint8_t transaction_id, uint8_t invoke_id,</span><br><span style="color: hsl(0, 100%, 40%);">-                              uint8_t error_code);</span><br><span style="color: hsl(0, 100%, 40%);">-int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(120, 100%, 40%);">+int msc_send_ussd_reject(struct gsm_subscriber_connection *conn,</span><br><span>                             uint8_t transaction_id, int invoke_id,</span><br><span>                       uint8_t problem_tag, uint8_t problem_code);</span><br><span> </span><br><span>diff --git a/src/libmsc/gsm_04_80.c b/src/libmsc/gsm_04_80.c</span><br><span>index 32e8e23..0adf059 100644</span><br><span>--- a/src/libmsc/gsm_04_80.c</span><br><span>+++ b/src/libmsc/gsm_04_80.c</span><br><span>@@ -22,20 +22,14 @@</span><br><span>  *</span><br><span>  */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-#include <stdio.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <stdlib.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <string.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span> #include <errno.h></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/msc/debug.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/msc/gsm_data.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/msc/gsm_04_08.h></span><br><span> #include <osmocom/msc/gsm_04_80.h></span><br><span> #include <osmocom/msc/msc_ifaces.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/protocol/gsm_04_80.h></span><br><span> #include <osmocom/gsm/gsm0480.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/gsm/gsm_utils.h></span><br><span> #include <osmocom/core/msgb.h></span><br><span> #include <osmocom/gsm/tlv.h></span><br><span> </span><br><span>@@ -48,120 +42,6 @@</span><br><span>   return data;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag,</span><br><span style="color: hsl(0, 100%, 40%);">-                                            uint8_t value)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-     uint8_t *data = msgb_push(msgb, 3);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     data[0] = tag;</span><br><span style="color: hsl(0, 100%, 40%);">-  data[1] = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-    data[2] = value;</span><br><span style="color: hsl(0, 100%, 40%);">-        return data;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static inline unsigned char *msgb_push_NULL(struct msgb *msgb)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-    uint8_t *data = msgb_push(msgb, 2);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     data[0] = ASN1_NULL_TYPE_TAG;</span><br><span style="color: hsl(0, 100%, 40%);">-   data[1] = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-    return data;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*! Send a MT RELEASE COMPLETE message with USSD-response,</span><br><span style="color: hsl(0, 100%, 40%);">- *  wrapped into the ReturnResult component (see section 3.6.1).</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  conn            Active subscriber connection</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  transaction_id  Transaction ID with TI flag set</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  invoke_id       InvokeID of the request</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  response_text   The response text</span><br><span style="color: hsl(0, 100%, 40%);">- * \return     result of \ref msc_tx_dtap</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(0, 100%, 40%);">-                             uint8_t transaction_id, uint8_t invoke_id,</span><br><span style="color: hsl(0, 100%, 40%);">-                              const char *response_text)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-      struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD RSP");</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gsm48_hdr *gh;</span><br><span style="color: hsl(0, 100%, 40%);">-   uint8_t *ptr8;</span><br><span style="color: hsl(0, 100%, 40%);">-  int response_len;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* First put the payload text into the message */</span><br><span style="color: hsl(0, 100%, 40%);">-       ptr8 = msgb_put(msg, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-        gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), response_text, &response_len);</span><br><span style="color: hsl(0, 100%, 40%);">-     msgb_put(msg, response_len);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Then wrap it as an Octet String */</span><br><span style="color: hsl(0, 100%, 40%);">-   msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* Pre-pend the DCS octet string */</span><br><span style="color: hsl(0, 100%, 40%);">-     msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0x0F);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Then wrap these as a Sequence */</span><br><span style="color: hsl(0, 100%, 40%);">-     msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* Pre-pend the operation code */</span><br><span style="color: hsl(0, 100%, 40%);">-       msgb_push_TLV1(msg, GSM0480_OPERATION_CODE,</span><br><span style="color: hsl(0, 100%, 40%);">-                     GSM0480_OP_CODE_PROCESS_USS_REQ);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Wrap the operation code and IA5 string as a sequence */</span><br><span style="color: hsl(0, 100%, 40%);">-      msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* Pre-pend the invoke ID */</span><br><span style="color: hsl(0, 100%, 40%);">-    msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Wrap this up as a Return Result component */</span><br><span style="color: hsl(0, 100%, 40%);">- msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_RESULT);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Wrap the component in a Facility message */</span><br><span style="color: hsl(0, 100%, 40%);">-  msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* And finally pre-pend the L3 header */</span><br><span style="color: hsl(0, 100%, 40%);">-        gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));</span><br><span style="color: hsl(0, 100%, 40%);">-  gh->proto_discr  = GSM48_PDISC_NC_SS;</span><br><span style="color: hsl(0, 100%, 40%);">-        gh->proto_discr |= transaction_id << 4;</span><br><span style="color: hsl(0, 100%, 40%);">-        gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       return msc_tx_dtap(conn, msg);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*! Send a MT RELEASE COMPLETE message with ReturnError component</span><br><span style="color: hsl(0, 100%, 40%);">- *  (see section 3.6.1) and given error code (see section 3.6.6).</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  conn            Active subscriber connection</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  transaction_id  Transaction ID with TI flag set</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  invoke_id       InvokeID of the request</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in]  error_code      Error code (section 4.5)</span><br><span style="color: hsl(0, 100%, 40%);">- * \return     result of \ref msc_tx_dtap</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-int gsm0480_send_ussd_return_error(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(0, 100%, 40%);">- uint8_t transaction_id, uint8_t invoke_id, uint8_t error_code)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD ERR");</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gsm48_hdr *gh;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   /* First insert the problem code */</span><br><span style="color: hsl(0, 100%, 40%);">-     msgb_push_TLV1(msg, GSM_0480_ERROR_CODE_TAG, error_code);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Before it insert the invoke ID */</span><br><span style="color: hsl(0, 100%, 40%);">-    msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Wrap this up as a Reject component */</span><br><span style="color: hsl(0, 100%, 40%);">-        msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_ERROR);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* Wrap the component in a Facility message */</span><br><span style="color: hsl(0, 100%, 40%);">-  msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* And finally pre-pend the L3 header */</span><br><span style="color: hsl(0, 100%, 40%);">-        gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));</span><br><span style="color: hsl(0, 100%, 40%);">-  gh->proto_discr  = GSM48_PDISC_NC_SS;</span><br><span style="color: hsl(0, 100%, 40%);">-        gh->proto_discr |= transaction_id << 4;</span><br><span style="color: hsl(0, 100%, 40%);">-        gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       return msc_tx_dtap(conn, msg);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*! Send a MT RELEASE COMPLETE message with Reject component</span><br><span>  *  (see section 3.6.1) and given error code (see section 3.6.7).</span><br><span>  *</span><br><span>@@ -176,27 +56,16 @@</span><br><span>  * failed, any incorrect value can be passed (0x00 > x > 0xff), so</span><br><span>  * the universal NULL-tag (see table 3.6) will be used instead.</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(120, 100%, 40%);">+int msc_send_ussd_reject(struct gsm_subscriber_connection *conn,</span><br><span>                             uint8_t transaction_id, int invoke_id,</span><br><span>                       uint8_t problem_tag, uint8_t problem_code)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-    struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD REJ");</span><br><span>    struct gsm48_hdr *gh;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   /* First insert the problem code */</span><br><span style="color: hsl(0, 100%, 40%);">-     msgb_push_TLV1(msg, problem_tag, problem_code);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /**</span><br><span style="color: hsl(0, 100%, 40%);">-      * If the Invoke ID is not available, Universal Null</span><br><span style="color: hsl(0, 100%, 40%);">-     * (table 3.9) with length = 0 shall be used.</span><br><span style="color: hsl(0, 100%, 40%);">-    */</span><br><span style="color: hsl(0, 100%, 40%);">-     if (invoke_id < 0 || invoke_id > 255)</span><br><span style="color: hsl(0, 100%, 40%);">-             msgb_push_NULL(msg);</span><br><span style="color: hsl(0, 100%, 40%);">-    else</span><br><span style="color: hsl(0, 100%, 40%);">-            msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Wrap this up as a Reject component */</span><br><span style="color: hsl(0, 100%, 40%);">-        msgb_wrap_with_TL(msg, GSM0480_CTYPE_REJECT);</span><br><span style="color: hsl(120, 100%, 40%);">+ msg = gsm0480_gen_reject(invoke_id, problem_tag, problem_code);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (!msg)</span><br><span style="color: hsl(120, 100%, 40%);">+             return -1;</span><br><span> </span><br><span>       /* Wrap the component in a Facility message */</span><br><span>       msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);</span><br><span>diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c</span><br><span>index 9b0a9e4..01389af 100644</span><br><span>--- a/src/libmsc/gsm_09_11.c</span><br><span>+++ b/src/libmsc/gsm_09_11.c</span><br><span>@@ -34,6 +34,9 @@</span><br><span> #include <osmocom/core/rate_ctr.h></span><br><span> #include <osmocom/core/utils.h></span><br><span> #include <osmocom/core/msgb.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/protocol/gsm_04_80.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gsm0480.h></span><br><span> #include <osmocom/gsm/tlv.h></span><br><span> </span><br><span> #include <osmocom/msc/gsm_04_80.h></span><br><span>@@ -200,7 +203,7 @@</span><br><span> </span><br><span> error:</span><br><span>    /* Abort transaction on DTAP-interface */</span><br><span style="color: hsl(0, 100%, 40%);">-       gsm0480_send_ussd_reject(conn, tid, -1,</span><br><span style="color: hsl(120, 100%, 40%);">+       msc_send_ussd_reject(conn, tid, -1,</span><br><span>          GSM_0480_PROBLEM_CODE_TAG_GENERAL,</span><br><span>           GSM_0480_GEN_PROB_CODE_UNRECOGNISED);</span><br><span>        if (trans)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10327">change 10327</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/10327"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I2990d8627bce0ce6afb1dcf6b11bb194292380d3 </div>
<div style="display:none"> Gerrit-Change-Number: 10327 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>