tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: getaddrinfo(3) on numerical addresses
> So, especially for a portable application, I would say it should be
> handled at the application level: as already pointed out, setting
> AI_NUMERICHOST should prevent the unintended name resolution in the
> above example (I confirmed it with my test code). I believe that will
> work for almost all variants of getaddrinfo() implementations that
> way, whatever policy its developer has on what should happen for
> 1.2.3.4 with AF_INET6 but not AI_NUMERICHOST.
I guess that setting AI_NUMERICHOST will make getaddrinfo() fail if the argument is non-numeric.
So if the desired application behaviour (i.e. what I consider useful in the case of check_ping) is:
1. If it's parsable as a numeric IPv4 address, treat it as v4, no DNS lookup
2. If it's parsable as a numeric IPv6 address, treat it as v6, no DNS lookup
3. Else, do a DNS lookup (where one can argue what to do if the name has both
A and AAAA records)
then no single invocation of getaddrinfo() will do, right?
Home |
Main Index |
Thread Index |
Old Index