[MERGED] osmo-bts[master]: OML: move BTS number check into separate function

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Jun 22 10:51:13 UTC 2017


Max has submitted this change and it was merged.

Change subject: OML: move BTS number check into separate function
......................................................................


OML: move BTS number check into separate function

* move code which checks for BTS number (obtained via OML) validity into
  separate function
* adjust log messages to match the check
* add spec reference and comments

Change-Id: Id5714fbed910696d30e18d1f20f4c9fced4b9230
Related: OS#2317
---
M src/common/oml.c
1 file changed, 34 insertions(+), 16 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/oml.c b/src/common/oml.c
index fe35e85..8f23f82 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -1041,6 +1041,38 @@
 	return bts_model_chg_adm_state(bts, mo, obj, adm_state);
 }
 
+/* Check and report if the BTS number received via OML is incorrect:
+   according to 3GPP TS 52.021 §9.3 BTS number is used to distinguish between different BTS of the same Site Manager.
+   As we always have only single BTS per Site Manager (in case of Abis/IP with each BTS having dedicated OML connection
+   to BSC), the only valid values are 0 and 0xFF (means all BTS' of a given Site Manager). */
+static inline bool report_bts_number_incorrect(struct gsm_bts *bts, const struct abis_om_fom_hdr *foh, bool is_formatted)
+{
+	struct gsm_bts_trx *trx;
+	struct gsm_abis_mo *mo = &bts->mo;
+	const char *form = is_formatted ?
+		"Unexpected BTS %d in formatted O&M %s (exp. 0 or 0xFF)" :
+		"Unexpected BTS %d in manufacturer O&M %s (exp. 0 or 0xFF)";
+
+	if (foh->obj_inst.bts_nr != 0 && foh->obj_inst.bts_nr != 0xff) {
+		LOGP(DOML, LOGL_ERROR, form, foh->obj_inst.bts_nr, get_value_string(abis_nm_msgtype_names,
+										    foh->msg_type));
+		LOGPC(DOML, LOGL_ERROR, "\n");
+		trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr);
+		if (trx) {
+			trx->mo.obj_inst.bts_nr = 0;
+			trx->mo.obj_inst.trx_nr = foh->obj_inst.trx_nr;
+			trx->mo.obj_inst.ts_nr = 0xff;
+			mo = &trx->mo;
+		}
+		oml_tx_failure_event_rep(mo, OSMO_EVT_MAJ_UKWN_MSG, form, foh->obj_inst.bts_nr,
+					 get_value_string(abis_nm_msgtype_names, foh->msg_type));
+
+		return true;
+	}
+
+	return false;
+}
+
 static int down_fom(struct gsm_bts *bts, struct msgb *msg)
 {
 	struct abis_om_fom_hdr *foh = msgb_l3(msg);
@@ -1060,20 +1092,8 @@
 		return -EIO;
 	}
 
-	if (foh->obj_inst.bts_nr != 0 && foh->obj_inst.bts_nr != 0xff) {
-		LOGP(DOML, LOGL_INFO, "Formatted O&M with BTS %d out of range.\n", foh->obj_inst.bts_nr);
-		trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr);
-		if (trx) {
-			trx->mo.obj_inst.bts_nr = 0;
-			trx->mo.obj_inst.trx_nr = foh->obj_inst.trx_nr;
-			trx->mo.obj_inst.ts_nr = 0xff;
-			oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_UKWN_MSG,
-						 "Formatted O&M with BTS %d out"
-						 " of range (0:0xFF)",
-						 foh->obj_inst.bts_nr);
-		}
+	if (report_bts_number_incorrect(bts, foh, true))
 		return oml_fom_ack_nack(msg, NM_NACK_BTSNR_UNKN);
-	}
 
 	switch (foh->msg_type) {
 	case NM_MT_SET_BTS_ATTR:
@@ -1363,10 +1383,8 @@
 	msg->l3h = oh->data + 1 + idstrlen;
 	foh = (struct abis_om_fom_hdr *) msg->l3h;
 
-	if (foh->obj_inst.bts_nr != 0 && foh->obj_inst.bts_nr != 0xff) {
-		LOGP(DOML, LOGL_INFO, "Manufacturer O&M with BTS %d out of range.\n", foh->obj_inst.bts_nr);
+	if (report_bts_number_incorrect(bts, foh, false))
 		return oml_fom_ack_nack(msg, NM_NACK_BTSNR_UNKN);
-	}
 
 	ret = oml_tlv_parse(&tp, foh->data, oh->length - sizeof(*foh));
 	if (ret < 0) {

-- 
To view, visit https://gerrit.osmocom.org/2866
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id5714fbed910696d30e18d1f20f4c9fced4b9230
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list