aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-08-03 04:39:04 +0700
committerHarald Welte <laforge@gnumonks.org>2018-08-05 07:15:01 +0000
commit0622ef5308f1822c023d3d8312b621e3343bc7b9 (patch)
treef6212969090cddefdf93f0f0f05d58af36256477
parent096be50c8237cef5015349aad7502a208f54ce72 (diff)
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
-rw-r--r--include/osmocom/msc/gsm_04_80.h12
-rw-r--r--src/libmsc/gsm_04_80.c145
-rw-r--r--src/libmsc/gsm_09_11.c5
3 files changed, 13 insertions, 149 deletions
diff --git a/include/osmocom/msc/gsm_04_80.h b/include/osmocom/msc/gsm_04_80.h
index 7d630888f..c448c91d8 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 32e8e23e0..0adf0596e 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 @@ static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, uint8_t tag)
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 @@ int gsm0480_send_ussd_return_error(struct gsm_subscriber_connection *conn,
* 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 9b0a9e446..01389afb7 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 @@ int gsm0911_rcv_nc_ss(struct gsm_subscriber_connection *conn, struct msgb *msg)
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)