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
This commit is contained in:
Philipp Maier 2018-01-22 11:39:59 +01:00 committed by Harald Welte
parent 275ac97036
commit 3cbfb8a53c
1 changed files with 11 additions and 5 deletions

View File

@ -226,7 +226,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
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 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
}
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 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
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)