Question about local ip address selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 26, 2009 at 12:12 PM, Johan Lantz <johan.lantz at genaker.net>wrote:

> Hi
>
> I wonder how it comes that pj_gethostip(..) always will return the loopback
> adapter in case everything else fails.
>
> This caused a slight confusion in my trials since we established the
> network connection ourselves (Windows Mobile). The connection returned ok
> but I guess the IP adapter was not yet completly configured when I
> initialized pjsip leading to that I got the loopback adapter configured as
> my ip address.
>
> IMO it feels like if the PJ_IP_HELPER_IGNORE_LOOPBACK_IF is set this part :
>
> /* If else fails, returns loopback interface as the last resort */
>   if (status != PJ_SUCCESS) {
>       PJ_LOG(1,("XXX","failed to get the first one, returning loopback
> if"));
>       if (af==PJ_AF_INET) {
>           addr->ipv4.sin_addr.s_addr = pj_htonl (0x7f000001);
>       } else {
>           pj_in6_addr *s6_addr;
>             s6_addr = (pj_in6_addr*) pj_sockaddr_get_addr(addr);
>           pj_bzero(s6_addr, sizeof(pj_in6_addr));
>           s6_addr->s6_addr[15] = 1;
>       }
>       status = PJ_SUCCESS;
>   }
>
> should not be executed and an error should be returned instad of returning
> the loopback adapter.
>
>
I still prefer that pj_gethostip() would always return some IP regardless
whether network is available for not though, for practical reasons. For
example, when testing new platform which lacks network connectivity, or
simply when one is using a laptop on a flight/travel.

If you require that a "valid" interface should be returned, then I can only
suggest to wait until the interface is fully up and running before starting
PJLIB.



> I do not really understand how the server should be able to contact me if
> my Contact: header contains 127.0.0.1. However I spotted the reply a few
> days ago to another question where Benny said, quote:
> "
>
> The selected IP shouldn't matter much IMO. For signaling, the IP will be
> (re)learnt from REGISTER response. And for media, that exactly what ICE is
> for, among other things.
> "
>
> It might very well be that I do not get the full picture here. Is there a
> way that the server will respond with a local IP for us in the 200 OK for
> REGISTER?


Yes, it should be in the "received" and "rport" parameter of the Via header
in the response.


> Atleast in the current setup it does not (is ICE required for this).
>
>
ICE is not required for this. It should work, as long as you put
pjsua_acc_config.allow_contact_rewrite in its default value (1). If not,
then you can blame your server or an ALG in the middle for not being
SIP-conformant. :)

cheers
 Benny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090126/cb9e1c6e/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux