Files: c02e2d7aeeba25cb53d8a81acad55318ce63a4c4 / common.h
3422 bytesRaw
1 | |
2 | |
3 | |
4 | /* FD_SETSIZE is 64 on Cygwin, which is really low. Just redefining it is |
5 | * enough for the macros to adapt (http://support.microsoft.com/kb/111855) |
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 | (res == -1) { \ |
37 | perror(str); \ |
38 | exit(1); \ |
39 | } |
40 | |
41 | |
42 | (res == -1) { \ |
43 | log_message(LOG_CRIT, | , str, errno, strerror(errno)); \
44 | return res; \ |
45 | } |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | enum connection_state { |
56 | ST_PROBING=1, /* Waiting for timeout to find where to forward */ |
57 | ST_SHOVELING /* Connexion is established */ |
58 | }; |
59 | |
60 | /* this is used to pass protocols through the command-line parameter parsing */ |
61 | |
62 | |
63 | /* A 'queue' is composed of a file descriptor (which can be read from or |
64 | * written to), and a queue for defered write data */ |
65 | struct queue { |
66 | int fd; |
67 | void *begin_defered_data; |
68 | void *defered_data; |
69 | int defered_data_size; |
70 | }; |
71 | |
72 | struct connection { |
73 | enum connection_state state; |
74 | time_t probe_timeout; |
75 | |
76 | /* q[0]: queue for external connection (client); |
77 | * q[1]: queue for internal connection (httpd or sshd); |
78 | * */ |
79 | struct queue q[2]; |
80 | }; |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | /* common.c */ |
88 | void init_cnx(struct connection *cnx); |
89 | int connect_addr(struct addrinfo *addr, int fd_from, const char* cnx_name); |
90 | int fd2fd(struct queue *target, struct queue *from); |
91 | char* sprintaddr(char* buf, size_t size, struct addrinfo *a); |
92 | void resolve_name(struct addrinfo **out, char* fullname); |
93 | struct proto* probe_client_protocol(struct connection *cnx); |
94 | void log_connection(struct connection *cnx); |
95 | int check_access_rights(int in_socket, const char* service); |
96 | void setup_signals(void); |
97 | void setup_syslog(const char* bin_name); |
98 | void drop_privileges(const char* user_name); |
99 | void write_pid_file(const char* pidfile); |
100 | void log_message(int type, char* msg, ...); |
101 | void dump_connection(struct connection *cnx); |
102 | int resolve_split_name(struct addrinfo **out, const char* hostname, const char* port); |
103 | |
104 | int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list); |
105 | |
106 | int defer_write(struct queue *q, void* data, int data_size); |
107 | int flush_defered(struct queue *q); |
108 | |
109 | extern int probing_timeout, verbose, inetd, foreground, |
110 | background, transparent, numeric; |
111 | extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn; |
112 | extern struct addrinfo *addr_listen; |
113 | extern const char* USAGE_STRING; |
114 | extern const char* user_name, *pid_file; |
115 | extern const char* server_type; |
116 | |
117 | /* sslh-fork.c */ |
118 | void start_shoveler(int); |
119 | |
120 | void main_loop(int *listen_sockets, int num_addr_listen); |
121 | |
122 | |
123 |
Built with git-ssb-web