This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. ( 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 '... at 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 at 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 at bsc' and a '0 at msc' endpoint on two separate osmo-mgw instances: 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 There can also be '0 at bsc' and '1 at msc' endpoints on one single osmo-mgw instance with: osmo-mgw.cfg: mgcp domain * and same osmo-{bsc,msc}.cfg as above. (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, 66 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Harald Welte: Looks good to me, approved diff --git a/include/osmocom/mgcp_client/mgcp_client.h b/include/osmocom/mgcp_client/mgcp_client.h index c1fd1b0..98e58d7 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 at mgw'. + * If this is nonempty, the contained name will be used instead of 'mgw'. */ + char endpoint_domain_name[MGCP_ENDPOINT_MAXLEN]; }; 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 8fa82cd..03e1da7 100644 --- a/src/libosmo-mgcp-client/mgcp_client.c +++ b/src/libosmo-mgcp-client/mgcp_client.c @@ -705,6 +705,16 @@ mgcp->actual.remote_port = conf->remote_port >= 0 ? (uint16_t)conf->remote_port : MGCP_CLIENT_REMOTE_PORT_DEFAULT; + if (osmo_strlcpy(mgcp->actual.endpoint_domain_name, conf->endpoint_domain_name, + sizeof(mgcp->actual.endpoint_domain_name)) + >= sizeof(mgcp->actual.endpoint_domain_name)) { + LOGP(DLMGCP, LOGL_ERROR, "MGCP client: endpoint domain name is too long, max length is %zu: '%s'\n", + sizeof(mgcp->actual.endpoint_domain_name) - 1, conf->endpoint_domain_name); + talloc_free(mgcp); + return NULL; + } + LOGP(DLMGCP, LOGL_NOTICE, "MGCP client: using endpoint domain '@%s'\n", mgcp_client_endpoint_domain(mgcp)); + return mgcp; } @@ -811,6 +821,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 of %zu: '" RTPBRIDGE_WILDCARD_FMT "'\n", + sizeof(endpoint) - 1, 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 8fa0272..d4e78f1 100644 --- a/src/libosmo-mgcp-client/mgcp_client_vty.c +++ b/src/libosmo-mgcp-client/mgcp_client_vty.c @@ -137,6 +137,22 @@ 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") +{ + if (osmo_strlcpy(global_mgcp_client_conf->endpoint_domain_name, argv[0], + sizeof(global_mgcp_client_conf->endpoint_domain_name)) + >= sizeof(global_mgcp_client_conf->endpoint_domain_name)) { + vty_out(vty, "%% Error: 'mgw endpoint-domain' name too long, max length is %zu: '%s'%s", + sizeof(global_mgcp_client_conf->endpoint_domain_name) - 1, argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + return CMD_SUCCESS; +} + int mgcp_client_config_write(struct vty *vty, const char *indent) { const char *addr; @@ -160,6 +176,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; } @@ -174,6 +194,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: merged Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8 Gerrit-Change-Number: 12357 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-CC: Stefan Sperling <stsp at stsp.name> Gerrit-CC: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190104/90b619af/attachment.htm>