develooper Front page | perl.perl5.porters | Postings from August 2001

Re: Adding IPv6 to Perl

Thread Previous | Thread Next
Jeff Okamoto
August 17, 2001 16:22
Re: Adding IPv6 to Perl
Message ID:
>     addr = SvPV(addrsv, len);
>     TAINT_PROPER("connect");
>     if (PerlSock_connect(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) >= 0)
>     else
> There is nothing here that knows about 'struct in_addr' for IPv4.  You
> just pack the correct thing into the 'addrsv' argument and the right
> stuff is eventually passed down to the OS-level connect().  This means
> that there is no need to replace perl's connect() function for IPv6.

Unfortunately, a sockaddr is not large enough to handle an IPv6 structure.
On my system, I see:

	Size of struct sockaddr_in is 16 bytes
	Size of struct sockaddr_un is 94 bytes
	Size of struct sockaddr_in6 is 28 bytes
	Size of struct sockaddr is 16 bytes
	Size of struct sockaddr_storage is 256 bytes

The sockaddr_storage structure is new to IPv6, and is supposed to be
"large enough to accomodate all supported protocol-specific address
structures".  Unfortunately, this is is only declared on nodes that
have IPv6.

However, doing something like:

typedef struct sockaddr_storage		Socket_address;
typedef struct sockaddr			Socket_address;

and using sizeof(Socket_address) instead of sizeof(struct sockaddr)
may be sufficient to not have to replicate these functions in a module.
That removes a big chunk from Socket6.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About