[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(usagi-users 02111) Re: multiproto bind() ?
- To: usagi-users@xxxxxxxxxxxxxx
- Subject: (usagi-users 02111) Re: multiproto bind() ?
- From: "Eva M. Castro" <ecastro@xxxxxxxxxx>
- Date: Sun, 19 Jan 2003 11:37:44 +0000
- References: <20030119015348.W43691-100000@wireless.cs.twsu.edu>
- Reply-to: usagi-users@xxxxxxxxxxxxxx
- Resent-date: Sun, 19 Jan 2003 19:49:04 +0900
- Resent-from: yoshfuji@xxxxxxxxxxxxxx
- Resent-message-id: <200301191949.FMLAAB11184.usagi-users@linux-ipv6.org>
- Resent-to: usagi-users@xxxxxxxxxxxxxx (moderated)
Abdul Basit wrote:
> i want to distinguish between clients coming to ipv4 or ipv6
> and print client address ? if i would get sa_family correct
> i can switch(family) { and case for AF_INET and AF_INET6 and
> use inet_ntop to print address ? but i am getting same family
> always (28c/bsd and 10c/linux --> AF_INET6)
>
> any hints?
When an IPv4 client connects to your server, the connection is established
using an IPv4-mapped IPv6 address, for instance, if your IPv4 client
is running at host using a.b.c.d IPv4 address, the IPv4-mapped IPv6
address will be:
::FFFF:a.b.c.d
Then, your IPv6 server will always use IPv6 addresses,
IPv6 addresses when connections come from IPv6 hosts and
IPv4-mapped IPv6 addresses when connections come from IPv4 hosts.
This is the reason you always print AF_INET6.
You can see how it works:
http://jungla.dit.upm.es/~ecastro/IPv6-web/ipv6.html
in the figure "IPv6 server on dual stack".
There is a macro definition to check if an address is IPv4-mapped IPv6
address:
IN6_IS_ADDR_V4MAPPED
Using this macro you can check if the client connections come from
IPv4 or IPv6 host.
I hope it helps,
eva