00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef NETWORK_IO_H
00018 #define NETWORK_IO_H
00019
00020 #include "apr.h"
00021 #include "apr_private.h"
00022 #include "apr_network_io.h"
00023 #include "apr_errno.h"
00024 #include "apr_general.h"
00025 #include "apr_lib.h"
00026 #ifndef WAITIO_USES_POLL
00027 #include "apr_poll.h"
00028 #endif
00029
00030
00031 #if APR_HAVE_SYS_TYPES_H
00032 #include <sys/types.h>
00033 #endif
00034 #if APR_HAVE_SYS_UIO_H
00035 #include <sys/uio.h>
00036 #endif
00037 #ifdef HAVE_SYS_SELECT_H
00038 #include <sys/select.h>
00039 #endif
00040 #if APR_HAVE_ERRNO_H
00041 #include <errno.h>
00042 #endif
00043 #if APR_HAVE_SYS_TIME_H
00044 #include <sys/time.h>
00045 #endif
00046 #if APR_HAVE_UNISTD_H
00047 #include <unistd.h>
00048 #endif
00049 #if APR_HAVE_STRING_H
00050 #include <string.h>
00051 #endif
00052 #if APR_HAVE_NETINET_TCP_H
00053 #include <netinet/tcp.h>
00054 #endif
00055 #if APR_HAVE_NETINET_SCTP_UIO_H
00056 #include <netinet/sctp_uio.h>
00057 #endif
00058 #if APR_HAVE_NETINET_SCTP_H
00059 #include <netinet/sctp.h>
00060 #endif
00061 #if APR_HAVE_NETINET_IN_H
00062 #include <netinet/in.h>
00063 #endif
00064 #if APR_HAVE_ARPA_INET_H
00065 #include <arpa/inet.h>
00066 #endif
00067 #if APR_HAVE_SYS_SOCKET_H
00068 #include <sys/socket.h>
00069 #endif
00070 #if APR_HAVE_SYS_SOCKIO_H
00071 #include <sys/sockio.h>
00072 #endif
00073 #if APR_HAVE_NETDB_H
00074 #include <netdb.h>
00075 #endif
00076 #if APR_HAVE_FCNTL_H
00077 #include <fcntl.h>
00078 #endif
00079 #if APR_HAVE_SYS_SENDFILE_H
00080 #include <sys/sendfile.h>
00081 #endif
00082 #if APR_HAVE_SYS_IOCTL_H
00083 #include <sys/ioctl.h>
00084 #endif
00085
00086
00087 #ifndef HAVE_POLLIN
00088 #define POLLIN 1
00089 #define POLLPRI 2
00090 #define POLLOUT 4
00091 #define POLLERR 8
00092 #define POLLHUP 16
00093 #define POLLNVAL 32
00094 #endif
00095
00096 typedef struct sock_userdata_t sock_userdata_t;
00097 struct sock_userdata_t {
00098 sock_userdata_t *next;
00099 const char *key;
00100 void *data;
00101 };
00102
00103 struct apr_socket_t {
00104 apr_pool_t *pool;
00105 int socketdes;
00106 int type;
00107 int protocol;
00108 apr_sockaddr_t *local_addr;
00109 apr_sockaddr_t *remote_addr;
00110 apr_interval_time_t timeout;
00111 #ifndef HAVE_POLL
00112 int connected;
00113 #endif
00114 int local_port_unknown;
00115 int local_interface_unknown;
00116 int remote_addr_unknown;
00117 apr_int32_t options;
00118 apr_int32_t inherit;
00119 sock_userdata_t *userdata;
00120 #ifndef WAITIO_USES_POLL
00121
00122 apr_pollset_t *pollset;
00123 #endif
00124 };
00125
00126 const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size);
00127 int apr_inet_pton(int af, const char *src, void *dst);
00128 void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t);
00129
00130 #define apr_is_option_set(skt, option) \
00131 (((skt)->options & (option)) == (option))
00132
00133 #define apr_set_option(skt, option, on) \
00134 do { \
00135 if (on) \
00136 (skt)->options |= (option); \
00137 else \
00138 (skt)->options &= ~(option); \
00139 } while (0)
00140
00141 #endif
00142