xref: /freebsd/contrib/sendmail/include/libmilter/mfapi.h (revision 2fb4f839f3fc72ce2bab12f9ba4760f97f73e97f)
106f25ae9SGregory Neil Shapiro /*
25dd76dd0SGregory Neil Shapiro  * Copyright (c) 1999-2004, 2006, 2008, 2012 Proofpoint, 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  *
104313cc83SGregory Neil Shapiro  *	$Id: mfapi.h,v 8.83 2013-11-22 20:51:27 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" {
46*5b0945b5SGregory Neil Shapiro #endif
47e92d3f3fSGregory Neil Shapiro 
4806f25ae9SGregory Neil Shapiro #ifndef _SOCK_ADDR
4906f25ae9SGregory Neil Shapiro # define _SOCK_ADDR	struct sockaddr
50*5b0945b5SGregory Neil Shapiro #endif
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
61*5b0945b5SGregory Neil Shapiro #endif
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)
79*5b0945b5SGregory Neil Shapiro #else
8006f25ae9SGregory Neil Shapiro # define SM__P(X)	__P(X)
81*5b0945b5SGregory Neil Shapiro #endif
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
87*5b0945b5SGregory Neil Shapiro # else
8806f25ae9SGregory Neil Shapiro #  define __P(X) ()
89*5b0945b5SGregory Neil Shapiro # endif
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;
990d3a0b40SGregory Neil Shapiro #    define false	0
1000d3a0b40SGregory Neil Shapiro #    define true	1
101e92d3f3fSGregory Neil Shapiro #    define __bool_true_false_are_defined	1
102e92d3f3fSGregory Neil Shapiro #   endif /* ! __bool_true_false_are_defined */
103e92d3f3fSGregory Neil Shapiro #  endif /* bool */
104e92d3f3fSGregory Neil Shapiro # endif /* ! __cplusplus */
105e92d3f3fSGregory Neil Shapiro #endif /* SM_CONF_STDBOOL_H */
106e92d3f3fSGregory Neil Shapiro 
10740266059SGregory Neil Shapiro /*
10840266059SGregory Neil Shapiro **  structure describing one milter
10940266059SGregory Neil Shapiro */
11040266059SGregory Neil Shapiro 
11106f25ae9SGregory Neil Shapiro struct smfiDesc
11206f25ae9SGregory Neil Shapiro {
11306f25ae9SGregory Neil Shapiro 	char		*xxfi_name;	/* filter name */
11406f25ae9SGregory Neil Shapiro 	int		xxfi_version;	/* version code -- do not change */
11540266059SGregory Neil Shapiro 	unsigned long	xxfi_flags;	/* flags */
11606f25ae9SGregory Neil Shapiro 
11706f25ae9SGregory Neil Shapiro 	/* connection info filter */
11806f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_connect) SM__P((SMFICTX *, char *, _SOCK_ADDR *));
11906f25ae9SGregory Neil Shapiro 
12006f25ae9SGregory Neil Shapiro 	/* SMTP HELO command filter */
12106f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_helo) SM__P((SMFICTX *, char *));
12206f25ae9SGregory Neil Shapiro 
12306f25ae9SGregory Neil Shapiro 	/* envelope sender filter */
12406f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_envfrom) SM__P((SMFICTX *, char **));
12506f25ae9SGregory Neil Shapiro 
12606f25ae9SGregory Neil Shapiro 	/* envelope recipient filter */
12706f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_envrcpt) SM__P((SMFICTX *, char **));
12806f25ae9SGregory Neil Shapiro 
12906f25ae9SGregory Neil Shapiro 	/* header filter */
13006f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_header) SM__P((SMFICTX *, char *, char *));
13106f25ae9SGregory Neil Shapiro 
13206f25ae9SGregory Neil Shapiro 	/* end of header */
13306f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_eoh) SM__P((SMFICTX *));
13406f25ae9SGregory Neil Shapiro 
13506f25ae9SGregory Neil Shapiro 	/* body block */
13640266059SGregory Neil Shapiro 	sfsistat	(*xxfi_body) SM__P((SMFICTX *, unsigned char *, size_t));
13706f25ae9SGregory Neil Shapiro 
13806f25ae9SGregory Neil Shapiro 	/* end of message */
13906f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_eom) SM__P((SMFICTX *));
14006f25ae9SGregory Neil Shapiro 
14106f25ae9SGregory Neil Shapiro 	/* message aborted */
14206f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_abort) SM__P((SMFICTX *));
14306f25ae9SGregory Neil Shapiro 
14406f25ae9SGregory Neil Shapiro 	/* connection cleanup */
14506f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_close) SM__P((SMFICTX *));
146e92d3f3fSGregory Neil Shapiro 
147e92d3f3fSGregory Neil Shapiro 	/* any unrecognized or unimplemented command filter */
148d0cef73dSGregory Neil Shapiro 	sfsistat	(*xxfi_unknown) SM__P((SMFICTX *, const char *));
149e92d3f3fSGregory Neil Shapiro 
150af9557fdSGregory Neil Shapiro 	/* SMTP DATA command filter */
151e92d3f3fSGregory Neil Shapiro 	sfsistat	(*xxfi_data) SM__P((SMFICTX *));
152d0cef73dSGregory Neil Shapiro 
153d0cef73dSGregory Neil Shapiro 	/* negotiation callback */
154d0cef73dSGregory Neil Shapiro 	sfsistat	(*xxfi_negotiate) SM__P((SMFICTX *,
155d0cef73dSGregory Neil Shapiro 					unsigned long, unsigned long,
156d0cef73dSGregory Neil Shapiro 					unsigned long, unsigned long,
157d0cef73dSGregory Neil Shapiro 					unsigned long *, unsigned long *,
158d0cef73dSGregory Neil Shapiro 					unsigned long *, unsigned long *));
159d0cef73dSGregory Neil Shapiro 
160d0cef73dSGregory Neil Shapiro #if 0
161d0cef73dSGregory Neil Shapiro 	/* signal handler callback, not yet implemented. */
162d0cef73dSGregory Neil Shapiro 	int		(*xxfi_signal) SM__P((int));
163d0cef73dSGregory Neil Shapiro #endif
164d0cef73dSGregory Neil Shapiro 
16506f25ae9SGregory Neil Shapiro };
16606f25ae9SGregory Neil Shapiro 
167323f6dcbSGregory Neil Shapiro LIBMILTER_API int smfi_opensocket __P((bool));
16806f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_register __P((struct smfiDesc));
16906f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_main __P((void));
170605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_setbacklog __P((int));
17106f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setdbg __P((int));
17206f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_settimeout __P((int));
17306f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setconn __P((char *));
17442e5d165SGregory Neil Shapiro LIBMILTER_API int smfi_stop __P((void));
175e92d3f3fSGregory Neil Shapiro LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
176d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *, unsigned int *));
17740266059SGregory Neil Shapiro 
17840266059SGregory Neil Shapiro /*
17940266059SGregory Neil Shapiro **  What the filter might do -- values to be ORed together for
18040266059SGregory Neil Shapiro **  smfiDesc.xxfi_flags.
18140266059SGregory Neil Shapiro */
18240266059SGregory Neil Shapiro 
18340266059SGregory Neil Shapiro #define SMFIF_NONE	0x00000000L	/* no flags */
18440266059SGregory Neil Shapiro #define SMFIF_ADDHDRS	0x00000001L	/* filter may add headers */
18540266059SGregory Neil Shapiro #define SMFIF_CHGBODY	0x00000002L	/* filter may replace body */
18640266059SGregory Neil Shapiro #define SMFIF_MODBODY	SMFIF_CHGBODY	/* backwards compatible */
18740266059SGregory Neil Shapiro #define SMFIF_ADDRCPT	0x00000004L	/* filter may add recipients */
18840266059SGregory Neil Shapiro #define SMFIF_DELRCPT	0x00000008L	/* filter may delete recipients */
18940266059SGregory Neil Shapiro #define SMFIF_CHGHDRS	0x00000010L	/* filter may change/delete headers */
19040266059SGregory Neil Shapiro #define SMFIF_QUARANTINE 0x00000020L	/* filter may quarantine envelope */
19140266059SGregory Neil Shapiro 
192d0cef73dSGregory Neil Shapiro /* filter may change "from" (envelope sender) */
193d0cef73dSGregory Neil Shapiro #define SMFIF_CHGFROM	0x00000040L
194d0cef73dSGregory Neil Shapiro #define SMFIF_ADDRCPT_PAR	0x00000080L	/* add recipients incl. args */
195d0cef73dSGregory Neil Shapiro 
196d0cef73dSGregory Neil Shapiro /* filter can send set of symbols (macros) that it wants */
197d0cef73dSGregory Neil Shapiro #define SMFIF_SETSYMLIST	0x00000100L
198d0cef73dSGregory Neil Shapiro 
199d0cef73dSGregory Neil Shapiro 
200d0cef73dSGregory Neil Shapiro /*
201d0cef73dSGregory Neil Shapiro **  Macro "places";
202d0cef73dSGregory Neil Shapiro **  Notes:
203d0cef73dSGregory Neil Shapiro **  - must be coordinated with libmilter/engine.c and sendmail/milter.c
204d0cef73dSGregory Neil Shapiro **  - the order MUST NOT be changed as it would break compatibility between
205d0cef73dSGregory Neil Shapiro **	different versions. It's ok to append new entries however
206d0cef73dSGregory Neil Shapiro **	(hence the list is not sorted by the SMT protocol steps).
207d0cef73dSGregory Neil Shapiro */
208d0cef73dSGregory Neil Shapiro 
209ba00ec3dSGregory Neil Shapiro #define SMFIM_NOMACROS	(-1)	/* Do NOT use, internal only */
210d0cef73dSGregory Neil Shapiro #define SMFIM_FIRST	0	/* Do NOT use, internal marker only */
211d0cef73dSGregory Neil Shapiro #define SMFIM_CONNECT	0	/* connect */
212d0cef73dSGregory Neil Shapiro #define SMFIM_HELO	1	/* HELO/EHLO */
213d0cef73dSGregory Neil Shapiro #define SMFIM_ENVFROM	2	/* MAIL From */
214d0cef73dSGregory Neil Shapiro #define SMFIM_ENVRCPT	3	/* RCPT To */
215d0cef73dSGregory Neil Shapiro #define SMFIM_DATA	4	/* DATA */
216d0cef73dSGregory Neil Shapiro #define SMFIM_EOM	5	/* end of message (final dot) */
217d0cef73dSGregory Neil Shapiro #define SMFIM_EOH	6	/* end of header */
218d0cef73dSGregory Neil Shapiro #define SMFIM_LAST	6	/* Do NOT use, internal marker only */
219d0cef73dSGregory Neil Shapiro 
22006f25ae9SGregory Neil Shapiro /*
22106f25ae9SGregory Neil Shapiro **  Continue processing message/connection.
22206f25ae9SGregory Neil Shapiro */
22306f25ae9SGregory Neil Shapiro 
22406f25ae9SGregory Neil Shapiro #define SMFIS_CONTINUE	0
22506f25ae9SGregory Neil Shapiro 
22606f25ae9SGregory Neil Shapiro /*
22706f25ae9SGregory Neil Shapiro **  Reject the message/connection.
22806f25ae9SGregory Neil Shapiro **  No further routines will be called for this message
22906f25ae9SGregory Neil Shapiro **  (or connection, if returned from a connection-oriented routine).
23006f25ae9SGregory Neil Shapiro */
23106f25ae9SGregory Neil Shapiro 
23206f25ae9SGregory Neil Shapiro #define SMFIS_REJECT	1
23306f25ae9SGregory Neil Shapiro 
23406f25ae9SGregory Neil Shapiro /*
23506f25ae9SGregory Neil Shapiro **  Accept the message,
23606f25ae9SGregory Neil Shapiro **  but silently discard the message.
23706f25ae9SGregory Neil Shapiro **  No further routines will be called for this message.
23806f25ae9SGregory Neil Shapiro **  This is only meaningful from message-oriented routines.
23906f25ae9SGregory Neil Shapiro */
24006f25ae9SGregory Neil Shapiro 
24106f25ae9SGregory Neil Shapiro #define SMFIS_DISCARD	2
24206f25ae9SGregory Neil Shapiro 
24306f25ae9SGregory Neil Shapiro /*
24406f25ae9SGregory Neil Shapiro **  Accept the message/connection.
24506f25ae9SGregory Neil Shapiro **  No further routines will be called for this message
24606f25ae9SGregory Neil Shapiro **  (or connection, if returned from a connection-oriented routine;
24706f25ae9SGregory Neil Shapiro **  in this case, it causes all messages on this connection
24806f25ae9SGregory Neil Shapiro **  to be accepted without filtering).
24906f25ae9SGregory Neil Shapiro */
25006f25ae9SGregory Neil Shapiro 
25106f25ae9SGregory Neil Shapiro #define SMFIS_ACCEPT	3
25206f25ae9SGregory Neil Shapiro 
25306f25ae9SGregory Neil Shapiro /*
25406f25ae9SGregory Neil Shapiro **  Return a temporary failure, i.e.,
25506f25ae9SGregory Neil Shapiro **  the corresponding SMTP command will return a 4xx status code.
25606f25ae9SGregory Neil Shapiro **  In some cases this may prevent further routines from
25706f25ae9SGregory Neil Shapiro **  being called on this message or connection,
25806f25ae9SGregory Neil Shapiro **  although in other cases (e.g., when processing an envelope
25906f25ae9SGregory Neil Shapiro **  recipient) processing of the message will continue.
26006f25ae9SGregory Neil Shapiro */
26106f25ae9SGregory Neil Shapiro 
26206f25ae9SGregory Neil Shapiro #define SMFIS_TEMPFAIL	4
26306f25ae9SGregory Neil Shapiro 
264d0cef73dSGregory Neil Shapiro /*
265d0cef73dSGregory Neil Shapiro **  Do not send a reply to the MTA
266d0cef73dSGregory Neil Shapiro */
267d0cef73dSGregory Neil Shapiro 
268d0cef73dSGregory Neil Shapiro #define SMFIS_NOREPLY	7
269d0cef73dSGregory Neil Shapiro 
270d0cef73dSGregory Neil Shapiro /*
271d0cef73dSGregory Neil Shapiro **  Skip over rest of same callbacks, e.g., body.
272d0cef73dSGregory Neil Shapiro */
273d0cef73dSGregory Neil Shapiro 
274d0cef73dSGregory Neil Shapiro #define SMFIS_SKIP	8
275d0cef73dSGregory Neil Shapiro 
276d0cef73dSGregory Neil Shapiro /* xxfi_negotiate: use all existing protocol options/actions */
277d0cef73dSGregory Neil Shapiro #define SMFIS_ALL_OPTS	10
278d0cef73dSGregory Neil Shapiro 
27906f25ae9SGregory Neil Shapiro #if 0
28006f25ae9SGregory Neil Shapiro /*
28106f25ae9SGregory Neil Shapiro **  Filter Routine Details
28206f25ae9SGregory Neil Shapiro */
28306f25ae9SGregory Neil Shapiro 
28406f25ae9SGregory Neil Shapiro /* connection info filter */
28506f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
28606f25ae9SGregory Neil Shapiro 
28706f25ae9SGregory Neil Shapiro /*
28806f25ae9SGregory Neil Shapiro **  xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
28906f25ae9SGregory Neil Shapiro **
29006f25ae9SGregory Neil Shapiro **	char *hostname; Host domain name, as determined by a reverse lookup
29106f25ae9SGregory Neil Shapiro **		on the host address.
29206f25ae9SGregory Neil Shapiro **	_SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
29306f25ae9SGregory Neil Shapiro **		call on the SMTP socket.
29406f25ae9SGregory Neil Shapiro */
29506f25ae9SGregory Neil Shapiro 
29606f25ae9SGregory Neil Shapiro /* SMTP HELO command filter */
29706f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_helo __P((SMFICTX *, char *));
29806f25ae9SGregory Neil Shapiro 
29906f25ae9SGregory Neil Shapiro /*
30006f25ae9SGregory Neil Shapiro **  xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
30106f25ae9SGregory Neil Shapiro **
30206f25ae9SGregory Neil Shapiro **	char *helohost; Value passed to HELO/EHLO command, which should be
30306f25ae9SGregory Neil Shapiro **		the domain name of the sending host (but is, in practice,
30406f25ae9SGregory Neil Shapiro **		anything the sending host wants to send).
30506f25ae9SGregory Neil Shapiro */
30606f25ae9SGregory Neil Shapiro 
30706f25ae9SGregory Neil Shapiro /* envelope sender filter */
30806f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_envfrom __P((SMFICTX *, char **));
30906f25ae9SGregory Neil Shapiro 
31006f25ae9SGregory Neil Shapiro /*
31106f25ae9SGregory Neil Shapiro **  xxfi_envfrom(ctx, argv) Invoked on envelope from
31206f25ae9SGregory Neil Shapiro **
31306f25ae9SGregory Neil Shapiro **	char **argv; Null-terminated SMTP command arguments;
31406f25ae9SGregory Neil Shapiro **		argv[0] is guaranteed to be the sender address.
31506f25ae9SGregory Neil Shapiro **		Later arguments are the ESMTP arguments.
31606f25ae9SGregory Neil Shapiro */
31706f25ae9SGregory Neil Shapiro 
31806f25ae9SGregory Neil Shapiro /* envelope recipient filter */
31906f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_envrcpt __P((SMFICTX *, char **));
32006f25ae9SGregory Neil Shapiro 
32106f25ae9SGregory Neil Shapiro /*
32206f25ae9SGregory Neil Shapiro **  xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
32306f25ae9SGregory Neil Shapiro **
32406f25ae9SGregory Neil Shapiro **	char **argv; Null-terminated SMTP command arguments;
32506f25ae9SGregory Neil Shapiro **		argv[0] is guaranteed to be the recipient address.
32606f25ae9SGregory Neil Shapiro **		Later arguments are the ESMTP arguments.
32706f25ae9SGregory Neil Shapiro */
32806f25ae9SGregory Neil Shapiro 
329e92d3f3fSGregory Neil Shapiro /* unknown command filter */
330e92d3f3fSGregory Neil Shapiro 
331d0cef73dSGregory Neil Shapiro extern sfsistat	*xxfi_unknown __P((SMFICTX *, const char *));
332e92d3f3fSGregory Neil Shapiro 
333e92d3f3fSGregory Neil Shapiro /*
334e92d3f3fSGregory Neil Shapiro **  xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
335e92d3f3fSGregory Neil Shapiro **  implemented.
336d0cef73dSGregory Neil Shapiro **	const char *arg; Null-terminated SMTP command
337e92d3f3fSGregory Neil Shapiro */
338e92d3f3fSGregory Neil Shapiro 
33906f25ae9SGregory Neil Shapiro /* header filter */
34006f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_header __P((SMFICTX *, char *, char *));
34106f25ae9SGregory Neil Shapiro 
34206f25ae9SGregory Neil Shapiro /*
34306f25ae9SGregory Neil Shapiro **  xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
34406f25ae9SGregory Neil Shapiro **  content of the header may have folded white space (that is, multiple
34506f25ae9SGregory Neil Shapiro **  lines with following white space) included.
34606f25ae9SGregory Neil Shapiro **
34706f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
34806f25ae9SGregory Neil Shapiro **	char *headerv; Header field value
34906f25ae9SGregory Neil Shapiro */
35006f25ae9SGregory Neil Shapiro 
35106f25ae9SGregory Neil Shapiro /* end of header */
35206f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_eoh __P((SMFICTX *));
35306f25ae9SGregory Neil Shapiro 
35406f25ae9SGregory Neil Shapiro /*
35506f25ae9SGregory Neil Shapiro **  xxfi_eoh(ctx) Invoked at end of header
35606f25ae9SGregory Neil Shapiro */
35706f25ae9SGregory Neil Shapiro 
35806f25ae9SGregory Neil Shapiro /* body block */
35940266059SGregory Neil Shapiro extern sfsistat	xxfi_body __P((SMFICTX *, unsigned char *, size_t));
36006f25ae9SGregory Neil Shapiro 
36106f25ae9SGregory Neil Shapiro /*
36206f25ae9SGregory Neil Shapiro **  xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
36306f25ae9SGregory Neil Shapiro **  be multiple body chunks passed to the filter. End-of-lines are
36406f25ae9SGregory Neil Shapiro **  represented as received from SMTP (normally Carriage-Return/Line-Feed).
36506f25ae9SGregory Neil Shapiro **
36640266059SGregory Neil Shapiro **	unsigned char *bodyp; Pointer to body data
36706f25ae9SGregory Neil Shapiro **	size_t bodylen; Length of body data
36806f25ae9SGregory Neil Shapiro */
36906f25ae9SGregory Neil Shapiro 
37006f25ae9SGregory Neil Shapiro /* end of message */
37106f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_eom __P((SMFICTX *));
37206f25ae9SGregory Neil Shapiro 
37306f25ae9SGregory Neil Shapiro /*
37406f25ae9SGregory Neil Shapiro **  xxfi_eom(ctx) Invoked at end of message. This routine can perform
37506f25ae9SGregory Neil Shapiro **  special operations such as modifying the message header, body, or
37606f25ae9SGregory Neil Shapiro **  envelope.
37706f25ae9SGregory Neil Shapiro */
37806f25ae9SGregory Neil Shapiro 
37906f25ae9SGregory Neil Shapiro /* message aborted */
38006f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_abort __P((SMFICTX *));
38106f25ae9SGregory Neil Shapiro 
38206f25ae9SGregory Neil Shapiro /*
38306f25ae9SGregory Neil Shapiro **  xxfi_abort(ctx) Invoked if message is aborted outside of the control of
38406f25ae9SGregory Neil Shapiro **  the filter, for example, if the SMTP sender issues an RSET command. If
38506f25ae9SGregory Neil Shapiro **  xxfi_abort is called, xxfi_eom will not be called and vice versa.
38606f25ae9SGregory Neil Shapiro */
38706f25ae9SGregory Neil Shapiro 
38806f25ae9SGregory Neil Shapiro /* connection cleanup */
38906f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_close __P((SMFICTX *));
39006f25ae9SGregory Neil Shapiro 
39106f25ae9SGregory Neil Shapiro /*
39206f25ae9SGregory Neil Shapiro **  xxfi_close(ctx) Invoked at end of the connection. This is called on
39306f25ae9SGregory Neil Shapiro **  close even if the previous mail transaction was aborted.
39406f25ae9SGregory Neil Shapiro */
39506f25ae9SGregory Neil Shapiro #endif /* 0 */
39606f25ae9SGregory Neil Shapiro 
39706f25ae9SGregory Neil Shapiro /*
39806f25ae9SGregory Neil Shapiro **  Additional information is passed in to the vendor filter routines using
39906f25ae9SGregory Neil Shapiro **  symbols. Symbols correspond closely to sendmail macros. The symbols
40006f25ae9SGregory Neil Shapiro **  defined depend on the context. The value of a symbol is accessed using:
40106f25ae9SGregory Neil Shapiro */
40206f25ae9SGregory Neil Shapiro 
40306f25ae9SGregory Neil Shapiro /* Return the value of a symbol. */
40406f25ae9SGregory Neil Shapiro LIBMILTER_API char * smfi_getsymval __P((SMFICTX *, char *));
40506f25ae9SGregory Neil Shapiro 
40606f25ae9SGregory Neil Shapiro /*
40706f25ae9SGregory Neil Shapiro **  Return the value of a symbol.
40806f25ae9SGregory Neil Shapiro **
40906f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
41006f25ae9SGregory Neil Shapiro **	char *symname; The name of the symbol to access.
41106f25ae9SGregory Neil Shapiro */
41206f25ae9SGregory Neil Shapiro 
41306f25ae9SGregory Neil Shapiro /*
41406f25ae9SGregory Neil Shapiro **  Vendor filter routines that want to pass additional information back to
41506f25ae9SGregory Neil Shapiro **  the MTA for use in SMTP replies may call smfi_setreply before returning.
41606f25ae9SGregory Neil Shapiro */
41706f25ae9SGregory Neil Shapiro 
41806f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
41906f25ae9SGregory Neil Shapiro 
42040266059SGregory Neil Shapiro /*
42140266059SGregory Neil Shapiro **  Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
42240266059SGregory Neil Shapiro **  is needed.
42340266059SGregory Neil Shapiro */
42440266059SGregory Neil Shapiro 
42540266059SGregory Neil Shapiro LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, ...));
42640266059SGregory Neil Shapiro 
42706f25ae9SGregory Neil Shapiro /*
42806f25ae9SGregory Neil Shapiro **  Set the specific reply code to be used in response to the active
42906f25ae9SGregory Neil Shapiro **  command. If not specified, a generic reply code is used.
43006f25ae9SGregory Neil Shapiro **
43106f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
43206f25ae9SGregory Neil Shapiro **	char *rcode; The three-digit (RFC 821) SMTP reply code to be
43306f25ae9SGregory Neil Shapiro **		returned, e.g., ``551''.
43406f25ae9SGregory Neil Shapiro **	char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
43506f25ae9SGregory Neil Shapiro **	char *message; The text part of the SMTP reply.
43606f25ae9SGregory Neil Shapiro */
43706f25ae9SGregory Neil Shapiro 
43806f25ae9SGregory Neil Shapiro /*
43906f25ae9SGregory Neil Shapiro **  The xxfi_eom routine is called at the end of a message (essentially,
44006f25ae9SGregory Neil Shapiro **  after the final DATA dot). This routine can call some special routines
44106f25ae9SGregory Neil Shapiro **  to modify the envelope, header, or body of the message before the
44206f25ae9SGregory Neil Shapiro **  message is enqueued. These routines must not be called from any vendor
44306f25ae9SGregory Neil Shapiro **  routine other than xxfi_eom.
44406f25ae9SGregory Neil Shapiro */
44506f25ae9SGregory Neil Shapiro 
44606f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
44706f25ae9SGregory Neil Shapiro 
44806f25ae9SGregory Neil Shapiro /*
449e92d3f3fSGregory Neil Shapiro **  Add a header to the message. It is not checked for standards
450e92d3f3fSGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
451e92d3f3fSGregory Neil Shapiro **  as a result of adding this header.
45206f25ae9SGregory Neil Shapiro **
45306f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
45406f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
45506f25ae9SGregory Neil Shapiro **	char *headerv; Header field value
45606f25ae9SGregory Neil Shapiro */
45706f25ae9SGregory Neil Shapiro 
45806f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
45906f25ae9SGregory Neil Shapiro 
46006f25ae9SGregory Neil Shapiro /*
46106f25ae9SGregory Neil Shapiro **  Change/delete a header in the message.  It is not checked for standards
46206f25ae9SGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
46306f25ae9SGregory Neil Shapiro **  as a result of adding this header.
46406f25ae9SGregory Neil Shapiro **
46506f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
46606f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
467*5b0945b5SGregory Neil Shapiro **	int index; The Nth occurrence of header field name
46806f25ae9SGregory Neil Shapiro **	char *headerv; New header field value (empty for delete header)
46906f25ae9SGregory Neil Shapiro */
47006f25ae9SGregory Neil Shapiro 
471e92d3f3fSGregory Neil Shapiro LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
472e92d3f3fSGregory Neil Shapiro 
473e92d3f3fSGregory Neil Shapiro /*
474e92d3f3fSGregory Neil Shapiro **  Insert a header into the message.  It is not checked for standards
475e92d3f3fSGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
476e92d3f3fSGregory Neil Shapiro **  as a result of adding this header.
477e92d3f3fSGregory Neil Shapiro **
478e92d3f3fSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
479e92d3f3fSGregory Neil Shapiro **	int idx; index into the header list where the insertion should happen
480e92d3f3fSGregory Neil Shapiro **	char *headerh; Header field name
481e92d3f3fSGregory Neil Shapiro **	char *headerv; Header field value
482e92d3f3fSGregory Neil Shapiro */
483e92d3f3fSGregory Neil Shapiro 
484d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *));
485d0cef73dSGregory Neil Shapiro 
486d0cef73dSGregory Neil Shapiro /*
487d0cef73dSGregory Neil Shapiro **  Modify envelope sender address
488d0cef73dSGregory Neil Shapiro **
489d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
490d0cef73dSGregory Neil Shapiro **	char *mail; New envelope sender address
491d0cef73dSGregory Neil Shapiro **	char *args; ESMTP arguments
492d0cef73dSGregory Neil Shapiro */
493d0cef73dSGregory Neil Shapiro 
494d0cef73dSGregory Neil Shapiro 
49506f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
49606f25ae9SGregory Neil Shapiro 
49706f25ae9SGregory Neil Shapiro /*
49806f25ae9SGregory Neil Shapiro **  Add a recipient to the envelope
49906f25ae9SGregory Neil Shapiro **
50006f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
50106f25ae9SGregory Neil Shapiro **	char *rcpt; Recipient to be added
50206f25ae9SGregory Neil Shapiro */
50306f25ae9SGregory Neil Shapiro 
504d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *));
505d0cef73dSGregory Neil Shapiro 
506d0cef73dSGregory Neil Shapiro /*
507d0cef73dSGregory Neil Shapiro **  Add a recipient to the envelope
508d0cef73dSGregory Neil Shapiro **
509d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
510d0cef73dSGregory Neil Shapiro **	char *rcpt; Recipient to be added
511d0cef73dSGregory Neil Shapiro **	char *args; ESMTP arguments
512d0cef73dSGregory Neil Shapiro */
513d0cef73dSGregory Neil Shapiro 
514d0cef73dSGregory Neil Shapiro 
51506f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
51606f25ae9SGregory Neil Shapiro 
517605302a5SGregory Neil Shapiro /*
518605302a5SGregory Neil Shapiro **  Send a "no-op" up to the MTA to tell it we're still alive, so long
519605302a5SGregory Neil Shapiro **  milter-side operations don't time out.
520605302a5SGregory Neil Shapiro **
521605302a5SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
522605302a5SGregory Neil Shapiro */
523605302a5SGregory Neil Shapiro 
524605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_progress __P((SMFICTX *));
525605302a5SGregory Neil Shapiro 
52606f25ae9SGregory Neil Shapiro /*
52706f25ae9SGregory Neil Shapiro **  Delete a recipient from the envelope
52806f25ae9SGregory Neil Shapiro **
52906f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
53006f25ae9SGregory Neil Shapiro **	char *rcpt; Envelope recipient to be deleted. This should be in
53106f25ae9SGregory Neil Shapiro **		exactly the form passed to xxfi_envrcpt or the address may
53206f25ae9SGregory Neil Shapiro **		not be deleted.
53306f25ae9SGregory Neil Shapiro */
53406f25ae9SGregory Neil Shapiro 
53540266059SGregory Neil Shapiro LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
53606f25ae9SGregory Neil Shapiro 
53706f25ae9SGregory Neil Shapiro /*
53806f25ae9SGregory Neil Shapiro **  Replace the body of the message. This routine may be called multiple
53906f25ae9SGregory Neil Shapiro **  times if the body is longer than convenient to send in one call. End of
54006f25ae9SGregory Neil Shapiro **  line should be represented as Carriage-Return/Line Feed.
54106f25ae9SGregory Neil Shapiro **
54206f25ae9SGregory Neil Shapiro **	char *bodyp; Pointer to block of body information to insert
54306f25ae9SGregory Neil Shapiro **	int bodylen; Length of data pointed at by bodyp
54406f25ae9SGregory Neil Shapiro */
54506f25ae9SGregory Neil Shapiro 
54606f25ae9SGregory Neil Shapiro /*
54706f25ae9SGregory Neil Shapiro **  If the message is aborted (for example, if the SMTP sender sends the
54806f25ae9SGregory Neil Shapiro **  envelope but then does a QUIT or RSET before the data is sent),
54906f25ae9SGregory Neil Shapiro **  xxfi_abort is called. This can be used to reset state.
55006f25ae9SGregory Neil Shapiro */
55106f25ae9SGregory Neil Shapiro 
55240266059SGregory Neil Shapiro /*
55340266059SGregory Neil Shapiro **  Quarantine an envelope
55440266059SGregory Neil Shapiro **
55540266059SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
55640266059SGregory Neil Shapiro **	char *reason: explanation
55740266059SGregory Neil Shapiro */
55840266059SGregory Neil Shapiro 
55940266059SGregory Neil Shapiro LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
56006f25ae9SGregory Neil Shapiro 
56106f25ae9SGregory Neil Shapiro /*
56206f25ae9SGregory Neil Shapiro **  Connection-private data (specific to an SMTP connection) can be
56306f25ae9SGregory Neil Shapiro **  allocated using the smfi_setpriv routine; routines can access private
56406f25ae9SGregory Neil Shapiro **  data using smfi_getpriv.
56506f25ae9SGregory Neil Shapiro */
56606f25ae9SGregory Neil Shapiro 
56706f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
56806f25ae9SGregory Neil Shapiro 
56906f25ae9SGregory Neil Shapiro /*
57006f25ae9SGregory Neil Shapiro **  Set the private data pointer
57106f25ae9SGregory Neil Shapiro **
57206f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
57306f25ae9SGregory Neil Shapiro **	void *privatedata; Pointer to private data area
57406f25ae9SGregory Neil Shapiro */
57506f25ae9SGregory Neil Shapiro 
57606f25ae9SGregory Neil Shapiro LIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
57706f25ae9SGregory Neil Shapiro 
578d0cef73dSGregory Neil Shapiro /*
579d0cef73dSGregory Neil Shapiro **  Get the private data pointer
580d0cef73dSGregory Neil Shapiro **
581d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
582d0cef73dSGregory Neil Shapiro **	void *privatedata; Pointer to private data area
583d0cef73dSGregory Neil Shapiro */
584d0cef73dSGregory Neil Shapiro 
585d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *));
586d0cef73dSGregory Neil Shapiro 
587d0cef73dSGregory Neil Shapiro /*
588d0cef73dSGregory Neil Shapiro **  Set list of symbols (macros) to receive
589d0cef73dSGregory Neil Shapiro **
590d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
591d0cef73dSGregory Neil Shapiro **	int where; where in the SMTP dialogue should the macros be sent
592d0cef73dSGregory Neil Shapiro **	char *macros; list of macros (space separated)
593d0cef73dSGregory Neil Shapiro */
594d0cef73dSGregory Neil Shapiro 
595d0cef73dSGregory Neil Shapiro #if _FFR_THREAD_MONITOR
596d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int));
597*5b0945b5SGregory Neil Shapiro #endif
598d0cef73dSGregory Neil Shapiro 
599e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus
600e92d3f3fSGregory Neil Shapiro }
601*5b0945b5SGregory Neil Shapiro #endif
60206f25ae9SGregory Neil Shapiro 
60306f25ae9SGregory Neil Shapiro #endif /* ! _LIBMILTER_MFAPI_H */
604