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.
This commit is contained in:
parent
fc7add20e1
commit
73828152d9
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue