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