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
53--EXPECT--
54Setting IPV6_MULTICAST_TTL
55bool(true)
56int(9)
57
58Setting IPV6_MULTICAST_LOOP
59bool(true)
60int(0)
61bool(true)
62int(1)
63
64Setting IPV6_MULTICAST_IF
65interface 0:
66bool(true)
67int(0)
68interface 1:
69bool(true)
70int(1)
71