diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-01 17:29:53 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-01 17:29:53 +0000 |
commit | b4e052ff22291a55e9791baa1c8a73f278550215 (patch) | |
tree | 58d4d6fa1212a34bfa6d9323192f4161d1df4a38 /pjlib/src | |
parent | 5d83e25006ecd3ba2b2c9ee73c337ddb0b44125d (diff) |
Fixed ticket #151: pj_gethostip() should fallback to default interface when 127.x.x.x is returned, not just 127.0.0.1 (thanks Andrey Kuprianov)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1025 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src')
-rw-r--r-- | pjlib/src/pj/addr_resolv_sock.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/pjlib/src/pj/addr_resolv_sock.c b/pjlib/src/pj/addr_resolv_sock.c index a292becd..04c0152b 100644 --- a/pjlib/src/pj/addr_resolv_sock.c +++ b/pjlib/src/pj/addr_resolv_sock.c @@ -59,12 +59,8 @@ pj_status_t pj_gethostip(pj_in_addr *addr) { const pj_str_t *hostname = pj_gethostname(); struct pj_hostent he; - pj_str_t cp; - pj_in_addr loopip; pj_status_t status; - cp = pj_str("127.0.0.1"); - loopip = pj_inet_addr(&cp); #ifdef _MSC_VER /* Get rid of "uninitialized he variable" with MS compilers */ @@ -78,11 +74,12 @@ pj_status_t pj_gethostip(pj_in_addr *addr) } - /* If we end up with 127.0.0.1, resolve the IP by getting the default + /* If we end up with 127.x.x.x, resolve the IP by getting the default * interface to connect to some public host. */ - if (status != PJ_SUCCESS || addr->s_addr == loopip.s_addr) { + if (status != PJ_SUCCESS || (pj_ntohl(addr->s_addr) >> 24)==127) { pj_sock_t fd; + pj_str_t cp; pj_sockaddr_in a; int len; |