IPPROTO_IPV6 Socket Options

The following tables describe IPPROTO_IPV6 socket options that apply to sockets created for the IPv6 address family (AF_INET6). See the getsockopt and setsockopt function reference pages for more information on getting and setting socket options.

To enumerate protocols and discover supported properties for each installed protocol, use the WSAEnumProtocols, WSCEnumProtocols, or WSCEnumProtocols32 function.

Some socket options require more explanation than these tables can convey; such options contain links to additional information.

**IPPROTO\_IPV6 Socket Options**
Option get set Optval type Description
IP_ORIGINAL_ARRIVAL_IF yes yes DWORD (boolean) Indicates if the WSARecvMsg function should return optional control data containing the original arrival interface where the packet was received for datagram sockets.
This option is used with IPv6 transition technologies (6to4, ISATAP, and Teredo tunnels, for example) that provide address assignment and host-to-host automatic tunneling for unicast IPv6 traffic when IPv6 hosts must traverse IP4 networks to reach other IPv6 networks. IPv6 packets are sent tunneled as IPv4 packets. This option allows the original IPv4 interface where the packet was received to be returned in the WSAMSG structure.
IPV6_ADD_MEMBERSHIP yes ipv6_mreq Join the socket to the supplied multicast group on the specified interface.
This option is only valid on datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW).
IPV6_DROP_MEMBERSHIP yes ipv6_mreq Leave the supplied multicast group from the given interface.
This option is only valid on datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW).
IPV6_HDRINCL yes yes DWORD(boolean) Indicates the application provides the IPv6 header on all outgoing data. If the optval parameter is set to 1 on the call to setsockopt, the option is enabled. If optval is set to 0, the option is disabled. The default value is disabled.
This option is only valid for datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW). A TCP/IP service provider that supports SOCK_RAW should also support IPV6_HDRINCL.
IPV6_HOPLIMIT yes yes DWORD (boolean) Indicates that hop (TTL) information should be returned in the WSARecvMsg function. If optval is set to 1 on the call to setsockopt, the option is enabled. If set to 0, the option is disabled.
This option is only valid for datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW).
IPV6_JOIN_GROUP yes ipv6_mreq Same as IPV6_ADD_MEMBERSHIP
IPV6_LEAVE_GROUP yes ipv6_mreq Same as IPV6_DROP_MEMBERSHIP
IPV6_MTU yes DWORD Gets the system's estimate of the path MTU. Socket must be connected.
IPV6_MTU_DISCOVER yes yes DWORD (PMTUD_STATE) Gets or sets the path MTU discovery state for the socket. The default value is IP_PMTUDISC_NOT_SET. For stream sockets, IP_PMTUDISC_NOT_SET and IP_PMTUDISC_DO will perform path MTU discovery. IP_PMTUDISC_DONT and IP_PMTUDISC_PROBE will turn off path MTU discovery. For datagram sockets, if set to IP_PMTUDISC_DO , attempts to send packets larger than path MTU will result in an error. If set to IP_PMTUDISC_DONT, packets will be fragmented according to interface MTU. If set to IP_PMTUDISC_PROBE, attempts to send packets larger than interface MTU will result in an error.
IPV6_MULTICAST_HOPS yes yes DWORD Gets or sets the TTL value associated with IPv6 multicast traffic on the socket. It is illegal to set the TTL to a value greater than 255.
This option is only valid for datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW).
IPV6_MULTICAST_IF yes yes DWORD Gets or sets the outgoing interface for sending IPv6 multicast traffic. This option does not change the default interface for receiving IPv6 multicast traffic. This option is important for multihomed computers.
The input value for setting this option is a 4-byte interface index of the desired outgoing interface in host byte order. The GetAdaptersAddresses function can be used to obtain the interface index information. If optval is set to NULL on call to setsockopt, the default IPv6 interface is used. If optval is zero , the default interface for receiving multicast is specified for sending multicast traffic.
When getting this option, the optval returns the current default interface index for sending multicast IPv6 traffic in host byte order.
IPV6_MULTICAST_LOOP yes yes DWORD (boolean) Indicates multicast data sent on the socket will be echoed to the sockets receive buffer if it is also joined on the destination multicast group. If optval is set to 1 on the call to setsockopt, the option is enabled. If set to 0, the option is disabled.
This option is only valid for datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW).
IPV6_PKTINFO yes yes DWORD (boolean) Indicates that packet information should be returned by the WSARecvMsg function.
IPV6_PROTECTION_LEVEL yes yes INT Enables restriction of a socket to a specified scope, such as addresses with the same link local or site local prefix. Provides various restriction levels and default settings. See IPV6_PROTECTION_LEVEL for more information.
IPV6_RECVIF yes yes DWORD (boolean) Indicates whether the IP stack should populate the control buffer with details about which interface received a packet with a datagram socket. When this value is true, the WSARecvMsg function will return optional control data containing the interface where the packet was received for datagram sockets.
This option allows the IPv6 interface where the packet was received to be returned in the WSAMSG structure.
This option is only valid for datagram and raw sockets (the socket type must be SOCK_DGRAM or SOCK_RAW).
IPV6_RECVTCLASS yes yes DWORD (boolean) Indicates whether the IP stack should populate the control buffer with a message containing the Traffic Class IPv6 header field on a received datagram. When this value is true, the WSARecvMsg function will return optional control data containing the Traffic Class IPv6 header field value of the received datagram.
This option allows the Traffic Class IPv6 header field of the received datagram to be returned in the WSAMSG structure. The returned message type will be IPV6_TCLASS. All DSCP and ECN bits of the Traffic Class field will be returned.
This option is only valid on datagram sockets (the socket type must be SOCK_DGRAM).
IPV6_UNICAST_HOPS yes yes DWORD Gets or sets the current TTL value associated with IPv6 socket for unicast traffic. It is illegal to set the TTL to a value greater than 255.
IPV6_UNICAST_IF yes yes DWORD (IF_INDEX) Gets or sets the outgoing interface for sending IPv6 traffic. This option does not change the default interface for receiving IPv6 traffic. This option is important for multihomed computers.
The input value for setting this option is a 4-byte interface index of the desired outgoing interface in host byte order. The GetAdaptersAddresses function can be used to obtain the interface index information. If optval is zero, the default interface for sending IPv6 traffic is set to unspecified.
When getting this option, the optval returns the current default interface index for sending IPv6 traffic in host byte order.
IPV6_V6ONLY yes yes DWORD (boolean) Indicates if a socket created for the AF_INET6 address family is restricted to IPv6 communications only. Sockets created for the AF_INET6 address family may be used for both IPv6 and IPv4 communications. Some applications may want to restrict their use of a socket created for the AF_INET6 address family to IPv6 communications only. When this value is nonzero (the default on Windows), a socket created for the AF_INET6 address family can be used to send and receive IPv6 packets only.
When this value is zero, a socket created for the AF_INET6 address family can be used to send and receive packets to and from an IPv6 address or an IPv4 address. Note that the ability to interact with an IPv4 address requires the use of IPv4 mapped addresses.
This socket option is supported on Windows Vista or later.

 

**Windows Support for IPPROTO\_IPV6 Socket Options**
Option Windows 8 Windows Server 2012 Windows 7 Windows Server 2008 Windows Vista Windows Server 2003 Windows XP
IP_ORIGINAL_ARRIVAL_IF
x x x
IPV6_ADD_MEMBERSHIP
x x x x x x x
IPV6_DROP_MEMBERSHIP
x x x x x x x
IPV6_HDRINCL
x x x x x x x
IPV6_HOPLIMIT
x x x x x x x
IPV6_JOIN_GROUP
x x x x x x x
IPV6_LEAVE_GROUP
x x x x x x x
IPV6_MULTICAST_HOPS
x x x x x x x
IPV6_MULTICAST_IF
x x x x x x x
IPV6_MULTICAST_LOOP
x x x x x x x
IPV6_PKTINFO
x x x x x x x
IPV6_PROTECTION_LEVEL
x x x x x x x
IPV6_RECVIF
x x x x x
IPV6_UNICAST_HOPS
x x x x x x x
IPV6_UNICAST_IF
x x x x x
IPV6_V6ONLY
x x x x x

 

Remarks

On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files has changed and IPPROTO_IPV6 level is defined in the Ws2def.h header file which is automatically included in the Winsock2.h header file. The IPPROTO_IPV6 socket options are defined in the Ws2ipdef.h header file which is automatically included in the Ws2tcpip.h header file. The Ws2def.h and Ws2ipdef.h header files should never be used directly.

The IP_ORIGINAL_ARRIVAL_IF socket option is supported on Windows Server 2008 R2 as well as on Windows 7.

Requirements

Header
Ws2def.h (include Winsock2.h);
Winsock2.h on Windows Server 2003 and Windows XP