summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-04 15:29:56 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-04 15:34:18 +0100
commite4baf402cb457ad46642cec9271b762a394a59ea (patch)
treee390eab0c4bb81fd6728af306b3432ef08da91a5
parent53d782fc38c1c609cb5986fc07980651d3ed8916 (diff)
move two gsm0480_send_*() to xsc as gsm0480_gen_*()
Have two separate gsm0480_send_ussdNotify() and gsm0480_send_releaseComplete() for each of libbsc and libmsc. Move their core into libxsc as generator functions returning a msgb. Add src/libbsc/gsm_04_80_utils.c (note, not 04_08) to implement the libbsc side of it. The code is identical, but the linked structs and functions differ in each case. There could be a common source file built for both, but I decided against it, for more clarity I hope.
-rw-r--r--openbsc/include/openbsc/gsm_04_80.h3
-rw-r--r--openbsc/src/libbsc/Makefile.am1
-rw-r--r--openbsc/src/libbsc/gsm_04_80_utils.c39
-rw-r--r--openbsc/src/libmsc/gsm_04_80.c24
-rw-r--r--openbsc/src/libxsc/xsc.c39
5 files changed, 84 insertions, 22 deletions
diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h
index 0a6065234..23f20c463 100644
--- a/openbsc/include/openbsc/gsm_04_80.h
+++ b/openbsc/include/openbsc/gsm_04_80.h
@@ -14,6 +14,9 @@ int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
const struct msgb *msg,
const struct ussd_request *request);
+struct msgb *gsm0480_gen_ussdNotify(int level, const char *text);
+struct msgb *gsm0480_gen_releaseComplete(void);
+
int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text);
int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am
index 8fa5c7c1a..488de6d4c 100644
--- a/openbsc/src/libbsc/Makefile.am
+++ b/openbsc/src/libbsc/Makefile.am
@@ -20,6 +20,7 @@ libbsc_a_SOURCES = abis_nm.c abis_nm_vty.c \
e1_config.c \
bsc_api.c bsc_msc.c bsc_vty.c \
gsm_04_08_utils.c \
+ gsm_04_80_utils.c \
bsc_init.c bts_init.c bsc_rf_ctrl.c \
arfcn_range_encode.c bsc_ctrl_commands.c \
bsc_ctrl_lookup.c \
diff --git a/openbsc/src/libbsc/gsm_04_80_utils.c b/openbsc/src/libbsc/gsm_04_80_utils.c
new file mode 100644
index 000000000..ddd8caf7d
--- /dev/null
+++ b/openbsc/src/libbsc/gsm_04_80_utils.c
@@ -0,0 +1,39 @@
+/* OpenBSC utility functions for 3GPP TS 04.80 */
+
+/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <openbsc/gsm_04_80.h>
+#include <openbsc/bsc_api.h>
+
+int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text)
+{
+ struct msgb *msg = gsm0480_gen_ussdNotify(level, text);
+ if (!msg)
+ return -1;
+ return gsm0808_submit_dtap(conn, msg, 0, 0);
+}
+
+int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn)
+{
+ struct msgb *msg = gsm0480_gen_releaseComplete();
+ if (!msg)
+ return -1;
+ return gsm0808_submit_dtap(conn, msg, 0, 0);
+}
diff --git a/openbsc/src/libmsc/gsm_04_80.c b/openbsc/src/libmsc/gsm_04_80.c
index f1d75f20d..f1e1f273f 100644
--- a/openbsc/src/libmsc/gsm_04_80.c
+++ b/openbsc/src/libmsc/gsm_04_80.c
@@ -140,36 +140,16 @@ int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text)
{
- struct gsm48_hdr *gh;
- struct msgb *msg;
-
- msg = gsm0480_create_unstructuredSS_Notify(level, text);
+ struct msgb *msg = gsm0480_gen_ussdNotify(level, text);
if (!msg)
return -1;
-
- gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0);
- gsm0480_wrap_facility(msg);
-
- /* And finally pre-pend the L3 header */
- gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
- gh->proto_discr = GSM48_PDISC_NC_SS;
- gh->msg_type = GSM0480_MTYPE_REGISTER;
-
return gsm0808_submit_dtap(conn, msg, 0, 0);
}
int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn)
{
- struct gsm48_hdr *gh;
- struct msgb *msg;
-
- msg = gsm48_msgb_alloc_name("GSM 04.08 USSD REL COMPL");
+ struct msgb *msg = gsm0480_gen_releaseComplete();
if (!msg)
return -1;
-
- gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
- gh->proto_discr = GSM48_PDISC_NC_SS;
- gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
-
return gsm0808_submit_dtap(conn, msg, 0, 0);
}
diff --git a/openbsc/src/libxsc/xsc.c b/openbsc/src/libxsc/xsc.c
index d9c2c8328..d0915d680 100644
--- a/openbsc/src/libxsc/xsc.c
+++ b/openbsc/src/libxsc/xsc.c
@@ -30,6 +30,8 @@
/* FIXME parts of the gsm_network are BSC specific and don't belong here. */
+#include <osmocom/gsm/gsm0480.h>
+
#include <openbsc/gsm_data.h>
#include <openbsc/osmo_msc_data.h>
#include <openbsc/gsm_subscriber.h>
@@ -202,6 +204,43 @@ int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
}
+struct msgb *gsm0480_gen_ussdNotify(int level, const char *text)
+{
+ struct gsm48_hdr *gh;
+ struct msgb *msg;
+
+ msg = gsm0480_create_unstructuredSS_Notify(level, text);
+ if (!msg)
+ return NULL;
+
+ gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0);
+ gsm0480_wrap_facility(msg);
+
+ /* And finally pre-pend the L3 header */
+ gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
+ gh->proto_discr = GSM48_PDISC_NC_SS;
+ gh->msg_type = GSM0480_MTYPE_REGISTER;
+
+ return msg;
+}
+
+struct msgb *gsm0480_gen_releaseComplete(void)
+{
+ struct gsm48_hdr *gh;
+ struct msgb *msg;
+
+ msg = gsm48_msgb_alloc_name("GSM 04.08 USSD REL COMPL");
+ if (!msg)
+ return NULL;
+
+ gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
+ gh->proto_discr = GSM48_PDISC_NC_SS;
+ gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
+
+ return msg;
+}
+
+
/* Helpers for SMS/GSM 04.11 */
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_04_11.h>