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