- }
- }
-
-#ifdef IPV6
- /* If we got an address info use that... */
- if (ret->ai) {
-
- /* Are we in IPv4 fallback mode? */
- /* We put the IPv4 address into the a variable so we can further-on use the IPv4 code... */
- if (ret->family == AF_INET)
- memcpy(&a,
- (char *) &((struct sockaddr_in *) ret->ai->
- ai_addr)->sin_addr, sizeof(a));
-
- /* Now let's find that canonicalname... */
- if (getnameinfo((struct sockaddr *) ret->ai->ai_addr,
- ret->family ==
- AF_INET ? sizeof(struct sockaddr_in) :
- sizeof(struct sockaddr_in6), realhost,
- sizeof(realhost), NULL, 0, 0) != 0) {
- strncpy(realhost, host, sizeof(realhost));
- }
- }
- /* We used the IPv4-only gethostbyname()... */
- else
-#endif
- {
- memcpy(&a, h->h_addr, sizeof(a));
- /* This way we are always sure the h->h_name is valid :) */
- strncpy(realhost, h->h_name, sizeof(realhost));