SOURCEFILTER(3)
π NAME π
sourcefilter β advanced multicast group membership API, and this is the sourcefilter(3) page from the Library Functions Manual, bestie. Multicast group membership but make it full-state and fancy. π
β¨ SYNOPSIS β¨
okay so hereβs the exact synopsis, no cap β copy these character-for-character if youβre writing code:
#include <sys/socket.h>
#include <netinet/in.h>
int
getipv4sourcefilter(int s, struct in_addr interface,
struct in_addr group, uint32_t *fmode, uint32_t *numsrc,
struct in_addr *slist);
int
getsourcefilter(int s, uint32_t interface, struct sockaddr *group,
socklen_t grouplen, uint32_t *fmode, uint32_t *numsrc,
struct sockaddr_storage *slist);
int
setipv4sourcefilter(int s, struct in_addr interface,
struct in_addr group, uint32_t fmode, uint32_t numsrc,
struct in_addr *slist);
int
setsourcefilter(int s, uint32_t interface, struct sockaddr *group,
socklen_t grouplen, uint32_t fmode, uint32_t numsrc,
struct sockaddr_storage *slist);
πΈ DESCRIPTION πΈ
The sourcefilter functions implement the advanced, full-state multicast API defined in RFC 3678. An application may use these functions to atomically set and retrieve the multicast source address filters associated with a socket s and a multicast group.
The functions getipv4sourcefilter() and getsourcefilter() allow an application to discover the filter mode, and source filter entries, for an existing group membership.
The kernel will always return the number of source filter entries on the socket for that group in *numsrc. If the *numsrc argument is non-zero, the kernel will attempt to return up to *numsrc filter entries in the array pointed to by slist. The *numsrc argument may be set to 0, in which case the slist argument will be ignored.
For the setipv4sourcefilter() and setsourcefilter() functions, the fmode argument may be used to place the socket into inclusive or exclusive group membership modes, by using the MCAST_INCLUDE or MCAST_EXCLUDE constants respectively. The numsrc argument specifies the number of source entries in the slist array. If the numsrc argument has a value of 0, all source filters will be removed from the socket. Removing all source filters from a membership which is in the MCAST_INCLUDE filter mode will cause the group to be left on that socket.
The protocol-independent function setsourcefilter() allows an application to join a multicast group on an interface which may not have an assigned protocol address, by passing its index for the interface argument.
Any changes made by these functions will be communicated to IGMPv3 and/or MLDv2 routers on the local network as appropriate. If no IGMPv3 or MLDv2 routers are present, changes in the source filter lists made by these functions will not cause state changes to be transmitted, with the exception of any change which causes a group to be joined or left. The kernel will continue to maintain the source filter state regardless of the IGMP or MLD version in use on the link.
π§ IMPLEMENTATION NOTES π§
The IPv4 specific versions of these functions are implemented in terms of the protocol-independent functions. Application writers are encouraged to use the protocol-independent functions for efficiency, and forwards compatibility with IPv6 networks.
For the protocol-independent functions getsourcefilter() and setsourcefilter(), the grouplen argument specifies the size of the structure pointed to by group. This is required in order to differentiate between different address families.
π¨ FreeBSD caveat time, bestie: currently FreeBSD does not support source address selection for the IPv4 protocol family, therefore the use of multicast APIs with an unnumbered IPv4 interface is not recommended. In all cases, the first assigned IPv4 address on the interface will be used as the source address of IGMP control traffic. If this address is removed or changed, the results are undefined β big yikes, donβt roll those dice. π
π RETURN VALUES π
The getsourcefilter(), getipv4sourcefilter(), setsourcefilter(), and setipv4sourcefilter() functions return the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
π₯ ERRORS π₯
The sourcefilter functions may fail because of:
[EADDRNOTAVAIL]β the network interface which theinterfaceargument refers to was not configured in the system, or the system is not a member of the group.[EAFNOSUPPORT]β thegroupand/or one or more of theslistarguments were of an address family unsupported by the system, or the address family of thegroupandslistarguments were not identical.[EINVAL]β thegroupargument does not contain a multicast address. Thefmodeargument is invalid; it must be set to eitherMCAST_INCLUDEorMCAST_EXCLUDE. Thenumsrcorslistarguments do not specify a source list.[ENOMEM]β insufficient memory was available to carry out the requested operation.
π¦ SEE ALSO π¦
D. Thaler, B. Fenner, and B. Quinn, Socket Interface Extensions for Multicast Source Filters, RFC 3678, Jan 2004.
π HISTORY π
The sourcefilter functions first appeared in FreeBSD 7.0.
π AUTHORS π
Bruce M. Simpson <bms@FreeBSD.org>
okay thatβs the whole page, bestie β this oneβs the Debian version, dated February 13, 2009, for sourcefilter(3). mwah πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2007-2009 Bruce Simpson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms