aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmo-bts/oml.h5
-rw-r--r--include/osmo-bts/signal.h1
-rw-r--r--src/common/abis.c2
-rw-r--r--src/common/bts.c6
-rw-r--r--src/common/l1sap.c6
-rw-r--r--src/common/main.c13
-rw-r--r--src/common/oml.c87
-rw-r--r--src/common/rsl.c21
8 files changed, 83 insertions, 58 deletions
diff --git a/include/osmo-bts/oml.h b/include/osmo-bts/oml.h
index 217ec64c..139464ec 100644
--- a/include/osmo-bts/oml.h
+++ b/include/osmo-bts/oml.h
@@ -9,7 +9,7 @@ struct msgb;
struct gsm_lchan;
-int oml_init(void);
+int oml_init(struct gsm_abis_mo *mo);
int down_oml(struct gsm_bts *bts, struct msgb *msg);
struct msgb *oml_msgb_alloc(void);
@@ -45,7 +45,6 @@ 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, uint16_t cause_value,
- const char *fmt, ...);
+void oml_fail_rep(uint16_t cause_value, const char *fmt, ...);
#endif // _OML_H */
diff --git a/include/osmo-bts/signal.h b/include/osmo-bts/signal.h
index c8168a26..01d4099b 100644
--- a/include/osmo-bts/signal.h
+++ b/include/osmo-bts/signal.h
@@ -5,6 +5,7 @@
enum sig_subsys {
SS_GLOBAL,
+ SS_FAIL,
};
enum signals_global {
diff --git a/src/common/abis.c b/src/common/abis.c
index 67531494..768d261c 100644
--- a/src/common/abis.c
+++ b/src/common/abis.c
@@ -235,7 +235,7 @@ void abis_init(struct gsm_bts *bts)
{
g_bts = bts;
- oml_init();
+ oml_init(&bts->mo);
libosmo_abis_init(NULL);
osmo_signal_register_handler(SS_L_INPUT, &inp_s_cbfn, bts);
diff --git a/src/common/bts.c b/src/common/bts.c
index efefb862..9915e1ca 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -268,9 +268,9 @@ int trx_link_estab(struct gsm_bts_trx *trx)
else
rc = bts_model_trx_deact_rf(trx);
if (rc < 0)
- oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_RSL_FAIL, link ?
- "Failed to establish RSL link (%d)\n" :
- "Failed to deactivate RF (%d)\n", rc);
+ oml_fail_rep(OSMO_EVT_MAJ_RSL_FAIL,
+ link ? "Failed to establish RSL link (%d)" :
+ "Failed to deactivate RF (%d)", rc);
return 0;
}
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 9116e23f..b2f18d1e 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -1065,10 +1065,8 @@ int l1sap_up(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
default:
LOGP(DL1P, LOGL_NOTICE, "unknown prim %d op %d\n",
l1sap->oph.primitive, l1sap->oph.operation);
- oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_UKWN_MSG,
- "unknown prim %d op %d\n",
- l1sap->oph.primitive,
- l1sap->oph.operation);
+ oml_fail_rep(OSMO_EVT_MAJ_UKWN_MSG, "unknown prim %d op %d",
+ l1sap->oph.primitive, l1sap->oph.operation);
break;
}
diff --git a/src/common/main.c b/src/common/main.c
index 1af4f348..4c518485 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -184,12 +184,9 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
- //osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
if (!quit) {
- oml_tx_failure_event_rep(&bts->mo,
- OSMO_EVT_CRIT_PROC_STOP,
- "BTS: SIGINT received -> "
- "shutdown\n");
+ oml_fail_rep(OSMO_EVT_CRIT_PROC_STOP,
+ "BTS: SIGINT received -> shutdown");
bts_shutdown(bts, "SIGINT");
}
quit++;
@@ -197,9 +194,9 @@ static void signal_handler(int signal)
case SIGABRT:
case SIGUSR1:
case SIGUSR2:
- oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_CRIT_PROC_STOP,
- "BTS: signal %s received\n",
- strsignal(signal));
+ oml_fail_rep(OSMO_EVT_CRIT_PROC_STOP,
+ "BTS: signal %d (%s) received", signal,
+ strsignal(signal));
talloc_report_full(tall_bts_ctx, stderr);
break;
default:
diff --git a/src/common/oml.c b/src/common/oml.c
index 14824104..272123e6 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -25,6 +25,8 @@
*/
#include <errno.h>
+#include <stdarg.h>
+#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
@@ -58,6 +60,42 @@ struct msgb *oml_msgb_alloc(void)
return msgb_alloc_headroom(1024, 128, "OML");
}
+/* 3GPP TS 12.21 § 8.8.2 */
+static int oml_tx_failure_event_rep(struct gsm_abis_mo *mo, uint16_t cause_value,
+ const char *fmt, ...)
+{
+ struct msgb *nmsg;
+ va_list ap;
+
+ LOGP(DOML, LOGL_NOTICE, "Reporting FAILURE to BSC: ");
+ va_start(ap, fmt);
+ osmo_vlogp(DOML, LOGL_NOTICE, __FILE__, __LINE__, 1, fmt, ap);
+ nmsg = abis_nm_fail_evt_vrep(NM_EVT_PROC_FAIL, NM_SEVER_CRITICAL,
+ NM_PCAUSE_T_MANUF, cause_value, fmt, ap);
+ va_end(ap);
+ LOGPC(DOML, LOGL_NOTICE, "\n");
+
+ if (!nmsg)
+ return -ENOMEM;
+
+ return oml_mo_send_msg(mo, nmsg, NM_MT_FAILURE_EVENT_REP);
+}
+
+void oml_fail_rep(uint16_t cause_value, const char *fmt, ...)
+{
+ va_list ap;
+ char *rep;
+
+ va_start(ap, fmt);
+ rep = talloc_asprintf(tall_bts_ctx, fmt, ap);
+ va_end(ap);
+
+ osmo_signal_dispatch(SS_FAIL, cause_value, rep);
+ /* signal dispatch is synchronous so all the signal handlers are
+ finished already: we're free to free */
+ talloc_free(rep);
+}
+
int oml_send_msg(struct msgb *msg, int is_manuf)
{
struct abis_om_hdr *omh;
@@ -347,7 +385,7 @@ static int oml_rx_set_bts_attr(struct gsm_bts *bts, struct msgb *msg)
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,
- "New value for Attribute not supported\n");
+ "New value for Attribute not supported");
return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
}
@@ -356,7 +394,7 @@ static int oml_rx_set_bts_attr(struct gsm_bts *bts, struct msgb *msg)
uint16_t arfcn = ntohs(tlvp_val16_unal(&tp, NM_ATT_BCCH_ARFCN));
if (arfcn > 1024) {
oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_WARN_SW_WARN,
- "Given ARFCN %d is not supported.\n",
+ "Given ARFCN %u is not supported",
arfcn);
LOGP(DOML, LOGL_NOTICE, "Given ARFCN %d is not supported.\n", arfcn);
return oml_fom_ack_nack(msg, NM_NACK_FREQ_NOTAVAIL);
@@ -366,7 +404,7 @@ static int oml_rx_set_bts_attr(struct gsm_bts *bts, struct msgb *msg)
if (TLVP_PRESENT(&tp, NM_ATT_START_TIME)) {
oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_MAJ_UNSUP_ATTR,
"NM_ATT_START_TIME Attribute not "
- "supported\n");
+ "supported");
return oml_fom_ack_nack(msg, NM_NACK_SPEC_IMPL_NOTSUPP);
}
@@ -506,7 +544,7 @@ static int oml_rx_set_radio_attr(struct gsm_bts_trx *trx, struct msgb *msg)
if (rc < 0) {
oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_UNSUP_ATTR,
"New value for Set Radio Attribute not"
- " supported\n");
+ " supported");
return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
}
@@ -568,8 +606,15 @@ static int oml_rx_set_radio_attr(struct gsm_bts_trx *trx, struct msgb *msg)
memcpy(&_value, value, 2);
arfcn = ntohs(_value);
value += 2;
- if (arfcn > 1024)
+ if (arfcn > 1024) {
+ oml_tx_failure_event_rep(&trx->bts->mo,
+ OSMO_EVT_WARN_SW_WARN,
+ "Given ARFCN %u is unsupported",
+ arfcn);
+ LOGP(DOML, LOGL_NOTICE,
+ "Given ARFCN %u is unsupported.\n", arfcn);
return oml_fom_ack_nack(msg, NM_NACK_FREQ_NOTAVAIL);
+ }
trx->arfcn = arfcn;
}
#endif
@@ -672,7 +717,7 @@ static int oml_rx_set_chan_attr(struct gsm_bts_trx_ts *ts, struct msgb *msg)
if (rc < 0) {
oml_tx_failure_event_rep(&ts->mo, OSMO_EVT_MAJ_UNSUP_ATTR,
"New value for Set Channel Attribute "
- "not supported\n");
+ "not supported");
return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
}
@@ -814,7 +859,7 @@ static int down_fom(struct gsm_bts *bts, struct msgb *msg)
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 message too short\n");
+ "Formatted O&M message too short");
}
return -EIO;
}
@@ -828,7 +873,7 @@ static int down_fom(struct gsm_bts *bts, struct msgb *msg)
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).\n",
+ " of range (0:0xFF)",
foh->obj_inst.bts_nr);
}
return oml_fom_ack_nack(msg, NM_NACK_BTSNR_UNKN);
@@ -871,12 +916,12 @@ static int down_fom(struct gsm_bts *bts, struct msgb *msg)
trx->mo.obj_inst.ts_nr = 0xff;
oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_UKWN_MSG,
"unknown Formatted O&M "
- "msg_type 0x%02x\n",
+ "msg_type 0x%02x",
foh->msg_type);
} else
oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_MAJ_UKWN_MSG,
"unknown Formatted O&M "
- "msg_type 0x%02x\n",
+ "msg_type 0x%02x",
foh->msg_type);
ret = oml_fom_ack_nack(msg, NM_NACK_MSGTYPE_INVAL);
}
@@ -1191,29 +1236,19 @@ int down_oml(struct gsm_bts *bts, struct msgb *msg)
return ret;
}
-/* 3GPP TS 12.21 § 8.8.2 */
-int oml_tx_failure_event_rep(struct gsm_abis_mo *mo, uint16_t cause_value,
- const char *fmt, ...)
+static int handle_fail_sig(unsigned int subsys, unsigned int signal, void *handle,
+ void *signal_data)
{
- struct msgb *nmsg;
- va_list ap;
+ oml_tx_failure_event_rep(handle, signal, "%s", signal_data);
- va_start(ap, fmt);
- nmsg = abis_nm_fail_evt_rep(NM_EVT_PROC_FAIL, NM_SEVER_CRITICAL,
- NM_PCAUSE_T_MANUF, cause_value, fmt, ap);
- LOGP(DOML, LOGL_INFO, fmt, ap);
- va_end(ap);
-
- if (!nmsg)
- return -ENOMEM;
-
- return oml_mo_send_msg(mo, nmsg, NM_MT_FAILURE_EVENT_REP);
+ return 0;
}
-int oml_init(void)
+int oml_init(struct gsm_abis_mo *mo)
{
DEBUGP(DOML, "Initializing OML attribute definitions\n");
tlv_def_patch(&abis_nm_att_tlvdef_ipa, &abis_nm_att_tlvdef);
+ osmo_signal_register_handler(SS_FAIL, handle_fail_sig, mo);
return 0;
}
diff --git a/src/common/rsl.c b/src/common/rsl.c
index a34c4556..b3e9afb7 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -403,9 +403,8 @@ static int rsl_rx_paging_cmd(struct gsm_bts_trx *trx, struct msgb *msg)
if (rc < 0) {
/* FIXME: notfiy the BSC on other errors? */
if (rc == -ENOSPC)
- oml_tx_failure_event_rep(&trx->mo,
- OSMO_EVT_MIN_PAG_TAB_FULL,
- "BTS paging table is full\n");
+ oml_fail_rep(OSMO_EVT_MIN_PAG_TAB_FULL,
+ "BTS paging table is full");
}
pcu_tx_pag_req(identity_lv, chan_needed);
@@ -1653,11 +1652,9 @@ static int rsl_rx_ipac_XXcx(struct msgb *msg)
LOGP(DRSL, LOGL_ERROR,
"%s IPAC Failed to create RTP/RTCP sockets\n",
gsm_lchan_name(lchan));
- oml_tx_failure_event_rep(&lchan->ts->trx->mo,
- OSMO_EVT_CRIT_RTP_TOUT,
- "%s IPAC Failed to create "
- "RTP/RTCP sockets\n",
- gsm_lchan_name(lchan));
+ oml_fail_rep(OSMO_EVT_CRIT_RTP_TOUT,
+ "%s IPAC Failed to create RTP/RTCP sockets",
+ gsm_lchan_name(lchan));
return tx_ipac_XXcx_nack(lchan, RSL_ERR_RES_UNAVAIL,
inc_ip_port, dch->c.msg_type);
}
@@ -1697,11 +1694,9 @@ static int rsl_rx_ipac_XXcx(struct msgb *msg)
LOGP(DRSL, LOGL_ERROR,
"%s IPAC Failed to bind RTP/RTCP sockets\n",
gsm_lchan_name(lchan));
- oml_tx_failure_event_rep(&lchan->ts->trx->mo,
- OSMO_EVT_CRIT_RTP_TOUT,
- "%s IPAC Failed to bind "
- "RTP/RTCP sockets\n",
- gsm_lchan_name(lchan));
+ oml_fail_rep(OSMO_EVT_CRIT_RTP_TOUT,
+ "%s IPAC Failed to bind RTP/RTCP sockets",
+ gsm_lchan_name(lchan));
osmo_rtp_socket_free(lchan->abis_ip.rtp_socket);
lchan->abis_ip.rtp_socket = NULL;
msgb_queue_flush(&lchan->dl_tch_queue);