diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-02-14 14:36:13 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-02-14 14:36:13 +0000 |
commit | 39f601dab4c54ead07b1d1c8ee59f7aebe6bc019 (patch) | |
tree | 3c9dea3bf2aa29ff4479bb53ed9cacae11a6a828 /pjsip | |
parent | 7f42602646dff69ae69acecec318fd6b32bbf8f5 (diff) |
Fixed ticket #101: PJSUA transport is not updated with correct port number if application specifies port is zero
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@947 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 68da5cef..4b235d3b 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -841,6 +841,20 @@ static pj_status_t create_sip_udp_sock(pj_in_addr bound_addr, return status; } + /* If port is zero, get the bound port */ + if (port == 0) { + pj_sockaddr_in bound_addr; + int namelen = sizeof(bound_addr); + status = pj_sock_getsockname(sock, &bound_addr, &namelen); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "getsockname() error", status); + pj_sock_close(sock); + return status; + } + + port = pj_ntohs(bound_addr.sin_port); + } + /* Copy and normalize STUN param */ if (use_stun) { pj_memcpy(&stun, stun_param, sizeof(*stun_param)); @@ -873,7 +887,8 @@ static pj_status_t create_sip_udp_sock(pj_in_addr bound_addr, * Public address is already specified, no need to resolve the * address, only set the port. */ - /* Do nothing */ + if (p_pub_addr->sin_port == 0) + p_pub_addr->sin_port = pj_htons((pj_uint16_t)port); } else { |