protocol: fix problem with line break and OSMUX

The SDP parameter block must be detached from the regular parameters
using an additional line break (empty line). At the moment this works
because the empty OSMOX variable is added and by this also adds a
line break. It breaks as soon as OSMUX is used again.

- Make clear that no OSMUX variable is added when OSMUX is not in
  use.

- Add the extra line break independently

Change-Id: I6261971040db527b96fe79676520ccd7794bd327
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index daedc8d..49c4c3c 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -226,7 +226,7 @@
 	struct msgb *sdp;
 	int rc;
 	struct msgb *result;
-	char osmux_extension[strlen("\nX-Osmux: 255") + 1];
+	char osmux_extension[strlen("X-Osmux: 255") + 1];
 	char local_ip_addr[INET_ADDRSTRLEN];
 
 	sdp = msgb_alloc_headroom(4096, 128, "sdp record");
@@ -239,7 +239,7 @@
 	}
 
 	if (conn->osmux.state == OSMUX_STATE_NEGOTIATING) {
-		sprintf(osmux_extension, "\nX-Osmux: %u", conn->osmux.cid);
+		sprintf(osmux_extension, "X-Osmux: %u", conn->osmux.cid);
 		conn->osmux.state = OSMUX_STATE_ACTIVATING;
 	} else {
 		osmux_extension[0] = '\0';
@@ -252,9 +252,15 @@
 			goto error;
 	}
 
-	rc = msgb_printf(sdp, "%s\n", osmux_extension);
-	if (rc < 0)
-		goto error;
+	/* Attach optional OSMUX parameters */
+	if (conn->osmux.state == OSMUX_STATE_NEGOTIATING) {
+		rc = msgb_printf(sdp, "%s\n", osmux_extension);
+		if (rc < 0)
+			goto error;
+	}
+
+	/* Attach line break to separate the parameters from the SDP block */
+	rc = msgb_printf(sdp, "\n");
 
 	rc = mgcp_write_response_sdp(endp, conn, sdp, addr);
 	if (rc < 0)