mgcp: make domain name configurable
At the moment the MGW has a fixed domain name string that is not even
checked properly.
- Make domain name configurable, use the current "mgw" string as
defualt to maintain compatibility
- Check the domain name with each request. If the endpoint contains
an unexpected domain name, the request must be rejected.
Change-Id: Ia91ac428ba83ac1f9b52a0ec8dbf00ef7876da9e
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 9d79343..5f1a734 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1072,6 +1072,8 @@
return NULL;
}
+ osmo_strlcpy(cfg->domain, "mgw", sizeof(cfg->domain));
+
cfg->net_ports.range_start = RTP_PORT_DEFAULT_RANGE_START;
cfg->net_ports.range_end = RTP_PORT_DEFAULT_RANGE_END;
cfg->net_ports.last_port = cfg->net_ports.range_start;
@@ -1208,13 +1210,16 @@
* \returns 0 on success, -1 on error */
int mgcp_send_reset_all(struct mgcp_config *cfg)
{
+ char buf[MGCP_ENDPOINT_MAXLEN + 128];
+ int len;
int rc;
- static const char mgcp_reset[] = {
- "RSIP 1 *@mgw MGCP 1.0\r\n"
- };
+ len = snprintf(buf, sizeof(buf),
+ "RSIP 1 *@%s MGCP 1.0\r\n", cfg->domain);
+ if (len < 0)
+ return -1;
- rc = send_agent(cfg, mgcp_reset, sizeof mgcp_reset - 1);
+ rc = send_agent(cfg, buf, len);
if (rc <= 0)
return -1;
@@ -1228,12 +1233,12 @@
* \returns 0 on success, -1 on error */
int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint)
{
- char buf[128];
+ char buf[MGCP_ENDPOINT_MAXLEN + 128];
int len;
int rc;
len = snprintf(buf, sizeof(buf),
- "RSIP 39 %x@mgw MGCP 1.0\r\n", endpoint);
+ "RSIP 39 %x@%s MGCP 1.0\r\n", endpoint, endp->cfg->domain);
if (len < 0)
return -1;