Fix FreeBSD 13 build
[exim.git] / src / src / transports / smtp.h
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2018 */
6 /* Copyright (c) The Exim Maintainers 2020 */
7 /* See the file NOTICE for conditions of use and distribution. */
8
9 #define DELIVER_BUFFER_SIZE 4096
10
11 #define PENDING          256
12 #define PENDING_DEFER   (PENDING + DEFER)
13 #define PENDING_OK      (PENDING + OK)
14
15
16 #ifndef DISABLE_TLS
17 /* Flags structure for validity of TLS configuration */
18
19 typedef struct {
20   BOOL conn_certs:1;            /* certificates etc. loaded */
21   BOOL cabundle:1;              /* CA certificates loaded */
22   BOOL crl:1;                   /* CRL loaded */
23   BOOL pri_string:1;            /* cipher priority-string cache loaded */
24   BOOL dh:1;                    /* Diffie-Helman params loaded */
25   BOOL ecdh:1;                  /* EC Diffie-Helman params loaded */
26
27   BOOL ca_rdn_emulate:1;        /* do not advertise usable-cert list */
28   BOOL ocsp_hook:1;             /* need hshake callback on session */
29
30   void * libdata0;              /* library-dependent preloaded data */
31   void * libdata1;              /* library-dependent preloaded data */
32 } exim_tlslib_state;
33 #endif
34
35
36 /* Private structure for the private options and other private data. */
37
38 typedef struct {
39   uschar        *hosts;
40   uschar        *fallback_hosts;
41   host_item     *hostlist;
42   host_item     *fallback_hostlist;
43   uschar        *authenticated_sender;
44   uschar        *helo_data;
45   uschar        *interface;
46   uschar        *port;
47   uschar        *protocol;
48   uschar        *dscp;
49   uschar        *serialize_hosts;
50   uschar        *hosts_try_auth;
51   uschar        *hosts_require_auth;
52   uschar        *hosts_try_chunking;
53 #ifdef SUPPORT_DANE
54   uschar        *hosts_try_dane;
55   uschar        *hosts_require_dane;
56   uschar        *dane_require_tls_ciphers;
57 #endif
58   uschar        *hosts_try_fastopen;
59 #ifndef DISABLE_PRDR
60   uschar        *hosts_try_prdr;
61 #endif
62 #ifndef DISABLE_OCSP
63   uschar        *hosts_request_ocsp;
64   uschar        *hosts_require_ocsp;
65 #endif
66   uschar        *hosts_require_tls;
67   uschar        *hosts_avoid_tls;
68   uschar        *hosts_verify_avoid_tls;
69   uschar        *hosts_avoid_pipelining;
70 #ifndef DISABLE_PIPE_CONNECT
71   uschar        *hosts_pipe_connect;
72 #endif
73   uschar        *hosts_avoid_esmtp;
74 #ifndef DISABLE_TLS
75   uschar        *hosts_nopass_tls;
76   uschar        *hosts_noproxy_tls;
77 #endif
78   int           command_timeout;
79   int           connect_timeout;
80   int           data_timeout;
81   int           final_timeout;
82   int           size_addition;
83   int           hosts_max_try;
84   int           hosts_max_try_hardlimit;
85   int                   message_linelength_limit;
86   BOOL          address_retry_include_sender;
87   BOOL          allow_localhost;
88   BOOL          authenticated_sender_force;
89   BOOL          gethostbyname;
90   BOOL          dns_qualify_single;
91   BOOL          dns_search_parents;
92   dnssec_domains dnssec;
93   BOOL          delay_after_cutoff;
94   BOOL          hosts_override;
95   BOOL          hosts_randomize;
96   BOOL          keepalive;
97   BOOL          lmtp_ignore_quota;
98   uschar        *expand_retry_include_ip_address;
99   BOOL          retry_include_ip_address;
100 #ifdef SUPPORT_SOCKS
101   uschar        *socks_proxy;
102 #endif
103 #ifndef DISABLE_TLS
104   uschar        *tls_certificate;
105   uschar        *tls_crl;
106   uschar        *tls_privatekey;
107   uschar        *tls_require_ciphers;
108 # ifndef DISABLE_TLS_RESUME
109   uschar        *tls_resumption_hosts;
110 # endif
111   const uschar  *tls_sni;
112   uschar        *tls_verify_certificates;
113   int           tls_dh_min_bits;
114   BOOL          tls_tempfail_tryclear;
115   uschar        *tls_verify_hosts;
116   uschar        *tls_try_verify_hosts;
117   uschar        *tls_verify_cert_hostnames;
118 #endif
119 #ifdef SUPPORT_I18N
120   uschar        *utf8_downconvert;
121 #endif
122 #ifndef DISABLE_DKIM
123   struct ob_dkim dkim;
124 #endif
125 #ifdef EXPERIMENTAL_ARC
126   uschar        *arc_sign;
127 #endif
128 #ifndef DISABLE_TLS
129   exim_tlslib_state tls_preload;
130 #endif
131 } smtp_transport_options_block;
132
133 #define SOB (smtp_transport_options_block *)
134
135
136 /* smtp connect context */
137 typedef struct {
138   uschar *              from_addr;
139   address_item *        addrlist;
140
141   smtp_connect_args     conn_args;
142   int                   port;
143
144   BOOL verify:1;
145   BOOL lmtp:1;
146   BOOL smtps:1;
147   BOOL ok:1;
148   BOOL setting_up:1;
149 #ifndef DISABLE_PIPE_CONNECT
150   BOOL early_pipe_ok:1;
151   BOOL early_pipe_active:1;
152 #endif
153   BOOL esmtp:1;
154   BOOL esmtp_sent:1;
155   BOOL pipelining_used:1;
156 #ifndef DISABLE_PRDR
157   BOOL prdr_active:1;
158 #endif
159 #ifdef SUPPORT_I18N
160   BOOL utf8_needed:1;
161 #endif
162   BOOL dsn_all_lasthop:1;
163 #if !defined(DISABLE_TLS) && defined(SUPPORT_DANE)
164   BOOL dane_required:1;
165 #endif
166 #ifndef DISABLE_PIPE_CONNECT
167   BOOL pending_BANNER:1;
168   BOOL pending_EHLO:1;
169 #endif
170   BOOL pending_MAIL:1;
171   BOOL pending_BDAT:1;
172   BOOL RCPT_452:1;
173   BOOL good_RCPT:1;
174   BOOL completed_addr:1;
175   BOOL send_rset:1;
176   BOOL send_quit:1;
177
178   int           max_rcpt;
179   int           cmd_count;
180
181   unsigned      peer_offered;
182   unsigned      avoid_option;
183   uschar *      igquotstr;
184   uschar *      helo_data;
185 #ifdef EXPERIMENTAL_DSN_INFO
186   uschar *      smtp_greeting;
187   uschar *      helo_response;
188 #endif
189 #ifndef DISABLE_PIPE_CONNECT
190   ehlo_resp_precis      ehlo_resp;
191 #endif
192
193   struct timeval        delivery_start;
194   address_item *        first_addr;
195   address_item *        next_addr;
196   address_item *        sync_addr;
197
198   client_conn_ctx       cctx;
199   smtp_inblock          inblock;
200   smtp_outblock         outblock;
201   uschar        buffer[DELIVER_BUFFER_SIZE];
202   uschar        inbuffer[4096];
203   uschar        outbuffer[4096];
204 } smtp_context;
205
206 extern int smtp_setup_conn(smtp_context *, BOOL);
207 extern int smtp_write_mail_and_rcpt_cmds(smtp_context *, int *);
208 extern int smtp_reap_early_pipe(smtp_context *, int *);
209
210
211 /* Data for reading the private options. */
212
213 extern optionlist smtp_transport_options[];
214 extern int smtp_transport_options_count;
215
216 /* Block containing default values. */
217
218 extern smtp_transport_options_block smtp_transport_option_defaults;
219
220 /* The main, init, and closedown entry points for the transport */
221
222 extern BOOL smtp_transport_entry(transport_instance *, address_item *);
223 extern void smtp_transport_init(transport_instance *);
224 extern void smtp_transport_closedown(transport_instance *);
225
226
227
228 #ifdef SUPPORT_SOCKS
229 extern int     socks_sock_connect(host_item *, int, int, uschar *,
230                  transport_instance *, int);
231 #endif
232
233 /* End of transports/smtp.h */