sockaddr_(in|in6) compatiblity

Lukasz Stelmach Lukasz.Stelmach at telmark.waw.pl
Thu Mar 18 05:05:27 PST 2004


 Byla godzina 03:48:02 w Wednesday 10 March, gdy do autobusu wsiadl kanar
 i wrzasnal:"Hajimu UMEMOTO!!! Bilecik do kontroli!!!" A on(a) na to:

LS>> 1. I open socket AF_INET6/SOCK_DGRAM... OK
LS>> 2. bind it to ::ffff:127.0.0.1/53...    OK
HU> Why do you use IPv4-mapped IPv6 address for binding IPv4?  When you
HU> wish to bind to IPv4, just use AF_INET socket.

It is not me in fact who ueses it. I try to setup djbdns with IPv6
support.

HU>  This feature is disabled by default on 5-CURRENT.

Can you tell me (or give some article to read) why? I am curious
because i think this is quite good for a programmer to use one
type of socket and the same set of structures for both protocols,
especially now when IPv6 just starts its go.

LS>> 3. recvfrom() data from the socket...   OK
LS>> 4. *from (the 5th parameter to recvfrom) gets filled in like it was
LS>>  a sockaddr_in (ipv4) structure
[...]

HU> Use getnameinfo(3).  You shouldn't need to use inet_ntop(3).  Welcome
HU> to an address family independent programming with getaddrinfo(3) and
HU> getnameinfo(3).

In fact it is not the matter of inet_ntop(3) but the way the djbdns patch
seems to work. get*info(3) won't do the thing since to get the address from
sockaddr structure (after recvfrom) i still need to check the family
field and do proper cast.

IMHO it would be much more logical that if I open AF_INET6 socket
(even v4 mapped) i *always* get sockaddr_in6 structure and need not to
cast it to sockaddr_in.

Best regards,
-- 
|/       |_,  _   .-  --,  Już z każdej strony pełzną, potworne żądze
|__ |_|. | \ |_|. ._' /_.         Będę uprawiał nierząd, za pieniąze
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20040318/16acf686/attachment.bin


More information about the freebsd-stable mailing list