mgcp_msg: add trunk parameter to mgcp_check_param for logging
There is not always an endp pointer present when mgcp_check_param() is
called but we always have a trunk pointer. Lets add a trunk parameter so
that the function can pick LOGPTRUNK when endp is not available.
Change-Id: I7327c5a105e7f0e20cabf64623ff9f36fd83bbb8
Related: SYS#5535
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index f8b486a..f36fa71 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -31,6 +31,7 @@
#include <osmocom/mgcp/mgcp_msg.h>
#include <osmocom/mgcp/mgcp_conn.h>
#include <osmocom/mgcp/mgcp_endp.h>
+#include <osmocom/mgcp/mgcp_trunk.h>
/*! Display an mgcp message on the log output.
* \param[in] message mgcp message string
@@ -208,22 +209,24 @@
}
/*! Check MGCP parameter line (string) for plausibility.
- * \param[in] endp pointer to endpoint (only used for log output)
+ * \param[in] endp pointer to endpoint (only used for log output, may be NULL)
+ * \param[in] trunk pointer to trunk (only used for log output, may be NULL if endp is not NULL)
* \param[in] line single parameter line from the MGCP message
- * \returns 1 when line seems plausible, 0 on error */
-int mgcp_check_param(const struct mgcp_endpoint *endp, const char *line)
+ * \returns true when line seems plausible, false on error */
+bool mgcp_check_param(const struct mgcp_endpoint *endp, struct mgcp_trunk *trunk, const char *line)
{
const size_t line_len = strlen(line);
if (line[0] != '\0' && line_len < 2) {
- LOGP(DLMGCP, LOGL_ERROR,
- "Wrong MGCP option format: '%s' on %s\n",
- line, endp->name);
- return 0;
+ if (endp)
+ LOGPENDP(endp, DLMGCP, LOGL_NOTICE, "wrong MGCP option format: '%s'\n", line);
+ else
+ LOGPTRUNK(trunk, DLMGCP, LOGL_NOTICE, "wrong MGCP option format: '%s'\n", line);
+ return false;
}
/* FIXME: A couple more checks wouldn't hurt... */
- return 1;
+ return true;
}
/*! Check if the specified callid seems plausible.