From e56ec4a146b5df46cac3676d5fa69806daaa5a20 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 4 Oct 2022 14:35:00 +0200 Subject: [PATCH] osmux: Use available API to check if remote end is known Since recently the port is guaranteed to be placed at CRCX/MDCX in the sockaddr, hence we can check it using the API instead of checking manually only for the address part. In osmux_send_dummy() we actually fix a bug where an in_addr was being compared against a struct sockaddr. Change-Id: I736e7f4c51e577d8eb0b96bc776f984f928b6d27 --- src/libosmo-mgcp/mgcp_osmux.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index 242f9074e..de0bc38db 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -504,7 +504,6 @@ int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn, * overlapping RTP SSRC traveling to the BTSes behind the BSC, * similarly, for flows traveling to the MSC. */ - struct in6_addr addr_unset = {}; static const uint32_t rtp_ssrc_winlen = UINT32_MAX / (OSMUX_CID_MAX + 1); uint16_t osmux_dummy = endp->trunk->cfg->osmux_dummy; @@ -517,10 +516,7 @@ int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn, } /* Wait until we have the connection information from MDCX */ - if (memcmp(&conn->end.addr, &addr_unset, - conn->end.addr.u.sa.sa_family == AF_INET6 ? - sizeof(struct in6_addr) : - sizeof(struct in_addr)) == 0) { + if (!mgcp_rtp_end_remote_addr_available(&conn->end)) { LOGPCONN(conn->conn, DOSMUX, LOGL_INFO, "Osmux remote address/port still unknown\n"); return -1; @@ -622,7 +618,6 @@ int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn) char ipbuf[INET6_ADDRSTRLEN]; struct osmux_hdr *osmuxh; int buf_len; - struct in_addr addr_unset = {}; /*! The dummy packet will not be sent via the actual OSMUX connection, * instead it is sent out of band to port where the remote OSMUX @@ -634,7 +629,7 @@ int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn) * approach is simple though. */ /* Wait until we have the connection information from MDCX */ - if (memcmp(&conn->end.addr, &addr_unset, sizeof(addr_unset)) == 0) + if (!mgcp_rtp_end_remote_addr_available(&conn->end)) return 0; if (endp_osmux_state_check(endp, conn, true) < 0)