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/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/19971 )
Change subject: mgw: Find and store RTP conn local_addr once during CRCX handling
......................................................................
mgw: Find and store RTP conn local_addr once during CRCX handling
It doesn't make sense to call the function several times since anyway we
are only binding during
allocate_port()->mgcp_bind_net_rtp_port()->bind_rtp()->mgcp_create_bind()->osmo_sock_init2().
Let's better calculate the local IP addr once and use that stored value.
THis is a previous step towards next commit updating the local IP addr
and re-bindng if encessary.
Change-Id: I803b99c5e5fe0f92a5bf6796d8c25df88d1608e6
---
M include/osmocom/mgcp/mgcp_network.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_protocol.c
3 files changed, 15 insertions(+), 14 deletions(-)
Approvals:
Jenkins Builder: Verified
dexter: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
diff --git a/include/osmocom/mgcp/mgcp_network.h b/include/osmocom/mgcp/mgcp_network.h
index 9674445..7dbf330 100644
--- a/include/osmocom/mgcp/mgcp_network.h
+++ b/include/osmocom/mgcp/mgcp_network.h
@@ -118,6 +118,9 @@
/* local UDP port number of the RTP socket; RTCP is +1 */
int local_port;
+ /* where the endpoint RTP connection binds to, set during CRCX and
+ * possibly updated during MDCX */
+ char local_addr[INET6_ADDRSTRLEN];
};
struct mgcp_rtp_tap {
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 84f3604..75a4754 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1620,7 +1620,6 @@
{
char name[512];
struct mgcp_rtp_end *end;
- char local_ip_addr[INET6_ADDRSTRLEN];
snprintf(name, sizeof(name), "%s-%s", conn->conn->name, conn->conn->id);
end = &conn->end;
@@ -1643,9 +1642,7 @@
end->rtcp.data = conn;
end->rtcp.cb = rtp_data_net;
- mgcp_get_local_addr(local_ip_addr, conn);
-
- return bind_rtp(endp->cfg, local_ip_addr, end, endp);
+ return bind_rtp(endp->cfg, conn->end.local_addr, end, endp);
}
/*! free allocated RTP and RTCP ports.
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 1269524..1e7ccbf 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -223,24 +223,22 @@
const char *trans_id,
bool add_conn_params)
{
- /* TODO: we may want to define another local_ip_osmux var to us for
- OSMUX connections. Perhaps adding a new internal API to get it based
- on conn type */
- const char *addr = endp->cfg->local_ip;
+ /* cfg->local_ip allows overwritting the announced IP address with
+ * regards to the one we actually bind to. Useful in behind-NAT
+ * scenarios.
+ * TODO: we may want to define another local_ip_osmux var to
+ * us for OSMUX connections. Perhaps adding a new internal API to get it
+ * based on conn type.
+ */
+ const char *addr = endp->cfg->local_ip ? : conn->end.local_addr;
struct msgb *sdp;
int rc;
struct msgb *result;
- char local_ip_addr[INET6_ADDRSTRLEN];
sdp = msgb_alloc_headroom(4096, 128, "sdp record");
if (!sdp)
return NULL;
- if (!addr) {
- mgcp_get_local_addr(local_ip_addr, conn);
- addr = local_ip_addr;
- }
-
/* Attach optional connection parameters */
if (add_conn_params) {
rc = add_params(sdp, endp, conn);
@@ -943,6 +941,9 @@
goto error2;
}
+ /* Find a local address for conn based on policy and initial SDP remote
+ information, then find a free port for it */
+ mgcp_get_local_addr(conn->end.local_addr, conn);
if (allocate_port(endp, conn) != 0) {
rate_ctr_inc(&rate_ctrs->ctr[MGCP_CRCX_FAIL_BIND_PORT]);
goto error2;
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/19971
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I803b99c5e5fe0f92a5bf6796d8c25df88d1608e6
Gerrit-Change-Number: 19971
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200908/399e7e33/attachment.htm>