Stefan Sperling has submitted this change and it was merged. Change subject: Support control connection status query for a particular MSC. ......................................................................
Support control connection status query for a particular MSC. Add a new control command 'msc.N.connection_status' which can be used to query the connection status of a particular MSC with number N. Keep the old control command 'msc_connection_status', which always queries MSC 0, for backwards compatibility. Change-Id: Ibd41474a1be80e782b19ec337c856b5efc593fa8 Related: OS#2729 --- M include/osmocom/bsc/ctrl.h M src/libbsc/bsc_ctrl_lookup.c M src/osmo-bsc/osmo_bsc_ctrl.c 3 files changed, 53 insertions(+), 9 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/bsc/ctrl.h b/include/osmocom/bsc/ctrl.h index c5ac210..04ca2cb 100644 --- a/include/osmocom/bsc/ctrl.h +++ b/include/osmocom/bsc/ctrl.h @@ -1,4 +1,11 @@ #pragma once +#include <osmocom/ctrl/control_cmd.h> + struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, const char *bind_addr, uint16_t port); + +enum bsc_ctrl_node { + CTRL_NODE_MSC = _LAST_CTRL_NODE, + _LAST_CTRL_NODE_BSC +}; diff --git a/src/libbsc/bsc_ctrl_lookup.c b/src/libbsc/bsc_ctrl_lookup.c index d1d9b0a..38d1ba4 100644 --- a/src/libbsc/bsc_ctrl_lookup.c +++ b/src/libbsc/bsc_ctrl_lookup.c @@ -1,4 +1,4 @@ -/* SNMP-like status interface. Look-up of BTS/TRX +/* SNMP-like status interface. Look-up of BTS/TRX/MSC * * (C) 2010-2011 by Daniel Willmann <dan...@totalueberwachung.de> * (C) 2010-2011 by On-Waves @@ -25,12 +25,14 @@ #include <osmocom/vty/command.h> #include <osmocom/ctrl/control_if.h> +#include <osmocom/bsc/ctrl.h> #include <osmocom/bsc/debug.h> #include <osmocom/bsc/gsm_data.h> +#include <osmocom/bsc/bsc_msc_data.h> extern vector ctrl_node_vec; -/*! \brief control interface lookup function for bsc/bts gsm_data +/*! \brief control interface lookup function for bsc/bts/msc gsm_data * \param[in] data Private data passed to controlif_setup() * \param[in] vline Vector of the line holding the command string * \param[out] node_type type (CTRL_NODE_) that was determined @@ -44,6 +46,7 @@ struct gsm_bts *bts = NULL; struct gsm_bts_trx *trx = NULL; struct gsm_bts_trx_ts *ts = NULL; + struct bsc_msc_data *msc = NULL; char *token = vector_slot(vline, *i); long num; @@ -89,6 +92,18 @@ goto err_missing; *node_data = ts; *node_type = CTRL_NODE_TS; + } else if (!strcmp(token, "msc")) { + if (*node_type != CTRL_NODE_ROOT || !net) + goto err_missing; + (*i)++; + if (!ctrl_parse_get_num(vline, *i, &num)) + goto err_index; + + msc = osmo_msc_data_find(net, num); + if (!msc) + goto err_missing; + *node_data = msc; + *node_type = CTRL_NODE_MSC; } else return 0; @@ -102,6 +117,7 @@ struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, const char *bind_addr, uint16_t port) { - return ctrl_interface_setup_dynip(net, bind_addr, port, - bsc_ctrl_node_lookup); + return ctrl_interface_setup_dynip2(net, bind_addr, port, + bsc_ctrl_node_lookup, + _LAST_CTRL_NODE_BSC); } diff --git a/src/osmo-bsc/osmo_bsc_ctrl.c b/src/osmo-bsc/osmo_bsc_ctrl.c index 4460288..fc79086 100644 --- a/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/src/osmo-bsc/osmo_bsc_ctrl.c @@ -19,6 +19,7 @@ */ #include <osmocom/ctrl/control_cmd.h> +#include <osmocom/bsc/ctrl.h> #include <osmocom/bsc/debug.h> #include <osmocom/bsc/gsm_data.h> #include <osmocom/bsc/osmo_bsc.h> @@ -57,10 +58,27 @@ talloc_free(trap); } -CTRL_CMD_DEFINE_RO(msc_connection_status, "msc_connection_status"); -static int msc_connection_status = 0; - +CTRL_CMD_DEFINE_RO(msc_connection_status, "connection_status"); static int get_msc_connection_status(struct ctrl_cmd *cmd, void *data) +{ + struct bsc_msc_data *msc = (struct bsc_msc_data *)cmd->node; + if (msc == NULL) { + cmd->reply = "msc not found"; + return CTRL_CMD_ERROR; + } + + if (msc->msc_con->is_connected) + cmd->reply = "connected"; + else + cmd->reply = "disconnected"; + return CTRL_CMD_REPLY; +} + +/* Backwards compat. */ +CTRL_CMD_DEFINE_RO(msc0_connection_status, "msc_connection_status"); +static int msc_connection_status = 0; /* XXX unused */ + +static int get_msc0_connection_status(struct ctrl_cmd *cmd, void *data) { struct gsm_network *gsmnet = data; struct bsc_msc_data *msc = osmo_msc_data_find(gsmnet, 0); @@ -96,7 +114,7 @@ cmd->id = "0"; cmd->variable = "msc_connection_status"; - get_msc_connection_status(cmd, NULL); + get_msc0_connection_status(cmd, NULL); ctrl_cmd_send_to_all(gsmnet->ctrl, cmd); @@ -627,7 +645,10 @@ rc = ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_timezone); if (rc) goto end; - rc = ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_msc_connection_status); + rc = ctrl_cmd_install(CTRL_NODE_MSC, &cmd_msc_connection_status); + if (rc) + goto end; + rc = ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_msc0_connection_status); if (rc) goto end; rc = osmo_signal_register_handler(SS_MSC, &msc_connection_status_trap_cb, net); -- To view, visit https://gerrit.osmocom.org/5630 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibd41474a1be80e782b19ec337c856b5efc593fa8 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de> Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max <msur...@sysmocom.de> Gerrit-Reviewer: Neels Hofmeyr <nhofm...@sysmocom.de> Gerrit-Reviewer: Stefan Sperling <ssperl...@sysmocom.de>