summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2014-04-15 14:02:12 +0400
committerIvan Kluchnikov <kluchnikovi@gmail.com>2014-05-06 15:40:30 +0400
commita57a325d0a340c746290f03f78f0313b74050495 (patch)
tree6c1f2e61fbaa00ca36786d5f8355ac9410b312f6
parent7f53932f6885a9877046053dce20418cda1d719d (diff)
nitb: Add ctrl command to get/set maximum amount of SMS delivery failuresfairwaves/ctrl-interface
-rw-r--r--openbsc/include/openbsc/sms_queue.h1
-rw-r--r--openbsc/src/libmsc/ctrl_commands.c34
-rw-r--r--openbsc/src/libmsc/sms_queue.c5
-rw-r--r--openbsc/tests/ctrl_test_runner.py15
4 files changed, 55 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/sms_queue.h b/openbsc/include/openbsc/sms_queue.h
index 8bb540dda..db91ec687 100644
--- a/openbsc/include/openbsc/sms_queue.h
+++ b/openbsc/include/openbsc/sms_queue.h
@@ -11,6 +11,7 @@ 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);
+int sms_queue_get_max_failure(struct gsm_sms_queue *smsq);
/* vty helper functions */
int sms_queue_stats(struct gsm_sms_queue *, struct vty* vty);
diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c
index 58558fd9f..5fc0e1184 100644
--- a/openbsc/src/libmsc/ctrl_commands.c
+++ b/openbsc/src/libmsc/ctrl_commands.c
@@ -21,6 +21,7 @@
#include <openbsc/control_cmd.h>
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_subscriber.h>
+#include <openbsc/sms_queue.h>
#include <openbsc/db.h>
#include <openbsc/debug.h>
@@ -168,6 +169,38 @@ static int get_subscriber_list(struct ctrl_cmd *cmd, void *d)
}
CTRL_CMD_DEFINE(subscriber_list, "subscriber-list-active-v1");
+static int verify_sms_queue_max_failure(struct ctrl_cmd *cmd, const char *value, void *d)
+{
+ int tmp = atoi(value);
+
+ if (tmp < 1 || tmp > 500) {
+ cmd->reply = "Value must be between 1 and 500";
+ return -1;
+ }
+
+ return 0;
+}
+
+static int get_sms_queue_max_failure(struct ctrl_cmd *cmd, void *d)
+{
+ struct gsm_network *net = cmd->node;
+ cmd->reply = talloc_asprintf(cmd, "%i", sms_queue_get_max_failure(net->sms_queue));
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+ return CTRL_CMD_REPLY;
+}
+
+static int set_sms_queue_max_failure(struct ctrl_cmd *cmd, void *d)
+{
+ struct gsm_network *net = cmd->node;
+ sms_queue_set_max_failure(net->sms_queue, atoi(cmd->value));
+ return get_sms_queue_max_failure(cmd, d);
+}
+
+CTRL_CMD_DEFINE(sms_queue_max_failure, "sms-queue-max-failure");
+
int msc_ctrl_cmds_install(void)
{
int rc = 0;
@@ -175,5 +208,6 @@ int msc_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_modify);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_delete);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_sms_queue_max_failure);
return rc;
}
diff --git a/openbsc/src/libmsc/sms_queue.c b/openbsc/src/libmsc/sms_queue.c
index e63870146..2edc42f02 100644
--- a/openbsc/src/libmsc/sms_queue.c
+++ b/openbsc/src/libmsc/sms_queue.c
@@ -505,6 +505,11 @@ int sms_queue_pending_stat(struct gsm_network *net, struct ctrl_cmd *cmd)
return 0;
}
+int sms_queue_get_max_failure(struct gsm_sms_queue *smsq)
+{
+ return smsq->max_fail;
+}
+
/* VTY helper functions */
int sms_queue_stats(struct gsm_sms_queue *smsq, struct vty *vty)
{
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index 0dc9800f0..1fe1adcbd 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -443,6 +443,21 @@ class TestCtrlNITB(TestCtrlBase):
self.assertEquals(r['var'], 'subscriber-list-active-v1')
self.assertEquals(r['value'], None)
+ def testSmsQueueMaxFailure(self):
+ r = self.do_get('sms-queue-max-failure')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'sms-queue-max-failure')
+ self.assertEquals(r['value'], '1')
+
+ r = self.do_set('sms-queue-max-failure', '5')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'sms-queue-max-failure')
+ self.assertEquals(r['value'], '5')
+
+ r = self.do_set('sms-queue-max-failure', '555')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Value must be between 1 and 500')
+
class TestCtrlNAT(TestCtrlBase):
def ctrl_command(self):