tst_leave_group - Leave a multicast group on a specified interface
To check IPV6_LEAVE_GROUP option can be used to leave a multicast group on a specified local 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.
./tst_leave_group [-tooloption ...] -tooloption : v6api tool option
1. Leave to a multicast group which is not available on Link0 2. Check A: Fail to leave and error EADDRNOTAVAIL will be returned 3. Join to a multicast group on Link0 4. Leave to the multicast group on Link0 5. Chech B: No error is returned 6. Join to the same multicast group on Link0 again 7. Check C: No error is returned, leave operation in step 4 is successed 8. Leave to the multicast group on lo 9. Check D: Fail to leave and error EADDRNOTAVAIL will be returned 10.Leave to the multicast group with the interface index is specified as 0 11.Check E: No error is returned 12.Join to a multicast group on Link0 13.Check F: No error is returned, leave operation in step 10 is successed 14.Leave to a multicast group with bad paramter type and paramter length 15.Check G: Fail to join and error EINVAL will be returned
None
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.