2b449a6485e279fe22660589354ef210f8f838de
[exim.git] / src / src / structs.h
1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2015 */
6 /* See the file NOTICE for conditions of use and distribution. */
7
8
9 /* Definitions of various structures. In addition, those that are visible for
10 the compilation of local_scan() are defined in local_scan.h. These are
11
12 header_line
13 optionlist
14 recipient_item
15
16 For those declared here, we have to pre-declare some because of mutually
17 recursive definitions in the auths, routers, and transports blocks. */
18
19 struct address_item;
20 struct auth_info;
21 struct driver_info;
22 struct director_info;
23 struct smtp_inblock;
24 struct smtp_outblock;
25 struct transport_info;
26 struct router_info;
27
28 /* Structure for remembering macros for the configuration file */
29
30 typedef struct macro_item {
31 struct macro_item *next;
32 BOOL command_line;
33 uschar *replacement;
34 uschar name[1];
35 } macro_item;
36
37 /* Structure for bit tables for debugging and logging */
38
39 typedef struct bit_table {
40 uschar *name;
41 int bit;
42 } bit_table;
43
44 /* Block for holding a uid and gid, possibly unset, and an initgroups flag. */
45
46 typedef struct ugid_block {
47 uid_t uid;
48 gid_t gid;
49 BOOL uid_set;
50 BOOL gid_set;
51 BOOL initgroups;
52 } ugid_block;
53
54 typedef enum {CHUNKING_NOT_OFFERED, CHUNKING_OFFERED, CHUNKING_ACTIVE, CHUNKING_LAST} chunking_state_t;
55
56 /* Structure for holding information about a host for use mainly by routers,
57 but also used when checking lists of hosts and when transporting. Looking up
58 host addresses is done using this structure. */
59
60 typedef enum {DS_UNK=-1, DS_NO, DS_YES} dnssec_status_t;
61
62 typedef struct host_item {
63 struct host_item *next;
64 const uschar *name; /* Host name */
65 const uschar *address; /* IP address in text form */
66 int port; /* port value in host order (if SRV lookup) */
67 int mx; /* MX value if found via MX records */
68 int sort_key; /* MX*1000 plus random "fraction" */
69 int status; /* Usable, unusable, or unknown */
70 int why; /* Why host is unusable */
71 int last_try; /* Time of last try if known */
72 dnssec_status_t dnssec;
73 } host_item;
74
75 /* Chain of rewrite rules, read from the rewrite config, or parsed from the
76 rewrite_headers field of a transport. */
77
78 typedef struct rewrite_rule {
79 struct rewrite_rule *next;
80 int flags;
81 uschar *key;
82 uschar *replacement;
83 } rewrite_rule;
84
85 /* This structure is used to pass back configuration data from the smtp
86 transport to the outside world. It is used during callback processing. If ever
87 another remote transport were implemented, it could use the same structure. */
88
89 typedef struct transport_feedback {
90 uschar *interface;
91 uschar *port;
92 uschar *protocol;
93 uschar *hosts;
94 uschar *helo_data;
95 BOOL hosts_override;
96 BOOL hosts_randomize;
97 BOOL gethostbyname;
98 BOOL qualify_single;
99 BOOL search_parents;
100 } transport_feedback;
101
102 /* Routers, transports, and authenticators have similar data blocks. Each
103 driver that is compiled into the code is represented by a xxx_info block; the
104 active drivers are represented by a chain of xxx_instance blocks. To make it
105 possible to use the same code for reading the configuration files for all
106 three, the layout of the start of the blocks is kept the same, and represented
107 by the generic structures driver_info and driver_instance. */
108
109 typedef struct driver_instance {
110 struct driver_instance *next;
111 uschar *name; /* Instance name */
112 struct driver_info *info; /* Points to info for this driver */
113 void *options_block; /* Pointer to private options */
114 uschar *driver_name; /* All start with this generic option */
115 } driver_instance;
116
117 typedef struct driver_info {
118 uschar *driver_name; /* Name of driver */
119 optionlist *options; /* Table of private options names */
120 int *options_count; /* -> Number of entries in table */
121 void *options_block; /* Points to default private block */
122 int options_len; /* Length of same in bytes */
123 void (*init)( /* Initialization entry point */
124 struct driver_instance *);
125 } driver_info;
126
127
128 /* Structure for holding information about the configured transports. Some
129 of the generally accessible options are set from the configuration file; others
130 are set by transport initialization, since they can only be set for certain
131 transports. They need to be generally accessible, however, as they are used by
132 the main transport code. */
133
134 typedef struct transport_instance {
135 struct transport_instance *next;
136 uschar *name; /* Instance name */
137 struct transport_info *info; /* Info for this driver */
138 void *options_block; /* Pointer to private options */
139 uschar *driver_name; /* Must be first */
140 int (*setup)( /* Setup entry point */
141 struct transport_instance *,
142 struct address_item *,
143 struct transport_feedback *, /* For passing back config data */
144 uid_t, /* The uid that will be used */
145 gid_t, /* The gid that will be used */
146 uschar **); /* For an error message */
147 /**************************************/
148 int batch_max; /* ) */
149 uschar *batch_id; /* ) */
150 uschar *home_dir; /* ) Used only for local transports */
151 uschar *current_dir; /* ) */
152 /**************************************/
153 uschar *expand_multi_domain; /* ) */
154 BOOL multi_domain; /* ) */
155 BOOL overrides_hosts; /* ) Used only for remote transports */
156 int max_addresses; /* ) */
157 int connection_max_messages;/* ) */
158 /**************************************/
159 BOOL deliver_as_creator; /* Used only by pipe at present */
160 BOOL disable_logging; /* For very weird requirements */
161 BOOL initgroups; /* Initialize groups when setting uid */
162 BOOL uid_set; /* uid is set */
163 BOOL gid_set; /* gid is set */
164 uid_t uid;
165 gid_t gid;
166 uschar *expand_uid; /* Variable uid */
167 uschar *expand_gid; /* Variable gid */
168 uschar *warn_message; /* Used only by appendfile at present */
169 uschar *shadow; /* Name of shadow transport */
170 uschar *shadow_condition; /* Condition for running it */
171 uschar *filter_command; /* For on-the-fly-filtering */
172 uschar *add_headers; /* Add these headers */
173 uschar *remove_headers; /* Remove these headers */
174 uschar *return_path; /* Overriding (rewriting) return path */
175 uschar *debug_string; /* Debugging output */
176 uschar *max_parallel; /* Number of concurrent instances */
177 uschar *message_size_limit; /* Biggest message this transport handles */
178 uschar *headers_rewrite; /* Rules for rewriting headers */
179 rewrite_rule *rewrite_rules; /* Parsed rewriting rules */
180 int rewrite_existflags; /* Bits showing which headers are rewritten */
181 int filter_timeout; /* For transport filter timing */
182 BOOL body_only; /* Deliver only the body */
183 BOOL delivery_date_add; /* Add Delivery-Date header */
184 BOOL envelope_to_add; /* Add Envelope-To header */
185 BOOL headers_only; /* Deliver only the headers */
186 BOOL rcpt_include_affixes; /* TRUE to retain affixes in RCPT commands */
187 BOOL return_path_add; /* Add Return-Path header */
188 BOOL return_output; /* TRUE if output should always be returned */
189 BOOL return_fail_output; /* ditto, but only on failure */
190 BOOL log_output; /* Similarly for logging */
191 BOOL log_fail_output;
192 BOOL log_defer_output;
193 BOOL retry_use_local_part; /* Defaults true for local, false for remote */
194 #ifndef DISABLE_EVENT
195 uschar *event_action; /* String to expand on notable events */
196 #endif
197 } transport_instance;
198
199
200 /* Structure for holding information about a type of transport. The first six
201 fields must match driver_info above. */
202
203 typedef struct transport_info {
204 uschar *driver_name; /* Driver name */
205 optionlist *options; /* Table of private options names */
206 int *options_count; /* -> Number of entries in table */
207 void *options_block; /* Points to default private block */
208 int options_len; /* Length of same in bytes */
209 void (*init)( /* Initialization function */
210 struct transport_instance *);
211 /****/
212 BOOL (*code)( /* Main entry point */
213 transport_instance *,
214 struct address_item *);
215 void (*tidyup)( /* Tidyup function */
216 struct transport_instance *);
217 void (*closedown)( /* For closing down a passed channel */
218 struct transport_instance *);
219 BOOL local; /* TRUE for local transports */
220 } transport_info;
221
222
223
224 typedef struct {
225 uschar *request;
226 uschar *require;
227 } dnssec_domains;
228
229 /* Structure for holding information about the configured routers. */
230
231 typedef struct router_instance {
232 struct router_instance *next;
233 uschar *name;
234 struct router_info *info;
235 void *options_block; /* Pointer to private options */
236 uschar *driver_name; /* Must be first */
237
238 uschar *address_data; /* Arbitrary data */
239 #ifdef EXPERIMENTAL_BRIGHTMAIL
240 uschar *bmi_rule; /* Brightmail AntiSpam rule checking */
241 #endif
242 uschar *cannot_route_message; /* Used when routing fails */
243 uschar *condition; /* General condition */
244 uschar *current_directory; /* For use during delivery */
245 uschar *debug_string; /* Debugging output */
246 uschar *domains; /* Specific domains */
247 uschar *errors_to; /* Errors address */
248 uschar *expand_gid; /* Expanded gid string */
249 uschar *expand_uid; /* Expanded uid string */
250 uschar *expand_more; /* Expanded more string */
251 uschar *expand_unseen; /* Expanded unseen string */
252 uschar *extra_headers; /* Additional headers */
253 uschar *fallback_hosts; /* For remote transports (text list) */
254 uschar *home_directory; /* For use during delivery */
255 uschar *ignore_target_hosts; /* Target hosts to ignore */
256 uschar *local_parts; /* Specific local parts */
257 uschar *pass_router_name; /* Router for passed address */
258 uschar *prefix; /* Address prefix */
259 uschar *redirect_router_name; /* Router for generated address */
260 uschar *remove_headers; /* Removed headers */
261 uschar *require_files; /* File checks before router is run */
262 uschar *router_home_directory; /* For use while routing */
263 uschar *self; /* Text option for handling self reference */
264 uschar *senders; /* Specific senders */
265 uschar *suffix; /* Address suffix */
266 uschar *translate_ip_address; /* IP address translation fudgery */
267 uschar *transport_name; /* Transport name */
268
269 BOOL address_test; /* Use this router when testing addresses */
270 #ifdef EXPERIMENTAL_BRIGHTMAIL
271 BOOL bmi_deliver_alternate; /* TRUE => BMI said that message should be delivered to alternate location */
272 BOOL bmi_deliver_default; /* TRUE => BMI said that message should be delivered to default location */
273 BOOL bmi_dont_deliver; /* TRUE => BMI said that message should not be delivered at all */
274 #endif
275 BOOL expn; /* Use this router when processing EXPN */
276 BOOL caseful_local_part; /* TRUE => don't lowercase */
277 BOOL check_local_user; /* TRUE => check local user */
278 BOOL disable_logging; /* For very weird requirements */
279 BOOL fail_verify_recipient; /* Fail verify if recipient match this router */
280 BOOL fail_verify_sender; /* Fail verify if sender match this router */
281 BOOL gid_set; /* Flag to indicate gid is set */
282 BOOL initgroups; /* TRUE if initgroups is required */
283 BOOL log_as_local; /* TRUE logs as a local delivery */
284 BOOL more; /* If FALSE, do no more if this one fails */
285 BOOL pass_on_timeout; /* Treat timeout DEFERs as fails */
286 BOOL prefix_optional; /* Just what it says */
287 BOOL repeat_use; /* If FALSE, skip if ancestor used it */
288 BOOL retry_use_local_part; /* Just what it says */
289 BOOL same_domain_copy_routing; /* TRUE => copy routing for same domain */
290 BOOL self_rewrite; /* TRUE to rewrite headers if making local */
291 BOOL suffix_optional; /* As it says */
292 BOOL verify_only; /* Skip this router if not verifying */
293 BOOL verify_recipient; /* Use this router when verifying a recipient*/
294 BOOL verify_sender; /* Use this router when verifying a sender */
295 BOOL uid_set; /* Flag to indicate uid is set */
296 BOOL unseen; /* If TRUE carry on, even after success */
297 BOOL dsn_lasthop; /* If TRUE, this router is a DSN endpoint */
298
299 int self_code; /* Encoded version of "self" */
300 uid_t uid; /* Fixed uid value */
301 gid_t gid; /* Fixed gid value */
302
303 host_item *fallback_hostlist; /* For remote transport (block chain) */
304 transport_instance *transport; /* Transport block (when found) */
305 struct router_instance *pass_router; /* Actual router for passed address */
306 struct router_instance *redirect_router; /* Actual router for generated address */
307
308 dnssec_domains dnssec;
309 } router_instance;
310
311
312 /* Structure for holding information about a type of router. The first six
313 fields must match driver_info above. */
314
315 typedef struct router_info {
316 uschar *driver_name;
317 optionlist *options; /* Table of private options names */
318 int *options_count; /* -> Number of entries in table */
319 void *options_block; /* Points to default private block */
320 int options_len; /* Length of same in bytes */
321 void (*init)( /* Initialization function */
322 struct router_instance *);
323 /****/
324 int (*code)( /* Main entry point */
325 router_instance *,
326 struct address_item *,
327 struct passwd *,
328 int,
329 struct address_item **,
330 struct address_item **,
331 struct address_item **,
332 struct address_item **);
333 void (*tidyup)( /* Tidyup function */
334 struct router_instance *);
335 int ri_flags; /* Descriptive flags */
336 } router_info;
337
338
339 /* Structure for holding information about a lookup type. */
340
341 #include "lookupapi.h"
342
343
344 /* Structure for holding information about the configured authentication
345 mechanisms */
346
347 typedef struct auth_instance {
348 struct auth_instance *next;
349 uschar *name; /* Exim instance name */
350 struct auth_info *info; /* Pointer to driver info block */
351 void *options_block; /* Pointer to private options */
352 uschar *driver_name; /* Must be first */
353 uschar *advertise_condition; /* Are we going to advertise this?*/
354 uschar *client_condition; /* Should the client try this? */
355 uschar *public_name; /* Advertised name */
356 uschar *set_id; /* String to set when server as authenticated id */
357 uschar *set_client_id; /* String to set when client as client_authenticated id */
358 uschar *mail_auth_condition; /* Condition for AUTH on MAIL command */
359 uschar *server_debug_string; /* Debugging output */
360 uschar *server_condition; /* Authorization condition */
361 BOOL client; /* TRUE if client option(s) set */
362 BOOL server; /* TRUE if server options(s) set */
363 BOOL advertised; /* Set TRUE when advertised */
364 } auth_instance;
365
366
367 /* Structure for holding information about an authentication mechanism. The
368 first six fields must match driver_info above. */
369
370 typedef struct auth_info {
371 uschar *driver_name; /* e.g. "condition" */
372 optionlist *options; /* Table of private options names */
373 int *options_count; /* -> Number of entries in table */
374 void *options_block; /* Points to default private block */
375 int options_len; /* Length of same in bytes */
376 void (*init)( /* initialization function */
377 struct auth_instance *);
378 /****/
379 int (*servercode)( /* server function */
380 auth_instance *, /* the instance data */
381 uschar *); /* rest of AUTH command */
382 int (*clientcode)( /* client function */
383 struct auth_instance *,
384 struct smtp_inblock *, /* socket and input buffer */
385 struct smtp_outblock *, /* socket and output buffer */
386 int, /* command timeout */
387 uschar *, /* buffer for reading response */
388 int); /* sizeof buffer */
389 void (*version_report)( /* diagnostic version reporting */
390 FILE *); /* I/O stream to print to */
391 } auth_info;
392
393
394 /* Structure for holding a single IP address and port; used for the chain of
395 addresses and ports for the local host. Make the char string large enough to
396 hold an IPv6 address. */
397
398 typedef struct ip_address_item {
399 struct ip_address_item *next;
400 int port;
401 BOOL v6_include_v4; /* Used in the daemon */
402 uschar address[46];
403 } ip_address_item;
404
405 /* Structure for chaining together arbitrary strings. */
406
407 typedef struct string_item {
408 struct string_item *next;
409 uschar *text;
410 } string_item;
411
412 /* Information about a soft delivery failure, for use when calculating
413 retry information. It's separate from the address block, because there
414 can be a chain of them for SMTP deliveries where multiple IP addresses
415 can be tried. */
416
417 typedef struct retry_item {
418 struct retry_item *next; /* for chaining */
419 uschar *key; /* string identifying host/address/message */
420 int basic_errno; /* error code for this destination */
421 int more_errno; /* additional error information */
422 uschar *message; /* local error message */
423 int flags; /* see below */
424 } retry_item;
425
426 /* Retry data flags */
427
428 #define rf_delete 0x0001 /* retry info is to be deleted */
429 #define rf_host 0x0002 /* retry info is for a remote host */
430 #define rf_message 0x0004 /* retry info is for a host+message */
431
432 /* Information about a constructed message that is to be sent using the
433 autoreply transport. This is pointed to from the address block. */
434
435 typedef struct reply_item {
436 uschar *from; /* ) */
437 uschar *reply_to; /* ) */
438 uschar *to; /* ) */
439 uschar *cc; /* ) specific header fields */
440 uschar *bcc; /* ) */
441 uschar *subject; /* ) */
442 uschar *headers; /* misc other headers, concatenated */
443 uschar *text; /* text string body */
444 uschar *file; /* file body */
445 BOOL file_expand; /* expand the body */
446 int expand_forbid; /* expansion lockout flags */
447 uschar *logfile; /* file to keep a log in */
448 uschar *oncelog; /* file to keep records in for once only */
449 time_t once_repeat; /* time to repeat "once only" */
450 BOOL return_message; /* send back the original message */
451 } reply_item;
452
453
454 /* The address_item structure contains many fields which are used at various
455 times while delivering a message. Some are used only for remote deliveries;
456 some only for local. A particular set of fields is copied whenever a child
457 address is created. For convenience, we keep those fields in a separate
458 sub-structure so they can be copied in one go. This also means I won't forget
459 to edit the various copying places when new to-be-copied fields are added. */
460
461 typedef struct address_item_propagated {
462 uschar *address_data; /* arbitrary data to keep with the address */
463 uschar *domain_data; /* from "domains" lookup */
464 uschar *localpart_data; /* from "local_parts" lookup */
465 uschar *errors_address; /* where to send errors (NULL => sender) */
466 header_line *extra_headers; /* additional headers */
467 uschar *remove_headers; /* list of those to remove */
468
469 #ifdef EXPERIMENTAL_SRS
470 uschar *srs_sender; /* Change return path when delivering */
471 #endif
472 #ifdef SUPPORT_I18N
473 BOOL utf8_msg:1; /* requires SMTPUTF8 processing */
474 BOOL utf8_downcvt:1; /* mandatory downconvert on delivery */
475 BOOL utf8_downcvt_maybe:1; /* optional downconvert on delivery */
476 #endif
477 } address_item_propagated;
478
479 /* Bits for the flags field below */
480
481 #define af_allow_file 0x00000001 /* allow file in generated address */
482 #define af_allow_pipe 0x00000002 /* allow pipe in generated address */
483 #define af_allow_reply 0x00000004 /* allow autoreply in generated address */
484 #define af_dr_retry_exists 0x00000008 /* router retry record exists */
485 #define af_expand_pipe 0x00000010 /* expand pipe arguments */
486 #define af_file 0x00000020 /* file delivery; always with pfr */
487 #define af_gid_set 0x00000040 /* gid field is set */
488 #define af_home_expanded 0x00000080 /* home_dir is already expanded */
489 #define af_ignore_error 0x00000100 /* ignore delivery error */
490 #define af_initgroups 0x00000200 /* use initgroups() for local transporting */
491 #define af_local_host_removed 0x00000400 /* local host was backup */
492 #define af_lt_retry_exists 0x00000800 /* local transport retry exists */
493 #define af_pfr 0x00001000 /* pipe or file or reply delivery */
494 #define af_retry_skipped 0x00002000 /* true if retry caused some skipping */
495 #define af_retry_timedout 0x00004000 /* true if retry timed out */
496 #define af_uid_set 0x00008000 /* uid field is set */
497 #define af_hide_child 0x00010000 /* hide child in bounce/defer msgs */
498 #define af_sverify_told 0x00020000 /* sender verify failure notified */
499 #define af_verify_pmfail 0x00040000 /* verify failure was postmaster callout */
500 #define af_verify_nsfail 0x00080000 /* verify failure was null sender callout */
501 #define af_homonym 0x00100000 /* an ancestor has same address */
502 #define af_verify_routed 0x00200000 /* for cached sender verify: routed OK */
503 #define af_verify_callout 0x00400000 /* for cached sender verify: callout was specified */
504 #define af_include_affixes 0x00800000 /* delivered with affixes in RCPT */
505 #define af_cert_verified 0x01000000 /* delivered with verified TLS cert */
506 #define af_pass_message 0x02000000 /* pass message in bounces */
507 #define af_bad_reply 0x04000000 /* filter could not generate autoreply */
508 #ifndef DISABLE_PRDR
509 # define af_prdr_used 0x08000000 /* delivery used SMTP PRDR */
510 #endif
511 #define af_force_command 0x10000000 /* force_command in pipe transport */
512 #ifdef EXPERIMENTAL_DANE
513 # define af_dane_verified 0x20000000 /* TLS cert verify done with DANE */
514 #endif
515 #ifdef SUPPORT_I18N
516 # define af_utf8_downcvt 0x40000000 /* downconvert was done for delivery */
517 #endif
518
519 /* These flags must be propagated when a child is created */
520
521 #define af_propagate (af_ignore_error)
522
523 /* The main address structure. Note that fields that are to be copied to
524 generated addresses should be put in the address_item_propagated structure (see
525 above) rather than directly into the address_item structure. */
526
527 typedef struct address_item {
528 struct address_item *next; /* for chaining addresses */
529 struct address_item *parent; /* parent address */
530 struct address_item *first; /* points to first after group delivery */
531 struct address_item *dupof; /* points to address this is a duplicate of */
532
533 router_instance *start_router; /* generated address starts here */
534 router_instance *router; /* the router that routed */
535 transport_instance *transport; /* the transport to use */
536
537 host_item *host_list; /* host data for the transport */
538 host_item *host_used; /* host that took delivery or failed hard */
539 host_item *fallback_hosts; /* to try if delivery defers */
540
541 reply_item *reply; /* data for autoreply */
542 retry_item *retries; /* chain of retry information */
543
544 uschar *address; /* address being delivered or routed */
545 uschar *unique; /* used for disambiguating */
546 uschar *cc_local_part; /* caseful local part */
547 uschar *lc_local_part; /* lowercased local part */
548 uschar *local_part; /* points to cc or lc version */
549 uschar *prefix; /* stripped prefix of local part */
550 uschar *suffix; /* stripped suffix of local part */
551 const uschar *domain; /* working domain (lower cased) */
552
553 uschar *address_retry_key; /* retry key including full address */
554 uschar *domain_retry_key; /* retry key for domain only */
555
556 uschar *current_dir; /* current directory for transporting */
557 uschar *home_dir; /* home directory for transporting */
558 uschar *message; /* error message */
559 uschar *user_message; /* error message that can be sent over SMTP
560 or quoted in bounce message */
561 uschar *onetime_parent; /* saved original parent for onetime */
562 uschar **pipe_expandn; /* numeric expansions for pipe from filter */
563 uschar *return_filename; /* name of return file */
564 uschar *self_hostname; /* after self=pass */
565 uschar *shadow_message; /* info about shadow transporting */
566
567 #ifdef SUPPORT_TLS
568 uschar *cipher; /* Cipher used for transport */
569 void *ourcert; /* Certificate offered to peer, binary */
570 void *peercert; /* Certificate from peer, binary */
571 uschar *peerdn; /* DN of server's certificate */
572 int ocsp; /* OCSP status of peer cert */
573 #endif
574
575 #ifdef EXPERIMENTAL_DSN_INFO
576 const uschar *smtp_greeting; /* peer self-identification */
577 const uschar *helo_response; /* peer message */
578 #endif
579
580 uschar *authenticator; /* auth driver name used by transport */
581 uschar *auth_id; /* auth "login" name used by transport */
582 uschar *auth_sndr; /* AUTH arg to SMTP MAIL, used by transport */
583
584 uschar *dsn_orcpt; /* DSN orcpt value */
585 int dsn_flags; /* DSN flags */
586 int dsn_aware; /* DSN aware flag */
587
588 uid_t uid; /* uid for transporting */
589 gid_t gid; /* gid for transporting */
590
591 unsigned int flags; /* a row of bits, defined above */
592 unsigned int domain_cache[(MAX_NAMED_LIST * 2)/32];
593 unsigned int localpart_cache[(MAX_NAMED_LIST * 2)/32];
594 int mode; /* mode for local transporting to a file */
595 int more_errno; /* additional error information */
596 /* (may need to hold a timestamp) */
597
598 short int basic_errno; /* status after failure */
599 short int child_count; /* number of child addresses */
600 short int return_file; /* fileno of return data file */
601 short int special_action; /* ( used when when deferred or failed */
602 /* ( also */
603 /* ( contains = or - when successful SMTP delivered */
604 /* ( also */
605 /* ( contains verify rc in sender verify cache */
606 short int transport_return; /* result of delivery attempt */
607 address_item_propagated prop; /* fields that are propagated to children */
608 } address_item;
609
610 /* The table of header names consists of items of this type */
611
612 typedef struct {
613 uschar *name;
614 int len;
615 BOOL allow_resent;
616 int htype;
617 } header_name;
618
619 /* Chain of information about errors (e.g. bad addresses) */
620
621 typedef struct error_block {
622 struct error_block *next;
623 const uschar *text1;
624 uschar *text2;
625 } error_block;
626
627 /* Chain of file names when processing the queue */
628
629 typedef struct queue_filename {
630 struct queue_filename *next;
631 uschar dir_uschar;
632 uschar text[1];
633 } queue_filename;
634
635 /* Chain of items of retry information, read from the retry config. */
636
637 typedef struct retry_rule {
638 struct retry_rule *next;
639 int rule;
640 int timeout;
641 int p1;
642 int p2;
643 } retry_rule;
644
645 typedef struct retry_config {
646 struct retry_config *next;
647 uschar *pattern;
648 int basic_errno;
649 int more_errno;
650 uschar *senders;
651 retry_rule *rules;
652 } retry_config;
653
654 /* Structure for each node in a tree, of which there are various kinds */
655
656 typedef struct tree_node {
657 struct tree_node *left; /* pointer to left child */
658 struct tree_node *right; /* pointer to right child */
659 union
660 {
661 void *ptr; /* pointer to data */
662 int val; /* or integer data */
663 } data;
664 uschar balance; /* balancing factor */
665 uschar name[1]; /* node name - variable length */
666 } tree_node;
667
668 /* Structure for holding time-limited data such as DNS returns.
669 We use this rather than extending tree_node to avoid wasting
670 space for most tree use (variables...) at the cost of complexity
671 for the lookups cache */
672
673 typedef struct expiring_data {
674 time_t expiry; /* if nonzero, data invalid after this time */
675 void *ptr; /* pointer to data */
676 } expiring_data;
677
678 /* Structure for holding the handle and the cached last lookup for searches.
679 This block is pointed to by the tree entry for the file. The file can get
680 closed if too many are opened at once. There is a LRU chain for deciding which
681 to close. */
682
683 typedef struct search_cache {
684 void *handle; /* lookup handle, or NULL if closed */
685 int search_type; /* search type */
686 tree_node *up; /* LRU up pointer */
687 tree_node *down; /* LRU down pointer */
688 tree_node *item_cache; /* tree of cached results */
689 } search_cache;
690
691 /* Structure for holding a partially decoded DNS record; the name has been
692 uncompressed, but the data pointer is into the raw data. */
693
694 typedef struct {
695 uschar name[DNS_MAXNAME]; /* domain name */
696 int type; /* record type */
697 unsigned short ttl; /* time-to-live, seconds */
698 int size; /* size of data */
699 uschar *data; /* pointer to data */
700 } dns_record;
701
702 /* Structure for holding the result of a DNS query. */
703
704 typedef struct {
705 int answerlen; /* length of the answer */
706 uschar answer[MAXPACKET]; /* the answer itself */
707 } dns_answer;
708
709 /* Structure for holding the intermediate data while scanning a DNS answer
710 block. */
711
712 typedef struct {
713 int rrcount; /* count of RRs in the answer */
714 uschar *aptr; /* pointer in the answer while scanning */
715 dns_record srr; /* data from current record in scan */
716 } dns_scan;
717
718 /* Structure for holding a chain of IP addresses that are extracted from
719 an A, AAAA, or A6 record. For the first two, there is only ever one address,
720 but the chaining feature of A6 allows for several addresses to be realized from
721 a single initial A6 record. The structure defines the address field of length
722 1. In use, a suitable sized block is obtained to hold the complete textual
723 address. */
724
725 typedef struct dns_address {
726 struct dns_address *next;
727 uschar address[1];
728 } dns_address;
729
730 /* Structure used for holding intermediate data during MD5 computations. */
731
732 typedef struct md5 {
733 unsigned int length;
734 unsigned int abcd[4];
735 }
736 md5;
737
738 /* Structure used for holding intermediate data during SHA-1 computations. */
739
740 typedef struct sha1 {
741 unsigned int H[5];
742 unsigned int length;
743 }
744 sha1;
745
746 /* Structure used to hold incoming packets of SMTP responses for a specific
747 socket. The packets which may contain multiple lines (and in some cases,
748 multiple responses). */
749
750 typedef struct smtp_inblock {
751 int sock; /* the socket */
752 int buffersize; /* the size of the buffer */
753 uschar *ptr; /* current position in the buffer */
754 uschar *ptrend; /* end of data in the buffer */
755 uschar *buffer; /* the buffer itself */
756 } smtp_inblock;
757
758 /* Structure used to hold buffered outgoing packets of SMTP commands for a
759 specific socket. The packets which may contain multiple lines when pipelining
760 is in use. */
761
762 typedef struct smtp_outblock {
763 int sock; /* the socket */
764 int cmd_count; /* count of buffered commands */
765 int buffersize; /* the size of the buffer */
766 BOOL authenticating; /* TRUE when authenticating */
767 uschar *ptr; /* current position in the buffer */
768 uschar *buffer; /* the buffer itself */
769 } smtp_outblock;
770
771 /* Structure to hold information about the source of redirection information */
772
773 typedef struct redirect_block {
774 uschar *string; /* file name or string */
775 uid_t *owners; /* allowed file owners */
776 gid_t *owngroups; /* allowed file groups */
777 struct passwd *pw; /* possible owner if not NULL */
778 int modemask; /* forbidden bits */
779 BOOL isfile; /* TRUE if string is a file name */
780 BOOL check_owner; /* TRUE, FALSE, or TRUE_UNSET */
781 BOOL check_group; /* TRUE, FALSE, or TRUE_UNSET */
782 } redirect_block;
783
784 /* Structure for passing arguments to check_host() */
785
786 typedef struct check_host_block {
787 const uschar *host_name;
788 const uschar *host_address;
789 const uschar *host_ipv4;
790 BOOL negative;
791 } check_host_block;
792
793 /* Structure for remembering lookup data when caching the result of
794 a lookup in a named list. */
795
796 typedef struct namedlist_cacheblock {
797 struct namedlist_cacheblock *next;
798 uschar *key;
799 uschar *data;
800 } namedlist_cacheblock;
801
802 /* Structure for holding data for an entry in a named list */
803
804 typedef struct namedlist_block {
805 const uschar *string; /* the list string */
806 namedlist_cacheblock *cache_data; /* cached domain_data or localpart_data */
807 int number; /* the number of the list for caching */
808 } namedlist_block;
809
810 /* Structures for Access Control Lists */
811
812 typedef struct acl_condition_block {
813 struct acl_condition_block *next;
814 uschar *arg;
815 int type;
816 union {
817 BOOL negated;
818 uschar *varname;
819 } u;
820 } acl_condition_block;
821
822 typedef struct acl_block {
823 struct acl_block *next;
824 acl_condition_block *condition;
825 int verb;
826 } acl_block;
827
828 /* smtp transport calc outbound_ip */
829 typedef BOOL (*oicf) (uschar *message_id, void *data);
830
831 /* DKIM information for transport */
832 struct ob_dkim {
833 uschar *dkim_domain;
834 uschar *dkim_private_key;
835 uschar *dkim_selector;
836 uschar *dkim_canon;
837 uschar *dkim_sign_headers;
838 uschar *dkim_strict;
839 } dkim;
840
841 /* End of structs.h */