diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2021-03-21 17:12:08 +0100 |
---|---|---|
committer | lynxis lazus <lynxis@fe80.eu> | 2021-03-24 15:42:45 +0000 |
commit | 27e5873c8d7b63912fd93b68cd58659f980975f5 (patch) | |
tree | 7518aaa15eeca84e0a1f236ad6b29d67d2cf2c64 /src | |
parent | 1dd9cbf45e7ff0b63f0accda54c497845b1d628a (diff) |
gprs_ns2: add vty command `nsvc <nsvci> reset`
Change-Id: I436dd0367e83548acfc8f8e36ae4707496a252d9
Diffstat (limited to 'src')
-rw-r--r-- | src/gb/gprs_ns2_internal.h | 1 | ||||
-rw-r--r-- | src/gb/gprs_ns2_vc_fsm.c | 20 | ||||
-rw-r--r-- | src/gb/gprs_ns2_vty.c | 9 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h index 6cfef444..8e4ba9e0 100644 --- a/src/gb/gprs_ns2_internal.h +++ b/src/gb/gprs_ns2_internal.h @@ -395,6 +395,7 @@ int ns2_vc_rx(struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp) int ns2_vc_is_alive(struct gprs_ns2_vc *nsvc); int ns2_vc_is_unblocked(struct gprs_ns2_vc *nsvc); int ns2_vc_block(struct gprs_ns2_vc *nsvc); +int ns2_vc_reset(struct gprs_ns2_vc *nsvc); int ns2_vc_unblock(struct gprs_ns2_vc *nsvc); void ns2_vty_dump_nsvc(struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats); diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c index c64f60d0..ad8d4dbf 100644 --- a/src/gb/gprs_ns2_vc_fsm.c +++ b/src/gb/gprs_ns2_vc_fsm.c @@ -115,6 +115,7 @@ enum gprs_ns2_vc_event { GPRS_NS2_EV_RX_UNITDATA, GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED, /* called via vty for tests */ + GPRS_NS2_EV_REQ_OM_RESET, /* vty cmd: reset */ GPRS_NS2_EV_REQ_OM_BLOCK, /* vty cmd: block */ GPRS_NS2_EV_REQ_OM_UNBLOCK, /* vty cmd: unblock*/ }; @@ -132,6 +133,7 @@ static const struct value_string ns2_vc_event_names[] = { { GPRS_NS2_EV_RX_STATUS, "RX-STATUS" }, { GPRS_NS2_EV_RX_UNITDATA, "RX-UNITDATA" }, { GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED, "REQ-FORCE_UNCONFIGURED" }, + { GPRS_NS2_EV_REQ_OM_RESET, "REQ-O&M-RESET"}, { GPRS_NS2_EV_REQ_OM_BLOCK, "REQ-O&M-BLOCK"}, { GPRS_NS2_EV_REQ_OM_UNBLOCK, "REQ-O&M-UNBLOCK"}, { 0, NULL } @@ -611,6 +613,15 @@ static void ns2_vc_fsm_allstate_action(struct osmo_fsm_inst *fi, struct msgb *msg = data; switch (event) { + case GPRS_NS2_EV_REQ_OM_RESET: + if (priv->nsvc->mode != GPRS_NS2_VC_MODE_BLOCKRESET) + break; + /* move the FSM into reset */ + if (fi->state != GPRS_NS2_ST_RESET) { + priv->initiate_reset = true; + osmo_fsm_inst_state_chg(fi, GPRS_NS2_ST_RESET, nsi->timeout[NS_TOUT_TNS_RESET], NS_TOUT_TNS_RESET); + } + break; case GPRS_NS2_EV_RX_RESET: if (priv->nsvc->mode != GPRS_NS2_VC_MODE_BLOCKRESET) break; @@ -710,6 +721,7 @@ static struct osmo_fsm ns2_vc_fsm = { S(GPRS_NS2_EV_RX_ALIVE) | S(GPRS_NS2_EV_RX_ALIVE_ACK) | S(GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED) | + S(GPRS_NS2_EV_REQ_OM_RESET) | S(GPRS_NS2_EV_REQ_OM_BLOCK) | S(GPRS_NS2_EV_REQ_OM_UNBLOCK), .allstate_action = ns2_vc_fsm_allstate_action, @@ -783,6 +795,14 @@ int ns2_vc_unblock(struct gprs_ns2_vc *nsvc) return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, NULL); } +/*! Reset a NS-VC. + * \param nsvc the virtual circuit + * \return 0 on success; negative on error */ +int ns2_vc_reset(struct gprs_ns2_vc *nsvc) +{ + return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_RESET, NULL); +} + /*! entry point for messages from the driver/VL * \param nsvc virtual circuit on which the message was received * \param msg message that was received diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index 68a14c25..fc060ae3 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -2035,11 +2035,12 @@ DEFUN_HIDDEN(nsvc_force_unconf, nsvc_force_unconf_cmd, } DEFUN(nsvc_block, nsvc_block_cmd, - "nsvc <0-65535> (block|unblock)", + "nsvc <0-65535> (block|unblock|reset)", "NS Virtual Connection\n" NSVCI_STR "Block a NSVC. As cause code O&M intervention will be used.\n" - "Unblock a NSVC. As cause code O&M intervention will be used.\n") + "Unblock a NSVC. As cause code O&M intervention will be used.\n" + "Reset a NSVC. As cause code O&M intervention will be used.\n") { struct gprs_ns2_inst *nsi = vty_nsi; struct gprs_ns2_vc *nsvc; @@ -2054,8 +2055,10 @@ DEFUN(nsvc_block, nsvc_block_cmd, if (!strcmp(argv[1], "block")) { ns2_vc_block(nsvc); - } else { + } else if (!strcmp(argv[1], "unblock")) { ns2_vc_unblock(nsvc); + } else { + ns2_vc_reset(nsvc); } return CMD_SUCCESS; |