Change in osmo-sgsn[master]: sgsn_rim: Add routing for (GERAN) BSSGP RIM messages

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/.

dexter gerrit-no-reply at lists.osmocom.org
Tue Jan 12 15:19:27 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/22110 )


Change subject: sgsn_rim: Add routing for (GERAN) BSSGP RIM messages
......................................................................

sgsn_rim: Add routing for (GERAN) BSSGP RIM messages

The SGSN currently does not forward BSSGP RIM messages.

Related: SYS#5103
Change-Id: I6fde8ab8955660b48000ca1b650cfc7c7b2e24ba
---
M include/osmocom/sgsn/Makefile.am
M include/osmocom/sgsn/debug.h
A include/osmocom/sgsn/sgsn_rim.h
M src/sgsn/Makefile.am
M src/sgsn/sgsn_main.c
A src/sgsn/sgsn_rim.c
6 files changed, 92 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/10/22110/1

diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am
index 3fdb6b3..95c811a 100644
--- a/include/osmocom/sgsn/Makefile.am
+++ b/include/osmocom/sgsn/Makefile.am
@@ -24,6 +24,7 @@
 	gprs_utils.h \
 	gtphub.h \
 	sgsn.h \
+	sgsn_rim.h \
 	signal.h \
 	slhc.h \
 	v42bis.h \
diff --git a/include/osmocom/sgsn/debug.h b/include/osmocom/sgsn/debug.h
index da819d5..ed09e29 100644
--- a/include/osmocom/sgsn/debug.h
+++ b/include/osmocom/sgsn/debug.h
@@ -40,6 +40,7 @@
 	DSIGTRAN,
 	DGTP,
 	DOBJ,
+	DRIM,
 	Debug_LastEntry,
 };
 
diff --git a/include/osmocom/sgsn/sgsn_rim.h b/include/osmocom/sgsn/sgsn_rim.h
new file mode 100644
index 0000000..9f62383
--- /dev/null
+++ b/include/osmocom/sgsn/sgsn_rim.h
@@ -0,0 +1,3 @@
+#pragma once
+
+int sgsn_rim_rx(struct msgb *msg);
diff --git a/src/sgsn/Makefile.am b/src/sgsn/Makefile.am
index 6a7392b..8738986 100644
--- a/src/sgsn/Makefile.am
+++ b/src/sgsn/Makefile.am
@@ -62,6 +62,7 @@
 	sgsn_auth.c \
 	gprs_subscriber.c \
 	sgsn_cdr.c \
+	sgsn_rim.c \
 	slhc.c \
 	gprs_llc_xid.c \
 	v42bis.c \
diff --git a/src/sgsn/sgsn_main.c b/src/sgsn/sgsn_main.c
index 19039f6..0fbd4a6 100644
--- a/src/sgsn/sgsn_main.c
+++ b/src/sgsn/sgsn_main.c
@@ -67,6 +67,7 @@
 #include <osmocom/ctrl/ports.h>
 
 #include <gtp.h>
+#include <osmocom/sgsn/sgsn_rim.h>
 
 #include "../../bscconfig.h"
 
@@ -120,6 +121,8 @@
 		break;
 	case SAP_BSSGP_NM:
 		break;
+	case SAP_BSSGP_RIM:
+		return sgsn_rim_rx(oph->msg);
 	}
 	return 0;
 }
@@ -311,6 +314,11 @@
 		.description = "GPRS Tunnelling Protocol (GTP)",
 		.enabled = 1, .loglevel = LOGL_NOTICE,
 	},
+	[DRIM] = {
+		.name = "DRIM",
+		.description = "RAN Information Management (RIM)",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
 };
 
 static const struct log_info gprs_log_info = {
diff --git a/src/sgsn/sgsn_rim.c b/src/sgsn/sgsn_rim.c
new file mode 100644
index 0000000..bbf75b2
--- /dev/null
+++ b/src/sgsn/sgsn_rim.c
@@ -0,0 +1,78 @@
+
+#include <stdio.h>
+
+#include <errno.h>
+#include <stdint.h>
+
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/vty/logging.h>
+#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gprs/gprs_bssgp_rim.h>
+#include <osmocom/sgsn/sgsn_rim.h>
+#include <osmocom/sgsn/debug.h>
+
+/* Find an NSEI for the destination cell, this function works only for GERAN! */
+static int find_dest_nsei_geran(struct bssgp_rim_routing_info *dest_rim_ri, uint16_t nsei)
+{
+	struct bssgp_bvc_ctx *bvc_ctx;
+
+	OSMO_ASSERT(dest_rim_ri->discr == BSSGP_RIM_ROUTING_INFO_GERAN);
+
+	bvc_ctx = btsctx_by_raid_cid(&dest_rim_ri->geran.raid, dest_rim_ri->geran.cid);
+	if (!bvc_ctx) {
+		LOGP(DRIM, LOGL_ERROR, "BSSGP RIM (NSEI=%u) cannot find NSEI for destination cell\n", nsei);
+		return -EINVAL;
+	}
+
+	return bvc_ctx->nsei;
+}
+
+int sgsn_rim_rx(struct msgb *msg)
+{
+	struct bssgp_rim_routing_info dest_rim_ri;
+	struct bssgp_rim_routing_info src_rim_ri;
+	int rc;
+        struct bssgp_ran_information_pdu pdu;
+        int d_nsei;
+	uint16_t nsei = msgb_nsei(msg);
+
+	rc = bssgp_parse_rim_pdu(&pdu, msg);
+	if (rc < 0)
+		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
+
+	/* Parse destination and source cell identifer */
+	rc = bssgp_parse_rim_ri(&dest_rim_ri, pdu.routing_info_dest, pdu.routing_info_dest_len);
+	if (rc < 0) {
+		LOGP(DRIM, LOGL_ERROR, "BSSGP RIM (NSEI=%u) cannot decode Destination Cell Identifier\n", nsei);
+		return bssgp_tx_status(BSSGP_CAUSE_UNKN_RIM_AI, NULL, msg);
+	}
+
+	rc = bssgp_parse_rim_ri(&src_rim_ri, pdu.routing_info_src, pdu.routing_info_src_len);
+	if (rc < 0) {
+		LOGP(DRIM, LOGL_ERROR, "BSSGP RIM (NSEI=%u) cannot decode Source Cell Identifier\n", nsei);
+		return bssgp_tx_status(BSSGP_CAUSE_UNKN_RIM_AI, NULL, msg);
+	}
+
+	/* At the moment we only support GERAN, so we block all other network
+	 * types here. */
+	if (dest_rim_ri.discr != BSSGP_RIM_ROUTING_INFO_GERAN) {
+		LOGP(DRIM, LOGL_ERROR,
+		     "BSSGP RIM (NSEI=%u) only GERAN supported, destination cell is not a GERAN cell -- rejected.\n",
+		     nsei);
+		return bssgp_tx_status(BSSGP_CAUSE_UNKN_RIM_AI, NULL, msg);
+	}
+	if (src_rim_ri.discr != BSSGP_RIM_ROUTING_INFO_GERAN) {
+		LOGP(DRIM, LOGL_ERROR,
+		     "BSSGP RIM (NSEI=%u) only GERAN supported, source cell is not a GERAN cell -- rejected.\n", nsei);
+		return bssgp_tx_status(BSSGP_CAUSE_UNKN_RIM_AI, NULL, msg);
+	}
+
+	d_nsei = find_dest_nsei_geran(&dest_rim_ri, nsei);
+	if (d_nsei < 0) {
+		return bssgp_tx_status(BSSGP_CAUSE_UNKN_RIM_AI, NULL, msg);
+	}
+
+	return bssgp_tx_rim(&pdu, (uint16_t)d_nsei);
+}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/22110
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I6fde8ab8955660b48000ca1b650cfc7c7b2e24ba
Gerrit-Change-Number: 22110
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210112/b20d262e/attachment.htm>


More information about the gerrit-log mailing list