aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-11-08 16:43:09 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-11-09 15:50:44 +0000
commit1cdf1d76ae63b1491c1d3277b707464a16eeac70 (patch)
tree63fe801b44c009c6aa36b2cfb97ed3a0f45df1c7
parent6597b54bd5b1ac6daeb14549cc38a34870f30c4d (diff)
abis_nm: Add support to parse OML IP and Unit Id in Get Attributes
-rw-r--r--include/osmocom/bsc/abis_nm.h2
-rw-r--r--src/osmo-bsc/abis_nm.c47
2 files changed, 49 insertions, 0 deletions
diff --git a/include/osmocom/bsc/abis_nm.h b/include/osmocom/bsc/abis_nm.h
index ef9e4f5fc..45bbe2c02 100644
--- a/include/osmocom/bsc/abis_nm.h
+++ b/include/osmocom/bsc/abis_nm.h
@@ -67,6 +67,8 @@ struct abis_nm_cfg {
extern int abis_nm_rcvmsg(struct msgb *msg);
int abis_nm_tlv_parse(struct tlv_parsed *tp, struct gsm_bts *bts, const uint8_t *buf, int len);
+int abis_nm_tlv_attr_primary_oml(struct tlv_parsed *tp, struct in_addr *ia, uint16_t *oml_port);
+int abis_nm_tlv_attr_unit_id(struct tlv_parsed *tp, char* unit_id, size_t buf_len);
int abis_nm_rx(struct msgb *msg);
int abis_nm_opstart(struct gsm_bts *bts, uint8_t obj_class, uint8_t i0, uint8_t i1, uint8_t i2);
int abis_nm_chg_adm_state(struct gsm_bts *bts, uint8_t obj_class, uint8_t i0,
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 005c417a8..89a6d82d4 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -64,6 +64,39 @@ int abis_nm_tlv_parse(struct tlv_parsed *tp, struct gsm_bts *bts, const uint8_t
return tlv_parse(tp, &bts->model->nm_att_tlvdef, buf, len, 0, 0);
}
+/* Parse OML Primary IP and port from tlv_parsed containing list of Reported Attributes */
+int abis_nm_tlv_attr_primary_oml(struct tlv_parsed *tp, struct in_addr *ia, uint16_t *oml_port)
+{
+ const uint8_t* data;
+ if (TLVP_PRES_LEN(tp, NM_ATT_IPACC_PRIM_OML_CFG_LIST, 7)) {
+ data = TLVP_VAL(tp, NM_ATT_IPACC_PRIM_OML_CFG_LIST);
+ if (NM_ATT_IPACC_PRIM_OML_CFG == *data) {
+ ia->s_addr = htonl(osmo_load32be(data+1));
+ *oml_port = osmo_load16be(data+5);
+ return 0;
+ }else {
+ LOGP(DNM, LOGL_ERROR,
+ "Get Attributes Response: PRIM_OML_CFG_LIST has unexpected format: %s\n",
+ osmo_hexdump(data, TLVP_LEN(tp, NM_ATT_IPACC_PRIM_OML_CFG_LIST)));
+ }
+ }
+ return -1;
+}
+
+/* Parse OML Primary IP and port from tlv_parsed containing list of Reported Attributes */
+int abis_nm_tlv_attr_unit_id(struct tlv_parsed *tp, char* unit_id, size_t buf_len)
+{
+ const uint8_t* data;
+ uint16_t len;
+ if (TLVP_PRES_LEN(tp, NM_ATT_IPACC_UNIT_ID, 1)) {
+ data = TLVP_VAL(tp, NM_ATT_IPACC_UNIT_ID);
+ len = TLVP_LEN(tp, NM_ATT_IPACC_UNIT_ID);
+ osmo_strlcpy(unit_id, (char*)data, OSMO_MIN(len, buf_len));
+ return 0;
+ }
+ return -1;
+}
+
static int is_in_arr(enum abis_nm_msgtype mt, const enum abis_nm_msgtype *arr, int size)
{
int i;
@@ -473,6 +506,9 @@ static int parse_attr_resp_info_attr(struct gsm_bts *bts, const struct gsm_bts_t
uint16_t len;
int i;
int rc;
+ uint16_t port;
+ struct in_addr ia = {0};
+ char unit_id[40];
struct abis_nm_sw_desc sw_descr[MAX_BTS_ATTR];
/* Parse Attribute Response Info content for 3GPP TS 52.021 ยง9.4.30 Manufacturer Id */
@@ -528,6 +564,17 @@ static int parse_attr_resp_info_attr(struct gsm_bts *bts, const struct gsm_bts_t
}
}
+ if (abis_nm_tlv_attr_primary_oml(tp, &ia, &port) == 0) {
+ LOGPFOH(DNM, LOGL_NOTICE, foh,
+ "BTS%u Get Attributes Response: Primary OML IP is %s:%u\n",
+ bts->nr, inet_ntoa(ia), port);
+ }
+
+ if (abis_nm_tlv_attr_unit_id(tp, unit_id, sizeof(unit_id)) == 0) {
+ LOGPFOH(DNM, LOGL_NOTICE, foh, "BTS%u Get Attributes Response: Unit ID is %s\n",
+ bts->nr, unit_id);
+ }
+
return 0;
}