xref: /titanic_54/usr/src/cmd/sendmail/libmilter/libmilter.h (revision 058561cbaa119a6f2659bc27ef343e1b47266bb2)
17c478bd9Sstevel@tonic-gate /*
2445f2479Sjbeck  * Copyright (c) 1999-2003, 2006 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 
107c478bd9Sstevel@tonic-gate /*
117c478bd9Sstevel@tonic-gate **  LIBMILTER.H -- include file for mail filter library functions
127c478bd9Sstevel@tonic-gate */
137c478bd9Sstevel@tonic-gate 
147c478bd9Sstevel@tonic-gate #ifndef _LIBMILTER_H
157c478bd9Sstevel@tonic-gate # define _LIBMILTER_H	1
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
187c478bd9Sstevel@tonic-gate 
197c478bd9Sstevel@tonic-gate #include <sm/gen.h>
207c478bd9Sstevel@tonic-gate 
217c478bd9Sstevel@tonic-gate #ifdef _DEFINE
227c478bd9Sstevel@tonic-gate # define EXTERN
237c478bd9Sstevel@tonic-gate # define INIT(x)	= x
24*058561cbSjbeck SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.74 2006/12/19 18:19:52 ca Exp $")
257c478bd9Sstevel@tonic-gate #else /* _DEFINE */
267c478bd9Sstevel@tonic-gate # define EXTERN extern
277c478bd9Sstevel@tonic-gate # define INIT(x)
287c478bd9Sstevel@tonic-gate #endif /* _DEFINE */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate 
31*058561cbSjbeck #include "sm/tailq.h"
32*058561cbSjbeck 
337c478bd9Sstevel@tonic-gate #define NOT_SENDMAIL	1
347c478bd9Sstevel@tonic-gate #define _SOCK_ADDR	union bigsockaddr
357c478bd9Sstevel@tonic-gate #include "sendmail.h"
367c478bd9Sstevel@tonic-gate 
37*058561cbSjbeck #ifdef SM_ASSERT
38*058561cbSjbeck #undef SM_ASSERT
39*058561cbSjbeck #endif
40*058561cbSjbeck #ifndef SM_ASSERT
41*058561cbSjbeck #include <assert.h>
42*058561cbSjbeck #define SM_ASSERT(x) assert(x)
43*058561cbSjbeck #endif
44*058561cbSjbeck 
457c478bd9Sstevel@tonic-gate #include "libmilter/milter.h"
467c478bd9Sstevel@tonic-gate 
47*058561cbSjbeck #define MAX_MACROS_ENTRIES	7	/* max size of macro pointer array */
48*058561cbSjbeck 
49*058561cbSjbeck typedef SM_TAILQ_HEAD(, smfi_str)	smfi_hd_T;
50*058561cbSjbeck typedef struct smfi_str smfi_str_S;
51*058561cbSjbeck 
52*058561cbSjbeck /*
53*058561cbSjbeck **  Context for one milter session.
54*058561cbSjbeck **
55*058561cbSjbeck **  Notes:
56*058561cbSjbeck **	There is a 1-1 correlation between a sendmail SMTP server process,
57*058561cbSjbeck **	an SMTP session, and an milter context. Due to the nature of SMTP
58*058561cbSjbeck **	session handling in sendmail 8, this libmilter implementation deals
59*058561cbSjbeck **	only with a single SMTP session per MTA - libmilter connection.
60*058561cbSjbeck **
61*058561cbSjbeck **	There is no "global" context for libmilter, global variables are
62*058561cbSjbeck **	just that (they are not "collected" in a context).
63*058561cbSjbeck **
64*058561cbSjbeck **  Implementation hint:
65*058561cbSjbeck **  macros are stored in mac_buf[] as sequence of:
66*058561cbSjbeck **  macro_name \0 macro_value
67*058561cbSjbeck **  (just as read from the MTA)
68*058561cbSjbeck **  mac_ptr is a list of pointers into mac_buf to the beginning of each
69*058561cbSjbeck **  entry, i.e., macro_name, macro_value, ...
70*058561cbSjbeck */
71*058561cbSjbeck 
72*058561cbSjbeck struct smfi_str
73*058561cbSjbeck {
74*058561cbSjbeck 	sthread_t	ctx_id;		/* thread id */
75*058561cbSjbeck 	socket_t	ctx_sd;		/* socket descriptor */
76*058561cbSjbeck 	int		ctx_dbg;	/* debug level */
77*058561cbSjbeck 	time_t		ctx_timeout;	/* timeout */
78*058561cbSjbeck 	int		ctx_state;	/* state */
79*058561cbSjbeck 	smfiDesc_ptr	ctx_smfi;	/* filter description */
80*058561cbSjbeck 
81*058561cbSjbeck 	int		ctx_prot_vers;	/* libmilter protocol version */
82*058561cbSjbeck 	unsigned long	ctx_aflags;	/* milter action flags */
83*058561cbSjbeck 
84*058561cbSjbeck 	unsigned long	ctx_pflags;	/* milter protocol flags */
85*058561cbSjbeck 
86*058561cbSjbeck 	/*
87*058561cbSjbeck 	**  milter protocol flags that are sent to the MTA;
88*058561cbSjbeck 	**  this is the same as ctx_pflags except for those flags that
89*058561cbSjbeck 	**  are not offered by the MTA but emulated in libmilter.
90*058561cbSjbeck 	*/
91*058561cbSjbeck 
92*058561cbSjbeck 	unsigned long	ctx_pflags2mta;
93*058561cbSjbeck 
94*058561cbSjbeck 	/*
95*058561cbSjbeck 	**  milter protocol version that is sent to the MTA;
96*058561cbSjbeck 	**  this is the same as ctx_prot_vers unless the
97*058561cbSjbeck 	**  MTA protocol version (ctx_mta_prot_vers) is smaller
98*058561cbSjbeck 	**  but still "acceptable".
99*058561cbSjbeck 	*/
100*058561cbSjbeck 
101*058561cbSjbeck 	int		ctx_prot_vers2mta;
102*058561cbSjbeck 
103*058561cbSjbeck 	char		**ctx_mac_ptr[MAX_MACROS_ENTRIES];
104*058561cbSjbeck 	char		*ctx_mac_buf[MAX_MACROS_ENTRIES];
105*058561cbSjbeck 	char		*ctx_mac_list[MAX_MACROS_ENTRIES];
106*058561cbSjbeck 	char		*ctx_reply;	/* reply code */
107*058561cbSjbeck 	void		*ctx_privdata;	/* private data */
108*058561cbSjbeck 
109*058561cbSjbeck 	int		ctx_mta_prot_vers;	/* MTA protocol version */
110*058561cbSjbeck 	unsigned long	ctx_mta_pflags;	/* MTA protocol flags */
111*058561cbSjbeck 	unsigned long	ctx_mta_aflags;	/* MTA action flags */
112*058561cbSjbeck 
113*058561cbSjbeck #if _FFR_THREAD_MONITOR
114*058561cbSjbeck 	time_t		ctx_start;	/* start time of thread */
115*058561cbSjbeck 	SM_TAILQ_ENTRY(smfi_str)	ctx_mon_link;
116*058561cbSjbeck #endif /* _FFR_THREAD_MONITOR */
117*058561cbSjbeck 
118*058561cbSjbeck #if _FFR_WORKERS_POOL
119*058561cbSjbeck 	long		ctx_sid;	/* session identifier */
120*058561cbSjbeck 	int		ctx_wstate;	/* state of the session (worker pool) */
121*058561cbSjbeck 	int		ctx_wait;	/* elapsed time waiting for sm cmd */
122*058561cbSjbeck 	SM_TAILQ_ENTRY(smfi_str)	ctx_link;
123*058561cbSjbeck #endif /* _FFR_WORKERS_POOL */
124*058561cbSjbeck };
125*058561cbSjbeck 
1267c478bd9Sstevel@tonic-gate # define ValidSocket(sd)	((sd) >= 0)
1277c478bd9Sstevel@tonic-gate # define INVALID_SOCKET		(-1)
1287c478bd9Sstevel@tonic-gate # define closesocket		close
1297c478bd9Sstevel@tonic-gate # define MI_SOCK_READ(s, b, l)	read(s, b, l)
1307c478bd9Sstevel@tonic-gate # define MI_SOCK_READ_FAIL(x)	((x) < 0)
1317c478bd9Sstevel@tonic-gate # define MI_SOCK_WRITE(s, b, l)	write(s, b, l)
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate # define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg)
1347c478bd9Sstevel@tonic-gate # define sthread_get_id()	pthread_self()
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate typedef pthread_mutex_t smutex_t;
1377c478bd9Sstevel@tonic-gate # define smutex_init(mp)	(pthread_mutex_init(mp, NULL) == 0)
1387c478bd9Sstevel@tonic-gate # define smutex_destroy(mp)	(pthread_mutex_destroy(mp) == 0)
1397c478bd9Sstevel@tonic-gate # define smutex_lock(mp)	(pthread_mutex_lock(mp) == 0)
1407c478bd9Sstevel@tonic-gate # define smutex_unlock(mp)	(pthread_mutex_unlock(mp) == 0)
1417c478bd9Sstevel@tonic-gate # define smutex_trylock(mp)	(pthread_mutex_trylock(mp) == 0)
1427c478bd9Sstevel@tonic-gate 
143*058561cbSjbeck #if _FFR_WORKERS_POOL
144*058561cbSjbeck /* SM_CONF_POLL shall be defined with _FFR_WORKERS_POOL */
145*058561cbSjbeck # if !SM_CONF_POLL
146*058561cbSjbeck #  define SM_CONF_POLL 1
147*058561cbSjbeck # endif /* SM_CONF_POLL */
148*058561cbSjbeck #endif /* _FFR_WORKERS_POOL */
149*058561cbSjbeck 
150*058561cbSjbeck typedef pthread_cond_t scond_t;
151*058561cbSjbeck #define scond_init(cp)			pthread_cond_init(cp, NULL)
152*058561cbSjbeck #define scond_destroy(cp)		pthread_cond_destroy(cp)
153*058561cbSjbeck #define scond_wait(cp, mp)		pthread_cond_wait(cp, mp)
154*058561cbSjbeck #define scond_signal(cp)		pthread_cond_signal(cp)
155*058561cbSjbeck #define scond_broadcast(cp)		pthread_cond_broadcast(cp)
156*058561cbSjbeck #define scond_timedwait(cp, mp, to)					\
157*058561cbSjbeck 	do								\
158*058561cbSjbeck 	{								\
159*058561cbSjbeck 		struct timespec timeout;				\
160*058561cbSjbeck 		struct timeval now;					\
161*058561cbSjbeck 		gettimeofday(&now, NULL);				\
162*058561cbSjbeck 		timeout.tv_sec = now.tv_sec + to;			\
163*058561cbSjbeck 		timeout.tv_nsec = now.tv_usec / 1000;			\
164*058561cbSjbeck 		r = pthread_cond_timedwait(cp,mp,&timeout);		\
165*058561cbSjbeck 		if (r != 0 && r != ETIMEDOUT)				\
166*058561cbSjbeck 			smi_log(SMI_LOG_ERR,				\
167*058561cbSjbeck 				"pthread_cond_timedwait error %d", r);	\
168*058561cbSjbeck 	} while (0)
169*058561cbSjbeck 
170*058561cbSjbeck 
1717c478bd9Sstevel@tonic-gate #if SM_CONF_POLL
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate # include <poll.h>
1747c478bd9Sstevel@tonic-gate # define MI_POLLSELECT  "poll"
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate # define MI_POLL_RD_FLAGS (POLLIN | POLLPRI)
1777c478bd9Sstevel@tonic-gate # define MI_POLL_WR_FLAGS (POLLOUT)
1787c478bd9Sstevel@tonic-gate # define MI_MS(timeout)	(((timeout)->tv_sec * 1000) + (timeout)->tv_usec)
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate # define FD_RD_VAR(rds, excs) struct pollfd rds
1817c478bd9Sstevel@tonic-gate # define FD_WR_VAR(wrs) struct pollfd wrs
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate # define FD_RD_INIT(sd, rds, excs)			\
1847c478bd9Sstevel@tonic-gate 		(rds).fd = (sd);			\
1857c478bd9Sstevel@tonic-gate 		(rds).events = MI_POLL_RD_FLAGS;	\
1867c478bd9Sstevel@tonic-gate 		(rds).revents = 0
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate # define FD_WR_INIT(sd, wrs)				\
1897c478bd9Sstevel@tonic-gate 		(wrs).fd = (sd);			\
1907c478bd9Sstevel@tonic-gate 		(wrs).events = MI_POLL_WR_FLAGS;	\
1917c478bd9Sstevel@tonic-gate 		(wrs).revents = 0
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate # define FD_IS_RD_EXC(sd, rds, excs)	\
1947c478bd9Sstevel@tonic-gate 		(((rds).revents & (POLLERR | POLLHUP | POLLNVAL)) != 0)
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate # define FD_IS_WR_RDY(sd, wrs)		\
1977c478bd9Sstevel@tonic-gate 		(((wrs).revents & MI_POLL_WR_FLAGS) != 0)
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate # define FD_IS_RD_RDY(sd, rds, excs)			\
2007c478bd9Sstevel@tonic-gate 		(((rds).revents & MI_POLL_RD_FLAGS) != 0)
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate # define FD_WR_READY(sd, excs, timeout)	\
2037c478bd9Sstevel@tonic-gate 		poll(&(wrs), 1, MI_MS(timeout))
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate # define FD_RD_READY(sd, rds, excs, timeout)	\
2067c478bd9Sstevel@tonic-gate 		poll(&(rds), 1, MI_MS(timeout))
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate #else /* SM_CONF_POLL */
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate # include <sm/fdset.h>
2117c478bd9Sstevel@tonic-gate # define MI_POLLSELECT  "select"
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate # define FD_RD_VAR(rds, excs) fd_set rds, excs
2147c478bd9Sstevel@tonic-gate # define FD_WR_VAR(wrs) fd_set wrs
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate # define FD_RD_INIT(sd, rds, excs)			\
2177c478bd9Sstevel@tonic-gate 		FD_ZERO(&(rds));			\
2187c478bd9Sstevel@tonic-gate 		FD_SET((unsigned int) (sd), &(rds));	\
2197c478bd9Sstevel@tonic-gate 		FD_ZERO(&(excs));			\
2207c478bd9Sstevel@tonic-gate 		FD_SET((unsigned int) (sd), &(excs))
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate # define FD_WR_INIT(sd, wrs)			\
2237c478bd9Sstevel@tonic-gate 		FD_ZERO(&(wrs));			\
224445f2479Sjbeck 		FD_SET((unsigned int) (sd), &(wrs))
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate # define FD_IS_RD_EXC(sd, rds, excs) FD_ISSET(sd, &(excs))
2277c478bd9Sstevel@tonic-gate # define FD_IS_WR_RDY(sd, wrs) FD_ISSET((sd), &(wrs))
2287c478bd9Sstevel@tonic-gate # define FD_IS_RD_RDY(sd, rds, excs) FD_ISSET((sd), &(rds))
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate # define FD_WR_READY(sd, wrs, timeout)	\
2317c478bd9Sstevel@tonic-gate 		select((sd) + 1, NULL, &(wrs), NULL, (timeout))
2327c478bd9Sstevel@tonic-gate # define FD_RD_READY(sd, rds, excs, timeout)	\
2337c478bd9Sstevel@tonic-gate 		select((sd) + 1, &(rds), NULL, &(excs), (timeout))
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate #endif /* SM_CONF_POLL */
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate #include <sys/time.h>
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate /* some defaults */
2407c478bd9Sstevel@tonic-gate #define MI_TIMEOUT	7210		/* default timeout for read/write */
2417c478bd9Sstevel@tonic-gate #define MI_CHK_TIME	5		/* checking whether to terminate */
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate #ifndef MI_SOMAXCONN
2447c478bd9Sstevel@tonic-gate # if SOMAXCONN > 20
2457c478bd9Sstevel@tonic-gate #  define MI_SOMAXCONN	SOMAXCONN
2467c478bd9Sstevel@tonic-gate # else /* SOMAXCONN */
2477c478bd9Sstevel@tonic-gate #  define MI_SOMAXCONN	20
2487c478bd9Sstevel@tonic-gate # endif /* SOMAXCONN */
2497c478bd9Sstevel@tonic-gate #endif /* ! MI_SOMAXCONN */
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate /* maximum number of repeated failures in mi_listener() */
2527c478bd9Sstevel@tonic-gate #define MAX_FAILS_M	16	/* malloc() */
2537c478bd9Sstevel@tonic-gate #define MAX_FAILS_T	16	/* thread creation */
2547c478bd9Sstevel@tonic-gate #define MAX_FAILS_A	16	/* accept() */
2557c478bd9Sstevel@tonic-gate #define MAX_FAILS_S	16	/* select() */
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /* internal "commands", i.e., error codes */
2587c478bd9Sstevel@tonic-gate #define SMFIC_TIMEOUT	((char) 1)	/* timeout */
2597c478bd9Sstevel@tonic-gate #define SMFIC_SELECT	((char) 2)	/* select error */
2607c478bd9Sstevel@tonic-gate #define SMFIC_MALLOC	((char) 3)	/* malloc error */
2617c478bd9Sstevel@tonic-gate #define SMFIC_RECVERR	((char) 4)	/* recv() error */
2627c478bd9Sstevel@tonic-gate #define SMFIC_EOF	((char) 5)	/* eof */
2637c478bd9Sstevel@tonic-gate #define SMFIC_UNKNERR	((char) 6)	/* unknown error */
2647c478bd9Sstevel@tonic-gate #define SMFIC_TOOBIG	((char) 7)	/* body chunk too big */
2657c478bd9Sstevel@tonic-gate #define SMFIC_VALIDCMD	' '		/* first valid command */
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /* hack */
2687c478bd9Sstevel@tonic-gate #define smi_log		syslog
2697c478bd9Sstevel@tonic-gate #define sm_dprintf	(void) printf
2707c478bd9Sstevel@tonic-gate #define milter_ret	int
2717c478bd9Sstevel@tonic-gate #define SMI_LOG_ERR	LOG_ERR
2727c478bd9Sstevel@tonic-gate #define SMI_LOG_FATAL	LOG_ERR
2737c478bd9Sstevel@tonic-gate #define SMI_LOG_WARN	LOG_WARNING
2747c478bd9Sstevel@tonic-gate #define SMI_LOG_INFO	LOG_INFO
2757c478bd9Sstevel@tonic-gate #define SMI_LOG_DEBUG	LOG_DEBUG
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate /* stop? */
2787c478bd9Sstevel@tonic-gate #define MILTER_CONT	0
2797c478bd9Sstevel@tonic-gate #define MILTER_STOP	1
2807c478bd9Sstevel@tonic-gate #define MILTER_ABRT	2
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate /* functions */
2837c478bd9Sstevel@tonic-gate extern int	mi_handle_session __P((SMFICTX_PTR));
2847c478bd9Sstevel@tonic-gate extern int	mi_engine __P((SMFICTX_PTR));
2857c478bd9Sstevel@tonic-gate extern int	mi_listener __P((char *, int, smfiDesc_ptr, time_t, int));
2867c478bd9Sstevel@tonic-gate extern void	mi_clr_macros __P((SMFICTX_PTR, int));
2877c478bd9Sstevel@tonic-gate extern int	mi_stop __P((void));
2887c478bd9Sstevel@tonic-gate extern int	mi_control_startup __P((char *));
2897c478bd9Sstevel@tonic-gate extern void	mi_stop_milters __P((int));
2907c478bd9Sstevel@tonic-gate extern void	mi_clean_signals __P((void));
2917c478bd9Sstevel@tonic-gate extern struct hostent *mi_gethostbyname __P((char *, int));
2927c478bd9Sstevel@tonic-gate extern int	mi_inet_pton __P((int, const char *, void *));
2937c478bd9Sstevel@tonic-gate extern void	mi_closener __P((void));
2947c478bd9Sstevel@tonic-gate extern int	mi_opensocket __P((char *, int, int, bool, smfiDesc_ptr));
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate /* communication functions */
2977c478bd9Sstevel@tonic-gate extern char	*mi_rd_cmd __P((socket_t, struct timeval *, char *, size_t *, char *));
2987c478bd9Sstevel@tonic-gate extern int	mi_wr_cmd __P((socket_t, struct timeval *, int, char *, size_t));
2997c478bd9Sstevel@tonic-gate extern bool	mi_sendok __P((SMFICTX_PTR, int));
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 
302*058561cbSjbeck #if _FFR_THREAD_MONITOR
303*058561cbSjbeck extern bool Monitor;
304*058561cbSjbeck 
305*058561cbSjbeck #define MI_MONITOR_INIT()	mi_monitor_init()
306*058561cbSjbeck #define MI_MONITOR_BEGIN(ctx, cmd)			\
307*058561cbSjbeck 	do						\
308*058561cbSjbeck 	{						\
309*058561cbSjbeck 		if (Monitor)				\
310*058561cbSjbeck 			mi_monitor_work_begin(ctx, cmd);\
311*058561cbSjbeck 	} while (0)
312*058561cbSjbeck 
313*058561cbSjbeck #define MI_MONITOR_END(ctx, cmd)			\
314*058561cbSjbeck 	do						\
315*058561cbSjbeck 	{						\
316*058561cbSjbeck 		if (Monitor)				\
317*058561cbSjbeck 			mi_monitor_work_end(ctx, cmd);	\
318*058561cbSjbeck 	} while (0)
319*058561cbSjbeck 
320*058561cbSjbeck int mi_monitor_init __P((void));
321*058561cbSjbeck int mi_monitor_work_begin __P((SMFICTX_PTR, int));
322*058561cbSjbeck int mi_monitor_work_end __P((SMFICTX_PTR, int));
323*058561cbSjbeck 
324*058561cbSjbeck #else /* _FFR_THREAD_MONITOR */
325*058561cbSjbeck #define MI_MONITOR_INIT()	MI_SUCCESS
326*058561cbSjbeck #define MI_MONITOR_BEGIN(ctx, cmd)
327*058561cbSjbeck #define MI_MONITOR_END(ctx, cmd)
328*058561cbSjbeck #endif /* _FFR_THREAD_MONITOR */
329*058561cbSjbeck 
330*058561cbSjbeck #if _FFR_WORKERS_POOL
331*058561cbSjbeck extern int mi_pool_manager_init __P((void));
332*058561cbSjbeck extern int mi_pool_controller_init __P((void));
333*058561cbSjbeck extern int mi_start_session __P((SMFICTX_PTR));
334*058561cbSjbeck #endif /* _FFR_WORKERS_POOL */
335*058561cbSjbeck 
3367c478bd9Sstevel@tonic-gate #endif /* ! _LIBMILTER_H */
337