NAME

  tst_send_hop_limit_udp - Specifying the Hop Limit as ancillary data


PURPOSE

  To check that the hot limit can be specified as ancillary data.


SYNOPSIS

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


TEST PROCEDURE

  1. Create an IPv6/UDP socket
  2. Bind the socket to address
  3. Specifying the outgoing hop limit -1 as ancillary data and
     send the message
  4. Check A: Message can be sent used kernel default hop limit
  5. Specifying the outgoing hop limit 0 as ancillary data and
     send the message
  6. Check B: Message can be sent
  7. Specifying the outgoing hop limit 64 as ancillary data and
     send the message
  8. Check C: Message can be sent
  9. Specifying the outgoing hop limit 255 as ancillary data and
     send the message
  10.Check D: Message can be sent
  11.Specifying the outgoing hop limit 256 as ancillary data and
     send the message
  12.Check E: Message can not be sent, return EINVAL error
  13.Specifying the outgoing hop limit -2 as ancillary data and
     send the message
  14.Check F: Message can not be sent, return EINVAL error


NOTE

  None


REFERENCE

  RFC 3542
  6.3.  Specifying/Receiving the Hop Limit
    The outgoing hop limit is normally specified with either the
    IPV6_UNICAST_HOPS socket option or the IPV6_MULTICAST_HOPS socket
    option, both of which are described in [RFC-3493].  Specifying the
    hop limit as ancillary data lets the application override either the
    kernel's default or a previously specified value, for either a
    unicast destination or a multicast destination, for a single output
    operation.  Returning the received hop limit is useful for IPv6
    applications that need to verify that the received hop limit is 255
    (e.g., that the packet has not been forwarded).
    The received hop limit is returned as ancillary data by recvmsg()
    only if the application has enabled the IPV6_RECVHOPLIMIT socket
    option:
      int  on = 1;
      setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on));
    In the cmsghdr structure containing this ancillary data, the
    cmsg_level member will be IPPROTO_IPV6, the cmsg_type member will be
    IPV6_HOPLIMIT, and the first byte of cmsg_data[] will be the first
    byte of the integer hop limit.
    Nothing special need be done to specify the outgoing hop limit: just
    specify the control information as ancillary data for sendmsg().  As
    specified in [RFC-3493], the interpretation of the integer hop limit
    value is
      x < -1:        return an error of EINVAL
      x == -1:       use kernel default
      0 <= x <= 255: use x
      x >= 256:      return an error of EINVAL
    This API defines IPV6_HOPLIMIT as an ancillary-only option, that is,
    the option name cannot be used as a socket option.  This is because
    [RFC-3493] has more fine-grained socket options; IPV6_UNICAST_HOPS
    and IPV6_MULTICAST_HOPS.