socket.h File Reference

Provides TCP and UDP sockets for network I/O. The sockets are event sources in the task system. More...

#include <isc/event.h>
#include <isc/eventclass.h>
#include <isc/lang.h>
#include <isc/json.h>
#include <isc/region.h>
#include <isc/sockaddr.h>
#include <isc/time.h>
#include <isc/types.h>
#include <isc/xml.h>

Go to the source code of this file.

Data Structures

struct  isc_socketevent
struct  isc_socket_newconnev
struct  isc_socket_connev
struct  isc_socketmgrmethods
 Socket and socket manager methods. More...
struct  isc_socketmethods
struct  isc_socketmgr
 This structure is actually just the common prefix of a socket manager object implementation's version of an isc_socketmgr_t. More...
struct  isc_socket
 This is the common prefix of a socket object. The same note as that for the socketmgr structure applies. More...

Defines

#define ISC_SOCKET_H   1
#define ISC_SOCKET_MAXSCATTERGATHER   8
 Maximum number of buffers in a scatter/gather read/write. The operating system in use must support at least this number (plus one on some.).
#define ISC_SOCKET_REUSEADDRESS   0x01U
 In isc_socket_bind() set socket option SO_REUSEADDR prior to calling bind() if a non zero port is specified (AF_INET and AF_INET6).
#define ISC_SOCKEVENT_ANYEVENT   (0)
#define ISC_SOCKEVENT_RECVDONE   (ISC_EVENTCLASS_SOCKET + 1)
#define ISC_SOCKEVENT_SENDDONE   (ISC_EVENTCLASS_SOCKET + 2)
#define ISC_SOCKEVENT_NEWCONN   (ISC_EVENTCLASS_SOCKET + 3)
#define ISC_SOCKEVENT_CONNECT   (ISC_EVENTCLASS_SOCKET + 4)
#define ISC_SOCKEVENT_INTR   (ISC_EVENTCLASS_SOCKET + 256)
#define ISC_SOCKEVENT_INTW   (ISC_EVENTCLASS_SOCKET + 257)
#define ISCAPI_SOCKETMGR_MAGIC   ISC_MAGIC('A','s','m','g')
#define ISCAPI_SOCKETMGR_VALID(m)
#define ISCAPI_SOCKET_MAGIC   ISC_MAGIC('A','s','c','t')
#define ISCAPI_SOCKET_VALID(s)
#define ISC_SOCKEVENTATTR_ATTACHED   0x80000000U
#define ISC_SOCKEVENTATTR_TRUNC   0x00800000U
#define ISC_SOCKEVENTATTR_CTRUNC   0x00400000U
#define ISC_SOCKEVENTATTR_TIMESTAMP   0x00200000U
#define ISC_SOCKEVENTATTR_PKTINFO   0x00100000U
#define ISC_SOCKEVENTATTR_MULTICAST   0x00080000U
#define ISC_SOCKEVENTATTR_DSCP   0x00040000U
#define ISC_SOCKSHUT_RECV   0x00000001
 close read side
#define ISC_SOCKSHUT_SEND   0x00000002
 close write side
#define ISC_SOCKSHUT_ALL   0x00000003
 close them all
#define ISC_SOCKCANCEL_RECV   0x00000001
 cancel recv
#define ISC_SOCKCANCEL_SEND   0x00000002
 cancel send
#define ISC_SOCKCANCEL_ACCEPT   0x00000004
 cancel accept
#define ISC_SOCKCANCEL_CONNECT   0x00000008
 cancel connect
#define ISC_SOCKCANCEL_ALL   0x0000000f
 cancel everything
#define ISC_SOCKFLAG_IMMEDIATE   0x00000001
 send event only if needed
#define ISC_SOCKFLAG_NORETRY   0x00000002
 drop failed UDP sends
#define ISC_SOCKFDWATCH_READ   0x00000001
 watch for readable
#define ISC_SOCKFDWATCH_WRITE   0x00000002
 watch for writable

Typedefs

typedef struct isc_socket_newconnev isc_socket_newconnev_t
typedef struct isc_socket_connev isc_socket_connev_t
typedef struct isc_socketmgrmethods isc_socketmgrmethods_t
typedef struct isc_socketmethods isc_socketmethods_t
typedef isc_result_t(* isc_socketmgrcreatefunc_t )(isc_mem_t *mctx, isc_socketmgr_t **managerp)
 See isc_socketmgr_create() above.

Enumerations

enum  {
  isc_sockstatscounter_udp4open = 0, isc_sockstatscounter_udp6open = 1, isc_sockstatscounter_tcp4open = 2, isc_sockstatscounter_tcp6open = 3,
  isc_sockstatscounter_unixopen = 4, isc_sockstatscounter_udp4openfail = 5, isc_sockstatscounter_udp6openfail = 6, isc_sockstatscounter_tcp4openfail = 7,
  isc_sockstatscounter_tcp6openfail = 8, isc_sockstatscounter_unixopenfail = 9, isc_sockstatscounter_udp4close = 10, isc_sockstatscounter_udp6close = 11,
  isc_sockstatscounter_tcp4close = 12, isc_sockstatscounter_tcp6close = 13, isc_sockstatscounter_unixclose = 14, isc_sockstatscounter_fdwatchclose = 15,
  isc_sockstatscounter_udp4bindfail = 16, isc_sockstatscounter_udp6bindfail = 17, isc_sockstatscounter_tcp4bindfail = 18, isc_sockstatscounter_tcp6bindfail = 19,
  isc_sockstatscounter_unixbindfail = 20, isc_sockstatscounter_fdwatchbindfail = 21, isc_sockstatscounter_udp4connect = 22, isc_sockstatscounter_udp6connect = 23,
  isc_sockstatscounter_tcp4connect = 24, isc_sockstatscounter_tcp6connect = 25, isc_sockstatscounter_unixconnect = 26, isc_sockstatscounter_fdwatchconnect = 27,
  isc_sockstatscounter_udp4connectfail = 28, isc_sockstatscounter_udp6connectfail = 29, isc_sockstatscounter_tcp4connectfail = 30, isc_sockstatscounter_tcp6connectfail = 31,
  isc_sockstatscounter_unixconnectfail = 32, isc_sockstatscounter_fdwatchconnectfail = 33, isc_sockstatscounter_tcp4accept = 34, isc_sockstatscounter_tcp6accept = 35,
  isc_sockstatscounter_unixaccept = 36, isc_sockstatscounter_tcp4acceptfail = 37, isc_sockstatscounter_tcp6acceptfail = 38, isc_sockstatscounter_unixacceptfail = 39,
  isc_sockstatscounter_udp4sendfail = 40, isc_sockstatscounter_udp6sendfail = 41, isc_sockstatscounter_tcp4sendfail = 42, isc_sockstatscounter_tcp6sendfail = 43,
  isc_sockstatscounter_unixsendfail = 44, isc_sockstatscounter_fdwatchsendfail = 45, isc_sockstatscounter_udp4recvfail = 46, isc_sockstatscounter_udp6recvfail = 47,
  isc_sockstatscounter_tcp4recvfail = 48, isc_sockstatscounter_tcp6recvfail = 49, isc_sockstatscounter_unixrecvfail = 50, isc_sockstatscounter_fdwatchrecvfail = 51,
  isc_sockstatscounter_udp4active = 52, isc_sockstatscounter_udp6active = 53, isc_sockstatscounter_tcp4active = 54, isc_sockstatscounter_tcp6active = 55,
  isc_sockstatscounter_unixactive = 56, isc_sockstatscounter_rawopen = 57, isc_sockstatscounter_rawopenfail = 58, isc_sockstatscounter_rawclose = 59,
  isc_sockstatscounter_rawrecvfail = 60, isc_sockstatscounter_rawactive = 61, isc_sockstatscounter_max = 62
}
 Statistics counters. Used as isc_statscounter_t values. More...
enum  isc_sockettype_t {
  isc_sockettype_udp = 1, isc_sockettype_tcp = 2, isc_sockettype_unix = 3, isc_sockettype_fdwatch = 4,
  isc_sockettype_raw = 5
}

Functions

isc_result_t isc_socket_fdwatchcreate (isc_socketmgr_t *manager, int fd, int flags, isc_sockfdwatch_t callback, void *cbarg, isc_task_t *task, isc_socket_t **socketp)
 Create a new file descriptor watch socket managed by 'manager'.
isc_result_t isc_socket_fdwatchpoke (isc_socket_t *sock, int flags)
 Poke a file descriptor watch socket informing the manager that it should restart watching the socket.
isc_result_t isc_socket_create (isc_socketmgr_t *manager, int pf, isc_sockettype_t type, isc_socket_t **socketp)
 Create a new 'type' socket managed by 'manager'.
isc_result_t isc_socket_dup (isc_socket_t *sock0, isc_socket_t **socketp)
 Duplicate an existing socket, reusing its file descriptor.
void isc_socket_cancel (isc_socket_t *sock, isc_task_t *task, unsigned int how)
 Cancel pending I/O of the type specified by "how".
void isc_socket_shutdown (isc_socket_t *sock, unsigned int how)
 Shutdown 'socket' according to 'how'.
void isc_socket_attach (isc_socket_t *sock, isc_socket_t **socketp)
 Attach *socketp to socket.
void isc_socket_detach (isc_socket_t **socketp)
 Detach *socketp from its socket.
isc_result_t isc_socket_open (isc_socket_t *sock)
 Open a new socket file descriptor of the given socket structure. It simply opens a new descriptor; all of the other parameters including the socket type are inherited from the existing socket. This function is provided to avoid overhead of destroying and creating sockets when many short-lived sockets are frequently opened and closed. When the efficiency is not an issue, it should be safer to detach the unused socket and re-create a new one. This optimization may not be available for some systems, in which case this function will return ISC_R_NOTIMPLEMENTED and must not be used.
isc_result_t isc_socket_close (isc_socket_t *sock)
 Close a socket file descriptor of the given socket structure. This function is provided as an alternative to destroying an unused socket when overhead destroying/re-creating sockets can be significant, and is expected to be used with isc_socket_open(). This optimization may not be available for some systems, in which case this function will return ISC_R_NOTIMPLEMENTED and must not be used.
isc_result_t isc_socket_bind (isc_socket_t *sock, isc_sockaddr_t *addressp, unsigned int options)
 Bind 'socket' to '*addressp'.
isc_result_t isc_socket_filter (isc_socket_t *sock, const char *filter)
 Inform the kernel that it should perform accept filtering. If filter is NULL the current filter will be removed.:w.
isc_result_t isc_socket_listen (isc_socket_t *sock, unsigned int backlog)
 Set listen mode on the socket. After this call, the only function that can be used (other than attach and detach) is isc_socket_accept().
isc_result_t isc_socket_accept (isc_socket_t *sock, isc_task_t *task, isc_taskaction_t action, void *arg)
 Queue accept event. When a new connection is received, the task will get an ISC_SOCKEVENT_NEWCONN event with the sender set to the listen socket. The new socket structure is sent inside the isc_socket_newconnev_t event type, and is attached to the task 'task'.
isc_result_t isc_socket_connect (isc_socket_t *sock, isc_sockaddr_t *addressp, isc_task_t *task, isc_taskaction_t action, void *arg)
 Connect 'socket' to peer with address *saddr. When the connection succeeds, or when an error occurs, a CONNECT event with action 'action' and arg 'arg' will be posted to the event queue for 'task'.
isc_result_t isc_socket_getpeername (isc_socket_t *sock, isc_sockaddr_t *addressp)
 Get the name of the peer connected to 'socket'.
isc_result_t isc_socket_getsockname (isc_socket_t *sock, isc_sockaddr_t *addressp)
 Get the name of 'socket'.
isc_result_t isc_socketmgr_createinctx (isc_mem_t *mctx, isc_appctx_t *actx, isc_socketmgr_t **managerp)
isc_result_t isc_socketmgr_create (isc_mem_t *mctx, isc_socketmgr_t **managerp)
isc_result_t isc_socketmgr_create2 (isc_mem_t *mctx, isc_socketmgr_t **managerp, unsigned int maxsocks)
 Create a socket manager. If "maxsocks" is non-zero, it specifies the maximum number of sockets that the created manager should handle. isc_socketmgr_create() is equivalent of isc_socketmgr_create2() with "maxsocks" being zero. isc_socketmgr_createinctx() also associates the new manager with the specified application context.
isc_result_t isc_socketmgr_getmaxsockets (isc_socketmgr_t *manager, unsigned int *nsockp)
 Returns in "*nsockp" the maximum number of sockets this manager may open.
void isc_socketmgr_setstats (isc_socketmgr_t *manager, isc_stats_t *stats)
 Set a general socket statistics counter set 'stats' for 'manager'.
void isc_socketmgr_destroy (isc_socketmgr_t **managerp)
 Destroy a socket manager.
isc_sockettype_t isc_socket_gettype (isc_socket_t *sock)
 Returns the socket type for "sock.".
void isc_socket_dscp (isc_socket_t *sock, isc_dscp_t dscp)
 Sets the Differentiated Services Code Point (DSCP) field for packets transmitted on this socket. If 'dscp' is -1, return immediately.
isc_socketevent_tisc_socket_socketevent (isc_mem_t *mctx, void *sender, isc_eventtype_t eventtype, isc_taskaction_t action, void *arg)
 Get a isc_socketevent_t to be used with isc_socket_sendto2(), etc.
void isc_socket_cleanunix (isc_sockaddr_t *addr, isc_boolean_t active)
 Cleanup UNIX domain sockets in the file-system. If 'active' is true then just unlink the socket. If 'active' is false try to determine if there is a listener of the socket or not. If no listener is found then unlink socket.
isc_result_t isc_socket_permunix (isc_sockaddr_t *sockaddr, isc_uint32_t perm, isc_uint32_t owner, isc_uint32_t group)
 Set ownership and file permissions on the UNIX domain socket.
void isc_socket_setname (isc_socket_t *socket, const char *name, void *tag)
 Set the name and optional tag for a socket. This allows tracking of the owner or purpose for this socket, and is useful for tracing and statistics reporting.
const char * isc_socket_getname (isc_socket_t *socket)
 Get the name associated with a socket, if any.
void * isc_socket_gettag (isc_socket_t *socket)
 Get the tag associated with a socket, if any.
int isc_socket_getfd (isc_socket_t *socket)
 Get the file descriptor associated with a socket.
void isc__socketmgr_setreserved (isc_socketmgr_t *mgr, isc_uint32_t)
 Temporary. For use by named only.
void isc__socketmgr_maxudp (isc_socketmgr_t *mgr, int maxudp)
 Test interface. Drop UDP packet > 'maxudp'.
isc_result_t isc_socket_register (isc_socketmgrcreatefunc_t createfunc)
 Register a new socket I/O implementation and add it to the list of supported implementations. This function must be called when a different event library is used than the one contained in the ISC library.
isc_result_t isc__socket_register (void)
 A short cut function that specifies the socket I/O module in the ISC library for isc_socket_register(). An application that uses the ISC library usually do not have to care about this function: it would call isc_lib_register(), which internally calls this function.
isc_result_t isc_socket_recv (isc_socket_t *sock, isc_region_t *region, unsigned int minimum, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc_socket_recvv (isc_socket_t *sock, isc_bufferlist_t *buflist, unsigned int minimum, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc_socket_recv2 (isc_socket_t *sock, isc_region_t *region, unsigned int minimum, isc_task_t *task, isc_socketevent_t *event, unsigned int flags)
isc_result_t isc_socket_send (isc_socket_t *sock, isc_region_t *region, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc_socket_sendto (isc_socket_t *sock, isc_region_t *region, isc_task_t *task, isc_taskaction_t action, void *arg, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo)
isc_result_t isc_socket_sendv (isc_socket_t *sock, isc_bufferlist_t *buflist, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc_socket_sendtov (isc_socket_t *sock, isc_bufferlist_t *buflist, isc_task_t *task, isc_taskaction_t action, void *arg, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo)
isc_result_t isc_socket_sendtov2 (isc_socket_t *sock, isc_bufferlist_t *buflist, isc_task_t *task, isc_taskaction_t action, void *arg, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo, unsigned int flags)
isc_result_t isc_socket_sendto2 (isc_socket_t *sock, isc_region_t *region, isc_task_t *task, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo, isc_socketevent_t *event, unsigned int flags)
isc_boolean_t isc__socket_isbound (isc_socket_t *sock)
void isc_socket_ipv6only (isc_socket_t *sock, isc_boolean_t yes)
 Intended for internal use in BIND9 only.


Detailed Description

Provides TCP and UDP sockets for network I/O. The sockets are event sources in the task system.

When I/O completes, a completion event for the socket is posted to the event queue of the task which requested the I/O.

Definition in file socket.h.


Define Documentation

#define ISC_SOCKET_H   1

Definition at line 21 of file socket.h.

#define ISC_SOCKET_MAXSCATTERGATHER   8

Maximum number of buffers in a scatter/gather read/write. The operating system in use must support at least this number (plus one on some.).

Definition at line 128 of file socket.h.

#define ISC_SOCKET_REUSEADDRESS   0x01U

In isc_socket_bind() set socket option SO_REUSEADDR prior to calling bind() if a non zero port is specified (AF_INET and AF_INET6).

Definition at line 134 of file socket.h.

Referenced by add_listener(), ATF_TC_BODY(), get_dispsocket(), get_udpsocket(), listener_bind(), ns_interface_accepttcp(), send_tcp_connect(), send_udp(), and xfrin_start().

#define ISC_SOCKEVENTATTR_ATTACHED   0x80000000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 263 of file socket.h.

Referenced by send_recvdone_event(), and send_senddone_event().

#define ISC_SOCKEVENTATTR_TRUNC   0x00800000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 264 of file socket.h.

Referenced by doio_recv(), and process_cmsg().

#define ISC_SOCKEVENTATTR_CTRUNC   0x00400000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 265 of file socket.h.

Referenced by process_cmsg().

#define ISC_SOCKEVENTATTR_TIMESTAMP   0x00200000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 266 of file socket.h.

Referenced by process_cmsg().

#define ISC_SOCKEVENTATTR_PKTINFO   0x00100000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 267 of file socket.h.

Referenced by build_msghdr_send(), client_request(), ns_lwdclient_recv(), and process_cmsg().

#define ISC_SOCKEVENTATTR_MULTICAST   0x00080000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 268 of file socket.h.

Referenced by client_request(), and process_cmsg().

#define ISC_SOCKEVENTATTR_DSCP   0x00040000U

_ATTACHED: Internal use only. _TRUNC: Packet was truncated on receive. _CTRUNC: Packet control information was truncated. This can indicate that the packet is not complete, even though all the data is valid. _TIMESTAMP: The timestamp member is valid. _PKTINFO: The pktinfo member is valid. _MULTICAST: The UDP packet was received via a multicast transmission. _DSCP: The UDP DSCP value is valid.

Definition at line 269 of file socket.h.

Referenced by ATF_TC_BODY(), build_msghdr_send(), client_request(), client_sendpkg(), event_done(), process_cmsg(), req_send(), and resquery_send().

#define ISC_SOCKEVENT_ANYEVENT   (0)

Definition at line 272 of file socket.h.

#define ISC_SOCKEVENT_RECVDONE   (ISC_EVENTCLASS_SOCKET + 1)

Definition at line 273 of file socket.h.

Referenced by client_create(), client_request(), recv_done(), startrecv(), tcp_length_done(), and udp_recv().

#define ISC_SOCKEVENT_SENDDONE   (ISC_EVENTCLASS_SOCKET + 2)

Definition at line 274 of file socket.h.

Referenced by ATF_TC_BODY(), client_create(), client_senddone(), req_send(), req_senddone(), resquery_send(), resquery_senddone(), send_done(), xfrin_send_done(), and xfrout_senddone().

#define ISC_SOCKEVENT_NEWCONN   (ISC_EVENTCLASS_SOCKET + 3)

Definition at line 275 of file socket.h.

Referenced by client_newconn(), and isc__socket_accept().

#define ISC_SOCKEVENT_CONNECT   (ISC_EVENTCLASS_SOCKET + 4)

Definition at line 276 of file socket.h.

Referenced by connect_done(), process_sendevent(), req_connected(), resquery_connected(), resquery_udpconnected(), and xfrin_connect_done().

#define ISC_SOCKEVENT_INTR   (ISC_EVENTCLASS_SOCKET + 256)

Definition at line 281 of file socket.h.

#define ISC_SOCKEVENT_INTW   (ISC_EVENTCLASS_SOCKET + 257)

Definition at line 282 of file socket.h.

Referenced by internal_connect().

#define ISC_SOCKSHUT_RECV   0x00000001

close read side

How a socket should be shutdown in isc_socket_shutdown() calls.

Definition at line 296 of file socket.h.

#define ISC_SOCKSHUT_SEND   0x00000002

close write side

Definition at line 297 of file socket.h.

#define ISC_SOCKSHUT_ALL   0x00000003

close them all

Definition at line 298 of file socket.h.

#define ISC_SOCKCANCEL_RECV   0x00000001

cancel recv

What I/O events to cancel in isc_socket_cancel() calls.

Definition at line 305 of file socket.h.

Referenced by dns_dispatch_changeattributes(), dns_dispatch_detach(), dns_dispatch_getudp_dup(), dns_dispatch_removeresponse(), dns_tcpmsg_cancelread(), exit_check(), isc__socket_cancel(), isccc_ccmsg_cancelread(), and ns_interfacemgr_shutdown().

#define ISC_SOCKCANCEL_SEND   0x00000002

cancel send

Definition at line 306 of file socket.h.

Referenced by exit_check(), fctx_cancelquery(), isc__socket_cancel(), maybe_free_connection(), req_cancel(), xfrin_cancelio(), and xfrout_maybe_destroy().

#define ISC_SOCKCANCEL_ACCEPT   0x00000004

cancel accept

Definition at line 307 of file socket.h.

Referenced by exit_check(), isc__socket_cancel(), and shutdown_listener().

#define ISC_SOCKCANCEL_CONNECT   0x00000008

cancel connect

Definition at line 308 of file socket.h.

Referenced by fctx_cancelquery(), isc__socket_cancel(), req_cancel(), and xfrin_cancelio().

#define ISC_SOCKCANCEL_ALL   0x0000000f

cancel everything

Definition at line 309 of file socket.h.

Referenced by cancel_all(), cancel_lookup(), connect_timeout(), dns_dispatchset_cancelall(), flush_lookup_list(), isc_httpdmgr_shutdown(), lwdclientmgr_shutdown_callback(), and main().

#define ISC_SOCKFLAG_IMMEDIATE   0x00000001

send event only if needed

Flags for isc_socket_send() and isc_socket_recv() calls.

Definition at line 316 of file socket.h.

Referenced by client_sendpkg().

#define ISC_SOCKFLAG_NORETRY   0x00000002

drop failed UDP sends

Definition at line 317 of file socket.h.

Referenced by client_sendpkg(), and send_udp().

#define ISC_SOCKFDWATCH_READ   0x00000001

watch for readable

Flags for fdwatchcreate.

Definition at line 324 of file socket.h.

Referenced by isc__socket_fdwatchcreate(), and isc__socket_fdwatchpoke().

#define ISC_SOCKFDWATCH_WRITE   0x00000002

watch for writable

Definition at line 325 of file socket.h.

Referenced by isc__socket_fdwatchcreate(), and isc__socket_fdwatchpoke().

#define ISCAPI_SOCKETMGR_MAGIC   ISC_MAGIC('A','s','m','g')

Definition at line 399 of file socket.h.

#define ISCAPI_SOCKETMGR_VALID (  ) 

Value:

((m) != NULL && \
                                         (m)->magic == ISCAPI_SOCKETMGR_MAGIC)

Definition at line 400 of file socket.h.

Referenced by isc_socket_create(), isc_socket_fdwatchcreate(), and isc_socketmgr_destroy().

#define ISCAPI_SOCKET_MAGIC   ISC_MAGIC('A','s','c','t')

Definition at line 415 of file socket.h.

#define ISCAPI_SOCKET_VALID ( s   ) 

Value:

((s) != NULL && \
                                 (s)->magic == ISCAPI_SOCKET_MAGIC)

Definition at line 416 of file socket.h.

Referenced by isc_socket_attach(), isc_socket_bind(), isc_socket_cancel(), isc_socket_connect(), isc_socket_detach(), isc_socket_dscp(), isc_socket_dup(), isc_socket_fdwatchpoke(), isc_socket_getfd(), isc_socket_getsockname(), isc_socket_gettype(), isc_socket_ipv6only(), isc_socket_recv(), isc_socket_sendto(), and isc_socket_setname().


Typedef Documentation

typedef struct isc_socket_newconnev isc_socket_newconnev_t

Definition at line 237 of file socket.h.

typedef struct isc_socket_connev isc_socket_connev_t

Definition at line 245 of file socket.h.

typedef struct isc_socketmgrmethods isc_socketmgrmethods_t

typedef struct isc_socketmethods isc_socketmethods_t

typedef isc_result_t(* isc_socketmgrcreatefunc_t)(isc_mem_t *mctx, isc_socketmgr_t **managerp)

See isc_socketmgr_create() above.

<

Definition at line 1249 of file socket.h.


Enumeration Type Documentation

anonymous enum

Statistics counters. Used as isc_statscounter_t values.

Enumerator:
isc_sockstatscounter_udp4open 
isc_sockstatscounter_udp6open 
isc_sockstatscounter_tcp4open 
isc_sockstatscounter_tcp6open 
isc_sockstatscounter_unixopen 
isc_sockstatscounter_udp4openfail 
isc_sockstatscounter_udp6openfail 
isc_sockstatscounter_tcp4openfail 
isc_sockstatscounter_tcp6openfail 
isc_sockstatscounter_unixopenfail 
isc_sockstatscounter_udp4close 
isc_sockstatscounter_udp6close 
isc_sockstatscounter_tcp4close 
isc_sockstatscounter_tcp6close 
isc_sockstatscounter_unixclose 
isc_sockstatscounter_fdwatchclose 
isc_sockstatscounter_udp4bindfail 
isc_sockstatscounter_udp6bindfail 
isc_sockstatscounter_tcp4bindfail 
isc_sockstatscounter_tcp6bindfail 
isc_sockstatscounter_unixbindfail 
isc_sockstatscounter_fdwatchbindfail 
isc_sockstatscounter_udp4connect 
isc_sockstatscounter_udp6connect 
isc_sockstatscounter_tcp4connect 
isc_sockstatscounter_tcp6connect 
isc_sockstatscounter_unixconnect 
isc_sockstatscounter_fdwatchconnect 
isc_sockstatscounter_udp4connectfail 
isc_sockstatscounter_udp6connectfail 
isc_sockstatscounter_tcp4connectfail 
isc_sockstatscounter_tcp6connectfail 
isc_sockstatscounter_unixconnectfail 
isc_sockstatscounter_fdwatchconnectfail 
isc_sockstatscounter_tcp4accept 
isc_sockstatscounter_tcp6accept 
isc_sockstatscounter_unixaccept 
isc_sockstatscounter_tcp4acceptfail 
isc_sockstatscounter_tcp6acceptfail 
isc_sockstatscounter_unixacceptfail 
isc_sockstatscounter_udp4sendfail 
isc_sockstatscounter_udp6sendfail 
isc_sockstatscounter_tcp4sendfail 
isc_sockstatscounter_tcp6sendfail 
isc_sockstatscounter_unixsendfail 
isc_sockstatscounter_fdwatchsendfail 
isc_sockstatscounter_udp4recvfail 
isc_sockstatscounter_udp6recvfail 
isc_sockstatscounter_tcp4recvfail 
isc_sockstatscounter_tcp6recvfail 
isc_sockstatscounter_unixrecvfail 
isc_sockstatscounter_fdwatchrecvfail 
isc_sockstatscounter_udp4active 
isc_sockstatscounter_udp6active 
isc_sockstatscounter_tcp4active 
isc_sockstatscounter_tcp6active 
isc_sockstatscounter_unixactive 
isc_sockstatscounter_rawopen 
isc_sockstatscounter_rawopenfail 
isc_sockstatscounter_rawclose 
isc_sockstatscounter_rawrecvfail 
isc_sockstatscounter_rawactive 
isc_sockstatscounter_max 

Definition at line 139 of file socket.h.

enum isc_sockettype_t

Enumerator:
isc_sockettype_udp 
isc_sockettype_tcp 
isc_sockettype_unix 
isc_sockettype_fdwatch 
isc_sockettype_raw 

Definition at line 284 of file socket.h.


Function Documentation

isc_result_t isc_socket_fdwatchcreate ( isc_socketmgr_t manager,
int  fd,
int  flags,
isc_sockfdwatch_t  callback,
void *  cbarg,
isc_task_t task,
isc_socket_t **  socketp 
)

Create a new file descriptor watch socket managed by 'manager'.

Note:

Requires:

Ensures:

'*socketp' is attached to the newly created fdwatch socket

Returns:

Definition at line 247 of file socket_api.c.

References isc_socketmgrmethods::fdwatchcreate, isc__socket_fdwatchcreate(), isc_bind9, ISCAPI_SOCKETMGR_VALID, isc_socketmgr::methods, and REQUIRE.

isc_result_t isc_socket_fdwatchpoke ( isc_socket_t sock,
int  flags 
)

Poke a file descriptor watch socket informing the manager that it should restart watching the socket.

Note:

Requires:

Returns:

Definition at line 264 of file socket_api.c.

References isc_socketmethods::fdwatchpoke, isc__socket_fdwatchpoke(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

isc_result_t isc_socket_create ( isc_socketmgr_t manager,
int  pf,
isc_sockettype_t  type,
isc_socket_t **  socketp 
)

Create a new 'type' socket managed by 'manager'.

For isc_sockettype_fdwatch sockets you should use isc_socket_fdwatchcreate() rather than isc_socket_create().

Note:

Requires:

Ensures:

'*socketp' is attached to the newly created socket

Returns:

Definition at line 102 of file socket_api.c.

References isc__socket_create(), isc_bind9, ISCAPI_SOCKETMGR_VALID, isc_socketmgr::methods, REQUIRE, and isc_socketmgrmethods::socketcreate.

Referenced by add_listener(), ATF_TC_BODY(), create_tcp_dispatch(), fctx_query(), listener_bind(), ns_interface_accepttcp(), ns_interfacemgr_create(), open_socket(), rndc_startconnect(), send_tcp_connect(), send_udp(), and xfrin_start().

isc_result_t isc_socket_dup ( isc_socket_t sock0,
isc_socket_t **  socketp 
)

Duplicate an existing socket, reusing its file descriptor.

Definition at line 275 of file socket_api.c.

References isc_socketmethods::dup, isc__socket_dup(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by ATF_TC_BODY(), and open_socket().

void isc_socket_cancel ( isc_socket_t sock,
isc_task_t task,
unsigned int  how 
)

Cancel pending I/O of the type specified by "how".

Note: if "task" is NULL, then the cancel applies to all tasks using the socket.

Requires:

"how" is a bitmask describing the type of cancelation to perform. The type ISC_SOCKCANCEL_ALL will cancel all pending I/O on this socket.

Definition at line 191 of file socket_api.c.

References isc_socketmethods::cancel, isc__socket_cancel(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by cancel_all(), cancel_lookup(), connect_timeout(), dns_dispatch_changeattributes(), dns_dispatch_detach(), dns_dispatch_getudp_dup(), dns_dispatch_removeresponse(), dns_dispatchset_cancelall(), dns_tcpmsg_cancelread(), exit_check(), fctx_cancelquery(), flush_lookup_list(), isc_httpdmgr_shutdown(), isccc_ccmsg_cancelread(), lwdclientmgr_shutdown_callback(), main(), maybe_free_connection(), ns_interfacemgr_shutdown(), req_cancel(), shutdown_listener(), xfrin_cancelio(), and xfrout_maybe_destroy().

void isc_socket_shutdown ( isc_socket_t sock,
unsigned int  how 
)

Shutdown 'socket' according to 'how'.

Requires:

The read queue must be empty.

No further read requests may be made.

The write queue must be empty.

No further write requests may be made.

void isc_socket_attach ( isc_socket_t sock,
isc_socket_t **  socketp 
)

Attach *socketp to socket.

Requires:

Ensures:

Definition at line 114 of file socket_api.c.

References isc_socketmethods::attach, ENSURE, isc__socket_attach(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by connect_done(), dns_dispatch_createtcp2(), get_client(), get_worker(), isc_httpdmgr_create(), listener_copysock(), ns_lwdclientmgr_create(), and send_tcp_connect().

void isc_socket_detach ( isc_socket_t **  socketp  ) 

Detach *socketp from its socket.

Requires:

There must be no pending I/O requests.

Ensures:

The socket will be shutdown (both reading and writing) for all tasks.

All resources used by the socket have been freed

Definition at line 127 of file socket_api.c.

References ENSURE, isc__socket_detach(), isc_bind9, ISCAPI_SOCKET_VALID, and REQUIRE.

Referenced by add_listener(), ATF_TC_BODY(), clear_query(), connect_done(), control_newconn(), control_recvmessage(), control_senddone(), create_tcp_dispatch(), destroy_client(), destroy_disp(), destroy_dispsocket(), destroy_libs(), dispatch_createudp(), dns_dispatch_createtcp2(), exit_check(), fctx_query(), flush_lookup_list(), free_listener(), get_dispsocket(), get_udpsocket(), httpdmgr_destroy(), isc_httpd_accept(), isc_httpdmgr_create(), launch_next_query(), listener_bind(), lwdclientmgr_destroy(), maybe_free(), ns_interface_accepttcp(), ns_interface_destroy(), ns_interfacemgr_create(), ns_interfacemgr_destroy(), ns_interfacemgr_shutdown(), ns_lwreslistener_detach(), open_socket(), process_sendevent(), recv_done(), resquery_connected(), rndc_connected(), rndc_recvdone(), rndc_senddone(), tcp_length_done(), and xfrin_reset().

isc_result_t isc_socket_open ( isc_socket_t sock  ) 

Open a new socket file descriptor of the given socket structure. It simply opens a new descriptor; all of the other parameters including the socket type are inherited from the existing socket. This function is provided to avoid overhead of destroying and creating sockets when many short-lived sockets are frequently opened and closed. When the efficiency is not an issue, it should be safer to detach the unused socket and re-create a new one. This optimization may not be available for some systems, in which case this function will return ISC_R_NOTIMPLEMENTED and must not be used.

isc_socket_open() should not be called on sockets created by isc_socket_fdwatchcreate().

Requires:

Returns: Same as isc_socket_create().

Definition at line 296 of file socket_api.c.

References isc__socket_open().

Referenced by open_socket().

isc_result_t isc_socket_close ( isc_socket_t sock  ) 

Close a socket file descriptor of the given socket structure. This function is provided as an alternative to destroying an unused socket when overhead destroying/re-creating sockets can be significant, and is expected to be used with isc_socket_open(). This optimization may not be available for some systems, in which case this function will return ISC_R_NOTIMPLEMENTED and must not be used.

isc_socket_close() should not be called on sockets created by isc_socket_fdwatchcreate().

Requires:

Returns:

Definition at line 301 of file socket_api.c.

References isc__socket_close().

Referenced by deactivate_dispsocket(), and open_socket().

isc_result_t isc_socket_bind ( isc_socket_t sock,
isc_sockaddr_t addressp,
unsigned int  options 
)

Bind 'socket' to '*addressp'.

Requires:

Returns:

Definition at line 139 of file socket_api.c.

References isc_socketmethods::bind, isc__socket_bind(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by add_listener(), ATF_TC_BODY(), create_tcp_dispatch(), fctx_query(), listener_bind(), ns_interface_accepttcp(), open_socket(), rndc_startconnect(), send_tcp_connect(), send_udp(), and xfrin_start().

isc_result_t isc_socket_filter ( isc_socket_t sock,
const char *  filter 
)

Inform the kernel that it should perform accept filtering. If filter is NULL the current filter will be removed.:w.

Definition at line 384 of file socket_api.c.

References isc__socket_filter().

Referenced by isc_httpdmgr_create(), and ns_interface_accepttcp().

isc_result_t isc_socket_listen ( isc_socket_t sock,
unsigned int  backlog 
)

Set listen mode on the socket. After this call, the only function that can be used (other than attach and detach) is isc_socket_accept().

Notes:

Requires:

Returns:

Definition at line 389 of file socket_api.c.

References isc__socket_listen().

Referenced by ATF_TC_BODY(), control_listen(), isc_httpdmgr_create(), and ns_interface_accepttcp().

isc_result_t isc_socket_accept ( isc_socket_t sock,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Queue accept event. When a new connection is received, the task will get an ISC_SOCKEVENT_NEWCONN event with the sender set to the listen socket. The new socket structure is sent inside the isc_socket_newconnev_t event type, and is attached to the task 'task'.

REQUIRES:

RETURNS:

Definition at line 394 of file socket_api.c.

References isc__socket_accept().

Referenced by ATF_TC_BODY(), client_accept(), control_accept(), isc_httpd_accept(), and isc_httpdmgr_create().

isc_result_t isc_socket_connect ( isc_socket_t sock,
isc_sockaddr_t addressp,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Connect 'socket' to peer with address *saddr. When the connection succeeds, or when an error occurs, a CONNECT event with action 'action' and arg 'arg' will be posted to the event queue for 'task'.

Requires:

Returns:

Posted event's result code:

Definition at line 166 of file socket_api.c.

References isc_socketmethods::connect, isc__socket_connect(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by ATF_TC_BODY(), dns_request_createraw4(), dns_request_createvia4(), fctx_query(), resquery_send(), rndc_startconnect(), send_tcp_connect(), and xfrin_start().

isc_result_t isc_socket_getpeername ( isc_socket_t sock,
isc_sockaddr_t addressp 
)

Get the name of the peer connected to 'socket'.

Requires:

Returns:

Definition at line 401 of file socket_api.c.

References isc__socket_getpeername().

Referenced by client_newconn(), control_newconn(), control_senddone(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), get_worker(), isc_httpd_accept(), and log_invalid().

isc_result_t isc_socket_getsockname ( isc_socket_t sock,
isc_sockaddr_t addressp 
)

Get the name of 'socket'.

Requires:

Returns:

Definition at line 201 of file socket_api.c.

References isc_socketmethods::getsockname, isc__socket_getsockname(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by client_request(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), local_addr_match(), portavailable(), and xfrin_connect_done().

isc_result_t isc_socket_recv ( isc_socket_t sock,
isc_region_t region,
unsigned int  minimum,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Definition at line 178 of file socket_api.c.

References isc__socket_recv(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, isc_socketmethods::recv, and REQUIRE.

Referenced by ATF_TC_BODY(), dns_tcpmsg_readmessage(), isc_httpd_accept(), isc_httpd_recvdone(), isc_httpd_senddone(), isccc_ccmsg_readmessage(), ns_interfacemgr_create(), ns_lwdclient_startrecv(), and recv_length().

isc_result_t isc_socket_recvv ( isc_socket_t sock,
isc_bufferlist_t *  buflist,
unsigned int  minimum,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Definition at line 313 of file socket_api.c.

References isc__socket_recvv().

Referenced by launch_next_query(), recv_done(), send_udp(), and tcp_length_done().

isc_result_t isc_socket_recv2 ( isc_socket_t sock,
isc_region_t region,
unsigned int  minimum,
isc_task_t task,
isc_socketevent_t event,
unsigned int  flags 
)

Definition at line 321 of file socket_api.c.

References isc__socket_recv2().

Referenced by client_udprecv(), and startrecv().

isc_result_t isc_socket_send ( isc_socket_t sock,
isc_region_t region,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Receive from 'socket', storing the results in region.

Notes:

Requires:

Returns:

Event results:

Definition at line 329 of file socket_api.c.

References isc__socket_send().

Referenced by control_recvmessage(), rndc_connected(), rndc_recvnonce(), sendstream(), and xfrin_send_request().

isc_result_t isc_socket_sendto ( isc_socket_t sock,
isc_region_t region,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
isc_sockaddr_t address,
struct in6_pktinfo pktinfo 
)

Receive from 'socket', storing the results in region.

Notes:

Requires:

Returns:

Event results:

Definition at line 151 of file socket_api.c.

References isc__socket_sendto(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, REQUIRE, and isc_socketmethods::sendto.

Referenced by ATF_TC_BODY(), and ns_lwdclient_sendreply().

isc_result_t isc_socket_sendv ( isc_socket_t sock,
isc_bufferlist_t *  buflist,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Receive from 'socket', storing the results in region.

Notes:

Requires:

Returns:

Event results:

Definition at line 336 of file socket_api.c.

References isc__socket_sendv().

Referenced by isc_httpd_recvdone(), and launch_next_query().

isc_result_t isc_socket_sendtov ( isc_socket_t sock,
isc_bufferlist_t *  buflist,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
isc_sockaddr_t address,
struct in6_pktinfo pktinfo 
)

Receive from 'socket', storing the results in region.

Notes:

Requires:

Returns:

Event results:

Definition at line 343 of file socket_api.c.

References isc__socket_sendtov().

isc_result_t isc_socket_sendtov2 ( isc_socket_t sock,
isc_bufferlist_t *  buflist,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
isc_sockaddr_t address,
struct in6_pktinfo pktinfo,
unsigned int  flags 
)

Receive from 'socket', storing the results in region.

Notes:

Requires:

Returns:

Event results:

Definition at line 352 of file socket_api.c.

References isc__socket_sendtov2().

Referenced by send_udp().

isc_result_t isc_socket_sendto2 ( isc_socket_t sock,
isc_region_t region,
isc_task_t task,
isc_sockaddr_t address,
struct in6_pktinfo pktinfo,
isc_socketevent_t event,
unsigned int  flags 
)

Receive from 'socket', storing the results in region.

Notes:

Requires:

Returns:

Event results:

Definition at line 362 of file socket_api.c.

References isc__socket_sendto2().

Referenced by ATF_TC_BODY(), client_sendpkg(), req_send(), and resquery_send().

isc_result_t isc_socketmgr_createinctx ( isc_mem_t mctx,
isc_appctx_t actx,
isc_socketmgr_t **  managerp 
)

Send the contents of 'region' to the socket's peer.

Notes:

Requires:

Returns:

Event results:

Definition at line 54 of file socket_api.c.

References createlock, isc_appctx_setsocketmgr(), ISC_R_SUCCESS, LOCK, REQUIRE, socketmgr_createfunc, and UNLOCK.

Referenced by dns_client_create().

isc_result_t isc_socketmgr_create ( isc_mem_t mctx,
isc_socketmgr_t **  managerp 
)

Definition at line 73 of file socket_api.c.

References createlock, isc__socketmgr_create(), isc_bind9, LOCK, REQUIRE, socketmgr_createfunc, and UNLOCK.

Referenced by create_managers(), main(), setup_libs(), and setup_system().

isc_result_t isc_socketmgr_create2 ( isc_mem_t mctx,
isc_socketmgr_t **  managerp,
unsigned int  maxsocks 
)

Create a socket manager. If "maxsocks" is non-zero, it specifies the maximum number of sockets that the created manager should handle. isc_socketmgr_create() is equivalent of isc_socketmgr_create2() with "maxsocks" being zero. isc_socketmgr_createinctx() also associates the new manager with the specified application context.

Notes:

Requires:

Ensures:

Returns:

Definition at line 306 of file socket_api.c.

References isc__socketmgr_create2().

Referenced by create_managers().

isc_result_t isc_socketmgr_getmaxsockets ( isc_socketmgr_t manager,
unsigned int *  nsockp 
)

Returns in "*nsockp" the maximum number of sockets this manager may open.

Requires:

Returns:

Definition at line 4742 of file socket.c.

Referenced by create_managers(), and load_configuration().

void isc_socketmgr_setstats ( isc_socketmgr_t manager,
isc_stats_t stats 
)

Set a general socket statistics counter set 'stats' for 'manager'.

Requires:

Definition at line 4753 of file socket.c.

Referenced by ns_server_create().

void isc_socketmgr_destroy ( isc_socketmgr_t **  managerp  ) 

Destroy a socket manager.

Notes:

Requires:

Ensures:

Definition at line 90 of file socket_api.c.

References ENSURE, isc__socketmgr_destroy(), isc_bind9, ISCAPI_SOCKETMGR_VALID, and REQUIRE.

Referenced by cleanup(), cleanup_managers(), destroy_libs(), destroy_managers(), destroyclient(), dns_client_create(), and main().

isc_sockettype_t isc_socket_gettype ( isc_socket_t sock  ) 

Returns the socket type for "sock.".

Requires:

Definition at line 228 of file socket_api.c.

References isc_socketmethods::gettype, isc__socket_gettype(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by dns_dispatch_createtcp2().

isc_boolean_t isc__socket_isbound ( isc_socket_t sock  ) 

Definition at line 6142 of file socket.c.

void isc_socket_ipv6only ( isc_socket_t sock,
isc_boolean_t  yes 
)

Intended for internal use in BIND9 only.

If the socket is an IPv6 socket set/clear the IPV6_IPV6ONLY socket option if the host OS supports this option.

Requires:

Definition at line 211 of file socket_api.c.

References isc_socketmethods::ipv6only, isc__socket_ipv6only(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by add_listener(), ns_interface_accepttcp(), and open_socket().

void isc_socket_dscp ( isc_socket_t sock,
isc_dscp_t  dscp 
)

Sets the Differentiated Services Code Point (DSCP) field for packets transmitted on this socket. If 'dscp' is -1, return immediately.

Requires:

Definition at line 221 of file socket_api.c.

References isc_socketmethods::dscp, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by ATF_TC_BODY(), create_tcp_dispatch(), fctx_query(), ns_interface_accepttcp(), resquery_send(), send_tcp_connect(), send_udp(), and xfrin_start().

isc_socketevent_t * isc_socket_socketevent ( isc_mem_t mctx,
void *  sender,
isc_eventtype_t  eventtype,
isc_taskaction_t  action,
void *  arg 
)

Get a isc_socketevent_t to be used with isc_socket_sendto2(), etc.

Definition at line 6258 of file socket.c.

Referenced by ATF_TC_BODY(), client_create(), and req_send().

void isc_socket_cleanunix ( isc_sockaddr_t addr,
isc_boolean_t  active 
)

Cleanup UNIX domain sockets in the file-system. If 'active' is true then just unlink the socket. If 'active' is false try to determine if there is a listener of the socket or not. If no listener is found then unlink socket.

Prior to unlinking the path is tested to see if it a socket.

Note: there are a number of race conditions which cannot be avoided both in the filesystem and any application using UNIX domain sockets (e.g. socket is tested between bind() and listen(), the socket is deleted and replaced in the file-system between stat() and unlink()).

Definition at line 372 of file socket_api.c.

References isc__socket_cleanunix().

Referenced by add_listener(), and shutdown_listener().

isc_result_t isc_socket_permunix ( isc_sockaddr_t sockaddr,
isc_uint32_t  perm,
isc_uint32_t  owner,
isc_uint32_t  group 
)

Set ownership and file permissions on the UNIX domain socket.

Note: On Solaris and SunOS this secures the directory containing the socket as Solaris and SunOS do not honour the filesystem permissions on the socket.

Requires:

Returns:

Definition at line 377 of file socket_api.c.

References isc__socket_permunix().

Referenced by add_listener(), and update_listener().

void isc_socket_setname ( isc_socket_t socket,
const char *  name,
void *  tag 
)

Set the name and optional tag for a socket. This allows tracking of the owner or purpose for this socket, and is useful for tracing and statistics reporting.

Definition at line 238 of file socket_api.c.

References ISCAPI_SOCKET_VALID, REQUIRE, and UNUSED.

Referenced by add_listener(), client_newconn(), control_newconn(), get_worker(), isc_httpd_accept(), ns_interface_accepttcp(), open_socket(), and xfrin_start().

const char* isc_socket_getname ( isc_socket_t socket  ) 

Get the name associated with a socket, if any.

void* isc_socket_gettag ( isc_socket_t socket  ) 

Get the tag associated with a socket, if any.

int isc_socket_getfd ( isc_socket_t socket  ) 

Get the file descriptor associated with a socket.

Definition at line 286 of file socket_api.c.

References isc_socketmethods::getfd, isc__socket_getfd(), isc_bind9, ISCAPI_SOCKET_VALID, isc_socket::methods, and REQUIRE.

Referenced by dispatch_createudp().

void isc__socketmgr_setreserved ( isc_socketmgr_t mgr,
isc_uint32_t   
)

Temporary. For use by named only.

Definition at line 4325 of file socket.c.

Referenced by load_configuration().

void isc__socketmgr_maxudp ( isc_socketmgr_t mgr,
int  maxudp 
)

Test interface. Drop UDP packet > 'maxudp'.

Definition at line 4334 of file socket.c.

Referenced by create_managers().

isc_result_t isc_socket_register ( isc_socketmgrcreatefunc_t  createfunc  ) 

Register a new socket I/O implementation and add it to the list of supported implementations. This function must be called when a different event library is used than the one contained in the ISC library.

Definition at line 38 of file socket_api.c.

References createlock, initialize(), isc_once_do, ISC_R_EXISTS, ISC_R_SUCCESS, LOCK, once, RUNTIME_CHECK, socketmgr_createfunc, and UNLOCK.

Referenced by isc__socket_getfd().

isc_result_t isc__socket_register ( void   ) 

A short cut function that specifies the socket I/O module in the ISC library for isc_socket_register(). An application that uses the ISC library usually do not have to care about this function: it would call isc_lib_register(), which internally calls this function.

Definition at line 6428 of file socket.c.

Referenced by do_register().


Generated on Tue Apr 28 17:41:16 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha