Skip to content
Newer
Older
100644 273 lines (189 sloc) 7.2 KB
e23f2db @yaoweibin add sources
authored
1
2 #ifndef _NGX_TCP_H_INCLUDED_
3 #define _NGX_TCP_H_INCLUDED_
4
5
2c053b7 @yaoweibin fix the nginx_version bug
authored
6 #include <nginx.h>
e23f2db @yaoweibin add sources
authored
7 #include <ngx_config.h>
8 #include <ngx_core.h>
9 #include <ngx_event.h>
10 #include <ngx_event_connect.h>
11
12
13 typedef struct ngx_tcp_protocol_s ngx_tcp_protocol_t;
14 typedef struct ngx_tcp_upstream_s ngx_tcp_upstream_t;
15 typedef struct ngx_tcp_cleanup_s ngx_tcp_cleanup_t;
16
a916a9e @yaoweibin add virtual_servers
authored
17 typedef struct ngx_tcp_core_srv_conf_s ngx_tcp_core_srv_conf_t;
18
2a82727 @yaoweibin add check type of http
authored
19 typedef struct ngx_tcp_upstream_srv_conf_s ngx_tcp_upstream_srv_conf_t;
20 typedef struct ngx_tcp_upstream_resolved_s ngx_tcp_upstream_resolved_t;
21
22 typedef struct ngx_tcp_check_peer_conf_s ngx_tcp_check_peer_conf_t;
23 typedef struct ngx_tcp_check_peers_conf_s ngx_tcp_check_peers_conf_t;
dd222ae @yaoweibin add check type of smtp and some test cases
authored
24 typedef struct check_conf_s check_conf_t;
2a82727 @yaoweibin add check type of http
authored
25
d686189 @yaoweibin add the version control for ngx_peer_addr_t
authored
26 /* make nginx-0.8.22+ happy */
27 #if defined(nginx_version) && nginx_version >= 8022
2c053b7 @yaoweibin fix the nginx_version bug
authored
28 typedef ngx_addr_t ngx_peer_addr_t;
d686189 @yaoweibin add the version control for ngx_peer_addr_t
authored
29 #endif
e23f2db @yaoweibin add sources
authored
30
31 #include <ngx_tcp_session.h>
32 #include <ngx_tcp_upstream.h>
2a82727 @yaoweibin add check type of http
authored
33 #include <ngx_tcp_upstream_check.h>
e23f2db @yaoweibin add sources
authored
34 #include <ngx_tcp_upstream_round_robin.h>
35
7c59eb2 @yaoweibin add the feature of ssl
authored
36 #if (NGX_TCP_SSL)
37 #include <ngx_tcp_ssl_module.h>
38 #endif
39
e23f2db @yaoweibin add sources
authored
40
41 typedef struct {
42 void **main_conf;
43 void **srv_conf;
44 } ngx_tcp_conf_ctx_t;
45
46
47 typedef struct {
48 u_char sockaddr[NGX_SOCKADDRLEN];
49 socklen_t socklen;
50
51 /* server ctx */
52 ngx_tcp_conf_ctx_t *ctx;
53
77a7461 @yaoweibin add the default option for listen
authored
54 unsigned default_port:1;
e23f2db @yaoweibin add sources
authored
55 unsigned bind:1;
56 unsigned wildcard:1;
7c59eb2 @yaoweibin add the feature of ssl
authored
57 #if (NGX_TCP_SSL)
58 unsigned ssl:1;
59 #endif
e23f2db @yaoweibin add sources
authored
60 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
61 unsigned ipv6only:2;
62 #endif
a916a9e @yaoweibin add virtual_servers
authored
63 ngx_tcp_core_srv_conf_t *conf;
e23f2db @yaoweibin add sources
authored
64 } ngx_tcp_listen_t;
65
66
67 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
68 ngx_str_t name;
4f8953e @yaoweibin add the directive of 'server_name'
authored
69 } ngx_tcp_server_name_t;
70
71
72 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
73 ngx_uint_t hash;
74 ngx_str_t name;
75 ngx_tcp_listen_t *listen;
76 ngx_tcp_conf_ctx_t *ctx;
c070171 @yaoweibin tidy the source
authored
77 } ngx_tcp_virtual_server_t;
78
79
80 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
81 ngx_str_t name;
ffbd10e @yaoweibin add the skeleton of 'location'
authored
82 } ngx_tcp_core_loc_t;
83
84
85 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
86 ngx_tcp_conf_ctx_t *ctx;
87 ngx_tcp_conf_ctx_t *default_ctx;
88 ngx_str_t addr_text;
7c59eb2 @yaoweibin add the feature of ssl
authored
89 #if (NGX_TCP_SSL)
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
90 ngx_uint_t ssl; /* unsigned ssl:1; */
7c59eb2 @yaoweibin add the feature of ssl
authored
91 #endif
e23f2db @yaoweibin add sources
authored
92 } ngx_tcp_addr_conf_t;
93
94 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
95 in_addr_t addr;
96 ngx_tcp_addr_conf_t conf;
e23f2db @yaoweibin add sources
authored
97 } ngx_tcp_in_addr_t;
98
99
100 #if (NGX_HAVE_INET6)
101
102 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
103 struct in6_addr addr6;
104 ngx_tcp_addr_conf_t conf;
e23f2db @yaoweibin add sources
authored
105 } ngx_tcp_in6_addr_t;
106
107 #endif
108
109
110 typedef struct {
111 /* ngx_tcp_in_addr_t or ngx_tcp_in6_addr_t */
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
112 void *addrs;
113 ngx_uint_t naddrs;
e23f2db @yaoweibin add sources
authored
114 } ngx_tcp_port_t;
115
116
117 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
118 int family;
119 in_port_t port;
120 ngx_array_t addrs; /* array of ngx_tcp_conf_addr_t */
e23f2db @yaoweibin add sources
authored
121 } ngx_tcp_conf_port_t;
122
123
124 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
125 struct sockaddr *sockaddr;
126 socklen_t socklen;
e23f2db @yaoweibin add sources
authored
127
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
128 ngx_tcp_conf_ctx_t *ctx;
129 ngx_tcp_conf_ctx_t *default_ctx;
e23f2db @yaoweibin add sources
authored
130
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
131 unsigned bind:1;
132 unsigned wildcard:1;
7c59eb2 @yaoweibin add the feature of ssl
authored
133 #if (NGX_TCP_SSL)
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
134 unsigned ssl:1;
7c59eb2 @yaoweibin add the feature of ssl
authored
135 #endif
e23f2db @yaoweibin add sources
authored
136 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
137 unsigned ipv6only:2;
e23f2db @yaoweibin add sources
authored
138 #endif
139 } ngx_tcp_conf_addr_t;
140
fcacae8 @yaoweibin add simple access features
authored
141 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
142 in_addr_t mask;
143 in_addr_t addr;
144 ngx_uint_t deny; /* unsigned deny:1; */
fcacae8 @yaoweibin add simple access features
authored
145 } ngx_tcp_access_rule_t;
e23f2db @yaoweibin add sources
authored
146
147 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
148 ngx_array_t servers; /* ngx_tcp_core_srv_conf_t */
149 ngx_array_t listen; /* ngx_tcp_listen_t */
150 ngx_array_t virtual_servers; /* ngx_tcp_virtual_server_t */
e23f2db @yaoweibin add sources
authored
151 } ngx_tcp_core_main_conf_t;
152
c729e62 @yaoweibin add docs for busyness module
authored
153 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
154 ngx_open_file_t *file;
155 time_t disk_full_time;
156 time_t error_log_time;
2e084e6 @yaoweibin add ngx_tcp_log
authored
157 } ngx_tcp_log_t;
158
159 typedef struct {
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
160 ngx_array_t *logs; /* array of ngx_tcp_log_t */
c729e62 @yaoweibin add docs for busyness module
authored
161
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
162 ngx_open_file_cache_t *open_file_cache;
163 time_t open_file_cache_valid;
164 ngx_uint_t open_file_cache_min_uses;
c729e62 @yaoweibin add docs for busyness module
authored
165
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
166 ngx_uint_t off; /* unsigned off:1 */
c729e62 @yaoweibin add docs for busyness module
authored
167 } ngx_tcp_log_srv_conf_t;
e23f2db @yaoweibin add sources
authored
168
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
169
d2c23b6 @yaoweibin plan to add websocket_proxy module
authored
170 #define NGX_TCP_GENERIC_PROTOCOL 0
171 #define NGX_TCP_WEBSOCKET_PROTOCOL 1
172
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
173
a916a9e @yaoweibin add virtual_servers
authored
174 struct ngx_tcp_core_srv_conf_s {
4f8953e @yaoweibin add the directive of 'server_name'
authored
175 /* array of the ngx_tcp_server_name_t, "server_name" directive */
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
176 ngx_array_t server_names;
4f8953e @yaoweibin add the directive of 'server_name'
authored
177
ffbd10e @yaoweibin add the skeleton of 'location'
authored
178 /* array of the ngx_tcp_core_loc_t, "location" directive */
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
179 ngx_array_t locations;
ffbd10e @yaoweibin add the skeleton of 'location'
authored
180
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
181 ngx_tcp_protocol_t *protocol;
e23f2db @yaoweibin add sources
authored
182
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
183 ngx_msec_t timeout;
184 ngx_msec_t resolver_timeout;
e23f2db @yaoweibin add sources
authored
185
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
186 ngx_flag_t so_keepalive;
187 ngx_flag_t tcp_nodelay;
e23f2db @yaoweibin add sources
authored
188
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
189 ngx_str_t server_name;
e23f2db @yaoweibin add sources
authored
190
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
191 u_char *file_name;
192 ngx_int_t line;
e23f2db @yaoweibin add sources
authored
193
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
194 ngx_resolver_t *resolver;
e23f2db @yaoweibin add sources
authored
195
fcacae8 @yaoweibin add simple access features
authored
196 /*ACL rules*/
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
197 ngx_array_t *rules;
fcacae8 @yaoweibin add simple access features
authored
198
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
199 ngx_tcp_log_srv_conf_t *access_log;
c729e62 @yaoweibin add docs for busyness module
authored
200
e23f2db @yaoweibin add sources
authored
201 /* server ctx */
3c3f463 @yaoweibin fix the coding style for tcp.c and tcp.h
authored
202 ngx_tcp_conf_ctx_t *ctx;
a916a9e @yaoweibin add virtual_servers
authored
203 };
e23f2db @yaoweibin add sources
authored
204
e61fd0d @yaoweibin tidy the source
authored
205
e23f2db @yaoweibin add sources
authored
206 typedef struct {
207 ngx_str_t *client;
e61fd0d @yaoweibin tidy the source
authored
208 ngx_tcp_session_t *session;
e23f2db @yaoweibin add sources
authored
209 } ngx_tcp_log_ctx_t;
210
211
12d5561 @yaoweibin desgin the struct of protocol
authored
212 typedef void (*ngx_tcp_init_session_pt)(ngx_tcp_session_t *s);
e23f2db @yaoweibin add sources
authored
213 typedef void (*ngx_tcp_init_protocol_pt)(ngx_event_t *rev);
12d5561 @yaoweibin desgin the struct of protocol
authored
214 typedef void (*ngx_tcp_parse_protocol_pt)(ngx_event_t *rev);
e23f2db @yaoweibin add sources
authored
215
216
217 struct ngx_tcp_protocol_s {
218 ngx_str_t name;
219 in_port_t port[4];
220 ngx_uint_t type;
221
e61fd0d @yaoweibin tidy the source
authored
222 ngx_tcp_init_session_pt init_session;
223 ngx_tcp_init_protocol_pt init_protocol;
12d5561 @yaoweibin desgin the struct of protocol
authored
224 ngx_tcp_parse_protocol_pt parse_protocol;
e23f2db @yaoweibin add sources
authored
225
226 ngx_str_t internal_server_error;
227 };
228
229
230 typedef struct {
e61fd0d @yaoweibin tidy the source
authored
231 ngx_tcp_protocol_t *protocol;
e23f2db @yaoweibin add sources
authored
232
233 void *(*create_main_conf)(ngx_conf_t *cf);
234 char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
235
236 void *(*create_srv_conf)(ngx_conf_t *cf);
237 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
238 void *conf);
239 } ngx_tcp_module_t;
240
241
242 #define NGX_TCP_MODULE 0x00504354 /* "TCP" */
243
0d564d6 @yaoweibin fix the bugs with 'include' directive and segment fault when reloading.
authored
244 #define NGX_TCP_MAIN_CONF 0x02000000
245 #define NGX_TCP_SRV_CONF 0x04000000
ffbd10e @yaoweibin add the skeleton of 'location'
authored
246 #define NGX_TCP_LOC_CONF 0x08000000
0d564d6 @yaoweibin fix the bugs with 'include' directive and segment fault when reloading.
authored
247 #define NGX_TCP_UPS_CONF 0x10000000
e23f2db @yaoweibin add sources
authored
248
249
250 #define NGX_TCP_MAIN_CONF_OFFSET offsetof(ngx_tcp_conf_ctx_t, main_conf)
251 #define NGX_TCP_SRV_CONF_OFFSET offsetof(ngx_tcp_conf_ctx_t, srv_conf)
252
253
254 #define ngx_tcp_get_module_ctx(s, module) (s)->ctx[module.ctx_index]
255 #define ngx_tcp_set_ctx(s, c, module) s->ctx[module.ctx_index] = c;
256 #define ngx_tcp_delete_ctx(s, module) s->ctx[module.ctx_index] = NULL;
257
258
259 #define ngx_tcp_get_module_main_conf(s, module) \
260 (s)->main_conf[module.ctx_index]
261 #define ngx_tcp_get_module_srv_conf(s, module) (s)->srv_conf[module.ctx_index]
262
263 #define ngx_tcp_conf_get_module_main_conf(cf, module) \
264 ((ngx_tcp_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
265 #define ngx_tcp_conf_get_module_srv_conf(cf, module) \
266 ((ngx_tcp_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
267
268
269 extern ngx_uint_t ngx_tcp_max_module;
270 extern ngx_module_t ngx_tcp_core_module;
271
272 #endif /* _NGX_TCP_H_INCLUDED_ */
Something went wrong with that request. Please try again.