NAME

  tst_mcast_loop_back - A copy is looped back if the IPV6_MULTICAST_LOOP option is set to 1


PURPOSE

  To check if a multicast datagram is sent to a group to which
  the sending host itself belongs (on the outgoing interface), 
  a copy of the datagram is looped back by the IP layer for local
  delivery if IPV6_MULTICAST_LOOP option is set to 1.


SYNOPSIS

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


TEST PROCEDURE

  1. Join a multicast group on a specified local interface.
  2. Set the value IPV6_MULTICAST_IF option to the same interface.
  3. Enabled the IPV6_MULTICAST_LOOP option.
  4. Send multicast datagram to the multicast group.
  5. Recv message on the socket with non-blocking.
  6. Check A: Copy of the multicast datagram is looped back


NOTE

  None


REFERENCE

  RFC 3493
  5.2 Sending and Receiving Multicast Packets
    IPv6 applications may send multicast packets by simply specifying an
    IPv6 multicast address as the destination address, for example in the
    destination address argument of the sendto() function.
    Three socket options at the IPPROTO_IPV6 layer control some of the
    parameters for sending multicast packets.  Setting these options is
    not required: applications may send multicast packets without using
    these options.  The setsockopt() options for controlling the sending
    of multicast packets are summarized below.  These three options can
    also be used with getsockopt().
      IPV6_MULTICAST_IF
         Set the interface to use for outgoing multicast packets.  The
         argument is the index of the interface to use.  If the
         interface index is specified as zero, the system selects the
         interface (for example, by looking up the address in a routing
         table and using the resulting interface).
         Argument type: unsigned int
      IPV6_MULTICAST_HOPS
         Set the hop limit to use for outgoing multicast packets.  (Note
         a separate option - IPV6_UNICAST_HOPS - is provided to set the
         hop limit to use for outgoing unicast packets.)
         The interpretation of the argument is the same as for the
         IPV6_UNICAST_HOPS option:
            x < -1:        return an error of EINVAL
            x == -1:       use kernel default
            0 <= x <= 255: use x
            x >= 256:      return an error of EINVAL
            If IPV6_MULTICAST_HOPS is not set, the default is 1
            (same as IPv4 today)
         Argument type: int
      IPV6_MULTICAST_LOOP
         If a multicast datagram is sent to a group to which the sending
         host itself belongs (on the outgoing interface), a copy of the
         datagram is looped back by the IP layer for local delivery if
         this option is set to 1.  If this option is set to 0 a copy is
         not looped back.  Other option values return an error of
         EINVAL.
         If IPV6_MULTICAST_LOOP is not set, the default is 1 (loopback;
         same as IPv4 today).
         Argument type: unsigned int
    The reception of multicast packets is controlled by the two
    setsockopt() options summarized below.  An error of EOPNOTSUPP is
    returned if these two options are used with getsockopt().
      IPV6_JOIN_GROUP
         Join a multicast group on a specified local interface.
         If the interface index is specified as 0,
         the kernel chooses the local interface.
         For example, some kernels look up the multicast group
         in the normal IPv6 routing table and use the resulting
         interface.
         Argument type: struct ipv6_mreq
      IPV6_LEAVE_GROUP
         Leave a multicast group on a specified interface.
         If the interface index is specified as 0, the system
         may choose a multicast group membership to drop by
         matching the multicast address only.
         Argument type: struct ipv6_mreq
    The argument type of both of these options is the ipv6_mreq
    structure, defined as a result of including the <netinet/in.h>
    header;
    struct ipv6_mreq {
        struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */
        unsigned int    ipv6mr_interface; /* interface index */
    };
    Note that to receive multicast datagrams a process must join the
    multicast group to which datagrams will be sent.  UDP applications
    must also bind the UDP port to which datagrams will be sent.  Some
    processes also bind the multicast group address to the socket, in
    addition to the port, to prevent other datagrams destined to that
    same port from being delivered to the socket.