Pau Espin Pedrol has submitted this change and it was merged. (
https://gerrit.osmocom.org/11693 )
Change subject: abis_nm: Split reported attr list parsing from Attribute
Response Info into its own func
..
abis_nm: Split reported attr list parsing from 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, 41 insertions(+), 53 deletions(-)
Approvals:
Neels Hofmeyr: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 17c987b..828d567 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 specific
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(, bts, data, *data_len);
- if (TLVP_PRES_LEN(, NM_ATT_MANUF_ID, 2)) {
- len = TLVP_LEN(, 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(, 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(>features, i) !=
osmo_bts_has_feature(>model->features, i))
@@ -500,41 +501,41 @@
osmo_bts_has_feature(>features, i),
osmo_bts_has_feature(>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(, trx->bts, data, *data_len);
- if (TLVP_PRES_LEN(, NM_ATT_MANUF_STATE, 1)) {
- power = TLVP_VAL(, 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_NOTICE, 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, _descr[0],
ARRAY_SIZE(sw_descr));
+ if (rc > 0) {
+