fixeria has uploaded this change for review.

View Change

abis_nm: get rid of MAX_BTS_ATTR

This is a partial revert of commit [1], which defined a limit on the
number of attributes and SW Description IEs as a constant and added
a spec. reference. The problem is that there is no such limit in the
referenced 3GPP TS 52.021. The attributes and SW Description IEs are
using TL16V encoding, so there can be as many as the Length part can
represent. It's actually the limitation of our side, since we
allocate a buffer of fixed size on the stack for parsing.

* Remove the MAX_BTS_ATTR and confusing spec. reference.
* For the SW Description IEs, define SW_DESCR_MAX locally.
* For the attributes, define the buffer size in place.

Change-Id: Idd8b971d32cf0f7a910a664d921e644b7c32d831
Related: [1] 1ebf23b7fe "Prepare for BTS attribute reporting via OML"
Related: OS#4505
---
M include/osmocom/bsc/abis_nm.h
M src/osmo-bsc/abis_nm.c
M src/osmo-bsc/nm_bb_transc_fsm.c
M src/osmo-bsc/nm_bts_fsm.c
4 files changed, 30 insertions(+), 7 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/55/34355/1
diff --git a/include/osmocom/bsc/abis_nm.h b/include/osmocom/bsc/abis_nm.h
index bfafa63..7f1ec74 100644
--- a/include/osmocom/bsc/abis_nm.h
+++ b/include/osmocom/bsc/abis_nm.h
@@ -29,9 +29,6 @@
#include <osmocom/bsc/gsm_data.h>
#include <osmocom/bsc/signal.h>

-/* max number of attributes represented as 3GPP TS 52.021 §9.4.62 SW Description array */
-#define MAX_BTS_ATTR 5
-
/* The BCCH info from an ip.access test, in host byte order
* and already parsed... */
struct ipac_bcch_info {
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 1b544fe..90b28eb 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -58,6 +58,9 @@
#define OM_HEADROOM_SIZE 128
#define IPACC_SEGMENT_SIZE 245

+/* max number of SW Description IEs we can parse */
+#define SW_DESCR_MAX 5
+
#define LOGPMO(mo, ss, lvl, fmt, args ...) \
LOGP(ss, lvl, "OC=%s(%02x) INST=(%02x,%02x,%02x): " fmt, \
get_value_string(abis_nm_obj_class_names, (mo)->obj_class), \
@@ -610,7 +613,6 @@
uint16_t port;
struct in_addr ia = {0};
char unit_id[40];
- struct abis_nm_sw_desc sw_descr[MAX_BTS_ATTR];

switch (bts->type) {
case GSM_BTS_TYPE_OSMOBTS:
@@ -638,6 +640,7 @@

/* Parse Attribute Response Info content for 3GPP TS 52.021 §9.4.61 SW Configuration */
if (TLVP_PRESENT(tp, NM_ATT_SW_CONFIG)) {
+ struct abis_nm_sw_desc sw_descr[SW_DESCR_MAX];
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: */
@@ -749,7 +752,7 @@
struct tlv_parsed tp;
const uint8_t *sw_config;
int ret, sw_config_len, len;
- struct abis_nm_sw_desc sw_descr[MAX_BTS_ATTR];
+ struct abis_nm_sw_desc sw_descr[SW_DESCR_MAX];

DEBUGPFOH(DNM, foh, "Software Activate Request, ACKing and Activating\n");

diff --git a/src/osmo-bsc/nm_bb_transc_fsm.c b/src/osmo-bsc/nm_bb_transc_fsm.c
index 4b5e2b2..b68dc67 100644
--- a/src/osmo-bsc/nm_bb_transc_fsm.c
+++ b/src/osmo-bsc/nm_bb_transc_fsm.c
@@ -111,7 +111,7 @@

/* Request TRX-level attributes */
if (!bb_transc->mo.get_attr_sent && !bb_transc->mo.get_attr_rep_received) {
- uint8_t attr_buf[MAX_BTS_ATTR];
+ uint8_t attr_buf[3]; /* enlarge if needed */
uint8_t *ptr = &attr_buf[0];

*(ptr++) = NM_ATT_MANUF_STATE;
diff --git a/src/osmo-bsc/nm_bts_fsm.c b/src/osmo-bsc/nm_bts_fsm.c
index a9b6604..544efb4 100644
--- a/src/osmo-bsc/nm_bts_fsm.c
+++ b/src/osmo-bsc/nm_bts_fsm.c
@@ -98,7 +98,7 @@

/* Request generic BTS-level attributes */
if (!bts->mo.get_attr_sent && !bts->mo.get_attr_rep_received) {
- uint8_t attr_buf[MAX_BTS_ATTR];
+ uint8_t attr_buf[3]; /* enlarge if needed */
uint8_t *ptr = &attr_buf[0];

*(ptr++) = NM_ATT_MANUF_ID;

To view, visit change 34355. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Idd8b971d32cf0f7a910a664d921e644b7c32d831
Gerrit-Change-Number: 34355
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange