This time SMPP is included. Here is the abridged complete overview:
Following the previous patch sets for libosmo-abis and libosmocore, this patch set allows configuring ALL of osmo-nitb's local IP addresses and makes it possible to run several osmo-nitb processes alongside each other.
(1) Abis/IP (from the libosmo-abis patch) In the config file, have:
e1_input ipa bind 10.9.8.7
(2) telnet VTY (prepared by libosmocore patch set) In the config file, have:
line vty bind 10.9.8.7
(3) ctrl interface (prepared by libosmocore patch set) In the config file, have:
ctrl bind 10.9.8.7
(4) MNCC socket In addition to the old -m option with a fixed socket path, you may now supply a cmdline argument with explicit path:
-M /path/to/socket/file
(5) SMPP SMSC In the config file, have: smpp local-tcp 10.9.8.7 2775
Neels Hofmeyr (6): enable telnet VTY bind address config for various programs osmo-nitb: add -M to pass specific MNCC socket path osmo-nitb: cosmetic: rename to rf_ctrl_path, following mncc_sock_path osmo-nitb: be strict about cmdline args enable ctrl bind config for various programs smpp: refactor initialization, add bind address
openbsc/include/openbsc/bsc_nat.h | 3 +- openbsc/include/openbsc/ctrl.h | 3 +- openbsc/include/openbsc/gprs_sgsn.h | 3 +- openbsc/include/openbsc/mncc.h | 2 +- openbsc/include/openbsc/smpp.h | 4 +- openbsc/src/gprs/gb_proxy_main.c | 12 +++-- openbsc/src/gprs/gtphub_main.c | 11 ++-- openbsc/src/gprs/sgsn_ctrl.c | 5 +- openbsc/src/gprs/sgsn_main.c | 42 ++++++++++----- openbsc/src/libbsc/bsc_ctrl_lookup.c | 6 ++- openbsc/src/libbsc/bsc_init.c | 6 ++- openbsc/src/libmsc/mncc_sock.c | 9 ++-- openbsc/src/libmsc/smpp_openbsc.c | 43 +++++++++------ openbsc/src/libmsc/smpp_smsc.c | 93 ++++++++++++++++++++++++--------- openbsc/src/libmsc/smpp_smsc.h | 7 ++- openbsc/src/libmsc/smpp_vty.c | 75 +++++++++++++++++++++----- openbsc/src/osmo-bsc/osmo_bsc_main.c | 10 +++- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 6 ++- openbsc/src/osmo-bsc_nat/bsc_nat.c | 22 ++++++-- openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c | 5 +- openbsc/src/osmo-nitb/bsc_hack.c | 43 ++++++++++----- 21 files changed, 298 insertions(+), 112 deletions(-)
Following the 'line vty'/'bind A.B.C.D' command added in libosmocore, use the configured address to set the telnet bind for the VTY line. It is now possible to publish the VTY on a specific local interface (including 0.0.0.0 aka "any").
Implement in all of: osmo-gbproxy osmo-gtphub osmo-sgsn osmo-bsc osmo-bsc_nat osmo-bsc_mgcp osmo-nitb
In some of these main programs, move the telnet initialization below the configuration parsing.
Historically, this was not a good idea for programs using bsc_init.c (aka bsc_bootstrap_network()), since they expected a gsm_network struct pointer in ((struct telnet_connection*)vty->priv)->priv, so that telnet had to be either initialized or replaced by a dummy struct. In the meantime, the gsm_network struct is not actually looked up in a priv pointer but in the static bsc_vty.c scope (bsc_gsmnet), so this limitation is mere legacy (even though said legacy is still there in an "#if 0" chunk).
In the other binaries I have briefly looked at the init sequence dependencies and found no reason to initialize telnet above the config file parsing. In any case, I have tested every single one of abovementioned binaries to verify that they still parse the example config successfully and launch, allowing VTY connections on the configured address(es). I hope this suffices.
In all of the above, log VTY address and port. LOGL_INFO is disabled by default in some of the logging scopes, and since it is a single log message right at program launch, I decided for the slightly more aggressive LOGL_NOTICE. --- openbsc/src/gprs/gb_proxy_main.c | 12 ++++++++---- openbsc/src/gprs/gtphub_main.c | 11 ++++++++--- openbsc/src/gprs/sgsn_main.c | 11 ++++++++--- openbsc/src/libbsc/bsc_init.c | 6 +++++- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 6 +++++- openbsc/src/osmo-bsc_nat/bsc_nat.c | 13 +++++++++---- 6 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c index f82fb5b..0c3cfbe 100644 --- a/openbsc/src/gprs/gb_proxy_main.c +++ b/openbsc/src/gprs/gb_proxy_main.c @@ -252,10 +252,6 @@ int main(int argc, char **argv) rate_ctr_init(tall_bsc_ctx); osmo_stats_init(tall_bsc_ctx);
- rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_GBPROXY); - if (rc < 0) - exit(1); - bssgp_nsi = gprs_ns_instantiate(&proxy_ns_cb, tall_bsc_ctx); if (!bssgp_nsi) { LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n"); @@ -274,6 +270,14 @@ int main(int argc, char **argv) exit(2); }
+ /* start telnet after reading config for vty_get_bind_addr() */ + LOGP(DGPRS, LOGL_NOTICE, "VTY at %s %d\n", + vty_get_bind_addr(), OSMO_VTY_PORT_GBPROXY); + rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network, + vty_get_bind_addr(), OSMO_VTY_PORT_GBPROXY); + if (rc < 0) + exit(1); + if (!gprs_nsvc_by_nsei(gbcfg.nsi, gbcfg.nsip_sgsn_nsei)) { LOGP(DGPRS, LOGL_FATAL, "You cannot proxy to NSEI %u " "without creating that NSEI before\n", diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c index f18710d..89582b1 100644 --- a/openbsc/src/gprs/gtphub_main.c +++ b/openbsc/src/gprs/gtphub_main.c @@ -314,9 +314,6 @@ int main(int argc, char **argv) gtphub_vty_init(hub, cfg);
rate_ctr_init(osmo_gtphub_ctx); - rc = telnet_init(osmo_gtphub_ctx, 0, OSMO_VTY_PORT_GTPHUB); - if (rc < 0) - exit(1);
handle_options(ccfg, argc, argv);
@@ -327,6 +324,14 @@ int main(int argc, char **argv) exit(2); }
+ /* start telnet after reading config for vty_get_bind_addr() */ + LOGP(DGTPHUB, LOGL_NOTICE, "VTY at %s %d\n", + vty_get_bind_addr(), OSMO_VTY_PORT_GTPHUB); + rc = telnet_init_dynif(osmo_gtphub_ctx, 0, vty_get_bind_addr(), + OSMO_VTY_PORT_GTPHUB); + if (rc < 0) + exit(1); + if (gtphub_start(hub, cfg, next_restart_count(ccfg->restart_counter_file)) != 0) diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index 2d3a0e4..b10b0b3 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -315,9 +315,6 @@ int main(int argc, char **argv) handle_options(argc, argv);
rate_ctr_init(tall_bsc_ctx); - rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_SGSN); - if (rc < 0) - exit(1);
ctrl = sgsn_controlif_setup(NULL, OSMO_CTRL_PORT_SGSN); if (!ctrl) { @@ -357,6 +354,14 @@ int main(int argc, char **argv) exit(2); }
+ /* start telnet after reading config for vty_get_bind_addr() */ + LOGP(DGPRS, LOGL_NOTICE, "VTY at %s %d\n", + vty_get_bind_addr(), OSMO_VTY_PORT_SGSN); + rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network, + vty_get_bind_addr(), OSMO_VTY_PORT_SGSN); + if (rc < 0) + exit(1); + rc = sgsn_gtp_init(&sgsn_inst); if (rc) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on GTP socket\n"); diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index 743f4c1..859d999 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -495,7 +495,11 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), return rc; }
- rc = telnet_init(tall_bsc_ctx, bsc_gsmnet, OSMO_VTY_PORT_NITB_BSC); + /* start telnet after reading config for vty_get_bind_addr() */ + LOGP(DNM, LOGL_NOTICE, "VTY at %s %d\n", + vty_get_bind_addr(), OSMO_VTY_PORT_NITB_BSC); + rc = telnet_init_dynif(tall_bsc_ctx, bsc_gsmnet, vty_get_bind_addr(), + OSMO_VTY_PORT_NITB_BSC); if (rc < 0) return rc;
diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index d755c90..e226b02 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -232,7 +232,11 @@ int main(int argc, char **argv) if (rc < 0) return rc;
- rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_BSC_MGCP); + /* start telnet after reading config for vty_get_bind_addr() */ + LOGP(DMGCP, LOGL_NOTICE, "VTY at %s %d\n", + vty_get_bind_addr(), OSMO_VTY_PORT_BSC_MGCP); + rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network, + vty_get_bind_addr(), OSMO_VTY_PORT_BSC_MGCP); if (rc < 0) return rc;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 2d4f2a8..04c12e3 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1628,15 +1628,20 @@ int main(int argc, char **argv) osmo_stats_init(tall_bsc_ctx);
/* init vty and parse */ - if (telnet_init(tall_bsc_ctx, NULL, OSMO_VTY_PORT_BSC_NAT)) { - fprintf(stderr, "Creating VTY telnet line failed\n"); - return -5; - } if (mgcp_parse_config(config_file, nat->mgcp_cfg, MGCP_BSC_NAT) < 0) { fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); return -3; }
+ /* start telnet after reading config for vty_get_bind_addr() */ + LOGP(DNAT, LOGL_NOTICE, "VTY at %s %d\n", + vty_get_bind_addr(), OSMO_VTY_PORT_BSC_NAT); + if (telnet_init_dynif(tall_bsc_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_BSC_NAT)) { + fprintf(stderr, "Creating VTY telnet line failed\n"); + return -5; + } + /* over rule the VTY config for MSC IP */ if (msc_ip) bsc_nat_set_msc_ip(nat, msc_ip);
The old -m option without argument is still available and marked deprecated, to not make users' lives more difficult than necessary. --- openbsc/include/openbsc/mncc.h | 2 +- openbsc/src/libmsc/mncc_sock.c | 9 +++++---- openbsc/src/osmo-nitb/bsc_hack.c | 17 +++++++++++------ 3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h index 10192ad..49f0c8b 100644 --- a/openbsc/include/openbsc/mncc.h +++ b/openbsc/include/openbsc/mncc.h @@ -206,7 +206,7 @@ int int_mncc_recv(struct gsm_network *net, struct msgb *msg); /* input from CC code into mncc_sock */ int mncc_sock_from_cc(struct gsm_network *net, struct msgb *msg);
-int mncc_sock_init(struct gsm_network *gsmnet); +int mncc_sock_init(struct gsm_network *net, const char *sock_path);
#define mncc_is_data_frame(msg_type) \ (msg_type == GSM_TCHF_FRAME \ diff --git a/openbsc/src/libmsc/mncc_sock.c b/openbsc/src/libmsc/mncc_sock.c index dd0a44f..6da1c56 100644 --- a/openbsc/src/libmsc/mncc_sock.c +++ b/openbsc/src/libmsc/mncc_sock.c @@ -277,7 +277,7 @@ static int mncc_sock_accept(struct osmo_fd *bfd, unsigned int flags) }
-int mncc_sock_init(struct gsm_network *net) +int mncc_sock_init(struct gsm_network *net, const char *sock_path) { struct mncc_sock_state *state; struct osmo_fd *bfd; @@ -292,10 +292,10 @@ int mncc_sock_init(struct gsm_network *net)
bfd = &state->listen_bfd;
- rc = osmo_unixsock_listen(bfd, SOCK_SEQPACKET, "/tmp/bsc_mncc"); + rc = osmo_unixsock_listen(bfd, SOCK_SEQPACKET, sock_path); if (rc < 0) { - LOGP(DMNCC, LOGL_ERROR, "Could not create unix socket: %s\n", - strerror(errno)); + LOGP(DMNCC, LOGL_ERROR, "Could not create unix socket: %s: %s\n", + sock_path, strerror(errno)); talloc_free(state); return rc; } @@ -314,6 +314,7 @@ int mncc_sock_init(struct gsm_network *net)
net->mncc_state = state;
+ LOGP(DMNCC, LOGL_NOTICE, "MNCC socket at %s\n", sock_path); return 0; }
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 8b074f1..3c878a6 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -62,7 +62,7 @@ static const char *config_file = "openbsc.cfg"; static const char *rf_ctrl_name = NULL; extern const char *openbsc_copyright; static int daemonize = 0; -static int use_mncc_sock = 0; +static const char *mncc_sock_path = NULL; static int use_db_counter = 1;
/* timer to store statistics */ @@ -103,7 +103,8 @@ static void print_help() printf(" -V --version Print the version of OpenBSC.\n"); printf(" -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC.\n"); printf(" -e --log-level number Set a global loglevel.\n"); - printf(" -m --mncc-sock Disable built-in MNCC handler and offer socket.\n"); + printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n"); + printf(" -m --mncc-sock Same as `-M /tmp/bsc_mncc' (deprecated).\n"); printf(" -C --no-dbcounter Disable regular syncing of counters to database.\n"); printf(" -r --rf-ctl NAME A unix domain socket to listen for cmds.\n"); } @@ -126,12 +127,13 @@ static void handle_options(int argc, char **argv) {"rtp-proxy", 0, 0, 'P'}, {"log-level", 1, 0, 'e'}, {"mncc-sock", 0, 0, 'm'}, + {"mncc-sock-path", 1, 0, 'M'}, {"no-dbcounter", 0, 0, 'C'}, {"rf-ctl", 1, 0, 'r'}, {0, 0, 0, 0} };
- c = getopt_long(argc, argv, "hd:Dsl:ar:p:TPVc:e:mCr:", + c = getopt_long(argc, argv, "hd:Dsl:ar:p:TPVc:e:mCr:M:", long_options, &option_index); if (c == -1) break; @@ -168,8 +170,11 @@ static void handle_options(int argc, char **argv) case 'e': log_set_log_level(osmo_stderr_target, atoi(optarg)); break; + case 'M': + mncc_sock_path = optarg; + break; case 'm': - use_mncc_sock = 1; + mncc_sock_path = "/tmp/bsc_mncc"; break; case 'C': use_db_counter = 0; @@ -275,10 +280,10 @@ int main(int argc, char **argv) handle_options(argc, argv);
/* internal MNCC handler or MNCC socket? */ - if (use_mncc_sock) { + if (mncc_sock_path) { rc = bsc_bootstrap_network(mncc_sock_from_cc, config_file); if (rc >= 0) - mncc_sock_init(bsc_gsmnet); + mncc_sock_init(bsc_gsmnet, mncc_sock_path); } else rc = bsc_bootstrap_network(int_mncc_recv, config_file); if (rc < 0)
Strictly speaking, the unix domain socket location is not a name but a path. The MNCC socket is called path, so it is confusing to call the ctrl socket a 'name'. --- openbsc/src/osmo-nitb/bsc_hack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 3c878a6..a89300a 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -59,7 +59,7 @@ struct gsm_network *bsc_gsmnet = 0; static const char *database_name = "hlr.sqlite3"; static const char *config_file = "openbsc.cfg"; -static const char *rf_ctrl_name = NULL; +static const char *rf_ctrl_path = NULL; extern const char *openbsc_copyright; static int daemonize = 0; static const char *mncc_sock_path = NULL; @@ -106,7 +106,7 @@ static void print_help() printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n"); printf(" -m --mncc-sock Same as `-M /tmp/bsc_mncc' (deprecated).\n"); printf(" -C --no-dbcounter Disable regular syncing of counters to database.\n"); - printf(" -r --rf-ctl NAME A unix domain socket to listen for cmds.\n"); + printf(" -r --rf-ctl PATH A unix domain socket to listen for cmds.\n"); }
static void handle_options(int argc, char **argv) @@ -184,7 +184,7 @@ static void handle_options(int argc, char **argv) exit(0); break; case 'r': - rf_ctrl_name = optarg; + rf_ctrl_path = optarg; break; default: /* ignore */ @@ -312,7 +312,7 @@ int main(int argc, char **argv) /* seed the PRNG */ srand(time(NULL));
- bsc_gsmnet->bsc_data->rf_ctrl = osmo_bsc_rf_create(rf_ctrl_name, bsc_gsmnet); + bsc_gsmnet->bsc_data->rf_ctrl = osmo_bsc_rf_create(rf_ctrl_path, bsc_gsmnet); if (!bsc_gsmnet->bsc_data->rf_ctrl) { fprintf(stderr, "Failed to create the RF service.\n"); exit(1);
Abort upon unknown options and missing option arguments. This came to my attention while rewiring the -m and -M options: passing -M without argument would launch nitb with wrong configuration. So, rather exit immediately.
If there are legacy options that should be ignored, they deserve an own 'case:' in the option switch. There are none that I'm aware of though. --- openbsc/src/osmo-nitb/bsc_hack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index a89300a..6f8da98 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -187,7 +187,9 @@ static void handle_options(int argc, char **argv) rf_ctrl_path = optarg; break; default: - /* ignore */ + /* catch unknown options *as well as* missing arguments. */ + fprintf(stderr, "Error in command line options. Abort.\n"); + exit(-1); break; } }
Add ctrl_vty_init() calls and feed the ctrl_vty_get_bind_addr() return value to ctrl_interface_setup() in the following programs:
osmo-bsc osmo-bsc_nat osmo-nitb osmo-sgsn
For osmo-sgsn, move the control interface setup invocation below the config parsing, so that the ctrl_vty_get_bind_addr() can return the configured address. --- openbsc/include/openbsc/bsc_nat.h | 3 ++- openbsc/include/openbsc/ctrl.h | 3 ++- openbsc/include/openbsc/gprs_sgsn.h | 3 ++- openbsc/src/gprs/sgsn_ctrl.c | 5 +++-- openbsc/src/gprs/sgsn_main.c | 31 ++++++++++++++++++++----------- openbsc/src/libbsc/bsc_ctrl_lookup.c | 6 ++++-- openbsc/src/osmo-bsc/osmo_bsc_main.c | 10 +++++++++- openbsc/src/osmo-bsc_nat/bsc_nat.c | 9 ++++++++- openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c | 5 +++-- openbsc/src/osmo-nitb/bsc_hack.c | 10 +++++++++- 10 files changed, 62 insertions(+), 23 deletions(-)
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 027b6de..309adb1 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -423,7 +423,8 @@ void bsc_nat_num_rewr_entry_adapt(void *ctx, struct llist_head *head, const stru void bsc_nat_send_mgcp_to_msc(struct bsc_nat *bsc_nat, struct msgb *msg); void bsc_nat_handle_mgcp(struct bsc_nat *bsc, struct msgb *msg);
-struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, int port); +struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, + const char *bind_addr, int port); void bsc_nat_ctrl_del_pending(struct bsc_cmd_list *pending); int bsc_nat_handle_ctrlif_msg(struct bsc_connection *bsc, struct msgb *msg);
diff --git a/openbsc/include/openbsc/ctrl.h b/openbsc/include/openbsc/ctrl.h index 38fa054..c5ac210 100644 --- a/openbsc/include/openbsc/ctrl.h +++ b/openbsc/include/openbsc/ctrl.h @@ -1,3 +1,4 @@ #pragma once
-struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, uint16_t port); +struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, + const char *bind_addr, uint16_t port); diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 74f0735..49d5407 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -315,7 +315,8 @@ int sgsn_force_reattach_oldmsg(struct msgb *oldmsg); * ctrl interface related work */ struct gsm_network; -struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *, uint16_t port); +struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *, + const char *bind_addr, uint16_t port); int sgsn_ctrl_cmds_install(void);
/* diff --git a/openbsc/src/gprs/sgsn_ctrl.c b/openbsc/src/gprs/sgsn_ctrl.c index eff94e0..ccf5076 100644 --- a/openbsc/src/gprs/sgsn_ctrl.c +++ b/openbsc/src/gprs/sgsn_ctrl.c @@ -73,7 +73,8 @@ int sgsn_ctrl_cmds_install(void) return rc; }
-struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net, uint16_t port) +struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net, + const char *bind_addr, uint16_t port) { - return ctrl_interface_setup(net, port, NULL); + return ctrl_interface_setup_dynip(net, bind_addr, port, NULL); } diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index b10b0b3..cb762b7 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -47,6 +47,8 @@ #include <osmocom/vty/stats.h> #include <osmocom/vty/ports.h>
+#include <osmocom/ctrl/control_vty.h> + #include <openbsc/signal.h> #include <openbsc/debug.h> #include <openbsc/vty.h> @@ -311,22 +313,12 @@ int main(int argc, char **argv) logging_vty_add_cmds(&gprs_log_info); osmo_stats_vty_add_cmds(&gprs_log_info); sgsn_vty_init(); + ctrl_vty_init(tall_bsc_ctx);
handle_options(argc, argv);
rate_ctr_init(tall_bsc_ctx);
- ctrl = sgsn_controlif_setup(NULL, OSMO_CTRL_PORT_SGSN); - if (!ctrl) { - LOGP(DGPRS, LOGL_ERROR, "Failed to create CTRL interface.\n"); - exit(1); - } - - if (sgsn_ctrl_cmds_install() != 0) { - LOGP(DGPRS, LOGL_ERROR, "Failed to install CTRL commands.\n"); - exit(1); - } - gprs_ns_set_log_ss(DNS); bssgp_set_log_ss(DBSSGP);
@@ -362,6 +354,23 @@ int main(int argc, char **argv) if (rc < 0) exit(1);
+ /* start control interface after reading config for + * ctrl_vty_get_bind_addr() */ + LOGP(DGPRS, LOGL_NOTICE, "CTRL at %s %d\n", + ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_SGSN); + ctrl = sgsn_controlif_setup(NULL, ctrl_vty_get_bind_addr(), + OSMO_CTRL_PORT_SGSN); + if (!ctrl) { + LOGP(DGPRS, LOGL_ERROR, "Failed to create CTRL interface.\n"); + exit(1); + } + + if (sgsn_ctrl_cmds_install() != 0) { + LOGP(DGPRS, LOGL_ERROR, "Failed to install CTRL commands.\n"); + exit(1); + } + + rc = sgsn_gtp_init(&sgsn_inst); if (rc) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on GTP socket\n"); diff --git a/openbsc/src/libbsc/bsc_ctrl_lookup.c b/openbsc/src/libbsc/bsc_ctrl_lookup.c index b504ccc..a8a8cf5 100644 --- a/openbsc/src/libbsc/bsc_ctrl_lookup.c +++ b/openbsc/src/libbsc/bsc_ctrl_lookup.c @@ -99,7 +99,9 @@ err_index: return -ERANGE; }
-struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, uint16_t port) +struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, + const char *bind_addr, uint16_t port) { - return ctrl_interface_setup(net, port, bsc_ctrl_node_lookup); + return ctrl_interface_setup_dynip(net, bind_addr, port, + bsc_ctrl_node_lookup); } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 3806b24..3594a5b 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -32,6 +32,7 @@ #include <osmocom/ctrl/control_cmd.h> #include <osmocom/ctrl/control_if.h> #include <osmocom/ctrl/ports.h> +#include <osmocom/ctrl/control_vty.h>
#include <osmocom/core/application.h> #include <osmocom/core/linuxlist.h> @@ -205,6 +206,7 @@ int main(int argc, char **argv) vty_init(&vty_info); bsc_vty_init(&log_info); bsc_msg_lst_vty_init(tall_bsc_ctx, &access_lists, BSC_NODE); + ctrl_vty_init(tall_bsc_ctx);
INIT_LLIST_HEAD(&access_lists);
@@ -225,7 +227,13 @@ int main(int argc, char **argv) } bsc_api_init(bsc_gsmnet, osmo_bsc_api());
- bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet, OSMO_CTRL_PORT_NITB_BSC); + /* start control interface after reading config for + * ctrl_vty_get_bind_addr() */ + LOGP(DNM, LOGL_NOTICE, "CTRL at %s %d\n", + ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_NITB_BSC); + bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet, + ctrl_vty_get_bind_addr(), + OSMO_CTRL_PORT_NITB_BSC); if (!bsc_gsmnet->ctrl) { fprintf(stderr, "Failed to init the control interface. Exiting.\n"); exit(1); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 04c12e3..cdab406 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -52,6 +52,7 @@ #include <osmocom/ctrl/control_cmd.h> #include <osmocom/ctrl/control_if.h> #include <osmocom/ctrl/ports.h> +#include <osmocom/ctrl/control_vty.h>
#include <osmocom/crypt/auth.h>
@@ -1618,6 +1619,7 @@ int main(int argc, char **argv) logging_vty_add_cmds(&log_info); osmo_stats_vty_add_cmds(&log_info); bsc_nat_vty_init(nat); + ctrl_vty_init(tall_bsc_ctx);
/* parse options */ @@ -1664,7 +1666,12 @@ int main(int argc, char **argv) exit(1); }
- nat->ctrl = bsc_nat_controlif_setup(nat, OSMO_CTRL_PORT_BSC_NAT); + /* start control interface after reading config for + * ctrl_vty_get_bind_addr() */ + LOGP(DNAT, LOGL_NOTICE, "CTRL at %s %d\n", + ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_BSC_NAT); + nat->ctrl = bsc_nat_controlif_setup(nat, ctrl_vty_get_bind_addr(), + OSMO_CTRL_PORT_BSC_NAT); if (!nat->ctrl) { fprintf(stderr, "Creating the control interface failed.\n"); exit(1); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c index f3ca924..ec4243e 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c @@ -470,13 +470,14 @@ static int get_net_save_cmd(struct ctrl_cmd *cmd, void *data) return CTRL_CMD_ERROR; }
-struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, int port) +struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, + const char *bind_addr, int port) { struct ctrl_handle *ctrl; int rc;
- ctrl = bsc_controlif_setup(NULL, OSMO_CTRL_PORT_BSC_NAT); + ctrl = bsc_controlif_setup(NULL, bind_addr, OSMO_CTRL_PORT_BSC_NAT); if (!ctrl) { fprintf(stderr, "Failed to initialize the control interface. Exiting.\n"); return NULL; diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 6f8da98..4bd03fc 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -49,6 +49,7 @@ #include <openbsc/rrlp.h> #include <osmocom/ctrl/control_if.h> #include <osmocom/ctrl/ports.h> +#include <osmocom/ctrl/control_vty.h> #include <openbsc/ctrl.h> #include <openbsc/osmo_bsc_rf.h> #include <openbsc/smpp.h> @@ -272,6 +273,7 @@ int main(int argc, char **argv) /* This needs to precede handle_options() */ vty_init(&vty_info); bsc_vty_init(&log_info); + ctrl_vty_init(tall_bsc_ctx);
#ifdef BUILD_SMPP if (smpp_openbsc_init(tall_bsc_ctx, 0) < 0) @@ -295,7 +297,13 @@ int main(int argc, char **argv) #endif bsc_api_init(bsc_gsmnet, msc_bsc_api());
- bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet, OSMO_CTRL_PORT_NITB_BSC); + /* start control interface after reading config for + * ctrl_vty_get_bind_addr() */ + LOGP(DNM, LOGL_NOTICE, "CTRL at %s %d\n", + ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_NITB_BSC); + bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet, + ctrl_vty_get_bind_addr(), + OSMO_CTRL_PORT_NITB_BSC); if (!bsc_gsmnet->ctrl) { printf("Failed to initialize control interface. Exiting.\n"); return -1;
Make the SMPP bind address configurable (used to be harcoded as "0.0.0.0").
Add VTY command
smpp local-tcp A.B.C.D <1-65535>
while keeping the old command 'local-tcp-port <1-65535>'. Both the old and the new command immediately change the SMPP listening address and port.
Add a LOGL_NOTICE log when the SMPP listening address and/or port change.
However, to be useful, this patch has to go somewhat further: refactor the initialization procedure, because it was impossible to run the VTY commands without an already established connection.
The SMPP initialization procedure was weird. It would first open a connection on the default port, and a subsequent VTY port reconfiguration while reading the config file would try to re-establish a connection on a different port. If that failed, smpp would switch back to the default port instead of failing the program launch as the user would expect. If anything else ran on port 2775, SMPP would thus refuse to launch despite the config file having a different port: the first bind would always happen on 0.0.0.0:2775. Change that.
In the VTY commands, merely store address and port if no fd is established yet.
Introduce several SMPP initialization stages:
* allocate struct and initialize pointers, * then read config file without immediately starting to listen, * and once the main program is ready, start listening.
After that, the VTY command behaves as before: try to re-establish the old connection if the newly supplied address and port don't work out. I'm not actually sure why this switch-back behavior is needed, but fair enough.
In detail, replace the function smpp_smsc_init() with the various steps smpp_smsc_alloc_init() -- prepare struct for VTY commands smpp_smsc_conf() -- set addr an port only, for reading the config file smpp_smsc_start() -- establish a first connection, for main() smpp_smsc_restart() -- switch running connection, for telnet VTY smpp_smsc_stop() -- tear down connection, used by _start() twice
And replace smpp_openbsc_init() smpp_openbsc_set_net() with smpp_openbsc_alloc_init() smpp_openbsc_start()
I'd have picked function names like "_bind"/"_unbind", but in the SMPP protocol there is also a bind/unbind process, so instead I chose the names "_start", "_restart" and "_stop".
The smsc struct used to be talloc'd outside of smpp_smsc_init(). Since the smsc code internally uses talloc anyway and employs the smsc struct as talloc context, I decided to enforce talloc allocation within smpp_smsc_alloc_init().
Be stricter about osmo_signal_register_handler() return codes. --- openbsc/include/openbsc/smpp.h | 4 +- openbsc/src/libmsc/smpp_openbsc.c | 43 +++++++++++------- openbsc/src/libmsc/smpp_smsc.c | 93 +++++++++++++++++++++++++++++---------- openbsc/src/libmsc/smpp_smsc.h | 7 ++- openbsc/src/libmsc/smpp_vty.c | 75 ++++++++++++++++++++++++++----- openbsc/src/osmo-nitb/bsc_hack.c | 4 +- 6 files changed, 169 insertions(+), 57 deletions(-)
diff --git a/openbsc/include/openbsc/smpp.h b/openbsc/include/openbsc/smpp.h index 9941cee..bcdac8f 100644 --- a/openbsc/include/openbsc/smpp.h +++ b/openbsc/include/openbsc/smpp.h @@ -1,4 +1,4 @@ #pragma once
-int smpp_openbsc_init(void *ctx, uint16_t port); -void smpp_openbsc_set_net(struct gsm_network *net); +int smpp_openbsc_alloc_init(void *ctx); +int smpp_openbsc_start(struct gsm_network *net); diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index a2fa0f4..0269f4b 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -569,27 +569,38 @@ struct smsc *smsc_from_vty(struct vty *v) return g_smsc; }
-/*! \brief Initialize the OpenBSC SMPP interface */ -int smpp_openbsc_init(void *ctx, uint16_t port) +/*! \brief Allocate the OpenBSC SMPP interface struct and init VTY. */ +int smpp_openbsc_alloc_init(void *ctx) +{ + g_smsc = smpp_smsc_alloc_init(ctx); + if (!g_smsc) { + LOGP(DSMPP, LOGL_FATAL, "Cannot allocate smsc struct\n"); + return -1; + } + return smpp_vty_init(); +} + +/*! \brief Launch the OpenBSC SMPP interface with the parameters set from VTY. + */ +int smpp_openbsc_start(struct gsm_network *net) { - struct smsc *smsc = talloc_zero(ctx, struct smsc); int rc; + g_smsc->priv = net;
- rc = smpp_smsc_init(smsc, port); + /* If a VTY configuration has taken place, the values have been stored + * in the smsc struct. Otherwise, use the defaults (NULL -> any, 0 -> + * default SMPP port, see smpp_smsc_bind()). */ + rc = smpp_smsc_start(g_smsc, g_smsc->bind_addr, g_smsc->listen_port); if (rc < 0) - talloc_free(smsc); - - osmo_signal_register_handler(SS_SMS, smpp_sms_cb, smsc); - osmo_signal_register_handler(SS_SUBSCR, smpp_subscr_cb, smsc); + return rc;
- g_smsc = smsc; - - smpp_vty_init(); + rc = osmo_signal_register_handler(SS_SMS, smpp_sms_cb, g_smsc); + if (rc < 0) + return rc; + rc = osmo_signal_register_handler(SS_SUBSCR, smpp_subscr_cb, g_smsc); + if (rc < 0) + return rc;
- return rc; + return 0; }
-void smpp_openbsc_set_net(struct gsm_network *net) -{ - g_smsc->priv = net; -} diff --git a/openbsc/src/libmsc/smpp_smsc.c b/openbsc/src/libmsc/smpp_smsc.c index c1ec22f..ef4277a 100644 --- a/openbsc/src/libmsc/smpp_smsc.c +++ b/openbsc/src/libmsc/smpp_smsc.c @@ -931,39 +931,84 @@ static int smsc_fd_cb(struct osmo_fd *ofd, unsigned int what) return link_accept_cb(ofd->data, rc, &sa, sa_len); }
-/*! \brief Initialize the SMSC-side SMPP implementation */ -int smpp_smsc_init(struct smsc *smsc, uint16_t port) +/*! \brief allocate and initialize an smsc struct from talloc context ctx. */ +struct smsc *smpp_smsc_alloc_init(void *ctx) +{ + struct smsc *smsc = talloc_zero(ctx, struct smsc); + + INIT_LLIST_HEAD(&smsc->esme_list); + INIT_LLIST_HEAD(&smsc->acl_list); + INIT_LLIST_HEAD(&smsc->route_list); + + smsc->listen_ofd.data = smsc; + smsc->listen_ofd.cb = smsc_fd_cb; + + return smsc; +} + +/*! \brief Set the SMPP address and port without binding. */ +int smpp_smsc_conf(struct smsc *smsc, const char *bind_addr, uint16_t port) +{ + talloc_free((void*)smsc->bind_addr); + smsc->bind_addr = NULL; + if (bind_addr) { + smsc->bind_addr = talloc_strdup(smsc, bind_addr); + if (!smsc->bind_addr) + return -ENOMEM; + } + smsc->listen_port = port; + return 0; +} + +/*! \brief Bind to given address and port and accept connections. + * \param[in] bind_addr Local IP address, may be NULL for any. + * \param[in] port TCP port number, may be 0 for default SMPP (2775). + */ +int smpp_smsc_start(struct smsc *smsc, const char *bind_addr, uint16_t port) { int rc;
/* default port for SMPP */ - if (port == 0) + if (!port) port = 2775;
- /* This will not work if we were to actually ever use FD 0 - * (stdin) for this ... */ - if (smsc->listen_ofd.fd <= 0) { - INIT_LLIST_HEAD(&smsc->esme_list); - INIT_LLIST_HEAD(&smsc->acl_list); - INIT_LLIST_HEAD(&smsc->route_list); - smsc->listen_ofd.data = smsc; - smsc->listen_ofd.cb = smsc_fd_cb; - } else { - close(smsc->listen_ofd.fd); - osmo_fd_unregister(&smsc->listen_ofd); - } + smpp_smsc_stop(smsc); + + LOGP(DSMPP, LOGL_NOTICE, "SMPP at %s %d\n", + bind_addr? bind_addr : "0.0.0.0", port);
rc = osmo_sock_init_ofd(&smsc->listen_ofd, AF_UNSPEC, SOCK_STREAM, - IPPROTO_TCP, NULL, port, + IPPROTO_TCP, bind_addr, port, OSMO_SOCK_F_BIND); + if (rc < 0) + return rc;
- /* if there is an error, try to re-bind to the old port */ - if (rc < 0) { - rc = osmo_sock_init_ofd(&smsc->listen_ofd, AF_UNSPEC, - SOCK_STREAM, IPPROTO_TCP, NULL, - smsc->listen_port, OSMO_SOCK_F_BIND); - } else - smsc->listen_port = port; - + /* store new address and port */ + rc = smpp_smsc_conf(smsc, bind_addr, port); + if (rc) + smpp_smsc_stop(smsc); return rc; } + +/*! \brief Change a running connection to a different address/port, and upon + * error switch back to the running configuration. */ +int smpp_smsc_restart(struct smsc *smsc, const char *bind_addr, uint16_t port) +{ + int rc; + + rc = smpp_smsc_start(smsc, bind_addr, port); + if (rc) + /* if there is an error, try to re-bind to the old port */ + return smpp_smsc_start(smsc, smsc->bind_addr, smsc->listen_port); + return 0; +} + +/*! /brief Close SMPP connection. */ +void smpp_smsc_stop(struct smsc *smsc) +{ + if (smsc->listen_ofd.fd > 0) { + close(smsc->listen_ofd.fd); + smsc->listen_ofd.fd = 0; + osmo_fd_unregister(&smsc->listen_ofd); + } +} diff --git a/openbsc/src/libmsc/smpp_smsc.h b/openbsc/src/libmsc/smpp_smsc.h index 3dd6562..bd20137 100644 --- a/openbsc/src/libmsc/smpp_smsc.h +++ b/openbsc/src/libmsc/smpp_smsc.h @@ -89,6 +89,7 @@ struct smsc { struct llist_head esme_list; struct llist_head acl_list; struct llist_head route_list; + const char *bind_addr; uint16_t listen_port; char system_id[SMPP_SYS_ID_LEN+1]; int accept_all; @@ -100,7 +101,11 @@ struct smsc { int smpp_addr_eq(const struct osmo_smpp_addr *a, const struct osmo_smpp_addr *b);
-int smpp_smsc_init(struct smsc *smsc, uint16_t port); +struct smsc *smpp_smsc_alloc_init(void *ctx); +int smpp_smsc_conf(struct smsc *smsc, const char *bind_addr, uint16_t port); +int smpp_smsc_start(struct smsc *smsc, const char *bind_addr, uint16_t port); +int smpp_smsc_restart(struct smsc *smsc, const char *bind_addr, uint16_t port); +void smpp_smsc_stop(struct smsc *smsc);
void smpp_esme_get(struct osmo_esme *esme); void smpp_esme_put(struct osmo_esme *esme); diff --git a/openbsc/src/libmsc/smpp_vty.c b/openbsc/src/libmsc/smpp_vty.c index c0695fe..5ab632f 100644 --- a/openbsc/src/libmsc/smpp_vty.c +++ b/openbsc/src/libmsc/smpp_vty.c @@ -76,31 +76,76 @@ DEFUN(cfg_no_smpp_first, cfg_no_smpp_first_cmd, return CMD_SUCCESS; }
-DEFUN(cfg_smpp_port, cfg_smpp_port_cmd, - "local-tcp-port <1-65535>", - "Set the local TCP port on which we listen for SMPP\n" - "TCP port number") +static int smpp_local_tcp(struct vty *vty, + const char *bind_addr, uint16_t port) { struct smsc *smsc = smsc_from_vty(vty); - uint16_t port = atoi(argv[0]); + int is_running = smsc->listen_ofd.fd > 0; + int same_bind_addr; int rc;
- rc = smpp_smsc_init(smsc, port); + /* If it is not up yet, don't rebind, just set values. */ + if (!is_running) { + rc = smpp_smsc_conf(smsc, bind_addr, port); + if (rc < 0) { + vty_out(vty, "%% Cannot configure new address:port%s", + VTY_NEWLINE); + return CMD_WARNING; + } + return CMD_SUCCESS; + } + + rc = smpp_smsc_restart(smsc, bind_addr, port); if (rc < 0) { - vty_out(vty, "%% Cannot bind to new port %u nor to " - "old port %u%s", port, smsc->listen_port, VTY_NEWLINE); + vty_out(vty, "%% Cannot bind to new port %s:%u nor to" + " old port %s:%u%s", + bind_addr? bind_addr : "0.0.0.0", + port, + smsc->bind_addr? smsc->bind_addr : "0.0.0.0", + smsc->listen_port, + VTY_NEWLINE); return CMD_WARNING; }
- if (port != smsc->listen_port) { - vty_out(vty, "%% Cannot bind to new port %u, staying on old" - "port %u%s", port, smsc->listen_port, VTY_NEWLINE); + same_bind_addr = (bind_addr == smsc->bind_addr) + || (bind_addr && smsc->bind_addr + && (strcmp(bind_addr, smsc->bind_addr) == 0)); + + if (!same_bind_addr || port != smsc->listen_port) { + vty_out(vty, "%% Cannot bind to new port %s:%u, staying on" + " old port %s:%u%s", + bind_addr? bind_addr : "0.0.0.0", + port, + smsc->bind_addr? smsc->bind_addr : "0.0.0.0", + smsc->listen_port, + VTY_NEWLINE); return CMD_WARNING; }
return CMD_SUCCESS; }
+DEFUN(cfg_smpp_port, cfg_smpp_port_cmd, + "local-tcp-port <1-65535>", + "Set the local TCP port on which we listen for SMPP\n" + "TCP port number") +{ + struct smsc *smsc = smsc_from_vty(vty); + uint16_t port = atoi(argv[0]); + return smpp_local_tcp(vty, smsc->bind_addr, port); +} + +DEFUN(cfg_smpp_addr_port, cfg_smpp_addr_port_cmd, + "local-tcp A.B.C.D <1-65535>", + "Set the local IP address and TCP port on which we listen for SMPP\n" + "Local IP address\n" + "TCP port number") +{ + const char *bind_addr = argv[0]; + uint16_t port = atoi(argv[1]); + return smpp_local_tcp(vty, bind_addr, port); +} + DEFUN(cfg_smpp_sys_id, cfg_smpp_sys_id_cmd, "system-id ID", "Set the System ID of this SMSC\n" @@ -138,7 +183,12 @@ static int config_write_smpp(struct vty *vty) struct smsc *smsc = smsc_from_vty(vty);
vty_out(vty, "smpp%s", VTY_NEWLINE); - vty_out(vty, " local-tcp-port %u%s", smsc->listen_port, VTY_NEWLINE); + if (smsc->bind_addr) + vty_out(vty, " local-tcp %s %u%s", smsc->bind_addr, + smsc->listen_port, VTY_NEWLINE); + else + vty_out(vty, " local-tcp-port %u%s", smsc->listen_port, + VTY_NEWLINE); if (strlen(smsc->system_id) > 0) vty_out(vty, " system-id %s%s", smsc->system_id, VTY_NEWLINE); vty_out(vty, " policy %s%s", @@ -535,6 +585,7 @@ int smpp_vty_init(void) install_element(SMPP_NODE, &cfg_smpp_first_cmd); install_element(SMPP_NODE, &cfg_no_smpp_first_cmd); install_element(SMPP_NODE, &cfg_smpp_port_cmd); + install_element(SMPP_NODE, &cfg_smpp_addr_port_cmd); install_element(SMPP_NODE, &cfg_smpp_sys_id_cmd); install_element(SMPP_NODE, &cfg_smpp_policy_cmd); install_element(SMPP_NODE, &cfg_esme_cmd); diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 4bd03fc..3bd73f4 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -276,7 +276,7 @@ int main(int argc, char **argv) ctrl_vty_init(tall_bsc_ctx);
#ifdef BUILD_SMPP - if (smpp_openbsc_init(tall_bsc_ctx, 0) < 0) + if (smpp_openbsc_alloc_init(tall_bsc_ctx) < 0) return -1; #endif
@@ -293,7 +293,7 @@ int main(int argc, char **argv) if (rc < 0) exit(1); #ifdef BUILD_SMPP - smpp_openbsc_set_net(bsc_gsmnet); + smpp_openbsc_start(bsc_gsmnet); #endif bsc_api_init(bsc_gsmnet, msc_bsc_api());