summaryrefslogtreecommitdiff
path: root/cpan
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2012-08-15 17:56:13 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2012-08-15 18:28:45 +0100
commitd4ada64ad845b1ffe124cf230a345b847e43d755 (patch)
tree1f32aeac57295402e9cb97f3523f162b5f72cbd3 /cpan
parente146574a8047f7322db7990ad354d7a606843288 (diff)
downloadperl-d4ada64ad845b1ffe124cf230a345b847e43d755.tar.gz
Upgrade Socket from 2.002 to 2.003
Diffstat (limited to 'cpan')
-rw-r--r--cpan/Socket/Makefile.PL22
-rw-r--r--cpan/Socket/Socket.pm36
-rw-r--r--cpan/Socket/Socket.xs67
-rw-r--r--cpan/Socket/t/ip_mreq.t14
4 files changed, 117 insertions, 22 deletions
diff --git a/cpan/Socket/Makefile.PL b/cpan/Socket/Makefile.PL
index 3be198e024..9e76dcea96 100644
--- a/cpan/Socket/Makefile.PL
+++ b/cpan/Socket/Makefile.PL
@@ -161,13 +161,14 @@ my @names = (
IOV_MAX
- IP_ADD_MEMBERSHIP IP_DROP_MEMBERSHIP IP_HDRINCL IP_MULTICAST_IF
- IP_MULTICAST_LOOP IP_MULTICAST_TTL IP_OPTIONS IP_RECVOPTS
- IP_RECVRETOPTS IP_RETOPTS IP_TOS IP_TTL
+ IP_ADD_MEMBERSHIP IP_ADD_SOURCE_MEMBERSHIP IP_DROP_MEMBERSHIP
+ IP_DROP_SOURCE_MEMBERSHIP IP_HDRINCL IP_MULTICAST_IF IP_MULTICAST_LOOP
+ IP_MULTICAST_TTL IP_OPTIONS IP_RECVOPTS IP_RECVRETOPTS IP_RETOPTS IP_TOS
+ IP_TTL
- IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP IPV6_MTU IPV6_MTU_DISCOVER
- IPV6_MULTICAST_HOPS IPV6_MULTICAST_IF IPV6_MULTICAST_LOOP
- IPV6_UNICAST_HOPS IPV6_V6ONLY
+ IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP IPV6_JOIN_GROUP
+ IPV6_LEAVE_GROUP IPV6_MTU IPV6_MTU_DISCOVER IPV6_MULTICAST_HOPS
+ IPV6_MULTICAST_IF IPV6_MULTICAST_LOOP IPV6_UNICAST_HOPS IPV6_V6ONLY
MSG_BCAST MSG_BTAG MSG_CTLFLAGS MSG_CTLIGNORE MSG_DONTWAIT MSG_EOF
MSG_EOR MSG_ERRQUEUE MSG_ETAG MSG_FIN MSG_MAXIOVLEN MSG_MCAST
@@ -200,10 +201,11 @@ my @names = (
SO_SECURITY_ENCRYPTION_TRANSPORT SO_SNDBUF SO_SNDLOWAT SO_SNDTIMEO
SO_STATE SO_TYPE SO_USELOOPBACK SO_XOPEN SO_XSE
- TCP_KEEPALIVE TCP_MAXRT TCP_MAXSEG TCP_NODELAY TCP_STDURG TCP_CORK
- TCP_KEEPIDLE TCP_KEEPINTVL TCP_KEEPCNT TCP_SYNCNT TCP_LINGER2
- TCP_DEFER_ACCEPT TCP_WINDOW_CLAMP TCP_INFO TCP_QUICKACK TCP_CONGESTION
- TCP_MD5SIG
+ TCP_CONGESTION TCP_CONNECTIONTIMEOUT TCP_CORK TCP_DEFER_ACCEPT TCP_INFO
+ TCP_INIT_CWND TCP_KEEPALIVE TCP_KEEPCNT TCP_KEEPIDLE TCP_KEEPINTVL
+ TCP_LINGER2 TCP_MAXRT TCP_MAXSEG TCP_MD5SIG TCP_NODELAY TCP_NOOPT
+ TCP_NOPUSH TCP_QUICKACK TCP_SACK_ENABLE TCP_STDURG TCP_SYNCNT
+ TCP_WINDOW_CLAMP
UIO_MAXIOV
),
diff --git a/cpan/Socket/Socket.pm b/cpan/Socket/Socket.pm
index 41f214d8fe..d9bbfae258 100644
--- a/cpan/Socket/Socket.pm
+++ b/cpan/Socket/Socket.pm
@@ -3,7 +3,7 @@ package Socket;
use strict;
{ use 5.006001; }
-our $VERSION = '2.002';
+our $VERSION = '2.003';
=head1 NAME
@@ -260,6 +260,18 @@ sockopts.
Takes an C<ip_mreq> structure. Returns a list of two elements; the IPv4
multicast address and interface address.
+=head2 $ip_mreq_source = pack_ip_mreq_source $multiaddr, $source, $interface
+
+Takes an IPv4 multicast address, source address, and optionally an interface
+address (or C<INADDR_ANY>). Returns the C<ip_mreq_source> structure with those
+arguments packed in. Suitable for use with the C<IP_ADD_SOURCE_MEMBERSHIP>
+and C<IP_DROP_SOURCE_MEMBERSHIP> sockopts.
+
+=head2 ($multiaddr, $source, $interface) = unpack_ip_mreq_source $ip_mreq
+
+Takes an C<ip_mreq_source> structure. Returns a list of three elements; the
+IPv4 multicast address, source address and interface address.
+
=head2 $ipv6_mreq = pack_ipv6_mreq $multiaddr6, $ifindex
Takes an IPv6 multicast address and an interface number. Returns the
@@ -736,24 +748,26 @@ our @EXPORT_OK = qw(
SOCK_NONBLOCK SOCK_CLOEXEC
- IP_ADD_MEMBERSHIP IP_DROP_MEMBERSHIP IP_MULTICAST_IF
- IP_MULTICAST_LOOP IP_MULTICAST_TTL
+ IP_ADD_MEMBERSHIP IP_ADD_SOURCE_MEMBERSHIP IP_DROP_MEMBERSHIP
+ IP_DROP_SOURCE_MEMBERSHIP IP_MULTICAST_IF IP_MULTICAST_LOOP
+ IP_MULTICAST_TTL
IPPROTO_IP IPPROTO_IPV6 IPPROTO_RAW IPPROTO_ICMP IPPROTO_TCP
IPPROTO_UDP
- TCP_CONGESTION TCP_CORK TCP_DEFER_ACCEPT TCP_INFO TCP_KEEPALIVE
- TCP_KEEPCNT TCP_KEEPIDLE TCP_KEEPINTVL TCP_LINGER2 TCP_MAXRT TCP_MAXSEG
- TCP_MD5SIG TCP_NODELAY TCP_QUICKACK TCP_STDURG TCP_SYNCNT
- TCP_WINDOW_CLAMP
+ TCP_CONGESTION TCP_CONNECTIONTIMEOUT TCP_CORK TCP_DEFER_ACCEPT TCP_INFO
+ TCP_INIT_CWND TCP_KEEPALIVE TCP_KEEPCNT TCP_KEEPIDLE TCP_KEEPINTVL
+ TCP_LINGER2 TCP_MAXRT TCP_MAXSEG TCP_MD5SIG TCP_NODELAY TCP_NOOPT
+ TCP_NOPUSH TCP_QUICKACK TCP_SACK_ENABLE TCP_STDURG TCP_SYNCNT
+ TCP_WINDOW_CLAMP
IN6ADDR_ANY IN6ADDR_LOOPBACK
- IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP IPV6_MTU IPV6_MTU_DISCOVER
- IPV6_MULTICAST_HOPS IPV6_MULTICAST_IF IPV6_MULTICAST_LOOP
- IPV6_UNICAST_HOPS IPV6_V6ONLY
+ IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP IPV6_JOIN_GROUP
+ IPV6_LEAVE_GROUP IPV6_MTU IPV6_MTU_DISCOVER IPV6_MULTICAST_HOPS
+ IPV6_MULTICAST_IF IPV6_MULTICAST_LOOP IPV6_UNICAST_HOPS IPV6_V6ONLY
- pack_ip_mreq unpack_ip_mreq
+ pack_ip_mreq unpack_ip_mreq pack_ip_mreq_source unpack_ip_mreq_source
pack_ipv6_mreq unpack_ipv6_mreq
diff --git a/cpan/Socket/Socket.xs b/cpan/Socket/Socket.xs
index f22c1f3001..0bdebf5ca4 100644
--- a/cpan/Socket/Socket.xs
+++ b/cpan/Socket/Socket.xs
@@ -1020,6 +1020,73 @@ unpack_ip_mreq(mreq_sv)
}
void
+pack_ip_mreq_source(multiaddr, source, interface=&PL_sv_undef)
+ SV * multiaddr
+ SV * source
+ SV * interface
+ CODE:
+ {
+#if defined(HAS_IP_MREQ) && defined (IP_ADD_SOURCE_MEMBERSHIP)
+ struct ip_mreq_source mreq;
+ char * multiaddrbytes;
+ char * sourcebytes;
+ char * interfacebytes;
+ STRLEN len;
+ if (DO_UTF8(multiaddr) && !sv_utf8_downgrade(multiaddr, 1))
+ croak("Wide character in %s", "Socket::pack_ip_mreq_source");
+ multiaddrbytes = SvPVbyte(multiaddr, len);
+ if (len != sizeof(mreq.imr_multiaddr))
+ croak("Bad arg length %s, length is %"UVuf", should be %"UVuf,
+ "Socket::pack_ip_mreq", (UV)len, (UV)sizeof(mreq.imr_multiaddr));
+ if (DO_UTF8(source) && !sv_utf8_downgrade(source, 1))
+ croak("Wide character in %s", "Socket::pack_ip_mreq_source");
+ if (len != sizeof(mreq.imr_sourceaddr))
+ croak("Bad arg length %s, length is %"UVuf", should be %"UVuf,
+ "Socket::pack_ip_mreq", (UV)len, (UV)sizeof(mreq.imr_sourceaddr));
+ sourcebytes = SvPVbyte(source, len);
+ Zero(&mreq, sizeof(mreq), char);
+ Copy(multiaddrbytes, &mreq.imr_multiaddr, sizeof(mreq.imr_multiaddr), char);
+ Copy(sourcebytes, &mreq.imr_sourceaddr, sizeof(mreq.imr_sourceaddr), char);
+ if(SvOK(interface)) {
+ if (DO_UTF8(interface) && !sv_utf8_downgrade(interface, 1))
+ croak("Wide character in %s", "Socket::pack_ip_mreq");
+ interfacebytes = SvPVbyte(interface, len);
+ if (len != sizeof(mreq.imr_interface))
+ croak("Bad arg length %s, length is %"UVuf", should be %"UVuf,
+ "Socket::pack_ip_mreq", (UV)len, (UV)sizeof(mreq.imr_interface));
+ Copy(interfacebytes, &mreq.imr_interface, sizeof(mreq.imr_interface), char);
+ }
+ else
+ mreq.imr_interface.s_addr = INADDR_ANY;
+ ST(0) = sv_2mortal(newSVpvn((char *)&mreq, sizeof(mreq)));
+#else
+ not_here("pack_ip_mreq_source");
+#endif
+ }
+
+void
+unpack_ip_mreq_source(mreq_sv)
+ SV * mreq_sv
+ PPCODE:
+ {
+#if defined(HAS_IP_MREQ) && defined (IP_ADD_SOURCE_MEMBERSHIP)
+ struct ip_mreq_source mreq;
+ STRLEN mreqlen;
+ char * mreqbytes = SvPVbyte(mreq_sv, mreqlen);
+ if (mreqlen != sizeof(mreq))
+ croak("Bad arg length for %s, length is %"UVuf", should be %"UVuf,
+ "Socket::unpack_ip_mreq_source", (UV)mreqlen, (UV)sizeof(mreq));
+ Copy(mreqbytes, &mreq, sizeof(mreq), char);
+ EXTEND(SP, 3);
+ mPUSHp((char *)&mreq.imr_multiaddr, sizeof(mreq.imr_multiaddr));
+ mPUSHp((char *)&mreq.imr_sourceaddr, sizeof(mreq.imr_sourceaddr));
+ mPUSHp((char *)&mreq.imr_interface, sizeof(mreq.imr_interface));
+#else
+ not_here("unpack_ip_mreq_source");
+#endif
+ }
+
+void
pack_ipv6_mreq(multiaddr, interface)
SV * multiaddr
unsigned int interface
diff --git a/cpan/Socket/t/ip_mreq.t b/cpan/Socket/t/ip_mreq.t
index f08920c437..2a99509904 100644
--- a/cpan/Socket/t/ip_mreq.t
+++ b/cpan/Socket/t/ip_mreq.t
@@ -5,6 +5,7 @@ use Test::More;
use Socket qw(
INADDR_ANY
pack_ip_mreq unpack_ip_mreq
+ pack_ip_mreq_source unpack_ip_mreq_source
);
# Check that pack/unpack_ip_mreq either croak with "Not implemented", or
@@ -19,7 +20,7 @@ if( !defined $packed ) {
die $@;
}
-plan tests => 3;
+plan tests => 6;
my @unpacked = unpack_ip_mreq $packed;
@@ -27,3 +28,14 @@ is( $unpacked[0], "\xe0\0\0\1", 'unpack_ip_mreq multiaddr' );
is( $unpacked[1], INADDR_ANY, 'unpack_ip_mreq interface' );
is( (unpack_ip_mreq pack_ip_mreq "\xe0\0\0\1")[1], INADDR_ANY, 'pack_ip_mreq interface defaults to INADDR_ANY' );
+
+SKIP: {
+ my $mreq;
+ skip 3, "No pack_ip_mreq_source" unless defined eval { $mreq = pack_ip_mreq_source "\xe0\0\0\2", "\x0a\0\0\1", INADDR_ANY };
+
+ @unpacked = unpack_ip_mreq_source $mreq;
+
+ is( $unpacked[0], "\xe0\0\0\2", 'unpack_ip_mreq_source multiaddr' );
+ is( $unpacked[1], "\x0a\0\0\1", 'unpack_ip_mreq_source source' );
+ is( $unpacked[2], INADDR_ANY, 'unpack_ip_mreq_source interface' );
+}