From 68fbf1ae69e875b95a29b8b32ca21b428f7c430f Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 20 Mar 2021 11:16:53 +0100 Subject: [PATCH] Osmo-CC: The 'local' socket peer is also used as default rtp-peer --- src/libosmocc/endpoint.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libosmocc/endpoint.c b/src/libosmocc/endpoint.c index 317efdb..e1d6027 100644 --- a/src/libosmocc/endpoint.c +++ b/src/libosmocc/endpoint.c @@ -1085,6 +1085,7 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text) { const char **address_p, **host_p; uint16_t *port_p; + int local = 0; int rc; if (!strncasecmp(text, "local", 5)) { @@ -1098,6 +1099,7 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text) address_p = &ep->local_address; host_p = &ep->local_host; port_p = &ep->local_port; + local = 1; } else if (!strncasecmp(text, "remote", 6)) { text += 6; /* remove spaces after keyword */ @@ -1137,6 +1139,17 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text) *address_p = strdup(text); *host_p = strdup(*host_p); + if (local) { + enum osmo_cc_session_addrtype addrtype; + addrtype = osmo_cc_address_type(*host_p); + if (addrtype == osmo_cc_session_addrtype_unknown) { + PDEBUG(DCC, DEBUG_ERROR, "Given local address '%s' is invalid.\n", *host_p); + return -EINVAL; + } + osmo_cc_set_local_peer(osmo_cc_session_nettype_inet, addrtype, *host_p); + return 0; + } + return 0; } @@ -1149,8 +1162,8 @@ static void osmo_cc_help_rtp(void) printf("rtp-ports \n\n"); printf("These options can be used to alter the local IP and port range for RTP traffic.\n"); - printf("By default the local IPv4 loopback address is used. To connect interfaces\n"); - printf("between machines, local machine's IP must be given.\n\n"); + printf("By default the local peer is used, which is loopback by default. To connect\n"); + printf("interfaces, between machines, local machine's IP must be given.\n\n"); } static int osmo_cc_set_rtp(const char *text)