NAME

  tst_hop_limit_set_to_gt_255 - Return an error of EINVAL when the IPV6_UNICAST_HOPS option is set to larger than 255


PURPOSE

  When the IPV6_UNICAST_HOPS option is set with setsockopt(), the
  option value given is used as the hop limit for all subsequent
  unicast packets sent via that socket.  If the option is value is
  larger than 255, an error of EINVAL should be returned.


SYNOPSIS

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


TEST PROCEDURE

  1. Set the value of hoplimit option to 256
  2. Check A: Error EINVAL is returned
  3. Set the value of hoplimit option to 32767
  4. Check B: Error EINVAL is returned
  5. Check C: The option value has not been changed


NOTE

  None


REFERENCE

  RFC 3493
  5.2.  Unicast Hop Limit
    A new setsockopt() option controls the hop limit used in outgoing
    unicast IPv6 packets.  The name of this option is IPV6_UNICAST_HOPS,
    and it is used at the IPPROTO_IPV6 layer.  The following example
    illustrates how it is used:
        int  hoplimit = 10;
        if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
                       (char *) &hoplimit, sizeof(hoplimit)) == -1)
            perror("setsockopt IPV6_UNICAST_HOPS");
    When the IPV6_UNICAST_HOPS option is set with setsockopt(), the
    option value given is used as the hop limit for all subsequent
    unicast packets sent via that socket.  If the option is not set, the
    system selects a default value.  The integer hop limit value (called
    x) is interpreted as follows:
        x < -1:        return an error of EINVAL
        x == -1:       use kernel default
        0 <= x <= 255: use x
        x >= 256:      return an error of EINVAL
    The IPV6_UNICAST_HOPS option may be used with getsockopt() to
    determine the hop limit value that the system will use for subsequent
    unicast packets sent via that socket.  For example:
        int  hoplimit;
        size_t  len = sizeof(hoplimit);
        if (getsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
                       (char *) &hoplimit, &len) == -1)
            perror("getsockopt IPV6_UNICAST_HOPS");
        else
            printf("Using %d for hop limit.\n", hoplimit);