[PATCH] osmo-pcu[master]: Support sending OML Alerts via BTS

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

Max gerrit-no-reply at lists.osmocom.org
Thu Mar 16 20:37:21 UTC 2017


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2071

to look at the new patch set (#3).

Support sending OML Alerts via BTS

* extend BTS <-> PCU protocol with TXT messages
* use it to implement OML alerts support
* use it to implement version message
* add function to transmit both of them them
* send alerts for internal encoding problems as an example
* send version when BTS socket is connected

Note: requires corresponding change
If57459c0610f2c7b36d599b13087c8deef8bdd9e in libosmocore.

Related: OS#1614, 1615
Change-Id: If4ea5b3f7409df2fb030681ad468df6b711790a7
---
M include/osmocom/pcu/pcuif_proto.h
M src/encoding.cpp
M src/osmobts_sock.cpp
M src/pcu_l1_if.cpp
M src/pcu_l1_if.h
5 files changed, 56 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/71/2071/3

diff --git a/include/osmocom/pcu/pcuif_proto.h b/include/osmocom/pcu/pcuif_proto.h
index 944f364..88dc09e 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -4,6 +4,7 @@
 #include <osmocom/gsm/l1sap.h>
 
 #define PCU_IF_VERSION		0x07
+#define TXT_MAX_LEN	128
 
 /* msg_type */
 #define PCU_IF_MSG_DATA_REQ	0x00	/* send data to given channel */
@@ -15,6 +16,7 @@
 #define PCU_IF_MSG_ACT_REQ	0x40	/* activate/deactivate PDCH */
 #define PCU_IF_MSG_TIME_IND	0x52	/* GSM time indication */
 #define PCU_IF_MSG_PAG_REQ	0x60	/* paging request */
+#define PCU_IF_MSG_TXT_IND	0x70	/* Text indication for BTS */
 
 /* sapi */
 #define PCU_IF_SAPI_RACH	0x01	/* channel request on CCCH */
@@ -41,6 +43,16 @@
 #define PCU_IF_FLAG_MCS7	(1 << 26)
 #define PCU_IF_FLAG_MCS8	(1 << 27)
 #define PCU_IF_FLAG_MCS9	(1 << 28)
+
+enum gsm_pcu_if_text_type {
+	PCU_VERSION,
+	PCU_OML_ALERT,
+};
+
+struct gsm_pcu_if_txt_ind {
+	uint8_t		type; /* gsm_pcu_if_text_type */
+	char		text[TXT_MAX_LEN]; /* Text to be transmitted to BTS */
+} __attribute__ ((packed));
 
 struct gsm_pcu_if_data {
 	uint8_t		sapi;
@@ -150,6 +162,7 @@
 		struct gsm_pcu_if_data		data_ind;
 		struct gsm_pcu_if_rts_req	rts_req;
 		struct gsm_pcu_if_rach_ind	rach_ind;
+		struct gsm_pcu_if_txt_ind	txt_ind;
 		struct gsm_pcu_if_info_ind	info_ind;
 		struct gsm_pcu_if_act_req	act_req;
 		struct gsm_pcu_if_time_ind	time_ind;
diff --git a/src/encoding.cpp b/src/encoding.cpp
index ea38b77..942772b 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -377,6 +377,8 @@
 	if ((wp % 8)) {
 		LOGP(DRLCMACUL, LOGL_ERROR, "Length of IMM.ASS without rest "
 			"octets is not multiple of 8 bits, PLEASE FIX!\n");
+		pcu_tx_txt_ind(PCU_OML_ALERT, "Length of IMM.ASS without rest "
+			       "octets is not multiple of 8 bits, exiting.");
 		exit (0);
 	}
 	plen = wp / 8;
@@ -621,6 +623,8 @@
 	if ((wp % 8)) {
 		LOGP(DRLCMACUL, LOGL_ERROR, "Length of PAG.REQ without rest "
 			"octets is not multiple of 8 bits, PLEASE FIX!\n");
+		pcu_tx_txt_ind(PCU_OML_ALERT, "Length of PAG.REQ without rest "
+			       "octets is not multiple of 8 bits, exiting.");
 		exit (0);
 	}
 	plen = wp / 8;
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index d542b66..d7e55e7 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -287,6 +287,9 @@
 
 	pcu_sock_state = state;
 
+	LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION);
+	pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
+
 	return 0;
 }
 
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index b892597..da66e32 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -73,6 +73,39 @@
 	return msg;
 }
 
+const struct value_string gsm_pcu_if_text_type_names[] = {
+	OSMO_VALUE_STRING(PCU_VERSION),
+	OSMO_VALUE_STRING(PCU_OML_ALERT),
+	{ 0, NULL }
+};
+
+int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...)
+{
+	struct gsm_pcu_if *pcu_prim;
+	struct gsm_pcu_if_txt_ind *txt;
+	va_list ap;
+	char *rep;
+	struct msgb *msg = pcu_msgb_alloc(PCU_IF_MSG_TXT_IND, 0);
+	if (!msg)
+		return -ENOMEM;
+
+	pcu_prim = (struct gsm_pcu_if *) msg->data;
+	txt = &pcu_prim->u.txt_ind;
+	txt->type = t;
+
+	va_start(ap, fmt);
+	rep = talloc_vasprintf(tall_pcu_ctx, fmt, ap);
+	va_end(ap);
+
+	osmo_strlcpy(txt->text, rep, TXT_MAX_LEN);
+	talloc_free(rep);
+
+	LOGP(DL1IF, LOGL_INFO, "Sending %s TXT as %s to BTS\n", txt->text,
+	     get_value_string(gsm_pcu_if_text_type_names, t));
+
+	return pcu_sock_send(msg);
+}
+
 static int pcu_tx_act_req(uint8_t trx, uint8_t ts, uint8_t activate)
 {
 	struct msgb *msg;
diff --git a/src/pcu_l1_if.h b/src/pcu_l1_if.h
index eaa0143..1618260 100644
--- a/src/pcu_l1_if.h
+++ b/src/pcu_l1_if.h
@@ -29,6 +29,7 @@
 #include <osmocom/core/timer.h>
 #include <osmocom/core/bitvec.h>
 #include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/pcu/pcuif_proto.h>
 #ifdef __cplusplus
 }
 #endif
@@ -131,6 +132,8 @@
 
 void pcu_l1if_tx_pch(bitvec * block, int plen, const char *imsi);
 
+int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...);
+
 int pcu_l1if_open(void);
 void pcu_l1if_close(void);
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If4ea5b3f7409df2fb030681ad468df6b711790a7
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list