NAME

  tst_hop_limit_set_to_valid - Use the given value when the IPV6_UNICAST_HOPS option is set to a valid value


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
  less than -1, an error of EINVAL should be returned.


SYNOPSIS

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


TEST PROCEDURE

  1. Set the value of hoplimit option to 0
  2. Check A: The value of hoplimit is set correctly
  3. Set the value of hoplimit option to 64
  4. Check B: The value of hoplimit is set correctly
  5. Set the value of hoplimit option to 255
  6. Check C: The value of hoplimit is set correctly


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);