1--TEST--
2socket_set_option() with IPV6_PKTINFO
3--EXTENSIONS--
4sockets
5--SKIPIF--
6<?php
7
8
9require 'ipv6_skipif.inc';
10
11if (!defined('IPPROTO_IPV6')) {
12    die('skip IPv6 not available.');
13}
14if (substr(PHP_OS, 0, 3) == 'WIN') {
15    die('skip Not for Windows!');
16}
17if (!defined('IPV6_PKTINFO')) {
18    die('skip IPV6_PKTINFO not available.');
19}
20?>
21--FILE--
22<?php
23
24$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("err");
25var_dump(socket_set_option($s, IPPROTO_IPV6, IPV6_PKTINFO, []));
26var_dump(socket_set_option($s, IPPROTO_IPV6, IPV6_PKTINFO, [
27    "addr" => '::1',
28    "ifindex" => 0
29]));
30//Oddly, Linux does not support IPV6_PKTINFO in sockgetopt().
31//See do_ipv6_getsockopt() on the kernel sources
32//A work-around with is sort-of possible (with IPV6_2292PKTOPTIONS),
33//but not worth it
34//var_dump(socket_get_option($s, IPPROTO_IPV6, IPV6_PKTINFO));
35?>
36--EXPECTF--
37Warning: socket_set_option(): error converting user data (path: in6_pktinfo): The key 'addr' is required in %s on line %d
38bool(false)
39bool(true)
40