pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39690?usp=email )
Change subject: sccp: Allow marking UNIT-DATA.req Sequence Control param non-presence, set
SLS
......................................................................
sccp: Allow marking UNIT-DATA.req Sequence Control param non-presence, set SLS
The public API for SCCP UNIT-DATA.req was missing a way to state whether
the "Sequence Control" Parameter was present or not in the primitive.
This was originated most probably by the fact that the field is always
present for SUA CLDT message generated and sent over the wire.
Still, the presence of such field during UNIT-DATA.req actually
indicates the Protocol Class to be used/set on the message.
Hence, it is important to provide it.
Once the Protocol Class to transmit the message is known, we can then
generate a proper SLS.
Change-Id: I834e91c1ec337713b0e684cf4fd7de854150bef6
---
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_helpers.c
M src/sccp_sclc.c
3 files changed, 39 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/90/39690/1
diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
index d0fb040..42c8af3 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -236,6 +236,13 @@
};
/* OSMO_SCU_PRIM_N_UNITDATA */
+/* NOTE: Idenally there should have been a "bool in_sequence_control_present",
+ * but that was found too late, so instead set:
+ * "in_sequence_control =
OSMO_SCU_UNITDATA_PARAM_SEQUENCE_CONTROL_NOT_PRESENT"
+ * to mark the field not present (aka select Protocol Class 0).
+ * See ITU-T Q.711 6.2.1 for more information.
+ */
+#define OSMO_SCU_UNITDATA_REQ_P_SEQUENCE_CONTROL_NOT_PRESENT 0xffffffff
struct osmo_scu_unitdata_param {
struct osmo_sccp_addr called_addr;
struct osmo_sccp_addr calling_addr;
diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c
index 2a04b9d..6dd9ab8 100644
--- a/src/sccp_helpers.c
+++ b/src/sccp_helpers.c
@@ -72,6 +72,7 @@
param = &prim->u.unitdata;
memcpy(¶m->calling_addr, calling_addr, sizeof(*calling_addr));
memcpy(¶m->called_addr, called_addr, sizeof(*called_addr));
+ param->in_sequence_control = OSMO_SCU_UNITDATA_REQ_P_SEQUENCE_CONTROL_NOT_PRESENT;
osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA,
PRIM_OP_REQUEST, msg);
msg->l2h = msgb_put(msg, len);
diff --git a/src/sccp_sclc.c b/src/sccp_sclc.c
index 186efbd..e0a2844 100644
--- a/src/sccp_sclc.c
+++ b/src/sccp_sclc.c
@@ -35,9 +35,6 @@
* SUA which classic SCCP cannot handle (like IP addresses in GT).
* However, all SCCP features can be expressed in SUA.
*
- * The code only supports Class 2. No support for Class 3 is intended,
- * but patches are of course always welcome.
- *
* Missing other features:
* * Segmentation/Reassembly support
* * T(guard) after (re)start
@@ -67,18 +64,47 @@
{
struct xua_msg *xua = xua_msg_alloc();
struct osmo_scu_unitdata_param *udpar = &prim->u.unitdata;
+ uint32_t seq_ctrl = udpar->in_sequence_control;
+ uint32_t proto_class;
if (!xua)
return NULL;
+ if (seq_ctrl == OSMO_SCU_UNITDATA_REQ_P_SEQUENCE_CONTROL_NOT_PRESENT) {
+ /* ITU-T Q.711 6.2.1 Class 0:
+ * "The SCCP user can invoke this service by means of the parameter
+ * "sequence control" in the N-UNITDATA request primitive being absent"
*/
+ proto_class = 0;
+ /* Erase the mark, we are anyway not using it in protocol_class=0. */
+ seq_ctrl = 0;
+ /* ITU-T Q.714 (1.1.2.1 Protocol class 0):
+ * "They are transferred independently of each other.
+ * Therefore, they may be delivered to the SCCP user out-of-sequence."
+ */
+ xua->mtp.sls = rand() & 0xf;
+ } else {
+ /* "ITU-T Q.711 6.2.1 Class 1:
+ * "The SCCP user can invoke this service by means of the parameter
+ * "sequence control" in the N-UNITDATA request primitive being
present." */
+ proto_class = 1;
+ /* ITU-T Q.714 (1.1.2.2 Protocol class 1):
+ * "The Signalling Link Selection (SLS) parameter in the MTP-TRANSFER
+ * request primitive is chosen by the originating SCCP based on the value
+ * of the sequence control parameter. The SLS shall be identical for a
+ * stream of NSDUs with the same sequence control parameter".
+ * SLS is 4 bits, as described in ITU Q.704 Figure 3.
+ */
+ xua->mtp.sls = udpar->in_sequence_control & 0x0f;
+ }
+
switch (msg_type) {
case SUA_CL_CLDT:
xua->hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT);
xua_msg_add_u32(xua, SUA_IEI_ROUTE_CTX, 0); /* FIXME */
- xua_msg_add_u32(xua, SUA_IEI_PROTO_CLASS, 0);
+ xua_msg_add_u32(xua, SUA_IEI_PROTO_CLASS, proto_class);
xua_msg_add_sccp_addr(xua, SUA_IEI_SRC_ADDR, &udpar->calling_addr);
xua_msg_add_sccp_addr(xua, SUA_IEI_DEST_ADDR, &udpar->called_addr);
- xua_msg_add_u32(xua, SUA_IEI_SEQ_CTRL, udpar->in_sequence_control);
+ xua_msg_add_u32(xua, SUA_IEI_SEQ_CTRL, seq_ctrl);
/* optional: importance, ... correlation id? */
if (!prim)
goto prim_needed;
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39690?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I834e91c1ec337713b0e684cf4fd7de854150bef6
Gerrit-Change-Number: 39690
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>