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
This commit is contained in:
Alexander Couzens 2021-03-21 17:28:36 +01:00 committed by laforge
parent 53e7009049
commit e7dfeac8dc
2 changed files with 34 additions and 2 deletions

View File

@ -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);
}

View File

@ -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;