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
Review at https://gerrit.osmocom.org/5867
client: do not insist on \n\n when parsing MGCP messages
The current implementation of mgcp_client.c requires MGCP
paragraphs to be separated wit a \n\n sequence. However,
when the client is used with servers other than osmo-mgcp,
the parapgraph may be formatted differently.
Also allow \n\r\n\r and \r\n\r\n as separator
Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 23 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/67/5867/1
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index 9fc414d..f094a09 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -219,12 +219,33 @@
return -EINVAL;
}
+/* A new section is marked by a double line break, check a few more
+ * patterns as there may be variants */
+static char *mgcp_find_section_end(char *string)
+{
+ char *rc;
+
+ rc = strstr(string, "\n\n");
+ if (rc)
+ return rc;
+
+ rc = strstr(string, "\n\r\n\r");
+ if (rc)
+ return rc;
+
+ rc = strstr(string, "\r\n\r\n");
+ if (rc)
+ return rc;
+
+ return NULL;
+}
+
int mgcp_response_parse_params(struct mgcp_response *r)
{
char *line;
int rc;
OSMO_ASSERT(r->body);
- char *data = strstr(r->body, "\n\n");
+ char *data = mgcp_find_section_end(r->body);
if (!data) {
LOGP(DLMGCP, LOGL_ERROR,
@@ -286,7 +307,7 @@
int rc = 0;
OSMO_ASSERT(r->body);
char *data = r->body;
- char *data_end = strstr(r->body, "\n\n");
+ char *data_end = mgcp_find_section_end(r->body);
/* Protect SDP body, for_each_non_empty_line() will
* only parse until it hits \0 mark. */
--
To view, visit https://gerrit.osmocom.org/5867
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>