NAME

  tst_v6only_set_client - Restricts AF_INET6 sockets to IPv6 communications only


PURPOSE

  To check the IPV6_V6ONLY option can restricts AF_INET6 sockets
  to IPv6 communications only.


SYNOPSIS

  ./tst_v6only_set_client [-tooloption ...]
    -tooloption : v6api tool option


TEST PROCEDURE

  1. Create an IPv4 socket
  2. Bind the IPv4 socket to an port
  3. Listen on the IPv4 socket
  4. Create an IPv6 socket
  5. Enabled the IPV6_V6ONLY option of the IPv6 socket
  6. Connect IPv6 socket to IPv4 socket
  7. Check A: IPv6 socket can not connect to IPv4 socket
  8. Disabled the IPV6_V6ONLY option of the IPv6 socket
  9. Connect IPv6 socket to IPv4 socket
  10.Check B: IPv6 socket can connect to IPv4 socket
  11.Send message from IPv4 socket to IPv6 socket
  12.Recv message on IPv6 socket


NOTE

  None


REFERENCE

  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.