From 1cdf1d76ae63b1491c1d3277b707464a16eeac70 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 8 Nov 2018 16:43:09 +0100 Subject: abis_nm: Add support to parse OML IP and Unit Id in Get Attributes Change-Id: Ia05e0b8fe3e28aaf2b2253d018f0614e83e23caa --- src/osmo-bsc/abis_nm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src') 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; } -- cgit v1.2.3