aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2023-09-09 00:19:33 +0700
committerfixeria <vyanitskiy@sysmocom.de>2023-09-13 10:40:45 +0000
commitc3446ef49e90c1a9e8aad3b888e37f58ddcd968d (patch)
tree376a7c94734a9b557e5bb644184b444d8b44e75b
parent9e1b54254c505f8ce54e623d06ce2da900b16494 (diff)
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
-rw-r--r--include/osmocom/bsc/abis_nm.h3
-rw-r--r--src/osmo-bsc/abis_nm.c7
-rw-r--r--src/osmo-bsc/nm_bb_transc_fsm.c2
-rw-r--r--src/osmo-bsc/nm_bts_fsm.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/include/osmocom/bsc/abis_nm.h b/include/osmocom/bsc/abis_nm.h
index bfafa63ed..7f1ec7447 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 1b544feb5..90b28eb50 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 @@ static int parse_attr_resp_info_attr(struct gsm_bts *bts, const struct gsm_bts_t
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 @@ static int parse_attr_resp_info_attr(struct gsm_bts *bts, const struct gsm_bts_t
/* 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 @@ static int abis_nm_rx_sw_act_req(struct msgb *mb)
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 4b5e2b24d..b68dc6720 100644
--- a/src/osmo-bsc/nm_bb_transc_fsm.c
+++ b/src/osmo-bsc/nm_bb_transc_fsm.c
@@ -111,7 +111,7 @@ static void configure_loop(struct gsm_bts_bb_trx *bb_transc, const struct gsm_nm
/* 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 a9b6604b5..544efb413 100644
--- a/src/osmo-bsc/nm_bts_fsm.c
+++ b/src/osmo-bsc/nm_bts_fsm.c
@@ -98,7 +98,7 @@ static void configure_loop(struct gsm_bts *bts, const struct gsm_nm_state *state
/* 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;