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
This commit is contained in:
Alexander Couzens 2021-09-23 16:19:32 +02:00 committed by laforge
parent cc1621e476
commit d802f9ae6e
4 changed files with 12 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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