diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-04-30 17:14:50 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-04-30 17:14:50 +0000 |
commit | fdf8a4face60342812ec1fc0b24405602a80ec37 (patch) | |
tree | 277fb6c3327246bb39c7f6f7a0e822e44ba5ff87 /pjnath/src | |
parent | 68b078949098a83c39bb5f12348ee5c15f8ee720 (diff) |
Ticket #757:
- put the default IP as the first host candidate
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2667 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/src')
-rw-r--r-- | pjnath/src/pjnath/stun_sock.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/pjnath/src/pjnath/stun_sock.c b/pjnath/src/pjnath/stun_sock.c index 70c257a9..a0d5ff2c 100644 --- a/pjnath/src/pjnath/stun_sock.c +++ b/pjnath/src/pjnath/stun_sock.c @@ -534,8 +534,17 @@ PJ_DEF(pj_status_t) pj_stun_sock_get_info( pj_stun_sock *stun_sock, info->alias_cnt = 1; pj_sockaddr_cp(&info->aliases[0], &info->bound_addr); } else { + pj_sockaddr def_addr; + pj_uint16_t port = pj_sockaddr_get_port(&info->bound_addr); unsigned i; + /* Get the default address */ + status = pj_gethostip(stun_sock->af, &def_addr); + if (status != PJ_SUCCESS) + return status; + + pj_sockaddr_set_port(&def_addr, port); + /* Enum all IP interfaces in the host */ info->alias_cnt = PJ_ARRAY_SIZE(info->aliases); status = pj_enum_ip_interface(stun_sock->af, &info->alias_cnt, @@ -545,10 +554,18 @@ PJ_DEF(pj_status_t) pj_stun_sock_get_info( pj_stun_sock *stun_sock, /* Set the port number for each address. */ - if (stun_sock->af == pj_AF_INET()) { - for (i=0; i<info->alias_cnt; ++i) { - pj_sockaddr_set_port(&info->aliases[i], - pj_sockaddr_get_port(&info->bound_addr)); + for (i=0; i<info->alias_cnt; ++i) { + pj_sockaddr_set_port(&info->aliases[i], port); + } + + /* Put the default IP in the first slot */ + for (i=0; i<info->alias_cnt; ++i) { + if (pj_sockaddr_cmp(&info->aliases[i], &def_addr)==0) { + if (i!=0) { + pj_sockaddr_cp(&info->aliases[i], &info->aliases[0]); + pj_sockaddr_cp(&info->aliases[0], &def_addr); + } + break; } } } |