Add abis_nm_fail_evt_vrep() function
It accept fixed number of arguments including va_list instead of variable
number of arguments in abis_nm_fail_evt_rep() - similar to vprintff() vs
printf().
Related: OS#1615
Change-Id: Ib293dec1c2de9b664584a8456c782ea7b6dd8555
diff --git a/include/osmocom/gsm/protocol/gsm_12_21.h b/include/osmocom/gsm/protocol/gsm_12_21.h
index 1a95311..5daab42 100644
--- a/include/osmocom/gsm/protocol/gsm_12_21.h
+++ b/include/osmocom/gsm/protocol/gsm_12_21.h
@@ -790,4 +790,9 @@
enum abis_nm_severity s,
enum abis_nm_pcause_type ct,
uint16_t cause_value, const char *fmt, ...);
+struct msgb *abis_nm_fail_evt_vrep(enum abis_nm_event_type t,
+ enum abis_nm_severity s,
+ enum abis_nm_pcause_type ct,
+ uint16_t cause_value, const char *fmt,
+ va_list ap);
/*! @} */
diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c
index f50a54f..73e3c7e 100644
--- a/src/gsm/abis_nm.c
+++ b/src/gsm/abis_nm.c
@@ -530,9 +530,25 @@
enum abis_nm_pcause_type ct,
uint16_t cause_value, const char *fmt, ...)
{
+ va_list ap;
+ struct msgb *nmsg;
+
+ va_start(ap, fmt);
+ nmsg = abis_nm_fail_evt_vrep(t, s, ct, cause_value, fmt, ap);
+ va_end(ap);
+
+ return nmsg;
+}
+
+/*! \brief Pack 3GPP TS 12.21 § 8.8.2 Failure Event Report into msgb */
+struct msgb *abis_nm_fail_evt_vrep(enum abis_nm_event_type t,
+ enum abis_nm_severity s,
+ enum abis_nm_pcause_type ct,
+ uint16_t cause_value, const char *fmt,
+ va_list ap)
+{
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,
@@ -548,10 +564,7 @@
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;