1--TEST--
2Multicast support: IPv6 send options
3--SKIPIF--
4<?php
5if (!extension_loaded('sockets')) {
6    die('skip sockets extension not available.');
7}
8if (!defined('IPPROTO_IPV6')) {
9	die('skip IPv6 not available.');
10}
11$level = IPPROTO_IPV6;
12$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("skip Can not create socket");
13if (socket_set_option($s, $level, IPV6_MULTICAST_IF, 1) === false) {
14	die("skip interface 1 either doesn't exist or has no ipv6 address");
15}
16--FILE--
17<?php
18$domain = AF_INET6;
19$level = IPPROTO_IPV6;
20$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err");
21
22echo "Setting IPV6_MULTICAST_TTL\n";
23$r = socket_set_option($s, $level, IPV6_MULTICAST_HOPS, 9);
24var_dump($r);
25$r = socket_get_option($s, $level, IPV6_MULTICAST_HOPS);
26var_dump($r);
27echo "\n";
28
29echo "Setting IPV6_MULTICAST_LOOP\n";
30$r = socket_set_option($s, $level, IPV6_MULTICAST_LOOP, 0);
31var_dump($r);
32$r = socket_get_option($s, $level, IPV6_MULTICAST_LOOP);
33var_dump($r);
34$r = socket_set_option($s, $level, IPV6_MULTICAST_LOOP, 1);
35var_dump($r);
36$r = socket_get_option($s, $level, IPV6_MULTICAST_LOOP);
37var_dump($r);
38echo "\n";
39
40echo "Setting IPV6_MULTICAST_IF\n";
41echo "interface 0:\n";
42$r = socket_set_option($s, $level, IPV6_MULTICAST_IF, 0);
43var_dump($r);
44$r = socket_get_option($s, $level, IPV6_MULTICAST_IF);
45var_dump($r);
46echo "interface 1:\n";
47$r = socket_set_option($s, $level, IPV6_MULTICAST_IF, 1);
48var_dump($r);
49$r = socket_get_option($s, $level, IPV6_MULTICAST_IF);
50var_dump($r);
51echo "\n";
52--EXPECT--
53Setting IPV6_MULTICAST_TTL
54bool(true)
55int(9)
56
57Setting IPV6_MULTICAST_LOOP
58bool(true)
59int(0)
60bool(true)
61int(1)
62
63Setting IPV6_MULTICAST_IF
64interface 0:
65bool(true)
66int(0)
67interface 1:
68bool(true)
69int(1)
70