libmct_convProgrammer’s Manual

mct_session_add/drop_name(3)

Name

mct_session_add_name, mct_session_drop_name — Add multicast membership to an MCT session by name

Synopsis

#include <mct/convenience.h>

int mct_session_add_name(struct mct *mct, int s,
	const char *ifname, const char *host, const char *serv, int flags)

int mct_session_drop_name(struct mct *mct, int s,
	const char *ifname, const char *host, const char *serv, int flags)

Description

The mct_session_add_name() and mct_session_drop_name() functions are a conveniences to call mct_session_add() and mct_session_drop() respectively with sockaddr structs constructed automatically.

The ifname argument identifies the network interface for multicast membership. This is a string as per if_nametoindex, or NULL to indicate any interface.

A host name and service name are given. These are passed through to getaddrinfo verbatim.

Either a host name or a service name (but not both) may be NULL. For AF_INET and AF_INET6 multicast it is only meaningful to specify the service as NULL.

The flags argument passed to getaddrinfo as the ai_flags field in its hints struct for the src and dst addresses respectively. The ai_family field is set to AF_UNSPEC. The ai_protocol field is set to 0. The ai_socktype field is set to SOCK_RAW.

Either a host name or a service name (or both) may be specified numerically. For IP, this would be an IP address and (possibly) a port number. See getaddrinfo for more information.

mct_session_add is called for each of the addresses getaddrinfo resolves. If no addresses are resolved then mct_session_add_name and mct_session_drop_name return EAI_NONAME.

Return Value

The mct_session_add_name() and mct_session_drop_name() functions returns 0 on success. On failure these functions returns one of the EAI_ constants <0 defined by getaddrinfo. As for getaddrinfo, EAI_SYSTEM indicates errno is set accordingly.

Errors

The mct_session_add_name() and mct_session_drop_name() functions may fail for any of the reasons mct_session_add and mct_session_drop may produce respectively.

In addition, mct_session_add_name() and mct_session_drop_name() may fail for any of the reasons getaddrinfo may produce.

In addition, mct_session_add_name() and mct_session_drop_name() may fail for the following reasons:

EINVAL

Both host and serv are NULL.

EAI_NONAME

The name resolver could not find the given name.

ENODEV

The given interface name could not be found.

EOVERFLOW

The interface index is too large to be used with setsockopt(). (See caveats below).

Caveats

See mct_session_add.

The non-standard struct ip_mreqn and the POSIX standard struct ipv6_mreqn structures use an int type for interface indexes. However the if_nametoindex name resolution interface returns an unsigned int, which has a larger range of possible positive values. Thus it is possible that some interface indexes may not be expressible to the socket API, for systems with over INT_MAX network interfaces.

See Also

mctd, mct, mct_ipc, mct_session_close, getaddrinfo, if_nametoindex.