c++ - Getting hostname aliases from IP -
i want list of aliases hostname in c++. input ip. call gethostbyaddr()
, returns hostent struct. struct has field list of aliases.
struct hostent { char far * h_name; /* official name of host */ char far * far * h_aliases; /* alias list */ short h_addrtype; /* host address type */ short h_length; /* length of address */ char far * far * h_addr_list; /* list of addresses */ };
gethostbyaddr() api legacy, , wanted support ipv6 inputs. replaced gethostbyaddr() getnameinfo()
recommended in msdn. after changes, there no way list of aliases hostname. getnameinfo() returns hostname string, , there no alias list returned it. can me alias list in case?
i don't think that's possible. dns stores:
- for each name, 1 or many ip/ipv6 addresses;
- for each ip/ipv6 address, 1 "canonical" name.
so can query addresses associated name (getaddrinfo
), or canonical name associated address (getaddrinfo
), there's no way query set of names map given address.
Comments
Post a Comment