xref: /titanic_44/usr/src/cmd/sendmail/include/libmilter/mfapi.h (revision e9af4bc0b1cc30cea75d6ad4aa2fde97d985e9be)
17c478bd9Sstevel@tonic-gate /*
2d4660949Sjbeck  * Copyright (c) 1999-2004, 2006, 2008 Sendmail, Inc. and its suppliers.
37c478bd9Sstevel@tonic-gate  *	All rights reserved.
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
67c478bd9Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
77c478bd9Sstevel@tonic-gate  * the sendmail distribution.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  *
10*e9af4bc0SJohn Beck  *	$Id: mfapi.h,v 8.80 2009/11/26 00:57:08 ca Exp $
117c478bd9Sstevel@tonic-gate  */
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate /*
147c478bd9Sstevel@tonic-gate  *  MFAPI.H -- Global definitions for mail filter library and mail filters.
157c478bd9Sstevel@tonic-gate  */
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate #ifndef	_LIBMILTER_MFAPI_H
187c478bd9Sstevel@tonic-gate #define	_LIBMILTER_MFAPI_H
197c478bd9Sstevel@tonic-gate 
207c478bd9Sstevel@tonic-gate #ifdef __cplusplus
217c478bd9Sstevel@tonic-gate extern "C" {
227c478bd9Sstevel@tonic-gate #endif
237c478bd9Sstevel@tonic-gate 
247c478bd9Sstevel@tonic-gate #ifndef SMFI_VERSION
25*e9af4bc0SJohn Beck #if _FFR_MDS_NEGOTIATE
26*e9af4bc0SJohn Beck #define	SMFI_VERSION	0x01000002	/* libmilter version number */
27*e9af4bc0SJohn Beck 
28*e9af4bc0SJohn Beck /* first libmilter version that has MDS support */
29*e9af4bc0SJohn Beck #define	SMFI_VERSION_MDS	0x01000002
30*e9af4bc0SJohn Beck #else /* _FFR_MDS_NEGOTIATE */
31d4660949Sjbeck #define	SMFI_VERSION	0x01000001	/* libmilter version number */
32*e9af4bc0SJohn Beck #endif /* _FFR_MDS_NEGOTIATE */
337c478bd9Sstevel@tonic-gate #endif /* ! SMFI_VERSION */
347c478bd9Sstevel@tonic-gate 
35058561cbSjbeck #define	SM_LM_VRS_MAJOR(v)	(((v) & 0x7f000000) >> 24)
36058561cbSjbeck #define	SM_LM_VRS_MINOR(v)	(((v) & 0x007fff00) >> 8)
37058561cbSjbeck #define	SM_LM_VRS_PLVL(v)	((v) & 0x0000007f)
38058561cbSjbeck 
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <sys/socket.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #include <libmilter/mfdef.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	LIBMILTER_API		extern
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #ifndef _SOCK_ADDR
477c478bd9Sstevel@tonic-gate #define	_SOCK_ADDR	struct sockaddr
487c478bd9Sstevel@tonic-gate #endif /* ! _SOCK_ADDR */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  *  libmilter functions return one of the following to indicate
52058561cbSjbeck  *  success/failure(/continue):
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #define	MI_SUCCESS	0
567c478bd9Sstevel@tonic-gate #define	MI_FAILURE	(-1)
57058561cbSjbeck #if _FFR_WORKERS_POOL
58058561cbSjbeck #define	MI_CONTINUE	1
59058561cbSjbeck #endif /* _FFR_WORKERS_POOL */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /* "forward" declarations */
627c478bd9Sstevel@tonic-gate typedef struct smfi_str SMFICTX;
637c478bd9Sstevel@tonic-gate typedef struct smfi_str *SMFICTX_PTR;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate typedef struct smfiDesc smfiDesc_str;
667c478bd9Sstevel@tonic-gate typedef struct smfiDesc	*smfiDesc_ptr;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  *  Type which callbacks should return to indicate message status.
707c478bd9Sstevel@tonic-gate  *  This may take on one of the SMFIS_* values listed below.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate typedef int	sfsistat;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && \
767c478bd9Sstevel@tonic-gate 	__GNUC_MINOR__ >= 8
777c478bd9Sstevel@tonic-gate #define	SM__P(X)	__PMT(X)
787c478bd9Sstevel@tonic-gate #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
797c478bd9Sstevel@tonic-gate #define	SM__P(X)	__P(X)
807c478bd9Sstevel@tonic-gate #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /* Some platforms don't define __P -- do it for them here: */
837c478bd9Sstevel@tonic-gate #ifndef __P
847c478bd9Sstevel@tonic-gate #ifdef __STDC__
857c478bd9Sstevel@tonic-gate #define	__P(X) X
867c478bd9Sstevel@tonic-gate #else /* __STDC__ */
877c478bd9Sstevel@tonic-gate #define	__P(X) ()
887c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
897c478bd9Sstevel@tonic-gate #endif /* __P */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #if SM_CONF_STDBOOL_H
927c478bd9Sstevel@tonic-gate #include <stdbool.h>
937c478bd9Sstevel@tonic-gate #else /* SM_CONF_STDBOOL_H */
947c478bd9Sstevel@tonic-gate #ifndef __cplusplus
957c478bd9Sstevel@tonic-gate #ifndef bool
967c478bd9Sstevel@tonic-gate #ifndef __bool_true_false_are_defined
977c478bd9Sstevel@tonic-gate typedef int	bool;
987c478bd9Sstevel@tonic-gate #define	__bool_true_false_are_defined	1
997c478bd9Sstevel@tonic-gate #endif /* ! __bool_true_false_are_defined */
1007c478bd9Sstevel@tonic-gate #endif /* bool */
1017c478bd9Sstevel@tonic-gate #endif /* ! __cplusplus */
1027c478bd9Sstevel@tonic-gate #endif /* SM_CONF_STDBOOL_H */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate  *  structure describing one milter
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate struct smfiDesc
1097c478bd9Sstevel@tonic-gate {
1107c478bd9Sstevel@tonic-gate 	char		*xxfi_name;	/* filter name */
1117c478bd9Sstevel@tonic-gate 	int		xxfi_version;	/* version code -- do not change */
1127c478bd9Sstevel@tonic-gate 	unsigned long	xxfi_flags;	/* flags */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate 	/* connection info filter */
1157c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_connect) SM__P((SMFICTX *, char *,
1167c478bd9Sstevel@tonic-gate 						_SOCK_ADDR *));
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 	/* SMTP HELO command filter */
1197c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_helo) SM__P((SMFICTX *, char *));
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	/* envelope sender filter */
1227c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_envfrom) SM__P((SMFICTX *, char **));
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	/* envelope recipient filter */
1257c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_envrcpt) SM__P((SMFICTX *, char **));
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 	/* header filter */
1287c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_header) SM__P((SMFICTX *, char *, char *));
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	/* end of header */
1317c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_eoh) SM__P((SMFICTX *));
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	/* body block */
1347c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_body) SM__P((SMFICTX *, unsigned char *,
1357c478bd9Sstevel@tonic-gate 						size_t));
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 	/* end of message */
1387c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_eom) SM__P((SMFICTX *));
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	/* message aborted */
1417c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_abort) SM__P((SMFICTX *));
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 	/* connection cleanup */
1447c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_close) SM__P((SMFICTX *));
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate 	/* any unrecognized or unimplemented command filter */
147058561cbSjbeck 	sfsistat	(*xxfi_unknown) SM__P((SMFICTX *, const char *));
1487c478bd9Sstevel@tonic-gate 
1493ee0e492Sjbeck 	/* SMTP DATA command filter */
1507c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_data) SM__P((SMFICTX *));
151058561cbSjbeck 
152058561cbSjbeck 	/* negotiation callback */
153058561cbSjbeck 	sfsistat	(*xxfi_negotiate) SM__P((SMFICTX *,
154058561cbSjbeck 					unsigned long, unsigned long,
155058561cbSjbeck 					unsigned long, unsigned long,
156058561cbSjbeck 					unsigned long *, unsigned long *,
157058561cbSjbeck 					unsigned long *, unsigned long *));
158058561cbSjbeck 
159058561cbSjbeck #if 0
160058561cbSjbeck 	/* signal handler callback, not yet implemented. */
161058561cbSjbeck 	int		(*xxfi_signal) SM__P((int));
162058561cbSjbeck #endif
163058561cbSjbeck 
1647c478bd9Sstevel@tonic-gate };
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_opensocket __P((bool));
1677c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_register __P((struct smfiDesc));
1687c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_main __P((void));
1697c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setbacklog __P((int));
1707c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setdbg __P((int));
1717c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_settimeout __P((int));
1727c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setconn __P((char *));
1737c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_stop __P((void));
1747c478bd9Sstevel@tonic-gate LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
175058561cbSjbeck LIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *,
176058561cbSjbeck     unsigned int *));
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate /*
1797c478bd9Sstevel@tonic-gate  *  What the filter might do -- values to be ORed together for
1807c478bd9Sstevel@tonic-gate  *  smfiDesc.xxfi_flags.
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #define	SMFIF_NONE	0x00000000L	/* no flags */
1847c478bd9Sstevel@tonic-gate #define	SMFIF_ADDHDRS	0x00000001L	/* filter may add headers */
1857c478bd9Sstevel@tonic-gate #define	SMFIF_CHGBODY	0x00000002L	/* filter may replace body */
1867c478bd9Sstevel@tonic-gate #define	SMFIF_MODBODY	SMFIF_CHGBODY	/* backwards compatible */
1877c478bd9Sstevel@tonic-gate #define	SMFIF_ADDRCPT	0x00000004L	/* filter may add recipients */
1887c478bd9Sstevel@tonic-gate #define	SMFIF_DELRCPT	0x00000008L	/* filter may delete recipients */
1897c478bd9Sstevel@tonic-gate #define	SMFIF_CHGHDRS	0x00000010L	/* filter may change/delete headers */
1907c478bd9Sstevel@tonic-gate #define	SMFIF_QUARANTINE 0x00000020L	/* filter may quarantine envelope */
1917c478bd9Sstevel@tonic-gate 
192058561cbSjbeck /* filter may change "from" (envelope sender) */
193058561cbSjbeck #define	SMFIF_CHGFROM	0x00000040L
194058561cbSjbeck #define	SMFIF_ADDRCPT_PAR	0x00000080L	/* add recipients incl. args */
195058561cbSjbeck 
196058561cbSjbeck /* filter can send set of symbols (macros) that it wants */
197058561cbSjbeck #define	SMFIF_SETSYMLIST	0x00000100L
198058561cbSjbeck 
199058561cbSjbeck 
200058561cbSjbeck /*
201058561cbSjbeck  *  Macro "places";
202058561cbSjbeck  *  Notes:
203058561cbSjbeck  *  - must be coordinated with libmilter/engine.c and sendmail/milter.c
204058561cbSjbeck  *  - the order MUST NOT be changed as it would break compatibility between
205058561cbSjbeck  *     different versions. It's ok to append new entries however
206058561cbSjbeck  *     (hence the list is not sorted by the SMT protocol steps).
207058561cbSjbeck  */
208058561cbSjbeck 
209058561cbSjbeck #define	SMFIM_FIRST	0	/* Do NOT use, internal marker only */
210058561cbSjbeck #define	SMFIM_CONNECT	0	/* connect */
211058561cbSjbeck #define	SMFIM_HELO	1	/* HELO/EHLO */
212058561cbSjbeck #define	SMFIM_ENVFROM	2	/* MAIL From */
213058561cbSjbeck #define	SMFIM_ENVRCPT	3	/* RCPT To */
214058561cbSjbeck #define	SMFIM_DATA	4	/* DATA */
215058561cbSjbeck #define	SMFIM_EOM	5	/* end of message (final dot) */
216058561cbSjbeck #define	SMFIM_EOH	6	/* end of header */
217058561cbSjbeck #define	SMFIM_LAST	6	/* Do NOT use, internal marker only */
218058561cbSjbeck 
2197c478bd9Sstevel@tonic-gate /*
2207c478bd9Sstevel@tonic-gate  *  Continue processing message/connection.
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate #define	SMFIS_CONTINUE	0
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate /*
2267c478bd9Sstevel@tonic-gate  *  Reject the message/connection.
2277c478bd9Sstevel@tonic-gate  *  No further routines will be called for this message
2287c478bd9Sstevel@tonic-gate  *  (or connection, if returned from a connection-oriented routine).
2297c478bd9Sstevel@tonic-gate  */
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #define	SMFIS_REJECT	1
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate /*
2347c478bd9Sstevel@tonic-gate  *  Accept the message,
2357c478bd9Sstevel@tonic-gate  *  but silently discard the message.
2367c478bd9Sstevel@tonic-gate  *  No further routines will be called for this message.
2377c478bd9Sstevel@tonic-gate  *  This is only meaningful from message-oriented routines.
2387c478bd9Sstevel@tonic-gate  */
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate #define	SMFIS_DISCARD	2
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate  *  Accept the message/connection.
2447c478bd9Sstevel@tonic-gate  *  No further routines will be called for this message
2457c478bd9Sstevel@tonic-gate  *  (or connection, if returned from a connection-oriented routine;
2467c478bd9Sstevel@tonic-gate  *  in this case, it causes all messages on this connection
2477c478bd9Sstevel@tonic-gate  *  to be accepted without filtering).
2487c478bd9Sstevel@tonic-gate  */
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate #define	SMFIS_ACCEPT	3
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  *  Return a temporary failure, i.e.,
2547c478bd9Sstevel@tonic-gate  *  the corresponding SMTP command will return a 4xx status code.
2557c478bd9Sstevel@tonic-gate  *  In some cases this may prevent further routines from
2567c478bd9Sstevel@tonic-gate  *  being called on this message or connection,
2577c478bd9Sstevel@tonic-gate  *  although in other cases (e.g., when processing an envelope
2587c478bd9Sstevel@tonic-gate  *  recipient) processing of the message will continue.
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate #define	SMFIS_TEMPFAIL	4
2627c478bd9Sstevel@tonic-gate 
263058561cbSjbeck /*
264058561cbSjbeck  *  Do not send a reply to the MTA
265058561cbSjbeck  */
266058561cbSjbeck 
267058561cbSjbeck #define	SMFIS_NOREPLY	7
268058561cbSjbeck 
269058561cbSjbeck /*
270058561cbSjbeck  *  Skip over rest of same callbacks, e.g., body.
271058561cbSjbeck  */
272058561cbSjbeck 
273058561cbSjbeck #define	SMFIS_SKIP	8
274058561cbSjbeck 
275058561cbSjbeck /* xxfi_negotiate: use all existing protocol options/actions */
276058561cbSjbeck #define	SMFIS_ALL_OPTS	10
277058561cbSjbeck 
2787c478bd9Sstevel@tonic-gate #if 0
2797c478bd9Sstevel@tonic-gate /*
2807c478bd9Sstevel@tonic-gate  *  Filter Routine Details
2817c478bd9Sstevel@tonic-gate  */
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate /* connection info filter */
2847c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate /*
2877c478bd9Sstevel@tonic-gate  *  xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
2887c478bd9Sstevel@tonic-gate  *
2897c478bd9Sstevel@tonic-gate  *	char *hostname; Host domain name, as determined by a reverse lookup
2907c478bd9Sstevel@tonic-gate  *		on the host address.
2917c478bd9Sstevel@tonic-gate  *	_SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
2927c478bd9Sstevel@tonic-gate  *		call on the SMTP socket.
2937c478bd9Sstevel@tonic-gate  */
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /* SMTP HELO command filter */
2967c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_helo __P((SMFICTX *, char *));
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate /*
2997c478bd9Sstevel@tonic-gate  *  xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
3007c478bd9Sstevel@tonic-gate  *
3017c478bd9Sstevel@tonic-gate  *	char *helohost; Value passed to HELO/EHLO command, which should be
3027c478bd9Sstevel@tonic-gate  *		the domain name of the sending host (but is, in practice,
3037c478bd9Sstevel@tonic-gate  *		anything the sending host wants to send).
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate /* envelope sender filter */
3077c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_envfrom __P((SMFICTX *, char **));
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  *  xxfi_envfrom(ctx, argv) Invoked on envelope from
3117c478bd9Sstevel@tonic-gate  *
3127c478bd9Sstevel@tonic-gate  *	char **argv; Null-terminated SMTP command arguments;
3137c478bd9Sstevel@tonic-gate  *		argv[0] is guaranteed to be the sender address.
3147c478bd9Sstevel@tonic-gate  *		Later arguments are the ESMTP arguments.
3157c478bd9Sstevel@tonic-gate  */
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate /* envelope recipient filter */
3187c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_envrcpt __P((SMFICTX *, char **));
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate /*
3217c478bd9Sstevel@tonic-gate  *  xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
3227c478bd9Sstevel@tonic-gate  *
3237c478bd9Sstevel@tonic-gate  *	char **argv; Null-terminated SMTP command arguments;
3247c478bd9Sstevel@tonic-gate  *		argv[0] is guaranteed to be the recipient address.
3257c478bd9Sstevel@tonic-gate  *		Later arguments are the ESMTP arguments.
3267c478bd9Sstevel@tonic-gate  */
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate /* unknown command filter */
3297c478bd9Sstevel@tonic-gate 
330058561cbSjbeck extern sfsistat	*xxfi_unknown __P((SMFICTX *, const char *));
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate /*
3337c478bd9Sstevel@tonic-gate  *  xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
3347c478bd9Sstevel@tonic-gate  *  implemented.
335058561cbSjbeck  *	const char *arg; Null-terminated SMTP command
3367c478bd9Sstevel@tonic-gate  */
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate /* header filter */
3397c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_header __P((SMFICTX *, char *, char *));
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate /*
3427c478bd9Sstevel@tonic-gate  *  xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
3437c478bd9Sstevel@tonic-gate  *  content of the header may have folded white space (that is, multiple
3447c478bd9Sstevel@tonic-gate  *  lines with following white space) included.
3457c478bd9Sstevel@tonic-gate  *
3467c478bd9Sstevel@tonic-gate  *	char *headerf; Header field name
3477c478bd9Sstevel@tonic-gate  *	char *headerv; Header field value
3487c478bd9Sstevel@tonic-gate  */
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate /* end of header */
3517c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_eoh __P((SMFICTX *));
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate /*
3547c478bd9Sstevel@tonic-gate  *  xxfi_eoh(ctx) Invoked at end of header
3557c478bd9Sstevel@tonic-gate  */
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate /* body block */
3587c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_body __P((SMFICTX *, unsigned char *, size_t));
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate /*
3617c478bd9Sstevel@tonic-gate  *  xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
3627c478bd9Sstevel@tonic-gate  *  be multiple body chunks passed to the filter. End-of-lines are
3637c478bd9Sstevel@tonic-gate  *  represented as received from SMTP (normally Carriage-Return/Line-Feed).
3647c478bd9Sstevel@tonic-gate  *
3657c478bd9Sstevel@tonic-gate  *	unsigned char *bodyp; Pointer to body data
3667c478bd9Sstevel@tonic-gate  *	size_t bodylen; Length of body data
3677c478bd9Sstevel@tonic-gate  */
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate /* end of message */
3707c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_eom __P((SMFICTX *));
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate /*
3737c478bd9Sstevel@tonic-gate  *  xxfi_eom(ctx) Invoked at end of message. This routine can perform
3747c478bd9Sstevel@tonic-gate  *  special operations such as modifying the message header, body, or
3757c478bd9Sstevel@tonic-gate  *  envelope.
3767c478bd9Sstevel@tonic-gate  */
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate /* message aborted */
3797c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_abort __P((SMFICTX *));
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate /*
3827c478bd9Sstevel@tonic-gate  *  xxfi_abort(ctx) Invoked if message is aborted outside of the control of
3837c478bd9Sstevel@tonic-gate  *  the filter, for example, if the SMTP sender issues an RSET command. If
3847c478bd9Sstevel@tonic-gate  *  xxfi_abort is called, xxfi_eom will not be called and vice versa.
3857c478bd9Sstevel@tonic-gate  */
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate /* connection cleanup */
3887c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_close __P((SMFICTX *));
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate /*
3917c478bd9Sstevel@tonic-gate  *  xxfi_close(ctx) Invoked at end of the connection. This is called on
3927c478bd9Sstevel@tonic-gate  *  close even if the previous mail transaction was aborted.
3937c478bd9Sstevel@tonic-gate  */
3947c478bd9Sstevel@tonic-gate #endif /* 0 */
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate /*
3977c478bd9Sstevel@tonic-gate  *  Additional information is passed in to the vendor filter routines using
3987c478bd9Sstevel@tonic-gate  *  symbols. Symbols correspond closely to sendmail macros. The symbols
3997c478bd9Sstevel@tonic-gate  *  defined depend on the context. The value of a symbol is accessed using:
4007c478bd9Sstevel@tonic-gate  */
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate /* Return the value of a symbol. */
4037c478bd9Sstevel@tonic-gate LIBMILTER_API char *smfi_getsymval __P((SMFICTX *, char *));
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate /*
4067c478bd9Sstevel@tonic-gate  *  Return the value of a symbol.
4077c478bd9Sstevel@tonic-gate  *
4087c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4097c478bd9Sstevel@tonic-gate  *	char *symname; The name of the symbol to access.
4107c478bd9Sstevel@tonic-gate  */
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /*
4137c478bd9Sstevel@tonic-gate  *  Vendor filter routines that want to pass additional information back to
4147c478bd9Sstevel@tonic-gate  *  the MTA for use in SMTP replies may call smfi_setreply before returning.
4157c478bd9Sstevel@tonic-gate  */
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate /*
4207c478bd9Sstevel@tonic-gate  *  Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
4217c478bd9Sstevel@tonic-gate  *  is needed.
4227c478bd9Sstevel@tonic-gate  */
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *,
4257c478bd9Sstevel@tonic-gate 					...));
4267c478bd9Sstevel@tonic-gate 
4277c478bd9Sstevel@tonic-gate /*
4287c478bd9Sstevel@tonic-gate  *  Set the specific reply code to be used in response to the active
4297c478bd9Sstevel@tonic-gate  *  command. If not specified, a generic reply code is used.
4307c478bd9Sstevel@tonic-gate  *
4317c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4327c478bd9Sstevel@tonic-gate  *	char *rcode; The three-digit (RFC 821) SMTP reply code to be
4337c478bd9Sstevel@tonic-gate  *		returned, e.g., ``551''.
4347c478bd9Sstevel@tonic-gate  *	char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
4357c478bd9Sstevel@tonic-gate  *	char *message; The text part of the SMTP reply.
4367c478bd9Sstevel@tonic-gate  */
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate /*
4397c478bd9Sstevel@tonic-gate  *  The xxfi_eom routine is called at the end of a message (essentially,
4407c478bd9Sstevel@tonic-gate  *  after the final DATA dot). This routine can call some special routines
4417c478bd9Sstevel@tonic-gate  *  to modify the envelope, header, or body of the message before the
4427c478bd9Sstevel@tonic-gate  *  message is enqueued. These routines must not be called from any vendor
4437c478bd9Sstevel@tonic-gate  *  routine other than xxfi_eom.
4447c478bd9Sstevel@tonic-gate  */
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate /*
4497c478bd9Sstevel@tonic-gate  *  Add a header to the message. It is not checked for standards
4507c478bd9Sstevel@tonic-gate  *  compliance; the mail filter must ensure that no protocols are violated
4517c478bd9Sstevel@tonic-gate  *  as a result of adding this header.
4527c478bd9Sstevel@tonic-gate  *
4537c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4547c478bd9Sstevel@tonic-gate  *	char *headerf; Header field name
4557c478bd9Sstevel@tonic-gate  *	char *headerv; Header field value
4567c478bd9Sstevel@tonic-gate  */
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate /*
4617c478bd9Sstevel@tonic-gate  *  Change/delete a header in the message.  It is not checked for standards
4627c478bd9Sstevel@tonic-gate  *  compliance; the mail filter must ensure that no protocols are violated
4637c478bd9Sstevel@tonic-gate  *  as a result of adding this header.
4647c478bd9Sstevel@tonic-gate  *
4657c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4667c478bd9Sstevel@tonic-gate  *	char *headerf; Header field name
4677c478bd9Sstevel@tonic-gate  *	int index; The Nth occurence of header field name
4687c478bd9Sstevel@tonic-gate  *	char *headerv; New header field value (empty for delete header)
4697c478bd9Sstevel@tonic-gate  */
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate /*
4747c478bd9Sstevel@tonic-gate  *  Insert a header into the message.  It is not checked for standards
4757c478bd9Sstevel@tonic-gate  *  compliance; the mail filter must ensure that no protocols are violated
4767c478bd9Sstevel@tonic-gate  *  as a result of adding this header.
4777c478bd9Sstevel@tonic-gate  *
4787c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4797c478bd9Sstevel@tonic-gate  *  	int idx; index into the header list where the insertion should happen
4807c478bd9Sstevel@tonic-gate  *	char *headerh; Header field name
4817c478bd9Sstevel@tonic-gate  *	char *headerv; Header field value
4827c478bd9Sstevel@tonic-gate  */
4837c478bd9Sstevel@tonic-gate 
484058561cbSjbeck LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *));
485058561cbSjbeck 
486058561cbSjbeck /*
487058561cbSjbeck  *  Modify envelope sender address
488058561cbSjbeck  *
489058561cbSjbeck  *     SMFICTX *ctx; Opaque context structure
490058561cbSjbeck  *     char *mail; New envelope sender address
491058561cbSjbeck  *     char *args; ESMTP arguments
492058561cbSjbeck  */
493058561cbSjbeck 
494058561cbSjbeck 
4957c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate /*
4987c478bd9Sstevel@tonic-gate  *  Add a recipient to the envelope
4997c478bd9Sstevel@tonic-gate  *
5007c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
5017c478bd9Sstevel@tonic-gate  *	char *rcpt; Recipient to be added
5027c478bd9Sstevel@tonic-gate  */
5037c478bd9Sstevel@tonic-gate 
504058561cbSjbeck LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *));
505058561cbSjbeck 
506058561cbSjbeck /*
507058561cbSjbeck  *  Add a recipient to the envelope
508058561cbSjbeck  *
509058561cbSjbeck  *	SMFICTX *ctx; Opaque context structure
510058561cbSjbeck  *	char *rcpt; Recipient to be added
511058561cbSjbeck  *	char *args; ESMTP arguments
512058561cbSjbeck  */
513058561cbSjbeck 
514058561cbSjbeck 
5157c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate /*
5187c478bd9Sstevel@tonic-gate  *  Send a "no-op" up to the MTA to tell it we're still alive, so long
5197c478bd9Sstevel@tonic-gate  *  milter-side operations don't time out.
5207c478bd9Sstevel@tonic-gate  *
5217c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
5227c478bd9Sstevel@tonic-gate  */
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_progress __P((SMFICTX *));
5257c478bd9Sstevel@tonic-gate 
5267c478bd9Sstevel@tonic-gate /*
5277c478bd9Sstevel@tonic-gate  *  Delete a recipient from the envelope
5287c478bd9Sstevel@tonic-gate  *
5297c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
5307c478bd9Sstevel@tonic-gate  *	char *rcpt; Envelope recipient to be deleted. This should be in
5317c478bd9Sstevel@tonic-gate  *		exactly the form passed to xxfi_envrcpt or the address may
5327c478bd9Sstevel@tonic-gate  *		not be deleted.
5337c478bd9Sstevel@tonic-gate  */
5347c478bd9Sstevel@tonic-gate 
5357c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
5367c478bd9Sstevel@tonic-gate 
5377c478bd9Sstevel@tonic-gate /*
5387c478bd9Sstevel@tonic-gate  *  Replace the body of the message. This routine may be called multiple
5397c478bd9Sstevel@tonic-gate  *  times if the body is longer than convenient to send in one call. End of
5407c478bd9Sstevel@tonic-gate  *  line should be represented as Carriage-Return/Line Feed.
5417c478bd9Sstevel@tonic-gate  *
5427c478bd9Sstevel@tonic-gate  *	char *bodyp; Pointer to block of body information to insert
5437c478bd9Sstevel@tonic-gate  *	int bodylen; Length of data pointed at by bodyp
5447c478bd9Sstevel@tonic-gate  */
5457c478bd9Sstevel@tonic-gate 
5467c478bd9Sstevel@tonic-gate /*
5477c478bd9Sstevel@tonic-gate  *  If the message is aborted (for example, if the SMTP sender sends the
5487c478bd9Sstevel@tonic-gate  *  envelope but then does a QUIT or RSET before the data is sent),
5497c478bd9Sstevel@tonic-gate  *  xxfi_abort is called. This can be used to reset state.
5507c478bd9Sstevel@tonic-gate  */
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate /*
5537c478bd9Sstevel@tonic-gate  *  Quarantine an envelope
5547c478bd9Sstevel@tonic-gate  *
5557c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
5567c478bd9Sstevel@tonic-gate  *	char *reason: explanation
5577c478bd9Sstevel@tonic-gate  */
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
5607c478bd9Sstevel@tonic-gate 
5617c478bd9Sstevel@tonic-gate /*
5627c478bd9Sstevel@tonic-gate  *  Connection-private data (specific to an SMTP connection) can be
5637c478bd9Sstevel@tonic-gate  *  allocated using the smfi_setpriv routine; routines can access private
5647c478bd9Sstevel@tonic-gate  *  data using smfi_getpriv.
5657c478bd9Sstevel@tonic-gate  */
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
5687c478bd9Sstevel@tonic-gate 
5697c478bd9Sstevel@tonic-gate /*
5707c478bd9Sstevel@tonic-gate  *  Set the private data pointer
5717c478bd9Sstevel@tonic-gate  *
5727c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
5737c478bd9Sstevel@tonic-gate  *	void *privatedata; Pointer to private data area
5747c478bd9Sstevel@tonic-gate  */
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate LIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
5777c478bd9Sstevel@tonic-gate 
578058561cbSjbeck /*
579058561cbSjbeck  *  Get the private data pointer
580058561cbSjbeck  *
581058561cbSjbeck  *	SMFICTX *ctx; Opaque context structure
582058561cbSjbeck  *	void *privatedata; Pointer to private data area
583058561cbSjbeck  */
584058561cbSjbeck 
585058561cbSjbeck LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *));
586058561cbSjbeck 
587058561cbSjbeck /*
588058561cbSjbeck  *  Set list of symbols (macros) to receive
589058561cbSjbeck  *
590058561cbSjbeck  *	SMFICTX *ctx; Opaque context structure
591058561cbSjbeck  *	int where; where in the SMTP dialogue should the macros be sent
592058561cbSjbeck  *	char *macros; list of macros (space separated)
593058561cbSjbeck  */
594058561cbSjbeck 
595058561cbSjbeck #if _FFR_THREAD_MONITOR
596058561cbSjbeck LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int));
597058561cbSjbeck #endif /* _FFR_THREAD_MONITOR */
598058561cbSjbeck 
5997c478bd9Sstevel@tonic-gate #ifdef __cplusplus
6007c478bd9Sstevel@tonic-gate }
6017c478bd9Sstevel@tonic-gate #endif
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate #endif /* !_LIBMILTER_MFAPI_H */
604