diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2021-09-23 16:19:32 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2021-10-08 05:43:46 +0000 |
commit | d802f9ae6e721680d19ee1fc30bf19691e5e9c30 (patch) | |
tree | 3126a8e1455614cc0348536dcbfc40756ab1268e | |
parent | cc1621e476ab7ef8e6fbc9c5334ceba92518361e (diff) |
ns2: message: allow to pass a foreign NSVCI to STATUS PDU
To answer correct on a BLOCK PDU with a different NSVCI, the
STATUS PDU needs also a NSVCI parameter.
Change-Id: I373eb48697097cdfa45748a091c11f7b3f0345fa
-rw-r--r-- | src/gb/gprs_ns2.c | 2 | ||||
-rw-r--r-- | src/gb/gprs_ns2_internal.h | 2 | ||||
-rw-r--r-- | src/gb/gprs_ns2_message.c | 11 | ||||
-rw-r--r-- | src/gb/gprs_ns2_vc_fsm.c | 4 |
4 files changed, 12 insertions, 7 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index 6bccf655..3bb04ae8 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -1356,7 +1356,7 @@ int ns2_recv_vc(struct gprs_ns2_vc *nsvc, if (rc < 0) { LOGP(DLNS, LOGL_NOTICE, "Error during TLV Parse\n"); if (nsh->pdu_type != NS_PDUT_STATUS) - ns2_tx_status(nsvc, NS_CAUSE_PROTO_ERR_UNSPEC, 0, msg); + ns2_tx_status(nsvc, NS_CAUSE_PROTO_ERR_UNSPEC, 0, msg, NULL); return rc; } return ns2_vc_rx(nsvc, msg, &tp); diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h index a5d78d45..0959d2b0 100644 --- a/src/gb/gprs_ns2_internal.h +++ b/src/gb/gprs_ns2_internal.h @@ -439,7 +439,7 @@ int ns2_tx_unit_data(struct gprs_ns2_vc *nsvc, struct msgb *msg); int ns2_tx_status(struct gprs_ns2_vc *nsvc, uint8_t cause, - uint16_t bvci, struct msgb *orig_msg); + uint16_t bvci, struct msgb *orig_msg, uint16_t *nsvci); /* driver */ struct gprs_ns2_vc *ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind, diff --git a/src/gb/gprs_ns2_message.c b/src/gb/gprs_ns2_message.c index de30470b..cc95334e 100644 --- a/src/gb/gprs_ns2_message.c +++ b/src/gb/gprs_ns2_message.c @@ -432,13 +432,14 @@ int ns2_tx_unit_data(struct gprs_ns2_vc *nsvc, * \param[in] cause Numeric NS cause value * \param[in] bvci BVCI to be reset within NSVC * \param[in] orig_msg message causing the STATUS + * \param[in] nsvci if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used. * \returns 0 in case of success */ int ns2_tx_status(struct gprs_ns2_vc *nsvc, uint8_t cause, - uint16_t bvci, struct msgb *orig_msg) + uint16_t bvci, struct msgb *orig_msg, uint16_t *nsvci) { struct msgb *msg = ns2_msgb_alloc(); struct gprs_ns_hdr *nsh; - uint16_t nsvci = osmo_htons(nsvc->nsvci); + uint16_t encoded_nsvci; unsigned int orig_len, max_orig_len; log_set_context(LOG_CTX_GB_NSE, nsvc->nse); @@ -459,7 +460,11 @@ int ns2_tx_status(struct gprs_ns2_vc *nsvc, uint8_t cause, case NS_CAUSE_NSVC_BLOCKED: case NS_CAUSE_NSVC_UNKNOWN: /* Section 9.2.7.1: Static conditions for NS-VCI */ - msgb_tvlv_put(msg, NS_IE_VCI, 2, (uint8_t *)&nsvci); + if (nsvci) + encoded_nsvci = osmo_htons(*nsvci); + else + encoded_nsvci = osmo_htons(nsvc->nsvci); + msgb_tvlv_put(msg, NS_IE_VCI, 2, (uint8_t *)&encoded_nsvci); break; case NS_CAUSE_SEM_INCORR_PDU: case NS_CAUSE_PDU_INCOMP_PSTATE: diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c index d09c31ad..1a632b18 100644 --- a/src/gb/gprs_ns2_vc_fsm.c +++ b/src/gb/gprs_ns2_vc_fsm.c @@ -679,7 +679,7 @@ static void ns2_vc_fsm_allstate_action(struct osmo_fsm_inst *fi, ns2_tx_status(priv->nsvc, NS_CAUSE_NSVC_BLOCKED, - 0, msg); + 0, msg, NULL); break; /* ALIVE can receive UNITDATA if the ALIVE_ACK is lost */ case GPRS_NS2_ST_RECOVERING: @@ -863,7 +863,7 @@ int ns2_vc_rx(struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp) if (ns2_validate(nsvc, nsh->pdu_type, msg, tp, &cause)) { /* don't answer on a STATUS with a STATUS */ if (nsh->pdu_type != NS_PDUT_STATUS) { - rc = ns2_tx_status(nsvc, cause, 0, msg); + rc = ns2_tx_status(nsvc, cause, 0, msg, NULL); goto out; } } |