Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/12357


Change subject: mgcp_client: make domain part of endpoint configurable
......................................................................

mgcp_client: make domain part of endpoint configurable

So far, both osmo-msc and osmo-bsc always pass endpoint names of the form
'...@mgw' to osmo-mgw. Allow configuring the 'mgw' part.

Note that the actual way to pass a differing name is to pass a composed
'rtpbridge/*@foo' to mgcp_msg_gen() in the struct mgcp_msg. So this merely adds
a common VTY config for the domain name part, changes to clients are necessary.

- add mgcp_client_rtpbridge_wildcard() (useful for AoIP endpoints)
- add mgcp_client_endpoint_domain() (useful for SCCPlite endpoints)
- add mgcp client vty cfg 'mgw endpoint-domain NAME'

Rationale: reading pcaps becomes so much easier when each of osmo-bsc and
osmo-msc address their MGW with differing domain names. Otherwise, both will
have a '0@mgw' endpoint and it gets really confusing.

Also: our MGCP clients osmo-bsc and osmo-msc use code dup to compose the
initial 'rtpbridge/*@mgw' rtpbridge wildcard. It should be defined by this API
instead.

This will be used by:
* osmo-msc I87ac11847d1a6d165ee9a2b5d8a4978e7ac73433
* osmo-bsc I492023e9dca0233ec0a077032455d9f2e3880f78

After these, with according configuration, there can be a '0@bsc' and a '0@msc'
endpoint.

osmo-mgw-for-bsc.cfg:
 mgcp
  domain bsc

osmo-bsc.cfg:
 msc 0
  mgw endpoint-domain bsc

osmo-mgw-for-msc.cfg:
 mgcp
  domain msc

osmo-msc.cfg:
 msc
  mgw endpoint-domain msc

(By default, everything will still use '@mgw')

Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
---
M include/osmocom/mgcp_client/mgcp_client.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_vty.c
M tests/mgcp_client/mgcp_client_test.err
4 files changed, 55 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/57/12357/1

diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index c1fd1b0..d284f49 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -22,6 +22,10 @@
        int local_port;
        const char *remote_addr;
        int remote_port;
+
+       /* By default, we are always addressing the MGW with e.g. 
'rtpbridge/123@mgw'.
+        * If this is nonempty, the contained name will be used instead of 
'mgw'. */
+       char endpoint_domain_name[64];
 };

 typedef unsigned int mgcp_trans_id_t;
@@ -120,6 +124,9 @@
 uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp);
 uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp);

+const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp);
+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp);
+
 /* Invoked when an MGCP response is received or sending failed.  When the
  * response is passed as NULL, this indicates failure during transmission. */
 typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void 
*priv);
diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 2ceab3c..2284e32 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -703,6 +703,10 @@
        mgcp->actual.remote_port = conf->remote_port >= 0 ? 
(uint16_t)conf->remote_port :
                MGCP_CLIENT_REMOTE_PORT_DEFAULT;

+       osmo_strlcpy(mgcp->actual.endpoint_domain_name, 
conf->endpoint_domain_name,
+                    sizeof(mgcp->actual.endpoint_domain_name));
+       LOGP(DLMGCP, LOGL_NOTICE, "MGCP client: using endpoint domain '@%s'\n", 
mgcp_client_endpoint_domain(mgcp));
+
        return mgcp;
 }

@@ -811,6 +815,32 @@
        return mgcp->remote_addr;
 }

+/* To compose endpoint names, usually for CRCX, use this as domain name.
+ * For example, snprintf("rtpbridge\*@%s", mgcp_client_endpoint_domain(mgcp)). 
*/
+const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp)
+{
+       return mgcp->actual.endpoint_domain_name[0]? 
mgcp->actual.endpoint_domain_name : "mgw";
+}
+
+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp)
+{
+       static char endpoint[MGCP_ENDPOINT_MAXLEN];
+       int rc;
+
+#define RTPBRIDGE_WILDCARD_FMT "rtpbridge/*@%s"
+       rc = snprintf(endpoint, sizeof(endpoint), RTPBRIDGE_WILDCARD_FMT, 
mgcp_client_endpoint_domain(mgcp));
+       if (rc > sizeof(endpoint) - 1) {
+               LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum length 
('" RTPBRIDGE_WILDCARD_FMT "')\n",
+                    mgcp_client_endpoint_domain(mgcp));
+               return NULL;
+       }
+       if (rc < 1) {
+               LOGP(DLMGCP, LOGL_ERROR, "Cannot compose MGCP endpoint name\n");
+               return NULL;
+       }
+       return endpoint;
+}
+
 struct mgcp_response_pending * mgcp_client_pending_add(
                                        struct mgcp_client *mgcp,
                                        mgcp_trans_id_t trans_id,
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c 
b/src/libosmo-mgcp-client/mgcp_client_vty.c
index b81fcd0..7aae5d3 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -139,6 +139,17 @@
       BTS_START_STR
       UDP_PORT_STR)

+DEFUN(cfg_mgw_endpoint_domain_name,
+      cfg_mgw_endpoint_domain_name_cmd,
+      "mgw endpoint-domain NAME",
+      MGW_STR "Set the domain name to send in MGCP messages, e.g. the part 
'foo' in 'rtpbridge/*@foo'.\n"
+      "Domain name, should be alphanumeric.\n")
+{
+       osmo_strlcpy(global_mgcp_client_conf->endpoint_domain_name, argv[0],
+                    sizeof(global_mgcp_client_conf->endpoint_domain_name));
+       return CMD_SUCCESS;
+}
+
 int mgcp_client_config_write(struct vty *vty, const char *indent)
 {
        const char *addr;
@@ -162,6 +173,10 @@
                vty_out(vty, "%smgw remote-port %u%s", indent,
                        (uint16_t)port, VTY_NEWLINE);

+       if (global_mgcp_client_conf->endpoint_domain_name[0])
+               vty_out(vty, "%smgw endpoint-domain %s%s", indent,
+                       global_mgcp_client_conf->endpoint_domain_name, 
VTY_NEWLINE);
+
        return CMD_SUCCESS;
 }

@@ -176,6 +191,7 @@
        install_element(node, &cfg_mgw_remote_port_cmd);
        install_element(node, &cfg_mgw_endpoint_range_cmd);
        install_element(node, &cfg_mgw_rtp_bts_base_port_cmd);
+       install_element(node, &cfg_mgw_endpoint_domain_name_cmd);

        /* deprecated 'mgcpgw' commands */
        install_element(node, &cfg_mgcpgw_local_ip_cmd);
diff --git a/tests/mgcp_client/mgcp_client_test.err 
b/tests/mgcp_client/mgcp_client_test.err
index 1d5a1a0..627b2d9 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -1,6 +1,8 @@
+DLMGCP MGCP client: using endpoint domain '@mgw'
 DLMGCP message buffer to small, can not generate MGCP message

 test_mgcp_client_cancel():
+DLMGCP MGCP client: using endpoint domain '@mgw'
 - composed msg with trans_id=1
 - not in queue yet, cannot cancel yet
 DLMGCP Cannot cancel, no such transaction: 1

--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <[email protected]>

Reply via email to