1 #ifndef _NETWORK_BACKENDS_H_
2 #define _NETWORK_BACKENDS_H_
3 /*----------------------------------------------------------------------------*/
4 #ifdef HAVE_CONFIG_H
5 # include "config.h"
6 #endif
7 #include "settings.h"
8 
9 #include <sys/types.h>
10 /*----------------------------------------------------------------------------*/
11 /* on linux 2.4.x you get either sendfile or LFS */
12 #if defined HAVE_SYS_SENDFILE_H && defined HAVE_SENDFILE && (!defined _LARGEFILE_SOURCE || defined HAVE_SENDFILE64) && defined HAVE_WRITEV && defined(__linux__) && !defined HAVE_SENDFILE_BROKEN
13 # define USE_LINUX_SENDFILE
14 # include <sys/sendfile.h>
15 # include <sys/uio.h>
16 #endif
17 
18 #if defined HAVE_SYS_UIO_H && defined HAVE_SENDFILE && defined HAVE_WRITEV && (defined(__FreeBSD__) || defined(__DragonFly__))
19 # define USE_FREEBSD_SENDFILE
20 # include <sys/uio.h>
21 #endif
22 
23 #if defined HAVE_SYS_SENDFILE_H && defined HAVE_SENDFILEV && defined HAVE_WRITEV && defined(__sun)
24 # define USE_SOLARIS_SENDFILEV
25 # include <sys/sendfile.h>
26 # include <sys/uio.h>
27 #endif
28 
29 #if defined HAVE_SYS_UIO_H && defined HAVE_WRITEV
30 # define USE_WRITEV
31 # include <sys/uio.h>
32 #endif
33 
34 #if defined HAVE_SYS_MMAN_H && defined HAVE_MMAP && defined ENABLE_MMAP
35 # define USE_MMAP
36 # include <sys/mman.h>
37 /* NetBSD 1.3.x needs it */
38 # ifndef MAP_FAILED
39 #  define MAP_FAILED -1
40 # endif
41 #endif
42 
43 #if defined HAVE_SYS_UIO_H && defined HAVE_WRITEV && defined HAVE_SEND_FILE && defined(__aix)
44 # define USE_AIX_SENDFILE
45 #endif
46 
47 #if defined HAVE_LIBMTCP && (HAVE_LIBPSIO | HAVE_LIBDPDK)
48 # define USE_MTCP
49 #include <sys/socket.h>
50 #include <mtcp_api.h>
51 #include <eventpoll.h>
52 #endif
53 
54 #include "base.h"
55 /*----------------------------------------------------------------------------*/
56 /* return values:
57  * >= 0 : no error
58  *   -1 : error (on our side)
59  *   -2 : remote close
60  */
61 
62 int network_write_chunkqueue_write(server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes);
63 int network_write_chunkqueue_writev(server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes);
64 int network_write_chunkqueue_linuxsendfile(server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes);
65 int network_write_chunkqueue_freebsdsendfile(server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes);
66 int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes);
67 int network_write_chunkqueue_mtcp_writev(server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes);
68 #ifdef USE_OPENSSL
69 int network_write_chunkqueue_openssl(server *srv, connection *con, SSL *ssl, chunkqueue *cq, off_t max_bytes);
70 #endif
71 /*----------------------------------------------------------------------------*/
72 #endif
73