Change in osmo-mgw[master]: mgcp_msg: add trunk parameter to mgcp_check_param for logging

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Tue Jul 20 15:23:53 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24971 )


Change subject: mgcp_msg: add trunk parameter to mgcp_check_param for logging
......................................................................

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
---
M include/osmocom/mgcp/mgcp_msg.h
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
3 files changed, 15 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/71/24971/1

diff --git a/include/osmocom/mgcp/mgcp_msg.h b/include/osmocom/mgcp/mgcp_msg.h
index 7732865..87987d3 100644
--- a/include/osmocom/mgcp/mgcp_msg.h
+++ b/include/osmocom/mgcp/mgcp_msg.h
@@ -39,7 +39,7 @@
 
 int mgcp_parse_osmux_cid(const char *line);
 
-int mgcp_check_param(const struct mgcp_endpoint *endp, const char *line);
+bool mgcp_check_param(const struct mgcp_endpoint *endp, struct mgcp_trunk *trunk, const char *line);
 
 int mgcp_verify_call_id(struct mgcp_endpoint *endp, const char *callid);
 
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index f8b486a..421dcbf 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.
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index b7ae748..ef82cfd 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -851,7 +851,7 @@
 
 	/* parse CallID C: and LocalParameters L: */
 	for_each_line(line, pdata->save) {
-		if (!mgcp_check_param(endp, line))
+		if (!mgcp_check_param(endp, trunk, line))
 			continue;
 
 		switch (toupper(line[0])) {
@@ -1143,7 +1143,7 @@
 	}
 
 	for_each_line(line, pdata->save) {
-		if (!mgcp_check_param(endp, line))
+		if (!mgcp_check_param(endp, trunk, line))
 			continue;
 
 		switch (toupper(line[0])) {
@@ -1388,7 +1388,7 @@
 	}
 
 	for_each_line(line, pdata->save) {
-		if (!mgcp_check_param(endp, line))
+		if (!mgcp_check_param(endp, trunk, line))
 			continue;
 
 		switch (toupper(line[0])) {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/24971
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I7327c5a105e7f0e20cabf64623ff9f36fd83bbb8
Gerrit-Change-Number: 24971
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210720/1ae6485a/attachment.htm>


More information about the gerrit-log mailing list