renames vmcb->control.v_irq to virq_pending
[freebsd-src/fkvm-freebsd.git] / contrib / sendmail / include / libmilter / mfapi.h
blob7d7fb1d99f57607805e8a28b8171365ebe93622a
1 /*
2 * Copyright (c) 1999-2004, 2006, 2008 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
10 * $Id: mfapi.h,v 8.78 2008/02/27 22:30:34 ca Exp $
14 ** MFAPI.H -- Global definitions for mail filter library and mail filters.
17 #ifndef _LIBMILTER_MFAPI_H
18 # define _LIBMILTER_MFAPI_H 1
20 #ifndef SMFI_VERSION
21 # define SMFI_VERSION 0x01000001 /* libmilter version number */
22 #endif /* ! SMFI_VERSION */
24 #define SM_LM_VRS_MAJOR(v) (((v) & 0x7f000000) >> 24)
25 #define SM_LM_VRS_MINOR(v) (((v) & 0x007fff00) >> 8)
26 #define SM_LM_VRS_PLVL(v) ((v) & 0x0000007f)
28 # include <sys/types.h>
29 # include <sys/socket.h>
31 #include "libmilter/mfdef.h"
33 # define LIBMILTER_API extern
36 /* Only need to export C interface if used by C++ source code */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
41 #ifndef _SOCK_ADDR
42 # define _SOCK_ADDR struct sockaddr
43 #endif /* ! _SOCK_ADDR */
46 ** libmilter functions return one of the following to indicate
47 ** success/failure(/continue):
50 #define MI_SUCCESS 0
51 #define MI_FAILURE (-1)
52 #if _FFR_WORKERS_POOL
53 # define MI_CONTINUE 1
54 #endif /* _FFR_WORKERS_POOL */
56 /* "forward" declarations */
57 typedef struct smfi_str SMFICTX;
58 typedef struct smfi_str *SMFICTX_PTR;
60 typedef struct smfiDesc smfiDesc_str;
61 typedef struct smfiDesc *smfiDesc_ptr;
64 ** Type which callbacks should return to indicate message status.
65 ** This may take on one of the SMFIS_* values listed below.
68 typedef int sfsistat;
70 #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC_MINOR__ >= 8
71 # define SM__P(X) __PMT(X)
72 #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
73 # define SM__P(X) __P(X)
74 #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
76 /* Some platforms don't define __P -- do it for them here: */
77 #ifndef __P
78 # ifdef __STDC__
79 # define __P(X) X
80 # else /* __STDC__ */
81 # define __P(X) ()
82 # endif /* __STDC__ */
83 #endif /* __P */
85 #if SM_CONF_STDBOOL_H
86 # include <stdbool.h>
87 #else /* SM_CONF_STDBOOL_H */
88 # ifndef __cplusplus
89 # ifndef bool
90 # ifndef __bool_true_false_are_defined
91 typedef int bool;
92 # define __bool_true_false_are_defined 1
93 # endif /* ! __bool_true_false_are_defined */
94 # endif /* bool */
95 # endif /* ! __cplusplus */
96 #endif /* SM_CONF_STDBOOL_H */
99 ** structure describing one milter
102 struct smfiDesc
104 char *xxfi_name; /* filter name */
105 int xxfi_version; /* version code -- do not change */
106 unsigned long xxfi_flags; /* flags */
108 /* connection info filter */
109 sfsistat (*xxfi_connect) SM__P((SMFICTX *, char *, _SOCK_ADDR *));
111 /* SMTP HELO command filter */
112 sfsistat (*xxfi_helo) SM__P((SMFICTX *, char *));
114 /* envelope sender filter */
115 sfsistat (*xxfi_envfrom) SM__P((SMFICTX *, char **));
117 /* envelope recipient filter */
118 sfsistat (*xxfi_envrcpt) SM__P((SMFICTX *, char **));
120 /* header filter */
121 sfsistat (*xxfi_header) SM__P((SMFICTX *, char *, char *));
123 /* end of header */
124 sfsistat (*xxfi_eoh) SM__P((SMFICTX *));
126 /* body block */
127 sfsistat (*xxfi_body) SM__P((SMFICTX *, unsigned char *, size_t));
129 /* end of message */
130 sfsistat (*xxfi_eom) SM__P((SMFICTX *));
132 /* message aborted */
133 sfsistat (*xxfi_abort) SM__P((SMFICTX *));
135 /* connection cleanup */
136 sfsistat (*xxfi_close) SM__P((SMFICTX *));
138 /* any unrecognized or unimplemented command filter */
139 sfsistat (*xxfi_unknown) SM__P((SMFICTX *, const char *));
141 /* SMTP DATA command filter */
142 sfsistat (*xxfi_data) SM__P((SMFICTX *));
144 /* negotiation callback */
145 sfsistat (*xxfi_negotiate) SM__P((SMFICTX *,
146 unsigned long, unsigned long,
147 unsigned long, unsigned long,
148 unsigned long *, unsigned long *,
149 unsigned long *, unsigned long *));
151 #if 0
152 /* signal handler callback, not yet implemented. */
153 int (*xxfi_signal) SM__P((int));
154 #endif
158 LIBMILTER_API int smfi_opensocket __P((bool));
159 LIBMILTER_API int smfi_register __P((struct smfiDesc));
160 LIBMILTER_API int smfi_main __P((void));
161 LIBMILTER_API int smfi_setbacklog __P((int));
162 LIBMILTER_API int smfi_setdbg __P((int));
163 LIBMILTER_API int smfi_settimeout __P((int));
164 LIBMILTER_API int smfi_setconn __P((char *));
165 LIBMILTER_API int smfi_stop __P((void));
166 #if _FFR_MAXDATASIZE
167 LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
168 #endif /* _FFR_MAXDATASIZE */
169 LIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *, unsigned int *));
172 ** What the filter might do -- values to be ORed together for
173 ** smfiDesc.xxfi_flags.
176 #define SMFIF_NONE 0x00000000L /* no flags */
177 #define SMFIF_ADDHDRS 0x00000001L /* filter may add headers */
178 #define SMFIF_CHGBODY 0x00000002L /* filter may replace body */
179 #define SMFIF_MODBODY SMFIF_CHGBODY /* backwards compatible */
180 #define SMFIF_ADDRCPT 0x00000004L /* filter may add recipients */
181 #define SMFIF_DELRCPT 0x00000008L /* filter may delete recipients */
182 #define SMFIF_CHGHDRS 0x00000010L /* filter may change/delete headers */
183 #define SMFIF_QUARANTINE 0x00000020L /* filter may quarantine envelope */
185 /* filter may change "from" (envelope sender) */
186 #define SMFIF_CHGFROM 0x00000040L
187 #define SMFIF_ADDRCPT_PAR 0x00000080L /* add recipients incl. args */
189 /* filter can send set of symbols (macros) that it wants */
190 #define SMFIF_SETSYMLIST 0x00000100L
194 ** Macro "places";
195 ** Notes:
196 ** - must be coordinated with libmilter/engine.c and sendmail/milter.c
197 ** - the order MUST NOT be changed as it would break compatibility between
198 ** different versions. It's ok to append new entries however
199 ** (hence the list is not sorted by the SMT protocol steps).
202 #define SMFIM_FIRST 0 /* Do NOT use, internal marker only */
203 #define SMFIM_CONNECT 0 /* connect */
204 #define SMFIM_HELO 1 /* HELO/EHLO */
205 #define SMFIM_ENVFROM 2 /* MAIL From */
206 #define SMFIM_ENVRCPT 3 /* RCPT To */
207 #define SMFIM_DATA 4 /* DATA */
208 #define SMFIM_EOM 5 /* end of message (final dot) */
209 #define SMFIM_EOH 6 /* end of header */
210 #define SMFIM_LAST 6 /* Do NOT use, internal marker only */
213 ** Continue processing message/connection.
216 #define SMFIS_CONTINUE 0
219 ** Reject the message/connection.
220 ** No further routines will be called for this message
221 ** (or connection, if returned from a connection-oriented routine).
224 #define SMFIS_REJECT 1
227 ** Accept the message,
228 ** but silently discard the message.
229 ** No further routines will be called for this message.
230 ** This is only meaningful from message-oriented routines.
233 #define SMFIS_DISCARD 2
236 ** Accept the message/connection.
237 ** No further routines will be called for this message
238 ** (or connection, if returned from a connection-oriented routine;
239 ** in this case, it causes all messages on this connection
240 ** to be accepted without filtering).
243 #define SMFIS_ACCEPT 3
246 ** Return a temporary failure, i.e.,
247 ** the corresponding SMTP command will return a 4xx status code.
248 ** In some cases this may prevent further routines from
249 ** being called on this message or connection,
250 ** although in other cases (e.g., when processing an envelope
251 ** recipient) processing of the message will continue.
254 #define SMFIS_TEMPFAIL 4
257 ** Do not send a reply to the MTA
260 #define SMFIS_NOREPLY 7
263 ** Skip over rest of same callbacks, e.g., body.
266 #define SMFIS_SKIP 8
268 /* xxfi_negotiate: use all existing protocol options/actions */
269 #define SMFIS_ALL_OPTS 10
271 #if 0
273 ** Filter Routine Details
276 /* connection info filter */
277 extern sfsistat xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
280 ** xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
282 ** char *hostname; Host domain name, as determined by a reverse lookup
283 ** on the host address.
284 ** _SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
285 ** call on the SMTP socket.
288 /* SMTP HELO command filter */
289 extern sfsistat xxfi_helo __P((SMFICTX *, char *));
292 ** xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
294 ** char *helohost; Value passed to HELO/EHLO command, which should be
295 ** the domain name of the sending host (but is, in practice,
296 ** anything the sending host wants to send).
299 /* envelope sender filter */
300 extern sfsistat xxfi_envfrom __P((SMFICTX *, char **));
303 ** xxfi_envfrom(ctx, argv) Invoked on envelope from
305 ** char **argv; Null-terminated SMTP command arguments;
306 ** argv[0] is guaranteed to be the sender address.
307 ** Later arguments are the ESMTP arguments.
310 /* envelope recipient filter */
311 extern sfsistat xxfi_envrcpt __P((SMFICTX *, char **));
314 ** xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
316 ** char **argv; Null-terminated SMTP command arguments;
317 ** argv[0] is guaranteed to be the recipient address.
318 ** Later arguments are the ESMTP arguments.
321 /* unknown command filter */
323 extern sfsistat *xxfi_unknown __P((SMFICTX *, const char *));
326 ** xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
327 ** implemented.
328 ** const char *arg; Null-terminated SMTP command
331 /* header filter */
332 extern sfsistat xxfi_header __P((SMFICTX *, char *, char *));
335 ** xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
336 ** content of the header may have folded white space (that is, multiple
337 ** lines with following white space) included.
339 ** char *headerf; Header field name
340 ** char *headerv; Header field value
343 /* end of header */
344 extern sfsistat xxfi_eoh __P((SMFICTX *));
347 ** xxfi_eoh(ctx) Invoked at end of header
350 /* body block */
351 extern sfsistat xxfi_body __P((SMFICTX *, unsigned char *, size_t));
354 ** xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
355 ** be multiple body chunks passed to the filter. End-of-lines are
356 ** represented as received from SMTP (normally Carriage-Return/Line-Feed).
358 ** unsigned char *bodyp; Pointer to body data
359 ** size_t bodylen; Length of body data
362 /* end of message */
363 extern sfsistat xxfi_eom __P((SMFICTX *));
366 ** xxfi_eom(ctx) Invoked at end of message. This routine can perform
367 ** special operations such as modifying the message header, body, or
368 ** envelope.
371 /* message aborted */
372 extern sfsistat xxfi_abort __P((SMFICTX *));
375 ** xxfi_abort(ctx) Invoked if message is aborted outside of the control of
376 ** the filter, for example, if the SMTP sender issues an RSET command. If
377 ** xxfi_abort is called, xxfi_eom will not be called and vice versa.
380 /* connection cleanup */
381 extern sfsistat xxfi_close __P((SMFICTX *));
384 ** xxfi_close(ctx) Invoked at end of the connection. This is called on
385 ** close even if the previous mail transaction was aborted.
387 #endif /* 0 */
390 ** Additional information is passed in to the vendor filter routines using
391 ** symbols. Symbols correspond closely to sendmail macros. The symbols
392 ** defined depend on the context. The value of a symbol is accessed using:
395 /* Return the value of a symbol. */
396 LIBMILTER_API char * smfi_getsymval __P((SMFICTX *, char *));
399 ** Return the value of a symbol.
401 ** SMFICTX *ctx; Opaque context structure
402 ** char *symname; The name of the symbol to access.
406 ** Vendor filter routines that want to pass additional information back to
407 ** the MTA for use in SMTP replies may call smfi_setreply before returning.
410 LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
413 ** Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
414 ** is needed.
417 LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, ...));
420 ** Set the specific reply code to be used in response to the active
421 ** command. If not specified, a generic reply code is used.
423 ** SMFICTX *ctx; Opaque context structure
424 ** char *rcode; The three-digit (RFC 821) SMTP reply code to be
425 ** returned, e.g., ``551''.
426 ** char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
427 ** char *message; The text part of the SMTP reply.
431 ** The xxfi_eom routine is called at the end of a message (essentially,
432 ** after the final DATA dot). This routine can call some special routines
433 ** to modify the envelope, header, or body of the message before the
434 ** message is enqueued. These routines must not be called from any vendor
435 ** routine other than xxfi_eom.
438 LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
441 ** Add a header to the message. It is not checked for standards
442 ** compliance; the mail filter must ensure that no protocols are violated
443 ** as a result of adding this header.
445 ** SMFICTX *ctx; Opaque context structure
446 ** char *headerf; Header field name
447 ** char *headerv; Header field value
450 LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
453 ** Change/delete a header in the message. It is not checked for standards
454 ** compliance; the mail filter must ensure that no protocols are violated
455 ** as a result of adding this header.
457 ** SMFICTX *ctx; Opaque context structure
458 ** char *headerf; Header field name
459 ** int index; The Nth occurence of header field name
460 ** char *headerv; New header field value (empty for delete header)
463 LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
466 ** Insert a header into the message. It is not checked for standards
467 ** compliance; the mail filter must ensure that no protocols are violated
468 ** as a result of adding this header.
470 ** SMFICTX *ctx; Opaque context structure
471 ** int idx; index into the header list where the insertion should happen
472 ** char *headerh; Header field name
473 ** char *headerv; Header field value
476 LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *));
479 ** Modify envelope sender address
481 ** SMFICTX *ctx; Opaque context structure
482 ** char *mail; New envelope sender address
483 ** char *args; ESMTP arguments
487 LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
490 ** Add a recipient to the envelope
492 ** SMFICTX *ctx; Opaque context structure
493 ** char *rcpt; Recipient to be added
496 LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *));
499 ** Add a recipient to the envelope
501 ** SMFICTX *ctx; Opaque context structure
502 ** char *rcpt; Recipient to be added
503 ** char *args; ESMTP arguments
507 LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
510 ** Send a "no-op" up to the MTA to tell it we're still alive, so long
511 ** milter-side operations don't time out.
513 ** SMFICTX *ctx; Opaque context structure
516 LIBMILTER_API int smfi_progress __P((SMFICTX *));
519 ** Delete a recipient from the envelope
521 ** SMFICTX *ctx; Opaque context structure
522 ** char *rcpt; Envelope recipient to be deleted. This should be in
523 ** exactly the form passed to xxfi_envrcpt or the address may
524 ** not be deleted.
527 LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
530 ** Replace the body of the message. This routine may be called multiple
531 ** times if the body is longer than convenient to send in one call. End of
532 ** line should be represented as Carriage-Return/Line Feed.
534 ** char *bodyp; Pointer to block of body information to insert
535 ** int bodylen; Length of data pointed at by bodyp
539 ** If the message is aborted (for example, if the SMTP sender sends the
540 ** envelope but then does a QUIT or RSET before the data is sent),
541 ** xxfi_abort is called. This can be used to reset state.
545 ** Quarantine an envelope
547 ** SMFICTX *ctx; Opaque context structure
548 ** char *reason: explanation
551 LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
554 ** Connection-private data (specific to an SMTP connection) can be
555 ** allocated using the smfi_setpriv routine; routines can access private
556 ** data using smfi_getpriv.
559 LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
562 ** Set the private data pointer
564 ** SMFICTX *ctx; Opaque context structure
565 ** void *privatedata; Pointer to private data area
568 LIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
571 ** Get the private data pointer
573 ** SMFICTX *ctx; Opaque context structure
574 ** void *privatedata; Pointer to private data area
577 LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *));
580 ** Set list of symbols (macros) to receive
582 ** SMFICTX *ctx; Opaque context structure
583 ** int where; where in the SMTP dialogue should the macros be sent
584 ** char *macros; list of macros (space separated)
587 #if _FFR_THREAD_MONITOR
588 LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int));
589 #endif /* _FFR_THREAD_MONITOR */
591 #ifdef __cplusplus
593 #endif /* __cplusplus */
595 #endif /* ! _LIBMILTER_MFAPI_H */