socket.c File Reference

#include <config.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <isc/buffer.h>
#include <isc/bufferlist.h>
#include <isc/condition.h>
#include <isc/formatcheck.h>
#include <isc/json.h>
#include <isc/list.h>
#include <isc/log.h>
#include <isc/mem.h>
#include <isc/msgs.h>
#include <isc/mutex.h>
#include <isc/net.h>
#include <isc/once.h>
#include <isc/platform.h>
#include <isc/print.h>
#include <isc/region.h>
#include <isc/resource.h>
#include <isc/socket.h>
#include <isc/stats.h>
#include <isc/strerror.h>
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/util.h>
#include <isc/xml.h>
#include "errno2result.h"
#include "socket_p.h"
#include "../task_p.h"
#include "../socket_api.c"

Go to the source code of this file.

Data Structures

struct  isc_socketwait
struct  isc__socket
struct  isc__socketmgr

Defines

#define USE_SHARED_MANAGER
#define USE_SELECT
 Choose the most preferable multiplex method.
#define ISC_SOCKET_MAXSOCKETS   FD_SETSIZE
 Maximum number of allowable open sockets. This is also the maximum allowable socket file descriptor.
#define FDLOCK_COUNT   1
 Mac OS X needs a special definition to support larger values in select(). We always define this because a larger value can be specified run-time.
#define FDLOCK_ID(fd)   0
#define ISC_SOCKADDR_LEN_T   unsigned int
 Maximum number of events communicated with the kernel. There should normally be no need for having a large number.
#define SOFT_ERROR(e)
 Define what the possible "soft" errors can be. These are non-fatal returns of various network related functions, like recv() and so on.
#define DLVL(x)   ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(x)
#define TRACE_LEVEL   90
#define CORRECTNESS_LEVEL   70
#define IOEVENT_LEVEL   60
#define EVENT_LEVEL   50
#define CREATION_LEVEL   20
#define TRACE   DLVL(TRACE_LEVEL)
#define CORRECTNESS   DLVL(CORRECTNESS_LEVEL)
#define IOEVENT   DLVL(IOEVENT_LEVEL)
#define EVENT   DLVL(EVENT_LEVEL)
#define CREATION   DLVL(CREATION_LEVEL)
#define SOCKET_MAGIC   ISC_MAGIC('I', 'O', 'i', 'o')
#define VALID_SOCKET(s)   ISC_MAGIC_VALID(s, SOCKET_MAGIC)
#define RCVBUFSIZE   (32*1024)
 NetBSD and FreeBSD can timestamp packets. XXXMLG Should we have a setsockopt() like interface to request timestamps, and if the OS doesn't do it for us, call gettimeofday() on every UDP receive?
#define NRETRIES   10
 The number of times a send operation is repeated if the result is EINTR.
#define NEWCONNSOCK(ev)   ((isc__socket_t *)(ev)->newsocket)
#define SOCKET_MANAGER_MAGIC   ISC_MAGIC('I', 'O', 'm', 'g')
#define VALID_MANAGER(m)   ISC_MAGIC_VALID(m, SOCKET_MANAGER_MAGIC)
#define CLOSED   0
#define MANAGED   1
#define CLOSE_PENDING   2
#define MAXSCATTERGATHER_SEND   (ISC_SOCKET_MAXSCATTERGATHER)
#define MAXSCATTERGATHER_RECV   (ISC_SOCKET_MAXSCATTERGATHER)
#define SELECT_POKE_SHUTDOWN   (-1)
#define SELECT_POKE_NOTHING   (-2)
#define SELECT_POKE_READ   (-3)
#define SELECT_POKE_ACCEPT   (-3)
 Same as _READ.
#define SELECT_POKE_WRITE   (-4)
#define SELECT_POKE_CONNECT   (-4)
 Same as _WRITE.
#define SELECT_POKE_CLOSE   (-5)
#define SOCK_DEAD(s)   ((s)->references == 0)
#define FIX_IPV6_RECVPKTINFO(sock)   (void)0
#define DOIO_SUCCESS   0
#define DOIO_SOFT   1
#define DOIO_HARD   2
#define DOIO_EOF   3
#define SOFT_OR_HARD(_system, _isc)
#define ALWAYS_HARD(_system, _isc)
#define SOFT_OR_HARD(_system, _isc)
#define ALWAYS_HARD(_system, _isc)
#define DCSPPKT(pf)   ((pf == AF_INET) ? ISC_NET_DSCPPKTV4 : ISC_NET_DSCPPKTV6)
#define ERROR_MATCH(a, b)   case a: dev->result = b; goto err_exit;
#define ERROR_MATCH(a, b)   case a: result = b; break;

Typedefs

typedef isc_event_t intev_t
typedef struct isc__socket isc__socket_t
typedef struct isc__socketmgr isc__socketmgr_t

Enumerations

enum  {
  STATID_OPEN = 0, STATID_OPENFAIL = 1, STATID_CLOSE = 2, STATID_BINDFAIL = 3,
  STATID_CONNECTFAIL = 4, STATID_CONNECT = 5, STATID_ACCEPTFAIL = 6, STATID_ACCEPT = 7,
  STATID_SENDFAIL = 8, STATID_RECVFAIL = 9, STATID_ACTIVE = 10
}
 Shortcut index arrays to get access to statistics counters. More...

Functions

static isc_result_t socket_create (isc_socketmgr_t *manager0, int pf, isc_sockettype_t type, isc_socket_t **socketp, isc_socket_t *dup_socket)
static void send_recvdone_event (isc__socket_t *, isc_socketevent_t **)
static void send_senddone_event (isc__socket_t *, isc_socketevent_t **)
static void send_connectdone_event (isc__socket_t *, isc_socket_connev_t **)
static void free_socket (isc__socket_t **)
static isc_result_t allocate_socket (isc__socketmgr_t *, isc_sockettype_t, isc__socket_t **)
static void destroy (isc__socket_t **)
static void internal_accept (isc_task_t *, isc_event_t *)
static void internal_connect (isc_task_t *, isc_event_t *)
static void internal_recv (isc_task_t *, isc_event_t *)
static void internal_send (isc_task_t *, isc_event_t *)
static void internal_fdwatch_write (isc_task_t *, isc_event_t *)
static void internal_fdwatch_read (isc_task_t *, isc_event_t *)
static void process_cmsg (isc__socket_t *, struct msghdr *, isc_socketevent_t *)
static void build_msghdr_send (isc__socket_t *, isc_socketevent_t *, struct msghdr *, struct iovec *, size_t *)
static void build_msghdr_recv (isc__socket_t *, isc_socketevent_t *, struct msghdr *, struct iovec *, size_t *)
static void setdscp (isc__socket_t *sock, isc_dscp_t dscp)
isc_result_t isc__socket_open (isc_socket_t *sock0)
 The following are intended for internal use (indicated by "isc__" prefix) but are not declared as static, allowing direct access from unit tests etc.
isc_result_t isc__socket_close (isc_socket_t *sock0)
isc_result_t isc__socket_create (isc_socketmgr_t *manager0, int pf, isc_sockettype_t type, isc_socket_t **socketp)
 Create a new 'type' socket managed by 'manager'. Events will be posted to 'task' and when dispatched 'action' will be called with 'arg' as the arg value. The new socket is returned in 'socketp'.
void isc__socket_attach (isc_socket_t *sock, isc_socket_t **socketp)
void isc__socket_detach (isc_socket_t **socketp)
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_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_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_socketevent_tisc_socket_socketevent (isc_mem_t *mctx, void *sender, isc_eventtype_t eventtype, isc_taskaction_t action, void *arg)
void isc__socket_cleanunix (isc_sockaddr_t *sockaddr, isc_boolean_t active)
isc_result_t isc__socket_permunix (isc_sockaddr_t *sockaddr, isc_uint32_t perm, isc_uint32_t owner, isc_uint32_t group)
isc_result_t isc__socket_bind (isc_socket_t *sock, isc_sockaddr_t *sockaddr, unsigned int options)
isc_result_t isc__socket_filter (isc_socket_t *sock, const char *filter)
isc_result_t isc__socket_listen (isc_socket_t *sock, unsigned int backlog)
isc_result_t isc__socket_accept (isc_socket_t *sock, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc__socket_connect (isc_socket_t *sock, isc_sockaddr_t *addr, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc__socket_getpeername (isc_socket_t *sock, isc_sockaddr_t *addressp)
isc_result_t isc__socket_getsockname (isc_socket_t *sock, isc_sockaddr_t *addressp)
void isc__socket_cancel (isc_socket_t *sock, isc_task_t *task, unsigned int how)
isc_sockettype_t isc__socket_gettype (isc_socket_t *sock)
isc_boolean_t isc__socket_isbound (isc_socket_t *sock)
void isc__socket_ipv6only (isc_socket_t *sock, isc_boolean_t yes)
void isc__socket_dscp (isc_socket_t *sock, isc_dscp_t dscp)
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)
isc_result_t isc__socket_fdwatchpoke (isc_socket_t *sock, int flags)
isc_result_t isc__socket_dup (isc_socket_t *sock0, isc_socket_t **socketp)
 Duplicate an existing socket. The new socket is returned in 'socketp'.
int isc__socket_getfd (isc_socket_t *sock)
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)
isc_result_t isc_socketmgr_getmaxsockets (isc_socketmgr_t *manager0, unsigned int *nsockp)
void isc_socketmgr_setstats (isc_socketmgr_t *manager0, isc_stats_t *stats)
void isc__socketmgr_destroy (isc_socketmgr_t **managerp)
void isc__socket_setname (isc_socket_t *socket0, const char *name, void *tag)
const char * isc__socket_getname (isc_socket_t *socket0)
void * isc__socket_gettag (isc_socket_t *socket0)
static void socket_log (isc__socket_t *sock, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, isc_msgcat_t *msgcat, int msgset, int message, const char *fmt,...) ISC_FORMAT_PRINTF(9
static void inc_stats (isc_stats_t *stats, isc_statscounter_t counterid)
 Increment socket-related statistics counters.
static void dec_stats (isc_stats_t *stats, isc_statscounter_t counterid)
 Decrement socket-related statistics counters.
static isc_result_t watch_fd (isc__socketmgr_t *manager, int fd, int msg)
static isc_result_t unwatch_fd (isc__socketmgr_t *manager, int fd, int msg)
static void wakeup_socket (isc__socketmgr_t *manager, int fd, int msg)
static void select_poke (isc__socketmgr_t *manager, int fd, int msg)
static isc_result_t make_nonblock (int fd)
static void set_dev_address (isc_sockaddr_t *address, isc__socket_t *sock, isc_socketevent_t *dev)
static void destroy_socketevent (isc_event_t *event)
static isc_socketevent_tallocate_socketevent (isc_mem_t *mctx, void *sender, isc_eventtype_t eventtype, isc_taskaction_t action, void *arg)
static int doio_recv (isc__socket_t *sock, isc_socketevent_t *dev)
static int doio_send (isc__socket_t *sock, isc_socketevent_t *dev)
static void socketclose (isc__socketmgr_t *manager, isc__socket_t *sock, int fd)
static void use_min_mtu (isc__socket_t *sock)
static isc_result_t opensocket (isc__socketmgr_t *manager, isc__socket_t *sock, isc__socket_t *dup_socket)
static void dispatch_recv (isc__socket_t *sock)
static void dispatch_send (isc__socket_t *sock)
static void dispatch_accept (isc__socket_t *sock)
static void dispatch_connect (isc__socket_t *sock)
static void process_fd (isc__socketmgr_t *manager, int fd, isc_boolean_t readable, isc_boolean_t writeable)
static void process_fds (isc__socketmgr_t *manager, int maxfd, fd_set *readfds, fd_set *writefds)
void isc__socketmgr_setreserved (isc_socketmgr_t *manager0, isc_uint32_t reserved)
 Temporary. For use by named only.
void isc__socketmgr_maxudp (isc_socketmgr_t *manager0, int maxudp)
 Test interface. Drop UDP packet > 'maxudp'.
static isc_result_t setup_watcher (isc_mem_t *mctx, isc__socketmgr_t *manager)
static void cleanup_watcher (isc_mem_t *mctx, isc__socketmgr_t *manager)
static isc_result_t socket_recv (isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, unsigned int flags)
static isc_result_t socket_send (isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo, unsigned int flags)
int isc__socketmgr_waitevents (isc_socketmgr_t *manager0, struct timeval *tvp, isc_socketwait_t **swaitp)
isc_result_t isc__socketmgr_dispatch (isc_socketmgr_t *manager0, isc_socketwait_t *swait)
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.

Variables

int isc_dscp_check_value = -1
static isc__socketmgr_tsocketmgr = NULL
struct {
   isc_socketmethods_t   methods
   void *   recvv
 The following are defined just for avoiding unused static functions.
   void *   send
   void *   sendv
   void *   sendto2
   void *   cleanunix
   void *   permunix
   void *   filter
   void *   listen
   void *   accept
   void *   getpeername
   void *   isbound
socketmethods
static isc_socketmgrmethods_t socketmgrmethods
static const isc_statscounter_t udp4statsindex []
static const isc_statscounter_t udp6statsindex []
static const isc_statscounter_t tcp4statsindex []
static const isc_statscounter_t tcp6statsindex []
static const isc_statscounter_t unixstatsindex []
static const isc_statscounter_t fdwatchstatsindex []
static const isc_statscounter_t rawstatsindex []
static isc_socketwait_t swait_private


Detailed Description

Definition in file socket.c.


Define Documentation

#define USE_SHARED_MANAGER

Definition at line 93 of file socket.c.

#define USE_SELECT

Choose the most preferable multiplex method.

Definition at line 119 of file socket.c.

#define ISC_SOCKET_MAXSOCKETS   FD_SETSIZE

Maximum number of allowable open sockets. This is also the maximum allowable socket file descriptor.

Care should be taken before modifying this value for select(): The API standard doesn't ensure select() accept more than (the system default of) FD_SETSIZE descriptors, and the default size should in fact be fine in the vast majority of cases. This constant should therefore be increased only when absolutely necessary and possible, i.e., the server is exhausting all available file descriptors (up to FD_SETSIZE) and the select() function and FD_xxx macros support larger values than FD_SETSIZE (which may not always by true, but we keep using some of them to ensure as much portability as possible). Note also that overall server performance may be rather worsened with a larger value of this constant due to inherent scalability problems of select().

As a special note, this value shouldn't have to be touched if this is a build for an authoritative only DNS server.

Definition at line 171 of file socket.c.

#define FDLOCK_COUNT   1

Mac OS X needs a special definition to support larger values in select(). We always define this because a larger value can be specified run-time.

Size of per-FD lock buckets.

Definition at line 220 of file socket.c.

#define FDLOCK_ID ( fd   )     0

Definition at line 221 of file socket.c.

Referenced by internal_accept(), isc__socket_fdwatchcreate(), process_fd(), socket_create(), socketclose(), unwatch_fd(), wakeup_socket(), and watch_fd().

#define ISC_SOCKADDR_LEN_T   unsigned int

Maximum number of events communicated with the kernel. There should normally be no need for having a large number.

Some systems define the socket length argument as an int, some as size_t, some as socklen_t. This is here so it can be easily changed if needed.

Definition at line 243 of file socket.c.

#define SOFT_ERROR (  ) 

Value:

((e) == EAGAIN || \
                         (e) == EWOULDBLOCK || \
                         (e) == EINTR || \
                         (e) == 0)
Define what the possible "soft" errors can be. These are non-fatal returns of various network related functions, like recv() and so on.

For some reason, BSDI (and perhaps others) will sometimes return <0 from recv() but will have errno==0. This is broken, but we have to work around it here.

Definition at line 254 of file socket.c.

Referenced by doio_recv(), doio_send(), internal_accept(), and internal_connect().

#define DLVL (  )     ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(x)

DLVL(90) -- Function entry/exit and other tracing. DLVL(70) -- Socket "correctness" -- including returning of events, etc. DLVL(60) -- Socket data send/receive DLVL(50) -- Event tracing, including receiving/sending completion events. DLVL(20) -- Socket creation/destruction.

Definition at line 259 of file socket.c.

#define TRACE_LEVEL   90

Definition at line 270 of file socket.c.

#define CORRECTNESS_LEVEL   70

Definition at line 271 of file socket.c.

#define IOEVENT_LEVEL   60

Definition at line 272 of file socket.c.

Referenced by doio_recv().

#define EVENT_LEVEL   50

Definition at line 273 of file socket.c.

#define CREATION_LEVEL   20

Definition at line 274 of file socket.c.

#define TRACE   DLVL(TRACE_LEVEL)

Definition at line 276 of file socket.c.

Referenced by build_msghdr_send(), internal_accept(), isc__socket_fdwatchpoke(), and process_cmsg().

#define CORRECTNESS   DLVL(CORRECTNESS_LEVEL)

Definition at line 277 of file socket.c.

#define IOEVENT   DLVL(IOEVENT_LEVEL)

Definition at line 278 of file socket.c.

Referenced by doio_recv().

#define EVENT   DLVL(EVENT_LEVEL)

Definition at line 279 of file socket.c.

Referenced by dispatch_recv().

#define CREATION   DLVL(CREATION_LEVEL)

Definition at line 280 of file socket.c.

Referenced by internal_accept(), isc__socket_fdwatchcreate(), isc__socket_filter(), and socket_create().

#define SOCKET_MAGIC   ISC_MAGIC('I', 'O', 'i', 'o')

Definition at line 284 of file socket.c.

#define VALID_SOCKET ( s   )     ISC_MAGIC_VALID(s, SOCKET_MAGIC)

Definition at line 285 of file socket.c.

Referenced by free_socket(), internal_accept(), internal_connect(), isc__socket_accept(), isc__socket_attach(), isc__socket_cancel(), isc__socket_detach(), isc__socket_dup(), isc__socket_fdwatchpoke(), isc__socket_filter(), and isc__socket_listen().

#define RCVBUFSIZE   (32*1024)

NetBSD and FreeBSD can timestamp packets. XXXMLG Should we have a setsockopt() like interface to request timestamps, and if the OS doesn't do it for us, call gettimeofday() on every UDP receive?

IPv6 control information. If the socket is an IPv6 socket we want to collect the destination address and interface so the client can set them on outgoing packets.

The size to raise the receive buffer to (from BIND 8).

Definition at line 319 of file socket.c.

#define NRETRIES   10

The number of times a send operation is repeated if the result is EINTR.

Definition at line 325 of file socket.c.

Referenced by doio_send().

#define NEWCONNSOCK ( ev   )     ((isc__socket_t *)(ev)->newsocket)

Definition at line 330 of file socket.c.

Referenced by internal_accept(), and isc__socket_cancel().

#define SOCKET_MANAGER_MAGIC   ISC_MAGIC('I', 'O', 'm', 'g')

Definition at line 390 of file socket.c.

#define VALID_MANAGER (  )     ISC_MAGIC_VALID(m, SOCKET_MANAGER_MAGIC)

Definition at line 391 of file socket.c.

#define CLOSED   0

Definition at line 455 of file socket.c.

Referenced by socketclose(), and wakeup_socket().

#define MANAGED   1

Definition at line 456 of file socket.c.

Referenced by internal_accept(), isc__socket_fdwatchcreate(), socket_create(), socketclose(), and wakeup_socket().

#define CLOSE_PENDING   2

Definition at line 457 of file socket.c.

Referenced by process_fd(), socketclose(), and wakeup_socket().

#define MAXSCATTERGATHER_SEND   (ISC_SOCKET_MAXSCATTERGATHER)

Definition at line 462 of file socket.c.

Referenced by build_msghdr_send().

#define MAXSCATTERGATHER_RECV   (ISC_SOCKET_MAXSCATTERGATHER)

Definition at line 466 of file socket.c.

Referenced by build_msghdr_recv().

#define SELECT_POKE_SHUTDOWN   (-1)

Definition at line 666 of file socket.c.

Referenced by select_poke().

#define SELECT_POKE_NOTHING   (-2)

Definition at line 667 of file socket.c.

#define SELECT_POKE_READ   (-3)

Definition at line 668 of file socket.c.

Referenced by isc__socket_fdwatchcreate(), isc__socket_fdwatchpoke(), process_fd(), setup_watcher(), socketclose(), unwatch_fd(), wakeup_socket(), and watch_fd().

#define SELECT_POKE_ACCEPT   (-3)

Same as _READ.

Definition at line 669 of file socket.c.

Referenced by internal_accept(), and isc__socket_accept().

#define SELECT_POKE_WRITE   (-4)

Definition at line 670 of file socket.c.

Referenced by isc__socket_fdwatchcreate(), isc__socket_fdwatchpoke(), process_fd(), socketclose(), unwatch_fd(), wakeup_socket(), and watch_fd().

#define SELECT_POKE_CONNECT   (-4)

Same as _WRITE.

Definition at line 671 of file socket.c.

Referenced by internal_connect().

#define SELECT_POKE_CLOSE   (-5)

Definition at line 672 of file socket.c.

Referenced by socketclose(), and wakeup_socket().

#define SOCK_DEAD ( s   )     ((s)->references == 0)

Definition at line 674 of file socket.c.

Referenced by process_fd().

#define FIX_IPV6_RECVPKTINFO ( sock   )     (void)0

Definition at line 873 of file socket.c.

#define DOIO_SUCCESS   0

Definition at line 1824 of file socket.c.

Referenced by doio_recv(), and doio_send().

#define DOIO_SOFT   1

Definition at line 1825 of file socket.c.

Referenced by doio_recv(), and doio_send().

#define DOIO_HARD   2

Definition at line 1826 of file socket.c.

Referenced by doio_recv(), and doio_send().

#define DOIO_EOF   3

Definition at line 1827 of file socket.c.

Referenced by doio_recv().

#define SOFT_OR_HARD ( _system,
_isc   ) 

Value:

if (recv_errno == _system) { \
                if (sock->connected) { \
                        dev->result = _isc; \
                        inc_stats(sock->manager->stats, \
                                  sock->statsindex[STATID_RECVFAIL]); \
                        return (DOIO_HARD); \
                } \
                return (DOIO_SOFT); \
        }

Referenced by doio_recv(), and doio_send().

#define ALWAYS_HARD ( _system,
_isc   ) 

Value:

if (recv_errno == _system) { \
                dev->result = _isc; \
                inc_stats(sock->manager->stats, \
                          sock->statsindex[STATID_RECVFAIL]); \
                return (DOIO_HARD); \
        }

Referenced by doio_recv(), and doio_send().

#define SOFT_OR_HARD ( _system,
_isc   ) 

Value:

if (send_errno == _system) { \
                if (sock->connected) { \
                        dev->result = _isc; \
                        inc_stats(sock->manager->stats, \
                                  sock->statsindex[STATID_SENDFAIL]); \
                        return (DOIO_HARD); \
                } \
                return (DOIO_SOFT); \
        }

#define ALWAYS_HARD ( _system,
_isc   ) 

Value:

if (send_errno == _system) { \
                dev->result = _isc; \
                inc_stats(sock->manager->stats, \
                          sock->statsindex[STATID_SENDFAIL]); \
                return (DOIO_HARD); \
        }

#define DCSPPKT ( pf   )     ((pf == AF_INET) ? ISC_NET_DSCPPKTV4 : ISC_NET_DSCPPKTV6)

Referenced by socket_create().

#define ERROR_MATCH ( a,
 )     case a: dev->result = b; goto err_exit;

Referenced by internal_connect().

#define ERROR_MATCH ( a,
 )     case a: result = b; break;


Typedef Documentation

typedef isc_event_t intev_t

Definition at line 282 of file socket.c.

typedef struct isc__socket isc__socket_t

Definition at line 327 of file socket.c.

typedef struct isc__socketmgr isc__socketmgr_t

Definition at line 328 of file socket.c.


Enumeration Type Documentation

anonymous enum

Shortcut index arrays to get access to statistics counters.

Enumerator:
STATID_OPEN 
STATID_OPENFAIL 
STATID_CLOSE 
STATID_BINDFAIL 
STATID_CONNECTFAIL 
STATID_CONNECT 
STATID_ACCEPTFAIL 
STATID_ACCEPT 
STATID_SENDFAIL 
STATID_RECVFAIL 
STATID_ACTIVE 

Definition at line 679 of file socket.c.


Function Documentation

static isc_result_t socket_create ( isc_socketmgr_t manager0,
int  pf,
isc_sockettype_t  type,
isc_socket_t **  socketp,
isc_socket_t dup_socket 
) [static]

Definition at line 2906 of file socket.c.

References allocate_socket(), isc__socket::common, CREATION, DCSPPKT, isc__socketmgr::fdlock, FDLOCK_ID, isc__socketmgr::fds, isc__socketmgr::fdstate, free_socket(), INSIST, ISC_LIST_APPEND, ISC_MSG_CREATED, ISC_MSGSET_SOCKET, isc_net_probedscp(), ISC_R_SUCCESS, isc_sockettype_fdwatch, isc_sockettype_raw, isc_sockettype_tcp, isc_sockettype_udp, isc_sockettype_unix, isc__socketmgr::lock, LOCK, MANAGED, isc__socket::manager, isc_socket::methods, opensocket(), REQUIRE, socket_log(), socketmethods, isc__socket::statsindex, isc__socket::type, UNLOCK, and VALID_MANAGER.

Referenced by isc__socket_create(), and isc__socket_dup().

static void send_recvdone_event ( isc__socket_t sock,
isc_socketevent_t **  dev 
) [static]

Definition at line 3381 of file socket.c.

References ISC_LINK_LINKED, ISC_LIST_DEQUEUE, ISC_SOCKEVENTATTR_ATTACHED, isc_task_send(), and isc_task_sendanddetach().

Referenced by isc__socket_cancel().

static void send_senddone_event ( isc__socket_t sock,
isc_socketevent_t **  dev 
) [static]

Definition at line 3404 of file socket.c.

References INSIST, ISC_LINK_LINKED, ISC_LIST_DEQUEUE, ISC_SOCKEVENTATTR_ATTACHED, isc_task_send(), and isc_task_sendanddetach().

Referenced by isc__socket_cancel().

static void send_connectdone_event ( isc__socket_t sock,
isc_socket_connev_t **  dev 
) [static]

Definition at line 3428 of file socket.c.

References INSIST, ISC_LINK_LINKED, ISC_LIST_DEQUEUE, and isc_task_sendanddetach().

Referenced by internal_connect(), and isc__socket_cancel().

static void free_socket ( isc__socket_t **  socketp  )  [static]

Definition at line 2384 of file socket.c.

References isc__socket::common, DESTROYLOCK, isc_socket::impmagic, INSIST, ISC_LINK_LINKED, ISC_LIST_EMPTY, isc_mem_put, isc__socket::lock, isc_socket::magic, isc__socket::manager, isc__socketmgr::mctx, and VALID_SOCKET.

Referenced by internal_accept(), isc__socket_accept(), isc__socket_cancel(), and socket_create().

static isc_result_t allocate_socket ( isc__socketmgr_t manager,
isc_sockettype_t  type,
isc__socket_t **  socketp 
) [static]

Definition at line 2245 of file socket.c.

Referenced by isc__socket_accept(), isc__socket_fdwatchcreate(), and socket_create().

static void destroy ( isc__socket_t **  sockp  )  [static]

Definition at line 2209 of file socket.c.

static void internal_accept ( isc_task_t me,
isc_event_t ev 
) [static]

Definition at line 3454 of file socket.c.

References accept, isc_socket_newconnev::address, CREATION, destroy(), isc__socketmgr::fdlock, FDLOCK_ID, isc__socketmgr::fds, isc__socketmgr::fdstate, free_socket(), inc_stats(), INSIST, isc__strerror(), ISC_EVENT_PTR, isc_lctx, ISC_LIST_APPEND, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_UNLINK, ISC_LOG_ERROR, isc_log_iwrite(), ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_SOCKET, ISC_MSG_ACCEPTEDCXN, ISC_MSG_ACCEPTLOCK, ISC_MSG_FAILED, ISC_MSG_TOOMANYFDS, isc_msgcat_get(), ISC_MSGSET_GENERAL, ISC_MSGSET_SOCKET, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_SOCKADDR_LEN_T, ISC_STRERRORSIZE, isc_task_sendanddetach(), isc__socketmgr::lock, isc__socket::lock, LOCK, make_nonblock(), MANAGED, isc__socket::manager, isc__socketmgr::maxsocks, NEWCONNSOCK, isc_socket_newconnev::newsocket, isc_socket_newconnev::result, select_poke(), SELECT_POKE_ACCEPT, setdscp(), socket_log(), SOFT_ERROR, STATID_ACCEPT, STATID_ACCEPTFAIL, STATID_ACTIVE, isc__socketmgr::stats, isc__socket::statsindex, TRACE, UNEXPECTED_ERROR, UNLOCK, UNUSED, use_min_mtu(), VALID_MANAGER, and VALID_SOCKET.

Referenced by dispatch_accept().

static void internal_connect ( isc_task_t me,
isc_event_t ev 
) [static]

Definition at line 5835 of file socket.c.

References destroy(), ERROR_MATCH, inc_stats(), INSIST, isc__strerror(), ISC_LIST_HEAD, ISC_R_ADDRNOTAVAIL, ISC_R_CONNECTIONRESET, ISC_R_CONNREFUSED, ISC_R_HOSTUNREACH, ISC_R_NETUNREACH, ISC_R_NOPERM, ISC_R_NORESOURCES, ISC_R_NOTCONNECTED, ISC_R_SUCCESS, ISC_R_TIMEDOUT, ISC_R_UNEXPECTED, isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, ISC_SOCKADDR_LEN_T, ISC_SOCKEVENT_INTW, ISC_STRERRORSIZE, isc__socket::lock, LOCK, isc__socket::manager, isc_socket_connev::result, select_poke(), SELECT_POKE_CONNECT, send_connectdone_event(), SOFT_ERROR, STATID_CONNECT, STATID_CONNECTFAIL, isc__socketmgr::stats, isc__socket::statsindex, UNEXPECTED_ERROR, UNLOCK, UNUSED, and VALID_SOCKET.

static void internal_recv ( isc_task_t me,
isc_event_t ev 
) [static]

Definition at line 3707 of file socket.c.

Referenced by dispatch_recv().

static void internal_send ( isc_task_t me,
isc_event_t ev 
) [static]

Definition at line 3772 of file socket.c.

static void internal_fdwatch_write ( isc_task_t me,
isc_event_t ev 
) [static]

Definition at line 3827 of file socket.c.

static void internal_fdwatch_read ( isc_task_t me,
isc_event_t ev 
) [static]

Definition at line 3868 of file socket.c.

Referenced by dispatch_recv().

static void process_cmsg ( isc__socket_t sock,
struct msghdr *  msg,
isc_socketevent_t dev 
) [static]

Definition at line 1288 of file socket.c.

References isc_socketevent::attributes, isc_socketevent::dscp, IN6_IS_ADDR_MULTICAST, in6_pktinfo::ipi6_addr, in6_pktinfo::ipi6_ifindex, ISC_MSG_IFRECEIVED, ISC_MSG_PROCESSCMSG, ISC_MSGSET_SOCKET, ISC_SOCKEVENTATTR_CTRUNC, ISC_SOCKEVENTATTR_DSCP, ISC_SOCKEVENTATTR_MULTICAST, ISC_SOCKEVENTATTR_PKTINFO, ISC_SOCKEVENTATTR_TIMESTAMP, ISC_SOCKEVENTATTR_TRUNC, isc_time::nanoseconds, isc_socketevent::pktinfo, isc_time::seconds, socket_log(), isc_socketevent::timestamp, TRACE, and UNUSED.

Referenced by doio_recv().

static void build_msghdr_send ( isc__socket_t sock,
isc_socketevent_t dev,
struct msghdr *  msg,
struct iovec *  iov,
size_t *  write_countp 
) [static]

Definition at line 1416 of file socket.c.

References isc_socketevent::address, AF_INET6, isc_socketevent::attributes, isc_region::base, buffer, isc_socketevent::bufferlist, cmsg_len(), cmsg_space(), isc_socketevent::dscp, INSIST, in6_pktinfo::ipi6_ifindex, isc__strerror(), isc_buffer_usedlength, isc_buffer_usedregion, ISC_BUFFER_VALID, isc_dscp_check_value, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_MSG_FAILED, ISC_MSG_SENDTODATA, isc_msgcat_get(), ISC_MSGSET_GENERAL, ISC_MSGSET_SOCKET, isc_sockettype_tcp, isc_sockettype_udp, ISC_SOCKEVENTATTR_DSCP, ISC_SOCKEVENTATTR_PKTINFO, ISC_STRERRORSIZE, isc_region::length, isc_sockaddr::length, MAXSCATTERGATHER_SEND, isc_socketevent::n, isc_socketevent::pktinfo, isc_socketevent::region, REQUIRE, isc_sockaddr::sa, socket_log(), TRACE, isc__socket::type, isc_sockaddr::type, UNEXPECTED_ERROR, and use_min_mtu().

Referenced by doio_send().

static void build_msghdr_recv ( isc__socket_t sock,
isc_socketevent_t dev,
struct msghdr *  msg,
struct iovec *  iov,
size_t *  read_countp 
) [static]

Definition at line 1633 of file socket.c.

References isc_socketevent::address, AF_INET6, isc_region::base, buffer, isc_socketevent::bufferlist, INSIST, isc_buffer_availablelength, isc_buffer_availableregion, ISC_BUFFER_VALID, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_sockettype_udp, isc_region::length, MAXSCATTERGATHER_RECV, isc_socketevent::n, isc_socketevent::region, REQUIRE, isc_sockaddr::sa, isc_sockaddr::sin, isc_sockaddr::sin6, isc_sockaddr::type, and isc__socket::type.

Referenced by doio_recv().

static void setdscp ( isc__socket_t sock,
isc_dscp_t  dscp 
) [static]

Definition at line 6189 of file socket.c.

Referenced by internal_accept().

isc_result_t isc__socket_open ( isc_socket_t sock0  ) 

The following are intended for internal use (indicated by "isc__" prefix) but are not declared as static, allowing direct access from unit tests etc.

Definition at line 3014 of file socket.c.

Referenced by isc_socket_open().

isc_result_t isc__socket_close ( isc_socket_t sock0  ) 

Definition at line 3203 of file socket.c.

Referenced by isc_socket_close().

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'. Events will be posted to 'task' and when dispatched 'action' will be called with 'arg' as the arg value. The new socket is returned in 'socketp'.

Definition at line 2991 of file socket.c.

References socket_create().

Referenced by isc_socket_create().

void isc__socket_attach ( isc_socket_t sock,
isc_socket_t **  socketp 
)

Definition at line 3163 of file socket.c.

References isc__socket::lock, LOCK, REQUIRE, UNLOCK, and VALID_SOCKET.

Referenced by isc_socket_attach().

void isc__socket_detach ( isc_socket_t **  socketp  ) 

Definition at line 3181 of file socket.c.

References destroy(), ISC_FALSE, ISC_TRUE, isc__socket::lock, LOCK, REQUIRE, UNLOCK, and VALID_SOCKET.

Referenced by isc_socket_detach().

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 4943 of file socket.c.

Referenced by isc_socket_recvv().

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 4998 of file socket.c.

Referenced by isc_socket_recv().

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 5023 of file socket.c.

Referenced by isc_socket_recv2().

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

Definition at line 5145 of file socket.c.

Referenced by isc_socket_send().

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 
)

Definition at line 5156 of file socket.c.

Referenced by isc_socket_sendto().

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

Definition at line 5185 of file socket.c.

Referenced by isc_socket_sendv().

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 
)

Definition at line 5193 of file socket.c.

Referenced by 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 
)

Definition at line 5202 of file socket.c.

Referenced by isc_socket_sendtov2().

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 
)

Definition at line 5244 of file socket.c.

Referenced by isc_socket_sendto2().

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

void isc__socket_cleanunix ( isc_sockaddr_t sockaddr,
isc_boolean_t  active 
)

Definition at line 5267 of file socket.c.

Referenced by isc_socket_cleanunix().

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

Definition at line 5397 of file socket.c.

Referenced by isc_socket_permunix().

isc_result_t isc__socket_bind ( isc_socket_t sock,
isc_sockaddr_t sockaddr,
unsigned int  options 
)

Definition at line 5451 of file socket.c.

Referenced by isc_socket_bind().

isc_result_t isc__socket_filter ( isc_socket_t sock,
const char *  filter 
)

Definition at line 5527 of file socket.c.

References CREATION, isc__strerror(), ISC_MSG_FILTER, ISC_MSGSET_SOCKET, ISC_R_FAILURE, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, ISC_STRERRORSIZE, REQUIRE, socket_log(), UNUSED, and VALID_SOCKET.

Referenced by isc_socket_filter().

isc_result_t isc__socket_listen ( isc_socket_t sock,
unsigned int  backlog 
)

Definition at line 5567 of file socket.c.

References isc__strerror(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_sockettype_tcp, isc_sockettype_unix, ISC_STRERRORSIZE, listen, isc__socket::lock, LOCK, REQUIRE, isc__socket::type, UNEXPECTED_ERROR, UNLOCK, and VALID_SOCKET.

Referenced by isc_socket_listen().

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

Definition at line 5602 of file socket.c.

References allocate_socket(), free_socket(), isc_event_allocate(), isc_event_free(), ISC_EVENT_PTR, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_EMPTY, ISC_LIST_ENQUEUE, ISC_R_NOMEMORY, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, ISC_SOCKEVENT_NEWCONN, isc_task_attach(), isc_task_detach(), isc_task_exiting(), ISC_TRUE, isc__socket::lock, LOCK, isc__socket::manager, isc__socketmgr::mctx, isc_socket_newconnev::newsocket, REQUIRE, select_poke(), SELECT_POKE_ACCEPT, isc__socket::statsindex, isc__socket::type, UNLOCK, VALID_MANAGER, and VALID_SOCKET.

Referenced by isc_socket_accept().

isc_result_t isc__socket_connect ( isc_socket_t sock,
isc_sockaddr_t addr,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Definition at line 5677 of file socket.c.

Referenced by isc_socket_connect().

isc_result_t isc__socket_getpeername ( isc_socket_t sock,
isc_sockaddr_t addressp 
)

Definition at line 5952 of file socket.c.

Referenced by isc_socket_getpeername().

isc_result_t isc__socket_getsockname ( isc_socket_t sock,
isc_sockaddr_t addressp 
)

Definition at line 5974 of file socket.c.

Referenced by isc_socket_getsockname().

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

Definition at line 6013 of file socket.c.

References free_socket(), INSIST, ISC_EVENT_PTR, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LIST_UNLINK, ISC_R_CANCELED, ISC_SOCKCANCEL_ACCEPT, ISC_SOCKCANCEL_CONNECT, ISC_SOCKCANCEL_RECV, ISC_SOCKCANCEL_SEND, isc_task_sendanddetach(), isc__socket::lock, LOCK, NEWCONNSOCK, isc_socket_newconnev::newsocket, REQUIRE, isc_socket_connev::result, isc_socket_newconnev::result, isc_socketevent::result, send_connectdone_event(), send_recvdone_event(), send_senddone_event(), and VALID_SOCKET.

Referenced by isc_socket_cancel().

isc_sockettype_t isc__socket_gettype ( isc_socket_t sock  ) 

Definition at line 6133 of file socket.c.

Referenced by isc_socket_gettype().

isc_boolean_t isc__socket_isbound ( isc_socket_t sock  ) 

void isc__socket_ipv6only ( isc_socket_t sock,
isc_boolean_t  yes 
)

Definition at line 6156 of file socket.c.

Referenced by isc_socket_ipv6only().

void isc__socket_dscp ( isc_socket_t sock,
isc_dscp_t  dscp 
)

Definition at line 6233 of file socket.c.

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 
)

Definition at line 3064 of file socket.c.

References allocate_socket(), isc__socket::common, CREATION, isc__socketmgr::fdlock, FDLOCK_ID, isc__socketmgr::fds, isc__socketmgr::fdstate, ISC_LIST_APPEND, ISC_MSG_CREATED, ISC_MSGSET_SOCKET, ISC_R_SUCCESS, isc_sockettype_fdwatch, ISC_SOCKFDWATCH_READ, ISC_SOCKFDWATCH_WRITE, isc__socketmgr::lock, LOCK, MANAGED, isc__socket::manager, isc_socket::methods, REQUIRE, select_poke(), SELECT_POKE_READ, SELECT_POKE_WRITE, socket_log(), socketmethods, isc__socket::statsindex, UNLOCK, and VALID_MANAGER.

Referenced by isc_socket_fdwatchcreate().

isc_result_t isc__socket_fdwatchpoke ( isc_socket_t sock,
int  flags 
)

Definition at line 3129 of file socket.c.

References ISC_MSG_POKED, ISC_MSGSET_SOCKET, ISC_R_SUCCESS, ISC_SOCKFDWATCH_READ, ISC_SOCKFDWATCH_WRITE, isc__socket::lock, LOCK, isc__socket::manager, REQUIRE, select_poke(), SELECT_POKE_READ, SELECT_POKE_WRITE, socket_log(), TRACE, UNLOCK, and VALID_SOCKET.

Referenced by isc_socket_fdwatchpoke().

isc_result_t isc__socket_dup ( isc_socket_t sock,
isc_socket_t **  socketp 
)

Duplicate an existing socket. The new socket is returned in 'socketp'.

Definition at line 3002 of file socket.c.

References isc__socket::manager, REQUIRE, socket_create(), isc__socket::type, and VALID_SOCKET.

Referenced by isc_socket_dup().

int isc__socket_getfd ( isc_socket_t sock  ) 

Definition at line 6433 of file socket.c.

References isc__socketmgr_create(), and isc_socket_register().

Referenced by isc_socket_getfd().

isc_result_t isc__socketmgr_create ( isc_mem_t mctx,
isc_socketmgr_t **  managerp 
)

Definition at line 4558 of file socket.c.

Referenced by isc__socket_getfd(), and isc_socketmgr_create().

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

Definition at line 4563 of file socket.c.

Referenced by isc_socketmgr_create2().

isc_result_t isc_socketmgr_getmaxsockets ( isc_socketmgr_t manager0,
unsigned int *  nsockp 
)

void isc_socketmgr_setstats ( isc_socketmgr_t manager0,
isc_stats_t stats 
)

void isc__socketmgr_destroy ( isc_socketmgr_t **  managerp  ) 

Definition at line 4765 of file socket.c.

Referenced by isc_socketmgr_destroy().

void isc__socket_setname ( isc_socket_t socket0,
const char *  name,
void *  tag 
)

Definition at line 6397 of file socket.c.

const char * isc__socket_getname ( isc_socket_t socket0  ) 

Definition at line 6414 of file socket.c.

void * isc__socket_gettag ( isc_socket_t socket0  ) 

Definition at line 6421 of file socket.c.

static void static void socket_log ( isc__socket_t sock,
isc_sockaddr_t address,
isc_logcategory_t category,
isc_logmodule_t module,
int  level,
isc_msgcat_t msgcat,
int  msgset,
int  message,
const char *  fmt,
  ... 
) [static]

Definition at line 816 of file socket.c.

References isc_lctx, isc_log_iwrite(), isc_log_wouldlog(), isc_sockaddr_format(), and ISC_SOCKADDR_FORMATSIZE.

Referenced by build_msghdr_send(), dispatch_recv(), doio_recv(), internal_accept(), isc__socket_fdwatchcreate(), isc__socket_fdwatchpoke(), isc__socket_filter(), process_cmsg(), and socket_create().

static void inc_stats ( isc_stats_t stats,
isc_statscounter_t  counterid 
) [inline, static]

Increment socket-related statistics counters.

Definition at line 880 of file socket.c.

References isc_stats_increment(), and REQUIRE.

Referenced by dns_dispatch_addresponse3(), dns_zone_notifyreceive(), doio_recv(), doio_send(), fctx_cancelquery(), fctx_create(), fctx_query(), fctx_timeout(), fctx_try(), fetch_callback(), fetch_name(), forward_action(), forward_callback(), got_transfer_quota(), internal_accept(), internal_connect(), notify_send_toaddr(), ns_update_start(), ns_xfr_start(), process_opt(), query_dns64(), query_error(), query_find(), query_next(), query_recurse(), query_send(), resquery_response(), resquery_send(), soa_query(), socketclose(), udp_recv(), updatedone_action(), valcreate(), xfrout_senddone(), and zone_xfrdone().

static void dec_stats ( isc_stats_t stats,
isc_statscounter_t  counterid 
) [inline, static]

Decrement socket-related statistics counters.

Definition at line 891 of file socket.c.

References isc_stats_decrement(), and REQUIRE.

Referenced by dns_dispatch_addresponse3(), dns_dispatch_removeresponse(), fctx_unlink(), and socketclose().

static isc_result_t watch_fd ( isc__socketmgr_t manager,
int  fd,
int  msg 
) [inline, static]

Definition at line 899 of file socket.c.

References isc__socketmgr::fdlock, FDLOCK_ID, isc__errno2result, ISC_R_SUCCESS, isc__socketmgr::lock, LOCK, SELECT_POKE_READ, SELECT_POKE_WRITE, and UNLOCK.

Referenced by setup_watcher(), and wakeup_socket().

static isc_result_t unwatch_fd ( isc__socketmgr_t manager,
int  fd,
int  msg 
) [inline, static]

Definition at line 967 of file socket.c.

References isc__socketmgr::fdlock, FDLOCK_ID, isc__errno2result, isc__strerror(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, isc__socketmgr::lock, LOCK, SELECT_POKE_READ, SELECT_POKE_WRITE, UNEXPECTED_ERROR, and UNLOCK.

Referenced by process_fd(), socketclose(), and wakeup_socket().

static void wakeup_socket ( isc__socketmgr_t manager,
int  fd,
int  msg 
) [static]

Definition at line 1054 of file socket.c.

References CLOSE_PENDING, CLOSED, isc__socketmgr::fdlock, FDLOCK_ID, isc__socketmgr::fdstate, INSIST, isc_lctx, ISC_LOG_ERROR, isc_log_write(), ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_SOCKET, ISC_R_SUCCESS, isc_result_totext(), LOCK, MANAGED, isc__socketmgr::maxsocks, SELECT_POKE_CLOSE, SELECT_POKE_READ, SELECT_POKE_WRITE, UNLOCK, unwatch_fd(), and watch_fd().

Referenced by select_poke().

static void select_poke ( isc__socketmgr_t manager,
int  fd,
int  msg 
) [static]

Definition at line 1189 of file socket.c.

References SELECT_POKE_SHUTDOWN, and wakeup_socket().

Referenced by internal_accept(), internal_connect(), isc__socket_accept(), isc__socket_fdwatchcreate(), isc__socket_fdwatchpoke(), and socketclose().

static isc_result_t make_nonblock ( int  fd  )  [static]

Definition at line 1202 of file socket.c.

References isc__strerror(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, and UNEXPECTED_ERROR.

static void set_dev_address ( isc_sockaddr_t address,
isc__socket_t sock,
isc_socketevent_t dev 
) [static]

Definition at line 1752 of file socket.c.

static void destroy_socketevent ( isc_event_t event  )  [static]

Definition at line 1767 of file socket.c.

static isc_socketevent_t* allocate_socketevent ( isc_mem_t mctx,
void *  sender,
isc_eventtype_t  eventtype,
isc_taskaction_t  action,
void *  arg 
) [static]

Definition at line 1776 of file socket.c.

static int doio_recv ( isc__socket_t sock,
isc_socketevent_t dev 
) [static]

Definition at line 1830 of file socket.c.

References isc_socketevent::address, ALWAYS_HARD, isc_socketevent::attributes, buffer, isc_socketevent::bufferlist, build_msghdr_recv(), DOIO_EOF, DOIO_HARD, DOIO_SOFT, DOIO_SUCCESS, inc_stats(), INSIST, IOEVENT, IOEVENT_LEVEL, isc__errno2result, isc__strerror(), isc_buffer_add, isc_buffer_availablelength, ISC_BUFFER_VALID, isc_lctx, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_log_wouldlog(), ISC_MSG_DOIORECV, ISC_MSG_PKTRECV, ISC_MSG_ZEROPORT, ISC_MSGSET_SOCKET, ISC_R_ADDRNOTAVAIL, ISC_R_CONNREFUSED, ISC_R_HOSTDOWN, ISC_R_HOSTUNREACH, ISC_R_NETUNREACH, ISC_R_NORESOURCES, ISC_R_SUCCESS, isc_sockaddr_getport(), isc_sockettype_fdwatch, isc_sockettype_raw, isc_sockettype_tcp, isc_sockettype_udp, isc_sockettype_unix, ISC_SOCKEVENTATTR_TRUNC, ISC_STRERRORSIZE, isc_sockaddr::length, isc__socket::manager, isc_socketevent::minimum, isc_socketevent::n, POST, process_cmsg(), REQUIRE, isc_socketevent::result, socket_log(), SOFT_ERROR, SOFT_OR_HARD, STATID_RECVFAIL, isc__socketmgr::stats, isc__socket::statsindex, and isc__socket::type.

static int doio_send ( isc__socket_t sock,
isc_socketevent_t dev 
) [static]

Definition at line 2025 of file socket.c.

References isc_socketevent::address, ALWAYS_HARD, build_msghdr_send(), DOIO_HARD, DOIO_SOFT, DOIO_SUCCESS, inc_stats(), isc__errno2result, isc__strerror(), ISC_MSG_RETURNED, isc_msgcat_get(), ISC_MSGSET_GENERAL, ISC_R_ADDRNOTAVAIL, ISC_R_CONNECTIONRESET, ISC_R_CONNREFUSED, ISC_R_HOSTUNREACH, ISC_R_NETUNREACH, ISC_R_NOPERM, ISC_R_NORESOURCES, ISC_R_NOTCONNECTED, ISC_R_SUCCESS, isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_sockettype_udp, ISC_STRERRORSIZE, isc__socket::manager, isc_socketevent::n, NRETRIES, isc_socketevent::result, SOFT_ERROR, SOFT_OR_HARD, STATID_SENDFAIL, isc__socketmgr::stats, isc__socket::statsindex, isc__socket::type, and UNEXPECTED_ERROR.

static void socketclose ( isc__socketmgr_t manager,
isc__socket_t sock,
int  fd 
) [static]

Definition at line 2141 of file socket.c.

References CLOSE_PENDING, CLOSED, dec_stats(), isc__socketmgr::fdlock, FDLOCK_ID, isc__socketmgr::fds, isc__socketmgr::fdstate, inc_stats(), isc_sockettype_fdwatch, isc__socketmgr::lock, LOCK, MANAGED, select_poke(), SELECT_POKE_CLOSE, SELECT_POKE_READ, SELECT_POKE_WRITE, STATID_ACTIVE, STATID_CLOSE, isc__socketmgr::stats, isc__socket::statsindex, isc__socket::type, UNLOCK, and unwatch_fd().

static void use_min_mtu ( isc__socket_t sock  )  [static]

Definition at line 2510 of file socket.c.

Referenced by build_msghdr_send(), and internal_accept().

static isc_result_t opensocket ( isc__socketmgr_t manager,
isc__socket_t sock,
isc__socket_t dup_socket 
) [static]

Definition at line 2535 of file socket.c.

Referenced by socket_create().

static void dispatch_recv ( isc__socket_t sock  )  [static]

Definition at line 3254 of file socket.c.

References EVENT, INSIST, internal_fdwatch_read(), internal_recv(), ISC_LIST_HEAD, isc_sockettype_fdwatch, socket_log(), and isc__socket::type.

Referenced by process_fd().

static void dispatch_send ( isc__socket_t sock  )  [static]

Definition at line 3288 of file socket.c.

Referenced by process_fd().

static void dispatch_accept ( isc__socket_t sock  )  [static]

Definition at line 3325 of file socket.c.

References INSIST, internal_accept(), and ISC_LIST_HEAD.

Referenced by process_fd().

static void dispatch_connect ( isc__socket_t sock  )  [static]

Definition at line 3351 of file socket.c.

Referenced by process_fd().

static void process_fd ( isc__socketmgr_t manager,
int  fd,
isc_boolean_t  readable,
isc_boolean_t  writeable 
) [static]

Definition at line 3913 of file socket.c.

References CLOSE_PENDING, dispatch_accept(), dispatch_connect(), dispatch_recv(), dispatch_send(), isc__socketmgr::fdlock, FDLOCK_ID, isc__socketmgr::fds, isc__socketmgr::fdstate, ISC_FALSE, ISC_TRUE, isc__socket::lock, LOCK, SELECT_POKE_READ, SELECT_POKE_WRITE, SOCK_DEAD, UNLOCK, and unwatch_fd().

static void process_fds ( isc__socketmgr_t manager,
int  maxfd,
fd_set *  readfds,
fd_set *  writefds 
) [static]

Definition at line 4108 of file socket.c.

void isc__socketmgr_setreserved ( isc_socketmgr_t manager0,
isc_uint32_t  reserved 
)

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 manager0,
int  maxudp 
)

Test interface. Drop UDP packet > 'maxudp'.

Definition at line 4334 of file socket.c.

Referenced by create_managers().

static isc_result_t setup_watcher ( isc_mem_t mctx,
isc__socketmgr_t manager 
) [static]

Definition at line 4347 of file socket.c.

References isc__socketmgr::fd_bufsize, isc__errno2result, isc__strerror(), isc_mem_get, isc_mem_put, ISC_MSG_FAILED, isc_msgcat_get(), ISC_MSGSET_GENERAL, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_resource_getcurlimit(), isc_resource_openfiles, ISC_STRERRORSIZE, isc__socketmgr::maxsocks, SELECT_POKE_READ, UNEXPECTED_ERROR, UNUSED, and watch_fd().

static void cleanup_watcher ( isc_mem_t mctx,
isc__socketmgr_t manager 
) [static]

Definition at line 4518 of file socket.c.

static isc_result_t socket_recv ( isc__socket_t sock,
isc_socketevent_t dev,
isc_task_t task,
unsigned int  flags 
) [static]

Definition at line 4871 of file socket.c.

static isc_result_t socket_send ( isc__socket_t sock,
isc_socketevent_t dev,
isc_task_t task,
isc_sockaddr_t address,
struct in6_pktinfo pktinfo,
unsigned int  flags 
) [static]

Definition at line 5053 of file socket.c.

int isc__socketmgr_waitevents ( isc_socketmgr_t manager0,
struct timeval *  tvp,
isc_socketwait_t **  swaitp 
)

Definition at line 6274 of file socket.c.

References isc__socketmgr::fd_bufsize, ISC_R_SUCCESS, isc_resource_getcurlimit(), isc_resource_openfiles, isc_socketwait::maxfd, isc_socketwait::readset, REQUIRE, timeout, and isc_socketwait::writeset.

Referenced by evloop(), and waitbody().

isc_result_t isc__socketmgr_dispatch ( isc_socketmgr_t manager0,
isc_socketwait_t swait 
)

Definition at line 6374 of file socket.c.

Referenced by evloop(), and waitbody().

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().


Variable Documentation

int isc_dscp_check_value = -1

Definition at line 142 of file socket.c.

Referenced by build_msghdr_send(), and parse_command_line().

isc__socketmgr_t* socketmgr = NULL [static]

Definition at line 452 of file socket.c.

isc_socketmethods_t methods

Definition at line 626 of file socket.c.

void* recvv

The following are defined just for avoiding unused static functions.

Definition at line 631 of file socket.c.

void * send

Definition at line 631 of file socket.c.

Referenced by render_xsl().

void * sendv

Definition at line 631 of file socket.c.

void * sendto2

Definition at line 631 of file socket.c.

void * cleanunix

Definition at line 631 of file socket.c.

void * permunix

Definition at line 631 of file socket.c.

void * filter

Definition at line 631 of file socket.c.

void * listen

Definition at line 631 of file socket.c.

Referenced by isc__socket_listen().

void * accept

Definition at line 631 of file socket.c.

Referenced by internal_accept().

void * getpeername

Definition at line 631 of file socket.c.

void * isbound

Definition at line 631 of file socket.c.

struct { ... } socketmethods [static]

Referenced by isc__socket_fdwatchcreate(), and socket_create().

isc_socketmgrmethods_t socketmgrmethods [static]

Initial value:

Definition at line 660 of file socket.c.

const isc_statscounter_t udp4statsindex[] [static]

Initial value:

Definition at line 692 of file socket.c.

const isc_statscounter_t udp6statsindex[] [static]

Initial value:

Definition at line 705 of file socket.c.

const isc_statscounter_t tcp4statsindex[] [static]

Initial value:

Definition at line 718 of file socket.c.

const isc_statscounter_t tcp6statsindex[] [static]

Initial value:

Definition at line 731 of file socket.c.

const isc_statscounter_t unixstatsindex[] [static]

Initial value:

Definition at line 744 of file socket.c.

const isc_statscounter_t fdwatchstatsindex[] [static]

Initial value:

Definition at line 757 of file socket.c.

const isc_statscounter_t rawstatsindex[] [static]

Initial value:

Definition at line 770 of file socket.c.

isc_socketwait_t swait_private [static]

Definition at line 6271 of file socket.c.


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