[asterisk-dev] [Code Review] Add getnameinfo() to ast_sockaddr_resolve ()

Simon Perreault simon.perreault at viagenie.ca
Thu May 5 11:56:15 CDT 2011


On 2011-05-05 12:25, Tilghman Lesher wrote:
> On Wednesday 04 May 2011 08:12:50 Simon Perreault wrote:
>> I don't think it is useful to disambiguate between an IP address and a
>> host name.
> 
> If you don't, then this entire thread is moot.  We have to be able to
> disambiguate between those two, because some peer names can be
> confused with IP addresses (in a nonstandard format), but host names
> should be distinct from IP addresses.

I think you misunderstood. Let me try again.

To be clear:
A peer name is configured in sip.conf.
A host name is resolved with getaddrinfo().

My point:
- It is useful to disambiguate between a peer name and something else.
Why: Because peer names are undistinguishable from host names and IP
addresses.

- It is not useful to disambiguate between a host name and an IP address.
Why: Because their grammars allow us to distinguish them. That is what
getaddrinfo() does internally.

(By "disambiguate", I mean adding syntax allowing the user to specify
which one is which in extensions.conf.)

> Consider that "1" should be
> evaluated first as a possible peer name, secondly as a hostname, and only
> finally as an IP address (because this third possibility will always return
> a positive result).

I think this order is wrong. It should be

1. peer name
2. IP address
3. host name

Otherwise you will end up querying the DNS for IP address literals. That
would be very wrong.

Now, it turns out that getaddrinfo() does 2 and 3, in that order. So we
just need to do, in pseudocode:

if (it's a peer name) {
   find it in sip.conf;
} else {
   getaddrinfo();
}

What's missing is the "it's a peer name" part, for which new syntax is
necessary.

Simon
-- 
DTN made easy, lean, and smart --> http://postellation.viagenie.ca
NAT64/DNS64 open-source        --> http://ecdysis.viagenie.ca
STUN/TURN server               --> http://numb.viagenie.ca



More information about the asterisk-dev mailing list