NAME

  tst_send_rhhdr_setopt - Send a Routing header by specifies it using setsockopt()


PURPOSE

  To check that send a Routing header, the application can specifies
  the header using setsockopt().


SYNOPSIS

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


TEST PROCEDURE

  1. Create an IPv6 socket
  2. Enable socket to receive routing header
  3. Set routing header of socket
  4. Bind socket to address
  5. Send message to itself
  6. Receive message on socket
  7. Check A: routing header can be received
  8. Check B: the value and length of routing header is correct


NOTE

  None


REFERENCE

  RFC 3542
  7.  Routing Header Option
    Source routing in IPv6 is accomplished by specifying a Routing header
    as an extension header.  There can be different types of Routing
    headers, but IPv6 currently defines only the Type 0 Routing header
    [RFC-2460].  This type supports up to 127 intermediate nodes (limited
    by the length field in the extension header).  With this maximum
    number of intermediate nodes, a source, and a destination, there are
    128 hops.
    Source routing with the IPv4 sockets API (the IP_OPTIONS socket
    option) requires the application to build the source route in the
    format that appears as the IPv4 header option, requiring intimate
    knowledge of the IPv4 options format.  This IPv6 API, however,
    defines six functions that the application calls to build and examine
    a Routing header, and the ability to use sticky options or ancillary
    data to communicate this information between the application and the
    kernel using the IPV6_RTHDR option.
    Three functions build a Routing header:
      inet6_rth_space()    - return #bytes required for Routing header
      inet6_rth_init()     - initialize buffer data for Routing header
      inet6_rth_add()      - add one IPv6 address to the Routing header
    Three functions deal with a returned Routing header:
      inet6_rth_reverse()  - reverse a Routing header
      inet6_rth_segments() - return #segments in a Routing header
      inet6_rth_getaddr()  - fetch one address from a Routing header
    The function prototypes for these functions are defined as a result
    of including <netinet/in.h>.
    To receive a Routing header the application must enable the
    IPV6_RECVRTHDR socket option:
      int  on = 1;
      setsockopt(fd, IPPROTO_IPV6, IPV6_RECVRTHDR, &on, sizeof(on));
    Each received Routing header is returned as one ancillary data object
    described by a cmsghdr structure with cmsg_type set to IPV6_RTHDR.
    When multiple Routing headers are received, multiple ancillary data
    objects (with cmsg_type set to IPV6_RTHDR) will be returned to the
    application.
    To send a Routing header the application specifies it either as
    ancillary data in a call to sendmsg() or using setsockopt().  For the
    sending side, this API assumes the number of occurrences of the
    Routing header as described in [RFC-2460].  That is, applications can
    only specify at most one outgoing Routing header.