[asterisk-dev] [Code Review] Add getnameinfo() to ast_sockaddr_resolve ()
Simon Perreault
simon.perreault at viagenie.ca
Thu May 5 13:28:05 CDT 2011
On 2011-05-05 13:51, Tilghman Lesher wrote:
>> - 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.
>
> That's not true, though. Some IP addresses in non-dotted format can be
> confused with hostnames.
As mentioned earlier in this thread, SIP's grammar makes this impossible.
host = hostname / IPv4address / IPv6reference
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum
/ alphanum *( alphanum / "-" ) alphanum
toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum
IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
IPv6reference = "[" IPv6address "]"
IPv6address = hexpart [ ":" IPv4address ]
hexpart = hexseq / hexseq "::" [ hexseq ] / "::" [ hexseq ]
hexseq = hex4 *( ":" hex4)
hex4 = 1*4HEXDIG
>> 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.
>
> But IP addresses in non-dotted format will NEVER fail. That is very wrong,
> as well.
Please explain why.
If the user specifies "1050" with "this is *not* a peer", then the
reasonable course of action is to interpret this as an IP address.
Or are you arguing that this is wrong and that resolving "1050" should
fail? If so, then you have decades-long implementation history to fight
against...
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