Mercurial > hg > nginx
annotate src/mail/ngx_mail.h @ 1514:0bd321c8ce67 stable-0.5
r1409, r1413 merge:
set delay only when almost whole sendfile_max_chunk was transferred
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 22 Sep 2007 19:23:34 +0000 |
parents | 4fd0907c968e |
children | 67578e966dcc ed9cd1702f7a |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
424
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
424
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
424
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
424
diff
changeset
|
5 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
424
diff
changeset
|
6 |
1136 | 7 #ifndef _NGX_MAIL_H_INCLUDED_ |
8 #define _NGX_MAIL_H_INCLUDED_ | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
13 #include <ngx_event.h> |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
14 #include <ngx_event_connect.h> |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
1136 | 16 #if (NGX_MAIL_SSL) |
17 #include <ngx_mail_ssl_module.h> | |
539 | 18 #endif |
19 | |
20 | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 typedef struct { |
583 | 23 void **main_conf; |
24 void **srv_conf; | |
1136 | 25 } ngx_mail_conf_ctx_t; |
521 | 26 |
27 | |
28 typedef struct { | |
641 | 29 in_addr_t addr; |
30 in_port_t port; | |
31 int family; | |
32 | |
33 /* server ctx */ | |
1136 | 34 ngx_mail_conf_ctx_t *ctx; |
641 | 35 |
36 unsigned bind:1; | |
1136 | 37 } ngx_mail_listen_t; |
641 | 38 |
39 | |
40 typedef struct { | |
41 in_addr_t addr; | |
1136 | 42 ngx_mail_conf_ctx_t *ctx; |
641 | 43 ngx_str_t addr_text; |
1136 | 44 } ngx_mail_in_addr_t; |
641 | 45 |
46 | |
47 typedef struct { | |
1136 | 48 ngx_mail_in_addr_t *addrs; /* array of ngx_mail_in_addr_t */ |
641 | 49 ngx_uint_t naddrs; |
1136 | 50 } ngx_mail_in_port_t; |
641 | 51 |
52 | |
53 typedef struct { | |
54 in_port_t port; | |
1136 | 55 ngx_array_t addrs; /* array of ngx_mail_conf_in_addr_t */ |
56 } ngx_mail_conf_in_port_t; | |
641 | 57 |
58 | |
59 typedef struct { | |
60 in_addr_t addr; | |
1136 | 61 ngx_mail_conf_ctx_t *ctx; |
641 | 62 unsigned bind:1; |
1136 | 63 } ngx_mail_conf_in_addr_t; |
641 | 64 |
65 | |
66 typedef struct { | |
1136 | 67 ngx_array_t servers; /* ngx_mail_core_srv_conf_t */ |
68 ngx_array_t listen; /* ngx_mail_listen_t */ | |
69 } ngx_mail_core_main_conf_t; | |
521 | 70 |
71 | |
1136 | 72 #define NGX_MAIL_POP3_PROTOCOL 0 |
73 #define NGX_MAIL_IMAP_PROTOCOL 1 | |
74 #define NGX_MAIL_SMTP_PROTOCOL 2 | |
521 | 75 |
76 typedef struct { | |
583 | 77 ngx_msec_t timeout; |
418
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
78 |
583 | 79 size_t imap_client_buffer_size; |
521 | 80 |
583 | 81 ngx_uint_t protocol; |
521 | 82 |
587 | 83 ngx_flag_t so_keepalive; |
84 | |
583 | 85 ngx_str_t pop3_capability; |
86 ngx_str_t pop3_starttls_capability; | |
1136 | 87 ngx_str_t pop3_starttls_only_capability; |
809 | 88 ngx_str_t pop3_auth_capability; |
89 | |
583 | 90 ngx_str_t imap_capability; |
91 ngx_str_t imap_starttls_capability; | |
92 ngx_str_t imap_starttls_only_capability; | |
527 | 93 |
1136 | 94 ngx_str_t smtp_capability; |
1501 | 95 ngx_str_t smtp_starttls_capability; |
96 ngx_str_t smtp_starttls_only_capability; | |
800 | 97 |
1136 | 98 ngx_str_t server_name; |
99 ngx_str_t smtp_server_name; | |
100 ngx_str_t smtp_greeting; | |
101 | |
102 ngx_uint_t pop3_auth_methods; | |
1502 | 103 ngx_uint_t imap_auth_methods; |
1136 | 104 ngx_uint_t smtp_auth_methods; |
800 | 105 |
583 | 106 ngx_array_t pop3_capabilities; |
107 ngx_array_t imap_capabilities; | |
1136 | 108 ngx_array_t smtp_capabilities; |
527 | 109 |
521 | 110 /* server ctx */ |
1136 | 111 ngx_mail_conf_ctx_t *ctx; |
112 } ngx_mail_core_srv_conf_t; | |
521 | 113 |
114 | |
115 typedef struct { | |
583 | 116 void *(*create_main_conf)(ngx_conf_t *cf); |
117 char *(*init_main_conf)(ngx_conf_t *cf, void *conf); | |
521 | 118 |
583 | 119 void *(*create_srv_conf)(ngx_conf_t *cf); |
120 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, | |
121 void *conf); | |
1136 | 122 } ngx_mail_module_t; |
527 | 123 |
124 | |
125 typedef enum { | |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
126 ngx_pop3_start = 0, |
527 | 127 ngx_pop3_user, |
809 | 128 ngx_pop3_passwd, |
129 ngx_pop3_auth_login_username, | |
130 ngx_pop3_auth_login_password, | |
131 ngx_pop3_auth_plain, | |
132 ngx_pop3_auth_cram_md5 | |
527 | 133 } ngx_po3_state_e; |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
134 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
135 |
1136 | 136 typedef enum { |
137 ngx_imap_start = 0, | |
1502 | 138 ngx_imap_auth_login_username, |
139 ngx_imap_auth_login_password, | |
140 ngx_imap_auth_plain, | |
141 ngx_imap_auth_cram_md5, | |
1136 | 142 ngx_imap_login, |
143 ngx_imap_user, | |
144 ngx_imap_passwd | |
145 } ngx_imap_state_e; | |
146 | |
147 | |
148 typedef enum { | |
149 ngx_smtp_start = 0, | |
150 ngx_smtp_auth_login_username, | |
151 ngx_smtp_auth_login_password, | |
152 ngx_smtp_auth_plain, | |
153 ngx_smtp_auth_cram_md5, | |
154 ngx_smtp_helo, | |
155 ngx_smtp_noxclient, | |
156 ngx_smtp_xclient | |
157 } ngx_smtp_state_e; | |
158 | |
159 | |
418
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
160 typedef struct { |
521 | 161 ngx_peer_connection_t upstream; |
162 ngx_buf_t *buffer; | |
1136 | 163 } ngx_mail_proxy_ctx_t; |
521 | 164 |
165 | |
166 typedef struct { | |
1136 | 167 uint32_t signature; /* "MAIL" */ |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
168 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
169 ngx_connection_t *connection; |
521 | 170 |
539 | 171 ngx_str_t out; |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
172 ngx_buf_t *buffer; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
173 |
521 | 174 void **ctx; |
175 void **main_conf; | |
176 void **srv_conf; | |
177 | |
1136 | 178 ngx_mail_proxy_ctx_t *proxy; |
521 | 179 |
1136 | 180 ngx_uint_t mail_state; |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
181 |
539 | 182 unsigned blocked:1; |
183 unsigned quit:1; | |
1136 | 184 unsigned protocol:2; |
527 | 185 unsigned quoted:1; |
543 | 186 unsigned backslash:1; |
187 unsigned no_sync_literal:1; | |
641 | 188 unsigned starttls:1; |
1136 | 189 unsigned esmtp:1; |
809 | 190 unsigned auth_method:2; |
883 | 191 unsigned auth_wait:1; |
418
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
192 |
422
edaefb2a20fc
nginx-0.0.10-2004-09-12-00:22:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
421
diff
changeset
|
193 ngx_str_t login; |
edaefb2a20fc
nginx-0.0.10-2004-09-12-00:22:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
421
diff
changeset
|
194 ngx_str_t passwd; |
edaefb2a20fc
nginx-0.0.10-2004-09-12-00:22:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
421
diff
changeset
|
195 |
800 | 196 ngx_str_t salt; |
527 | 197 ngx_str_t tag; |
539 | 198 ngx_str_t tagged_line; |
527 | 199 |
641 | 200 ngx_str_t *addr_text; |
1136 | 201 ngx_str_t smtp_helo; |
641 | 202 |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
203 ngx_uint_t command; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
204 ngx_array_t args; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
205 |
527 | 206 ngx_uint_t login_attempt; |
207 | |
1136 | 208 /* used to parse IMAP/POP3/SMTP command */ |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
209 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
210 ngx_uint_t state; |
527 | 211 u_char *cmd_start; |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
212 u_char *arg_start; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
213 u_char *arg_end; |
527 | 214 ngx_uint_t literal_len; |
1136 | 215 } ngx_mail_session_t; |
418
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
216 |
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
217 |
541 | 218 typedef struct { |
583 | 219 ngx_str_t *client; |
1136 | 220 ngx_mail_session_t *session; |
221 } ngx_mail_log_ctx_t; | |
541 | 222 |
223 | |
1502 | 224 #define NGX_POP3_USER 1 |
225 #define NGX_POP3_PASS 2 | |
226 #define NGX_POP3_CAPA 3 | |
227 #define NGX_POP3_QUIT 4 | |
228 #define NGX_POP3_NOOP 5 | |
229 #define NGX_POP3_STLS 6 | |
230 #define NGX_POP3_APOP 7 | |
231 #define NGX_POP3_AUTH 8 | |
232 #define NGX_POP3_STAT 9 | |
233 #define NGX_POP3_LIST 10 | |
234 #define NGX_POP3_RETR 11 | |
235 #define NGX_POP3_DELE 12 | |
236 #define NGX_POP3_RSET 13 | |
237 #define NGX_POP3_TOP 14 | |
238 #define NGX_POP3_UIDL 15 | |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
239 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
240 |
1502 | 241 #define NGX_IMAP_LOGIN 1 |
242 #define NGX_IMAP_LOGOUT 2 | |
243 #define NGX_IMAP_CAPABILITY 3 | |
244 #define NGX_IMAP_NOOP 4 | |
245 #define NGX_IMAP_STARTTLS 5 | |
800 | 246 |
1502 | 247 #define NGX_IMAP_NEXT 6 |
248 | |
249 #define NGX_IMAP_AUTHENTICATE 7 | |
527 | 250 |
800 | 251 |
1502 | 252 #define NGX_SMTP_HELO 1 |
253 #define NGX_SMTP_EHLO 2 | |
254 #define NGX_SMTP_AUTH 3 | |
255 #define NGX_SMTP_QUIT 4 | |
256 #define NGX_SMTP_NOOP 5 | |
257 #define NGX_SMTP_MAIL 6 | |
258 #define NGX_SMTP_RSET 7 | |
259 #define NGX_SMTP_RCPT 8 | |
260 #define NGX_SMTP_DATA 9 | |
261 #define NGX_SMTP_VRFY 10 | |
262 #define NGX_SMTP_EXPN 11 | |
263 #define NGX_SMTP_HELP 12 | |
264 #define NGX_SMTP_STARTTLS 13 | |
527 | 265 |
266 | |
1136 | 267 #define NGX_MAIL_AUTH_PLAIN 0 |
268 #define NGX_MAIL_AUTH_LOGIN 1 | |
269 #define NGX_MAIL_AUTH_APOP 2 | |
270 #define NGX_MAIL_AUTH_CRAM_MD5 3 | |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
271 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
272 |
1136 | 273 #define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002 |
274 #define NGX_MAIL_AUTH_LOGIN_ENABLED 0x0004 | |
275 #define NGX_MAIL_AUTH_APOP_ENABLED 0x0008 | |
276 #define NGX_MAIL_AUTH_CRAM_MD5_ENABLED 0x0010 | |
521 | 277 |
278 | |
1136 | 279 #define NGX_MAIL_PARSE_INVALID_COMMAND 20 |
521 | 280 |
281 | |
1136 | 282 #define NGX_MAIL_MODULE 0x4C49414D /* "MAIL" */ |
283 | |
284 #define NGX_MAIL_MAIN_CONF 0x02000000 | |
285 #define NGX_MAIL_SRV_CONF 0x04000000 | |
286 | |
287 | |
288 #define NGX_MAIL_MAIN_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, main_conf) | |
289 #define NGX_MAIL_SRV_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, srv_conf) | |
290 | |
291 | |
292 #define ngx_mail_get_module_ctx(s, module) (s)->ctx[module.ctx_index] | |
293 #define ngx_mail_set_ctx(s, c, module) s->ctx[module.ctx_index] = c; | |
294 #define ngx_mail_delete_ctx(s, module) s->ctx[module.ctx_index] = NULL; | |
521 | 295 |
296 | |
1136 | 297 #define ngx_mail_get_module_main_conf(s, module) \ |
521 | 298 (s)->main_conf[module.ctx_index] |
1136 | 299 #define ngx_mail_get_module_srv_conf(s, module) (s)->srv_conf[module.ctx_index] |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
300 |
1136 | 301 #define ngx_mail_conf_get_module_main_conf(cf, module) \ |
302 ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] | |
1501 | 303 #define ngx_mail_conf_get_module_srv_conf(cf, module) \ |
304 ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index] | |
641 | 305 |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
306 |
1136 | 307 void ngx_mail_init_connection(ngx_connection_t *c); |
308 void ngx_mail_send(ngx_event_t *wev); | |
527 | 309 void ngx_pop3_auth_state(ngx_event_t *rev); |
1136 | 310 void ngx_imap_auth_state(ngx_event_t *rev); |
311 void ngx_smtp_auth_state(ngx_event_t *rev); | |
312 void ngx_mail_close_connection(ngx_connection_t *c); | |
313 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s); | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
314 |
1136 | 315 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s); |
316 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s); | |
317 ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s); | |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
318 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
319 |
521 | 320 /* STUB */ |
1136 | 321 void ngx_mail_proxy_init(ngx_mail_session_t *s, ngx_peer_addr_t *peer); |
322 void ngx_mail_auth_http_init(ngx_mail_session_t *s); | |
521 | 323 /**/ |
324 | |
325 | |
1136 | 326 extern ngx_uint_t ngx_mail_max_module; |
327 extern ngx_module_t ngx_mail_core_module; | |
521 | 328 |
329 | |
1136 | 330 #endif /* _NGX_MAIL_H_INCLUDED_ */ |