[asterisk-dev] Getting IP of host when not NATted (technical code question)

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Tue Dec 12 12:05:44 MST 2006


On Tuesday 12 December 2006 09:34, jezzzz . wrote:
> (I asked this question in users, was referred to the
> dev list)
>
> In chan_sip.c, line 5876 (Asterisk-1.2.13), the
> function parse_ok_contact returns whether the host
> that requested an invite is a valid or invalid host.
>
> In line 5925 the following clause is tested:
>
> if (!(ast_test_flag(pvt, SIP_NAT) & SIP_NAT_ROUTE))
>     hp = ast_gethostbyname(n, &ahp);
>
> If this clause is false then Asterisk will attempt to
> retrieve the IP address by using the hostname provided
> in the invite.
>
> My question is, is this test always going to be true
> if a user (who receives the invite) does not use NAT
> and the person sending the invite sends a hostname
> rather than an IP? Is there a reason why this was set
> up only for non-NATted?

Yes, because if a phone is coming in from behind NAT, then
you want to respond to the same host and port from which you
received the packet, not necessarily the host which is encoded
within.  It's a technical violation of the SIP spec, but it also tends
to make things work the way it is desired.

-- 
Tilghman


More information about the asterisk-dev mailing list