From bbb7c0f580049864574c0da8402d4b92767c356f Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 9 Jun 2008 10:07:11 +0000 Subject: 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 --- pjlib/src/pj/sock_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'pjlib/src/pj/sock_common.c') 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); } -- cgit v1.2.3