Change in osmo-bts[master]: common/oml.c: use proper OML object for Get Attribute Response

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Thu Apr 18 19:07:20 UTC 2019


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13701


Change subject: common/oml.c: use proper OML object for Get Attribute Response
......................................................................

common/oml.c: use proper OML object for Get Attribute Response

Change-Id: Icb1ee75d4bf680deb6365288d8c2053816a12217
---
M src/common/oml.c
1 file changed, 25 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/01/13701/1

diff --git a/src/common/oml.c b/src/common/oml.c
index f5e50c0..cb1766b 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -252,26 +252,31 @@
 }
 
 /* send 3GPP TS 52.021 §8.11.2 Get Attribute Response */
-static int oml_tx_attr_resp(struct gsm_bts *bts, const struct abis_om_fom_hdr *foh, const uint8_t *attr,
-			    uint16_t attr_len)
+static int oml_tx_attr_resp(const struct gsm_abis_mo *mo,
+			    const uint8_t *attr, uint16_t attr_len)
 {
 	struct msgb *nmsg;
 	uint8_t resp[MAX_VERSION_LENGTH * attr_len * 2]; /* heuristic for Attribute Response Info space requirements */
+	void *obj;
 	int len;
 
 	LOGP(DOML, LOGL_INFO, "%s Tx Get Attribute Response\n",
-	     get_value_string(abis_nm_obj_class_names, foh->obj_class));
+	     get_value_string(abis_nm_obj_class_names, mo->obj_class));
 
-	switch (foh->obj_class) {
+	OSMO_ASSERT(mo->bts != NULL);
+	obj = gsm_objclass2obj(mo->bts, mo->obj_class, &mo->obj_inst);
+	OSMO_ASSERT(obj != NULL);
+
+	switch (mo->obj_class) {
 	case NM_OC_BTS:
-		len = handle_attrs_bts(resp, bts, attr, attr_len);
+		len = handle_attrs_bts(resp, (const struct gsm_bts *) obj, attr, attr_len);
 		break;
 	case NM_OC_BASEB_TRANSC:
-		len = handle_attrs_trx(resp, gsm_bts_trx_num(bts, foh->obj_inst.trx_nr), attr, attr_len);
+		len = handle_attrs_trx(resp, (const struct gsm_bts_trx *) obj, attr, attr_len);
 		break;
 	default:
 		LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute Response\n",
-		     get_value_string(abis_nm_obj_class_names, foh->obj_class));
+		     get_value_string(abis_nm_obj_class_names, mo->obj_class));
 		len = -NM_NACK_OBJCLASS_NOTSUPP;
 	}
 
@@ -287,7 +292,7 @@
 	/* §9.4.64 Get Attribute Response Info */
 	msgb_tl16v_put(nmsg, NM_ATT_GET_ARI, len, resp);
 
-	len = oml_mo_send_msg(&bts->mo, nmsg, NM_MT_GET_ATTR_RESP);
+	len = oml_mo_send_msg(mo, nmsg, NM_MT_GET_ATTR_RESP);
 	return (len < 0) ? -NM_NACK_CANT_PERFORM : len;
 }
 
@@ -527,6 +532,7 @@
 static int oml_rx_get_attr(struct gsm_bts *bts, struct msgb *msg)
 {
 	struct abis_om_fom_hdr *foh = msgb_l3(msg);
+	const struct gsm_abis_mo *mo;
 	struct tlv_parsed tp;
 	int rc;
 
@@ -536,18 +542,26 @@
 	abis_nm_debugp_foh(DOML, foh);
 	DEBUGPC(DOML, "Rx GET ATTR\n");
 
+	/* Determine which OML object is addressed */
+	mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	if (!mo) {
+		LOGP(DOML, LOGL_ERROR, "%s Get Attributes for unknown Object Instance\n",
+		     abis_nm_dump_foh(foh));
+		return oml_fom_ack_nack(msg, NM_NACK_OBJINST_UNKN);
+	}
+
 	rc = oml_tlv_parse(&tp, foh->data, msgb_l3len(msg) - sizeof(*foh));
 	if (rc < 0) {
-		oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_MAJ_UNSUP_ATTR, "Get Attribute parsing failure");
+		oml_tx_failure_event_rep(mo, OSMO_EVT_MAJ_UNSUP_ATTR, "Get Attribute parsing failure");
 		return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
 	}
 
 	if (!TLVP_PRES_LEN(&tp, NM_ATT_LIST_REQ_ATTR, 1)) {
-		oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_MAJ_UNSUP_ATTR, "Get Attribute without Attribute List");
+		oml_tx_failure_event_rep(mo, OSMO_EVT_MAJ_UNSUP_ATTR, "Get Attribute without Attribute List");
 		return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
 	}
 
-	rc = oml_tx_attr_resp(bts, foh, TLVP_VAL(&tp, NM_ATT_LIST_REQ_ATTR), TLVP_LEN(&tp, NM_ATT_LIST_REQ_ATTR));
+	rc = oml_tx_attr_resp(mo, TLVP_VAL(&tp, NM_ATT_LIST_REQ_ATTR), TLVP_LEN(&tp, NM_ATT_LIST_REQ_ATTR));
 	if (rc < 0) {
 		LOGP(DOML, LOGL_ERROR, "responding to O&M Get Attributes message with NACK 0%x\n", -rc);
 		return oml_fom_ack_nack(msg, -rc);

-- 
To view, visit https://gerrit.osmocom.org/13701
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb1ee75d4bf680deb6365288d8c2053816a12217
Gerrit-Change-Number: 13701
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190418/af5ca1b3/attachment.htm>


More information about the gerrit-log mailing list