Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail.h @ 1156:a9005d2e2c99
style fix
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 02 Apr 2007 05:43:21 +0000 |
parents | 68f30ab68bb7 |
children | 27f2299e0d80 |
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; |
800 | 95 |
1136 | 96 ngx_str_t server_name; |
97 ngx_str_t smtp_server_name; | |
98 ngx_str_t smtp_greeting; | |
99 | |
100 ngx_uint_t pop3_auth_methods; | |
101 ngx_uint_t smtp_auth_methods; | |
800 | 102 |
583 | 103 ngx_array_t pop3_capabilities; |
104 ngx_array_t imap_capabilities; | |
1136 | 105 ngx_array_t smtp_capabilities; |
527 | 106 |
521 | 107 /* server ctx */ |
1136 | 108 ngx_mail_conf_ctx_t *ctx; |
109 } ngx_mail_core_srv_conf_t; | |
521 | 110 |
111 | |
112 typedef struct { | |
583 | 113 void *(*create_main_conf)(ngx_conf_t *cf); |
114 char *(*init_main_conf)(ngx_conf_t *cf, void *conf); | |
521 | 115 |
583 | 116 void *(*create_srv_conf)(ngx_conf_t *cf); |
117 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, | |
118 void *conf); | |
1136 | 119 } ngx_mail_module_t; |
527 | 120 |
121 | |
122 typedef enum { | |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
123 ngx_pop3_start = 0, |
527 | 124 ngx_pop3_user, |
809 | 125 ngx_pop3_passwd, |
126 ngx_pop3_auth_login_username, | |
127 ngx_pop3_auth_login_password, | |
128 ngx_pop3_auth_plain, | |
129 ngx_pop3_auth_cram_md5 | |
527 | 130 } 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
|
131 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
132 |
1136 | 133 typedef enum { |
134 ngx_imap_start = 0, | |
135 ngx_imap_login, | |
136 ngx_imap_user, | |
137 ngx_imap_passwd | |
138 } ngx_imap_state_e; | |
139 | |
140 | |
141 typedef enum { | |
142 ngx_smtp_start = 0, | |
143 ngx_smtp_auth_login_username, | |
144 ngx_smtp_auth_login_password, | |
145 ngx_smtp_auth_plain, | |
146 ngx_smtp_auth_cram_md5, | |
147 ngx_smtp_helo, | |
148 ngx_smtp_noxclient, | |
149 ngx_smtp_xclient | |
150 } ngx_smtp_state_e; | |
151 | |
152 | |
418
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
153 typedef struct { |
521 | 154 ngx_peer_connection_t upstream; |
155 ngx_buf_t *buffer; | |
1136 | 156 } ngx_mail_proxy_ctx_t; |
521 | 157 |
158 | |
159 typedef struct { | |
1136 | 160 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
|
161 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
162 ngx_connection_t *connection; |
521 | 163 |
539 | 164 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
|
165 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
|
166 |
521 | 167 void **ctx; |
168 void **main_conf; | |
169 void **srv_conf; | |
170 | |
1136 | 171 ngx_mail_proxy_ctx_t *proxy; |
521 | 172 |
1136 | 173 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
|
174 |
539 | 175 unsigned blocked:1; |
176 unsigned quit:1; | |
1136 | 177 unsigned protocol:2; |
527 | 178 unsigned quoted:1; |
543 | 179 unsigned backslash:1; |
180 unsigned no_sync_literal:1; | |
641 | 181 unsigned starttls:1; |
1136 | 182 unsigned esmtp:1; |
809 | 183 unsigned auth_method:2; |
883 | 184 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
|
185 |
422
edaefb2a20fc
nginx-0.0.10-2004-09-12-00:22:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
421
diff
changeset
|
186 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
|
187 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
|
188 |
800 | 189 ngx_str_t salt; |
527 | 190 ngx_str_t tag; |
539 | 191 ngx_str_t tagged_line; |
527 | 192 |
641 | 193 ngx_str_t *addr_text; |
1136 | 194 ngx_str_t smtp_helo; |
641 | 195 |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
196 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
|
197 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
|
198 |
527 | 199 ngx_uint_t login_attempt; |
200 | |
1136 | 201 /* 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
|
202 |
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 state; |
527 | 204 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
|
205 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
|
206 u_char *arg_end; |
527 | 207 ngx_uint_t literal_len; |
1136 | 208 } 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
|
209 |
cf072d26d6d6
nginx-0.0.10-2004-09-08-09:18:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
210 |
541 | 211 typedef struct { |
583 | 212 ngx_str_t *client; |
1136 | 213 ngx_mail_session_t *session; |
214 } ngx_mail_log_ctx_t; | |
541 | 215 |
216 | |
800 | 217 #define NGX_POP3_USER 1 |
218 #define NGX_POP3_PASS 2 | |
219 #define NGX_POP3_CAPA 3 | |
220 #define NGX_POP3_QUIT 4 | |
221 #define NGX_POP3_NOOP 5 | |
222 #define NGX_POP3_STLS 6 | |
223 #define NGX_POP3_APOP 7 | |
809 | 224 #define NGX_POP3_AUTH 8 |
225 #define NGX_POP3_STAT 9 | |
226 #define NGX_POP3_LIST 10 | |
227 #define NGX_POP3_RETR 11 | |
228 #define NGX_POP3_DELE 12 | |
229 #define NGX_POP3_RSET 13 | |
230 #define NGX_POP3_TOP 14 | |
231 #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
|
232 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
233 |
800 | 234 #define NGX_IMAP_LOGIN 1 |
235 #define NGX_IMAP_LOGOUT 2 | |
236 #define NGX_IMAP_CAPABILITY 3 | |
237 #define NGX_IMAP_NOOP 4 | |
238 #define NGX_IMAP_STARTTLS 5 | |
239 | |
240 #define NGX_IMAP_NEXT 6 | |
527 | 241 |
800 | 242 |
1136 | 243 #define NGX_SMTP_HELO 1 |
244 #define NGX_SMTP_EHLO 2 | |
245 #define NGX_SMTP_AUTH 3 | |
246 #define NGX_SMTP_QUIT 4 | |
247 #define NGX_SMTP_NOOP 5 | |
248 #define NGX_SMTP_MAIL 6 | |
249 #define NGX_SMTP_RSET 7 | |
527 | 250 |
251 | |
1136 | 252 #define NGX_MAIL_AUTH_PLAIN 0 |
253 #define NGX_MAIL_AUTH_LOGIN 1 | |
254 #define NGX_MAIL_AUTH_APOP 2 | |
255 #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
|
256 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
257 |
1136 | 258 #define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002 |
259 #define NGX_MAIL_AUTH_LOGIN_ENABLED 0x0004 | |
260 #define NGX_MAIL_AUTH_APOP_ENABLED 0x0008 | |
261 #define NGX_MAIL_AUTH_CRAM_MD5_ENABLED 0x0010 | |
521 | 262 |
263 | |
1136 | 264 #define NGX_MAIL_PARSE_INVALID_COMMAND 20 |
521 | 265 |
266 | |
1136 | 267 #define NGX_MAIL_MODULE 0x4C49414D /* "MAIL" */ |
268 | |
269 #define NGX_MAIL_MAIN_CONF 0x02000000 | |
270 #define NGX_MAIL_SRV_CONF 0x04000000 | |
271 | |
272 | |
273 #define NGX_MAIL_MAIN_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, main_conf) | |
274 #define NGX_MAIL_SRV_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, srv_conf) | |
275 | |
276 | |
277 #define ngx_mail_get_module_ctx(s, module) (s)->ctx[module.ctx_index] | |
278 #define ngx_mail_set_ctx(s, c, module) s->ctx[module.ctx_index] = c; | |
279 #define ngx_mail_delete_ctx(s, module) s->ctx[module.ctx_index] = NULL; | |
521 | 280 |
281 | |
1136 | 282 #define ngx_mail_get_module_main_conf(s, module) \ |
521 | 283 (s)->main_conf[module.ctx_index] |
1136 | 284 #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
|
285 |
1136 | 286 #define ngx_mail_conf_get_module_main_conf(cf, module) \ |
287 ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] | |
641 | 288 |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
289 |
1136 | 290 void ngx_mail_init_connection(ngx_connection_t *c); |
291 void ngx_mail_send(ngx_event_t *wev); | |
527 | 292 void ngx_pop3_auth_state(ngx_event_t *rev); |
1136 | 293 void ngx_imap_auth_state(ngx_event_t *rev); |
294 void ngx_smtp_auth_state(ngx_event_t *rev); | |
295 void ngx_mail_close_connection(ngx_connection_t *c); | |
296 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
|
297 |
1136 | 298 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s); |
299 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s); | |
300 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
|
301 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 |
521 | 303 /* STUB */ |
1136 | 304 void ngx_mail_proxy_init(ngx_mail_session_t *s, ngx_peer_addr_t *peer); |
305 void ngx_mail_auth_http_init(ngx_mail_session_t *s); | |
521 | 306 /**/ |
307 | |
308 | |
1136 | 309 extern ngx_uint_t ngx_mail_max_module; |
310 extern ngx_module_t ngx_mail_core_module; | |
521 | 311 |
312 | |
1136 | 313 #endif /* _NGX_MAIL_H_INCLUDED_ */ |