Change in osmo-bsc[master]: abis_nm: Split attr parsing in Attribute Response Info into its own func

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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Nov 8 16:05:11 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/11693


Change subject: abis_nm: Split attr parsing in Attribute Response Info into its own func
......................................................................

abis_nm: Split attr parsing in Attribute Response Info into its own func

nanoBTS uses same format for the attribute list from Attribute Response
Info, but without using the later as an evelope. By splitting we can
later reuse the code handling the Attribute list.

While at it, take the chance to remove functions parse_attr_resp_info_*
which expect TLVs following an specific order, which is not mandatory.

Related: OS#3624
Change-Id: Iec7a6e4d27639d0e5adc0d9a01cd3c3e7a46f558
---
M src/osmo-bsc/abis_nm.c
1 file changed, 39 insertions(+), 51 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/93/11693/1

diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index aec4a58..20f5156 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -466,16 +466,18 @@
 	return ari + num_unreported + 1; /* we have to account for 1st byte with number of unreported attributes */
 }
 
-/* Parse Attribute Response Info content for 3GPP TS 52.021 §9.4.30 Manufacturer Id */
-static inline const uint8_t *parse_attr_resp_info_manuf_id(struct gsm_bts *bts, const uint8_t *data, uint16_t *data_len)
+/* Handle 3GPP TS 52.021 §8.11.3 Get Attribute Response (with nanoBTS speecific attribute formatting) */
+static int parse_attr_resp_info_attr(struct gsm_bts *bts, const struct gsm_bts_trx *trx, struct abis_om_fom_hdr *foh, struct tlv_parsed *tp)
 {
-	struct tlv_parsed tp;
-	uint16_t len = 0;
-	uint8_t adjust = 0, i;
+	const uint8_t* data;
+	uint16_t len;
+	int i;
+	int rc;
+	struct abis_nm_sw_desc sw_descr[MAX_BTS_ATTR];
 
-	abis_nm_tlv_parse(&tp, bts, data, *data_len);
-	if (TLVP_PRES_LEN(&tp, NM_ATT_MANUF_ID, 2)) {
-		len = TLVP_LEN(&tp, NM_ATT_MANUF_ID);
+	/* Parse Attribute Response Info content for 3GPP TS 52.021 §9.4.30 Manufacturer Id */
+	if (TLVP_PRES_LEN(tp, NM_ATT_MANUF_ID, 2)) {
+		len = TLVP_LEN(tp, NM_ATT_MANUF_ID);
 
 		/* log potential BTS feature vector overflow */
 		if (len > sizeof(bts->_features_data))
@@ -489,8 +491,7 @@
 			     "Consider upgrading your BSC to later version.\n",
 			     bts->nr, len);
 
-		memcpy(bts->_features_data, TLVP_VAL(&tp, NM_ATT_MANUF_ID), sizeof(bts->_features_data));
-		adjust = len + 3; /* adjust for parsed TL16V struct */
+		memcpy(bts->_features_data, TLVP_VAL(tp, NM_ATT_MANUF_ID), sizeof(bts->_features_data));
 
 		for (i = 0; i < _NUM_BTS_FEAT; i++)
 			if (osmo_bts_has_feature(&bts->features, i) != osmo_bts_has_feature(&bts->model->features, i))
@@ -500,41 +501,41 @@
 				     osmo_bts_has_feature(&bts->features, i), osmo_bts_has_feature(&bts->model->features, i));
 	}
 
-	*data_len -= adjust;
-
-	return data + adjust;
-}
-
-/* Parse Attribute Response Info content for 3GPP TS 52.021 §9.4.28 Manufacturer Dependent State */
-static inline const uint8_t *parse_attr_resp_info_manuf_state(const struct gsm_bts_trx *trx, const uint8_t *data, uint16_t *data_len)
-{
-	struct tlv_parsed tp;
-	const uint8_t *power;
-	uint8_t adjust = 0;
-
-	if (!trx) /* this attribute does not make sense on BTS level, only on TRX level */
-		return data;
-
-	abis_nm_tlv_parse(&tp, trx->bts, data, *data_len);
-	if (TLVP_PRES_LEN(&tp, NM_ATT_MANUF_STATE, 1)) {
-		power = TLVP_VAL(&tp, NM_ATT_MANUF_STATE);
-		LOGP(DNM, LOGL_NOTICE, "%s Get Attributes Response: nominal power is %u\n", gsm_trx_name(trx), *power);
-		adjust = 2; /* adjust for parsed TV struct */
+	/* Parse Attribute Response Info content for 3GPP TS 52.021 §9.4.28 Manufacturer Dependent State */
+	/* this attribute does not make sense on BTS level, only on TRX level */
+	if (trx && TLVP_PRES_LEN(tp, NM_ATT_MANUF_STATE, 1)) {
+		data = TLVP_VAL(tp, NM_ATT_MANUF_STATE);
+		LOGPFOH(DNM, LOGL_INFO, foh, "%s Get Attributes Response: nominal power is %u\n", gsm_trx_name(trx), *data);
 	}
 
-	*data_len -= adjust;
+	/* Parse Attribute Response Info content for 3GPP TS 52.021 §9.4.61 SW Configuration */
+	if (TLVP_PRESENT(tp, NM_ATT_SW_CONFIG)) {
+		data = TLVP_VAL(tp, NM_ATT_SW_CONFIG);
+		len = TLVP_LEN(tp, NM_ATT_SW_CONFIG);
+		/* after parsing manufacturer-specific attributes there's list of replies in form of sw-conf structure: */
+		rc = abis_nm_get_sw_conf(data, len, &sw_descr[0], ARRAY_SIZE(sw_descr));
+		if (rc > 0) {
+			for (i = 0; i < rc; i++) {
+				if (!handle_attr(bts, str2btsattr((const char *)sw_descr[i].file_id),
+						 sw_descr[i].file_version, sw_descr[i].file_version_len))
+					LOGPFOH(DNM, LOGL_NOTICE, foh, "BTS%u: ARI reported sw[%d/%d]: %s "
+						"is %s\n", bts->nr, i, rc, sw_descr[i].file_id,
+						sw_descr[i].file_version);
+			}
+		} else {
+			LOGPFOH(DNM, LOGL_ERROR, foh, "BTS%u: failed to parse SW-Config part of "
+				"Get Attribute Response Info: %s\n", bts->nr, strerror(-rc));
+		}
+	}
 
-	return data + adjust;
+	return 0;
 }
 
 /* Handle 3GPP TS 52.021 §9.4.64 Get Attribute Response Info */
 static int parse_attr_resp_info(struct gsm_bts *bts, const struct gsm_bts_trx *trx, struct abis_om_fom_hdr *foh, struct tlv_parsed *tp)
 {
 	const uint8_t *data;
-	int i;
 	uint16_t data_len;
-	int rc;
-	struct abis_nm_sw_desc sw_descr[MAX_BTS_ATTR];
 
 	if (!TLVP_PRES_LEN(tp, NM_ATT_GET_ARI, 1)) {
 		LOGPFOH(DNM, LOGL_ERROR, foh, "BTS%u: Get Attr Response without Response Info?!\n",
@@ -545,23 +546,10 @@
 	data = parse_attr_resp_info_unreported(bts->nr, TLVP_VAL(tp, NM_ATT_GET_ARI), TLVP_LEN(tp, NM_ATT_GET_ARI),
 					       &data_len);
 
-	data = parse_attr_resp_info_manuf_state(trx, data, &data_len);
-	data = parse_attr_resp_info_manuf_id(bts, data, &data_len);
+	/* After parsing unreported part of Response info, there's a TLV of attr, same as per nanoBTS */
+	abis_nm_tlv_parse(tp, bts, data, data_len);
+	parse_attr_resp_info_attr(bts, trx, foh, tp);
 
-	/* after parsing manufacturer-specific attributes there's list of replies in form of sw-conf structure: */
-	rc = abis_nm_get_sw_conf(data, data_len, &sw_descr[0], ARRAY_SIZE(sw_descr));
-	if (rc > 0) {
-		for (i = 0; i < rc; i++) {
-			if (!handle_attr(bts, str2btsattr((const char *)sw_descr[i].file_id),
-					 sw_descr[i].file_version, sw_descr[i].file_version_len))
-				LOGPFOH(DNM, LOGL_NOTICE, foh, "BTS%u: ARI reported sw[%d/%d]: %s "
-					"is %s\n", bts->nr, i, rc, sw_descr[i].file_id,
-					sw_descr[i].file_version);
-		}
-	} else {
-		LOGPFOH(DNM, LOGL_ERROR, foh, "BTS%u: failed to parse SW-Config part of "
-			"Get Attribute Response Info: %s\n", bts->nr, strerror(-rc));
-	}
 	return 0;
 }
 

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec7a6e4d27639d0e5adc0d9a01cd3c3e7a46f558
Gerrit-Change-Number: 11693
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181108/25a4dc82/attachment.htm>


More information about the gerrit-log mailing list