setsourcefilter() — Set source filter

Standards

Standards / Extensions C or C++ Dependencies
RFC3678 both z/OS® V1.9

Format

#define _XOPEN_SYS_SOCK_EXT3
#include <netinet/in.h>

int setsourcefilter(int s, uint32_t interface, struct sockaddr *group,
 socklen_t grouplen, uint32_t fmode, uint32_t numsrc,
 struct sockaddr_storage *slist);

General description

This function allow applications to set and replace the current multicast filtering state for a tuple consisting of socket, interface, and multicast group values.

A multicast filter is described by a filter mode, which is MCAST_INCLUDE or MCAST_EXCLUDE, and a list of source addresses which are filtered.

This function is protocol-independent. It can be on either AF_INET or AF_INET6 sockets of the type SOCK_DGRAM or SOCK_RAW.

If the function is unable to obtain the required storage, control will not return to the caller. Instead the application will terminate due to an out of memory condition (if the reserve stack is available and the caller is not XPLINK), or it will terminate with an abend indicating that storage could not be obtained.

Argument
Description
s
Identifies the socket.
interface
Holds the local the index of the interface.
group
Points to either a sockaddr_in structure for IPv4 or a sockaddr_in6 structure for IPv6 that holds the IP multicast address of the group.
grouplen
Gives the length of the sockaddr_in or sockaddr_in6 structure.
fmode
Identifies the filter mode. The value of this field will be either MCAST_INCLUDE or MCAST_EXCLUDE, which are likewise defined in <netinet/in.h>.
numsrc
Holds the number of source addresses in the slist array.
slist
Points to an array of IP addresses of sources to include or exclude depending on the filter mode.

Returned value

If successful, the function returns 0. Otherwise, it returns -1 and sets errno to one of the following values.

errno
Description
EBADF
s is not a valid socket descriptor.
EAFNOSUPPORT
The address family of the input sockaddr is not AF_INET or AF_INET6.
EPROTOTYPE
The socket s is not of type SOCK_DGRAM or SOCK_RAW.
EINVAL
Interface or group is not a valid address, or the socket s has already requested multicast setsockopt options (refer to z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference for details.) Or if the group address family is AF_INET and grouplen is not at least size of sockaddr_in or if the group address family is AF_INET6 and grouplen is not at least size of sockaddr_in6 or if grouplen is not at least size of sockaddr_in.
ENOBUFS
The number of the source addresses exceeds the allowed limit.

Related information