00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef APR_NETWORK_IO_H
00056 #define APR_NETWORK_IO_H
00057
00062 #include "apr.h"
00063 #include "apr_pools.h"
00064 #include "apr_file_io.h"
00065 #include "apr_errno.h"
00066 #include "apr_inherit.h"
00067
00068 #if APR_HAVE_NETINET_IN_H
00069 #include <netinet/in.h>
00070 #endif
00071
00072 #ifdef __cplusplus
00073 extern "C" {
00074 #endif
00075
00082 #ifndef APR_MAX_SECS_TO_LINGER
00083
00084 #define APR_MAX_SECS_TO_LINGER 30
00085 #endif
00086
00087 #ifndef MAX_SECS_TO_LINGER
00088
00089 #define MAX_SECS_TO_LINGER APR_MAX_SECS_TO_LINGER
00090 #endif
00091
00092 #ifndef APRMAXHOSTLEN
00093
00094 #define APRMAXHOSTLEN 256
00095 #endif
00096
00097 #ifndef APR_ANYADDR
00098
00099 #define APR_ANYADDR "0.0.0.0"
00100 #endif
00101
00106 #define APR_SO_LINGER 1
00107 #define APR_SO_KEEPALIVE 2
00108 #define APR_SO_DEBUG 4
00109 #define APR_SO_NONBLOCK 8
00110 #define APR_SO_REUSEADDR 16
00111 #define APR_SO_TIMEOUT 32
00112 #define APR_SO_SNDBUF 64
00113 #define APR_SO_RCVBUF 128
00114 #define APR_SO_DISCONNECTED 256
00115 #define APR_TCP_NODELAY 512
00118 #define APR_TCP_NOPUSH 1024
00119 #define APR_RESET_NODELAY 2048
00125 #define APR_INCOMPLETE_READ 4096
00136 #define APR_INCOMPLETE_WRITE 8192
00139 #define APR_IPV6_V6ONLY 16384
00146 typedef enum {
00147 APR_SHUTDOWN_READ,
00148 APR_SHUTDOWN_WRITE,
00149 APR_SHUTDOWN_READWRITE
00150 } apr_shutdown_how_e;
00151
00152 #define APR_IPV4_ADDR_OK 0x01
00153 #define APR_IPV6_ADDR_OK 0x02
00155 #if (!APR_HAVE_IN_ADDR)
00156
00160 struct in_addr {
00161 apr_uint32_t s_addr;
00162 };
00163 #endif
00164
00170 #define APR_INET AF_INET
00171
00174 #ifdef AF_UNSPEC
00175 #define APR_UNSPEC AF_UNSPEC
00176 #else
00177 #define APR_UNSPEC 0
00178 #endif
00179 #if APR_HAVE_IPV6
00180 #define APR_INET6 AF_INET6
00181 #endif
00182
00187 #define APR_PROTO_TCP 6
00188 #define APR_PROTO_UDP 17
00189 #define APR_PROTO_SCTP 132
00195 typedef enum {
00196 APR_LOCAL,
00197 APR_REMOTE
00198 } apr_interface_e;
00199
00205 #if APR_HAVE_INET_ADDR
00206 #define apr_inet_addr inet_addr
00207 #elif APR_HAVE_INET_NETWORK
00208
00212 #define apr_inet_addr inet_network
00213 #endif
00214
00216 typedef struct apr_socket_t apr_socket_t;
00220 typedef struct apr_hdtr_t apr_hdtr_t;
00222 typedef struct in_addr apr_in_addr_t;
00224 typedef struct apr_ipsubnet_t apr_ipsubnet_t;
00225
00227 typedef apr_uint16_t apr_port_t;
00228
00232 typedef struct apr_sockaddr_t apr_sockaddr_t;
00236 struct apr_sockaddr_t {
00238 apr_pool_t *pool;
00240 char *hostname;
00242 char *servname;
00244 apr_port_t port;
00246 apr_int32_t family;
00248 union {
00250 struct sockaddr_in sin;
00251 #if APR_HAVE_IPV6
00252
00253 struct sockaddr_in6 sin6;
00254 #endif
00255 } sa;
00257 apr_socklen_t salen;
00259 int ipaddr_len;
00262 int addr_str_len;
00265 void *ipaddr_ptr;
00268 apr_sockaddr_t *next;
00269 };
00270
00271 #if APR_HAS_SENDFILE
00272
00277 #define APR_SENDFILE_DISCONNECT_SOCKET 1
00278 #endif
00279
00281 struct apr_hdtr_t {
00283 struct iovec* headers;
00285 int numheaders;
00287 struct iovec* trailers;
00289 int numtrailers;
00290 };
00291
00292
00293
00303 APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock,
00304 int family, int type,
00305 apr_pool_t *cont);
00306
00317 APR_DECLARE(apr_status_t) apr_socket_create_ex(apr_socket_t **new_sock,
00318 int family, int type,
00319 int protocol,
00320 apr_pool_t *cont);
00321
00335 APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket,
00336 apr_shutdown_how_e how);
00337
00339 APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket,
00340 apr_shutdown_how_e how);
00341
00346 APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket);
00347
00355 APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock,
00356 apr_sockaddr_t *sa);
00357
00359 APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa);
00360
00368 APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock,
00369 apr_int32_t backlog);
00370
00372 APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog);
00373
00382 APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock,
00383 apr_socket_t *sock,
00384 apr_pool_t *connection_pool);
00385
00387 APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock,
00388 apr_socket_t *sock,
00389 apr_pool_t *connection_pool);
00390
00399 APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock,
00400 apr_sockaddr_t *sa);
00401
00403 APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa);
00404
00428 APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa,
00429 const char *hostname,
00430 apr_int32_t family,
00431 apr_port_t port,
00432 apr_int32_t flags,
00433 apr_pool_t *p);
00434
00441 APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname,
00442 apr_sockaddr_t *sa,
00443 apr_int32_t flags);
00444
00475 APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr,
00476 char **scope_id,
00477 apr_port_t *port,
00478 const char *str,
00479 apr_pool_t *p);
00480
00489 APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont);
00490
00497 APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
00498 apr_socket_t *sock);
00499
00507 APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data,
00508 const char *key,
00509 apr_status_t (*cleanup)(void*));
00510
00527 APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf,
00528 apr_size_t *len);
00529
00531 APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf,
00532 apr_size_t *len);
00533
00551 APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock,
00552 const struct iovec *vec,
00553 apr_int32_t nvec, apr_size_t *len);
00554
00556 APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock,
00557 const struct iovec *vec,
00558 apr_int32_t nvec, apr_size_t *len);
00559
00567 APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock,
00568 apr_sockaddr_t *where,
00569 apr_int32_t flags, const char *buf,
00570 apr_size_t *len);
00571
00573 APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
00574 apr_int32_t flags, const char *buf,
00575 apr_size_t *len);
00576
00585 APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from,
00586 apr_socket_t *sock,
00587 apr_int32_t flags, char *buf,
00588 apr_size_t *len);
00589
00591 APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
00592 apr_int32_t flags, char *buf,
00593 apr_size_t *len);
00594
00595 #if APR_HAS_SENDFILE || defined(DOXYGEN)
00596
00612 APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock,
00613 apr_file_t *file,
00614 apr_hdtr_t *hdtr,
00615 apr_off_t *offset,
00616 apr_size_t *len,
00617 apr_int32_t flags);
00618
00620 APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file,
00621 apr_hdtr_t *hdtr, apr_off_t *offset,
00622 apr_size_t *len, apr_int32_t flags);
00623
00624 #endif
00625
00644 APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock,
00645 char *buf, apr_size_t *len);
00646
00648 APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock,
00649 char *buf, apr_size_t *len);
00650
00668 APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock,
00669 apr_int32_t opt, apr_int32_t on);
00670
00672 APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock,
00673 apr_int32_t opt, apr_int32_t on);
00674
00686 APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock,
00687 apr_interval_time_t t);
00688
00708 APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock,
00709 apr_int32_t opt, apr_int32_t *on);
00710
00712 APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock,
00713 apr_int32_t opt, apr_int32_t *on);
00714
00720 APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock,
00721 apr_interval_time_t *t);
00722
00729 APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa,
00730 apr_interface_e which,
00731 apr_socket_t *sock);
00732
00738 APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr,
00739 apr_port_t port);
00740
00746 APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port,
00747 apr_sockaddr_t *sockaddr);
00748
00755 APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr,
00756 const char *addr);
00757
00765 APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr,
00766 apr_sockaddr_t *sockaddr);
00767
00778 APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
00779 const apr_sockaddr_t *addr2);
00780
00781
00782 #if APR_FILES_AS_SOCKETS || defined(DOXYGEN)
00783
00794 APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock,
00795 apr_file_t *file);
00796
00797 #endif
00798
00804 APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr,
00805 const char *servname);
00814 APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub,
00815 const char *ipstr,
00816 const char *mask_or_numbits,
00817 apr_pool_t *p);
00818
00826 APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa);
00827
00828 #if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN)
00829
00836 apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
00837 char *args);
00838 #endif
00839
00845 APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock,
00846 int *protocol);
00847
00851 APR_DECLARE_INHERIT_SET(socket);
00852
00854 APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);
00855
00859 APR_DECLARE_INHERIT_UNSET(socket);
00860
00862 APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);
00863
00866 #ifdef __cplusplus
00867 }
00868 #endif
00869
00870 #endif
00871