This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH 3/3] Provide wrappers for IN6ADDR_ANY and IN6ADDR_LOOPBACK
authorPaul Evans <leonerd@leonerd.org.uk>
Thu, 25 Nov 2010 20:08:05 +0000 (20:08 +0000)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Thu, 25 Nov 2010 20:08:05 +0000 (20:08 +0000)
Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
ext/Socket/Makefile.PL
ext/Socket/Socket.pm

index 7167aa4..62ecab2 100644 (file)
@@ -71,6 +71,14 @@ push @names,
  value => "newSVpvn_flags((char *)&ip_address,sizeof(ip_address), SVs_TEMP)",}
          foreach qw(INADDR_ANY INADDR_LOOPBACK INADDR_NONE INADDR_BROADCAST);
 
+push @names,
+{name => $_, type => "SV",
+ macro=>["#ifdef ${_}_INIT\n",
+         "#endif\n"],
+ pre=>"struct in6_addr ip6_address = ${_}_INIT;",
+ value => "newSVpvn_flags((char *)&ip6_address,sizeof(ip6_address), SVs_TEMP)",}
+        foreach qw(IN6ADDR_ANY IN6ADDR_LOOPBACK);
+
 WriteConstants(
     PROXYSUBS => {autoload => 1},
     NAME => 'Socket',
index d4bd73c..b0a72e5 100644 (file)
@@ -112,6 +112,16 @@ Note - does not return a number.
 Returns the 4-byte 'invalid' ip address.  Normally equivalent
 to inet_aton('255.255.255.255').
 
+=item IN6ADDR_ANY
+
+Returns the 16-byte wildcard IPv6 address. Normally equivalent
+to inet_pton(AF_INET6, "::")
+
+=item IN6ADDR_LOOPBACK
+
+Returns the 16-byte loopback IPv6 address. Normally equivalent
+to inet_pton(AF_INET6, "::1")
+
 =item sockaddr_family SOCKADDR
 
 Takes a sockaddr structure (as returned by pack_sockaddr_in(),
@@ -231,6 +241,7 @@ require XSLoader;
        pack_sockaddr_in6 unpack_sockaddr_in6
        sockaddr_in sockaddr_in6 sockaddr_un
        INADDR_ANY INADDR_BROADCAST INADDR_LOOPBACK INADDR_NONE
+       IN6ADDR_ANY IN6ADDR_LOOPBACK
        AF_802
        AF_AAL
        AF_APPLETALK