From ecbcdf52ec7c165c7933346441c02030833aba78 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 2 Jan 2017 14:43:35 +0100 Subject: Add OML Failure Event Report support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 3GPP TS 12.21 § 8.8.2 Failure Event Report function which pack given vararg string and parameters into msgb. Change-Id: I58c198d8ea588432c62520928b08f0b2a7035e93 Related: OS#1615 --- src/gsm/abis_nm.c | 38 ++++++++++++++++++++++++++++++++++++++ src/gsm/libosmogsm.map | 1 + 2 files changed, 39 insertions(+) (limited to 'src') diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index 87d05ab0..2de49411 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -517,6 +517,44 @@ static const enum abis_nm_chan_comb chcomb4pchan[] = { /* FIXME: bounds check */ }; +/*! \brief Pack 3GPP TS 12.21 § 8.8.2 Failure Event Report into msgb */ +struct msgb *abis_nm_fail_evt_rep(enum abis_nm_event_type t, + enum abis_nm_severity s, + enum abis_nm_pcause_type ct, + uint16_t cause_value, const char *fmt, ...) +{ + uint8_t cause[3]; + int len; + va_list ap; + char add_text[ABIS_NM_MSG_HEADROOM]; + struct msgb *nmsg = msgb_alloc_headroom(ABIS_NM_MSG_SIZE, + ABIS_NM_MSG_HEADROOM, + "OML FAIL EV. REP."); + if (!nmsg) + return NULL; + + msgb_tv_put(nmsg, NM_ATT_EVENT_TYPE, t); + msgb_tv_put(nmsg, NM_ATT_SEVERITY, s); + + cause[0] = ct; + osmo_store16be(cause_value, cause + 1); + + msgb_tv_fixed_put(nmsg, NM_ATT_PROB_CAUSE, 3, cause); + + va_start(ap, fmt); + len = vsnprintf(add_text, ABIS_NM_MSG_HEADROOM, fmt, ap); + va_end(ap); + + if (len < 0) { + msgb_free(nmsg); + return NULL; + } + if (len) + msgb_tl16v_put(nmsg, NM_ATT_ADD_TEXT, len, add_text); + + return nmsg; +} + /*! \brief Obtain OML Channel Combination for phnsical channel config */ int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan) { diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index c876d2b4..0c37d1cf 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -4,6 +4,7 @@ global: abis_nm_adm_state_names; abis_nm_att_settable; abis_nm_avail_name; +abis_nm_fail_evt_rep; abis_nm_chcomb4pchan; abis_nm_debugp_foh; abis_nm_event_type_name; -- cgit v1.2.3