From b379bd7af9cb2671bd3a67d429225d51a3ad86fa Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Mon, 6 Nov 2023 16:46:34 +0100 Subject: [PATCH] sip/transp: add win32 local transport addr fallback (#1001) tcp_conn_local_get function does not always return information about the host address when the socket has been bound to an unspecified address. fixes baresip/baresip#2797 --- src/sip/transp.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sip/transp.c b/src/sip/transp.c index eb7717b3e..ada515522 100644 --- a/src/sip/transp.c +++ b/src/sip/transp.c @@ -792,8 +792,22 @@ static int conn_send(struct sip_connqent **qentp, struct sip *sip, bool secure, if (err) goto out; - if (connh) + /* Fallback check for any address win32 */ + if (!sa_isset(&conn->laddr, SA_ALL)) { + uint16_t port = sa_port(&conn->laddr); + err = sip_transp_laddr(sip, &conn->laddr, conn->tp, dst); + if (err) + goto out; + + if (port) + sa_set_port(&conn->laddr, port); + } + + if (connh) { err = connh(&conn->laddr, dst, mb, arg); + if (err) + goto out; + } (void)tcp_conn_settos(conn->tc, sip->tos); #ifdef USE_TLS