aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-12-05 01:11:28 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-12-05 03:26:33 +0100
commit526813f4a761b9667b60fbe19d0b1afe2e39998c (patch)
treef2ca280656ff9bcf2e4b5fe481aec8b672ecc6f4
parentf7822e41960d388a84fa9b5248ee1a8f66c0a8c3 (diff)
add VTY commands: mncc internal / external (== -M)neels/mncc_path
So far the only way to use external MNCC is to pass the -M cmdline arg: osmo-msc -M /path/to/socket However, the osmo-msc.service file for systemd is installed by 'make install', and hence it is quite impractical to depend on such a config item to be required in the service file: - It defies any scheme an operator may have in place to compose the osmo-msc.cfg file -- this option doesn't go in the .cfg file but needs separate action to add to the installed service file. - After a make install or package upgrades / re-installations, this option will be plain overwritten silently, or lead to the need for resolving file conflicts. The initial spark for this came from configuring the 35c3 GSM from cfg templates. Change-Id: I2ec59d5eba407f83295528b51b93678d446b9cee
-rw-r--r--include/osmocom/msc/gsm_data.h1
-rw-r--r--include/osmocom/msc/msc_common.h1
-rw-r--r--src/libmsc/msc_vty.c23
-rw-r--r--src/libmsc/osmo_msc.c7
-rw-r--r--src/osmo-msc/msc_main.c13
-rw-r--r--tests/test_nodes.vty25
6 files changed, 68 insertions, 2 deletions
diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index d3cb7d8..63af3e7 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -140,6 +140,7 @@ struct gsm_network {
struct osmo_counter *active_nc_ss;
/* layer 4 */
+ char *mncc_sock_path;
struct mncc_sock_state *mncc_state;
mncc_recv_cb_t mncc_recv;
struct llist_head upqueue;
diff --git a/include/osmocom/msc/msc_common.h b/include/osmocom/msc/msc_common.h
index ffe8902..3ca3469 100644
--- a/include/osmocom/msc/msc_common.h
+++ b/include/osmocom/msc/msc_common.h
@@ -15,6 +15,7 @@ enum nsap_addr_enc {
typedef int (*mncc_recv_cb_t)(struct gsm_network *, struct msgb *);
struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv);
+void gsm_network_set_mncc_sock_path(struct gsm_network *net, const char *mncc_sock_path);
int msc_vlr_alloc(struct gsm_network *net);
int msc_vlr_start(struct gsm_network *net);
diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c
index d9e57a7..e1d1b40 100644
--- a/src/libmsc/msc_vty.c
+++ b/src/libmsc/msc_vty.c
@@ -339,6 +339,25 @@ DEFUN(cfg_msc, cfg_msc_cmd,
#define MNCC_GUARD_TIMEOUT_STR "Set global guard timer for mncc interface activity\n"
#define MNCC_GUARD_TIMEOUT_VALUE_STR "guard timer value (sec.)\n"
+DEFUN(cfg_msc_mncc_internal,
+ cfg_msc_mncc_internal_cmd,
+ "mncc internal",
+ MNCC_STR "Use internal MNCC handler (default; changes need a program restart)\n")
+{
+ gsm_network_set_mncc_sock_path(gsmnet, NULL);
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_msc_mncc_external,
+ cfg_msc_mncc_external_cmd,
+ "mncc external MNCC_SOCKET_PATH",
+ MNCC_STR "Use external MNCC handler (changes need a program restart)\n"
+ "File system path to create the MNCC unix domain socket at\n")
+{
+ gsm_network_set_mncc_sock_path(gsmnet, argv[0]);
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_msc_mncc_guard_timeout,
cfg_msc_mncc_guard_timeout_cmd,
"mncc guard-timeout <0-255>",
@@ -442,6 +461,8 @@ DEFUN(cfg_msc_emergency_msisdn, cfg_msc_emergency_msisdn_cmd,
static int config_write_msc(struct vty *vty)
{
vty_out(vty, "msc%s", VTY_NEWLINE);
+ if (gsmnet->mncc_sock_path)
+ vty_out(vty, " mncc external %s%s", gsmnet->mncc_sock_path, VTY_NEWLINE);
vty_out(vty, " mncc guard-timeout %i%s",
gsmnet->mncc_guard_timeout, VTY_NEWLINE);
vty_out(vty, " %sassign-tmsi%s",
@@ -1451,6 +1472,8 @@ void msc_vty_init(struct gsm_network *msc_network)
install_element(CONFIG_NODE, &cfg_msc_cmd);
install_node(&msc_node, config_write_msc);
install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd);
+ install_element(MSC_NODE, &cfg_msc_mncc_internal_cmd);
+ install_element(MSC_NODE, &cfg_msc_mncc_external_cmd);
install_element(MSC_NODE, &cfg_msc_mncc_guard_timeout_cmd);
install_element(MSC_NODE, &cfg_msc_deprecated_mncc_guard_timeout_cmd);
install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd);
diff --git a/src/libmsc/osmo_msc.c b/src/libmsc/osmo_msc.c
index 52277b7..37c1d15 100644
--- a/src/libmsc/osmo_msc.c
+++ b/src/libmsc/osmo_msc.c
@@ -76,6 +76,13 @@ struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv)
return net;
}
+void gsm_network_set_mncc_sock_path(struct gsm_network *net, const char *mncc_sock_path)
+{
+ if (net->mncc_sock_path)
+ talloc_free(net->mncc_sock_path);
+ net->mncc_sock_path = mncc_sock_path ? talloc_strdup(net, mncc_sock_path) : NULL;
+}
+
/* Receive a SAPI-N-REJECT from BSC */
void ran_conn_sapi_n_reject(struct ran_conn *conn, int dlci)
{
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 4434056..a192b64 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -573,11 +573,20 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialize MNCC socket if appropriate */
+ /* Initialize MNCC socket if appropriate. If the cmdline option -M is present, it overrides the .cfg file
+ * setting 'msc' / 'mncc external MNCC_SOCKET_PATH'. Note that when -M is given, it "bleeds" back into the vty
+ * 'write' command and is reflected in the written out 'mncc external' cfg. */
if (msc_cmdline_config.mncc_sock_path) {
+ LOGP(DMNCC, LOGL_NOTICE,
+ "MNCC socket path is configured from commandline argument -M."
+ " This affects a written-back config file. Instead consider using the config file directly"
+ " ('msc' / 'mncc external MNCC_SOCKET_PATH').\n");
+ gsm_network_set_mncc_sock_path(msc_network, msc_cmdline_config.mncc_sock_path);
+ }
+ if (msc_network->mncc_sock_path) {
msc_network->mncc_recv = mncc_sock_from_cc;
rc = mncc_sock_init(msc_network,
- msc_cmdline_config.mncc_sock_path);
+ msc_network->mncc_sock_path);
if (rc) {
fprintf(stderr, "MNCC socket initialization failed. exiting.\n");
exit(1);
diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index 6a55e1b..c6902da 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -30,6 +30,8 @@ OsmoMSC(config)# msc
OsmoMSC(config-msc)# list
...
assign-tmsi
+ mncc internal
+ mncc external MNCC_SOCKET_PATH
mncc guard-timeout <0-255>
no assign-tmsi
auth-tuple-max-reuse-count <-1-2147483647>
@@ -48,6 +50,29 @@ OsmoMSC(config-msc)# list
asn1 debug (1|0)
asn1 xer-print (1|0)
+OsmoMSC(config-msc)# mncc?
+ mncc Configure Mobile Network Call Control
+
+OsmoMSC(config-msc)# mncc ?
+ internal Use internal MNCC handler (default; changes need a program restart)
+ external Use external MNCC handler (changes need a program restart)
+ guard-timeout Set global guard timer for mncc interface activity
+
+OsmoMSC(config-msc)# mncc external ?
+ MNCC_SOCKET_PATH File system path to create the MNCC unix domain socket at
+
+OsmoMSC(config-msc)# mncc external /path/not/used
+OsmoMSC(config-msc)# show running-config
+...
+msc
+...
+ mncc external /path/not/used
+...
+
+OsmoMSC(config-msc)# mncc internal
+OsmoMSC(config-msc)# show running-config
+... ! mncc external
+
OsmoMSC(config-msc)# exit
OsmoMSC(config)# mncc-int
OsmoMSC(config-mncc-int)# list