- /* Look up the remote host name. */
- if ((hp = gethostbyaddr((char *) &sockin->sin_addr,
- sizeof(sockin->sin_addr),
- AF_INET))) {
- strlcpy(name_buf,(char *)hp->h_name,sizeof(name_buf));
- }
-
-
- /* do a forward lookup as well to prevent spoofing */
- hp = gethostbyname(name_buf);
- if (!hp) {
- strcpy (name_buf,def);
- rprintf (FERROR, "reverse name lookup for \"%s\" failed\n",
- name_buf);
- } else {
- for (p=hp->h_addr_list;*p;p++) {
- if (memcmp(*p, &sockin->sin_addr, hp->h_length) == 0) {
- break;
- }
- }
- if (!*p) {
- strcpy(name_buf,def);
- rprintf(FERROR,"reverse name lookup mismatch - spoofed address?\n");
- }
- }
-
- return name_buf;
-}
-
-/**
- Convert a string to an IP address. The string can be a name or
- dotted decimal number.
-
- Returns a pointer to a static in_addr struct -- if you call this
- more than once then you should copy it.
-*/
-struct in_addr *ip_address(const char *str)
-{
- static struct in_addr ret;
- struct hostent *hp;
-
- if (!str) {
- rprintf (FERROR, "ip_address received NULL name\n");
- return NULL;
- }
-
- /* try as an IP address */
- if (inet_aton(str, &ret) != 0) {
- return &ret;
- }
+#ifdef INET6
+ if (ss.sa_family == AF_INET6 &&
+ IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&ss)->sin6_addr)) {
+ struct sockaddr_in6 sin6;
+ struct sockaddr_in *sin;