summaryrefslogtreecommitdiffstats
path: root/canohost.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-03-11 20:45:40 +1100
committerDamien Miller <djm@mindrot.org>2000-03-11 20:45:40 +1100
commit7bcb089ef791e2b624cf349ba24bf798aebef99a (patch)
tree40be5ead7ace0d0e16adb69781f05483e58511ca /canohost.c
parentd58b3abe0e9d887a00679245065ee91b8565037f (diff)
- IPv6 workarounds from Hideaki YOSHIFUJI <yoshfuji@ecei.tohoku.ac.jp>
Diffstat (limited to 'canohost.c')
-rw-r--r--canohost.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/canohost.c b/canohost.c
index 9a6d8b73..a11d6639 100644
--- a/canohost.c
+++ b/canohost.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: canohost.c,v 1.7 2000/01/14 04:45:48 damien Exp $");
+RCSID("$Id: canohost.c,v 1.8 2000/03/11 09:45:41 damien Exp $");
#include "packet.h"
#include "xmalloc.h"
@@ -42,6 +42,30 @@ get_remote_hostname(int socket)
debug("getpeername failed: %.100s", strerror(errno));
fatal_cleanup();
}
+
+#ifdef IPV4_IN_IPV6
+ if (from.ss_family == AF_INET6) {
+ struct sockaddr_in6 *from6 = (struct sockaddr_in6 *)&from;
+
+ /* Detect IPv4 in IPv6 mapped address and convert it to */
+ /* plain (AF_INET) IPv4 address */
+ if (IN6_IS_ADDR_V4MAPPED(&from6->sin6_addr)) {
+ struct sockaddr_in *from4 = (struct sockaddr_in *)&from;
+ struct in_addr addr;
+ u_int16_t port;
+
+ memcpy(&addr, ((char *)&from6->sin6_addr) + 12, sizeof(addr));
+ port = from6->sin6_port;
+
+ memset(&from, 0, sizeof(from));
+
+ from4->sin_family = AF_INET;
+ memcpy(&from4->sin_addr, &addr, sizeof(addr));
+ from4->sin_port = port;
+ }
+ }
+#endif
+
if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop),
NULL, 0, NI_NUMERICHOST) != 0)
fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed");