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/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
index eb6564f..b2c7370 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -49,6 +49,14 @@
 	MGCP_CONN_LOOPBACK  = 4 | MGCP_CONN_RECV_SEND,
 };
 
+#define MGCP_X_OSMO_IGN_HEADER "X-Osmo-IGN:"
+
+/* Values should be bitwise-OR-able */
+enum mgcp_x_osmo_ign {
+	MGCP_X_OSMO_IGN_NONE = 0,
+	MGCP_X_OSMO_IGN_CALLID = 1,
+};
+
 /* Ensure that the msg->l2h is NUL terminated. */
 static inline int mgcp_msg_terminate_nul(struct msgb *msg)
 {
diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index 3876794..d834c09 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -90,6 +90,9 @@
 	/*! Memorize if this endpoint was choosen by the MGW (wildcarded, true)
 	 *   or if the user has choosen the particular endpoint explicitly. */
 	bool wildcarded_req;
+
+	/*! MGCP_X_OSMO_IGN_* flags from 'X-Osmo-IGN:' header */
+	uint32_t x_osmo_ign;
 };
 
 /*! Extract endpoint number for a given endpoint */
diff --git a/include/osmocom/mgcp_client/mgcp_client.h b/include/osmocom/mgcp_client/mgcp_client.h
index ed2dfb0..6c478e8 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -11,6 +11,8 @@
 #define MGCP_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1"
 #define MGCP_CLIENT_REMOTE_PORT_DEFAULT 2427
 
+#define MGCP_CLIENT_MGW_STR "Configure MGCP connection to Media Gateway\n"
+
 struct msgb;
 struct vty;
 struct mgcp_client;
@@ -88,6 +90,7 @@
 #define MGCP_MSG_PRESENCE_AUDIO_IP	0x0008
 #define MGCP_MSG_PRESENCE_AUDIO_PORT	0x0010
 #define MGCP_MSG_PRESENCE_CONN_MODE	0x0020
+#define MGCP_MSG_PRESENCE_X_OSMO_IGN	0x8000
 
 struct mgcp_msg {
 	enum mgcp_verb verb;
@@ -104,6 +107,7 @@
 	unsigned int codecs_len;
 	struct ptmap ptmap[MGCP_MAX_CODECS];
 	unsigned int ptmap_len;
+	uint32_t x_osmo_ign;
 };
 
 void mgcp_client_conf_init(struct mgcp_client_conf *conf);
diff --git a/include/osmocom/mgcp_client/mgcp_client_fsm.h b/include/osmocom/mgcp_client/mgcp_client_fsm.h
index 81d3dea..bb07872 100644
--- a/include/osmocom/mgcp_client/mgcp_client_fsm.h
+++ b/include/osmocom/mgcp_client/mgcp_client_fsm.h
@@ -42,6 +42,11 @@
 	/*! RTP payload type map length (optional, only needed when payload
 	 * types are used that differ from what IANA/3GPP defines) */
 	unsigned int ptmap_len;
+
+	/*! If nonzero, send 'X-Osmo-IGN:' header. This is useful e.g. for SCCPlite MSCs where the MSC is
+	 * known to issue incoherent or unknown CallIDs / to issue CRCX commands with a different domain
+	 * name than the BSC. An OsmoMGW will then ignore these and not fail on mismatches. */
+	uint32_t x_osmo_ign;
 };
 
 struct osmo_fsm_inst *mgcp_conn_create(struct mgcp_client *mgcp, struct osmo_fsm_inst *parent_fi, uint32_t parent_term_evt,