From ef1e5870082d4e4f671c7a6db75345b364ad2cc3 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 3 May 2011 22:44:39 +0200 Subject: msc: bail out if subscriber VTY command fails This patch adds several messages that would be displayed if: * the Ki argument is missing. * you pass an invalid Ki. * the database fails to perform the operation (add/delete/update). Before this patch, no messages were spotted on this errors. I noticed this while adding Ki to the existing subscribers in the nanoBTS setup: I introduced a wrong Ki but the VTY command line did not report any error. A quick look at the database via sqlite command confirmed that the new authkey information was not added. --- openbsc/src/libmsc/vty_interface_layer3.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'openbsc/src/libmsc/vty_interface_layer3.c') diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 2d3dd146b..6ac2c65c3 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -575,6 +575,8 @@ DEFUN(ena_subscr_a3a8, } else { /* Unknown method */ subscr_put(subscr); + vty_out(vty, "%% Unknown auth method %s%s", + alg_str, VTY_NEWLINE); return CMD_WARNING; } @@ -582,6 +584,8 @@ DEFUN(ena_subscr_a3a8, rc = hexparse(ki_str, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki)); if ((rc > maxlen) || (rc < minlen)) { subscr_put(subscr); + vty_out(vty, "%% Wrong Ki `%s'%s", + ki_str, VTY_NEWLINE); return CMD_WARNING; } ainfo.a3a8_ki_len = rc; @@ -589,6 +593,7 @@ DEFUN(ena_subscr_a3a8, ainfo.a3a8_ki_len = 0; if (minlen) { subscr_put(subscr); + vty_out(vty, "%% Missing Ki argument%s", VTY_NEWLINE); return CMD_WARNING; } } @@ -601,7 +606,11 @@ DEFUN(ena_subscr_a3a8, db_sync_lastauthtuple_for_subscr(NULL, subscr); subscr_put(subscr); - return rc ? CMD_WARNING : CMD_SUCCESS; + if (rc) { + vty_out(vty, "%% Operation has failed%s", VTY_NEWLINE); + return CMD_WARNING; + } + return CMD_SUCCESS; } DEFUN(subscriber_purge, -- cgit v1.2.3