libmsc: fix: properly initialize the SGs server
It was observed that the SGs server is started before the actual VTY configuration is parsed. For example: sgs local-port 9999 local-ip 127.0.0.1 vlr-name vlr.example.net produces the following debug output: <0011> sgs_server.c:185 SGs socket bound to r=NULL<->l=0.0.0.0:29118 DLSS7 NOTICE <001e> osmo_ss7.c:1284 0: ASP Restart for server not implemented yet! DSGS NOTICE <0011> sgs_server.c:185 SGs socket bound to r=NULL<->l=0.0.0.0:9999 DSGS NOTICE <0011> sgs_server.c:185 SGs socket bound to r=NULL<->l=127.0.0.1:9999 DMNCC DEBUG <0004> msc_main.c:604 Using internal MNCC handler. The first startup is triggered by sgs_iface_init(), before reading the VTY configuration, so the logging style is different. The next two calls to sgs_server_open() are triggered during reading of the VTY configuration by cfg_sgs_local_port() and cfg_sgs_local_ip(). Let's avoid starting the SGs server three times, and do it once, after the VTY configuration is parsed. Also, keep the possibility to change the binding parameters at run-time. Change-Id: Ie0c31205ac48be7e50d0380a89833771b2708da4
This commit is contained in:
parent
1d802e2635
commit
81635d3400
|
@ -1258,8 +1258,6 @@ struct sgs_state *sgs_iface_init(void *ctx, struct gsm_network *network)
|
|||
return NULL;
|
||||
g_sgs = sgs;
|
||||
|
||||
sgs_server_open(sgs);
|
||||
|
||||
return sgs;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,11 @@ DEFUN(cfg_sgs_local_ip, cfg_sgs_local_ip_cmd,
|
|||
osmo_strlcpy(sgs->cfg.local_addr, argv[0], sizeof(sgs->cfg.local_addr));
|
||||
osmo_stream_srv_link_set_addr(sgs->srv_link, sgs->cfg.local_addr);
|
||||
|
||||
rc = sgs_server_open(sgs);
|
||||
if (rc < 0)
|
||||
return CMD_WARNING;
|
||||
if (vty->type != VTY_FILE) {
|
||||
rc = sgs_server_open(sgs);
|
||||
if (rc < 0)
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
@ -74,9 +76,11 @@ DEFUN(cfg_sgs_local_port, cfg_sgs_local_port_cmd,
|
|||
sgs->cfg.local_port = atoi(argv[0]);
|
||||
osmo_stream_srv_link_set_port(sgs->srv_link, sgs->cfg.local_port);
|
||||
|
||||
rc = sgs_server_open(sgs);
|
||||
if (rc < 0)
|
||||
return CMD_WARNING;
|
||||
if (vty->type != VTY_FILE) {
|
||||
rc = sgs_server_open(sgs);
|
||||
if (rc < 0)
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include <osmocom/sigtran/osmo_ss7.h>
|
||||
#include <osmocom/mgcp_client/mgcp_client.h>
|
||||
#include <osmocom/msc/sgs_iface.h>
|
||||
#include <osmocom/msc/sgs_server.h>
|
||||
|
||||
#ifdef BUILD_IU
|
||||
#include <osmocom/ranap/iu_client.h>
|
||||
|
@ -692,6 +693,11 @@ TODO: we probably want some of the _net_ ctrl commands from bsc_base_ctrl_cmds_i
|
|||
return 8;
|
||||
}
|
||||
|
||||
if (sgs_server_open(g_sgs)) {
|
||||
printf("Starting SGs server failed\n");
|
||||
return 9;
|
||||
}
|
||||
|
||||
#ifdef BUILD_IU
|
||||
/* Set up IuCS */
|
||||
ranap_iu_init(tall_msc_ctx, DRANAP, "OsmoMSC-IuCS", msc_network->iu.sccp, rcvmsg_iu_cs, rx_iu_event);
|
||||
|
|
Loading…
Reference in New Issue