osmux: Handle Osmux MGCP extension in MDCX messages
Change-Id: I65e53bd5dd08b58c253e03d2f358f3be523a2688
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index e1bf12b..35141f8 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1048,6 +1048,7 @@
const char *mode = NULL;
struct mgcp_conn_rtp *conn = NULL;
const char *conn_id = NULL;
+ int osmux_cid = -2;
int rc;
LOGPENDP(endp, DLMGCP, LOGL_NOTICE, "MDCX: modifying existing connection ...\n");
@@ -1095,6 +1096,16 @@
case 'Z':
silent = strcmp("noanswer", line + 3) == 0;
break;
+ case 'X':
+ if (strncmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
+ /* If osmux is disabled, just skip setting it up */
+ if (!p->endp->cfg->osmux)
+ break;
+ osmux_cid = mgcp_osmux_setup(endp, line);
+ break;
+ }
+ /* Ignore unknown X-headers */
+ break;
case '\0':
have_sdp = 1;
goto mgcp_header_done;
@@ -1166,6 +1177,25 @@
goto error3;
}
+ if (mgcp_conn_rtp_is_osmux(conn)) {
+ OSMO_ASSERT(conn->osmux.cid_allocated);
+ if (osmux_cid < -1) {
+ LOGPCONN(conn->conn, DLMGCP, LOGL_ERROR,
+ "MDCX: Failed to parse Osmux CID!\n");
+ goto error3;
+ } else if (osmux_cid == -1) {
+ LOGPCONN(conn->conn, DLMGCP, LOGL_ERROR,
+ "MDCX: wilcard in MDCX is not supported!\n");
+ goto error3;
+ } else if (osmux_cid != (int) conn->osmux.cid) {
+ LOGPCONN(conn->conn, DLMGCP, LOGL_ERROR,
+ "MDCX: changing already allocated CID is not supported!\n");
+ goto error3;
+ }
+ /* TODO: In the future (when we have recvCID!=sendCID), we need to
+ tell Osmux code that osmux_cid is to be used as sendCID for
+ that conn. */
+ }
if (setup_rtp_processing(endp, conn) != 0) {
rate_ctr_inc(&rate_ctrs->ctr[MGCP_MDCX_FAIL_START_RTP]);