libcomm Globals


 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

comm_api.h

comm_private.h

Global member Documentation

extern int  comm_init (void)

comm_init

#include <comm_api.h>


Library initialization. Need be called only once, during startup.

Note: Currently it is not thread-safe.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern void  comm_exit (void)

comm_exit

#include <comm_api.h>


Library termination/cleanup. Must be called at process exit.

Note: Currently it is not thread-safe.

extern int  comm_get_last_error (void)

comm_get_last_error

#include <comm_api.h>


Retrieve the most recently occured error for the current thread.

Returns: operating system specific error code for this thread's last socket operation.

extern char const *  comm_get_error_str (int serrno)

comm_get_error_str

#include <comm_api.h>


Retrieve a human readable string (in English) for the given error code.

Note: Currently it is not thread-safe.

Parameters:

serrnothe socket error number returned by comm_get_last_error().

Returns: a pointer to a string giving more information about the error.

extern char const * comm_get_last_error_str (void)

comm_get_last_error_str

#include <comm_api.h>


Retrieve a human readable string (in English) for the last error.

Returns: a human readable string of the last error.

extern int  comm_ipv4_present (void)

comm_ipv4_present

#include <comm_api.h>


Test whether the underlying system has IPv4 support.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_ipv6_present (void)

comm_ipv6_present

#include <comm_api.h>


Test whether the underlying system has IPv6 support.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_bindtodevice_present (void)

comm_bindtodevice_present

#include <comm_api.h>


Test whether the underlying system has SO_BINDTODEVICE support.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_onesbcast_present (void)

comm_onesbcast_present

#include <comm_api.h>


Test whether the underlying system has IP_ONESBCAST support.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_tos_present (void)

comm_tos_present

#include <comm_api.h>


Test whether the underlying system has IP_TOS support.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_unicast_ttl_present (void)

comm_unicast_ttl_present

#include <comm_api.h>


Test whether the underlying system has IP_TTL support.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern xsock_t  comm_open_tcp (int family, int is_blocking)

comm_open_tcp

#include <comm_api.h>


Open a TCP socket.

Parameters:

familythe address family.
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwsise XORP_BAD_SOCKET.

extern xsock_t  comm_open_udp (int family, int is_blocking)

comm_open_udp

#include <comm_api.h>


Open an UDP socket.

Parameters:

familythe address family.
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwsise XORP_BAD_SOCKET.

extern int  comm_close (xsock_t sock)

comm_close

#include <comm_api.h>


Close a socket.

Parameters:

sockthe socket to close.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_listen (xsock_t sock, int backlog)

comm_listen

#include <comm_api.h>


Listen on a socket.

Parameters:

sockthe socket to listen on.
backlogthe maximum queue size for pending connections.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern xsock_t  comm_bind_tcp4 (const struct in_addr *my_addr, unsigned short my_port, int is_blocking)

comm_bind_tcp4

#include <comm_api.h>


Open an IPv4 TCP socket and bind it to a local address and a port.

Parameters:

my_addrthe local IPv4 address to bind to (in network order). If it is NULL, will bind to `any' local address.
my_portthe local port to bind to (in network order).
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_tcp6 (const struct in6_addr *my_addr, unsigned int my_ifindex, unsigned short my_port, int is_blocking)

comm_bind_tcp6

#include <comm_api.h>


Open an IPv6 TCP socket and bind it to a local address and a port.

Parameters:

my_addrthe local IPv6 address to bind to (in network order). If it is NULL, will bind to `any' local address.
my_ifindexthe local network interface index to bind to. It is required if my_addr is a link-local address, otherwise it should be set to 0.
my_portthe local port to bind to (in network order).
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_tcp (const struct sockaddr *sin, int is_blocking)

comm_bind_tcp

#include <comm_api.h>


Open a TCP (IPv4 or IPv6) socket and bind it to a local address and a port.

Parameters:

sinagnostic sockaddr containing the local address (If it is NULL, will bind to `any' local address.) and the local port to bind to all in network order.
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_udp4 (const struct in_addr *my_addr, unsigned short my_port, int is_blocking)

comm_bind_udp4

#include <comm_api.h>


Open an IPv4 UDP socket and bind it to a local address and a port.

Parameters:

my_addrthe local IPv4 address to bind to (in network order). If it is NULL, will bind to `any' local address.
my_portthe local port to bind to (in network order).
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_udp6 (const struct in6_addr *my_addr, unsigned int my_ifindex, unsigned short my_port, int is_blocking)

comm_bind_udp6

#include <comm_api.h>


Open an IPv6 UDP socket and bind it to a local address and a port.

Parameters:

my_addrthe local IPv6 address to bind to (in network order). If it is NULL, will bind to `any' local address.
my_ifindexthe network interface index to bind to. It is required if my_addr is a link-local address, otherwise it should be set to 0.
my_portthe local port to bind to (in network order).
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_join_udp4 (const struct in_addr *mcast_addr, const struct in_addr *join_if_addr, unsigned short my_port, int reuse_flag, int is_blocking)

comm_bind_join_udp4

#include <comm_api.h>


Open an IPv4 UDP socket on an interface, bind it to a port, and join a multicast group.

Note that we bind to ANY address instead of the multicast address only. If we bind to the multicast address instead, then using the same socket for sending multicast packets will trigger a bug in the FreeBSD kernel: the source IP address will be set to the multicast address. Hence, the application itself may want to filter the UDP unicast packets that may have arrived with a destination address one of the local interface addresses and the same port number.

Parameters:

mcast_addrthe multicast address to join.
join_if_addrthe local unicast interface address (in network order) to join the multicast group on. If it is NULL, the system will choose the interface each time a datagram is sent.
my_portthe port to bind to (in network order).
reuse_flagif true, allow other sockets to bind to the same multicast address and port, otherwise disallow it.
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_join_udp6 (const struct in6_addr *mcast_addr, unsigned int my_ifindex, unsigned short my_port, int reuse_flag, int is_blocking)

comm_bind_join_udp6

#include <comm_api.h>


Open an IPv6 UDP socket on an interface, bind it to a port, and join a multicast group.

Note that we bind to ANY address instead of the multicast address only. If we bind to the multicast address instead, then using the same socket for sending multicast packets will trigger a bug in the FreeBSD kernel: the source IP address will be set to the multicast address. Hence, the application itself may want to filter the UDP unicast packets that may have arrived with a destination address one of the local interface addresses and the same port number.

Parameters:

mcast_addrthe multicast address to join.
my_ifindexthe local network interface index to join the multicast group on. If it is 0, the system will choose the interface each time a datagram is sent.
my_portthe port to bind to (in network order).
reuse_flagif true, allow other sockets to bind to the same multicast address and port, otherwise disallow it.
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_connect_tcp4 (const struct in_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_connect_tcp4

#include <comm_api.h>


Open an IPv4 TCP socket, and connect it to a remote address and port.

Parameters:

remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_connect_tcp6 (const struct in6_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_connect_tcp6

#include <comm_api.h>


Open an IPv6 TCP socket, and connect it to a remote address and port.

Parameters:

remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_connect_udp4 (const struct in_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_connect_udp4

#include <comm_api.h>


Open an IPv4 UDP socket, and connect it to a remote address and port.

Parameters:

remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_connect_udp6 (const struct in6_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_connect_udp6

#include <comm_api.h>


Open an IPv6 UDP socket, and connect it to a remote address and port.

Parameters:

remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_connect_tcp4 (const struct in_addr *local_addr, unsigned short local_port, const struct in_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_bind_connect_tcp4

#include <comm_api.h>


Open an IPv4 TCP socket, bind it to a local address and a port, and connect it to a remote address and port.

Parameters:

local_addrthe local address to bind to. If it is NULL, will bind to `any' local address.
local_portthe local port to bind to.
remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_connect_tcp6 (const struct in6_addr *local_addr, unsigned int my_ifindex, unsigned short local_port, const struct in6_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_bind_connect_tcp6

#include <comm_api.h>


Open an IPv6 TCP socket, bind it to a local address and a port, and connect it to a remote address and port.

Parameters:

local_addrthe local address to bind to. If it is NULL, will bind to `any' local address.
my_ifindexthe network interface index to bind to. It is required if local_addr is a link-local address, otherwise it should be set to 0.
local_portthe local port to bind to.
remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_connect_udp4 (const struct in_addr *local_addr, unsigned short local_port, const struct in_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_bind_connect_udp4

#include <comm_api.h>


Open an IPv4 UDP socket, bind it to a local address and a port, and connect it to a remote address and port.

Parameters:

local_addrthe local address to bind to. If it is NULL, will bind to `any' local address.
local_portthe local port to bind to.
remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_connect_udp6 (const struct in6_addr *local_addr, unsigned int my_ifindex, unsigned short local_port, const struct in6_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_bind_connect_udp6

#include <comm_api.h>


Open an IPv6 UDP socket, bind it to a local address and a port, and connect it to a remote address and port.

Parameters:

local_addrthe local address to bind to. If it is NULL, will bind to `any' local address.
my_ifindexthe network interface index to bind to. It is required if local_addr is a link-local address, otherwise it should be set to 0.
local_portthe local port to bind to.
remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true then the socket will be blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is the new socket. If the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_BAD_SOCKET or if the socket is blocking, then the return value is undefined.

Returns: the new socket on success, otherwise XORP_BAD_SOCKET.

extern xsock_t  comm_bind_unix (const char* path, int is_blocking)

comm_bind_unix

#include <comm_api.h>


extern xsock_t  comm_connect_unix (const char* path, int is_blocking)

comm_connect_unix

#include <comm_api.h>


extern xsock_t  comm_sock_open (int domain, int type, int protocol, int is_blocking)

comm_sock_open

#include <comm_api.h>


Open a socket for given domain, type and protocol.

The sending and receiving buffer size are set, and the socket itself is set with TCP_NODELAY (if a TCP socket).

Parameters:

domainthe domain of the socket (e.g., AF_INET, AF_INET6).
typethe type of the socket (e.g., SOCK_STREAM, SOCK_DGRAM).
protocolthe particular protocol to be used with the socket.
is_blockingif true then the socket will be blocking, otherwise non-blocking.

Returns: the open socket on success, otherwise XORP_BAD_SOCKET.

extern int  comm_sock_pair (int domain, int type, int protocol, xsock_t sv[2])

comm_sock_pair

#include <comm_api.h>


Create a pair of connected sockets.

The sockets will be created in the blocking state by default, and with no additional socket options set.

On Windows platforms, a domain of AF_UNIX, AF_INET, or AF_INET6 must be specified. For the AF_UNIX case, the sockets created will actually be in the AF_INET domain. The protocol field is ignored.

On UNIX, this function simply wraps the socketpair(2) system call.

Parameters:

domainthe domain of the socket (e.g., AF_INET, AF_INET6).
typethe type of the socket (e.g., SOCK_STREAM, SOCK_DGRAM).
protocolthe particular protocol to be used with the socket.
svpointer to an array of two xsock_t handles to receive the allocated socket pair.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_bind4 (xsock_t sock, const struct in_addr *my_addr, unsigned short my_port)

comm_sock_bind4

#include <comm_api.h>


Bind an IPv4 socket to an address and a port.

Parameters:

sockthe socket to bind.
my_addrthe address to bind to (in network order). If it is NULL, will bind to `any' local address.
my_portthe port to bind to (in network order).

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_bind6 (xsock_t sock, const struct in6_addr *my_addr, unsigned int my_ifindex, unsigned short my_port)

comm_sock_bind6

#include <comm_api.h>


Bind an IPv6 socket to an address and a port.

Parameters:

sockthe socket to bind.
my_addrthe address to bind to (in network order). If it is NULL, will bind to `any' local address.
my_ifindexthe network interface index to bind to. It is required if my_addr is a link-local address, otherwise it should be set to 0.
my_portthe port to bind to (in network order).

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_bind (xsock_t sock, const struct sockaddr *sin)

comm_sock_bind

#include <comm_api.h>


Bind a socket (IPv4 or IPv6) to an address and a port.

Parameters:

sockthe socket to bind.
sinagnostic sockaddr containing the local address (If it is NULL, will bind to `any' local address.) and the local port to bind to all in network order.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_join4 (xsock_t sock, const struct in_addr *mcast_addr, const struct in_addr *my_addr)

comm_sock_join4

#include <comm_api.h>


Join an IPv4 multicast group on a socket (and an interface).

Parameters:

sockthe socket to join the group.
mcast_addrthe multicast address to join.
my_addrthe local unicast address of an interface to join. If it is NULL, the interface is chosen by the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_join6 (xsock_t sock, const struct in6_addr *mcast_addr, unsigned int my_ifindex)

comm_sock_join6

#include <comm_api.h>


Join an IPv6 multicast group on a socket (and an interface).

Parameters:

sockhe socket to join the group.
mcast_addrthe multicast address to join.
my_ifindexthe local network interface index to join. If it is 0, the interface is chosen by the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_leave4 (xsock_t sock, const struct in_addr *mcast_addr, const struct in_addr *my_addr)

comm_sock_leave4

#include <comm_api.h>


Leave an IPv4 multicast group on a socket (and an interface).

Parameters:

sockthe socket to leave the group.
mcast_addrthe multicast address to leave.
my_addrthe local unicast address of an interface to leave. If it is NULL, the interface is chosen by the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_leave6 (xsock_t sock, const struct in6_addr *mcast_addr, unsigned int my_ifindex)

comm_sock_leave6

#include <comm_api.h>


Leave an IPv6 multicast group on a socket (and an interface).

Parameters:

sockhe socket to leave the group.
mcast_addrthe multicast address to leave.
my_ifindexthe local network interface index to leave. If it is 0, the interface is chosen by the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_connect4 (xsock_t sock, const struct in_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_sock_connect4

#include <comm_api.h>


Connect to a remote IPv4 address.

Note that we can use this function not only for TCP, but for UDP sockets as well.

Parameters:

sockthe socket to use to connect.
remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true, the socket is blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is XORP_ERROR. For all other errors or if the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_OK or if the socket is blocking, then the return value is undefined.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_connect6 (xsock_t sock, const struct in6_addr *remote_addr, unsigned short remote_port, int is_blocking, int *in_progress)

comm_sock_connect6

#include <comm_api.h>


Connect to a remote IPv6 address.

Note that we can use this function not only for TCP, but for UDP sockets as well.

Parameters:

sockthe socket to use to connect.
remote_addrthe remote address to connect to.
remote_portthe remote port to connect to.
is_blockingif true, the socket is blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is XORP_ERROR. For all other errors or if the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_OK or if the socket is blocking, then the return value is undefined.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_connect (xsock_t sock, const struct sockaddr *sin, int is_blocking, int *in_progress)

comm_sock_connect

#include <comm_api.h>


Connect to a remote address (IPv4 or IPv6).

Note that we can use this function not only for TCP, but for UDP sockets as well.

Parameters:

sockthe socket to use to connect.
sinagnostic sockaddr containing the local address (If it is NULL, will bind to `any' local address.) and the local port to bind to all in network order.
is_blockingif true, the socket is blocking, otherwise non-blocking.
in_progressif the socket is non-blocking and the connect cannot be completed immediately, then the referenced value is set to 1, and the return value is XORP_ERROR. For all other errors or if the non-blocking socket was connected, the referenced value is set to 0. If the return value is XORP_OK or if the socket is blocking, then the return value is undefined.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern xsock_t  comm_sock_accept (xsock_t sock)

comm_sock_accept

#include <comm_api.h>


Accept a connection on a listening socket.

Parameters:

sockthe listening socket to accept on.

Returns: the accepted socket on success, otherwise XORP_BAD_SOCKET.

extern int  comm_sock_listen (xsock_t sock, int backlog)

comm_sock_listen

#include <comm_api.h>


Listen for connections on a socket.

Parameters:

sockthe socket to listen on.
backlogthe maximum queue size for pending connections

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_close (xsock_t sock)

comm_sock_close

#include <comm_api.h>


Close a socket.

Parameters:

sockthe socket to close.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_send_broadcast (xsock_t sock, int val)

comm_set_send_broadcast

#include <comm_api.h>


Set/reset the SO_BROADCAST option on a socket.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_receive_broadcast (xsock_t sock, int val)

comm_set_receive_broadcast

#include <comm_api.h>


Set/reset the IP_RECEIVE_BROADCAST option on a socket. This option is specific to Windows Server 2003 and later.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_nodelay (xsock_t sock, int val)

comm_set_nodelay

#include <comm_api.h>


Set/reset the TCP_NODELAY option on a TCP socket.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_reuseaddr (xsock_t sock, int val)

comm_set_reuseaddr

#include <comm_api.h>


Set/reset the SO_REUSEADDR option on a socket.

Note: If the OS doesn't support this option, then XORP_ERROR is returned.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_reuseport (xsock_t sock, int val)

comm_set_reuseport

#include <comm_api.h>


Set/reset the SO_REUSEPORT option on a socket.

Note: If the OS doesn't support this option, then XORP_ERROR is returned.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_loopback (xsock_t sock, int val)

comm_set_loopback

#include <comm_api.h>


Set/reset the multicast loopback option on a socket.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_tcpmd5 (xsock_t sock, int val)

comm_set_tcpmd5

#include <comm_api.h>


Set/reset the TCP_MD5SIG option on a socket.

Note: If the OS doesn't support this option, XORP_ERROR is returned.

Parameters:

sockthe socket whose option we want to set/reset.
valif non-zero, the option will be set, otherwise will be reset.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_tos (xsock_t sock, int val)

comm_set_tos

#include <comm_api.h>


Set the ip_tos bits of the outgoing packets on a socket.

Parameters:

sockthe socket whose ip_tos we want to set.
valthe ip_tos of the outgoing packets.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_unicast_ttl (xsock_t sock, int val)

comm_set_unicast_ttl

#include <comm_api.h>


Set the TTL of the outgoing unicast/broadcast packets on a socket.

Parameters:

sockthe socket whose TTL we want to set.
valthe TTL of the outgoing unicast/broadcast packets.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_multicast_ttl (xsock_t sock, int val)

comm_set_multicast_ttl

#include <comm_api.h>


Set the TTL of the outgoing multicast packets on a socket.

Parameters:

sockthe socket whose TTL we want to set.
valthe TTL of the outgoing multicast packets.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_iface4 (xsock_t sock, const struct in_addr *in_addr)

comm_set_iface4

#include <comm_api.h>


Set default interface for IPv4 outgoing multicast on a socket.

Parameters:

sockthe socket whose default multicast interface to set.
in_addrthe IPv4 address of the default interface to set. If in_addr is NULL, the system will choose the interface each time a datagram is sent.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_iface6 (xsock_t sock, unsigned int my_ifindex)

comm_set_iface6

#include <comm_api.h>


Set default interface for IPv6 outgoing multicast on a socket.

Parameters:

sockthe socket whose default multicast interface to set.
my_ifindexthe local network interface index of the default interface to set. If it is 0, the system will choose the interface each time a datagram is sent.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_bindtodevice (xsock_t sock, const char * my_ifname)

comm_set_bindtodevice

#include <comm_api.h>


Set the interface to which a socket is bound.

XXX: This exists to support XORP's use of the 255.255.255.255 address in Linux for MANET protocols, as well as certain limited uses with raw IPv4 sockets, and SHOULD NOT be used in new code.

Parameters:

sockthe socket to be bound to @param my_ifname
my_ifnamethe name of the local network interface to which the socket should be bound.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_set_onesbcast (xsock_t sock, int enabled)

comm_set_onesbcast

#include <comm_api.h>


Set the option which causes sends to directed IPv4 broadcast addresses to go to 255.255.255.255 instead.

XXX: This exists to support XORP's use of the 255.255.255.255 address in BSD-derived systems for MANET protocols. It SHOULD NOT be used in new code.

Parameters:

sockthe socket to enable undirected broadcasts for.
enabledzero to disable the option, non-zero to enable it.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_set_sndbuf (xsock_t sock, int desired_bufsize, int min_bufsize)

comm_sock_set_sndbuf

#include <comm_api.h>


Set the sending buffer size of a socket.

Parameters:

sockthe socket whose sending buffer size to set.
desired_bufsizethe preferred buffer size.
min_bufsizethe smallest acceptable buffer size.

Returns: the successfully set buffer size on success, otherwise XORP_ERROR.

extern int  comm_sock_set_rcvbuf (xsock_t sock, int desired_bufsize, int min_bufsize)

comm_sock_set_rcvbuf

#include <comm_api.h>


Set the receiving buffer size of a socket.

Parameters:

sockthe socket whose receiving buffer size to set.
desired_bufsizethe preferred buffer size.
min_bufsizethe smallest acceptable buffer size.

Returns: the successfully set buffer size on success, otherwise XORP_ERROR.

extern int  comm_sock_get_family (xsock_t sock)

comm_sock_get_family

#include <comm_api.h>


Get the address family of a socket.

Note: Idea taken from W. Stevens' UNPv1, 2e (pp 109).

Parameters:

sockthe socket whose address family we need to get.

Returns: the address family on success, otherwise XORP_ERROR.

extern int  comm_sock_get_type (xsock_t sock)

comm_sock_get_type

#include <comm_api.h>


Get the type of a socket.

Examples of socket type are SOCK_STREAM for TCP, SOCK_DGRAM for UDP, and SOCK_RAW for raw protocol sockets.

Parameters:

sockthe socket whose type we need to get.

Returns: the socket type on success, otherwise XORP_ERROR.

extern int  comm_sock_set_blocking (xsock_t sock, int is_blocking)

comm_sock_set_blocking

#include <comm_api.h>


Set the blocking or non-blocking mode of an existing socket.

Parameters:

sockthe socket whose blocking mode is to be set.
is_blockingif non-zero, then set socket to blocking mode.

Returns: XORP_OK on success, otherwise XORP_ERROR.

extern int  comm_sock_is_connected (xsock_t sock, int *is_connected)

comm_sock_is_connected

#include <comm_api.h>


Determine if an existing socket is in the connected state.

Parameters:

sockthe socket whose connected state is to be queried.
is_connectedif the socket is in the connected state, then the referenced value is set to 1, otherwise it is set to 0.

Returns: XORP_OK on success, otherwise XORP_ERROR.

void  comm_sock_no_ipv6 (const char* method, ...)

comm_sock_no_ipv6

#include <comm_private.h>


Log an error if an IPv6 specific method is called when IPv6 is not present.

An error message is output via XLOG_ERROR(). Set an appropriate error code relevant to the underlying system. Note: This is currently done with knowledge of how the error code is stored internally, which is a design bug (we're not thread friendly). This function is variadic so it can be used to remove unused variable warnings in non-IPv6 code as well as log the error.

Parameters:

methodC-style string denoting the ipv6 function called.
void  _comm_set_serrno (void)

_comm_set_serrno

#include <comm_private.h>


Fetch and record the last socket layer error code from the underlying system.

Note: Currently not thread-safe. Internal use only. This is done using a function to facilitate using explicit Thread Local Storage (TLS) at a later time.


Generated by: pavlin on kobe.xorp.net on Wed Jan 7 19:10:44 2009, using kdoc 2.0a54+XORP.