Change in osmo-bts[master]: clear GPRS indicator in SI3 while PCU is disconnected

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
Wed May 29 08:40:33 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10170 )

Change subject: clear GPRS indicator in SI3 while PCU is disconnected
......................................................................

clear GPRS indicator in SI3 while PCU is disconnected

osmo-bts cannot provide GPRS service while osmo-pcu is not connected.
The BSC has no knowledge of the PCU connection state. Prevent MSs
from trying to register for GPRS while the PCU is disconnected by
erasing the GPRS Indicator in SI3.

Change-Id: I1a6f5c636c0fe098ee31c280d4572a3f8122b44b
Depends: I690cf308311f910005a325d50f5d5d825678d2b2 (libosmocore.git)
Depends: I08e0ca9a8d13c7aa40b9d90f34f0e13adb87d4e0 (libosmocore.git)
Depends: I8b1ee2405f6338507e9dfb5f1f437c4c2db2e330 (libosmocore.git)
Related: OS#3075
---
M include/osmo-bts/bts.h
M include/osmo-bts/gsm_data_shared.h
M src/common/pcu_sock.c
M src/common/rsl.c
M src/common/sysinfo.c
5 files changed, 63 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index d7c4bbf..970fb1b 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -48,6 +48,7 @@
 		      int is_ag_res);
 
 uint8_t *bts_sysinfo_get(struct gsm_bts *bts, const struct gsm_time *g_time);
+void regenerate_si3_restoctets(struct gsm_bts *bts);
 uint8_t *lchan_sacch_get(struct gsm_lchan *lchan);
 int lchan_init_lapdm(struct gsm_lchan *lchan);
 
diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h
index 415e6bc..90772e2 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -15,6 +15,7 @@
 #include <osmocom/gsm/rxlev_stat.h>
 #include <osmocom/gsm/sysinfo.h>
 #include <osmocom/gsm/meas_rep.h>
+#include <osmocom/gsm/gsm48_rest_octets.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/protocol/gsm_08_58.h>
 #include <osmocom/gsm/protocol/gsm_12_21.h>
@@ -620,6 +621,10 @@
 	/* offsets used while generating SI2quater */
 	size_t e_offset;
 	size_t u_offset;
+	/* decoded SI3 rest octets - *unmodified* as received from BSC */
+	struct osmo_gsm48_si_ro_info si3_ro_decoded;
+	/* is SI3 GPRS Indicator currently disabled due to lack of PCU connection? */
+	bool si3_gprs_ind_disabled;
 
 	/* ip.accesss Unit ID's have Site/BTS/TRX layout */
 	union {
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index e4f2d66..39b4568 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -1,6 +1,6 @@
 /* pcu_sock.c: Connect from PCU via unix domain socket */
 
-/* (C) 2008-2010 by Harald Welte <laforge at gnumonks.org>
+/* (C) 2008-2019 by Harald Welte <laforge at gnumonks.org>
  * (C) 2009-2012 by Andreas Eversberg <jolly at eversberg.eu>
  * (C) 2012 by Holger Hans Peter Freyther
  * All Rights Reserved
@@ -598,6 +598,9 @@
 		oml_tx_failure_event_rep(&bts->gprs.cell.mo, NM_SEVER_CEASED, OSMO_EVT_PCU_VERS, txt->text);
 		osmo_strlcpy(bts->pcu_version, txt->text, MAX_VERSION_LENGTH);
 
+		/* patch SI3 to advertise GPRS, *if* the SI3 sent by BSC said so */
+		regenerate_si3_restoctets(bts);
+
 		if (GSM_BTS_HAS_SI(bts, SYSINFO_TYPE_13))
 			return pcu_tx_si13(bts, true);
 
@@ -741,6 +744,9 @@
 	bfd->fd = -1;
 	osmo_fd_unregister(bfd);
 
+	/* patch SI3 to remove GPRS indicator */
+	regenerate_si3_restoctets(bts);
+
 	/* re-enable the generation of ACCEPT for new connections */
 	state->listen_bfd.when |= BSC_FD_READ;
 
diff --git a/src/common/rsl.c b/src/common/rsl.c
index f76a006..b96182f 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1,7 +1,7 @@
 /* GSM TS 08.58 RSL, BTS Side */
 
 /* (C) 2011 by Andreas Eversberg <jolly at eversberg.eu>
- * (C) 2011-2017 by Harald Welte <laforge at gnumonks.org>
+ * (C) 2011-2019 by Harald Welte <laforge at gnumonks.org>
  *
  * All Rights Reserved
  *
@@ -360,12 +360,18 @@
 
 		bts->si_valid |= (1 << osmo_si);
 
-		if (SYSINFO_TYPE_3 == osmo_si && trx->nr == 0 &&
-		    num_agch(trx, "RSL") != 1) {
-			lchan_deactivate(&trx->bts->c0->ts[0].lchan[CCCH_LCHAN]);
-			/* will be reactivated by sapi_deactivate_cb() */
-			trx->bts->c0->ts[0].lchan[CCCH_LCHAN].rel_act_kind =
-				LCHAN_REL_ACT_REACT;
+		if (SYSINFO_TYPE_3 == osmo_si) {
+			if (trx->nr == 0 && num_agch(trx, "RSL") != 1) {
+				lchan_deactivate(&trx->bts->c0->ts[0].lchan[CCCH_LCHAN]);
+				/* will be reactivated by sapi_deactivate_cb() */
+				trx->bts->c0->ts[0].lchan[CCCH_LCHAN].rel_act_kind =
+					LCHAN_REL_ACT_REACT;
+			}
+			/* decode original SI3 Rest Octets as sent by BSC */
+			osmo_gsm48_rest_octets_si3_decode(&bts->si3_ro_decoded, GSM_BTS_SI(bts, osmo_si));
+			/* patch out GPRS indicator from binary if PCU is not connected; will be enabled
+			 * after PCU connects */
+			regenerate_si3_restoctets(bts);
 		}
 
 		if (SYSINFO_TYPE_13 == osmo_si)
@@ -387,6 +393,8 @@
 			get_value_string(osmo_sitype_strs, osmo_si));
 		if (SYSINFO_TYPE_13 == osmo_si)
 			pcu_tx_si13(trx->bts, false);
+		if (SYSINFO_TYPE_3 == osmo_si)
+			memset(&bts->si3_ro_decoded, 0, sizeof(bts->si3_ro_decoded));
 	}
 	osmo_signal_dispatch(SS_GLOBAL, S_NEW_SYSINFO, bts);
 
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c
index e4a05c8..c41f9d6 100644
--- a/src/common/sysinfo.c
+++ b/src/common/sysinfo.c
@@ -1,4 +1,4 @@
-/* (C) 2011 by Harald Welte <laforge at gnumonks.org>
+/* (C) 2011-2019 by Harald Welte <laforge at gnumonks.org>
  *
  * All Rights Reserved
  *
@@ -24,6 +24,7 @@
 
 #include <osmo-bts/logging.h>
 #include <osmo-bts/gsm_data.h>
+#include <osmo-bts/pcu_if.h>
 
 /* properly increment SI2q index and return SI2q data for scheduling */
 static inline uint8_t *get_si2q_inc_index(struct gsm_bts *bts)
@@ -175,3 +176,36 @@
 	LOGPLCHAN(lchan, DL1P, LOGL_NOTICE, "SACCH no SI available\n");
 	return NULL;
 }
+
+/* re-generate SI3 restoctets with GPRS indicator depending on the PCU socket connection state */
+void regenerate_si3_restoctets(struct gsm_bts *bts)
+{
+	uint8_t *si3_buf = GSM_BTS_SI(bts, SYSINFO_TYPE_3);
+	size_t si3_size = offsetof(struct gsm48_system_information_type_3, rest_octets);
+	struct osmo_gsm48_si_ro_info si3ro_tmp;
+
+	/* If BSC has never set SI3, there's nothing to patch */
+	if (!GSM_BTS_HAS_SI(bts, SYSINFO_TYPE_3))
+		return;
+
+	/* If SI3 from BSC doesn't have a GPRS indicator, we won't have anything to patch */
+	if (!bts->si3_ro_decoded.gprs_ind.present)
+		return;
+
+	/* Create a temporary copy and patch that, if no PCU is around */
+	si3ro_tmp = bts->si3_ro_decoded;
+	if (!pcu_connected()) {
+		if (!bts->si3_gprs_ind_disabled)
+			LOGP(DPCU, LOGL_NOTICE, "Disabling GPRS Indicator in SI3 (No PCU connected)\n");
+		bts->si3_gprs_ind_disabled = true;
+		si3ro_tmp.gprs_ind.present = 0;
+	} else {
+		if (bts->si3_gprs_ind_disabled)
+			LOGP(DPCU, LOGL_NOTICE, "Enabling GPRS Indicator in SI3 (PCU connected)\n");
+		bts->si3_gprs_ind_disabled = false;
+		si3ro_tmp.gprs_ind.present = 1; /* is a no-op as we copy from bts->si3_ro_decoded */
+	}
+
+	/* re-generate the binary SI3 rest octets */
+	osmo_gsm48_rest_octets_si3_encode(si3_buf + si3_size, &si3ro_tmp);
+}

-- 
To view, visit https://gerrit.osmocom.org/10170
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1a6f5c636c0fe098ee31c280d4572a3f8122b44b
Gerrit-Change-Number: 10170
Gerrit-PatchSet: 5
Gerrit-Owner: Stefan Sperling <stsp at stsp.name>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <stsp at stsp.name>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-CC: Max <suraev at alumni.ntnu.no>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190529/b07a3114/attachment.htm>


More information about the gerrit-log mailing list