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
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. */