aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns2_vc_fsm.c
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2021-03-21 17:12:08 +0100
committerlynxis lazus <lynxis@fe80.eu>2021-03-24 15:42:45 +0000
commit27e5873c8d7b63912fd93b68cd58659f980975f5 (patch)
tree7518aaa15eeca84e0a1f236ad6b29d67d2cf2c64 /src/gb/gprs_ns2_vc_fsm.c
parent1dd9cbf45e7ff0b63f0accda54c497845b1d628a (diff)
gprs_ns2: add vty command `nsvc <nsvci> reset`
Diffstat (limited to 'src/gb/gprs_ns2_vc_fsm.c')
-rw-r--r--src/gb/gprs_ns2_vc_fsm.c20
1 files changed, 20 insertions, 0 deletions
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