123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 |
- #ifndef APR_NETWORK_IO_H
- #define APR_NETWORK_IO_H
- #include "apr.h"
- #include "apr_pools.h"
- #include "apr_file_io.h"
- #include "apr_errno.h"
- #include "apr_inherit.h"
- #include "apr_perms_set.h"
- #if APR_HAVE_NETINET_IN_H
- #include <netinet/in.h>
- #endif
- #if APR_HAVE_SYS_UN_H
- #include <sys/un.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifndef APR_MAX_SECS_TO_LINGER
- #define APR_MAX_SECS_TO_LINGER 30
- #endif
- #ifndef APRMAXHOSTLEN
- #define APRMAXHOSTLEN 256
- #endif
- #ifndef APR_ANYADDR
- #define APR_ANYADDR "0.0.0.0"
- #endif
- #define APR_SO_LINGER 1
- #define APR_SO_KEEPALIVE 2
- #define APR_SO_DEBUG 4
- #define APR_SO_NONBLOCK 8
- #define APR_SO_REUSEADDR 16
- #define APR_SO_SNDBUF 64
- #define APR_SO_RCVBUF 128
- #define APR_SO_DISCONNECTED 256
- #define APR_TCP_NODELAY 512
- #define APR_TCP_NOPUSH 1024
- #define APR_RESET_NODELAY 2048
- #define APR_INCOMPLETE_READ 4096
- #define APR_INCOMPLETE_WRITE 8192
- #define APR_IPV6_V6ONLY 16384
- #define APR_TCP_DEFER_ACCEPT 32768
- #define APR_SO_BROADCAST 65536
- #define APR_SO_FREEBIND 131072
- typedef enum {
- APR_SHUTDOWN_READ,
- APR_SHUTDOWN_WRITE,
- APR_SHUTDOWN_READWRITE
- } apr_shutdown_how_e;
- #define APR_IPV4_ADDR_OK 0x01
- #define APR_IPV6_ADDR_OK 0x02
- #if (!APR_HAVE_IN_ADDR)
- struct in_addr {
- apr_uint32_t s_addr;
- };
- #endif
- #ifdef INADDR_NONE
- #define APR_INADDR_NONE INADDR_NONE
- #else
- #define APR_INADDR_NONE ((unsigned int) 0xffffffff)
- #endif
- #define APR_INET AF_INET
- #ifdef AF_UNSPEC
- #define APR_UNSPEC AF_UNSPEC
- #else
- #define APR_UNSPEC 0
- #endif
- #if APR_HAVE_IPV6
- #define APR_INET6 AF_INET6
- #endif
- #if APR_HAVE_SOCKADDR_UN
- #if defined (AF_UNIX)
- #define APR_UNIX AF_UNIX
- #elif defined(AF_LOCAL)
- #define APR_UNIX AF_LOCAL
- #else
- #error "Neither AF_UNIX nor AF_LOCAL is defined"
- #endif
- #else
- #if defined (AF_UNIX)
- #define APR_UNIX AF_UNIX
- #elif defined(AF_LOCAL)
- #define APR_UNIX AF_LOCAL
- #else
- #define APR_UNIX 1234
- #endif
- #endif
- #define APR_PROTO_TCP 6
- #define APR_PROTO_UDP 17
- #define APR_PROTO_SCTP 132
- typedef enum {
- APR_LOCAL,
- APR_REMOTE
- } apr_interface_e;
- #if APR_HAVE_INET_ADDR
- #define apr_inet_addr inet_addr
- #elif APR_HAVE_INET_NETWORK
- #define apr_inet_addr inet_network
- #endif
- typedef struct apr_socket_t apr_socket_t;
- typedef struct apr_hdtr_t apr_hdtr_t;
- typedef struct in_addr apr_in_addr_t;
- typedef struct apr_ipsubnet_t apr_ipsubnet_t;
- typedef apr_uint16_t apr_port_t;
- typedef struct apr_sockaddr_t apr_sockaddr_t;
- struct apr_sockaddr_t {
-
- apr_pool_t *pool;
-
- char *hostname;
-
- char *servname;
-
- apr_port_t port;
-
- apr_int32_t family;
-
- apr_socklen_t salen;
-
- int ipaddr_len;
-
- int addr_str_len;
-
- void *ipaddr_ptr;
-
- apr_sockaddr_t *next;
-
- union {
-
- struct sockaddr_in sin;
- #if APR_HAVE_IPV6
-
- struct sockaddr_in6 sin6;
- #endif
- #if APR_HAVE_SA_STORAGE
-
- struct sockaddr_storage sas;
- #endif
- #if APR_HAVE_SOCKADDR_UN
-
- struct sockaddr_un unx;
- #endif
- } sa;
- };
- #if APR_HAS_SENDFILE
- #define APR_SENDFILE_DISCONNECT_SOCKET 1
- #endif
- struct apr_hdtr_t {
-
- struct iovec* headers;
-
- int numheaders;
-
- struct iovec* trailers;
-
- int numtrailers;
- };
- APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock,
- int family, int type,
- int protocol,
- apr_pool_t *cont);
- APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket,
- apr_shutdown_how_e how);
- APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket);
- APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock,
- apr_sockaddr_t *sa);
- APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock,
- apr_int32_t backlog);
- APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock,
- apr_socket_t *sock,
- apr_pool_t *connection_pool);
- APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock,
- apr_sockaddr_t *sa);
- APR_DECLARE(apr_status_t) apr_socket_atreadeof(apr_socket_t *sock,
- int *atreadeof);
- APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa,
- const char *hostname,
- apr_int32_t family,
- apr_port_t port,
- apr_int32_t flags,
- apr_pool_t *p);
- APR_DECLARE(apr_status_t) apr_sockaddr_info_copy(apr_sockaddr_t **dst,
- const apr_sockaddr_t *src,
- apr_pool_t *p);
- APR_DECLARE(apr_status_t) apr_sockaddr_zone_set(apr_sockaddr_t *sa,
- const char *zone_id);
- APR_DECLARE(apr_status_t) apr_sockaddr_zone_get(const apr_sockaddr_t *sa,
- const char **name,
- apr_uint32_t *id,
- apr_pool_t *p);
-
- APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname,
- apr_sockaddr_t *sa,
- apr_int32_t flags);
- APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr,
- char **scope_id,
- apr_port_t *port,
- const char *str,
- apr_pool_t *p);
- APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont);
- APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
- apr_socket_t *sock);
- APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data,
- const char *key,
- apr_status_t (*cleanup)(void*));
- APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf,
- apr_size_t *len);
- APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock,
- const struct iovec *vec,
- apr_int32_t nvec, apr_size_t *len);
- APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock,
- apr_sockaddr_t *where,
- apr_int32_t flags, const char *buf,
- apr_size_t *len);
- APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from,
- apr_socket_t *sock,
- apr_int32_t flags, char *buf,
- apr_size_t *len);
-
- #if APR_HAS_SENDFILE || defined(DOXYGEN)
- APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock,
- apr_file_t *file,
- apr_hdtr_t *hdtr,
- apr_off_t *offset,
- apr_size_t *len,
- apr_int32_t flags);
- #endif
- APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock,
- char *buf, apr_size_t *len);
- APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock,
- apr_int32_t opt, apr_int32_t on);
- APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock,
- apr_interval_time_t t);
- APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock,
- apr_int32_t opt, apr_int32_t *on);
- APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock,
- apr_interval_time_t *t);
- APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock,
- int *atmark);
- APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa,
- apr_interface_e which,
- apr_socket_t *sock);
-
- APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr,
- apr_sockaddr_t *sockaddr);
- APR_DECLARE(apr_status_t) apr_sockaddr_ip_getbuf(char *buf, apr_size_t buflen,
- apr_sockaddr_t *sockaddr);
- APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
- const apr_sockaddr_t *addr2);
- APR_DECLARE(int) apr_sockaddr_is_wildcard(const apr_sockaddr_t *addr);
- APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock,
- int *type);
-
- APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr,
- const char *servname);
- APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub,
- const char *ipstr,
- const char *mask_or_numbits,
- apr_pool_t *p);
- APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa);
- #if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN)
- apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
- char *args);
- #endif
- APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock,
- int *protocol);
- APR_POOL_DECLARE_ACCESSOR(socket);
- APR_DECLARE_INHERIT_SET(socket);
- APR_DECLARE_INHERIT_UNSET(socket);
- APR_PERMS_SET_IMPLEMENT(socket);
- APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock,
- apr_sockaddr_t *join,
- apr_sockaddr_t *iface,
- apr_sockaddr_t *source);
- APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock,
- apr_sockaddr_t *addr,
- apr_sockaddr_t *iface,
- apr_sockaddr_t *source);
- APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock,
- apr_byte_t ttl);
- APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock,
- apr_byte_t opt);
- APR_DECLARE(apr_status_t) apr_mcast_interface(apr_socket_t *sock,
- apr_sockaddr_t *iface);
- #ifdef __cplusplus
- }
- #endif
- #endif
|