NAME

  tst_recv_tclass_udp - Receiving the Traffic Class when the IPV6_RECVTCLASS socket option is enabled


PURPOSE

  To check that when the IPV6_RECVTCLASS socket option is enabled, the
  received traffic class is always returned as ancillary data by 
  recvmsg().


SYNOPSIS

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


TEST PROCEDURE

  1. Create an IPv6/UDP socket
  2. Set the value of traffic class to 255
  3. Enabled the IPV6_RECVTCLASS option to receive traffic class
  4. Bind the socket to address
  5. Send one message to socket itself
  6. Receive one message used recvmsg() 
  7. Check A: The traffic class option is returned
  8. Check B: The received value and length of traffic class is correct


NOTE

  None


REFERENCE

  RFC 3542
  6.5.  Specifying/Receiving the Traffic Class value
    The outgoing traffic class is normally set to 0.  Specifying the
    traffic class 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 traffic class is useful for
    programs such as a diffserv debugging tool and for user level ECN
    (explicit congestion notification) implementation.
    The received traffic class is returned as ancillary data by recvmsg()
    only if the application has enabled the IPV6_RECVTCLASS socket
    option:
      int  on = 1;
      setsockopt(fd, IPPROTO_IPV6, IPV6_RECVTCLASS, &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_TCLASS, and the first byte of cmsg_data[] will be the first byte
    of the integer traffic class.
    To specify the outgoing traffic class value, just specify the control
    information as ancillary data for sendmsg() or using setsockopt().
    Just like the hop limit value, the interpretation of the integer
    traffic class 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
    In order to clear a sticky IPV6_TCLASS option the application can
    specify -1 as the value.
    There are cases where the kernel needs to control the traffic class
    value and conflicts with the user-specified value on the outgoing
    traffic.  An example is an implementation of ECN in the kernel,
    setting 2 bits of the traffic class value.  In such cases, the kernel
    should override the user-specified value.  On the incoming traffic,
    the kernel may mask some of the bits in the traffic class field.