add X-Osmo-IGN MGCP header to ignore CallID
The format is
CRCX ...
C: ...
M: ...
X-Osmo-IGN: C
So far the only ignorable element is C, i.e. the CallID. Any other items may be
added in the future.
(I initially intended to also add '@' to ignore the endpoint name's domain
part, but in the osmo-mgw code base the domain part is verified long before any
additional headers are even parsed, so sparing that refactoring for now.)
The intention is that osmo-bsc will issue "X-Osmo-IGN: C" for all SCCPlite
calls, because we are unable to retrieve the CallID that the MSC sends to
osmo-mgw for the network side of the endpoint.
Testing with a specific SCCPlite MSC, I actually observe that all CallIDs are
1, even for concurrent calls. So, an alternative hacky solution would have been
to always pass CallID == 1 for SCCPlite connections from osmo-bsc.
Related: I257ad574d8060fef19afce9798bd8a5a7f8c99fe (osmo-bsc)
Change-Id: Id7ae275ffde8ea9389270cfe3db087ee8db00b51
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index c10abc9..e9d7b3f 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -1313,6 +1313,13 @@
msgb_printf(msg, "M: %s\r\n",
mgcp_client_cmode_name(mgcp_msg->conn_mode));
+ /* Add X-Osmo-IGN */
+ if ((mgcp_msg->presence & MGCP_MSG_PRESENCE_X_OSMO_IGN)
+ && (mgcp_msg->x_osmo_ign != 0))
+ rc +=
+ msgb_printf(msg, MGCP_X_OSMO_IGN_HEADER "%s\r\n",
+ mgcp_msg->x_osmo_ign & MGCP_X_OSMO_IGN_CALLID ? " C": "");
+
/* Add session description protocol (SDP) */
if (use_sdp
&& (mgcp_msg->verb == MGCP_VERB_CRCX
diff --git a/src/libosmo-mgcp-client/mgcp_client_fsm.c b/src/libosmo-mgcp-client/mgcp_client_fsm.c
index 770db5e..0b5a251 100644
--- a/src/libosmo-mgcp-client/mgcp_client_fsm.c
+++ b/src/libosmo-mgcp-client/mgcp_client_fsm.c
@@ -119,6 +119,11 @@
osmo_strlcpy(mgcp_msg->endpoint, info->endpoint, MGCP_ENDPOINT_MAXLEN);
memcpy(mgcp_msg->codecs, info->codecs, sizeof(mgcp_msg->codecs));
memcpy(mgcp_msg->ptmap, info->ptmap, sizeof(mgcp_msg->ptmap));
+
+ if (info->x_osmo_ign) {
+ mgcp_msg->x_osmo_ign = info->x_osmo_ign;
+ mgcp_msg->presence |= MGCP_MSG_PRESENCE_X_OSMO_IGN;
+ }
}
static void add_audio(struct mgcp_msg *mgcp_msg, struct mgcp_conn_peer *info)
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c
index 10d078a..48fcd70 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -30,7 +30,7 @@
#include <osmocom/mgcp_client/mgcp_client.h>
-#define MGW_STR "Configure MGCP connection to Media Gateway\n"
+#define MGW_STR MGCP_CLIENT_MGW_STR
void *global_mgcp_client_ctx = NULL;
struct mgcp_client_conf *global_mgcp_client_conf = NULL;
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index a5bef7b..a7c8b47 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -407,6 +407,11 @@
if (!endp)
return -1;
+
+ /* Accept any CallID for "X-Osmo-IGN: C" */
+ if (endp->x_osmo_ign & MGCP_X_OSMO_IGN_CALLID)
+ return 0;
+
if (!callid)
return -1;
if (!endp->callid)
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index ea80907..cb2c965 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -715,12 +715,31 @@
mode = (const char *)line + 3;
break;
case 'X':
- /* If osmoux is disabled, just skip setting it up */
- if (!p->endp->cfg->osmux)
- break;
- if (strncmp("Osmux: ", line + 2, strlen("Osmux: ")) ==
- 0)
+ 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;
+ }
+
+ /* Parse X-Osmo-IGN header */
+ if (!strncmp(line, MGCP_X_OSMO_IGN_HEADER,
+ strlen(MGCP_X_OSMO_IGN_HEADER))) {
+ int i;
+ int line_len = strlen(line);
+ for (i = strlen(MGCP_X_OSMO_IGN_HEADER); i < line_len; i++) {
+ switch (line[i]) {
+ case 'C':
+ endp->x_osmo_ign |= MGCP_X_OSMO_IGN_CALLID;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ /* Ignore unknown X-headers */
break;
case '\0':
have_sdp = 1;