ip.7p (2010 09)

i
IP(7P) IP(7P)
gr_interface field holds the interface index of a local interface, or zero. If the interface address is
INADDR_ANY, or if the interface index is zero, the system chooses a multicast group by matching the
multicast address only. For example:
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr("224.1.2.3");
mreq.imr_interface.s_addr = INADDR_ANY;
setsockopt(s, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
struct group_req gr;
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&gr.gr_group;
bzero(sin, sizeof(*sin));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr("224.1.2.3");
gr.gr_interface = 0;
setsockopt(s, IPPROTO_IP, MCAST_LEAVE_GROUP, &gr, sizeof(gr));
IP_BLOCK_SOURCE
and MCAST_BLOCK_SOURCE
add a source address to the list of sources being
blocked.
IP_UNBLOCK_SOURCE
and MCAST_UNBLOCK_SOURCE
remove a source address from the list
of sources being blocked. The group must already be joined, and must be in "exclude" mode. The
imr_interface field holds the IPv4 address of a local interface, or
INADDR_ANY. The
gsr_interface field holds the interface index of a local interface, or zero. If the interface address is
INADDR_ANY, or if the interface index is zero, the system chooses a multicast group by matching the
multicast address only. For example:
struct ip_mreq_source imr;
imr.imr_multiaddr.s_addr = inet_addr("224.1.2.3");
imr.imr_sourceaddr.s_addr = inet_addr("10.4.5.6");
imr.imr_interface.s_addr = INADDR_ANY;
setsockopt(s, IPPROTO_IP, IP_BLOCK_SOURCE, &imr, sizeof(imr));
setsockopt(s, IPPROTO_IP, IP_UNBLOCK_SOURCE, &imr, sizeof(imr));
struct group_source_req gsr;
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&gsr.gsr_group;
bzero(sin, sizeof(*sin));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr("224.1.2.3");
sin = (struct sockaddr_in *)&gsr.gsr_source;
bzero(sin, sizeof(*sin));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr("10.4.5.6");
gsr.gsr_interface = 0;
setsockopt(s, IPPROTO_IP, MCAST_BLOCK_SOURCE, &gsr, sizeof(gsr));
setsockopt(s, IPPROTO_IP, MCAST_UNBLOCK_SOURCE, &gsr, sizeof(gsr));
IP_ADD_SOURCE_MEMBERSHIP and MCAST_JOIN_SOURCE_GROUP
add a source address to the list
of allowed sources for a multicast group in "include" mode, joining the group in "include" mode if not
already joined.
IP_DROP_SOURCE_MEMBERSHIP and MCAST_LEAVE_SOURCE_GROUP
remove a
source address from the list of allowed sources for a multicast group in "include" mode, leaving the group
if the last source is being removed. The
imr_interface field holds the IPv4 address of a local inter-
face, or INADDR_ANY. The gsr_interface field holds the interface index of a local interface, or zero.
If the interface address is INADDR_ANY or the interface index is zero, the behavior depends on whether
the group is being joined. If the group is being joined, the system joins the specified group on the inter-
face from which datagrams for that group would be sent, based on the routing configuration; otherwise,
the system chooses a multicast group by matching the multicast address only. For example:
struct ip_mreq_source imr;
imr.imr_multiaddr.s_addr = inet_addr("224.1.2.3");
imr.imr_sourceaddr.s_addr = inet_addr("10.4.5.6");
imr.imr_interface.s_addr = INADDR_ANY;
setsockopt(s, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, &imr, sizeof(imr));
setsockopt(s, IPPROTO_IP, IP_DROP_SOURCE_MEMBERSHIP, &imr, sizeof(imr));
HP-UX 11i Version 3: September 2010 3 Hewlett-Packard Company 3