xref: /freebsd/contrib/sendmail/include/libmilter/mfapi.h (revision 9bd497b8354567454e075076d40c996e21bd6095)
106f25ae9SGregory Neil Shapiro /*
2e3793f76SGregory Neil Shapiro  * Copyright (c) 1999-2004, 2006, 2008 Sendmail, Inc. and its suppliers.
306f25ae9SGregory Neil Shapiro  *	All rights reserved.
406f25ae9SGregory Neil Shapiro  *
506f25ae9SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
606f25ae9SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
706f25ae9SGregory Neil Shapiro  * the sendmail distribution.
806f25ae9SGregory Neil Shapiro  *
906f25ae9SGregory Neil Shapiro  *
109bd497b8SGregory Neil Shapiro  *	$Id: mfapi.h,v 8.80 2009/11/06 00:57:08 ca Exp $
1106f25ae9SGregory Neil Shapiro  */
1206f25ae9SGregory Neil Shapiro 
1306f25ae9SGregory Neil Shapiro /*
1406f25ae9SGregory Neil Shapiro **  MFAPI.H -- Global definitions for mail filter library and mail filters.
1506f25ae9SGregory Neil Shapiro */
1606f25ae9SGregory Neil Shapiro 
1706f25ae9SGregory Neil Shapiro #ifndef _LIBMILTER_MFAPI_H
1806f25ae9SGregory Neil Shapiro # define _LIBMILTER_MFAPI_H	1
1906f25ae9SGregory Neil Shapiro 
20e92d3f3fSGregory Neil Shapiro #ifndef SMFI_VERSION
219bd497b8SGregory Neil Shapiro # if _FFR_MDS_NEGOTIATE
229bd497b8SGregory Neil Shapiro #  define SMFI_VERSION	0x01000002	/* libmilter version number */
239bd497b8SGregory Neil Shapiro 
249bd497b8SGregory Neil Shapiro    /* first libmilter version that has MDS support */
259bd497b8SGregory Neil Shapiro #  define SMFI_VERSION_MDS	0x01000002
269bd497b8SGregory Neil Shapiro # else /* _FFR_MDS_NEGOTIATE */
27e3793f76SGregory Neil Shapiro #  define SMFI_VERSION	0x01000001	/* libmilter version number */
289bd497b8SGregory Neil Shapiro # endif /* _FFR_MDS_NEGOTIATE */
29e92d3f3fSGregory Neil Shapiro #endif /* ! SMFI_VERSION */
3013bd1963SGregory Neil Shapiro 
31d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_MAJOR(v)	(((v) & 0x7f000000) >> 24)
32d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_MINOR(v)	(((v) & 0x007fff00) >> 8)
33d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_PLVL(v)	((v) & 0x0000007f)
34d0cef73dSGregory Neil Shapiro 
35e92d3f3fSGregory Neil Shapiro # include <sys/types.h>
3640266059SGregory Neil Shapiro # include <sys/socket.h>
37e92d3f3fSGregory Neil Shapiro 
3840266059SGregory Neil Shapiro #include "libmilter/mfdef.h"
3906f25ae9SGregory Neil Shapiro 
4040266059SGregory Neil Shapiro # define LIBMILTER_API		extern
4106f25ae9SGregory Neil Shapiro 
4206f25ae9SGregory Neil Shapiro 
43e92d3f3fSGregory Neil Shapiro /* Only need to export C interface if used by C++ source code */
44e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus
45e92d3f3fSGregory Neil Shapiro extern "C" {
46e92d3f3fSGregory Neil Shapiro #endif /* __cplusplus */
47e92d3f3fSGregory Neil Shapiro 
4806f25ae9SGregory Neil Shapiro #ifndef _SOCK_ADDR
4906f25ae9SGregory Neil Shapiro # define _SOCK_ADDR	struct sockaddr
5006f25ae9SGregory Neil Shapiro #endif /* ! _SOCK_ADDR */
5106f25ae9SGregory Neil Shapiro 
5206f25ae9SGregory Neil Shapiro /*
5306f25ae9SGregory Neil Shapiro **  libmilter functions return one of the following to indicate
54d0cef73dSGregory Neil Shapiro **  success/failure(/continue):
5506f25ae9SGregory Neil Shapiro */
5606f25ae9SGregory Neil Shapiro 
5706f25ae9SGregory Neil Shapiro #define MI_SUCCESS	0
5806f25ae9SGregory Neil Shapiro #define MI_FAILURE	(-1)
59d0cef73dSGregory Neil Shapiro #if _FFR_WORKERS_POOL
60d0cef73dSGregory Neil Shapiro # define MI_CONTINUE	1
61d0cef73dSGregory Neil Shapiro #endif /* _FFR_WORKERS_POOL */
6206f25ae9SGregory Neil Shapiro 
6306f25ae9SGregory Neil Shapiro /* "forward" declarations */
6406f25ae9SGregory Neil Shapiro typedef struct smfi_str SMFICTX;
6506f25ae9SGregory Neil Shapiro typedef struct smfi_str *SMFICTX_PTR;
6606f25ae9SGregory Neil Shapiro 
6706f25ae9SGregory Neil Shapiro typedef struct smfiDesc smfiDesc_str;
6806f25ae9SGregory Neil Shapiro typedef struct smfiDesc	*smfiDesc_ptr;
6906f25ae9SGregory Neil Shapiro 
7006f25ae9SGregory Neil Shapiro /*
7106f25ae9SGregory Neil Shapiro **  Type which callbacks should return to indicate message status.
7206f25ae9SGregory Neil Shapiro **  This may take on one of the SMFIS_* values listed below.
7306f25ae9SGregory Neil Shapiro */
7406f25ae9SGregory Neil Shapiro 
7506f25ae9SGregory Neil Shapiro typedef int	sfsistat;
7606f25ae9SGregory Neil Shapiro 
7706f25ae9SGregory Neil Shapiro #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC_MINOR__ >= 8
7806f25ae9SGregory Neil Shapiro # define SM__P(X)	__PMT(X)
7906f25ae9SGregory Neil Shapiro #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
8006f25ae9SGregory Neil Shapiro # define SM__P(X)	__P(X)
8106f25ae9SGregory Neil Shapiro #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
8206f25ae9SGregory Neil Shapiro 
8306f25ae9SGregory Neil Shapiro /* Some platforms don't define __P -- do it for them here: */
8406f25ae9SGregory Neil Shapiro #ifndef __P
8506f25ae9SGregory Neil Shapiro # ifdef __STDC__
8606f25ae9SGregory Neil Shapiro #  define __P(X) X
8706f25ae9SGregory Neil Shapiro # else /* __STDC__ */
8806f25ae9SGregory Neil Shapiro #  define __P(X) ()
8906f25ae9SGregory Neil Shapiro # endif /* __STDC__ */
9006f25ae9SGregory Neil Shapiro #endif /* __P */
9106f25ae9SGregory Neil Shapiro 
92e92d3f3fSGregory Neil Shapiro #if SM_CONF_STDBOOL_H
93e92d3f3fSGregory Neil Shapiro # include <stdbool.h>
94e92d3f3fSGregory Neil Shapiro #else /* SM_CONF_STDBOOL_H */
95e92d3f3fSGregory Neil Shapiro # ifndef __cplusplus
96e92d3f3fSGregory Neil Shapiro #  ifndef bool
97e92d3f3fSGregory Neil Shapiro #   ifndef __bool_true_false_are_defined
98e92d3f3fSGregory Neil Shapiro typedef int	bool;
99e92d3f3fSGregory Neil Shapiro #    define __bool_true_false_are_defined	1
100e92d3f3fSGregory Neil Shapiro #   endif /* ! __bool_true_false_are_defined */
101e92d3f3fSGregory Neil Shapiro #  endif /* bool */
102e92d3f3fSGregory Neil Shapiro # endif /* ! __cplusplus */
103e92d3f3fSGregory Neil Shapiro #endif /* SM_CONF_STDBOOL_H */
104e92d3f3fSGregory Neil Shapiro 
10540266059SGregory Neil Shapiro /*
10640266059SGregory Neil Shapiro **  structure describing one milter
10740266059SGregory Neil Shapiro */
10840266059SGregory Neil Shapiro 
10906f25ae9SGregory Neil Shapiro struct smfiDesc
11006f25ae9SGregory Neil Shapiro {
11106f25ae9SGregory Neil Shapiro 	char		*xxfi_name;	/* filter name */
11206f25ae9SGregory Neil Shapiro 	int		xxfi_version;	/* version code -- do not change */
11340266059SGregory Neil Shapiro 	unsigned long	xxfi_flags;	/* flags */
11406f25ae9SGregory Neil Shapiro 
11506f25ae9SGregory Neil Shapiro 	/* connection info filter */
11606f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_connect) SM__P((SMFICTX *, char *, _SOCK_ADDR *));
11706f25ae9SGregory Neil Shapiro 
11806f25ae9SGregory Neil Shapiro 	/* SMTP HELO command filter */
11906f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_helo) SM__P((SMFICTX *, char *));
12006f25ae9SGregory Neil Shapiro 
12106f25ae9SGregory Neil Shapiro 	/* envelope sender filter */
12206f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_envfrom) SM__P((SMFICTX *, char **));
12306f25ae9SGregory Neil Shapiro 
12406f25ae9SGregory Neil Shapiro 	/* envelope recipient filter */
12506f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_envrcpt) SM__P((SMFICTX *, char **));
12606f25ae9SGregory Neil Shapiro 
12706f25ae9SGregory Neil Shapiro 	/* header filter */
12806f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_header) SM__P((SMFICTX *, char *, char *));
12906f25ae9SGregory Neil Shapiro 
13006f25ae9SGregory Neil Shapiro 	/* end of header */
13106f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_eoh) SM__P((SMFICTX *));
13206f25ae9SGregory Neil Shapiro 
13306f25ae9SGregory Neil Shapiro 	/* body block */
13440266059SGregory Neil Shapiro 	sfsistat	(*xxfi_body) SM__P((SMFICTX *, unsigned char *, size_t));
13506f25ae9SGregory Neil Shapiro 
13606f25ae9SGregory Neil Shapiro 	/* end of message */
13706f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_eom) SM__P((SMFICTX *));
13806f25ae9SGregory Neil Shapiro 
13906f25ae9SGregory Neil Shapiro 	/* message aborted */
14006f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_abort) SM__P((SMFICTX *));
14106f25ae9SGregory Neil Shapiro 
14206f25ae9SGregory Neil Shapiro 	/* connection cleanup */
14306f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_close) SM__P((SMFICTX *));
144e92d3f3fSGregory Neil Shapiro 
145e92d3f3fSGregory Neil Shapiro 	/* any unrecognized or unimplemented command filter */
146d0cef73dSGregory Neil Shapiro 	sfsistat	(*xxfi_unknown) SM__P((SMFICTX *, const char *));
147e92d3f3fSGregory Neil Shapiro 
148af9557fdSGregory Neil Shapiro 	/* SMTP DATA command filter */
149e92d3f3fSGregory Neil Shapiro 	sfsistat	(*xxfi_data) SM__P((SMFICTX *));
150d0cef73dSGregory Neil Shapiro 
151d0cef73dSGregory Neil Shapiro 	/* negotiation callback */
152d0cef73dSGregory Neil Shapiro 	sfsistat	(*xxfi_negotiate) SM__P((SMFICTX *,
153d0cef73dSGregory Neil Shapiro 					unsigned long, unsigned long,
154d0cef73dSGregory Neil Shapiro 					unsigned long, unsigned long,
155d0cef73dSGregory Neil Shapiro 					unsigned long *, unsigned long *,
156d0cef73dSGregory Neil Shapiro 					unsigned long *, unsigned long *));
157d0cef73dSGregory Neil Shapiro 
158d0cef73dSGregory Neil Shapiro #if 0
159d0cef73dSGregory Neil Shapiro 	/* signal handler callback, not yet implemented. */
160d0cef73dSGregory Neil Shapiro 	int		(*xxfi_signal) SM__P((int));
161d0cef73dSGregory Neil Shapiro #endif
162d0cef73dSGregory Neil Shapiro 
16306f25ae9SGregory Neil Shapiro };
16406f25ae9SGregory Neil Shapiro 
165323f6dcbSGregory Neil Shapiro LIBMILTER_API int smfi_opensocket __P((bool));
16606f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_register __P((struct smfiDesc));
16706f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_main __P((void));
168605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_setbacklog __P((int));
16906f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setdbg __P((int));
17006f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_settimeout __P((int));
17106f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setconn __P((char *));
17242e5d165SGregory Neil Shapiro LIBMILTER_API int smfi_stop __P((void));
173e92d3f3fSGregory Neil Shapiro LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
174d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *, unsigned int *));
17540266059SGregory Neil Shapiro 
17640266059SGregory Neil Shapiro /*
17740266059SGregory Neil Shapiro **  What the filter might do -- values to be ORed together for
17840266059SGregory Neil Shapiro **  smfiDesc.xxfi_flags.
17940266059SGregory Neil Shapiro */
18040266059SGregory Neil Shapiro 
18140266059SGregory Neil Shapiro #define SMFIF_NONE	0x00000000L	/* no flags */
18240266059SGregory Neil Shapiro #define SMFIF_ADDHDRS	0x00000001L	/* filter may add headers */
18340266059SGregory Neil Shapiro #define SMFIF_CHGBODY	0x00000002L	/* filter may replace body */
18440266059SGregory Neil Shapiro #define SMFIF_MODBODY	SMFIF_CHGBODY	/* backwards compatible */
18540266059SGregory Neil Shapiro #define SMFIF_ADDRCPT	0x00000004L	/* filter may add recipients */
18640266059SGregory Neil Shapiro #define SMFIF_DELRCPT	0x00000008L	/* filter may delete recipients */
18740266059SGregory Neil Shapiro #define SMFIF_CHGHDRS	0x00000010L	/* filter may change/delete headers */
18840266059SGregory Neil Shapiro #define SMFIF_QUARANTINE 0x00000020L	/* filter may quarantine envelope */
18940266059SGregory Neil Shapiro 
190d0cef73dSGregory Neil Shapiro /* filter may change "from" (envelope sender) */
191d0cef73dSGregory Neil Shapiro #define SMFIF_CHGFROM	0x00000040L
192d0cef73dSGregory Neil Shapiro #define SMFIF_ADDRCPT_PAR	0x00000080L	/* add recipients incl. args */
193d0cef73dSGregory Neil Shapiro 
194d0cef73dSGregory Neil Shapiro /* filter can send set of symbols (macros) that it wants */
195d0cef73dSGregory Neil Shapiro #define SMFIF_SETSYMLIST	0x00000100L
196d0cef73dSGregory Neil Shapiro 
197d0cef73dSGregory Neil Shapiro 
198d0cef73dSGregory Neil Shapiro /*
199d0cef73dSGregory Neil Shapiro **  Macro "places";
200d0cef73dSGregory Neil Shapiro **  Notes:
201d0cef73dSGregory Neil Shapiro **  - must be coordinated with libmilter/engine.c and sendmail/milter.c
202d0cef73dSGregory Neil Shapiro **  - the order MUST NOT be changed as it would break compatibility between
203d0cef73dSGregory Neil Shapiro **	different versions. It's ok to append new entries however
204d0cef73dSGregory Neil Shapiro **	(hence the list is not sorted by the SMT protocol steps).
205d0cef73dSGregory Neil Shapiro */
206d0cef73dSGregory Neil Shapiro 
207d0cef73dSGregory Neil Shapiro #define SMFIM_FIRST	0	/* Do NOT use, internal marker only */
208d0cef73dSGregory Neil Shapiro #define SMFIM_CONNECT	0	/* connect */
209d0cef73dSGregory Neil Shapiro #define SMFIM_HELO	1	/* HELO/EHLO */
210d0cef73dSGregory Neil Shapiro #define SMFIM_ENVFROM	2	/* MAIL From */
211d0cef73dSGregory Neil Shapiro #define SMFIM_ENVRCPT	3	/* RCPT To */
212d0cef73dSGregory Neil Shapiro #define SMFIM_DATA	4	/* DATA */
213d0cef73dSGregory Neil Shapiro #define SMFIM_EOM	5	/* end of message (final dot) */
214d0cef73dSGregory Neil Shapiro #define SMFIM_EOH	6	/* end of header */
215d0cef73dSGregory Neil Shapiro #define SMFIM_LAST	6	/* Do NOT use, internal marker only */
216d0cef73dSGregory Neil Shapiro 
21706f25ae9SGregory Neil Shapiro /*
21806f25ae9SGregory Neil Shapiro **  Continue processing message/connection.
21906f25ae9SGregory Neil Shapiro */
22006f25ae9SGregory Neil Shapiro 
22106f25ae9SGregory Neil Shapiro #define SMFIS_CONTINUE	0
22206f25ae9SGregory Neil Shapiro 
22306f25ae9SGregory Neil Shapiro /*
22406f25ae9SGregory Neil Shapiro **  Reject the message/connection.
22506f25ae9SGregory Neil Shapiro **  No further routines will be called for this message
22606f25ae9SGregory Neil Shapiro **  (or connection, if returned from a connection-oriented routine).
22706f25ae9SGregory Neil Shapiro */
22806f25ae9SGregory Neil Shapiro 
22906f25ae9SGregory Neil Shapiro #define SMFIS_REJECT	1
23006f25ae9SGregory Neil Shapiro 
23106f25ae9SGregory Neil Shapiro /*
23206f25ae9SGregory Neil Shapiro **  Accept the message,
23306f25ae9SGregory Neil Shapiro **  but silently discard the message.
23406f25ae9SGregory Neil Shapiro **  No further routines will be called for this message.
23506f25ae9SGregory Neil Shapiro **  This is only meaningful from message-oriented routines.
23606f25ae9SGregory Neil Shapiro */
23706f25ae9SGregory Neil Shapiro 
23806f25ae9SGregory Neil Shapiro #define SMFIS_DISCARD	2
23906f25ae9SGregory Neil Shapiro 
24006f25ae9SGregory Neil Shapiro /*
24106f25ae9SGregory Neil Shapiro **  Accept the message/connection.
24206f25ae9SGregory Neil Shapiro **  No further routines will be called for this message
24306f25ae9SGregory Neil Shapiro **  (or connection, if returned from a connection-oriented routine;
24406f25ae9SGregory Neil Shapiro **  in this case, it causes all messages on this connection
24506f25ae9SGregory Neil Shapiro **  to be accepted without filtering).
24606f25ae9SGregory Neil Shapiro */
24706f25ae9SGregory Neil Shapiro 
24806f25ae9SGregory Neil Shapiro #define SMFIS_ACCEPT	3
24906f25ae9SGregory Neil Shapiro 
25006f25ae9SGregory Neil Shapiro /*
25106f25ae9SGregory Neil Shapiro **  Return a temporary failure, i.e.,
25206f25ae9SGregory Neil Shapiro **  the corresponding SMTP command will return a 4xx status code.
25306f25ae9SGregory Neil Shapiro **  In some cases this may prevent further routines from
25406f25ae9SGregory Neil Shapiro **  being called on this message or connection,
25506f25ae9SGregory Neil Shapiro **  although in other cases (e.g., when processing an envelope
25606f25ae9SGregory Neil Shapiro **  recipient) processing of the message will continue.
25706f25ae9SGregory Neil Shapiro */
25806f25ae9SGregory Neil Shapiro 
25906f25ae9SGregory Neil Shapiro #define SMFIS_TEMPFAIL	4
26006f25ae9SGregory Neil Shapiro 
261d0cef73dSGregory Neil Shapiro /*
262d0cef73dSGregory Neil Shapiro **  Do not send a reply to the MTA
263d0cef73dSGregory Neil Shapiro */
264d0cef73dSGregory Neil Shapiro 
265d0cef73dSGregory Neil Shapiro #define SMFIS_NOREPLY	7
266d0cef73dSGregory Neil Shapiro 
267d0cef73dSGregory Neil Shapiro /*
268d0cef73dSGregory Neil Shapiro **  Skip over rest of same callbacks, e.g., body.
269d0cef73dSGregory Neil Shapiro */
270d0cef73dSGregory Neil Shapiro 
271d0cef73dSGregory Neil Shapiro #define SMFIS_SKIP	8
272d0cef73dSGregory Neil Shapiro 
273d0cef73dSGregory Neil Shapiro /* xxfi_negotiate: use all existing protocol options/actions */
274d0cef73dSGregory Neil Shapiro #define SMFIS_ALL_OPTS	10
275d0cef73dSGregory Neil Shapiro 
27606f25ae9SGregory Neil Shapiro #if 0
27706f25ae9SGregory Neil Shapiro /*
27806f25ae9SGregory Neil Shapiro **  Filter Routine Details
27906f25ae9SGregory Neil Shapiro */
28006f25ae9SGregory Neil Shapiro 
28106f25ae9SGregory Neil Shapiro /* connection info filter */
28206f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
28306f25ae9SGregory Neil Shapiro 
28406f25ae9SGregory Neil Shapiro /*
28506f25ae9SGregory Neil Shapiro **  xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
28606f25ae9SGregory Neil Shapiro **
28706f25ae9SGregory Neil Shapiro **	char *hostname; Host domain name, as determined by a reverse lookup
28806f25ae9SGregory Neil Shapiro **		on the host address.
28906f25ae9SGregory Neil Shapiro **	_SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
29006f25ae9SGregory Neil Shapiro **		call on the SMTP socket.
29106f25ae9SGregory Neil Shapiro */
29206f25ae9SGregory Neil Shapiro 
29306f25ae9SGregory Neil Shapiro /* SMTP HELO command filter */
29406f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_helo __P((SMFICTX *, char *));
29506f25ae9SGregory Neil Shapiro 
29606f25ae9SGregory Neil Shapiro /*
29706f25ae9SGregory Neil Shapiro **  xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
29806f25ae9SGregory Neil Shapiro **
29906f25ae9SGregory Neil Shapiro **	char *helohost; Value passed to HELO/EHLO command, which should be
30006f25ae9SGregory Neil Shapiro **		the domain name of the sending host (but is, in practice,
30106f25ae9SGregory Neil Shapiro **		anything the sending host wants to send).
30206f25ae9SGregory Neil Shapiro */
30306f25ae9SGregory Neil Shapiro 
30406f25ae9SGregory Neil Shapiro /* envelope sender filter */
30506f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_envfrom __P((SMFICTX *, char **));
30606f25ae9SGregory Neil Shapiro 
30706f25ae9SGregory Neil Shapiro /*
30806f25ae9SGregory Neil Shapiro **  xxfi_envfrom(ctx, argv) Invoked on envelope from
30906f25ae9SGregory Neil Shapiro **
31006f25ae9SGregory Neil Shapiro **	char **argv; Null-terminated SMTP command arguments;
31106f25ae9SGregory Neil Shapiro **		argv[0] is guaranteed to be the sender address.
31206f25ae9SGregory Neil Shapiro **		Later arguments are the ESMTP arguments.
31306f25ae9SGregory Neil Shapiro */
31406f25ae9SGregory Neil Shapiro 
31506f25ae9SGregory Neil Shapiro /* envelope recipient filter */
31606f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_envrcpt __P((SMFICTX *, char **));
31706f25ae9SGregory Neil Shapiro 
31806f25ae9SGregory Neil Shapiro /*
31906f25ae9SGregory Neil Shapiro **  xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
32006f25ae9SGregory Neil Shapiro **
32106f25ae9SGregory Neil Shapiro **	char **argv; Null-terminated SMTP command arguments;
32206f25ae9SGregory Neil Shapiro **		argv[0] is guaranteed to be the recipient address.
32306f25ae9SGregory Neil Shapiro **		Later arguments are the ESMTP arguments.
32406f25ae9SGregory Neil Shapiro */
32506f25ae9SGregory Neil Shapiro 
326e92d3f3fSGregory Neil Shapiro /* unknown command filter */
327e92d3f3fSGregory Neil Shapiro 
328d0cef73dSGregory Neil Shapiro extern sfsistat	*xxfi_unknown __P((SMFICTX *, const char *));
329e92d3f3fSGregory Neil Shapiro 
330e92d3f3fSGregory Neil Shapiro /*
331e92d3f3fSGregory Neil Shapiro **  xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
332e92d3f3fSGregory Neil Shapiro **  implemented.
333d0cef73dSGregory Neil Shapiro **	const char *arg; Null-terminated SMTP command
334e92d3f3fSGregory Neil Shapiro */
335e92d3f3fSGregory Neil Shapiro 
33606f25ae9SGregory Neil Shapiro /* header filter */
33706f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_header __P((SMFICTX *, char *, char *));
33806f25ae9SGregory Neil Shapiro 
33906f25ae9SGregory Neil Shapiro /*
34006f25ae9SGregory Neil Shapiro **  xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
34106f25ae9SGregory Neil Shapiro **  content of the header may have folded white space (that is, multiple
34206f25ae9SGregory Neil Shapiro **  lines with following white space) included.
34306f25ae9SGregory Neil Shapiro **
34406f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
34506f25ae9SGregory Neil Shapiro **	char *headerv; Header field value
34606f25ae9SGregory Neil Shapiro */
34706f25ae9SGregory Neil Shapiro 
34806f25ae9SGregory Neil Shapiro /* end of header */
34906f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_eoh __P((SMFICTX *));
35006f25ae9SGregory Neil Shapiro 
35106f25ae9SGregory Neil Shapiro /*
35206f25ae9SGregory Neil Shapiro **  xxfi_eoh(ctx) Invoked at end of header
35306f25ae9SGregory Neil Shapiro */
35406f25ae9SGregory Neil Shapiro 
35506f25ae9SGregory Neil Shapiro /* body block */
35640266059SGregory Neil Shapiro extern sfsistat	xxfi_body __P((SMFICTX *, unsigned char *, size_t));
35706f25ae9SGregory Neil Shapiro 
35806f25ae9SGregory Neil Shapiro /*
35906f25ae9SGregory Neil Shapiro **  xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
36006f25ae9SGregory Neil Shapiro **  be multiple body chunks passed to the filter. End-of-lines are
36106f25ae9SGregory Neil Shapiro **  represented as received from SMTP (normally Carriage-Return/Line-Feed).
36206f25ae9SGregory Neil Shapiro **
36340266059SGregory Neil Shapiro **	unsigned char *bodyp; Pointer to body data
36406f25ae9SGregory Neil Shapiro **	size_t bodylen; Length of body data
36506f25ae9SGregory Neil Shapiro */
36606f25ae9SGregory Neil Shapiro 
36706f25ae9SGregory Neil Shapiro /* end of message */
36806f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_eom __P((SMFICTX *));
36906f25ae9SGregory Neil Shapiro 
37006f25ae9SGregory Neil Shapiro /*
37106f25ae9SGregory Neil Shapiro **  xxfi_eom(ctx) Invoked at end of message. This routine can perform
37206f25ae9SGregory Neil Shapiro **  special operations such as modifying the message header, body, or
37306f25ae9SGregory Neil Shapiro **  envelope.
37406f25ae9SGregory Neil Shapiro */
37506f25ae9SGregory Neil Shapiro 
37606f25ae9SGregory Neil Shapiro /* message aborted */
37706f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_abort __P((SMFICTX *));
37806f25ae9SGregory Neil Shapiro 
37906f25ae9SGregory Neil Shapiro /*
38006f25ae9SGregory Neil Shapiro **  xxfi_abort(ctx) Invoked if message is aborted outside of the control of
38106f25ae9SGregory Neil Shapiro **  the filter, for example, if the SMTP sender issues an RSET command. If
38206f25ae9SGregory Neil Shapiro **  xxfi_abort is called, xxfi_eom will not be called and vice versa.
38306f25ae9SGregory Neil Shapiro */
38406f25ae9SGregory Neil Shapiro 
38506f25ae9SGregory Neil Shapiro /* connection cleanup */
38606f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_close __P((SMFICTX *));
38706f25ae9SGregory Neil Shapiro 
38806f25ae9SGregory Neil Shapiro /*
38906f25ae9SGregory Neil Shapiro **  xxfi_close(ctx) Invoked at end of the connection. This is called on
39006f25ae9SGregory Neil Shapiro **  close even if the previous mail transaction was aborted.
39106f25ae9SGregory Neil Shapiro */
39206f25ae9SGregory Neil Shapiro #endif /* 0 */
39306f25ae9SGregory Neil Shapiro 
39406f25ae9SGregory Neil Shapiro /*
39506f25ae9SGregory Neil Shapiro **  Additional information is passed in to the vendor filter routines using
39606f25ae9SGregory Neil Shapiro **  symbols. Symbols correspond closely to sendmail macros. The symbols
39706f25ae9SGregory Neil Shapiro **  defined depend on the context. The value of a symbol is accessed using:
39806f25ae9SGregory Neil Shapiro */
39906f25ae9SGregory Neil Shapiro 
40006f25ae9SGregory Neil Shapiro /* Return the value of a symbol. */
40106f25ae9SGregory Neil Shapiro LIBMILTER_API char * smfi_getsymval __P((SMFICTX *, char *));
40206f25ae9SGregory Neil Shapiro 
40306f25ae9SGregory Neil Shapiro /*
40406f25ae9SGregory Neil Shapiro **  Return the value of a symbol.
40506f25ae9SGregory Neil Shapiro **
40606f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
40706f25ae9SGregory Neil Shapiro **	char *symname; The name of the symbol to access.
40806f25ae9SGregory Neil Shapiro */
40906f25ae9SGregory Neil Shapiro 
41006f25ae9SGregory Neil Shapiro /*
41106f25ae9SGregory Neil Shapiro **  Vendor filter routines that want to pass additional information back to
41206f25ae9SGregory Neil Shapiro **  the MTA for use in SMTP replies may call smfi_setreply before returning.
41306f25ae9SGregory Neil Shapiro */
41406f25ae9SGregory Neil Shapiro 
41506f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
41606f25ae9SGregory Neil Shapiro 
41740266059SGregory Neil Shapiro /*
41840266059SGregory Neil Shapiro **  Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
41940266059SGregory Neil Shapiro **  is needed.
42040266059SGregory Neil Shapiro */
42140266059SGregory Neil Shapiro 
42240266059SGregory Neil Shapiro LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, ...));
42340266059SGregory Neil Shapiro 
42406f25ae9SGregory Neil Shapiro /*
42506f25ae9SGregory Neil Shapiro **  Set the specific reply code to be used in response to the active
42606f25ae9SGregory Neil Shapiro **  command. If not specified, a generic reply code is used.
42706f25ae9SGregory Neil Shapiro **
42806f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
42906f25ae9SGregory Neil Shapiro **	char *rcode; The three-digit (RFC 821) SMTP reply code to be
43006f25ae9SGregory Neil Shapiro **		returned, e.g., ``551''.
43106f25ae9SGregory Neil Shapiro **	char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
43206f25ae9SGregory Neil Shapiro **	char *message; The text part of the SMTP reply.
43306f25ae9SGregory Neil Shapiro */
43406f25ae9SGregory Neil Shapiro 
43506f25ae9SGregory Neil Shapiro /*
43606f25ae9SGregory Neil Shapiro **  The xxfi_eom routine is called at the end of a message (essentially,
43706f25ae9SGregory Neil Shapiro **  after the final DATA dot). This routine can call some special routines
43806f25ae9SGregory Neil Shapiro **  to modify the envelope, header, or body of the message before the
43906f25ae9SGregory Neil Shapiro **  message is enqueued. These routines must not be called from any vendor
44006f25ae9SGregory Neil Shapiro **  routine other than xxfi_eom.
44106f25ae9SGregory Neil Shapiro */
44206f25ae9SGregory Neil Shapiro 
44306f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
44406f25ae9SGregory Neil Shapiro 
44506f25ae9SGregory Neil Shapiro /*
446e92d3f3fSGregory Neil Shapiro **  Add a header to the message. It is not checked for standards
447e92d3f3fSGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
448e92d3f3fSGregory Neil Shapiro **  as a result of adding this header.
44906f25ae9SGregory Neil Shapiro **
45006f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
45106f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
45206f25ae9SGregory Neil Shapiro **	char *headerv; Header field value
45306f25ae9SGregory Neil Shapiro */
45406f25ae9SGregory Neil Shapiro 
45506f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
45606f25ae9SGregory Neil Shapiro 
45706f25ae9SGregory Neil Shapiro /*
45806f25ae9SGregory Neil Shapiro **  Change/delete a header in the message.  It is not checked for standards
45906f25ae9SGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
46006f25ae9SGregory Neil Shapiro **  as a result of adding this header.
46106f25ae9SGregory Neil Shapiro **
46206f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
46306f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
46406f25ae9SGregory Neil Shapiro **	int index; The Nth occurence of header field name
46506f25ae9SGregory Neil Shapiro **	char *headerv; New header field value (empty for delete header)
46606f25ae9SGregory Neil Shapiro */
46706f25ae9SGregory Neil Shapiro 
468e92d3f3fSGregory Neil Shapiro LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
469e92d3f3fSGregory Neil Shapiro 
470e92d3f3fSGregory Neil Shapiro /*
471e92d3f3fSGregory Neil Shapiro **  Insert a header into the message.  It is not checked for standards
472e92d3f3fSGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
473e92d3f3fSGregory Neil Shapiro **  as a result of adding this header.
474e92d3f3fSGregory Neil Shapiro **
475e92d3f3fSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
476e92d3f3fSGregory Neil Shapiro **  	int idx; index into the header list where the insertion should happen
477e92d3f3fSGregory Neil Shapiro **	char *headerh; Header field name
478e92d3f3fSGregory Neil Shapiro **	char *headerv; Header field value
479e92d3f3fSGregory Neil Shapiro */
480e92d3f3fSGregory Neil Shapiro 
481d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *));
482d0cef73dSGregory Neil Shapiro 
483d0cef73dSGregory Neil Shapiro /*
484d0cef73dSGregory Neil Shapiro **  Modify envelope sender address
485d0cef73dSGregory Neil Shapiro **
486d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
487d0cef73dSGregory Neil Shapiro **	char *mail; New envelope sender address
488d0cef73dSGregory Neil Shapiro **	char *args; ESMTP arguments
489d0cef73dSGregory Neil Shapiro */
490d0cef73dSGregory Neil Shapiro 
491d0cef73dSGregory Neil Shapiro 
49206f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
49306f25ae9SGregory Neil Shapiro 
49406f25ae9SGregory Neil Shapiro /*
49506f25ae9SGregory Neil Shapiro **  Add a recipient to the envelope
49606f25ae9SGregory Neil Shapiro **
49706f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
49806f25ae9SGregory Neil Shapiro **	char *rcpt; Recipient to be added
49906f25ae9SGregory Neil Shapiro */
50006f25ae9SGregory Neil Shapiro 
501d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *));
502d0cef73dSGregory Neil Shapiro 
503d0cef73dSGregory Neil Shapiro /*
504d0cef73dSGregory Neil Shapiro **  Add a recipient to the envelope
505d0cef73dSGregory Neil Shapiro **
506d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
507d0cef73dSGregory Neil Shapiro **	char *rcpt; Recipient to be added
508d0cef73dSGregory Neil Shapiro **	char *args; ESMTP arguments
509d0cef73dSGregory Neil Shapiro */
510d0cef73dSGregory Neil Shapiro 
511d0cef73dSGregory Neil Shapiro 
51206f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
51306f25ae9SGregory Neil Shapiro 
514605302a5SGregory Neil Shapiro /*
515605302a5SGregory Neil Shapiro **  Send a "no-op" up to the MTA to tell it we're still alive, so long
516605302a5SGregory Neil Shapiro **  milter-side operations don't time out.
517605302a5SGregory Neil Shapiro **
518605302a5SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
519605302a5SGregory Neil Shapiro */
520605302a5SGregory Neil Shapiro 
521605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_progress __P((SMFICTX *));
522605302a5SGregory Neil Shapiro 
52306f25ae9SGregory Neil Shapiro /*
52406f25ae9SGregory Neil Shapiro **  Delete a recipient from the envelope
52506f25ae9SGregory Neil Shapiro **
52606f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
52706f25ae9SGregory Neil Shapiro **	char *rcpt; Envelope recipient to be deleted. This should be in
52806f25ae9SGregory Neil Shapiro **		exactly the form passed to xxfi_envrcpt or the address may
52906f25ae9SGregory Neil Shapiro **		not be deleted.
53006f25ae9SGregory Neil Shapiro */
53106f25ae9SGregory Neil Shapiro 
53240266059SGregory Neil Shapiro LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
53306f25ae9SGregory Neil Shapiro 
53406f25ae9SGregory Neil Shapiro /*
53506f25ae9SGregory Neil Shapiro **  Replace the body of the message. This routine may be called multiple
53606f25ae9SGregory Neil Shapiro **  times if the body is longer than convenient to send in one call. End of
53706f25ae9SGregory Neil Shapiro **  line should be represented as Carriage-Return/Line Feed.
53806f25ae9SGregory Neil Shapiro **
53906f25ae9SGregory Neil Shapiro **	char *bodyp; Pointer to block of body information to insert
54006f25ae9SGregory Neil Shapiro **	int bodylen; Length of data pointed at by bodyp
54106f25ae9SGregory Neil Shapiro */
54206f25ae9SGregory Neil Shapiro 
54306f25ae9SGregory Neil Shapiro /*
54406f25ae9SGregory Neil Shapiro **  If the message is aborted (for example, if the SMTP sender sends the
54506f25ae9SGregory Neil Shapiro **  envelope but then does a QUIT or RSET before the data is sent),
54606f25ae9SGregory Neil Shapiro **  xxfi_abort is called. This can be used to reset state.
54706f25ae9SGregory Neil Shapiro */
54806f25ae9SGregory Neil Shapiro 
54940266059SGregory Neil Shapiro /*
55040266059SGregory Neil Shapiro **  Quarantine an envelope
55140266059SGregory Neil Shapiro **
55240266059SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
55340266059SGregory Neil Shapiro **	char *reason: explanation
55440266059SGregory Neil Shapiro */
55540266059SGregory Neil Shapiro 
55640266059SGregory Neil Shapiro LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
55706f25ae9SGregory Neil Shapiro 
55806f25ae9SGregory Neil Shapiro /*
55906f25ae9SGregory Neil Shapiro **  Connection-private data (specific to an SMTP connection) can be
56006f25ae9SGregory Neil Shapiro **  allocated using the smfi_setpriv routine; routines can access private
56106f25ae9SGregory Neil Shapiro **  data using smfi_getpriv.
56206f25ae9SGregory Neil Shapiro */
56306f25ae9SGregory Neil Shapiro 
56406f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
56506f25ae9SGregory Neil Shapiro 
56606f25ae9SGregory Neil Shapiro /*
56706f25ae9SGregory Neil Shapiro **  Set the private data pointer
56806f25ae9SGregory Neil Shapiro **
56906f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
57006f25ae9SGregory Neil Shapiro **	void *privatedata; Pointer to private data area
57106f25ae9SGregory Neil Shapiro */
57206f25ae9SGregory Neil Shapiro 
57306f25ae9SGregory Neil Shapiro LIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
57406f25ae9SGregory Neil Shapiro 
575d0cef73dSGregory Neil Shapiro /*
576d0cef73dSGregory Neil Shapiro **  Get the private data pointer
577d0cef73dSGregory Neil Shapiro **
578d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
579d0cef73dSGregory Neil Shapiro **	void *privatedata; Pointer to private data area
580d0cef73dSGregory Neil Shapiro */
581d0cef73dSGregory Neil Shapiro 
582d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *));
583d0cef73dSGregory Neil Shapiro 
584d0cef73dSGregory Neil Shapiro /*
585d0cef73dSGregory Neil Shapiro **  Set list of symbols (macros) to receive
586d0cef73dSGregory Neil Shapiro **
587d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
588d0cef73dSGregory Neil Shapiro **	int where; where in the SMTP dialogue should the macros be sent
589d0cef73dSGregory Neil Shapiro **	char *macros; list of macros (space separated)
590d0cef73dSGregory Neil Shapiro */
591d0cef73dSGregory Neil Shapiro 
592d0cef73dSGregory Neil Shapiro #if _FFR_THREAD_MONITOR
593d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int));
594d0cef73dSGregory Neil Shapiro #endif /* _FFR_THREAD_MONITOR */
595d0cef73dSGregory Neil Shapiro 
596e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus
597e92d3f3fSGregory Neil Shapiro }
598e92d3f3fSGregory Neil Shapiro #endif /* __cplusplus */
59906f25ae9SGregory Neil Shapiro 
60006f25ae9SGregory Neil Shapiro #endif /* ! _LIBMILTER_MFAPI_H */
601