summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-23 15:10:33 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-25 12:18:04 +0100
commit73828152d9472d5977a18491f2d9ca9b24077f43 (patch)
tree72d54bdd16bd2efa3f750825bff79771b7310fe7
parentfc7add20e1b54e1b0d10c7457629507fb62d7d31 (diff)
enable ctrl bind config for various programs
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.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h3
-rw-r--r--openbsc/include/openbsc/ctrl.h3
-rw-r--r--openbsc/include/openbsc/gprs_sgsn.h3
-rw-r--r--openbsc/src/gprs/sgsn_ctrl.c5
-rw-r--r--openbsc/src/gprs/sgsn_main.c31
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_lookup.c6
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c10
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c9
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c5
-rw-r--r--openbsc/src/osmo-nitb/bsc_hack.c10
10 files changed, 62 insertions, 23 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 027b6ded4..309adb1ba 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 38fa054db..c5ac21092 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 74f073597..49d5407f5 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 eff94e074..ccf507672 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 b10b0b37f..cb762b792 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 b504cccd5..a8a8cf526 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 3806b2473..3594a5b5a 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 04c12e33f..cdab4064d 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 f3ca92400..ec4243e8e 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 bfc1b7165..257fe3ede 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;