diff options
author | Damien Miller <djm@mindrot.org> | 2000-03-11 20:45:40 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-03-11 20:45:40 +1100 |
commit | 7bcb089ef791e2b624cf349ba24bf798aebef99a (patch) | |
tree | 40be5ead7ace0d0e16adb69781f05483e58511ca /canohost.c | |
parent | d58b3abe0e9d887a00679245065ee91b8565037f (diff) |
- IPv6 workarounds from Hideaki YOSHIFUJI <yoshfuji@ecei.tohoku.ac.jp>
Diffstat (limited to 'canohost.c')
-rw-r--r-- | canohost.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/canohost.c b/canohost.c index 9a6d8b732..a11d66392 100644 --- a/canohost.c +++ b/canohost.c | |||
@@ -14,7 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include "includes.h" | 16 | #include "includes.h" |
17 | RCSID("$Id: canohost.c,v 1.7 2000/01/14 04:45:48 damien Exp $"); | 17 | RCSID("$Id: canohost.c,v 1.8 2000/03/11 09:45:41 damien Exp $"); |
18 | 18 | ||
19 | #include "packet.h" | 19 | #include "packet.h" |
20 | #include "xmalloc.h" | 20 | #include "xmalloc.h" |
@@ -42,6 +42,30 @@ get_remote_hostname(int socket) | |||
42 | debug("getpeername failed: %.100s", strerror(errno)); | 42 | debug("getpeername failed: %.100s", strerror(errno)); |
43 | fatal_cleanup(); | 43 | fatal_cleanup(); |
44 | } | 44 | } |
45 | |||
46 | #ifdef IPV4_IN_IPV6 | ||
47 | if (from.ss_family == AF_INET6) { | ||
48 | struct sockaddr_in6 *from6 = (struct sockaddr_in6 *)&from; | ||
49 | |||
50 | /* Detect IPv4 in IPv6 mapped address and convert it to */ | ||
51 | /* plain (AF_INET) IPv4 address */ | ||
52 | if (IN6_IS_ADDR_V4MAPPED(&from6->sin6_addr)) { | ||
53 | struct sockaddr_in *from4 = (struct sockaddr_in *)&from; | ||
54 | struct in_addr addr; | ||
55 | u_int16_t port; | ||
56 | |||
57 | memcpy(&addr, ((char *)&from6->sin6_addr) + 12, sizeof(addr)); | ||
58 | port = from6->sin6_port; | ||
59 | |||
60 | memset(&from, 0, sizeof(from)); | ||
61 | |||
62 | from4->sin_family = AF_INET; | ||
63 | memcpy(&from4->sin_addr, &addr, sizeof(addr)); | ||
64 | from4->sin_port = port; | ||
65 | } | ||
66 | } | ||
67 | #endif | ||
68 | |||
45 | if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop), | 69 | if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop), |
46 | NULL, 0, NI_NUMERICHOST) != 0) | 70 | NULL, 0, NI_NUMERICHOST) != 0) |
47 | fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed"); | 71 | fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed"); |