summaryrefslogtreecommitdiff
path: root/src/network_backends.h
blob: 4f99a66383fb7dce7838a1fb9c1c17859579a6a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _NETWORK_BACKENDS_H_
#define _NETWORK_BACKENDS_H_

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <sys/types.h>

#include "settings.h"
#include "base.h"
#include "network.h"

#define NETWORK_BACKEND_WRITE_CHUNK(x) \
    network_status_t network_write_chunkqueue_##x(server *srv, connection *con, iosocket *sock, chunkqueue *cq, chunk *c)

#define NETWORK_BACKEND_WRITE(x) \
    network_status_t network_write_chunkqueue_##x(server *srv, connection *con, iosocket *sock, chunkqueue *cq)
#define NETWORK_BACKEND_READ(x) \
    network_status_t network_read_chunkqueue_##x(server *srv, connection *con, iosocket *sock, chunkqueue *cq)

LI_API NETWORK_BACKEND_WRITE_CHUNK(writev_mem);

LI_API NETWORK_BACKEND_WRITE(write);
LI_API NETWORK_BACKEND_WRITE(writev);
LI_API NETWORK_BACKEND_WRITE(linuxsendfile);
LI_API NETWORK_BACKEND_WRITE(linuxaiosendfile);
LI_API NETWORK_BACKEND_WRITE(posixaio);
LI_API NETWORK_BACKEND_WRITE(gthreadaio);
LI_API NETWORK_BACKEND_WRITE(gthreadsendfile);
LI_API NETWORK_BACKEND_WRITE(gthreadfreebsdsendfile);
LI_API NETWORK_BACKEND_WRITE(freebsdsendfile);
LI_API NETWORK_BACKEND_WRITE(solarissendfilev);

LI_API NETWORK_BACKEND_WRITE(win32transmitfile);
LI_API NETWORK_BACKEND_WRITE(win32send);

LI_API NETWORK_BACKEND_READ(read);
LI_API NETWORK_BACKEND_READ(win32recv);

#ifdef USE_OPENSSL
LI_API NETWORK_BACKEND_WRITE(openssl);
LI_API NETWORK_BACKEND_READ(openssl);
#endif

typedef struct {
	network_backend_t type;
	const char *name;
	const char *description;
	network_status_t (*read_handler)(server *srv, connection *con, iosocket *sock, chunkqueue *cq);
	network_status_t (*write_handler)(server *srv, connection *con, iosocket *sock, chunkqueue *cq);
} network_backend_info_t;

LI_API const network_backend_info_t *network_get_backends();
LI_API const network_backend_info_t *network_get_defaultbackend();
LI_API const network_backend_info_t *network_get_backend_info_by_type(network_backend_t type);
LI_API const network_backend_info_t *network_get_backend_info_by_name(const char *name);

#endif