apr_network_io.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 APR_NETWORK_IO_H
00018 #define APR_NETWORK_IO_H
00019 
00024 #include "apr.h"
00025 #include "apr_pools.h"
00026 #include "apr_file_io.h"
00027 #include "apr_errno.h"
00028 #include "apr_inherit.h" 
00029 
00030 #if APR_HAVE_NETINET_IN_H
00031 #include <netinet/in.h>
00032 #endif
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif /* __cplusplus */
00037 
00044 #ifndef APR_MAX_SECS_TO_LINGER
00045 
00046 #define APR_MAX_SECS_TO_LINGER 30
00047 #endif
00048 
00049 #ifndef MAX_SECS_TO_LINGER
00050 
00051 #define MAX_SECS_TO_LINGER APR_MAX_SECS_TO_LINGER
00052 #endif
00053 
00054 #ifndef APRMAXHOSTLEN
00055 
00056 #define APRMAXHOSTLEN 256
00057 #endif
00058 
00059 #ifndef APR_ANYADDR
00060 
00061 #define APR_ANYADDR "0.0.0.0"
00062 #endif
00063 
00068 #define APR_SO_LINGER        1    
00069 #define APR_SO_KEEPALIVE     2    
00070 #define APR_SO_DEBUG         4    
00071 #define APR_SO_NONBLOCK      8    
00072 #define APR_SO_REUSEADDR     16   
00073 #define APR_SO_TIMEOUT       32   
00074 #define APR_SO_SNDBUF        64   
00075 #define APR_SO_RCVBUF        128  
00076 #define APR_SO_DISCONNECTED  256  
00077 #define APR_TCP_NODELAY      512  
00080 #define APR_TCP_NOPUSH       1024 
00081 #define APR_RESET_NODELAY    2048 
00087 #define APR_INCOMPLETE_READ 4096  
00098 #define APR_INCOMPLETE_WRITE 8192 
00101 #define APR_IPV6_V6ONLY     16384 
00108 typedef enum {
00109     APR_SHUTDOWN_READ,          
00110     APR_SHUTDOWN_WRITE,         
00111     APR_SHUTDOWN_READWRITE      
00112 } apr_shutdown_how_e;
00113 
00114 #define APR_IPV4_ADDR_OK  0x01  
00115 #define APR_IPV6_ADDR_OK  0x02  
00117 #if (!APR_HAVE_IN_ADDR)
00118 
00122 struct in_addr {
00123     apr_uint32_t  s_addr; 
00124 };
00125 #endif
00126 
00132 #define APR_INET     AF_INET
00133 
00136 #ifdef AF_UNSPEC
00137 #define APR_UNSPEC   AF_UNSPEC
00138 #else
00139 #define APR_UNSPEC   0
00140 #endif
00141 #if APR_HAVE_IPV6
00142 #define APR_INET6    AF_INET6
00143 #endif
00144 
00149 #define APR_PROTO_TCP       6   
00150 #define APR_PROTO_UDP      17   
00151 #define APR_PROTO_SCTP    132   
00157 typedef enum {
00158     APR_LOCAL,
00159     APR_REMOTE
00160 } apr_interface_e;
00161 
00167 #if APR_HAVE_INET_ADDR
00168 #define apr_inet_addr    inet_addr
00169 #elif APR_HAVE_INET_NETWORK        /* only DGUX, as far as I know */
00170 
00174 #define apr_inet_addr    inet_network
00175 #endif
00176 
00178 typedef struct apr_socket_t     apr_socket_t;
00182 typedef struct apr_hdtr_t       apr_hdtr_t;
00184 typedef struct in_addr          apr_in_addr_t;
00186 typedef struct apr_ipsubnet_t apr_ipsubnet_t;
00187 
00189 typedef apr_uint16_t            apr_port_t;
00190 
00194 typedef struct apr_sockaddr_t apr_sockaddr_t;
00198 struct apr_sockaddr_t {
00200     apr_pool_t *pool;
00202     char *hostname;
00204     char *servname;
00206     apr_port_t port;
00208     apr_int32_t family;
00210     union {
00212         struct sockaddr_in sin;
00213 #if APR_HAVE_IPV6
00214 
00215         struct sockaddr_in6 sin6;
00216 #endif
00217     } sa;
00219     apr_socklen_t salen;
00221     int ipaddr_len;
00224     int addr_str_len;
00227     void *ipaddr_ptr;
00230     apr_sockaddr_t *next;
00231 };
00232 
00233 #if APR_HAS_SENDFILE
00234 
00239 #define APR_SENDFILE_DISCONNECT_SOCKET      1
00240 #endif
00241 
00243 struct apr_hdtr_t {
00245     struct iovec* headers;
00247     int numheaders;
00249     struct iovec* trailers;
00251     int numtrailers;
00252 };
00253 
00254 /* function definitions */
00255 
00265 APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, 
00266                                             int family, int type,
00267                                             apr_pool_t *cont);
00268 
00279 APR_DECLARE(apr_status_t) apr_socket_create_ex(apr_socket_t **new_sock, 
00280                                                int family, int type,
00281                                                int protocol,
00282                                                apr_pool_t *cont);
00283 
00297 APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket,
00298                                               apr_shutdown_how_e how);
00299 
00301 APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket,
00302                                        apr_shutdown_how_e how);
00303 
00308 APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket);
00309 
00317 APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, 
00318                                           apr_sockaddr_t *sa);
00319 
00321 APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa);
00322 
00330 APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, 
00331                                             apr_int32_t backlog);
00332 
00334 APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog);
00335 
00344 APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, 
00345                                             apr_socket_t *sock,
00346                                             apr_pool_t *connection_pool);
00347 
00349 APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock, 
00350                                      apr_socket_t *sock,
00351                                      apr_pool_t *connection_pool);
00352 
00361 APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock,
00362                                              apr_sockaddr_t *sa);
00363 
00365 APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa);
00366 
00390 APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa,
00391                                           const char *hostname,
00392                                           apr_int32_t family,
00393                                           apr_port_t port,
00394                                           apr_int32_t flags,
00395                                           apr_pool_t *p);
00396 
00403 APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname,
00404                                           apr_sockaddr_t *sa,
00405                                           apr_int32_t flags);
00406 
00437 APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr,
00438                                               char **scope_id,
00439                                               apr_port_t *port,
00440                                               const char *str,
00441                                               apr_pool_t *p);
00442 
00451 APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont);
00452 
00459 APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
00460                                               apr_socket_t *sock);
00461 
00469 APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data,
00470                                               const char *key,
00471                                               apr_status_t (*cleanup)(void*));
00472 
00489 APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, 
00490                                           apr_size_t *len);
00491 
00493 APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf, 
00494                                    apr_size_t *len);
00495 
00513 APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, 
00514                                            const struct iovec *vec,
00515                                            apr_int32_t nvec, apr_size_t *len);
00516 
00518 APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock, 
00519                                     const struct iovec *vec,
00520                                     apr_int32_t nvec, apr_size_t *len);
00521 
00529 APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, 
00530                                             apr_sockaddr_t *where,
00531                                             apr_int32_t flags, const char *buf, 
00532                                             apr_size_t *len);
00533 
00535 APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
00536                                      apr_int32_t flags, const char *buf, 
00537                                      apr_size_t *len);
00538 
00547 APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, 
00548                                               apr_socket_t *sock,
00549                                               apr_int32_t flags, char *buf, 
00550                                               apr_size_t *len);
00551  
00553 APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
00554                                        apr_int32_t flags, char *buf, 
00555                                        apr_size_t *len);
00556 
00557 #if APR_HAS_SENDFILE || defined(DOXYGEN)
00558 
00574 APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, 
00575                                               apr_file_t *file,
00576                                               apr_hdtr_t *hdtr,
00577                                               apr_off_t *offset,
00578                                               apr_size_t *len,
00579                                               apr_int32_t flags);
00580 
00582 APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file,
00583                                        apr_hdtr_t *hdtr, apr_off_t *offset,
00584                                        apr_size_t *len, apr_int32_t flags);
00585 
00586 #endif /* APR_HAS_SENDFILE */
00587 
00606 APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, 
00607                                    char *buf, apr_size_t *len);
00608 
00610 APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock, 
00611                                    char *buf, apr_size_t *len);
00612 
00630 APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock,
00631                                              apr_int32_t opt, apr_int32_t on);
00632 
00634 APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock,
00635                                            apr_int32_t opt, apr_int32_t on);
00636 
00648 APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock,
00649                                                  apr_interval_time_t t);
00650 
00670 APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, 
00671                                              apr_int32_t opt, apr_int32_t *on);
00672 
00674 APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock, 
00675                                            apr_int32_t opt, apr_int32_t *on);
00676 
00682 APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, 
00683                                                  apr_interval_time_t *t);
00684 
00691 APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, 
00692                                             int *atmark);
00693 
00700 APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa,
00701                                               apr_interface_e which,
00702                                               apr_socket_t *sock);
00703  
00710 APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr,
00711                                                 apr_port_t port);
00712 
00719 APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port,
00720                                                 apr_sockaddr_t *sockaddr);
00721 
00729 APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr,
00730                                               const char *addr);
00731 
00739 APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, 
00740                                               apr_sockaddr_t *sockaddr);
00741 
00752 APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
00753                                     const apr_sockaddr_t *addr2);
00754 
00755 
00756 #if APR_FILES_AS_SOCKETS || defined(DOXYGEN)
00757 
00768 APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock,
00769                                                apr_file_t *file);
00770 
00771 #endif /* APR_FILES_AS_SOCKETS */
00772 
00778 APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, 
00779                                             const char *servname);
00788 APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, 
00789                                               const char *ipstr, 
00790                                               const char *mask_or_numbits, 
00791                                               apr_pool_t *p);
00792 
00800 APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa);
00801 
00802 #if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN)
00803 
00810 apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
00811                                       char *args);
00812 #endif
00813 
00819 APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock,
00820                                                   int *protocol);
00821 
00825 APR_DECLARE_INHERIT_SET(socket);
00826 
00828 APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);
00829 
00833 APR_DECLARE_INHERIT_UNSET(socket);
00834 
00836 APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);
00837 
00840 #ifdef __cplusplus
00841 }
00842 #endif
00843 
00844 #endif  /* ! APR_NETWORK_IO_H */
00845 

Generated on Mon Nov 26 11:47:26 2007 for Apache Portable Runtime by  doxygen 1.5.2