IPv6 and FreeBSD

Johan van Selst johans at stack.nl
Wed Oct 22 07:59:22 UTC 2008


Julien ÉLIE wrote:
> Thanks.  I will add "if (ListenAddr != NULL)" conditions.

ListenAddr will never be NULL, as this is a static array of characters
rather than a character pointer. Still the value should be initalized
(not not used when it is not initialized).

> The size is good because ssa has the right size:

The relevant code which determines the value of sizeof(ssa) is:

 #ifdef HAVE_INET6
     struct sockaddr_storage ssa, csa;
     struct sockaddr_in6 *ssa6 = (struct sockaddr_in6 *) &ssa;
 #else
     struct sockaddr_in  ssa, csa;
 #endif

So the type of ssa is defined at compile time, depending on
whether INET6 is available or not.

>        if (bind(lfd, (struct sockaddr *) &ssa, sizeof(ssa)) < 0) {
>            syslog(L_FATAL, "can't bind local address (%m)");
>            exit(1);
>        }

> memset ajusts it for IPv6 and then IPv4 ,if it fails.
> I do not see why the size is not right here in bind().

No, the memset earlier has no effect at all on the value of
sizeof(ssa) here. If INET6 is available, then the third argument
will be sizeof(ssa) = sizeof(struct sockaddr_storage) = 128
even when an IPv4 address is used as second argument.


Johan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20081022/8d27b19d/attachment.bin>


More information about the inn-workers mailing list