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