Change in osmo-msc[master]: libmsc/gsm_09_11.c: clean up the local GSM 04.80 API

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Thu Aug 2 21:49:17 UTC 2018


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/10327


Change subject: libmsc/gsm_09_11.c: clean up the local GSM 04.80 API
......................................................................

libmsc/gsm_09_11.c: clean up the local GSM 04.80 API

Since we don't process SS/USSD requests in OsmoMSC anymore, there
are some useless GSM 04.80 functions remained from the past.

In particular, this change does the following:

  - removes both gsm0480_send_{ussd_response|return_error}
    functions because they are not used anymore;

  - changes symbol prefix from 'gsm0480_' to 'msc_', in order to
    avoid possible conflicts with the libosmogsm's GSM 04.80 API;

  - cleans up useless includes;

Change-Id: I2990d8627bce0ce6afb1dcf6b11bb194292380d3
---
M include/osmocom/msc/gsm_04_80.h
M src/libmsc/gsm_04_80.c
M src/libmsc/gsm_09_11.c
3 files changed, 13 insertions(+), 149 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/27/10327/1

diff --git a/include/osmocom/msc/gsm_04_80.h b/include/osmocom/msc/gsm_04_80.h
index 7d63088..c448c91 100644
--- a/include/osmocom/msc/gsm_04_80.h
+++ b/include/osmocom/msc/gsm_04_80.h
@@ -1,18 +1,10 @@
 #pragma once
 
-#include <osmocom/core/msgb.h>
-#include <osmocom/gsm/protocol/gsm_04_80.h>
-#include <osmocom/gsm/gsm0480.h>
+#include <stdint.h>
 
 struct gsm_subscriber_connection;
 
-int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
-			       uint8_t transaction_id, uint8_t invoke_id,
-			       const char *response_text);
-int gsm0480_send_ussd_return_error(struct gsm_subscriber_connection *conn,
-				   uint8_t transaction_id, uint8_t invoke_id,
-				   uint8_t error_code);
-int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
+int msc_send_ussd_reject(struct gsm_subscriber_connection *conn,
 			     uint8_t transaction_id, int invoke_id,
 			     uint8_t problem_tag, uint8_t problem_code);
 
diff --git a/src/libmsc/gsm_04_80.c b/src/libmsc/gsm_04_80.c
index 32e8e23..0adf059 100644
--- a/src/libmsc/gsm_04_80.c
+++ b/src/libmsc/gsm_04_80.c
@@ -22,20 +22,14 @@
  *
  */
 
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <stdint.h>
 #include <errno.h>
 
-#include <osmocom/msc/debug.h>
-#include <osmocom/msc/gsm_data.h>
-#include <osmocom/msc/gsm_04_08.h>
 #include <osmocom/msc/gsm_04_80.h>
 #include <osmocom/msc/msc_ifaces.h>
 
+#include <osmocom/gsm/protocol/gsm_04_80.h>
 #include <osmocom/gsm/gsm0480.h>
-#include <osmocom/gsm/gsm_utils.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/gsm/tlv.h>
 
@@ -48,120 +42,6 @@
 	return data;
 }
 
-static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag,
-					    uint8_t value)
-{
-	uint8_t *data = msgb_push(msgb, 3);
-
-	data[0] = tag;
-	data[1] = 1;
-	data[2] = value;
-	return data;
-}
-
-static inline unsigned char *msgb_push_NULL(struct msgb *msgb)
-{
-	uint8_t *data = msgb_push(msgb, 2);
-
-	data[0] = ASN1_NULL_TYPE_TAG;
-	data[1] = 0;
-	return data;
-}
-
-
-/*! Send a MT RELEASE COMPLETE message with USSD-response,
- *  wrapped into the ReturnResult component (see section 3.6.1).
- *
- * \param[in]  conn            Active subscriber connection
- * \param[in]  transaction_id  Transaction ID with TI flag set
- * \param[in]  invoke_id       InvokeID of the request
- * \param[in]  response_text   The response text
- * \return     result of \ref msc_tx_dtap
- */
-int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
-			       uint8_t transaction_id, uint8_t invoke_id,
-			       const char *response_text)
-{
-	struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD RSP");
-	struct gsm48_hdr *gh;
-	uint8_t *ptr8;
-	int response_len;
-
-	/* First put the payload text into the message */
-	ptr8 = msgb_put(msg, 0);
-	gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), response_text, &response_len);
-	msgb_put(msg, response_len);
-
-	/* Then wrap it as an Octet String */
-	msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);
-
-	/* Pre-pend the DCS octet string */
-	msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0x0F);
-
-	/* Then wrap these as a Sequence */
-	msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);
-
-	/* Pre-pend the operation code */
-	msgb_push_TLV1(msg, GSM0480_OPERATION_CODE,
-			GSM0480_OP_CODE_PROCESS_USS_REQ);
-
-	/* Wrap the operation code and IA5 string as a sequence */
-	msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);
-
-	/* Pre-pend the invoke ID */
-	msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);
-
-	/* Wrap this up as a Return Result component */
-	msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_RESULT);
-
-	/* Wrap the component in a Facility message */
-	msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
-
-	/* And finally pre-pend the L3 header */
-	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
-	gh->proto_discr  = GSM48_PDISC_NC_SS;
-	gh->proto_discr |= transaction_id << 4;
-	gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
-
-	return msc_tx_dtap(conn, msg);
-}
-
-/*! Send a MT RELEASE COMPLETE message with ReturnError component
- *  (see section 3.6.1) and given error code (see section 3.6.6).
- *
- * \param[in]  conn            Active subscriber connection
- * \param[in]  transaction_id  Transaction ID with TI flag set
- * \param[in]  invoke_id       InvokeID of the request
- * \param[in]  error_code      Error code (section 4.5)
- * \return     result of \ref msc_tx_dtap
- */
-int gsm0480_send_ussd_return_error(struct gsm_subscriber_connection *conn,
-	uint8_t transaction_id, uint8_t invoke_id, uint8_t error_code)
-{
-	struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD ERR");
-	struct gsm48_hdr *gh;
-
-	/* First insert the problem code */
-	msgb_push_TLV1(msg, GSM_0480_ERROR_CODE_TAG, error_code);
-
-	/* Before it insert the invoke ID */
-	msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);
-
-	/* Wrap this up as a Reject component */
-	msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_ERROR);
-
-	/* Wrap the component in a Facility message */
-	msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
-
-	/* And finally pre-pend the L3 header */
-	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
-	gh->proto_discr  = GSM48_PDISC_NC_SS;
-	gh->proto_discr |= transaction_id << 4;
-	gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
-
-	return msc_tx_dtap(conn, msg);
-}
-
 /*! Send a MT RELEASE COMPLETE message with Reject component
  *  (see section 3.6.1) and given error code (see section 3.6.7).
  *
@@ -176,27 +56,16 @@
  * failed, any incorrect value can be passed (0x00 > x > 0xff), so
  * the universal NULL-tag (see table 3.6) will be used instead.
  */
-int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
+int msc_send_ussd_reject(struct gsm_subscriber_connection *conn,
 			     uint8_t transaction_id, int invoke_id,
 			     uint8_t problem_tag, uint8_t problem_code)
 {
-	struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD REJ");
 	struct gsm48_hdr *gh;
+	struct msgb *msg;
 
-	/* First insert the problem code */
-	msgb_push_TLV1(msg, problem_tag, problem_code);
-
-	/**
-	 * If the Invoke ID is not available, Universal Null
-	 * (table 3.9) with length = 0 shall be used.
-	 */
-	if (invoke_id < 0 || invoke_id > 255)
-		msgb_push_NULL(msg);
-	else
-		msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);
-
-	/* Wrap this up as a Reject component */
-	msgb_wrap_with_TL(msg, GSM0480_CTYPE_REJECT);
+	msg = gsm0480_gen_reject(invoke_id, problem_tag, problem_code);
+	if (!msg)
+		return -1;
 
 	/* Wrap the component in a Facility message */
 	msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index 9b0a9e4..01389af 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -34,6 +34,9 @@
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
+
+#include <osmocom/gsm/protocol/gsm_04_80.h>
+#include <osmocom/gsm/gsm0480.h>
 #include <osmocom/gsm/tlv.h>
 
 #include <osmocom/msc/gsm_04_80.h>
@@ -200,7 +203,7 @@
 
 error:
 	/* Abort transaction on DTAP-interface */
-	gsm0480_send_ussd_reject(conn, tid, -1,
+	msc_send_ussd_reject(conn, tid, -1,
 		GSM_0480_PROBLEM_CODE_TAG_GENERAL,
 		GSM_0480_GEN_PROB_CODE_UNRECOGNISED);
 	if (trans)

-- 
To view, visit https://gerrit.osmocom.org/10327
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2990d8627bce0ce6afb1dcf6b11bb194292380d3
Gerrit-Change-Number: 10327
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180802/e9445a3d/attachment.htm>


More information about the gerrit-log mailing list