Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ngx_mail.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) Nginx, Inc.
5  */
6 
7 
8 #ifndef _NGX_MAIL_H_INCLUDED_
9 #define _NGX_MAIL_H_INCLUDED_
10 
11 
12 #include <ngx_config.h>
13 #include <ngx_core.h>
14 #include <ngx_event.h>
15 #include <ngx_event_connect.h>
16 
17 #if (NGX_MAIL_SSL)
18 #include <ngx_mail_ssl_module.h>
19 #endif
20 
21 
22 
23 typedef struct {
24  void **main_conf;
25  void **srv_conf;
27 
28 
29 typedef struct {
30  u_char sockaddr[NGX_SOCKADDRLEN];
31  socklen_t socklen;
32 
33  /* server ctx */
35 
36  unsigned bind:1;
37  unsigned wildcard:1;
38 #if (NGX_MAIL_SSL)
39  unsigned ssl:1;
40 #endif
41 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
42  unsigned ipv6only:1;
43 #endif
44  unsigned so_keepalive:2;
45 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
46  int tcp_keepidle;
47  int tcp_keepintvl;
48  int tcp_keepcnt;
49 #endif
51 
52 
53 typedef struct {
56 #if (NGX_MAIL_SSL)
57  ngx_uint_t ssl; /* unsigned ssl:1; */
58 #endif
60 
61 typedef struct {
62  in_addr_t addr;
65 
66 
67 #if (NGX_HAVE_INET6)
68 
69 typedef struct {
70  struct in6_addr addr6;
72 } ngx_mail_in6_addr_t;
73 
74 #endif
75 
76 
77 typedef struct {
78  /* ngx_mail_in_addr_t or ngx_mail_in6_addr_t */
79  void *addrs;
82 
83 
84 typedef struct {
85  int family;
86  in_port_t port;
87  ngx_array_t addrs; /* array of ngx_mail_conf_addr_t */
89 
90 
91 typedef struct {
92  struct sockaddr *sockaddr;
93  socklen_t socklen;
94 
96 
97  unsigned bind:1;
98  unsigned wildcard:1;
99 #if (NGX_MAIL_SSL)
100  unsigned ssl:1;
101 #endif
102 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
103  unsigned ipv6only:1;
104 #endif
105  unsigned so_keepalive:2;
106 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
107  int tcp_keepidle;
108  int tcp_keepintvl;
109  int tcp_keepcnt;
110 #endif
112 
113 
114 typedef struct {
115  ngx_array_t servers; /* ngx_mail_core_srv_conf_t */
116  ngx_array_t listen; /* ngx_mail_listen_t */
118 
119 
120 #define NGX_MAIL_POP3_PROTOCOL 0
121 #define NGX_MAIL_IMAP_PROTOCOL 1
122 #define NGX_MAIL_SMTP_PROTOCOL 2
123 
124 
126 
127 
128 typedef struct {
130 
133 
135 
137 
138  u_char *file_name;
140 
142 
143  /* server ctx */
146 
147 
148 typedef enum {
157 
158 
159 typedef enum {
169 
170 
171 typedef enum {
186 
187 
188 typedef struct {
192 
193 
194 typedef struct {
195  uint32_t signature; /* "MAIL" */
196 
198 
201 
202  void **ctx;
203  void **main_conf;
204  void **srv_conf;
205 
207 
209 
211 
212  unsigned protocol:3;
213  unsigned blocked:1;
214  unsigned quit:1;
215  unsigned quoted:1;
216  unsigned backslash:1;
217  unsigned no_sync_literal:1;
218  unsigned starttls:1;
219  unsigned esmtp:1;
220  unsigned auth_method:3;
221  unsigned auth_wait:1;
222 
225 
230 
236 
239 
241 
242  /* used to parse POP3/IMAP/SMTP command */
243 
245  u_char *cmd_start;
246  u_char *arg_start;
247  u_char *arg_end;
250 
251 
252 typedef struct {
256 
257 
258 #define NGX_POP3_USER 1
259 #define NGX_POP3_PASS 2
260 #define NGX_POP3_CAPA 3
261 #define NGX_POP3_QUIT 4
262 #define NGX_POP3_NOOP 5
263 #define NGX_POP3_STLS 6
264 #define NGX_POP3_APOP 7
265 #define NGX_POP3_AUTH 8
266 #define NGX_POP3_STAT 9
267 #define NGX_POP3_LIST 10
268 #define NGX_POP3_RETR 11
269 #define NGX_POP3_DELE 12
270 #define NGX_POP3_RSET 13
271 #define NGX_POP3_TOP 14
272 #define NGX_POP3_UIDL 15
273 
274 
275 #define NGX_IMAP_LOGIN 1
276 #define NGX_IMAP_LOGOUT 2
277 #define NGX_IMAP_CAPABILITY 3
278 #define NGX_IMAP_NOOP 4
279 #define NGX_IMAP_STARTTLS 5
280 
281 #define NGX_IMAP_NEXT 6
282 
283 #define NGX_IMAP_AUTHENTICATE 7
284 
285 
286 #define NGX_SMTP_HELO 1
287 #define NGX_SMTP_EHLO 2
288 #define NGX_SMTP_AUTH 3
289 #define NGX_SMTP_QUIT 4
290 #define NGX_SMTP_NOOP 5
291 #define NGX_SMTP_MAIL 6
292 #define NGX_SMTP_RSET 7
293 #define NGX_SMTP_RCPT 8
294 #define NGX_SMTP_DATA 9
295 #define NGX_SMTP_VRFY 10
296 #define NGX_SMTP_EXPN 11
297 #define NGX_SMTP_HELP 12
298 #define NGX_SMTP_STARTTLS 13
299 
300 
301 #define NGX_MAIL_AUTH_PLAIN 0
302 #define NGX_MAIL_AUTH_LOGIN 1
303 #define NGX_MAIL_AUTH_LOGIN_USERNAME 2
304 #define NGX_MAIL_AUTH_APOP 3
305 #define NGX_MAIL_AUTH_CRAM_MD5 4
306 #define NGX_MAIL_AUTH_NONE 5
307 
308 
309 #define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002
310 #define NGX_MAIL_AUTH_LOGIN_ENABLED 0x0004
311 #define NGX_MAIL_AUTH_APOP_ENABLED 0x0008
312 #define NGX_MAIL_AUTH_CRAM_MD5_ENABLED 0x0010
313 #define NGX_MAIL_AUTH_NONE_ENABLED 0x0020
314 
315 
316 #define NGX_MAIL_PARSE_INVALID_COMMAND 20
317 
318 
320  ngx_connection_t *c);
322 typedef void (*ngx_mail_auth_state_pt)(ngx_event_t *rev);
324 
325 
328  in_port_t port[4];
330 
335 
337 };
338 
339 
340 typedef struct {
342 
343  void *(*create_main_conf)(ngx_conf_t *cf);
344  char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
345 
346  void *(*create_srv_conf)(ngx_conf_t *cf);
347  char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
348  void *conf);
350 
351 
352 #define NGX_MAIL_MODULE 0x4C49414D /* "MAIL" */
353 
354 #define NGX_MAIL_MAIN_CONF 0x02000000
355 #define NGX_MAIL_SRV_CONF 0x04000000
356 
357 
358 #define NGX_MAIL_MAIN_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, main_conf)
359 #define NGX_MAIL_SRV_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, srv_conf)
360 
361 
362 #define ngx_mail_get_module_ctx(s, module) (s)->ctx[module.ctx_index]
363 #define ngx_mail_set_ctx(s, c, module) s->ctx[module.ctx_index] = c;
364 #define ngx_mail_delete_ctx(s, module) s->ctx[module.ctx_index] = NULL;
365 
366 
367 #define ngx_mail_get_module_main_conf(s, module) \
368  (s)->main_conf[module.ctx_index]
369 #define ngx_mail_get_module_srv_conf(s, module) (s)->srv_conf[module.ctx_index]
370 
371 #define ngx_mail_conf_get_module_main_conf(cf, module) \
372  ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
373 #define ngx_mail_conf_get_module_srv_conf(cf, module) \
374  ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
375 
376 
377 #if (NGX_MAIL_SSL)
378 void ngx_mail_starttls_handler(ngx_event_t *rev);
379 ngx_int_t ngx_mail_starttls_only(ngx_mail_session_t *s, ngx_connection_t *c);
380 #endif
381 
382 
384 
388  ngx_uint_t n);
392  ngx_connection_t *c);
394  ngx_connection_t *c, char *prefix, size_t len);
397 
398 void ngx_mail_send(ngx_event_t *wev);
403 u_char *ngx_mail_log_error(ngx_log_t *log, u_char *buf, size_t len);
404 
405 
406 char *ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
407 
408 
409 /* STUB */
412 
413 
414 
417 
418 
419 #endif /* _NGX_MAIL_H_INCLUDED_ */