tst_v6only_set_send - Restricts the socket can be used to send and receive IPv6 packets only
To check the IPV6_V6ONLY option can restricts AF_INET6 the socket be used to send and receive IPv6 packets only.
./tst_v6only_set_send [-tooloption ...] -tooloption : v6api tool option
1. Create an IPv4 socket 2. Bind the IPv4 socket to an port 3. Create an IPv6 socket 4. Disabled the IPV6_V6ONLY option of the IPv6 socket 5. Bind the IPv6 socket to an port 6. Send message from IPv6 socket to IPv4 socket 7. Recv message just send by IPv6 socket on IPv4 socket 8. Send message from IPv4 socket to IPv6 socket 9. Recv message just send by IPv4 socket on IPv6 socket 10.Create an IPv6 socket 11.Enabled the IPV6_V6ONLY option of the IPv6 socket 12.Bind the IPv6 socket to an port 13.Send message from IPv6 socket to IPv4 socket 14.Check A: message can not be send 15.Send message from IPv4 socket to IPv6 socket 16.Recv message just send by IPv4 socket on IPv6 socket 17.Check B: Message can not be received
None
RFC 3493
5.3 IPV6_V6ONLY option for AF_INET6 Sockets
This socket option restricts AF_INET6 sockets to IPv6 communications only. As stated in section <3.7 Compatibility with IPv4 Nodes>, AF_INET6 sockets may be used for both IPv4 and IPv6 communications. Some applications may want to restrict their use of an AF_INET6 socket to IPv6 communications only. For these applications the IPV6_V6ONLY socket option is defined. When this option is turned on, the socket can be used to send and receive IPv6 packets only. This is an IPPROTO_IPV6 level option. This option takes an int value. This is a boolean option. By default this option is turned off.
Here is an example of setting this option:
int on = 1;
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on, sizeof(on)) == -1) perror("setsockopt IPV6_V6ONLY"); else printf("IPV6_V6ONLY set\n");
Note - This option has no effect on the use of IPv4 Mapped addresses which enter a node as a valid IPv6 addresses for IPv6 communications as defined by Stateless IP/ICMP Translation Algorithm (SIIT) [5].
An example use of this option is to allow two versions of the same server process to run on the same port, one providing service over IPv6, the other providing the same service over IPv4.