1--TEST--
2socket_set_option() with IPV6_PKTINFO
3--SKIPIF--
4<?php
5if (!extension_loaded('sockets')) {
6    die('skip sockets extension not available.');
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--FILE--
21<?php
22
23$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("err");
24var_dump(socket_set_option($s, IPPROTO_IPV6, IPV6_PKTINFO, []));
25var_dump(socket_set_option($s, IPPROTO_IPV6, IPV6_PKTINFO, [
26    "addr" => '::1',
27    "ifindex" => 0
28]));
29//Oddly, Linux does not support IPV6_PKTINFO in sockgetopt().
30//See do_ipv6_getsockopt() on the kernel sources
31//A work-around with is sort-of possible (with IPV6_2292PKTOPTIONS),
32//but not worth it
33//var_dump(socket_get_option($s, IPPROTO_IPV6, IPV6_PKTINFO));
34--EXPECTF--
35Warning: socket_set_option(): error converting user data (path: in6_pktinfo): The key 'addr' is required in %s on line %d
36bool(false)
37bool(true)
38