xref: /freebsd/contrib/sendmail/include/libmilter/mfapi.h (revision d0cef73d40a409e3116f095b83633b1364e95741)
106f25ae9SGregory Neil Shapiro /*
2d0cef73dSGregory Neil Shapiro  * Copyright (c) 1999-2004, 2006 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  *
10d0cef73dSGregory Neil Shapiro  *	$Id: mfapi.h,v 8.77 2006/11/02 02:44:07 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
21d0cef73dSGregory Neil Shapiro # define SMFI_VERSION	0x01000000	/* libmilter version number */
22e92d3f3fSGregory Neil Shapiro #endif /* ! SMFI_VERSION */
2313bd1963SGregory Neil Shapiro 
24d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_MAJOR(v)	(((v) & 0x7f000000) >> 24)
25d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_MINOR(v)	(((v) & 0x007fff00) >> 8)
26d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_PLVL(v)	((v) & 0x0000007f)
27d0cef73dSGregory Neil Shapiro 
28e92d3f3fSGregory Neil Shapiro # include <sys/types.h>
2940266059SGregory Neil Shapiro # include <sys/socket.h>
30e92d3f3fSGregory Neil Shapiro 
3140266059SGregory Neil Shapiro #include "libmilter/mfdef.h"
3206f25ae9SGregory Neil Shapiro 
3340266059SGregory Neil Shapiro # define LIBMILTER_API		extern
3406f25ae9SGregory Neil Shapiro 
3506f25ae9SGregory Neil Shapiro 
36e92d3f3fSGregory Neil Shapiro /* Only need to export C interface if used by C++ source code */
37e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus
38e92d3f3fSGregory Neil Shapiro extern "C" {
39e92d3f3fSGregory Neil Shapiro #endif /* __cplusplus */
40e92d3f3fSGregory Neil Shapiro 
4106f25ae9SGregory Neil Shapiro #ifndef _SOCK_ADDR
4206f25ae9SGregory Neil Shapiro # define _SOCK_ADDR	struct sockaddr
4306f25ae9SGregory Neil Shapiro #endif /* ! _SOCK_ADDR */
4406f25ae9SGregory Neil Shapiro 
4506f25ae9SGregory Neil Shapiro /*
4606f25ae9SGregory Neil Shapiro **  libmilter functions return one of the following to indicate
47d0cef73dSGregory Neil Shapiro **  success/failure(/continue):
4806f25ae9SGregory Neil Shapiro */
4906f25ae9SGregory Neil Shapiro 
5006f25ae9SGregory Neil Shapiro #define MI_SUCCESS	0
5106f25ae9SGregory Neil Shapiro #define MI_FAILURE	(-1)
52d0cef73dSGregory Neil Shapiro #if _FFR_WORKERS_POOL
53d0cef73dSGregory Neil Shapiro # define MI_CONTINUE	1
54d0cef73dSGregory Neil Shapiro #endif /* _FFR_WORKERS_POOL */
5506f25ae9SGregory Neil Shapiro 
5606f25ae9SGregory Neil Shapiro /* "forward" declarations */
5706f25ae9SGregory Neil Shapiro typedef struct smfi_str SMFICTX;
5806f25ae9SGregory Neil Shapiro typedef struct smfi_str *SMFICTX_PTR;
5906f25ae9SGregory Neil Shapiro 
6006f25ae9SGregory Neil Shapiro typedef struct smfiDesc smfiDesc_str;
6106f25ae9SGregory Neil Shapiro typedef struct smfiDesc	*smfiDesc_ptr;
6206f25ae9SGregory Neil Shapiro 
6306f25ae9SGregory Neil Shapiro /*
6406f25ae9SGregory Neil Shapiro **  Type which callbacks should return to indicate message status.
6506f25ae9SGregory Neil Shapiro **  This may take on one of the SMFIS_* values listed below.
6606f25ae9SGregory Neil Shapiro */
6706f25ae9SGregory Neil Shapiro 
6806f25ae9SGregory Neil Shapiro typedef int	sfsistat;
6906f25ae9SGregory Neil Shapiro 
7006f25ae9SGregory Neil Shapiro #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC_MINOR__ >= 8
7106f25ae9SGregory Neil Shapiro # define SM__P(X)	__PMT(X)
7206f25ae9SGregory Neil Shapiro #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
7306f25ae9SGregory Neil Shapiro # define SM__P(X)	__P(X)
7406f25ae9SGregory Neil Shapiro #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
7506f25ae9SGregory Neil Shapiro 
7606f25ae9SGregory Neil Shapiro /* Some platforms don't define __P -- do it for them here: */
7706f25ae9SGregory Neil Shapiro #ifndef __P
7806f25ae9SGregory Neil Shapiro # ifdef __STDC__
7906f25ae9SGregory Neil Shapiro #  define __P(X) X
8006f25ae9SGregory Neil Shapiro # else /* __STDC__ */
8106f25ae9SGregory Neil Shapiro #  define __P(X) ()
8206f25ae9SGregory Neil Shapiro # endif /* __STDC__ */
8306f25ae9SGregory Neil Shapiro #endif /* __P */
8406f25ae9SGregory Neil Shapiro 
85e92d3f3fSGregory Neil Shapiro #if SM_CONF_STDBOOL_H
86e92d3f3fSGregory Neil Shapiro # include <stdbool.h>
87e92d3f3fSGregory Neil Shapiro #else /* SM_CONF_STDBOOL_H */
88e92d3f3fSGregory Neil Shapiro # ifndef __cplusplus
89e92d3f3fSGregory Neil Shapiro #  ifndef bool
90e92d3f3fSGregory Neil Shapiro #   ifndef __bool_true_false_are_defined
91e92d3f3fSGregory Neil Shapiro typedef int	bool;
92e92d3f3fSGregory Neil Shapiro #    define __bool_true_false_are_defined	1
93e92d3f3fSGregory Neil Shapiro #   endif /* ! __bool_true_false_are_defined */
94e92d3f3fSGregory Neil Shapiro #  endif /* bool */
95e92d3f3fSGregory Neil Shapiro # endif /* ! __cplusplus */
96e92d3f3fSGregory Neil Shapiro #endif /* SM_CONF_STDBOOL_H */
97e92d3f3fSGregory Neil Shapiro 
9840266059SGregory Neil Shapiro /*
9940266059SGregory Neil Shapiro **  structure describing one milter
10040266059SGregory Neil Shapiro */
10140266059SGregory Neil Shapiro 
10206f25ae9SGregory Neil Shapiro struct smfiDesc
10306f25ae9SGregory Neil Shapiro {
10406f25ae9SGregory Neil Shapiro 	char		*xxfi_name;	/* filter name */
10506f25ae9SGregory Neil Shapiro 	int		xxfi_version;	/* version code -- do not change */
10640266059SGregory Neil Shapiro 	unsigned long	xxfi_flags;	/* flags */
10706f25ae9SGregory Neil Shapiro 
10806f25ae9SGregory Neil Shapiro 	/* connection info filter */
10906f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_connect) SM__P((SMFICTX *, char *, _SOCK_ADDR *));
11006f25ae9SGregory Neil Shapiro 
11106f25ae9SGregory Neil Shapiro 	/* SMTP HELO command filter */
11206f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_helo) SM__P((SMFICTX *, char *));
11306f25ae9SGregory Neil Shapiro 
11406f25ae9SGregory Neil Shapiro 	/* envelope sender filter */
11506f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_envfrom) SM__P((SMFICTX *, char **));
11606f25ae9SGregory Neil Shapiro 
11706f25ae9SGregory Neil Shapiro 	/* envelope recipient filter */
11806f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_envrcpt) SM__P((SMFICTX *, char **));
11906f25ae9SGregory Neil Shapiro 
12006f25ae9SGregory Neil Shapiro 	/* header filter */
12106f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_header) SM__P((SMFICTX *, char *, char *));
12206f25ae9SGregory Neil Shapiro 
12306f25ae9SGregory Neil Shapiro 	/* end of header */
12406f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_eoh) SM__P((SMFICTX *));
12506f25ae9SGregory Neil Shapiro 
12606f25ae9SGregory Neil Shapiro 	/* body block */
12740266059SGregory Neil Shapiro 	sfsistat	(*xxfi_body) SM__P((SMFICTX *, unsigned char *, size_t));
12806f25ae9SGregory Neil Shapiro 
12906f25ae9SGregory Neil Shapiro 	/* end of message */
13006f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_eom) SM__P((SMFICTX *));
13106f25ae9SGregory Neil Shapiro 
13206f25ae9SGregory Neil Shapiro 	/* message aborted */
13306f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_abort) SM__P((SMFICTX *));
13406f25ae9SGregory Neil Shapiro 
13506f25ae9SGregory Neil Shapiro 	/* connection cleanup */
13606f25ae9SGregory Neil Shapiro 	sfsistat	(*xxfi_close) SM__P((SMFICTX *));
137e92d3f3fSGregory Neil Shapiro 
138e92d3f3fSGregory Neil Shapiro 	/* any unrecognized or unimplemented command filter */
139d0cef73dSGregory Neil Shapiro 	sfsistat	(*xxfi_unknown) SM__P((SMFICTX *, const char *));
140e92d3f3fSGregory Neil Shapiro 
141af9557fdSGregory Neil Shapiro 	/* SMTP DATA command filter */
142e92d3f3fSGregory Neil Shapiro 	sfsistat	(*xxfi_data) SM__P((SMFICTX *));
143d0cef73dSGregory Neil Shapiro 
144d0cef73dSGregory Neil Shapiro 	/* negotiation callback */
145d0cef73dSGregory Neil Shapiro 	sfsistat	(*xxfi_negotiate) SM__P((SMFICTX *,
146d0cef73dSGregory Neil Shapiro 					unsigned long, unsigned long,
147d0cef73dSGregory Neil Shapiro 					unsigned long, unsigned long,
148d0cef73dSGregory Neil Shapiro 					unsigned long *, unsigned long *,
149d0cef73dSGregory Neil Shapiro 					unsigned long *, unsigned long *));
150d0cef73dSGregory Neil Shapiro 
151d0cef73dSGregory Neil Shapiro #if 0
152d0cef73dSGregory Neil Shapiro 	/* signal handler callback, not yet implemented. */
153d0cef73dSGregory Neil Shapiro 	int		(*xxfi_signal) SM__P((int));
154d0cef73dSGregory Neil Shapiro #endif
155d0cef73dSGregory Neil Shapiro 
15606f25ae9SGregory Neil Shapiro };
15706f25ae9SGregory Neil Shapiro 
158323f6dcbSGregory Neil Shapiro LIBMILTER_API int smfi_opensocket __P((bool));
15906f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_register __P((struct smfiDesc));
16006f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_main __P((void));
161605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_setbacklog __P((int));
16206f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setdbg __P((int));
16306f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_settimeout __P((int));
16406f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setconn __P((char *));
16542e5d165SGregory Neil Shapiro LIBMILTER_API int smfi_stop __P((void));
166e92d3f3fSGregory Neil Shapiro #if _FFR_MAXDATASIZE
167e92d3f3fSGregory Neil Shapiro LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
168e92d3f3fSGregory Neil Shapiro #endif /* _FFR_MAXDATASIZE */
169d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *, unsigned int *));
17040266059SGregory Neil Shapiro 
17140266059SGregory Neil Shapiro /*
17240266059SGregory Neil Shapiro **  What the filter might do -- values to be ORed together for
17340266059SGregory Neil Shapiro **  smfiDesc.xxfi_flags.
17440266059SGregory Neil Shapiro */
17540266059SGregory Neil Shapiro 
17640266059SGregory Neil Shapiro #define SMFIF_NONE	0x00000000L	/* no flags */
17740266059SGregory Neil Shapiro #define SMFIF_ADDHDRS	0x00000001L	/* filter may add headers */
17840266059SGregory Neil Shapiro #define SMFIF_CHGBODY	0x00000002L	/* filter may replace body */
17940266059SGregory Neil Shapiro #define SMFIF_MODBODY	SMFIF_CHGBODY	/* backwards compatible */
18040266059SGregory Neil Shapiro #define SMFIF_ADDRCPT	0x00000004L	/* filter may add recipients */
18140266059SGregory Neil Shapiro #define SMFIF_DELRCPT	0x00000008L	/* filter may delete recipients */
18240266059SGregory Neil Shapiro #define SMFIF_CHGHDRS	0x00000010L	/* filter may change/delete headers */
18340266059SGregory Neil Shapiro #define SMFIF_QUARANTINE 0x00000020L	/* filter may quarantine envelope */
18440266059SGregory Neil Shapiro 
185d0cef73dSGregory Neil Shapiro /* filter may change "from" (envelope sender) */
186d0cef73dSGregory Neil Shapiro #define SMFIF_CHGFROM	0x00000040L
187d0cef73dSGregory Neil Shapiro #define SMFIF_ADDRCPT_PAR	0x00000080L	/* add recipients incl. args */
188d0cef73dSGregory Neil Shapiro 
189d0cef73dSGregory Neil Shapiro /* filter can send set of symbols (macros) that it wants */
190d0cef73dSGregory Neil Shapiro #define SMFIF_SETSYMLIST	0x00000100L
191d0cef73dSGregory Neil Shapiro 
192d0cef73dSGregory Neil Shapiro 
193d0cef73dSGregory Neil Shapiro /*
194d0cef73dSGregory Neil Shapiro **  Macro "places";
195d0cef73dSGregory Neil Shapiro **  Notes:
196d0cef73dSGregory Neil Shapiro **  - must be coordinated with libmilter/engine.c and sendmail/milter.c
197d0cef73dSGregory Neil Shapiro **  - the order MUST NOT be changed as it would break compatibility between
198d0cef73dSGregory Neil Shapiro **	different versions. It's ok to append new entries however
199d0cef73dSGregory Neil Shapiro **	(hence the list is not sorted by the SMT protocol steps).
200d0cef73dSGregory Neil Shapiro */
201d0cef73dSGregory Neil Shapiro 
202d0cef73dSGregory Neil Shapiro #define SMFIM_FIRST	0	/* Do NOT use, internal marker only */
203d0cef73dSGregory Neil Shapiro #define SMFIM_CONNECT	0	/* connect */
204d0cef73dSGregory Neil Shapiro #define SMFIM_HELO	1	/* HELO/EHLO */
205d0cef73dSGregory Neil Shapiro #define SMFIM_ENVFROM	2	/* MAIL From */
206d0cef73dSGregory Neil Shapiro #define SMFIM_ENVRCPT	3	/* RCPT To */
207d0cef73dSGregory Neil Shapiro #define SMFIM_DATA	4	/* DATA */
208d0cef73dSGregory Neil Shapiro #define SMFIM_EOM	5	/* end of message (final dot) */
209d0cef73dSGregory Neil Shapiro #define SMFIM_EOH	6	/* end of header */
210d0cef73dSGregory Neil Shapiro #define SMFIM_LAST	6	/* Do NOT use, internal marker only */
211d0cef73dSGregory Neil Shapiro 
21206f25ae9SGregory Neil Shapiro /*
21306f25ae9SGregory Neil Shapiro **  Continue processing message/connection.
21406f25ae9SGregory Neil Shapiro */
21506f25ae9SGregory Neil Shapiro 
21606f25ae9SGregory Neil Shapiro #define SMFIS_CONTINUE	0
21706f25ae9SGregory Neil Shapiro 
21806f25ae9SGregory Neil Shapiro /*
21906f25ae9SGregory Neil Shapiro **  Reject the message/connection.
22006f25ae9SGregory Neil Shapiro **  No further routines will be called for this message
22106f25ae9SGregory Neil Shapiro **  (or connection, if returned from a connection-oriented routine).
22206f25ae9SGregory Neil Shapiro */
22306f25ae9SGregory Neil Shapiro 
22406f25ae9SGregory Neil Shapiro #define SMFIS_REJECT	1
22506f25ae9SGregory Neil Shapiro 
22606f25ae9SGregory Neil Shapiro /*
22706f25ae9SGregory Neil Shapiro **  Accept the message,
22806f25ae9SGregory Neil Shapiro **  but silently discard the message.
22906f25ae9SGregory Neil Shapiro **  No further routines will be called for this message.
23006f25ae9SGregory Neil Shapiro **  This is only meaningful from message-oriented routines.
23106f25ae9SGregory Neil Shapiro */
23206f25ae9SGregory Neil Shapiro 
23306f25ae9SGregory Neil Shapiro #define SMFIS_DISCARD	2
23406f25ae9SGregory Neil Shapiro 
23506f25ae9SGregory Neil Shapiro /*
23606f25ae9SGregory Neil Shapiro **  Accept the message/connection.
23706f25ae9SGregory Neil Shapiro **  No further routines will be called for this message
23806f25ae9SGregory Neil Shapiro **  (or connection, if returned from a connection-oriented routine;
23906f25ae9SGregory Neil Shapiro **  in this case, it causes all messages on this connection
24006f25ae9SGregory Neil Shapiro **  to be accepted without filtering).
24106f25ae9SGregory Neil Shapiro */
24206f25ae9SGregory Neil Shapiro 
24306f25ae9SGregory Neil Shapiro #define SMFIS_ACCEPT	3
24406f25ae9SGregory Neil Shapiro 
24506f25ae9SGregory Neil Shapiro /*
24606f25ae9SGregory Neil Shapiro **  Return a temporary failure, i.e.,
24706f25ae9SGregory Neil Shapiro **  the corresponding SMTP command will return a 4xx status code.
24806f25ae9SGregory Neil Shapiro **  In some cases this may prevent further routines from
24906f25ae9SGregory Neil Shapiro **  being called on this message or connection,
25006f25ae9SGregory Neil Shapiro **  although in other cases (e.g., when processing an envelope
25106f25ae9SGregory Neil Shapiro **  recipient) processing of the message will continue.
25206f25ae9SGregory Neil Shapiro */
25306f25ae9SGregory Neil Shapiro 
25406f25ae9SGregory Neil Shapiro #define SMFIS_TEMPFAIL	4
25506f25ae9SGregory Neil Shapiro 
256d0cef73dSGregory Neil Shapiro /*
257d0cef73dSGregory Neil Shapiro **  Do not send a reply to the MTA
258d0cef73dSGregory Neil Shapiro */
259d0cef73dSGregory Neil Shapiro 
260d0cef73dSGregory Neil Shapiro #define SMFIS_NOREPLY	7
261d0cef73dSGregory Neil Shapiro 
262d0cef73dSGregory Neil Shapiro /*
263d0cef73dSGregory Neil Shapiro **  Skip over rest of same callbacks, e.g., body.
264d0cef73dSGregory Neil Shapiro */
265d0cef73dSGregory Neil Shapiro 
266d0cef73dSGregory Neil Shapiro #define SMFIS_SKIP	8
267d0cef73dSGregory Neil Shapiro 
268d0cef73dSGregory Neil Shapiro /* xxfi_negotiate: use all existing protocol options/actions */
269d0cef73dSGregory Neil Shapiro #define SMFIS_ALL_OPTS	10
270d0cef73dSGregory Neil Shapiro 
27106f25ae9SGregory Neil Shapiro #if 0
27206f25ae9SGregory Neil Shapiro /*
27306f25ae9SGregory Neil Shapiro **  Filter Routine Details
27406f25ae9SGregory Neil Shapiro */
27506f25ae9SGregory Neil Shapiro 
27606f25ae9SGregory Neil Shapiro /* connection info filter */
27706f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
27806f25ae9SGregory Neil Shapiro 
27906f25ae9SGregory Neil Shapiro /*
28006f25ae9SGregory Neil Shapiro **  xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
28106f25ae9SGregory Neil Shapiro **
28206f25ae9SGregory Neil Shapiro **	char *hostname; Host domain name, as determined by a reverse lookup
28306f25ae9SGregory Neil Shapiro **		on the host address.
28406f25ae9SGregory Neil Shapiro **	_SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
28506f25ae9SGregory Neil Shapiro **		call on the SMTP socket.
28606f25ae9SGregory Neil Shapiro */
28706f25ae9SGregory Neil Shapiro 
28806f25ae9SGregory Neil Shapiro /* SMTP HELO command filter */
28906f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_helo __P((SMFICTX *, char *));
29006f25ae9SGregory Neil Shapiro 
29106f25ae9SGregory Neil Shapiro /*
29206f25ae9SGregory Neil Shapiro **  xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
29306f25ae9SGregory Neil Shapiro **
29406f25ae9SGregory Neil Shapiro **	char *helohost; Value passed to HELO/EHLO command, which should be
29506f25ae9SGregory Neil Shapiro **		the domain name of the sending host (but is, in practice,
29606f25ae9SGregory Neil Shapiro **		anything the sending host wants to send).
29706f25ae9SGregory Neil Shapiro */
29806f25ae9SGregory Neil Shapiro 
29906f25ae9SGregory Neil Shapiro /* envelope sender filter */
30006f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_envfrom __P((SMFICTX *, char **));
30106f25ae9SGregory Neil Shapiro 
30206f25ae9SGregory Neil Shapiro /*
30306f25ae9SGregory Neil Shapiro **  xxfi_envfrom(ctx, argv) Invoked on envelope from
30406f25ae9SGregory Neil Shapiro **
30506f25ae9SGregory Neil Shapiro **	char **argv; Null-terminated SMTP command arguments;
30606f25ae9SGregory Neil Shapiro **		argv[0] is guaranteed to be the sender address.
30706f25ae9SGregory Neil Shapiro **		Later arguments are the ESMTP arguments.
30806f25ae9SGregory Neil Shapiro */
30906f25ae9SGregory Neil Shapiro 
31006f25ae9SGregory Neil Shapiro /* envelope recipient filter */
31106f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_envrcpt __P((SMFICTX *, char **));
31206f25ae9SGregory Neil Shapiro 
31306f25ae9SGregory Neil Shapiro /*
31406f25ae9SGregory Neil Shapiro **  xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
31506f25ae9SGregory Neil Shapiro **
31606f25ae9SGregory Neil Shapiro **	char **argv; Null-terminated SMTP command arguments;
31706f25ae9SGregory Neil Shapiro **		argv[0] is guaranteed to be the recipient address.
31806f25ae9SGregory Neil Shapiro **		Later arguments are the ESMTP arguments.
31906f25ae9SGregory Neil Shapiro */
32006f25ae9SGregory Neil Shapiro 
321e92d3f3fSGregory Neil Shapiro /* unknown command filter */
322e92d3f3fSGregory Neil Shapiro 
323d0cef73dSGregory Neil Shapiro extern sfsistat	*xxfi_unknown __P((SMFICTX *, const char *));
324e92d3f3fSGregory Neil Shapiro 
325e92d3f3fSGregory Neil Shapiro /*
326e92d3f3fSGregory Neil Shapiro **  xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
327e92d3f3fSGregory Neil Shapiro **  implemented.
328d0cef73dSGregory Neil Shapiro **	const char *arg; Null-terminated SMTP command
329e92d3f3fSGregory Neil Shapiro */
330e92d3f3fSGregory Neil Shapiro 
33106f25ae9SGregory Neil Shapiro /* header filter */
33206f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_header __P((SMFICTX *, char *, char *));
33306f25ae9SGregory Neil Shapiro 
33406f25ae9SGregory Neil Shapiro /*
33506f25ae9SGregory Neil Shapiro **  xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
33606f25ae9SGregory Neil Shapiro **  content of the header may have folded white space (that is, multiple
33706f25ae9SGregory Neil Shapiro **  lines with following white space) included.
33806f25ae9SGregory Neil Shapiro **
33906f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
34006f25ae9SGregory Neil Shapiro **	char *headerv; Header field value
34106f25ae9SGregory Neil Shapiro */
34206f25ae9SGregory Neil Shapiro 
34306f25ae9SGregory Neil Shapiro /* end of header */
34406f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_eoh __P((SMFICTX *));
34506f25ae9SGregory Neil Shapiro 
34606f25ae9SGregory Neil Shapiro /*
34706f25ae9SGregory Neil Shapiro **  xxfi_eoh(ctx) Invoked at end of header
34806f25ae9SGregory Neil Shapiro */
34906f25ae9SGregory Neil Shapiro 
35006f25ae9SGregory Neil Shapiro /* body block */
35140266059SGregory Neil Shapiro extern sfsistat	xxfi_body __P((SMFICTX *, unsigned char *, size_t));
35206f25ae9SGregory Neil Shapiro 
35306f25ae9SGregory Neil Shapiro /*
35406f25ae9SGregory Neil Shapiro **  xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
35506f25ae9SGregory Neil Shapiro **  be multiple body chunks passed to the filter. End-of-lines are
35606f25ae9SGregory Neil Shapiro **  represented as received from SMTP (normally Carriage-Return/Line-Feed).
35706f25ae9SGregory Neil Shapiro **
35840266059SGregory Neil Shapiro **	unsigned char *bodyp; Pointer to body data
35906f25ae9SGregory Neil Shapiro **	size_t bodylen; Length of body data
36006f25ae9SGregory Neil Shapiro */
36106f25ae9SGregory Neil Shapiro 
36206f25ae9SGregory Neil Shapiro /* end of message */
36306f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_eom __P((SMFICTX *));
36406f25ae9SGregory Neil Shapiro 
36506f25ae9SGregory Neil Shapiro /*
36606f25ae9SGregory Neil Shapiro **  xxfi_eom(ctx) Invoked at end of message. This routine can perform
36706f25ae9SGregory Neil Shapiro **  special operations such as modifying the message header, body, or
36806f25ae9SGregory Neil Shapiro **  envelope.
36906f25ae9SGregory Neil Shapiro */
37006f25ae9SGregory Neil Shapiro 
37106f25ae9SGregory Neil Shapiro /* message aborted */
37206f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_abort __P((SMFICTX *));
37306f25ae9SGregory Neil Shapiro 
37406f25ae9SGregory Neil Shapiro /*
37506f25ae9SGregory Neil Shapiro **  xxfi_abort(ctx) Invoked if message is aborted outside of the control of
37606f25ae9SGregory Neil Shapiro **  the filter, for example, if the SMTP sender issues an RSET command. If
37706f25ae9SGregory Neil Shapiro **  xxfi_abort is called, xxfi_eom will not be called and vice versa.
37806f25ae9SGregory Neil Shapiro */
37906f25ae9SGregory Neil Shapiro 
38006f25ae9SGregory Neil Shapiro /* connection cleanup */
38106f25ae9SGregory Neil Shapiro extern sfsistat	xxfi_close __P((SMFICTX *));
38206f25ae9SGregory Neil Shapiro 
38306f25ae9SGregory Neil Shapiro /*
38406f25ae9SGregory Neil Shapiro **  xxfi_close(ctx) Invoked at end of the connection. This is called on
38506f25ae9SGregory Neil Shapiro **  close even if the previous mail transaction was aborted.
38606f25ae9SGregory Neil Shapiro */
38706f25ae9SGregory Neil Shapiro #endif /* 0 */
38806f25ae9SGregory Neil Shapiro 
38906f25ae9SGregory Neil Shapiro /*
39006f25ae9SGregory Neil Shapiro **  Additional information is passed in to the vendor filter routines using
39106f25ae9SGregory Neil Shapiro **  symbols. Symbols correspond closely to sendmail macros. The symbols
39206f25ae9SGregory Neil Shapiro **  defined depend on the context. The value of a symbol is accessed using:
39306f25ae9SGregory Neil Shapiro */
39406f25ae9SGregory Neil Shapiro 
39506f25ae9SGregory Neil Shapiro /* Return the value of a symbol. */
39606f25ae9SGregory Neil Shapiro LIBMILTER_API char * smfi_getsymval __P((SMFICTX *, char *));
39706f25ae9SGregory Neil Shapiro 
39806f25ae9SGregory Neil Shapiro /*
39906f25ae9SGregory Neil Shapiro **  Return the value of a symbol.
40006f25ae9SGregory Neil Shapiro **
40106f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
40206f25ae9SGregory Neil Shapiro **	char *symname; The name of the symbol to access.
40306f25ae9SGregory Neil Shapiro */
40406f25ae9SGregory Neil Shapiro 
40506f25ae9SGregory Neil Shapiro /*
40606f25ae9SGregory Neil Shapiro **  Vendor filter routines that want to pass additional information back to
40706f25ae9SGregory Neil Shapiro **  the MTA for use in SMTP replies may call smfi_setreply before returning.
40806f25ae9SGregory Neil Shapiro */
40906f25ae9SGregory Neil Shapiro 
41006f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
41106f25ae9SGregory Neil Shapiro 
41240266059SGregory Neil Shapiro /*
41340266059SGregory Neil Shapiro **  Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
41440266059SGregory Neil Shapiro **  is needed.
41540266059SGregory Neil Shapiro */
41640266059SGregory Neil Shapiro 
41740266059SGregory Neil Shapiro LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, ...));
41840266059SGregory Neil Shapiro 
41906f25ae9SGregory Neil Shapiro /*
42006f25ae9SGregory Neil Shapiro **  Set the specific reply code to be used in response to the active
42106f25ae9SGregory Neil Shapiro **  command. If not specified, a generic reply code is used.
42206f25ae9SGregory Neil Shapiro **
42306f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
42406f25ae9SGregory Neil Shapiro **	char *rcode; The three-digit (RFC 821) SMTP reply code to be
42506f25ae9SGregory Neil Shapiro **		returned, e.g., ``551''.
42606f25ae9SGregory Neil Shapiro **	char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
42706f25ae9SGregory Neil Shapiro **	char *message; The text part of the SMTP reply.
42806f25ae9SGregory Neil Shapiro */
42906f25ae9SGregory Neil Shapiro 
43006f25ae9SGregory Neil Shapiro /*
43106f25ae9SGregory Neil Shapiro **  The xxfi_eom routine is called at the end of a message (essentially,
43206f25ae9SGregory Neil Shapiro **  after the final DATA dot). This routine can call some special routines
43306f25ae9SGregory Neil Shapiro **  to modify the envelope, header, or body of the message before the
43406f25ae9SGregory Neil Shapiro **  message is enqueued. These routines must not be called from any vendor
43506f25ae9SGregory Neil Shapiro **  routine other than xxfi_eom.
43606f25ae9SGregory Neil Shapiro */
43706f25ae9SGregory Neil Shapiro 
43806f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
43906f25ae9SGregory Neil Shapiro 
44006f25ae9SGregory Neil Shapiro /*
441e92d3f3fSGregory Neil Shapiro **  Add a header to the message. It is not checked for standards
442e92d3f3fSGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
443e92d3f3fSGregory Neil Shapiro **  as a result of adding this header.
44406f25ae9SGregory Neil Shapiro **
44506f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
44606f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
44706f25ae9SGregory Neil Shapiro **	char *headerv; Header field value
44806f25ae9SGregory Neil Shapiro */
44906f25ae9SGregory Neil Shapiro 
45006f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
45106f25ae9SGregory Neil Shapiro 
45206f25ae9SGregory Neil Shapiro /*
45306f25ae9SGregory Neil Shapiro **  Change/delete a header in the message.  It is not checked for standards
45406f25ae9SGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
45506f25ae9SGregory Neil Shapiro **  as a result of adding this header.
45606f25ae9SGregory Neil Shapiro **
45706f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
45806f25ae9SGregory Neil Shapiro **	char *headerf; Header field name
45906f25ae9SGregory Neil Shapiro **	int index; The Nth occurence of header field name
46006f25ae9SGregory Neil Shapiro **	char *headerv; New header field value (empty for delete header)
46106f25ae9SGregory Neil Shapiro */
46206f25ae9SGregory Neil Shapiro 
463e92d3f3fSGregory Neil Shapiro LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
464e92d3f3fSGregory Neil Shapiro 
465e92d3f3fSGregory Neil Shapiro /*
466e92d3f3fSGregory Neil Shapiro **  Insert a header into the message.  It is not checked for standards
467e92d3f3fSGregory Neil Shapiro **  compliance; the mail filter must ensure that no protocols are violated
468e92d3f3fSGregory Neil Shapiro **  as a result of adding this header.
469e92d3f3fSGregory Neil Shapiro **
470e92d3f3fSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
471e92d3f3fSGregory Neil Shapiro **  	int idx; index into the header list where the insertion should happen
472e92d3f3fSGregory Neil Shapiro **	char *headerh; Header field name
473e92d3f3fSGregory Neil Shapiro **	char *headerv; Header field value
474e92d3f3fSGregory Neil Shapiro */
475e92d3f3fSGregory Neil Shapiro 
476d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *));
477d0cef73dSGregory Neil Shapiro 
478d0cef73dSGregory Neil Shapiro /*
479d0cef73dSGregory Neil Shapiro **  Modify envelope sender address
480d0cef73dSGregory Neil Shapiro **
481d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
482d0cef73dSGregory Neil Shapiro **	char *mail; New envelope sender address
483d0cef73dSGregory Neil Shapiro **	char *args; ESMTP arguments
484d0cef73dSGregory Neil Shapiro */
485d0cef73dSGregory Neil Shapiro 
486d0cef73dSGregory Neil Shapiro 
48706f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
48806f25ae9SGregory Neil Shapiro 
48906f25ae9SGregory Neil Shapiro /*
49006f25ae9SGregory Neil Shapiro **  Add a recipient to the envelope
49106f25ae9SGregory Neil Shapiro **
49206f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
49306f25ae9SGregory Neil Shapiro **	char *rcpt; Recipient to be added
49406f25ae9SGregory Neil Shapiro */
49506f25ae9SGregory Neil Shapiro 
496d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *));
497d0cef73dSGregory Neil Shapiro 
498d0cef73dSGregory Neil Shapiro /*
499d0cef73dSGregory Neil Shapiro **  Add a recipient to the envelope
500d0cef73dSGregory Neil Shapiro **
501d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
502d0cef73dSGregory Neil Shapiro **	char *rcpt; Recipient to be added
503d0cef73dSGregory Neil Shapiro **	char *args; ESMTP arguments
504d0cef73dSGregory Neil Shapiro */
505d0cef73dSGregory Neil Shapiro 
506d0cef73dSGregory Neil Shapiro 
50706f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
50806f25ae9SGregory Neil Shapiro 
509605302a5SGregory Neil Shapiro /*
510605302a5SGregory Neil Shapiro **  Send a "no-op" up to the MTA to tell it we're still alive, so long
511605302a5SGregory Neil Shapiro **  milter-side operations don't time out.
512605302a5SGregory Neil Shapiro **
513605302a5SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
514605302a5SGregory Neil Shapiro */
515605302a5SGregory Neil Shapiro 
516605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_progress __P((SMFICTX *));
517605302a5SGregory Neil Shapiro 
51806f25ae9SGregory Neil Shapiro /*
51906f25ae9SGregory Neil Shapiro **  Delete a recipient from the envelope
52006f25ae9SGregory Neil Shapiro **
52106f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
52206f25ae9SGregory Neil Shapiro **	char *rcpt; Envelope recipient to be deleted. This should be in
52306f25ae9SGregory Neil Shapiro **		exactly the form passed to xxfi_envrcpt or the address may
52406f25ae9SGregory Neil Shapiro **		not be deleted.
52506f25ae9SGregory Neil Shapiro */
52606f25ae9SGregory Neil Shapiro 
52740266059SGregory Neil Shapiro LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
52806f25ae9SGregory Neil Shapiro 
52906f25ae9SGregory Neil Shapiro /*
53006f25ae9SGregory Neil Shapiro **  Replace the body of the message. This routine may be called multiple
53106f25ae9SGregory Neil Shapiro **  times if the body is longer than convenient to send in one call. End of
53206f25ae9SGregory Neil Shapiro **  line should be represented as Carriage-Return/Line Feed.
53306f25ae9SGregory Neil Shapiro **
53406f25ae9SGregory Neil Shapiro **	char *bodyp; Pointer to block of body information to insert
53506f25ae9SGregory Neil Shapiro **	int bodylen; Length of data pointed at by bodyp
53606f25ae9SGregory Neil Shapiro */
53706f25ae9SGregory Neil Shapiro 
53806f25ae9SGregory Neil Shapiro /*
53906f25ae9SGregory Neil Shapiro **  If the message is aborted (for example, if the SMTP sender sends the
54006f25ae9SGregory Neil Shapiro **  envelope but then does a QUIT or RSET before the data is sent),
54106f25ae9SGregory Neil Shapiro **  xxfi_abort is called. This can be used to reset state.
54206f25ae9SGregory Neil Shapiro */
54306f25ae9SGregory Neil Shapiro 
54440266059SGregory Neil Shapiro /*
54540266059SGregory Neil Shapiro **  Quarantine an envelope
54640266059SGregory Neil Shapiro **
54740266059SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
54840266059SGregory Neil Shapiro **	char *reason: explanation
54940266059SGregory Neil Shapiro */
55040266059SGregory Neil Shapiro 
55140266059SGregory Neil Shapiro LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
55206f25ae9SGregory Neil Shapiro 
55306f25ae9SGregory Neil Shapiro /*
55406f25ae9SGregory Neil Shapiro **  Connection-private data (specific to an SMTP connection) can be
55506f25ae9SGregory Neil Shapiro **  allocated using the smfi_setpriv routine; routines can access private
55606f25ae9SGregory Neil Shapiro **  data using smfi_getpriv.
55706f25ae9SGregory Neil Shapiro */
55806f25ae9SGregory Neil Shapiro 
55906f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
56006f25ae9SGregory Neil Shapiro 
56106f25ae9SGregory Neil Shapiro /*
56206f25ae9SGregory Neil Shapiro **  Set the private data pointer
56306f25ae9SGregory Neil Shapiro **
56406f25ae9SGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
56506f25ae9SGregory Neil Shapiro **	void *privatedata; Pointer to private data area
56606f25ae9SGregory Neil Shapiro */
56706f25ae9SGregory Neil Shapiro 
56806f25ae9SGregory Neil Shapiro LIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
56906f25ae9SGregory Neil Shapiro 
570d0cef73dSGregory Neil Shapiro /*
571d0cef73dSGregory Neil Shapiro **  Get the private data pointer
572d0cef73dSGregory Neil Shapiro **
573d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
574d0cef73dSGregory Neil Shapiro **	void *privatedata; Pointer to private data area
575d0cef73dSGregory Neil Shapiro */
576d0cef73dSGregory Neil Shapiro 
577d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *));
578d0cef73dSGregory Neil Shapiro 
579d0cef73dSGregory Neil Shapiro /*
580d0cef73dSGregory Neil Shapiro **  Set list of symbols (macros) to receive
581d0cef73dSGregory Neil Shapiro **
582d0cef73dSGregory Neil Shapiro **	SMFICTX *ctx; Opaque context structure
583d0cef73dSGregory Neil Shapiro **	int where; where in the SMTP dialogue should the macros be sent
584d0cef73dSGregory Neil Shapiro **	char *macros; list of macros (space separated)
585d0cef73dSGregory Neil Shapiro */
586d0cef73dSGregory Neil Shapiro 
587d0cef73dSGregory Neil Shapiro #if _FFR_THREAD_MONITOR
588d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int));
589d0cef73dSGregory Neil Shapiro #endif /* _FFR_THREAD_MONITOR */
590d0cef73dSGregory Neil Shapiro 
591e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus
592e92d3f3fSGregory Neil Shapiro }
593e92d3f3fSGregory Neil Shapiro #endif /* __cplusplus */
59406f25ae9SGregory Neil Shapiro 
59506f25ae9SGregory Neil Shapiro #endif /* ! _LIBMILTER_MFAPI_H */
596