Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

apr_network_io.h

Go to the documentation of this file.
00001 /* Copyright 2000-2004 The Apache Software Foundation 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 00016 #ifndef APR_NETWORK_IO_H 00017 #define APR_NETWORK_IO_H 00018 00023 #include "apr.h" 00024 #include "apr_pools.h" 00025 #include "apr_file_io.h" 00026 #include "apr_errno.h" 00027 #include "apr_inherit.h" 00028 00029 #if APR_HAVE_NETINET_IN_H 00030 #include <netinet/in.h> 00031 #endif 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif /* __cplusplus */ 00036 00043 #ifndef APR_MAX_SECS_TO_LINGER 00044 00045 #define APR_MAX_SECS_TO_LINGER 30 00046 #endif 00047 00048 #ifndef MAX_SECS_TO_LINGER 00049 00050 #define MAX_SECS_TO_LINGER APR_MAX_SECS_TO_LINGER 00051 #endif 00052 00053 #ifndef APRMAXHOSTLEN 00054 00055 #define APRMAXHOSTLEN 256 00056 #endif 00057 00058 #ifndef APR_ANYADDR 00059 00060 #define APR_ANYADDR "0.0.0.0" 00061 #endif 00062 00067 #define APR_SO_LINGER 1 00068 #define APR_SO_KEEPALIVE 2 00069 #define APR_SO_DEBUG 4 00070 #define APR_SO_NONBLOCK 8 00071 #define APR_SO_REUSEADDR 16 00072 #define APR_SO_TIMEOUT 32 00073 #define APR_SO_SNDBUF 64 00074 #define APR_SO_RCVBUF 128 00075 #define APR_SO_DISCONNECTED 256 00076 #define APR_TCP_NODELAY 512 00079 #define APR_TCP_NOPUSH 1024 00080 #define APR_RESET_NODELAY 2048 00086 #define APR_INCOMPLETE_READ 4096 00097 #define APR_INCOMPLETE_WRITE 8192 00100 #define APR_IPV6_V6ONLY 16384 00107 typedef enum { 00108 APR_SHUTDOWN_READ, 00109 APR_SHUTDOWN_WRITE, 00110 APR_SHUTDOWN_READWRITE 00111 } apr_shutdown_how_e; 00112 00113 #define APR_IPV4_ADDR_OK 0x01 00114 #define APR_IPV6_ADDR_OK 0x02 00116 #if (!APR_HAVE_IN_ADDR) 00117 00121 struct in_addr { 00122 apr_uint32_t s_addr; 00123 }; 00124 #endif 00125 00131 #define APR_INET AF_INET 00132 00135 #ifdef AF_UNSPEC 00136 #define APR_UNSPEC AF_UNSPEC 00137 #else 00138 #define APR_UNSPEC 0 00139 #endif 00140 #if APR_HAVE_IPV6 00141 #define APR_INET6 AF_INET6 00142 #endif 00143 00148 #define APR_PROTO_TCP 6 00149 #define APR_PROTO_UDP 17 00150 #define APR_PROTO_SCTP 132 00156 typedef enum { 00157 APR_LOCAL, 00158 APR_REMOTE 00159 } apr_interface_e; 00160 00166 #if APR_HAVE_INET_ADDR 00167 #define apr_inet_addr inet_addr 00168 #elif APR_HAVE_INET_NETWORK /* only DGUX, as far as I know */ 00169 00173 #define apr_inet_addr inet_network 00174 #endif 00175 00177 typedef struct apr_socket_t apr_socket_t; 00181 typedef struct apr_hdtr_t apr_hdtr_t; 00183 typedef struct in_addr apr_in_addr_t; 00185 typedef struct apr_ipsubnet_t apr_ipsubnet_t; 00186 00188 typedef apr_uint16_t apr_port_t; 00189 00193 typedef struct apr_sockaddr_t apr_sockaddr_t; 00197 struct apr_sockaddr_t { 00199 apr_pool_t *pool; 00201 char *hostname; 00203 char *servname; 00205 apr_port_t port; 00207 apr_int32_t family; 00209 union { 00211 struct sockaddr_in sin; 00212 #if APR_HAVE_IPV6 00213 00214 struct sockaddr_in6 sin6; 00215 #endif 00216 } sa; 00218 apr_socklen_t salen; 00220 int ipaddr_len; 00223 int addr_str_len; 00226 void *ipaddr_ptr; 00229 apr_sockaddr_t *next; 00230 }; 00231 00232 #if APR_HAS_SENDFILE 00233 00238 #define APR_SENDFILE_DISCONNECT_SOCKET 1 00239 #endif 00240 00242 struct apr_hdtr_t { 00244 struct iovec* headers; 00246 int numheaders; 00248 struct iovec* trailers; 00250 int numtrailers; 00251 }; 00252 00253 /* function definitions */ 00254 00264 APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, 00265 int family, int type, 00266 apr_pool_t *cont); 00267 00278 APR_DECLARE(apr_status_t) apr_socket_create_ex(apr_socket_t **new_sock, 00279 int family, int type, 00280 int protocol, 00281 apr_pool_t *cont); 00282 00296 APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, 00297 apr_shutdown_how_e how); 00298 00300 APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket, 00301 apr_shutdown_how_e how); 00302 00307 APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket); 00308 00316 APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, 00317 apr_sockaddr_t *sa); 00318 00320 APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa); 00321 00329 APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, 00330 apr_int32_t backlog); 00331 00333 APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog); 00334 00343 APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, 00344 apr_socket_t *sock, 00345 apr_pool_t *connection_pool); 00346 00348 APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock, 00349 apr_socket_t *sock, 00350 apr_pool_t *connection_pool); 00351 00360 APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, 00361 apr_sockaddr_t *sa); 00362 00364 APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa); 00365 00389 APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, 00390 const char *hostname, 00391 apr_int32_t family, 00392 apr_port_t port, 00393 apr_int32_t flags, 00394 apr_pool_t *p); 00395 00402 APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, 00403 apr_sockaddr_t *sa, 00404 apr_int32_t flags); 00405 00436 APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, 00437 char **scope_id, 00438 apr_port_t *port, 00439 const char *str, 00440 apr_pool_t *p); 00441 00450 APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont); 00451 00458 APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, 00459 apr_socket_t *sock); 00460 00468 APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, 00469 const char *key, 00470 apr_status_t (*cleanup)(void*)); 00471 00488 APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, 00489 apr_size_t *len); 00490 00492 APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf, 00493 apr_size_t *len); 00494 00512 APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, 00513 const struct iovec *vec, 00514 apr_int32_t nvec, apr_size_t *len); 00515 00517 APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock, 00518 const struct iovec *vec, 00519 apr_int32_t nvec, apr_size_t *len); 00520 00528 APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, 00529 apr_sockaddr_t *where, 00530 apr_int32_t flags, const char *buf, 00531 apr_size_t *len); 00532 00534 APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where, 00535 apr_int32_t flags, const char *buf, 00536 apr_size_t *len); 00537 00546 APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, 00547 apr_socket_t *sock, 00548 apr_int32_t flags, char *buf, 00549 apr_size_t *len); 00550 00552 APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, 00553 apr_int32_t flags, char *buf, 00554 apr_size_t *len); 00555 00556 #if APR_HAS_SENDFILE || defined(DOXYGEN) 00557 00573 APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, 00574 apr_file_t *file, 00575 apr_hdtr_t *hdtr, 00576 apr_off_t *offset, 00577 apr_size_t *len, 00578 apr_int32_t flags); 00579 00581 APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file, 00582 apr_hdtr_t *hdtr, apr_off_t *offset, 00583 apr_size_t *len, apr_int32_t flags); 00584 00585 #endif /* APR_HAS_SENDFILE */ 00586 00605 APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, 00606 char *buf, apr_size_t *len); 00607 00609 APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock, 00610 char *buf, apr_size_t *len); 00611 00629 APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, 00630 apr_int32_t opt, apr_int32_t on); 00631 00633 APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock, 00634 apr_int32_t opt, apr_int32_t on); 00635 00647 APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, 00648 apr_interval_time_t t); 00649 00669 APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, 00670 apr_int32_t opt, apr_int32_t *on); 00671 00673 APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock, 00674 apr_int32_t opt, apr_int32_t *on); 00675 00681 APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, 00682 apr_interval_time_t *t); 00683 00690 APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, 00691 int *atmark); 00692 00699 APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, 00700 apr_interface_e which, 00701 apr_socket_t *sock); 00702 00709 APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr, 00710 apr_port_t port); 00711 00718 APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port, 00719 apr_sockaddr_t *sockaddr); 00720 00728 APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr, 00729 const char *addr); 00730 00738 APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, 00739 apr_sockaddr_t *sockaddr); 00740 00751 APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, 00752 const apr_sockaddr_t *addr2); 00753 00754 00755 #if APR_FILES_AS_SOCKETS || defined(DOXYGEN) 00756 00767 APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock, 00768 apr_file_t *file); 00769 00770 #endif /* APR_FILES_AS_SOCKETS */ 00771 00777 APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, 00778 const char *servname); 00787 APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, 00788 const char *ipstr, 00789 const char *mask_or_numbits, 00790 apr_pool_t *p); 00791 00799 APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa); 00800 00801 #if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN) 00809 apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, 00810 char *args); 00811 #endif 00812 00818 APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, 00819 int *protocol); 00820 00824 APR_DECLARE_INHERIT_SET(socket); 00825 00827 APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt); 00828 00832 APR_DECLARE_INHERIT_UNSET(socket); 00833 00835 APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt); 00836 00839 #ifdef __cplusplus 00840 } 00841 #endif 00842 00843 #endif /* ! APR_NETWORK_IO_H */ 00844

Generated on Tue Aug 10 17:42:34 2004 for Apache Portable Runtime by doxygen 1.3.7