[5/9] libmsc: Create a separate SUP socket for USSD MAP

Submitted by Sergey Kostanbaev on April 22, 2016, 12:41 p.m.

Details

Message ID 1461328898-8298-5-git-send-email-sergey.kostanbaev@gmail.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Sergey Kostanbaev April 22, 2016, 12:41 p.m.
From: Sergey Kostanbaev <Sergey.Kostanbaev@fairwaves.co>

---
 openbsc/include/openbsc/gsm_data.h        |  1 +
 openbsc/src/libmsc/vty_interface_layer3.c | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

Patch hide | download patch | download mbox

diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 6d7aba3..5800df7 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -244,6 +244,7 @@  struct gsm_network {
 	struct llist_head upqueue;
 	struct llist_head trans_list;
 	struct bsc_api *bsc_api;
+	struct gprs_gsup_client *ussd_sup_client;
 
 	unsigned int num_bts;
 	struct llist_head bts_list;
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 790fedf..1a5b518 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -48,6 +48,8 @@ 
 #include <openbsc/sms_queue.h>
 #include <openbsc/mncc_int.h>
 #include <openbsc/handover.h>
+#include <openbsc/gprs_gsup_client.h>
+#include <openbsc/gsm_ussd_map.h>
 
 #include <osmocom/vty/logging.h>
 
@@ -993,6 +995,30 @@  DEFUN(meas_feed_scenario, meas_feed_scenario_cmd,
 	return CMD_SUCCESS;
 }
 
+DEFUN(sup_ussd_destination, sup_ussd_destination_cmd,
+	"sup-ussd destination ADDR <0-65535>",
+	"Enable SUP USSD socket to a given address/port" "destination\n" "address or hostname\n" "port number\n")
+{
+	struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+
+	if (gsmnet->ussd_sup_client) {
+		LOGP(DMM, LOGL_FATAL, "Can't create two USSD SUP clients\n");
+		vty_out(vty, "%%USSD SUP client already configured%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	gsmnet->ussd_sup_client = gprs_gsup_client_create(
+		argv[0], atoi(argv[1]), &ussd_map_read_cb);
+	if (!gsmnet->ussd_sup_client) {
+		LOGP(DMM, LOGL_FATAL, "Cannot set up USSD SUP socket\n");
+		vty_out(vty, "%%Cannot set up USSD SUP socket%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	gsmnet->ussd_sup_client->data = gsmnet;
+	return CMD_SUCCESS;
+}
+
 
 DEFUN(logging_fltr_imsi,
       logging_fltr_imsi_cmd,
@@ -1130,6 +1156,7 @@  int bsc_vty_init_extra(void)
 	install_element(NITB_NODE, &cfg_nitb_no_subscr_create_cmd);
 	install_element(NITB_NODE, &cfg_nitb_assign_tmsi_cmd);
 	install_element(NITB_NODE, &cfg_nitb_no_assign_tmsi_cmd);
+	install_element(NITB_NODE, &sup_ussd_destination_cmd);
 
 	return 0;
 }