Change in libosmocore[master]: gsm: Introduce API osmo_gsm48_rest_octets_si13_decode

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

pespin gerrit-no-reply at lists.osmocom.org
Tue Feb 9 18:52:59 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22800 )


Change subject: gsm: Introduce API osmo_gsm48_rest_octets_si13_decode
......................................................................

gsm: Introduce API osmo_gsm48_rest_octets_si13_decode

Related: SYS#5358
Change-Id: I74fb0a3afc1ac4aadbfc609b882d929401f790eb
---
M include/osmocom/gsm/gsm48_rest_octets.h
M src/gsm/gsm48_rest_octets.c
M src/gsm/libosmogsm.map
3 files changed, 131 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/00/22800/1

diff --git a/include/osmocom/gsm/gsm48_rest_octets.h b/include/osmocom/gsm/gsm48_rest_octets.h
index 8f143be..f295824 100644
--- a/include/osmocom/gsm/gsm48_rest_octets.h
+++ b/include/osmocom/gsm/gsm48_rest_octets.h
@@ -120,7 +120,8 @@
 	uint8_t prio_acc_thr;
 };
 
-/* Generate SI13 Rest Octests (Chapter 10.5.2.37b) */
+/* Parse/Generate SI13 Rest Octests (Chapter 10.5.2.37b) */
+int osmo_gsm48_rest_octets_si13_decode(struct osmo_gsm48_si13_info *si13, const uint8_t *data);
 int osmo_gsm48_rest_octets_si13_encode(uint8_t *data, const struct osmo_gsm48_si13_info *si13);
 
 /* Parse SI3 Rest Octets */
diff --git a/src/gsm/gsm48_rest_octets.c b/src/gsm/gsm48_rest_octets.c
index 1bab8e0..79ee0d9 100644
--- a/src/gsm/gsm48_rest_octets.c
+++ b/src/gsm/gsm48_rest_octets.c
@@ -749,6 +749,134 @@
 	return bv.data_len;
 }
 
+
+static int decode_t3192(unsigned int t3192)
+{
+	/* See also 3GPP TS 44.060
+	   Table 12.24.2: GPRS Cell Options information element details */
+
+	switch (t3192) {
+	case 0: return 500;
+	case 1: return 1000;
+	case 2: return 1500;
+	case 3: return 0;
+	case 4: return 80;
+	case 5: return 120;
+	case 6: return 160;
+	case 7: return 200;
+	default:
+		OSMO_ASSERT(t3192 <= 7);
+		return 0;
+	}
+}
+
+static int decode_drx_timer(unsigned int drx)
+{
+	switch (drx) {
+	case 0: return 0;
+	case 1: return 1;
+	case 2: return 2;
+	case 3: return 4;
+	case 4: return 8;
+	case 5: return 16;
+	case 6: return 32;
+	case 7: return 64;
+	default:
+		OSMO_ASSERT(drx <= 7);
+		return 0;
+	}
+}
+
+static void decode_gprs_cell_opt(struct osmo_gprs_cell_options *gco, struct bitvec *bv)
+{
+	gco->nmo = bitvec_get_uint(bv, 2);
+	gco->t3168 = (bitvec_get_uint(bv, 3) + 1) * 500;
+	gco->t3192 = decode_t3192(bitvec_get_uint(bv, 3));
+	gco->drx_timer_max = decode_drx_timer(bitvec_get_uint(bv, 3));
+
+	/* ACCESS_BURST_TYPE: */
+	bitvec_get_uint(bv, 1);
+	/* CONTROL_ACK_TYPE: */
+	gco->ctrl_ack_type_use_block = bitvec_get_uint(bv, 1);
+	gco->bs_cv_max = bitvec_get_uint(bv, 4);
+
+	if (bitvec_get_uint(bv, 1)) {
+		bitvec_get_uint(bv, 3);	/* DEC */
+		bitvec_get_uint(bv, 3);	/* INC */
+		bitvec_get_uint(bv, 3);	/* MAX */
+	}
+
+	if (bitvec_get_uint(bv, 1)) {
+		uint8_t ext_len = bitvec_get_uint(bv, 6);
+		unsigned int cur_bit = bv->cur_bit;
+		/* Extension Information */
+		/* R99 extension: */
+		gco->ext_info.egprs_supported = bitvec_get_uint(bv, 1);
+		if (gco->ext_info.egprs_supported) {
+			gco->ext_info.use_egprs_p_ch_req = !bitvec_get_uint(bv, 1);
+			gco->ext_info.bep_period = bitvec_get_uint(bv, 4);
+		}
+		gco->ext_info.pfc_supported = bitvec_get_uint(bv, 1);
+		gco->ext_info.dtm_supported = bitvec_get_uint(bv, 1);
+		gco->ext_info.bss_paging_coordination = bitvec_get_uint(bv, 1);
+		/* REL-4 extension: */
+		gco->ext_info.ccn_active = bitvec_get_uint(bv, 1);
+		bitvec_get_uint(bv, 1); /* NW_EXT_UTBF */
+		bv->cur_bit = cur_bit + ext_len + 1;
+	}
+}
+
+static void decode_gprs_pwr_ctrl_pars(struct osmo_gprs_power_ctrl_pars *pcp, struct bitvec *bv)
+{
+	pcp->alpha = bitvec_get_uint(bv, 4);
+	pcp->t_avg_w = bitvec_get_uint(bv,5);
+	pcp->t_avg_t = bitvec_get_uint(bv, 5);
+	pcp->pc_meas_chan = bitvec_get_uint(bv, 1);
+	pcp->n_avg_i = bitvec_get_uint(bv, 4);
+}
+
+/*! Decode SI13 Rest Octests (04.08 Chapter 10.5.2.37b).
+ *  \param[out] si13 decoded SI13 rest octets
+ *  \param[in] encoded SI13 rest octets
+*  \returns parsed bits on success, negative on error */
+int osmo_gsm48_rest_octets_si13_decode(struct osmo_gsm48_si13_info *si13, const uint8_t *data)
+{
+	struct osmo_gprs_cell_options *co = &si13->cell_opts;
+	struct osmo_gprs_power_ctrl_pars *pcp = &si13->pwr_ctrl_pars;
+	struct bitvec bv;
+
+	memset(&bv, 0, sizeof(bv));
+	bv.data = (uint8_t *) data;
+	bv.data_len = 20;
+
+	memset(si13, 0, sizeof(*si13));
+
+
+	if (bitvec_get_bit_high(&bv) == H) {
+		si13->bcch_change_mark = bitvec_get_uint(&bv, 3);
+		si13->si_change_field = bitvec_get_uint(&bv, 4);
+		if (bitvec_get_uint(&bv, 1)) {
+			si13->bcch_change_mark = bitvec_get_uint(&bv, 2);
+			/* FIXME: implement parsing GPRS Mobile Allocation IE */
+			return -1;
+		}
+		if (bitvec_get_uint(&bv, 1)) {
+			/* PBCCH present in cell */
+			/* FIXME: parse not implemented */
+			return -1;
+		} else {
+			/* PBCCH not present in cell */
+			si13->rac = bitvec_get_uint(&bv, 8);
+			si13->spgc_ccch_sup = bitvec_get_uint(&bv, 1);
+			si13->prio_acc_thr = bitvec_get_uint(&bv, 3);
+			si13->net_ctrl_ord = bitvec_get_uint(&bv, 2);
+			decode_gprs_cell_opt(co, &bv);
+			decode_gprs_pwr_ctrl_pars(pcp, &bv);
+		}
+	}
+	return bv.cur_bit;
+}
+
 /* GPRS Mobile Allocation as per TS 04.60 Chapter 12.10a:
    < GPRS Mobile Allocation IE > ::=
      < HSN : bit (6) >
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index efa23e6..0ea0678 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -320,6 +320,7 @@
 osmo_gsm48_rest_octets_si6_encode;
 osmo_gsm48_rest_octets_si3_encode;
 osmo_gsm48_rest_octets_si4_encode;
+osmo_gsm48_rest_octets_si13_decode;
 osmo_gsm48_rest_octets_si13_encode;
 osmo_gsm48_rest_octets_si3_decode;
 osmo_gsm48_rest_octets_si4_decode;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I74fb0a3afc1ac4aadbfc609b882d929401f790eb
Gerrit-Change-Number: 22800
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210209/201a1fa5/attachment.htm>


More information about the gerrit-log mailing list