Mercurial > dropbear
comparison netio.h @ 1051:359fba4b1a49
merge tcp fastopen
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 28 Feb 2015 23:24:30 +0800 |
parents | c2a50c9f509e |
children | c71df09bc610 |
comparison
equal
deleted
inserted
replaced
1045:31727a8abd4b | 1051:359fba4b1a49 |
---|---|
1 #ifndef DROPBEAR_NETIO_H | |
2 #define DROPBEAR_NETIO_H | |
3 | |
4 #include "includes.h" | |
5 #include "buffer.h" | |
6 #include "queue.h" | |
7 | |
8 enum dropbear_prio { | |
9 DROPBEAR_PRIO_DEFAULT = 10, | |
10 DROPBEAR_PRIO_LOWDELAY = 11, | |
11 DROPBEAR_PRIO_BULK = 12, | |
12 }; | |
13 | |
14 void set_sock_nodelay(int sock); | |
15 void set_sock_priority(int sock, enum dropbear_prio prio); | |
16 | |
17 void get_socket_address(int fd, char **local_host, char **local_port, | |
18 char **remote_host, char **remote_port, int host_lookup); | |
19 void getaddrstring(struct sockaddr_storage* addr, | |
20 char **ret_host, char **ret_port, int host_lookup); | |
21 int dropbear_listen(const char* address, const char* port, | |
22 int *socks, unsigned int sockcount, char **errstring, int *maxfd); | |
23 | |
24 struct dropbear_progress_connection; | |
25 | |
26 /* result is DROPBEAR_SUCCESS or DROPBEAR_FAILURE. | |
27 errstring is only set on DROPBEAR_FAILURE, returns failure message for the last attempted socket */ | |
28 typedef void(*connect_callback)(int result, int sock, void* data, const char* errstring); | |
29 | |
30 struct dropbear_progress_connection * connect_remote (const char* remotehost, const char* remoteport, | |
31 connect_callback cb, void *cb_data); | |
32 | |
33 /* Sets up for select() */ | |
34 void set_connect_fds(fd_set *writefd); | |
35 /* Handles ready sockets after select() */ | |
36 void handle_connect_fds(fd_set *writefd); | |
37 /* Cleanup */ | |
38 void remove_connect_pending(); | |
39 | |
40 /* Doesn't actually stop the connect, but adds a dummy callback instead */ | |
41 void cancel_connect(struct dropbear_progress_connection *c); | |
42 | |
43 void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue); | |
44 | |
45 /* TODO: writev #ifdef guard */ | |
46 struct iovec * packet_queue_to_iovec(struct Queue *queue, int *ret_iov_count); | |
47 void packet_queue_consume(struct Queue *queue, ssize_t written); | |
48 | |
49 #ifdef DROPBEAR_TCP_FAST_OPEN | |
50 /* Try for any Linux builds, will fall back if the kernel doesn't support it */ | |
51 void set_listen_fast_open(int sock); | |
52 /* Define values which may be supported by the kernel even if the libc is too old */ | |
53 #ifndef TCP_FASTOPEN | |
54 #define TCP_FASTOPEN 23 | |
55 #endif | |
56 #ifndef MSG_FASTOPEN | |
57 #define MSG_FASTOPEN 0x20000000 | |
58 #endif | |
59 #endif | |
60 | |
61 #endif | |
62 |