In pjproject-1.0.3/pjlib/include/pj/addr_resolv.h:320 118 /** 119 * Get the IP address of the default interface. Default interface is the 120 * interface of the default route. 121 * 122 * @param af The desired address family to query. Valid values 123 * are pj_AF_INET() or pj_AF_INET6(). 124 * @param addr On successful resolution, the address family and address 125 * part of this socket address will be filled up with the host 126 * IP address, in network byte order. Other parts of the socket 127 * address are untouched. 128 * 129 * @return PJ_SUCCESS on success, or the appropriate error code. 130 */ 131 PJ_DECL(pj_status_t) pj_getdefaultipinterface(int af, 132 pj_sockaddr *addr); Also, pj_enum_ip_interface (libs/pjproject-1.0.3/pjlib/src/pj/ip_helper_generic.c) uses if_enum_by_af which in turn calls pj_getdefaultipinterface. You were mentioning pj_gethostip. In libs/pjproject-1.0.3/pjlib/src/pj/sock_common.c:449 It does pj_getaddrinfo, then if it ends up with 127.0.0.0/8, it calls pj_getdefaultipinterface. If that fails, it uses pj_enum_ip_interface and picks the first interface, and if that fails again, the loopback interface is returned. Maybe you should consider offering the user the ability to manually select the interface he/she wishes to use. A few weeks ago, we had one of our user (https://launchpad.net/~daniel-gimpelevich) who sent us a patch for our softphone in order to "fix" what you seem to be experiencing. It's still considered for inclusion and not yet merged into our git repository. However, I'm attaching it so that you can study how it works. On Wed, 2009-08-12 at 16:46 +0800, xutm wrote: > Hi Pierre-Luc Bacon, > > > The IP of VMwareWorkstation is 10.10.10.1, and it cannot access the > NGN Server. > My PJSIP version is pjproject-1.1. Now I found in method > create_sip_udp_sock in pjsua_core.c, pjsip should Get the published > address, either by STUN or by resolving the name of local host. Before > calling method pj_gethostip, I print out the value in p_pub_addr, the > IP is 0.0.0.0, after calling, the value is 10.10.10.1. So I think the > method pj_gethostip is the primary point. > > pj_gethostip call method pj_getaddrinfo to get all IP addresses. But I > do not find the Detecting the default route? Exactly it did call > pj_enum_ip_interface -> enum_ipv4_interface to enumerating IP > interfaces and use the first one. > > So my question is: > 1. Where is it to detecting the default route > 2. How can I determine the appropriate IP interface if there is route > for every IP interface? Should I ping the destination IP first? > > 2009/8/11 Pierre-Luc Bacon <pierre-luc.bacon at savoirfairelinux.com> > I'm not sure I'd call that a bug. By default, PJSIP uses the > interface > that is bound to the default route. More specifically: > > "local IP is detected by: > - calling gethostbyaddr(gethostname()) > - detecting the default route > - enumerating IP interfaces and use the first interface" > > http://osdir.com/ml/voip.pjsip/2008-01/msg00044.html > > > On Tue, 2009-08-11 at 17:42 +0800, Ricky Wu wrote: > > Hi all, > > i have two NIC, and they have different IP. > > NIC A's IP is 172.18.1.131 > > NIC B's IP is 192.168.1.165 > > SIP server IP is 172.168.1.112. and NIC B can't > connent SIP > > server actually. > > but when i use PJSUA to register and make a call, I > find the > > server show NIC B is connenting. > > There is no this problem when i use other softphone. > > Is there someone can help me to modify this bug? > > > > > > > > > > > > > ______________________________________________________________________ > > ???????????,www.yeah.net > > > > _______________________________________________ > > Visit our blog: http://blog.pjsip.org > > > > pjsip mailing list > > pjsip at lists.pjsip.org > > > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > -------------- next part -------------- A non-text attachment was scrubbed... Name: daniel-gimpelevich-sflphone-pjsip.patch Type: text/x-patch Size: 3800 bytes Desc: not available URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090812/abc6c084/attachment-0001.patch>