[PATCH] osmo-bts[master]: Add Abis OML failure event reporting

Max gerrit-no-reply at lists.osmocom.org
Mon Jan 2 17:33:11 UTC 2017


Review at  https://gerrit.osmocom.org/1522

Add Abis OML failure event reporting

Send 3GPP TS 12.21 § 8.8.2 Abis/OML failure event report.

Max's note: used libosmocore functions, minor restructuring.

Change-Id: Ib1170edca2207752984a554d7a6a57c224f6d5f5
Related: OS#1615
---
M include/osmo-bts/oml.h
M src/common/main.c
M src/common/oml.c
3 files changed, 44 insertions(+), 1 deletion(-)


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

diff --git a/include/osmo-bts/oml.h b/include/osmo-bts/oml.h
index 9f49444..510b0ea 100644
--- a/include/osmo-bts/oml.h
+++ b/include/osmo-bts/oml.h
@@ -1,6 +1,8 @@
 #ifndef _OML_H
 #define _OML_H
 
+#include <osmocom/gsm/protocol/gsm_12_21.h>
+
 struct gsm_bts;
 struct gsm_abis_mo;
 struct msgb;
@@ -42,4 +44,8 @@
 int oml_set_lchan_t200(struct gsm_lchan *lchan);
 extern const unsigned int oml_default_t200_ms[7];
 
+/* Transmit failure event report */
+int oml_tx_failure_event_rep(struct gsm_abis_mo *mo,
+			     struct abis_nm_fail_evt_rep failure_evt_rep);
+
 #endif // _OML_H */
diff --git a/src/common/main.c b/src/common/main.c
index 1b2549e..977f63a 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -50,6 +50,7 @@
 #include <osmo-bts/bts_model.h>
 #include <osmo-bts/pcu_if.h>
 #include <osmo-bts/control_if.h>
+#include <osmo-bts/oml.h>
 
 int quit = 0;
 static const char *config_file = "osmo-bts.cfg";
@@ -176,18 +177,35 @@
 
 static void signal_handler(int signal)
 {
+	char log_msg[100];
+	struct abis_nm_fail_evt_rep failure_rep;
+	failure_rep.type = NM_EVT_PROC_FAIL;
+	failure_rep.severity = NM_SEVER_CRITICAL;
+	failure_rep.cause_type = NM_PCAUSE_T_MANUF;
+	failure_rep.cause_value = OSMO_EVT_CRIT_PROC_STOP;
+
 	fprintf(stderr, "signal %u received\n", signal);
 
 	switch (signal) {
 	case SIGINT:
 		//osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
-		if (!quit)
+		if (!quit) {
+			snprintf(log_msg, 100, "BTS: SIGINT received -> shutdown\n");
+			failure_rep.add_text = (char *)&log_msg;
+			oml_tx_failure_event_rep(&bts->mo, failure_rep);
+
 			bts_shutdown(bts, "SIGINT");
+		}
 		quit++;
 		break;
 	case SIGABRT:
 	case SIGUSR1:
 	case SIGUSR2:
+		snprintf(log_msg, 100, "BTS: signal %s received\n",
+			 strsignal(signal));
+		failure_rep.add_text = (char *)&log_msg;
+		oml_tx_failure_event_rep(&bts->mo, failure_rep);
+
 		talloc_report_full(tall_bts_ctx, stderr);
 		break;
 	default:
diff --git a/src/common/oml.c b/src/common/oml.c
index 0700aa2..42a70ac 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -1140,6 +1140,25 @@
 	return ret;
 }
 
+/* 3GPP TS 12.21 § 8.8.2 */
+int oml_tx_failure_event_rep(struct gsm_abis_mo *mo,
+                            struct abis_nm_fail_evt_rep failure_evt_rep)
+{
+	size_t len = strlen(failure_evt_rep.add_text);
+	struct msgb *nmsg = abis_nm_fail_evt_rep2msgb(failure_evt_rep);
+	if (!nmsg)
+		return -ENOMEM;
+
+       LOGP(DOML, LOGL_INFO, "%s Tx FAILure EVT REP\n", gsm_abis_mo_name(mo));
+
+       if (len)
+               LOGP(DOML, LOGL_DEBUG, "%s Tx FAILure EVT REP Additional Text ="
+                    " %s (%zu)\n", gsm_abis_mo_name(mo),
+                    failure_evt_rep.add_text, len);
+
+       return oml_mo_send_msg(mo, nmsg, NM_MT_FAILURE_EVENT_REP);
+}
+
 int oml_init(void)
 {
 	DEBUGP(DOML, "Initializing OML attribute definitions\n");

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1170edca2207752984a554d7a6a57c224f6d5f5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Minh-Quang Nguyen <minh-quang.nguyen at nutaq.com>


More information about the gerrit-log mailing list