From 81c0e2582fd0688ccf479e67c6a6be488dcc3fd6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 25 Dec 2010 14:08:00 +0100 Subject: [PATCH] sms: Provide some simple vty command for the state of the SMS queue --- openbsc/include/openbsc/sms_queue.h | 4 ++++ openbsc/src/sms_queue.c | 16 ++++++++++++++++ openbsc/src/vty_interface_layer3.c | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/openbsc/include/openbsc/sms_queue.h b/openbsc/include/openbsc/sms_queue.h index d04856629..5bfa4b44c 100644 --- a/openbsc/include/openbsc/sms_queue.h +++ b/openbsc/include/openbsc/sms_queue.h @@ -3,8 +3,12 @@ struct gsm_network; struct gsm_sms_queue; +struct vty; int sms_queue_start(struct gsm_network *, int in_flight); int sms_queue_trigger(struct gsm_sms_queue *); +/* vty helper functions */ +int sms_queue_stats(struct gsm_sms_queue *, struct vty* vty); + #endif diff --git a/openbsc/src/sms_queue.c b/openbsc/src/sms_queue.c index f6d09cf76..ee4398751 100644 --- a/openbsc/src/sms_queue.c +++ b/openbsc/src/sms_queue.c @@ -40,6 +40,8 @@ #include +#include + /* * One pending SMS that we wait for. */ @@ -391,3 +393,17 @@ static int sms_sms_cb(unsigned int subsys, unsigned int signal, return 0; } + +/* VTY helper functions */ +int sms_queue_stats(struct gsm_sms_queue *smsq, struct vty *vty) +{ + struct gsm_sms_pending *pending; + + vty_out(vty, "SMSqueue with max_pending: %d pending: %d%s", + smsq->max_pending, smsq->pending, VTY_NEWLINE); + + llist_for_each_entry(pending, &smsq->pending_sms, entry) + vty_out(vty, " SMS Pending for Subscriber: %llu%s\n", + pending->subscr->id, VTY_NEWLINE); + return 0; +} diff --git a/openbsc/src/vty_interface_layer3.c b/openbsc/src/vty_interface_layer3.c index f1e537183..f9dd5860f 100644 --- a/openbsc/src/vty_interface_layer3.c +++ b/openbsc/src/vty_interface_layer3.c @@ -46,6 +46,7 @@ #include #include #include +#include extern struct gsm_network *gsmnet_from_vty(struct vty *v); @@ -633,6 +634,17 @@ DEFUN(show_stats, return CMD_SUCCESS; } +DEFUN(show_smsqueue, + show_smsqueue_cmd, + "show sms-queue", + SHOW_STR "Display SMSqueue statistics\n") +{ + struct gsm_network *net = gsmnet_from_vty(vty); + + sms_queue_stats(net->sms_queue, vty); + return CMD_SUCCESS; +} + int bsc_vty_init_extra(void) { @@ -650,6 +662,7 @@ int bsc_vty_init_extra(void) install_element_ve(&subscriber_ussd_notify_cmd); install_element_ve(&subscriber_update_cmd); install_element_ve(&show_stats_cmd); + install_element_ve(&show_smsqueue_cmd); install_element(ENABLE_NODE, &ena_subscr_name_cmd); install_element(ENABLE_NODE, &ena_subscr_extension_cmd);