diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-06-09 10:07:11 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-06-09 10:07:11 +0000 |
commit | bbb7c0f580049864574c0da8402d4b92767c356f (patch) | |
tree | d2828ecf7ab9fe214fbc7ea6314d8aef29f793e1 | |
parent | aaf615c87e0dda72c1d4be4447f6cc7a4e6f4dcb (diff) |
Related to r1996, do not return 0.0.0.0/8 class IP address in pj_gethostip() (thanks Helmut Wolf)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1999 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjlib/src/pj/sock_common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pjlib/src/pj/sock_common.c b/pjlib/src/pj/sock_common.c index fc68c2a0..dbdfb81e 100644 --- a/pjlib/src/pj/sock_common.c +++ b/pjlib/src/pj/sock_common.c @@ -468,11 +468,14 @@ PJ_DEF(pj_status_t) pj_gethostip(int af, pj_sockaddr *addr) } - /* If we end up with 127.x.x.x, resolve the IP by getting the default - * interface to connect to some public host. + /* If we end up with 127.0.0.0/8 or 0.0.0.0/8, resolve the IP + * by getting the default interface to connect to some public host. + * The 0.0.0.0/8 is a special IP class that doesn't seem to be + * practically useful for our purpose. */ if (status != PJ_SUCCESS || !pj_sockaddr_has_addr(addr) || - (af==PJ_AF_INET && (pj_ntohl(addr->ipv4.sin_addr.s_addr) >> 24)==127)) + (af==PJ_AF_INET && (pj_ntohl(addr->ipv4.sin_addr.s_addr)>>24)==127) || + (af==PJ_AF_INET && (pj_ntohl(addr->ipv4.sin_addr.s_addr)>>24)==0)) { status = pj_getdefaultipinterface(af, addr); } |