[PATCH] osmo-msc[master]: DTAP: Ensure proper DLCI is used in MSC-originated DTAP

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Apr 9 14:41:08 UTC 2018


Review at  https://gerrit.osmocom.org/7690

DTAP: Ensure proper DLCI is used in MSC-originated DTAP

The DLCI field of the DTAP header indicates the SAPI as well as the
data link (main DCCH or SACCH).  We must make sure to use the correct
DLCI when sending DTAP to the BSC.

We achieve this by
* storing the DLCI in the msgb->cb while parsing the DTAP header
* storing the received DLCI (from msgb->cb) in the transaction for
  mobile-originated transactions
* using the trans->dlci to sent msgb->cb when transmitting L3
* filling the DTAP DLCI value from msgb->cb when transmitting DTAP

For MSC-originated transactions, we choose a DLCI value corresponding
to the service (SAPI=0 for CC, SAPI=3 for SMS) and store that in
trans->dlci.

Change-Id: If511b20f52575054cab1346d99a8cb68d827fdbf
---
M include/osmocom/msc/gsm_data.h
M include/osmocom/msc/transaction.h
M src/libmsc/a_iface.c
M src/libmsc/a_iface_bssap.c
M src/libmsc/gsm_04_08.c
M src/libmsc/gsm_04_11.c
6 files changed, 16 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/90/7690/1

diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index f3e1b94..6f0aca4 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -20,7 +20,8 @@
 
 #include "gsm_data_shared.h"
 
-
+/* TS 48.008 DLCI containing DCCH/ACCH + SAPI */
+#define OMSC_LINKID_CB(__msgb)   (__msgb)->cb[3]
 
 /** annotations for msgb ownership */
 #define __uses
diff --git a/include/osmocom/msc/transaction.h b/include/osmocom/msc/transaction.h
index 272fb3b..63b1cc5 100644
--- a/include/osmocom/msc/transaction.h
+++ b/include/osmocom/msc/transaction.h
@@ -31,6 +31,9 @@
 	/* The current transaction ID */
 	uint8_t transaction_id;
 
+	/* The DLCI (DCCH/ACCH + SAPI) of this transaction */
+	uint8_t dlci;
+
 	/* To whom we belong, unique identifier of remote MM entity */
 	struct vlr_subscr *vsub;
 
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 2b1baf0..6f2000e 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -145,14 +145,13 @@
 	struct gsm_subscriber_connection *conn;
 	struct msgb *msg_resp;
 
-	/* FIXME: Set this to some meaninful value! */
-	uint8_t link_id = 0x00;
+	uint8_t link_id = OMSC_LINKID_CB(msg);
 	OSMO_ASSERT(msg);
 	conn = (struct gsm_subscriber_connection *)msg->dst;
 	OSMO_ASSERT(conn);
 	OSMO_ASSERT(conn->a.scu);
 
-	LOGPCONN(conn, LOGL_DEBUG, "Passing DTAP message from MSC to BSC\n");
+	LOGPCONN(conn, LOGL_DEBUG, "Passing DTAP message (DLCI=0x%02x) from MSC to BSC\n", link_id);
 
 	msg->l3h = msg->data;
 	msg_resp = gsm0808_create_dtap(msg, link_id);
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index 1665e23..d0d6bc0 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -610,6 +610,7 @@
 {
 	struct gsm_network *network = a_conn_info->network;
 	struct gsm_subscriber_connection *conn;
+	struct dtap_header *dtap = (struct dtap_header *) msg->l2h;
 
 	conn = subscr_conn_lookup_a(network, a_conn_info->conn_id);
 	if (!conn) {
@@ -620,6 +621,7 @@
 
 	/* msc_dtap expects the dtap payload in l3h */
 	msg->l3h = msg->l2h + 3;
+	OMSC_LINKID_CB(msg) = dtap->link_id;
 
 	/* Forward dtap payload into the msc */
 	msc_dtap(conn, conn->a.conn_id, msg);
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index a90ff17..e5ddb44 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -164,6 +164,7 @@
 	 * work that the caller no longer has to do */
 	if (trans) {
 		gh->proto_discr = trans->protocol | (trans->transaction_id << 4);
+		OMSC_LINKID_CB(msg) = trans->dlci;
 	}
 
 	return msc_tx_dtap(conn, msg);
@@ -3110,6 +3111,7 @@
 
 		/* Assign conn */
 		trans->conn = msc_subscr_conn_get(conn, MSC_CONN_USE_TRANS_CC);
+		trans->dlci = 0x00; /* SAPI=0, not SACCH */
 		vlr_subscr_put(vsub);
 	} else {
 		/* update the subscriber we deal with */
@@ -3262,6 +3264,7 @@
 		}
 		/* Assign transaction */
 		trans->conn = msc_subscr_conn_get(conn, MSC_CONN_USE_TRANS_CC);
+		trans->dlci = OMSC_LINKID_CB(msg); /* DLCI as received from BSC */
 		cm_service_request_concludes(conn, msg);
 	}
 
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index f82aa6d..aa60490 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -137,6 +137,7 @@
 	/* Outgoing needs the highest bit set */
 	gh->proto_discr = trans->protocol | (trans->transaction_id<<4);
 	gh->msg_type = msg_type;
+	OMSC_LINKID_CB(msg) = trans->dlci;
 
 	DEBUGP(DLSMS, "sending CP message (trans=%x)\n", trans->transaction_id);
 
@@ -947,6 +948,7 @@
 			gsm411_rl_recv, gsm411_mn_send);
 
 		trans->conn = msc_subscr_conn_get(conn, MSC_CONN_USE_TRANS_SMS);
+		trans->dlci = OMSC_LINKID_CB(msg); /* DLCI as received from BSC */
 
 		new_trans = 1;
 		cm_service_request_concludes(conn, msg);
@@ -1029,6 +1031,8 @@
 	trans->sms.sms = sms;
 
 	trans->conn = msc_subscr_conn_get(conn, MSC_CONN_USE_TRANS_SMS);
+	trans->dlci = 0x03;
+	/* FIXME: specify SACCH in case we already have active TCH */
 
 	/* Hardcode SMSC Originating Address for now */
 	data = (uint8_t *)msgb_put(msg, 8);

-- 
To view, visit https://gerrit.osmocom.org/7690
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If511b20f52575054cab1346d99a8cb68d827fdbf
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list