Change in ...osmo-pcu[master]: Forward ETWS Primary Notification to MS

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

osmith gerrit-no-reply at lists.osmocom.org
Mon Sep 9 15:19:22 UTC 2019


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/15459


Change subject: Forward ETWS Primary Notification to MS
......................................................................

Forward ETWS Primary Notification to MS

Receive an Application Information Request from the BTS via PCU
interface. Construct a Packet Application Information message from it
(3GPP TS 44.060 11.2.47) and send it to all MS with active TBF.

The TTCN-3 test infrastructure to test this feature is not quite ready
yet, so I've added C unit tests instead.

Related: OS#4048
Change-Id: Ie35959f833f46bde5f2126314b6f96763f863b36
---
M include/osmocom/pcu/pcuif_proto.h
M src/Makefile.am
M src/bts.cpp
M src/bts.h
M src/gprs_ms.h
M src/gprs_rlcmac.cpp
M src/gprs_rlcmac.h
M src/gprs_rlcmac_sched.cpp
M src/pcu_l1_if.cpp
M tests/Makefile.am
A tests/app_info/AppInfoTest.cpp
A tests/app_info/AppInfoTest.err
A tests/app_info/AppInfoTest.ok
M tests/testsuite.at
14 files changed, 413 insertions(+), 30 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/59/15459/1

diff --git a/include/osmocom/pcu/pcuif_proto.h b/include/osmocom/pcu/pcuif_proto.h
index 144fba6..fd989a5 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -13,6 +13,7 @@
 #define PCU_IF_MSG_DATA_CNF	0x01	/* confirm (e.g. transmission on PCH) */
 #define PCU_IF_MSG_DATA_IND	0x02	/* receive data from given channel */
 #define PCU_IF_MSG_SUSP_REQ	0x03	/* BTS forwards GPRS SUSP REQ to PCU */
+#define PCU_IF_MSG_APP_INFO_REQ	0x04	/* BTS asks PCU to transmit APP INFO via PACCH */
 #define PCU_IF_MSG_RTS_REQ	0x10	/* ready to send request */
 #define PCU_IF_MSG_DATA_CNF_DT	0x11	/* confirm (with direct tlli) */
 #define PCU_IF_MSG_RACH_IND	0x22	/* receive RACH */
@@ -172,6 +173,13 @@
 	uint8_t		identity_lv[9];
 } __attribute__ ((packed));
 
+/* BTS tells PCU to [once] send given application data via PACCH to all UE with active TBF */
+struct gsm_pcu_if_app_info_req {
+	uint8_t		application_type; /* 4bit field, see TS 44.060 11.2.47 */
+	uint8_t		len;		  /* length of data */
+	uint8_t		data[162];	  /* random size choice; ETWS needs 56 bytes */
+} __attribute__ ((packed));
+
 /* BTS tells PCU about a GPRS SUSPENSION REQUEST received on DCCH */
 struct gsm_pcu_if_susp_req {
 	uint32_t	tlli;
@@ -198,6 +206,7 @@
 		struct gsm_pcu_if_act_req	act_req;
 		struct gsm_pcu_if_time_ind	time_ind;
 		struct gsm_pcu_if_pag_req	pag_req;
+		struct gsm_pcu_if_app_info_req	app_info_req;
 	} u;
 } __attribute__ ((packed));
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 233e24d..7148267 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,7 +69,8 @@
 	gprs_codel.c \
 	coding_scheme.c \
 	gprs_coding_scheme.cpp \
-	egprs_rlc_compression.cpp
+	egprs_rlc_compression.cpp \
+	gprs_rlcmac_sched.cpp
 
 bin_PROGRAMS = \
 	osmo-pcu
diff --git a/src/bts.cpp b/src/bts.cpp
index 26dd401..6326cf3 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -216,6 +216,7 @@
 {
 	memset(&m_bts, 0, sizeof(m_bts));
 	m_bts.bts = this;
+	m_bts.app_info = NULL;
 
 	/* initialize back pointers */
 	for (size_t trx_no = 0; trx_no < ARRAY_SIZE(m_bts.trx); ++trx_no) {
@@ -259,6 +260,11 @@
 		osmo_stat_item_group_free(m_statg);
 		m_statg = NULL;
 	}
+
+	if (m_bts.app_info) {
+		msgb_free(m_bts.app_info);
+		m_bts.app_info = NULL;
+	}
 }
 
 BTS::~BTS()
diff --git a/src/bts.h b/src/bts.h
index 767605c..b238d44 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -164,6 +164,11 @@
 
 	/* Are we talking Gb with IP-SNS (true) or classic Gb? */
 	bool gb_dialect_sns;
+
+	/* Packet Application Information (3GPP TS 44.060 11.2.47, usually ETWS primary message). We don't need to store
+	 * more than one message, because they get sent so rarely. */
+	struct msgb *app_info; /* Encoded as RLC/MAC message */
+	uint32_t app_info_todo; /* Count of MS with active TBF, to which we did not send app_info yet */
 };
 
 #ifdef __cplusplus
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index ad8ca1d..2bbfde1 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -40,6 +40,10 @@
 struct BTS;
 struct gprs_rlcmac_trx;
 
+struct gprs_rlcmac_ms {
+	bool app_info_send;
+};
+
 class GprsMs {
 public:
 	struct Callback {
@@ -61,6 +65,8 @@
 	GprsMs(BTS *bts, uint32_t tlli);
 	~GprsMs();
 
+	struct gprs_rlcmac_ms *ms_data() {return &m_ms_data;}
+
 	void set_callback(Callback *cb) {m_cb = cb;}
 
 	void merge_old_ms(GprsMs *old_ms);
@@ -150,6 +156,7 @@
 	gprs_rlcmac_ul_tbf *m_ul_tbf;
 	gprs_rlcmac_dl_tbf *m_dl_tbf;
 	LListHead<gprs_rlcmac_tbf> m_old_tbfs;
+	struct gprs_rlcmac_ms m_ms_data = {0};
 
 	uint32_t m_tlli;
 	uint32_t m_new_ul_tlli;
diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp
index 5a223c1..1a62bfb 100644
--- a/src/gprs_rlcmac.cpp
+++ b/src/gprs_rlcmac.cpp
@@ -41,4 +41,34 @@
 	return 0;
 }
 
+/* Encode Application Information Request to Packet Application Information (3GPP TS 44.060 11.2.47) */
+struct msgb *gprs_rlcmac_app_info_msg(const struct gsm_pcu_if_app_info_req *req) {
+	struct msgb *msg;
+	uint8_t i;
+	uint8_t word;
 
+	if (!req->len) {
+		LOGP(DRLCMAC, LOGL_ERROR, "Application Information Request with zero length received!\n");
+		return NULL;
+	}
+
+	msg = msgb_alloc(req->len + 1, "app_info_msg");
+	if (!msg)
+		return NULL;
+
+	word = 0x00;					/* 0-1: page mode: normal */
+	word |= (0x0F & req->application_type) << 6;	/* 2-5: application type */
+	word |= (0xC0 & req->data[0]) >> 6;		/* 6-7: first two data bits */
+	msgb_put_u8(msg, word);
+
+	for (i=0; i < req->len - 1; i++) {
+		word = req->data[i] << 2;		/* 0-6: last six data bits from current byte */
+		word |= (0xC0 & req->data[i + 1]) >> 6;	/* 7-8: first two data bits from next byte */
+		msgb_put_u8(msg, word);
+	}
+
+	word = (0xC0 & req->data[req->len -1]) << 2;	/* 0-6: last six data bits from last byte (rest is padding) */
+	msgb_put_u8(msg, word);
+
+	return msg;
+}
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 7a3a7af..16cb05f 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -31,6 +31,7 @@
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/timer.h>
 #include <osmocom/core/bitvec.h>
+#include <osmocom/pcu/pcuif_proto.h>
 }
 #endif
 
@@ -94,6 +95,8 @@
 int gprs_rlcmac_paging_request(uint8_t *ptmsi, uint16_t ptmsi_len,
 	const char *imsi);
 
+struct msgb *gprs_rlcmac_app_info_msg(const struct gsm_pcu_if_app_info_req *req);
+
 int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts,
 	uint8_t trx, uint8_t ts,
         uint32_t fn, uint8_t block_nr);
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 57756e3..4b74708 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -123,6 +123,37 @@
 	return usf;
 }
 
+struct msgb *sched_app_info(struct gprs_rlcmac_tbf *tbf) {
+	struct gprs_rlcmac_ms *ms_data;
+	struct gprs_rlcmac_bts *bts_data;
+	struct msgb *msg = NULL;
+
+	if (!tbf || !tbf->ms()->ms_data()->app_info_send)
+		return NULL;
+
+	ms_data = tbf->ms()->ms_data();
+	bts_data = BTS::main_bts()->bts_data();
+
+	if (bts_data->app_info) {
+		LOGP(DRLCMACSCHED, LOGL_DEBUG, "Sending Packet Application Information message\n");
+		msg = msgb_copy(bts_data->app_info, "app_info_msg_sched");
+	}
+	else
+		LOGP(DRLCMACSCHED, LOGL_ERROR, "MS has app_info_send flag set, but no Packet Application Information"
+		     " message stored in BTS!\n");
+
+	ms_data->app_info_send = false;
+	bts_data->app_info_todo--;
+
+	if (!bts_data->app_info_todo) {
+		LOGP(DRLCMACSCHED, LOGL_DEBUG, "Packet Application Information successfully sent to all MS with active"
+		     " TBF\n");
+		msgb_free(bts_data->app_info);
+		bts_data->app_info = NULL;
+	}
+	return msg;
+}
+
 static struct msgb *sched_select_ctrl_msg(
 		    uint8_t trx, uint8_t ts, uint32_t fn,
 		    uint8_t block_nr, struct gprs_rlcmac_pdch *pdch,
@@ -134,37 +165,42 @@
 	struct gprs_rlcmac_tbf *tbf = NULL;
 	struct gprs_rlcmac_tbf *next_list[3] = { ul_ass_tbf, dl_ass_tbf, ul_ack_tbf };
 
-	for (size_t i = 0; i < ARRAY_SIZE(next_list); ++i) {
-		tbf = next_list[(pdch->next_ctrl_prio + i) % 3];
-		if (!tbf)
-			continue;
+	/* Send Packet Application Information first (ETWS primary notifications) */
+	msg = sched_app_info(dl_ass_tbf);
 
-		/*
-		 * Assignments for the same direction have lower precedence,
-		 * because they may kill the TBF when the CONTROL ACK is
-		 * received, thus preventing the others from being processed.
-		 */
-		if (tbf == ul_ass_tbf && tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
-			msg = ul_ass_tbf->create_packet_access_reject();
-		else if (tbf == ul_ass_tbf && tbf->direction ==
-				GPRS_RLCMAC_DL_TBF)
-			if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
+	if (!msg) {
+		for (size_t i = 0; i < ARRAY_SIZE(next_list); ++i) {
+			tbf = next_list[(pdch->next_ctrl_prio + i) % 3];
+			if (!tbf)
+				continue;
+
+			/*
+			 * Assignments for the same direction have lower precedence,
+			 * because they may kill the TBF when the CONTROL ACK is
+			 * received, thus preventing the others from being processed.
+			 */
+			if (tbf == ul_ass_tbf && tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
 				msg = ul_ass_tbf->create_packet_access_reject();
-			else
-				msg = ul_ass_tbf->create_ul_ass(fn, ts);
-		else if (tbf == dl_ass_tbf && tbf->direction == GPRS_RLCMAC_UL_TBF)
-			msg = dl_ass_tbf->create_dl_ass(fn, ts);
-		else if (tbf == ul_ack_tbf)
-			msg = ul_ack_tbf->create_ul_ack(fn, ts);
+			else if (tbf == ul_ass_tbf && tbf->direction ==
+					GPRS_RLCMAC_DL_TBF)
+				if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
+					msg = ul_ass_tbf->create_packet_access_reject();
+				else
+					msg = ul_ass_tbf->create_ul_ass(fn, ts);
+			else if (tbf == dl_ass_tbf && tbf->direction == GPRS_RLCMAC_UL_TBF)
+				msg = dl_ass_tbf->create_dl_ass(fn, ts);
+			else if (tbf == ul_ack_tbf)
+				msg = ul_ack_tbf->create_ul_ack(fn, ts);
 
-		if (!msg) {
-			tbf = NULL;
-			continue;
+			if (!msg) {
+				tbf = NULL;
+				continue;
+			}
+
+			pdch->next_ctrl_prio += 1;
+			pdch->next_ctrl_prio %= 3;
+			break;
 		}
-
-		pdch->next_ctrl_prio += 1;
-		pdch->next_ctrl_prio %= 3;
-		break;
 	}
 
 	if (!msg) {
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index da85df4..90df70d 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -620,6 +620,42 @@
 	return bssgp_tx_suspend(bctx->nsei, susp_req->tlli, &ra_id);
 }
 
+static int pcu_rx_app_info_req(struct gsm_pcu_if_app_info_req *app_info_req)
+{
+	LListHead<GprsMs> *ms_iter;
+	BTS *bts = BTS::main_bts();
+	struct gprs_rlcmac_bts *bts_data = bts->bts_data();
+
+	LOGP(DL1IF, LOGL_DEBUG, "Application Information Request received: type=0x%08x len=%i\n",
+	     app_info_req->application_type, app_info_req->len);
+
+	bts_data->app_info_todo = 0;
+	llist_for_each(ms_iter, &bts->ms_store().ms_list()) {
+		GprsMs *ms = ms_iter->entry();
+		if (!ms->dl_tbf())
+			continue;
+		bts_data->app_info_todo++;
+		ms->ms_data()->app_info_send = true;
+	}
+
+	if (!bts_data->app_info_todo) {
+		LOGP(DL1IF, LOGL_NOTICE, "Packet Application Information will not be sent, no subscribers with active"
+		     " TBF\n");
+		return -1;
+	}
+
+	if (bts_data->app_info) {
+		LOGP(DL1IF, LOGL_NOTICE, "Previous Packet Application Information was not sent to all subscribers,"
+		     " overwriting with new one\n");
+		msgb_free(bts_data->app_info);
+	}
+
+	LOGP(DL1IF, LOGL_INFO, "Sending Packet Application Information to %i subscribers with active TBF\n",
+	     bts_data->app_info_todo);
+	bts_data->app_info = gprs_rlcmac_app_info_msg(app_info_req);
+	return 0;
+}
+
 int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim)
 {
 	int rc = 0;
@@ -649,6 +685,9 @@
 	case PCU_IF_MSG_SUSP_REQ:
 		rc = pcu_rx_susp_req(&pcu_prim->u.susp_req);
 		break;
+	case PCU_IF_MSG_APP_INFO_REQ:
+		rc = pcu_rx_app_info_req(&pcu_prim->u.app_info_req);
+		break;
 	default:
 		LOGP(DL1IF, LOGL_ERROR, "Received unknown PCU msg type %d\n",
 			msg_type);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 887200d..42dade9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/ -I$(top_srcdir)/include/
 AM_LDFLAGS = -lrt -no-install
 
-check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest alloc/MslotTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest fn/FnTest
+check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest alloc/MslotTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest fn/FnTest app_info/AppInfoTest
 noinst_PROGRAMS = emu/pcu_emu
 
 rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp
@@ -108,6 +108,14 @@
 	$(LIBOSMOCORE_LIBS) \
 	$(COMMON_LA)
 
+app_info_AppInfoTest_SOURCES = app_info/AppInfoTest.cpp
+app_info_AppInfoTest_LDADD = \
+	$(top_builddir)/src/libgprs.la \
+	$(LIBOSMOGB_LIBS) \
+	$(LIBOSMOGSM_LIBS) \
+	$(LIBOSMOCORE_LIBS) \
+	$(COMMON_LA)
+
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
 	:;{ \
@@ -138,7 +146,8 @@
 	llist/LListTest.ok llist/LListTest.err \
 	codel/codel_test.ok \
 	edge/EdgeTest.ok \
-	fn/FnTest.ok
+	fn/FnTest.ok \
+	app_info/AppInfoTest.ok app_info/AppInfoTest.err
 
 DISTCLEANFILES = atconfig
 
diff --git a/tests/app_info/AppInfoTest.cpp b/tests/app_info/AppInfoTest.cpp
new file mode 100644
index 0000000..eb73067
--- /dev/null
+++ b/tests/app_info/AppInfoTest.cpp
@@ -0,0 +1,181 @@
+/* Copyright (C) 2019 by sysmocom - s.f.m.c. GmbH <info at sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <cstdlib>
+#include <cstring>
+#include <assert.h>
+#include "gprs_rlcmac.h"
+#include "bts.h"
+
+extern "C" {
+#include <osmocom/vty/telnet_interface.h>
+#include <osmocom/vty/logging.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/application.h>
+}
+
+using namespace std;
+gprs_rlcmac_dl_tbf *tbf1, *tbf2;
+GprsMs *ms1, *ms2;
+struct msgb *sched_app_info(struct gprs_rlcmac_tbf *tbf);
+
+/* globals used by the code */
+void *tall_pcu_ctx;
+int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
+
+void test_enc_zero_len() {
+	struct gsm_pcu_if_app_info_req req = {0, 0, {0}};
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+	assert(gprs_rlcmac_app_info_msg(&req) == NULL);
+	fprintf(stderr, "\n");
+}
+
+void test_enc() {
+	struct gsm_pcu_if_app_info_req req = {0, 15, {0xff, 0x00, 0xff}};
+	const char *exp = "03 fc 03 fc 00 00 00 00 00 00 00 00 00 00 00 00 "; /* shifted by two bits to the right */
+	struct msgb *msg;
+	char *msg_dump;
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+	msg = gprs_rlcmac_app_info_msg(&req);
+	msg_dump = msgb_hexdump_c(tall_pcu_ctx, msg);
+
+	fprintf(stderr, "exp: %s\n", exp);
+	fprintf(stderr, "msg: %s\n", msg_dump);
+	assert(strcmp(msg_dump, exp) == 0);
+
+	msgb_free(msg);
+	talloc_free(msg_dump);
+	fprintf(stderr, "\n");
+}
+
+void test_pcu_rx_no_subscr_with_active_tbf()
+{
+	struct gsm_pcu_if pcu_prim = {PCU_IF_MSG_APP_INFO_REQ, };
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+	pcu_rx(PCU_IF_MSG_APP_INFO_REQ, &pcu_prim);
+	fprintf(stderr, "\n");
+}
+
+void prepare_bts_with_two_dl_tbf_subscr()
+{
+	BTS *bts = BTS::main_bts();
+	struct gprs_rlcmac_bts *bts_data;
+	struct gprs_rlcmac_trx *trx;
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+
+	bts_data = bts->bts_data();
+	bts_data->alloc_algorithm = alloc_algorithm_b;
+
+	trx = bts_data->trx;
+	trx->pdch[4].enable();
+	trx->pdch[5].enable();
+	trx->pdch[6].enable();
+	trx->pdch[7].enable();
+
+	ms1 = bts->ms_alloc(10, 11);
+	tbf1 = tbf_alloc_dl_tbf(bts_data, ms1, 0, 10, 11, false);
+	ms2 = bts->ms_alloc(12, 13);
+	tbf2 = tbf_alloc_dl_tbf(bts_data, ms2, 0, 12, 13, false);
+
+	fprintf(stderr, "\n");
+}
+
+void test_sched_app_info_ok()
+{
+	struct gsm_pcu_if pcu_prim = {PCU_IF_MSG_APP_INFO_REQ, };
+	struct msgb *msg;
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+	pcu_prim.u.app_info_req = {0, 15, {0xff, 0x00, 0xff}};
+	pcu_rx(PCU_IF_MSG_APP_INFO_REQ, &pcu_prim);
+
+	msg = sched_app_info(tbf1);
+	assert(msg);
+	msgb_free(msg);
+
+	msg = sched_app_info(tbf2);
+	assert(msg);
+	msgb_free(msg);
+
+	fprintf(stderr, "\n");
+}
+
+void test_sched_app_info_missing_app_info_in_bts()
+{
+	struct gprs_rlcmac_bts *bts_data = BTS::main_bts()->bts_data();
+	struct gsm_pcu_if pcu_prim = {PCU_IF_MSG_APP_INFO_REQ, };
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+	pcu_prim.u.app_info_req = {0, 15, {0xff, 0x00, 0xff}};
+	pcu_rx(PCU_IF_MSG_APP_INFO_REQ, &pcu_prim);
+
+	msgb_free(bts_data->app_info);
+	bts_data->app_info = NULL;
+
+	assert(sched_app_info(tbf1) == NULL);
+
+	fprintf(stderr, "\n");
+}
+
+void test_pcu_rx_overwrite_app_info()
+{
+	struct gsm_pcu_if pcu_prim = {PCU_IF_MSG_APP_INFO_REQ, };
+
+	fprintf(stderr, "--- %s ---\n",  __func__);
+	pcu_prim.u.app_info_req = {0, 15, {0xff, 0x00, 0xff}};
+	pcu_rx(PCU_IF_MSG_APP_INFO_REQ, &pcu_prim);
+	pcu_rx(PCU_IF_MSG_APP_INFO_REQ, &pcu_prim);
+	fprintf(stderr, "\n");
+}
+
+void cleanup()
+{
+	fprintf(stderr, "--- %s ---\n",  __func__);
+
+	BTS::main_bts()->cleanup();
+	talloc_free(tbf1);
+	talloc_free(tbf2);
+	/* FIXME: talloc report disabled, because bts->ms_alloc() in prepare_bts_with_two_dl_tbf_subscr() causes leak */
+	/* talloc_report_full(tall_pcu_ctx, stderr); */
+	talloc_free(tall_pcu_ctx);
+}
+
+int main(int argc, char *argv[])
+{
+	tall_pcu_ctx = talloc_named_const(NULL, 1, "AppInfoTest");
+	osmo_init_logging2(tall_pcu_ctx, &gprs_log_info);
+	log_set_use_color(osmo_stderr_target, 0);
+	log_set_print_filename(osmo_stderr_target, 0);
+	log_parse_category_mask(osmo_stderr_target, "DL1IF,1:DRLCMAC,3:DRLCMACSCHED,1");
+
+	test_enc_zero_len();
+	test_enc();
+	test_pcu_rx_no_subscr_with_active_tbf();
+
+	prepare_bts_with_two_dl_tbf_subscr();
+	test_sched_app_info_ok();
+	test_sched_app_info_missing_app_info_in_bts();
+	test_pcu_rx_overwrite_app_info();
+
+	cleanup();
+}
diff --git a/tests/app_info/AppInfoTest.err b/tests/app_info/AppInfoTest.err
new file mode 100644
index 0000000..9c89094
--- /dev/null
+++ b/tests/app_info/AppInfoTest.err
@@ -0,0 +1,50 @@
+--- test_enc_zero_len ---
+Application Information Request with zero length received!
+
+--- test_enc ---
+exp: 03 fc 03 fc 00 00 00 00 00 00 00 00 00 00 00 00 
+msg: 03 fc 03 fc 00 00 00 00 00 00 00 00 00 00 00 00 
+
+--- test_pcu_rx_no_subscr_with_active_tbf ---
+Application Information Request received: type=0x00000000 len=0
+Packet Application Information will not be sent, no subscribers with active TBF
+
+--- prepare_bts_with_two_dl_tbf_subscr ---
+Creating MS object, TLLI = 0x00000000
+Modifying MS object, TLLI = 0x00000000, MS class 0 -> 10
+Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 11
+[DL] algo B <multi> (suggested TRX: 0): using 4 slots
+PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001.
+PDCH(TS 5, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001.
+PDCH(TS 6, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001.
+PDCH(TS 7, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001.
+Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL)
+Creating MS object, TLLI = 0x00000000
+Modifying MS object, TLLI = 0x00000000, MS class 0 -> 12
+Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 13
+[DL] algo B <multi> (suggested TRX: 0): using 3 slots
+PDCH(TS 4, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000003.
+PDCH(TS 5, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000003.
+PDCH(TS 6, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000003.
+Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL)
+
+--- test_sched_app_info_ok ---
+Application Information Request received: type=0x00000000 len=15
+Sending Packet Application Information to 2 subscribers with active TBF
+Sending Packet Application Information message
+Sending Packet Application Information message
+Packet Application Information successfully sent to all MS with active TBF
+
+--- test_sched_app_info_missing_app_info_in_bts ---
+Application Information Request received: type=0x00000000 len=15
+Sending Packet Application Information to 2 subscribers with active TBF
+MS has app_info_send flag set, but no Packet Application Information message stored in BTS!
+
+--- test_pcu_rx_overwrite_app_info ---
+Application Information Request received: type=0x00000000 len=15
+Sending Packet Application Information to 2 subscribers with active TBF
+Application Information Request received: type=0x00000000 len=15
+Previous Packet Application Information was not sent to all subscribers, overwriting with new one
+Sending Packet Application Information to 2 subscribers with active TBF
+
+--- cleanup ---
diff --git a/tests/app_info/AppInfoTest.ok b/tests/app_info/AppInfoTest.ok
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/app_info/AppInfoTest.ok
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 86f45a8..09b0247 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -82,3 +82,10 @@
 cat $abs_srcdir/fn/FnTest.ok > expout
 AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/fn/FnTest], [0], [expout], [ignore])
 AT_CLEANUP
+
+AT_SETUP([app_info])
+AT_KEYWORDS([app_info])
+cat $abs_srcdir/app_info/AppInfoTest.ok > expout
+cat $abs_srcdir/app_info/AppInfoTest.err > experr
+AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/app_info/AppInfoTest], [0], [expout], [experr])
+AT_CLEANUP

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ie35959f833f46bde5f2126314b6f96763f863b36
Gerrit-Change-Number: 15459
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190909/edc8fc2e/attachment.htm>


More information about the gerrit-log mailing list