Skip to content

Commit 33d66a0

Browse files
authored
Fix wrong TCP/TLS source port in Contact & Via (#4627)
It was reported that the Contact and Via headers in REGISTER requests are using the listener port instead of the actual port, which did not occur in older PJSIP versions. Upon investigation, this behavior appears to be introduced by #4411, which always initializes the TCP/TLS local name using the listener's local name, regardless of whether the published address setting is configured Thanks to Marcus Froeschl for the report.
1 parent b772200 commit 33d66a0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pjsip/src/pjsip/sip_transport_tcp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,12 @@ static pj_status_t tcp_create( struct tcp_listener *listener,
678678

679679
/* Use listener's published address, if any. */
680680
tcp->base.has_addr_name = listener->factory.has_addr_name;
681-
tcp->base.local_name = listener->factory.addr_name;
681+
if (listener->factory.has_addr_name) {
682+
tcp->base.local_name = listener->factory.addr_name;
683+
} else {
684+
sockaddr_to_host_port(pool, &tcp->base.local_name,
685+
&tcp->base.local_addr);
686+
}
682687

683688
sockaddr_to_host_port(pool, &tcp->base.remote_name, remote);
684689
tcp->base.dir = is_server? PJSIP_TP_DIR_INCOMING : PJSIP_TP_DIR_OUTGOING;

pjsip/src/pjsip/sip_transport_tls.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,12 @@ static pj_status_t tls_create( struct tls_listener *listener,
925925

926926
/* Use listener's published address, if any. */
927927
tls->base.has_addr_name = listener->factory.has_addr_name;
928-
tls->base.local_name = listener->factory.addr_name;
928+
if (listener->factory.has_addr_name) {
929+
tls->base.local_name = listener->factory.addr_name;
930+
} else {
931+
sockaddr_to_host_port(pool, &tls->base.local_name,
932+
&tls->base.local_addr);
933+
}
929934

930935
if (tls->remote_name.slen) {
931936
tls->base.remote_name.host = tls->remote_name;

0 commit comments

Comments
 (0)