106f25ae9SGregory Neil Shapiro /* 2e3793f76SGregory Neil Shapiro * Copyright (c) 1999-2004, 2006, 2008 Sendmail, Inc. and its suppliers. 306f25ae9SGregory Neil Shapiro * All rights reserved. 406f25ae9SGregory Neil Shapiro * 506f25ae9SGregory Neil Shapiro * By using this file, you agree to the terms and conditions set 606f25ae9SGregory Neil Shapiro * forth in the LICENSE file which can be found at the top level of 706f25ae9SGregory Neil Shapiro * the sendmail distribution. 806f25ae9SGregory Neil Shapiro * 906f25ae9SGregory Neil Shapiro * 109bd497b8SGregory Neil Shapiro * $Id: mfapi.h,v 8.80 2009/11/06 00:57:08 ca Exp $ 1106f25ae9SGregory Neil Shapiro */ 1206f25ae9SGregory Neil Shapiro 1306f25ae9SGregory Neil Shapiro /* 1406f25ae9SGregory Neil Shapiro ** MFAPI.H -- Global definitions for mail filter library and mail filters. 1506f25ae9SGregory Neil Shapiro */ 1606f25ae9SGregory Neil Shapiro 1706f25ae9SGregory Neil Shapiro #ifndef _LIBMILTER_MFAPI_H 1806f25ae9SGregory Neil Shapiro # define _LIBMILTER_MFAPI_H 1 1906f25ae9SGregory Neil Shapiro 20e92d3f3fSGregory Neil Shapiro #ifndef SMFI_VERSION 219bd497b8SGregory Neil Shapiro # if _FFR_MDS_NEGOTIATE 229bd497b8SGregory Neil Shapiro # define SMFI_VERSION 0x01000002 /* libmilter version number */ 239bd497b8SGregory Neil Shapiro 249bd497b8SGregory Neil Shapiro /* first libmilter version that has MDS support */ 259bd497b8SGregory Neil Shapiro # define SMFI_VERSION_MDS 0x01000002 269bd497b8SGregory Neil Shapiro # else /* _FFR_MDS_NEGOTIATE */ 27e3793f76SGregory Neil Shapiro # define SMFI_VERSION 0x01000001 /* libmilter version number */ 289bd497b8SGregory Neil Shapiro # endif /* _FFR_MDS_NEGOTIATE */ 29e92d3f3fSGregory Neil Shapiro #endif /* ! SMFI_VERSION */ 3013bd1963SGregory Neil Shapiro 31d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_MAJOR(v) (((v) & 0x7f000000) >> 24) 32d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_MINOR(v) (((v) & 0x007fff00) >> 8) 33d0cef73dSGregory Neil Shapiro #define SM_LM_VRS_PLVL(v) ((v) & 0x0000007f) 34d0cef73dSGregory Neil Shapiro 35e92d3f3fSGregory Neil Shapiro # include <sys/types.h> 3640266059SGregory Neil Shapiro # include <sys/socket.h> 37e92d3f3fSGregory Neil Shapiro 3840266059SGregory Neil Shapiro #include "libmilter/mfdef.h" 3906f25ae9SGregory Neil Shapiro 4040266059SGregory Neil Shapiro # define LIBMILTER_API extern 4106f25ae9SGregory Neil Shapiro 4206f25ae9SGregory Neil Shapiro 43e92d3f3fSGregory Neil Shapiro /* Only need to export C interface if used by C++ source code */ 44e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus 45e92d3f3fSGregory Neil Shapiro extern "C" { 46e92d3f3fSGregory Neil Shapiro #endif /* __cplusplus */ 47e92d3f3fSGregory Neil Shapiro 4806f25ae9SGregory Neil Shapiro #ifndef _SOCK_ADDR 4906f25ae9SGregory Neil Shapiro # define _SOCK_ADDR struct sockaddr 5006f25ae9SGregory Neil Shapiro #endif /* ! _SOCK_ADDR */ 5106f25ae9SGregory Neil Shapiro 5206f25ae9SGregory Neil Shapiro /* 5306f25ae9SGregory Neil Shapiro ** libmilter functions return one of the following to indicate 54d0cef73dSGregory Neil Shapiro ** success/failure(/continue): 5506f25ae9SGregory Neil Shapiro */ 5606f25ae9SGregory Neil Shapiro 5706f25ae9SGregory Neil Shapiro #define MI_SUCCESS 0 5806f25ae9SGregory Neil Shapiro #define MI_FAILURE (-1) 59d0cef73dSGregory Neil Shapiro #if _FFR_WORKERS_POOL 60d0cef73dSGregory Neil Shapiro # define MI_CONTINUE 1 61d0cef73dSGregory Neil Shapiro #endif /* _FFR_WORKERS_POOL */ 6206f25ae9SGregory Neil Shapiro 6306f25ae9SGregory Neil Shapiro /* "forward" declarations */ 6406f25ae9SGregory Neil Shapiro typedef struct smfi_str SMFICTX; 6506f25ae9SGregory Neil Shapiro typedef struct smfi_str *SMFICTX_PTR; 6606f25ae9SGregory Neil Shapiro 6706f25ae9SGregory Neil Shapiro typedef struct smfiDesc smfiDesc_str; 6806f25ae9SGregory Neil Shapiro typedef struct smfiDesc *smfiDesc_ptr; 6906f25ae9SGregory Neil Shapiro 7006f25ae9SGregory Neil Shapiro /* 7106f25ae9SGregory Neil Shapiro ** Type which callbacks should return to indicate message status. 7206f25ae9SGregory Neil Shapiro ** This may take on one of the SMFIS_* values listed below. 7306f25ae9SGregory Neil Shapiro */ 7406f25ae9SGregory Neil Shapiro 7506f25ae9SGregory Neil Shapiro typedef int sfsistat; 7606f25ae9SGregory Neil Shapiro 7706f25ae9SGregory Neil Shapiro #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC_MINOR__ >= 8 7806f25ae9SGregory Neil Shapiro # define SM__P(X) __PMT(X) 7906f25ae9SGregory Neil Shapiro #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */ 8006f25ae9SGregory Neil Shapiro # define SM__P(X) __P(X) 8106f25ae9SGregory Neil Shapiro #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */ 8206f25ae9SGregory Neil Shapiro 8306f25ae9SGregory Neil Shapiro /* Some platforms don't define __P -- do it for them here: */ 8406f25ae9SGregory Neil Shapiro #ifndef __P 8506f25ae9SGregory Neil Shapiro # ifdef __STDC__ 8606f25ae9SGregory Neil Shapiro # define __P(X) X 8706f25ae9SGregory Neil Shapiro # else /* __STDC__ */ 8806f25ae9SGregory Neil Shapiro # define __P(X) () 8906f25ae9SGregory Neil Shapiro # endif /* __STDC__ */ 9006f25ae9SGregory Neil Shapiro #endif /* __P */ 9106f25ae9SGregory Neil Shapiro 92e92d3f3fSGregory Neil Shapiro #if SM_CONF_STDBOOL_H 93e92d3f3fSGregory Neil Shapiro # include <stdbool.h> 94e92d3f3fSGregory Neil Shapiro #else /* SM_CONF_STDBOOL_H */ 95e92d3f3fSGregory Neil Shapiro # ifndef __cplusplus 96e92d3f3fSGregory Neil Shapiro # ifndef bool 97e92d3f3fSGregory Neil Shapiro # ifndef __bool_true_false_are_defined 98e92d3f3fSGregory Neil Shapiro typedef int bool; 99*0d3a0b40SGregory Neil Shapiro # define false 0 100*0d3a0b40SGregory 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 209d0cef73dSGregory Neil Shapiro #define SMFIM_FIRST 0 /* Do NOT use, internal marker only */ 210d0cef73dSGregory Neil Shapiro #define SMFIM_CONNECT 0 /* connect */ 211d0cef73dSGregory Neil Shapiro #define SMFIM_HELO 1 /* HELO/EHLO */ 212d0cef73dSGregory Neil Shapiro #define SMFIM_ENVFROM 2 /* MAIL From */ 213d0cef73dSGregory Neil Shapiro #define SMFIM_ENVRCPT 3 /* RCPT To */ 214d0cef73dSGregory Neil Shapiro #define SMFIM_DATA 4 /* DATA */ 215d0cef73dSGregory Neil Shapiro #define SMFIM_EOM 5 /* end of message (final dot) */ 216d0cef73dSGregory Neil Shapiro #define SMFIM_EOH 6 /* end of header */ 217d0cef73dSGregory Neil Shapiro #define SMFIM_LAST 6 /* Do NOT use, internal marker only */ 218d0cef73dSGregory Neil Shapiro 21906f25ae9SGregory Neil Shapiro /* 22006f25ae9SGregory Neil Shapiro ** Continue processing message/connection. 22106f25ae9SGregory Neil Shapiro */ 22206f25ae9SGregory Neil Shapiro 22306f25ae9SGregory Neil Shapiro #define SMFIS_CONTINUE 0 22406f25ae9SGregory Neil Shapiro 22506f25ae9SGregory Neil Shapiro /* 22606f25ae9SGregory Neil Shapiro ** Reject the message/connection. 22706f25ae9SGregory Neil Shapiro ** No further routines will be called for this message 22806f25ae9SGregory Neil Shapiro ** (or connection, if returned from a connection-oriented routine). 22906f25ae9SGregory Neil Shapiro */ 23006f25ae9SGregory Neil Shapiro 23106f25ae9SGregory Neil Shapiro #define SMFIS_REJECT 1 23206f25ae9SGregory Neil Shapiro 23306f25ae9SGregory Neil Shapiro /* 23406f25ae9SGregory Neil Shapiro ** Accept the message, 23506f25ae9SGregory Neil Shapiro ** but silently discard the message. 23606f25ae9SGregory Neil Shapiro ** No further routines will be called for this message. 23706f25ae9SGregory Neil Shapiro ** This is only meaningful from message-oriented routines. 23806f25ae9SGregory Neil Shapiro */ 23906f25ae9SGregory Neil Shapiro 24006f25ae9SGregory Neil Shapiro #define SMFIS_DISCARD 2 24106f25ae9SGregory Neil Shapiro 24206f25ae9SGregory Neil Shapiro /* 24306f25ae9SGregory Neil Shapiro ** Accept the message/connection. 24406f25ae9SGregory Neil Shapiro ** No further routines will be called for this message 24506f25ae9SGregory Neil Shapiro ** (or connection, if returned from a connection-oriented routine; 24606f25ae9SGregory Neil Shapiro ** in this case, it causes all messages on this connection 24706f25ae9SGregory Neil Shapiro ** to be accepted without filtering). 24806f25ae9SGregory Neil Shapiro */ 24906f25ae9SGregory Neil Shapiro 25006f25ae9SGregory Neil Shapiro #define SMFIS_ACCEPT 3 25106f25ae9SGregory Neil Shapiro 25206f25ae9SGregory Neil Shapiro /* 25306f25ae9SGregory Neil Shapiro ** Return a temporary failure, i.e., 25406f25ae9SGregory Neil Shapiro ** the corresponding SMTP command will return a 4xx status code. 25506f25ae9SGregory Neil Shapiro ** In some cases this may prevent further routines from 25606f25ae9SGregory Neil Shapiro ** being called on this message or connection, 25706f25ae9SGregory Neil Shapiro ** although in other cases (e.g., when processing an envelope 25806f25ae9SGregory Neil Shapiro ** recipient) processing of the message will continue. 25906f25ae9SGregory Neil Shapiro */ 26006f25ae9SGregory Neil Shapiro 26106f25ae9SGregory Neil Shapiro #define SMFIS_TEMPFAIL 4 26206f25ae9SGregory Neil Shapiro 263d0cef73dSGregory Neil Shapiro /* 264d0cef73dSGregory Neil Shapiro ** Do not send a reply to the MTA 265d0cef73dSGregory Neil Shapiro */ 266d0cef73dSGregory Neil Shapiro 267d0cef73dSGregory Neil Shapiro #define SMFIS_NOREPLY 7 268d0cef73dSGregory Neil Shapiro 269d0cef73dSGregory Neil Shapiro /* 270d0cef73dSGregory Neil Shapiro ** Skip over rest of same callbacks, e.g., body. 271d0cef73dSGregory Neil Shapiro */ 272d0cef73dSGregory Neil Shapiro 273d0cef73dSGregory Neil Shapiro #define SMFIS_SKIP 8 274d0cef73dSGregory Neil Shapiro 275d0cef73dSGregory Neil Shapiro /* xxfi_negotiate: use all existing protocol options/actions */ 276d0cef73dSGregory Neil Shapiro #define SMFIS_ALL_OPTS 10 277d0cef73dSGregory Neil Shapiro 27806f25ae9SGregory Neil Shapiro #if 0 27906f25ae9SGregory Neil Shapiro /* 28006f25ae9SGregory Neil Shapiro ** Filter Routine Details 28106f25ae9SGregory Neil Shapiro */ 28206f25ae9SGregory Neil Shapiro 28306f25ae9SGregory Neil Shapiro /* connection info filter */ 28406f25ae9SGregory Neil Shapiro extern sfsistat xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *)); 28506f25ae9SGregory Neil Shapiro 28606f25ae9SGregory Neil Shapiro /* 28706f25ae9SGregory Neil Shapiro ** xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection 28806f25ae9SGregory Neil Shapiro ** 28906f25ae9SGregory Neil Shapiro ** char *hostname; Host domain name, as determined by a reverse lookup 29006f25ae9SGregory Neil Shapiro ** on the host address. 29106f25ae9SGregory Neil Shapiro ** _SOCK_ADDR *hostaddr; Host address, as determined by a getpeername 29206f25ae9SGregory Neil Shapiro ** call on the SMTP socket. 29306f25ae9SGregory Neil Shapiro */ 29406f25ae9SGregory Neil Shapiro 29506f25ae9SGregory Neil Shapiro /* SMTP HELO command filter */ 29606f25ae9SGregory Neil Shapiro extern sfsistat xxfi_helo __P((SMFICTX *, char *)); 29706f25ae9SGregory Neil Shapiro 29806f25ae9SGregory Neil Shapiro /* 29906f25ae9SGregory Neil Shapiro ** xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command 30006f25ae9SGregory Neil Shapiro ** 30106f25ae9SGregory Neil Shapiro ** char *helohost; Value passed to HELO/EHLO command, which should be 30206f25ae9SGregory Neil Shapiro ** the domain name of the sending host (but is, in practice, 30306f25ae9SGregory Neil Shapiro ** anything the sending host wants to send). 30406f25ae9SGregory Neil Shapiro */ 30506f25ae9SGregory Neil Shapiro 30606f25ae9SGregory Neil Shapiro /* envelope sender filter */ 30706f25ae9SGregory Neil Shapiro extern sfsistat xxfi_envfrom __P((SMFICTX *, char **)); 30806f25ae9SGregory Neil Shapiro 30906f25ae9SGregory Neil Shapiro /* 31006f25ae9SGregory Neil Shapiro ** xxfi_envfrom(ctx, argv) Invoked on envelope from 31106f25ae9SGregory Neil Shapiro ** 31206f25ae9SGregory Neil Shapiro ** char **argv; Null-terminated SMTP command arguments; 31306f25ae9SGregory Neil Shapiro ** argv[0] is guaranteed to be the sender address. 31406f25ae9SGregory Neil Shapiro ** Later arguments are the ESMTP arguments. 31506f25ae9SGregory Neil Shapiro */ 31606f25ae9SGregory Neil Shapiro 31706f25ae9SGregory Neil Shapiro /* envelope recipient filter */ 31806f25ae9SGregory Neil Shapiro extern sfsistat xxfi_envrcpt __P((SMFICTX *, char **)); 31906f25ae9SGregory Neil Shapiro 32006f25ae9SGregory Neil Shapiro /* 32106f25ae9SGregory Neil Shapiro ** xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient 32206f25ae9SGregory Neil Shapiro ** 32306f25ae9SGregory Neil Shapiro ** char **argv; Null-terminated SMTP command arguments; 32406f25ae9SGregory Neil Shapiro ** argv[0] is guaranteed to be the recipient address. 32506f25ae9SGregory Neil Shapiro ** Later arguments are the ESMTP arguments. 32606f25ae9SGregory Neil Shapiro */ 32706f25ae9SGregory Neil Shapiro 328e92d3f3fSGregory Neil Shapiro /* unknown command filter */ 329e92d3f3fSGregory Neil Shapiro 330d0cef73dSGregory Neil Shapiro extern sfsistat *xxfi_unknown __P((SMFICTX *, const char *)); 331e92d3f3fSGregory Neil Shapiro 332e92d3f3fSGregory Neil Shapiro /* 333e92d3f3fSGregory Neil Shapiro ** xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not 334e92d3f3fSGregory Neil Shapiro ** implemented. 335d0cef73dSGregory Neil Shapiro ** const char *arg; Null-terminated SMTP command 336e92d3f3fSGregory Neil Shapiro */ 337e92d3f3fSGregory Neil Shapiro 33806f25ae9SGregory Neil Shapiro /* header filter */ 33906f25ae9SGregory Neil Shapiro extern sfsistat xxfi_header __P((SMFICTX *, char *, char *)); 34006f25ae9SGregory Neil Shapiro 34106f25ae9SGregory Neil Shapiro /* 34206f25ae9SGregory Neil Shapiro ** xxfi_header(ctx, headerf, headerv) Invoked on each message header. The 34306f25ae9SGregory Neil Shapiro ** content of the header may have folded white space (that is, multiple 34406f25ae9SGregory Neil Shapiro ** lines with following white space) included. 34506f25ae9SGregory Neil Shapiro ** 34606f25ae9SGregory Neil Shapiro ** char *headerf; Header field name 34706f25ae9SGregory Neil Shapiro ** char *headerv; Header field value 34806f25ae9SGregory Neil Shapiro */ 34906f25ae9SGregory Neil Shapiro 35006f25ae9SGregory Neil Shapiro /* end of header */ 35106f25ae9SGregory Neil Shapiro extern sfsistat xxfi_eoh __P((SMFICTX *)); 35206f25ae9SGregory Neil Shapiro 35306f25ae9SGregory Neil Shapiro /* 35406f25ae9SGregory Neil Shapiro ** xxfi_eoh(ctx) Invoked at end of header 35506f25ae9SGregory Neil Shapiro */ 35606f25ae9SGregory Neil Shapiro 35706f25ae9SGregory Neil Shapiro /* body block */ 35840266059SGregory Neil Shapiro extern sfsistat xxfi_body __P((SMFICTX *, unsigned char *, size_t)); 35906f25ae9SGregory Neil Shapiro 36006f25ae9SGregory Neil Shapiro /* 36106f25ae9SGregory Neil Shapiro ** xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may 36206f25ae9SGregory Neil Shapiro ** be multiple body chunks passed to the filter. End-of-lines are 36306f25ae9SGregory Neil Shapiro ** represented as received from SMTP (normally Carriage-Return/Line-Feed). 36406f25ae9SGregory Neil Shapiro ** 36540266059SGregory Neil Shapiro ** unsigned char *bodyp; Pointer to body data 36606f25ae9SGregory Neil Shapiro ** size_t bodylen; Length of body data 36706f25ae9SGregory Neil Shapiro */ 36806f25ae9SGregory Neil Shapiro 36906f25ae9SGregory Neil Shapiro /* end of message */ 37006f25ae9SGregory Neil Shapiro extern sfsistat xxfi_eom __P((SMFICTX *)); 37106f25ae9SGregory Neil Shapiro 37206f25ae9SGregory Neil Shapiro /* 37306f25ae9SGregory Neil Shapiro ** xxfi_eom(ctx) Invoked at end of message. This routine can perform 37406f25ae9SGregory Neil Shapiro ** special operations such as modifying the message header, body, or 37506f25ae9SGregory Neil Shapiro ** envelope. 37606f25ae9SGregory Neil Shapiro */ 37706f25ae9SGregory Neil Shapiro 37806f25ae9SGregory Neil Shapiro /* message aborted */ 37906f25ae9SGregory Neil Shapiro extern sfsistat xxfi_abort __P((SMFICTX *)); 38006f25ae9SGregory Neil Shapiro 38106f25ae9SGregory Neil Shapiro /* 38206f25ae9SGregory Neil Shapiro ** xxfi_abort(ctx) Invoked if message is aborted outside of the control of 38306f25ae9SGregory Neil Shapiro ** the filter, for example, if the SMTP sender issues an RSET command. If 38406f25ae9SGregory Neil Shapiro ** xxfi_abort is called, xxfi_eom will not be called and vice versa. 38506f25ae9SGregory Neil Shapiro */ 38606f25ae9SGregory Neil Shapiro 38706f25ae9SGregory Neil Shapiro /* connection cleanup */ 38806f25ae9SGregory Neil Shapiro extern sfsistat xxfi_close __P((SMFICTX *)); 38906f25ae9SGregory Neil Shapiro 39006f25ae9SGregory Neil Shapiro /* 39106f25ae9SGregory Neil Shapiro ** xxfi_close(ctx) Invoked at end of the connection. This is called on 39206f25ae9SGregory Neil Shapiro ** close even if the previous mail transaction was aborted. 39306f25ae9SGregory Neil Shapiro */ 39406f25ae9SGregory Neil Shapiro #endif /* 0 */ 39506f25ae9SGregory Neil Shapiro 39606f25ae9SGregory Neil Shapiro /* 39706f25ae9SGregory Neil Shapiro ** Additional information is passed in to the vendor filter routines using 39806f25ae9SGregory Neil Shapiro ** symbols. Symbols correspond closely to sendmail macros. The symbols 39906f25ae9SGregory Neil Shapiro ** defined depend on the context. The value of a symbol is accessed using: 40006f25ae9SGregory Neil Shapiro */ 40106f25ae9SGregory Neil Shapiro 40206f25ae9SGregory Neil Shapiro /* Return the value of a symbol. */ 40306f25ae9SGregory Neil Shapiro LIBMILTER_API char * smfi_getsymval __P((SMFICTX *, char *)); 40406f25ae9SGregory Neil Shapiro 40506f25ae9SGregory Neil Shapiro /* 40606f25ae9SGregory Neil Shapiro ** Return the value of a symbol. 40706f25ae9SGregory Neil Shapiro ** 40806f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 40906f25ae9SGregory Neil Shapiro ** char *symname; The name of the symbol to access. 41006f25ae9SGregory Neil Shapiro */ 41106f25ae9SGregory Neil Shapiro 41206f25ae9SGregory Neil Shapiro /* 41306f25ae9SGregory Neil Shapiro ** Vendor filter routines that want to pass additional information back to 41406f25ae9SGregory Neil Shapiro ** the MTA for use in SMTP replies may call smfi_setreply before returning. 41506f25ae9SGregory Neil Shapiro */ 41606f25ae9SGregory Neil Shapiro 41706f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *)); 41806f25ae9SGregory Neil Shapiro 41940266059SGregory Neil Shapiro /* 42040266059SGregory Neil Shapiro ** Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply 42140266059SGregory Neil Shapiro ** is needed. 42240266059SGregory Neil Shapiro */ 42340266059SGregory Neil Shapiro 42440266059SGregory Neil Shapiro LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, ...)); 42540266059SGregory Neil Shapiro 42606f25ae9SGregory Neil Shapiro /* 42706f25ae9SGregory Neil Shapiro ** Set the specific reply code to be used in response to the active 42806f25ae9SGregory Neil Shapiro ** command. If not specified, a generic reply code is used. 42906f25ae9SGregory Neil Shapiro ** 43006f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 43106f25ae9SGregory Neil Shapiro ** char *rcode; The three-digit (RFC 821) SMTP reply code to be 43206f25ae9SGregory Neil Shapiro ** returned, e.g., ``551''. 43306f25ae9SGregory Neil Shapiro ** char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''. 43406f25ae9SGregory Neil Shapiro ** char *message; The text part of the SMTP reply. 43506f25ae9SGregory Neil Shapiro */ 43606f25ae9SGregory Neil Shapiro 43706f25ae9SGregory Neil Shapiro /* 43806f25ae9SGregory Neil Shapiro ** The xxfi_eom routine is called at the end of a message (essentially, 43906f25ae9SGregory Neil Shapiro ** after the final DATA dot). This routine can call some special routines 44006f25ae9SGregory Neil Shapiro ** to modify the envelope, header, or body of the message before the 44106f25ae9SGregory Neil Shapiro ** message is enqueued. These routines must not be called from any vendor 44206f25ae9SGregory Neil Shapiro ** routine other than xxfi_eom. 44306f25ae9SGregory Neil Shapiro */ 44406f25ae9SGregory Neil Shapiro 44506f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *)); 44606f25ae9SGregory Neil Shapiro 44706f25ae9SGregory Neil Shapiro /* 448e92d3f3fSGregory Neil Shapiro ** Add a header to the message. It is not checked for standards 449e92d3f3fSGregory Neil Shapiro ** compliance; the mail filter must ensure that no protocols are violated 450e92d3f3fSGregory Neil Shapiro ** as a result of adding this header. 45106f25ae9SGregory Neil Shapiro ** 45206f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 45306f25ae9SGregory Neil Shapiro ** char *headerf; Header field name 45406f25ae9SGregory Neil Shapiro ** char *headerv; Header field value 45506f25ae9SGregory Neil Shapiro */ 45606f25ae9SGregory Neil Shapiro 45706f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *)); 45806f25ae9SGregory Neil Shapiro 45906f25ae9SGregory Neil Shapiro /* 46006f25ae9SGregory Neil Shapiro ** Change/delete a header in the message. It is not checked for standards 46106f25ae9SGregory Neil Shapiro ** compliance; the mail filter must ensure that no protocols are violated 46206f25ae9SGregory Neil Shapiro ** as a result of adding this header. 46306f25ae9SGregory Neil Shapiro ** 46406f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 46506f25ae9SGregory Neil Shapiro ** char *headerf; Header field name 46606f25ae9SGregory Neil Shapiro ** int index; The Nth occurence of header field name 46706f25ae9SGregory Neil Shapiro ** char *headerv; New header field value (empty for delete header) 46806f25ae9SGregory Neil Shapiro */ 46906f25ae9SGregory Neil Shapiro 470e92d3f3fSGregory Neil Shapiro LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *)); 471e92d3f3fSGregory Neil Shapiro 472e92d3f3fSGregory Neil Shapiro /* 473e92d3f3fSGregory Neil Shapiro ** Insert a header into the message. It is not checked for standards 474e92d3f3fSGregory Neil Shapiro ** compliance; the mail filter must ensure that no protocols are violated 475e92d3f3fSGregory Neil Shapiro ** as a result of adding this header. 476e92d3f3fSGregory Neil Shapiro ** 477e92d3f3fSGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 478e92d3f3fSGregory Neil Shapiro ** int idx; index into the header list where the insertion should happen 479e92d3f3fSGregory Neil Shapiro ** char *headerh; Header field name 480e92d3f3fSGregory Neil Shapiro ** char *headerv; Header field value 481e92d3f3fSGregory Neil Shapiro */ 482e92d3f3fSGregory Neil Shapiro 483d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *)); 484d0cef73dSGregory Neil Shapiro 485d0cef73dSGregory Neil Shapiro /* 486d0cef73dSGregory Neil Shapiro ** Modify envelope sender address 487d0cef73dSGregory Neil Shapiro ** 488d0cef73dSGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 489d0cef73dSGregory Neil Shapiro ** char *mail; New envelope sender address 490d0cef73dSGregory Neil Shapiro ** char *args; ESMTP arguments 491d0cef73dSGregory Neil Shapiro */ 492d0cef73dSGregory Neil Shapiro 493d0cef73dSGregory Neil Shapiro 49406f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *)); 49506f25ae9SGregory Neil Shapiro 49606f25ae9SGregory Neil Shapiro /* 49706f25ae9SGregory Neil Shapiro ** Add a recipient to the envelope 49806f25ae9SGregory Neil Shapiro ** 49906f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 50006f25ae9SGregory Neil Shapiro ** char *rcpt; Recipient to be added 50106f25ae9SGregory Neil Shapiro */ 50206f25ae9SGregory Neil Shapiro 503d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *)); 504d0cef73dSGregory Neil Shapiro 505d0cef73dSGregory Neil Shapiro /* 506d0cef73dSGregory Neil Shapiro ** Add a recipient to the envelope 507d0cef73dSGregory Neil Shapiro ** 508d0cef73dSGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 509d0cef73dSGregory Neil Shapiro ** char *rcpt; Recipient to be added 510d0cef73dSGregory Neil Shapiro ** char *args; ESMTP arguments 511d0cef73dSGregory Neil Shapiro */ 512d0cef73dSGregory Neil Shapiro 513d0cef73dSGregory Neil Shapiro 51406f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *)); 51506f25ae9SGregory Neil Shapiro 516605302a5SGregory Neil Shapiro /* 517605302a5SGregory Neil Shapiro ** Send a "no-op" up to the MTA to tell it we're still alive, so long 518605302a5SGregory Neil Shapiro ** milter-side operations don't time out. 519605302a5SGregory Neil Shapiro ** 520605302a5SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 521605302a5SGregory Neil Shapiro */ 522605302a5SGregory Neil Shapiro 523605302a5SGregory Neil Shapiro LIBMILTER_API int smfi_progress __P((SMFICTX *)); 524605302a5SGregory Neil Shapiro 52506f25ae9SGregory Neil Shapiro /* 52606f25ae9SGregory Neil Shapiro ** Delete a recipient from the envelope 52706f25ae9SGregory Neil Shapiro ** 52806f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 52906f25ae9SGregory Neil Shapiro ** char *rcpt; Envelope recipient to be deleted. This should be in 53006f25ae9SGregory Neil Shapiro ** exactly the form passed to xxfi_envrcpt or the address may 53106f25ae9SGregory Neil Shapiro ** not be deleted. 53206f25ae9SGregory Neil Shapiro */ 53306f25ae9SGregory Neil Shapiro 53440266059SGregory Neil Shapiro LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int)); 53506f25ae9SGregory Neil Shapiro 53606f25ae9SGregory Neil Shapiro /* 53706f25ae9SGregory Neil Shapiro ** Replace the body of the message. This routine may be called multiple 53806f25ae9SGregory Neil Shapiro ** times if the body is longer than convenient to send in one call. End of 53906f25ae9SGregory Neil Shapiro ** line should be represented as Carriage-Return/Line Feed. 54006f25ae9SGregory Neil Shapiro ** 54106f25ae9SGregory Neil Shapiro ** char *bodyp; Pointer to block of body information to insert 54206f25ae9SGregory Neil Shapiro ** int bodylen; Length of data pointed at by bodyp 54306f25ae9SGregory Neil Shapiro */ 54406f25ae9SGregory Neil Shapiro 54506f25ae9SGregory Neil Shapiro /* 54606f25ae9SGregory Neil Shapiro ** If the message is aborted (for example, if the SMTP sender sends the 54706f25ae9SGregory Neil Shapiro ** envelope but then does a QUIT or RSET before the data is sent), 54806f25ae9SGregory Neil Shapiro ** xxfi_abort is called. This can be used to reset state. 54906f25ae9SGregory Neil Shapiro */ 55006f25ae9SGregory Neil Shapiro 55140266059SGregory Neil Shapiro /* 55240266059SGregory Neil Shapiro ** Quarantine an envelope 55340266059SGregory Neil Shapiro ** 55440266059SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 55540266059SGregory Neil Shapiro ** char *reason: explanation 55640266059SGregory Neil Shapiro */ 55740266059SGregory Neil Shapiro 55840266059SGregory Neil Shapiro LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason)); 55906f25ae9SGregory Neil Shapiro 56006f25ae9SGregory Neil Shapiro /* 56106f25ae9SGregory Neil Shapiro ** Connection-private data (specific to an SMTP connection) can be 56206f25ae9SGregory Neil Shapiro ** allocated using the smfi_setpriv routine; routines can access private 56306f25ae9SGregory Neil Shapiro ** data using smfi_getpriv. 56406f25ae9SGregory Neil Shapiro */ 56506f25ae9SGregory Neil Shapiro 56606f25ae9SGregory Neil Shapiro LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *)); 56706f25ae9SGregory Neil Shapiro 56806f25ae9SGregory Neil Shapiro /* 56906f25ae9SGregory Neil Shapiro ** Set the private data pointer 57006f25ae9SGregory Neil Shapiro ** 57106f25ae9SGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 57206f25ae9SGregory Neil Shapiro ** void *privatedata; Pointer to private data area 57306f25ae9SGregory Neil Shapiro */ 57406f25ae9SGregory Neil Shapiro 57506f25ae9SGregory Neil Shapiro LIBMILTER_API void *smfi_getpriv __P((SMFICTX *)); 57606f25ae9SGregory Neil Shapiro 577d0cef73dSGregory Neil Shapiro /* 578d0cef73dSGregory Neil Shapiro ** Get the private data pointer 579d0cef73dSGregory Neil Shapiro ** 580d0cef73dSGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 581d0cef73dSGregory Neil Shapiro ** void *privatedata; Pointer to private data area 582d0cef73dSGregory Neil Shapiro */ 583d0cef73dSGregory Neil Shapiro 584d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *)); 585d0cef73dSGregory Neil Shapiro 586d0cef73dSGregory Neil Shapiro /* 587d0cef73dSGregory Neil Shapiro ** Set list of symbols (macros) to receive 588d0cef73dSGregory Neil Shapiro ** 589d0cef73dSGregory Neil Shapiro ** SMFICTX *ctx; Opaque context structure 590d0cef73dSGregory Neil Shapiro ** int where; where in the SMTP dialogue should the macros be sent 591d0cef73dSGregory Neil Shapiro ** char *macros; list of macros (space separated) 592d0cef73dSGregory Neil Shapiro */ 593d0cef73dSGregory Neil Shapiro 594d0cef73dSGregory Neil Shapiro #if _FFR_THREAD_MONITOR 595d0cef73dSGregory Neil Shapiro LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int)); 596d0cef73dSGregory Neil Shapiro #endif /* _FFR_THREAD_MONITOR */ 597d0cef73dSGregory Neil Shapiro 598e92d3f3fSGregory Neil Shapiro #ifdef __cplusplus 599e92d3f3fSGregory Neil Shapiro } 600e92d3f3fSGregory Neil Shapiro #endif /* __cplusplus */ 60106f25ae9SGregory Neil Shapiro 60206f25ae9SGregory Neil Shapiro #endif /* ! _LIBMILTER_MFAPI_H */ 603