From 1710c7e71f679117d76580c339b362679e6e59f2 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 9 Apr 2017 19:36:21 +0200 Subject: [PATCH] M3UA: Ensure XFER messages are not sent on stream 0 According to the RFC, Stream ID 0 MUST not be used for XFER/DATA messages. This was discovered (and fix validated) using m3ua-sgp-mtr-v-003-alternate of Michale Tuexen's m3ua-testtool. Change-Id: I80b941426b5106e091bd1becff0ae97958aff97c --- src/m3ua.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/m3ua.c b/src/m3ua.c index 14df269b..c29ed00f 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -432,6 +432,10 @@ static int m3ua_tx_xua_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) return -1; } + if (xua->hdr.msg_class == M3UA_MSGC_XFER) + msgb_sctp_stream(msg) = 1; + else + msgb_sctp_stream(msg) = 0; msgb_sctp_ppid(msg) = M3UA_PPID; return osmo_ss7_asp_send(asp, msg); } @@ -666,12 +670,16 @@ int m3ua_rx_msg(struct osmo_ss7_asp *asp, struct msgb *msg) goto out; } - /* TODO: check for SCTP Strema ID */ /* TODO: check if any AS configured in ASP */ /* TODO: check for valid routing context */ switch (xua->hdr.msg_class) { case M3UA_MSGC_XFER: + /* The DATA message MUST NOT be sent on stream 0. */ + if (msgb_sctp_stream(msg) == 0) { + rc = M3UA_ERR_INVAL_STREAM_ID; + break; + } rc = m3ua_rx_xfer(asp, xua); break; case M3UA_MSGC_ASPSM: