6 #include <sys/socket.h>
7 #include <netinet/in.h>
13 #if defined IP_ADD_MEMBERSHIP && defined IPV6_ADD_MEMBERSHIP \
14 && defined IPV6_JOIN_ANYCAST && defined HAVE_INET_PTON
18 inet_pton(AF_INET, "224.0.0.3", &m4.imr_multiaddr);
19 inet_pton(AF_INET, "127.0.0.1", &m4.imr_interface);
20 inet_pton(AF_INET6, "ff01::c", &m6.ipv6mr_multiaddr);
21 m6.ipv6mr_interface = 1;
24 assert(socket(AF_INET, SOCK_DGRAM, 0) == 0);
26 assert(setsockopt(0, SOL_IP, IP_ADD_MEMBERSHIP, &m4, 1) == -1);
27 assert(setsockopt(0, SOL_IP, IP_DROP_MEMBERSHIP, &m4, 1) == -1);
28 assert(setsockopt(0, SOL_IP, IP_ADD_MEMBERSHIP, &m4, sizeof(m4)) == 0);
29 assert(setsockopt(0, SOL_IP, IP_DROP_MEMBERSHIP, &m4, sizeof(m4)) == 0);
31 assert(setsockopt(0, SOL_IPV6, IPV6_ADD_MEMBERSHIP, &m6, 1) == -1);
32 assert(setsockopt(0, SOL_IPV6, IPV6_DROP_MEMBERSHIP, &m6, 1) == -1);
33 assert(setsockopt(0, SOL_IPV6, IPV6_ADD_MEMBERSHIP, &m6, sizeof(m6)) == -1);
34 assert(setsockopt(0, SOL_IPV6, IPV6_DROP_MEMBERSHIP, &m6, sizeof(m6)) == -1);
36 assert(setsockopt(0, SOL_IPV6, IPV6_JOIN_ANYCAST, &m6, 1) == -1);
37 assert(setsockopt(0, SOL_IPV6, IPV6_LEAVE_ANYCAST, &m6, 1) == -1);
38 assert(setsockopt(0, SOL_IPV6, IPV6_JOIN_ANYCAST, &m6, sizeof(m6)) == -1);
39 assert(setsockopt(0, SOL_IPV6, IPV6_LEAVE_ANYCAST, &m6, sizeof(m6)) == -1);