summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2014-04-14 14:45:16 +0400
committerIvan Kluchnikov <kluchnikovi@gmail.com>2014-05-06 15:40:30 +0400
commit68be1aa3d637e5870cb1ea06ef47b5fb4774e063 (patch)
tree55ebe0ae69b7536599d9ea21b5c40756ae919c74
parente9ae4559ca7c4d0914050cdada279d7afa04deb4 (diff)
nitb: Add ctrl commands to get paging counters, state of oml link and SMS queue status
-rw-r--r--openbsc/include/openbsc/sms_queue.h4
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c87
-rw-r--r--openbsc/src/libmsc/sms_queue.c12
3 files changed, 103 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/sms_queue.h b/openbsc/include/openbsc/sms_queue.h
index 2a8bd5850..8bb540dda 100644
--- a/openbsc/include/openbsc/sms_queue.h
+++ b/openbsc/include/openbsc/sms_queue.h
@@ -4,10 +4,14 @@
struct gsm_network;
struct gsm_sms_queue;
struct vty;
+struct ctrl_cmd;
int sms_queue_start(struct gsm_network *, int in_flight);
int sms_queue_trigger(struct gsm_sms_queue *);
+/* Ctrl interface helper function */
+int sms_queue_pending_stat(struct gsm_network *net, struct ctrl_cmd *cmd);
+
/* vty helper functions */
int sms_queue_stats(struct gsm_sms_queue *, struct vty* vty);
int sms_queue_set_max_pending(struct gsm_sms_queue *, int max);
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index e55dd82ae..aecd6cf5c 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -24,6 +24,7 @@
#include <openbsc/gsm_data.h>
#include <openbsc/abis_nm.h>
#include <openbsc/chan_alloc.h>
+#include <openbsc/sms_queue.h>
#include <openbsc/debug.h>
#define CTRL_CMD_VTY_STRING(cmdname, cmdstr, dtype, element) \
@@ -376,6 +377,89 @@ static int get_net_lchan(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_lchan, "lchan");
+CTRL_HELPER_VERIFY_STATUS(net_paging);
+CTRL_HELPER_SET_STATUS(net_paging);
+
+static int get_net_paging(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_network *net = cmd->node;
+ struct gsm_bts *bts;
+ int bts_nr;
+
+ if (!strcmp(cmd->variable,"paging"))
+ cmd->reply = talloc_strdup(cmd, "\n");
+
+ for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
+ bts = gsm_bts_num(net, bts_nr);
+ cmd->reply = talloc_asprintf_append(cmd->reply,
+ "paging.pending_requests.bts.%u,%u\n", bts_nr,
+ paging_pending_requests_nr(bts));
+ cmd->reply = talloc_asprintf_append(cmd->reply,
+ "paging.available_slots.bts.%u,%u\n", bts_nr,
+ bts->paging.available_slots);
+ }
+
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+
+ return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE(net_paging, "paging");
+
+
+CTRL_HELPER_VERIFY_STATUS(net_oml_link);
+CTRL_HELPER_SET_STATUS(net_oml_link);
+
+static int get_net_oml_link(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_network *net = cmd->node;
+ struct gsm_bts *bts;
+ int bts_nr;
+
+ if (!strcmp(cmd->variable,"oml_link"))
+ cmd->reply = talloc_strdup(cmd, "\n");
+
+ for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
+ bts = gsm_bts_num(net, bts_nr);
+ cmd->reply = talloc_asprintf_append(cmd->reply,
+ "oml_link.bts.%u,%u\n", bts_nr, bts->oml_link ? 1 : 0);
+ }
+
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+
+ return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE(net_oml_link, "oml_link");
+
+CTRL_HELPER_VERIFY_STATUS(net_smsqueue);
+CTRL_HELPER_SET_STATUS(net_smsqueue);
+
+static int get_net_smsqueue(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_network *net = cmd->node;
+
+ if (!strcmp(cmd->variable,"smsqueue"))
+ cmd->reply = talloc_strdup(cmd, "\n");
+
+ sms_queue_pending_stat(net, cmd);
+
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+
+ return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE(net_smsqueue, "smsqueue");
+
/* BTS related commands below here */
static int verify_bts_band(struct ctrl_cmd *cmd, const char *value, void *data)
{
@@ -460,6 +544,9 @@ int bsc_base_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc_mnc_apply);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_channels_load);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_lchan);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_paging);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_oml_link);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_smsqueue);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_band);
diff --git a/openbsc/src/libmsc/sms_queue.c b/openbsc/src/libmsc/sms_queue.c
index 536bfdd14..e63870146 100644
--- a/openbsc/src/libmsc/sms_queue.c
+++ b/openbsc/src/libmsc/sms_queue.c
@@ -40,6 +40,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/vty/vty.h>
+#include <openbsc/control_cmd.h>
/*
* One pending SMS that we wait for.
@@ -493,6 +494,17 @@ static int sms_sms_cb(unsigned int subsys, unsigned int signal,
return 0;
}
+/* Ctrl interface helper function */
+int sms_queue_pending_stat(struct gsm_network *net, struct ctrl_cmd *cmd)
+{
+ cmd->reply = talloc_asprintf_append(cmd->reply, "smsqueue.max_pending,%u\n",
+ net->sms_queue->max_pending);
+ cmd->reply = talloc_asprintf_append(cmd->reply, "smsqueue.pending,%u\n",
+ net->sms_queue->pending);
+
+ return 0;
+}
+
/* VTY helper functions */
int sms_queue_stats(struct gsm_sms_queue *smsq, struct vty *vty)
{