Apache HTTPD
apr_network_io.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef APR_NETWORK_IO_H
18#define APR_NETWORK_IO_H
24#include "apr.h"
25#include "apr_pools.h"
26#include "apr_file_io.h"
27#include "apr_errno.h"
28#include "apr_inherit.h"
29#include "apr_perms_set.h"
30
31#if APR_HAVE_NETINET_IN_H
32#include <netinet/in.h>
33#endif
34#if APR_HAVE_SYS_UN_H
35#include <sys/un.h>
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
48#ifndef APR_MAX_SECS_TO_LINGER
50#define APR_MAX_SECS_TO_LINGER 30
51#endif
52
53#ifndef APRMAXHOSTLEN
55#define APRMAXHOSTLEN 256
56#endif
57
58#ifndef APR_ANYADDR
60#define APR_ANYADDR "0.0.0.0"
61#endif
62
67#define APR_SO_LINGER 1
68#define APR_SO_KEEPALIVE 2
69#define APR_SO_DEBUG 4
70#define APR_SO_NONBLOCK 8
71#define APR_SO_REUSEADDR 16
72#define APR_SO_SNDBUF 64
73#define APR_SO_RCVBUF 128
74#define APR_SO_DISCONNECTED 256
75#define APR_TCP_NODELAY 512
78#define APR_TCP_NOPUSH 1024
79#define APR_RESET_NODELAY 2048
85#define APR_INCOMPLETE_READ 4096
96#define APR_INCOMPLETE_WRITE 8192
99#define APR_IPV6_V6ONLY 16384
102#define APR_TCP_DEFER_ACCEPT 32768
106#define APR_SO_BROADCAST 65536
108#define APR_SO_FREEBIND 131072
120
121#define APR_IPV4_ADDR_OK 0x01
122#define APR_IPV6_ADDR_OK 0x02
124#if (!APR_HAVE_IN_ADDR)
132#endif
133
138#ifdef INADDR_NONE
139#define APR_INADDR_NONE INADDR_NONE
140#else
141#define APR_INADDR_NONE ((unsigned int) 0xffffffff)
142#endif
143
149#define APR_INET AF_INET
153#ifdef AF_UNSPEC
154#define APR_UNSPEC AF_UNSPEC
155#else
156#define APR_UNSPEC 0
157#endif
158#if APR_HAVE_IPV6
163#define APR_INET6 AF_INET6
164#endif
165
166#if APR_HAVE_SOCKADDR_UN
167#if defined (AF_UNIX)
168#define APR_UNIX AF_UNIX
169#elif defined(AF_LOCAL)
170#define APR_UNIX AF_LOCAL
171#else
172#error "Neither AF_UNIX nor AF_LOCAL is defined"
173#endif
174#else /* !APR_HAVE_SOCKADDR_UN */
175#if defined (AF_UNIX)
176#define APR_UNIX AF_UNIX
177#elif defined(AF_LOCAL)
178#define APR_UNIX AF_LOCAL
179#else
180/* TODO: Use a smarter way to detect unique APR_UNIX value */
181#define APR_UNIX 1234
182#endif
183#endif
184
189#define APR_PROTO_TCP 6
190#define APR_PROTO_UDP 17
191#define APR_PROTO_SCTP 132
202
208#if APR_HAVE_INET_ADDR
209#define apr_inet_addr inet_addr
210#elif APR_HAVE_INET_NETWORK /* only DGUX, as far as I know */
215#define apr_inet_addr inet_network
216#endif
217
223typedef struct apr_hdtr_t apr_hdtr_t;
225typedef struct in_addr apr_in_addr_t;
228
231
243 char *hostname;
245 char *servname;
264 union {
267#if APR_HAVE_IPV6
269 struct sockaddr_in6 sin6;
270#endif
271#if APR_HAVE_SA_STORAGE
274 struct sockaddr_storage sas;
275#endif
276#if APR_HAVE_SOCKADDR_UN
278 struct sockaddr_un unx;
279#endif
280 } sa;
281};
282
283#if APR_HAS_SENDFILE
289#define APR_SENDFILE_DISCONNECT_SOCKET 1
290#endif
291
303
304/* function definitions */
305
318 int family, int type,
321
337
343
353
363
378
387
402
428 const char *hostname,
433
442 apr_pool_t *p);
443
452 const char *zone_id);
453
454
467 const char **name,
469 apr_pool_t *p);
470
482
514 char **scope_id,
516 const char *str,
517 apr_pool_t *p);
518
528
537
546 const char *key,
548
567 apr_size_t *len);
568
588 const struct iovec *vec,
590
600 apr_int32_t flags, const char *buf,
601 apr_size_t *len);
602
618 apr_int32_t flags, char *buf,
619 apr_size_t *len);
620
621#if APR_HAS_SENDFILE || defined(DOXYGEN)
622
647
648#endif /* APR_HAS_SENDFILE */
649
670 char *buf, apr_size_t *len);
671
697
711
733
741
749 int *atmark);
750
762
772
780
793
803
810 int *type);
811
818 const char *servname);
828 const char *ipstr,
829 const char *mask_or_numbits,
830 apr_pool_t *p);
831
840
841#if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN)
852 char *args);
853#endif
854
861 int *protocol);
862
867
872
877
882
901
916
926
934
935
943
948#ifdef __cplusplus
949}
950#endif
951
952#endif /* ! APR_NETWORK_IO_H */
953
#define socket
APR Error Codes.
APR File I/O Handling.
APR File Handle Inheritance Helpers.
#define APR_DECLARE_INHERIT_SET(type)
Definition apr_inherit.h:35
#define APR_DECLARE_INHERIT_UNSET(type)
Definition apr_inherit.h:47
APR Process Locking Routines.
APR memory allocation.
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
int apr_status_t
Definition apr_errno.h:44
apr_seek_where_t apr_off_t * offset
const char apr_file_t * file
apr_sockaddr_t apr_sockaddr_t apr_sockaddr_t * source
apr_sockaddr_t * join
apr_sockaddr_t apr_sockaddr_t * iface
apr_byte_t ttl
apr_sockaddr_t * addr
const char * ipstr
apr_sockaddr_t * sockaddr
apr_int32_t opt
apr_interface_e
const char apr_int32_t apr_port_t port
int family
apr_interface_e which
apr_socket_t * sock
int int type
apr_sockaddr_t * where
const apr_sockaddr_t * addr2
const char * servname
apr_sockaddr_t * sa
const apr_sockaddr_t * src
apr_interval_time_t t
void * data
int * atmark
apr_size_t buflen
const struct iovec apr_int32_t nvec
apr_int32_t backlog
const char * key
apr_shutdown_how_e how
int len
void const char apr_status_t(* cleanup)(void *))
apr_uint16_t apr_port_t
const char * hostname
const char ** name
int int int protocol
apr_int32_t apr_int32_t on
int * atreadeof
const char apr_int32_t apr_port_t apr_int32_t apr_pool_t * p
char ** scope_id
const char * buf
int int int apr_pool_t * cont
const char const char * mask_or_numbits
apr_shutdown_how_e
apr_socket_t apr_pool_t * connection_pool
const char apr_int32_t apr_port_t apr_int32_t flags
const struct iovec * vec
const char * zone_id
char apr_port_t const char * str
@ APR_LOCAL
@ APR_REMOTE
@ APR_SHUTDOWN_WRITE
@ APR_SHUTDOWN_READ
@ APR_SHUTDOWN_READWRITE
#define APR_PERMS_SET_IMPLEMENT(type)
#define APR_POOL_DECLARE_ACCESSOR(type)
Definition apr_pools.h:81
const char const char *const * args
apr_int64_t apr_interval_time_t
Definition apr_time.h:55
struct iovec * trailers
struct iovec * headers
union apr_sockaddr_t::@55 sa
apr_pool_t * pool
apr_sockaddr_t * next
struct sockaddr_in sin
apr_int32_t family
apr_socklen_t salen
apr_uint32_t s_addr
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)
Definition sendrecv.c:112
apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, apr_int32_t flags, char *buf, apr_size_t *len)
Definition sendrecv.c:146
apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
Definition sendrecv.c:30
apr_status_t apr_socket_sendv(apr_socket_t *sock, const struct iovec *vec, apr_int32_t nvec, apr_size_t *len)
Definition sendrecv.c:194
apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
Definition sendrecv.c:70
apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, apr_pool_t *connection_context)
Definition sockets.c:247
apr_status_t apr_socket_listen(apr_socket_t *sock, apr_int32_t backlog)
Definition sockets.c:239
apr_status_t apr_socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
Definition sockets.c:216
apr_status_t apr_socket_close(apr_socket_t *thesocket)
Definition sockets.c:211
apr_status_t apr_socket_type_get(apr_socket_t *sock, int *type)
Definition sockets.c:466
apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
Definition sockets.c:388
apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol)
Definition sockets.c:110
apr_status_t apr_socket_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how)
Definition sockets.c:205
apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, int protocol, apr_pool_t *cont)
Definition sockets.c:116
apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *sock)
Definition sockets.c:472
apr_status_t apr_socket_data_set(apr_socket_t *sock, void *data, const char *key, apr_status_t(*cleanup)(void *))
Definition sockets.c:489
apr_status_t apr_socket_opt_set(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on)
Definition sockopt.c:113
apr_status_t apr_socket_opt_get(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on)
Definition sockopt.c:362
apr_status_t apr_socket_atmark(apr_socket_t *sock, int *atmark)
Definition sockopt.c:373
apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont)
Definition sockopt.c:389
apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
Definition sockopt.c:75
apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t)
Definition sockopt.c:355