NAME

  tst_hop_limit_get - Get the value of IPV6_UNICAST_HOPS option from kernel


PURPOSE

  To check whether the IPV6_UNICAST_HOPS option can be used with
  getsockopt() to determine the hop limit value that the system
  will use for subsequent unicast packets sent via that socket.


SYNOPSIS

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


TEST PROCEDURE

  1. Get the default value of hoplimit option from kernel
  2. Check A: No error is returned
  3. Set the value of hoplimit option to 64
  4. Get the value of hoplimit option from kernel
  5. Check B: The value of hoplimit option is 64


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