diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2021-03-21 17:28:36 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2021-04-07 16:25:35 +0000 |
commit | e7dfeac8dcb3c665a9082bf2011fca59ad4805d1 (patch) | |
tree | 6a58c1f1dd46e3f30667ee5b4e6b55d4f000b809 /src | |
parent | 53e70090492ed69311cd2d721ffcbf5618274f8b (diff) |
gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|reset)
The vty wasn't printing anything to the user if it was a success or not
Change-Id: Idbb83ea319bbdc94177febdd66e79c49fce7fdd2
Diffstat (limited to 'src')
-rw-r--r-- | src/gb/gprs_ns2_vc_fsm.c | 8 | ||||
-rw-r--r-- | src/gb/gprs_ns2_vty.c | 28 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c index 85cd2add..9a6bfc23 100644 --- a/src/gb/gprs_ns2_vc_fsm.c +++ b/src/gb/gprs_ns2_vc_fsm.c @@ -784,6 +784,10 @@ int ns2_vc_force_unconfigured(struct gprs_ns2_vc *nsvc) * \return 0 on success; negative on error */ int ns2_vc_block(struct gprs_ns2_vc *nsvc) { + struct gprs_ns2_vc_priv *priv = nsvc->fi->priv; + if (priv->initiate_block) + return -EALREADY; + return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_BLOCK, NULL); } @@ -792,6 +796,10 @@ int ns2_vc_block(struct gprs_ns2_vc *nsvc) * \return 0 on success; negative on error */ int ns2_vc_unblock(struct gprs_ns2_vc *nsvc) { + struct gprs_ns2_vc_priv *priv = nsvc->fi->priv; + if (!priv->initiate_block) + return -EALREADY; + return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, NULL); } diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index fc060ae3..b678db48 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -2044,6 +2044,7 @@ DEFUN(nsvc_block, nsvc_block_cmd, { struct gprs_ns2_inst *nsi = vty_nsi; struct gprs_ns2_vc *nsvc; + int rc; uint16_t id = atoi(argv[0]); @@ -2054,11 +2055,34 @@ DEFUN(nsvc_block, nsvc_block_cmd, } if (!strcmp(argv[1], "block")) { - ns2_vc_block(nsvc); + rc = ns2_vc_block(nsvc); + switch (rc) { + case 0: + vty_out(vty, "The NS-VC %05u will be blocked.%s", id, VTY_NEWLINE); + return CMD_SUCCESS; + case -EALREADY: + vty_out(vty, "The NS-VC %05u is already blocked.%s", id, VTY_NEWLINE); + return CMD_ERR_NOTHING_TODO; + default: + vty_out(vty, "An unknown error %d happend on NS-VC %05u.%s", rc, id, VTY_NEWLINE); + return CMD_WARNING; + } } else if (!strcmp(argv[1], "unblock")) { - ns2_vc_unblock(nsvc); + rc = ns2_vc_unblock(nsvc); + switch (rc) { + case 0: + vty_out(vty, "The NS-VC %05u will be unblocked.%s", id, VTY_NEWLINE); + return CMD_SUCCESS; + case -EALREADY: + vty_out(vty, "The NS-VC %05u is already unblocked.%s", id, VTY_NEWLINE); + return CMD_ERR_NOTHING_TODO; + default: + vty_out(vty, "An unknown error %d happend on NS-VC %05u.%s", rc, id, VTY_NEWLINE); + return CMD_WARNING; + } } else { ns2_vc_reset(nsvc); + vty_out(vty, "The NS-VC %05u has been resetted.%s", id, VTY_NEWLINE); } return CMD_SUCCESS; |