[PATCH] openbsc[master]: move to libxsc: factor out gen of USSD notify and release co...

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Oct 21 00:01:11 UTC 2016


Review at  https://gerrit.osmocom.org/1129

move to libxsc: factor out gen of USSD notify and release complete -- TODO subscr_conn

Both libmsc and libbsc need distinct gsm0480_send_ussdNotify() and
gsm0480_send_releaseComplete() functions to account for the distinct subscriber
connection structs.

The current functions live in libmsc, so add the same in libbsc in new file
gsm_04_80_utils.c.

To avoid too much code dup, move the message generation part of
gsm0480_send_ussdNotify() and gsm0480_send_releaseComplete() to new functions
gsm0480_gen_ussdNotify() and gsm0480_gen_releaseComplete(), placed in libxsc.

Change-Id: I33a84e3c28576ced91d2ea24103123431f551173
---
M openbsc/include/openbsc/gsm_04_80.h
M openbsc/src/libbsc/Makefile.am
A openbsc/src/libbsc/gsm_04_80_utils.c
M openbsc/src/libmsc/gsm_04_80.c
M openbsc/src/libmsc/vty_interface_layer3.c
M openbsc/src/libxsc/xsc.c
M openbsc/src/osmo-bsc/osmo_bsc_api.c
M openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
M openbsc/src/osmo-bsc/osmo_bsc_filter.c
M openbsc/src/osmo-bsc/osmo_bsc_grace.c
M openbsc/src/osmo-bsc/osmo_bsc_sccp.c
11 files changed, 106 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/29/1129/1

diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h
index 0a60652..3682c89 100644
--- a/openbsc/include/openbsc/gsm_04_80.h
+++ b/openbsc/include/openbsc/gsm_04_80.h
@@ -14,7 +14,16 @@
 			     const struct msgb *msg, 
 			     const struct ussd_request *request);
 
-int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text);
-int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
+struct msgb *gsm0480_gen_ussdNotify(int level, const char *text);
+struct msgb *gsm0480_gen_releaseComplete(void);
+
+int msc_gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn,
+				int level, const char *text);
+int msc_gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
+
+/* TODO: move to a bsc_*.h file? */
+int bsc_gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn,
+				int level, const char *text);
+int bsc_gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
 
 #endif
diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am
index 4728e23..28f556a 100644
--- a/openbsc/src/libbsc/Makefile.am
+++ b/openbsc/src/libbsc/Makefile.am
@@ -41,6 +41,7 @@
 	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 \
@@ -50,4 +51,3 @@
 	net_init.c \
 	bsc_dyn_ts.c \
 	$(NULL)
-
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 0000000..c96259d
--- /dev/null
+++ b/openbsc/src/libbsc/gsm_04_80_utils.c
@@ -0,0 +1,40 @@
+/* OpenBSC utility functions for 3GPP TS 04.80 */
+
+/* (C) 2016 by sysmocom s.m.f.c. GmbH <info at 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 bsc_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 bsc_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 f1d75f2..b8d950f 100644
--- a/openbsc/src/libmsc/gsm_04_80.c
+++ b/openbsc/src/libmsc/gsm_04_80.c
@@ -138,38 +138,18 @@
 	return gsm0808_submit_dtap(conn, msg, 0, 0);
 }
 
-int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text)
+int msc_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)
+int msc_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/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 6f0006c..956302e 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -473,8 +473,8 @@
 		return CMD_WARNING;
 	}
 
-	gsm0480_send_ussdNotify(conn, level, text);
-	gsm0480_send_releaseComplete(conn);
+	msc_gsm0480_send_ussdNotify(conn, level, text);
+	msc_gsm0480_send_releaseComplete(conn);
 
 	subscr_put(subscr);
 	talloc_free(text);
diff --git a/openbsc/src/libxsc/xsc.c b/openbsc/src/libxsc/xsc.c
index 138be11..04bc53e 100644
--- a/openbsc/src/libxsc/xsc.c
+++ b/openbsc/src/libxsc/xsc.c
@@ -113,3 +113,39 @@
 	gh->data[0] = cause;
 	return msg;
 }
+
+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;
+}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c
index d31e6c1..e759805 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_api.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c
@@ -205,8 +205,8 @@
 	gsm48_tx_mm_serv_ack(conn);
 
 	LOGP(DMSC, LOGL_INFO, "Sending USSD message: '%s'\n", text);
-	gsm0480_send_ussdNotify(conn, 1, text);
-	gsm0480_send_releaseComplete(conn);
+	bsc_gsm0480_send_ussdNotify(conn, 1, text);
+	bsc_gsm0480_send_releaseComplete(conn);
 }
 
 /*
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index 3010b55..84b7b92 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -598,8 +598,8 @@
 		 * the release complete when we get a returnResultLast
 		 * for this invoke id.
 		 */
-		gsm0480_send_releaseComplete(conn);
-		gsm0480_send_ussdNotify(conn, alert, text_str);
+		bsc_gsm0480_send_releaseComplete(conn);
+		bsc_gsm0480_send_ussdNotify(conn, alert, text_str);
 		cmd->reply = "Found a connection";
 		break;
 	}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c
index 14e0b71..8fc899e 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c
@@ -246,8 +246,9 @@
 
 int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn)
 {
-	gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_welcome_txt);
-	gsm0480_send_releaseComplete(conn);
+	bsc_gsm0480_send_ussdNotify(conn, 1,
+				    conn->sccp_con->msc->ussd_welcome_txt);
+	bsc_gsm0480_send_releaseComplete(conn);
 
 	return 0;
 }
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c
index e6194ab..c1d7c6a 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c
@@ -112,8 +112,8 @@
 	if (lchan->state != LCHAN_S_ACTIVE)
 		return -1;
 
-	gsm0480_send_ussdNotify(conn, 0, text);
-	gsm0480_send_releaseComplete(conn);
+	bsc_gsm0480_send_ussdNotify(conn, 0, text);
+	bsc_gsm0480_send_releaseComplete(conn);
 
 	return 0;
 }
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
index 86b27be..fa060da 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
@@ -285,8 +285,9 @@
 		return;
 
 	/* send USSD notification */
-	gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_msc_lost_txt);
-	gsm0480_send_releaseComplete(conn);
+	bsc_gsm0480_send_ussdNotify(conn, 1,
+				    conn->sccp_con->msc->ussd_msc_lost_txt);
+	bsc_gsm0480_send_releaseComplete(conn);
 }
 
 static void bsc_notify_and_close_conns(struct bsc_msc_connection *msc_con)

-- 
To view, visit https://gerrit.osmocom.org/1129
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I33a84e3c28576ced91d2ea24103123431f551173
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list