GME  13
apr_arch_networkio.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 /* System headers the network I/O library needs */
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 /* End System Headers */
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     /* if there is a timeout set, then this pollset is used */
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  /* ! NETWORK_IO_H */
00142