10Sstevel@tonic-gate /* 26562Sjbeck * Copyright (c) 1999-2004, 2006, 2008 Sendmail, Inc. and its suppliers. 30Sstevel@tonic-gate * All rights reserved. 40Sstevel@tonic-gate * 50Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 60Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 70Sstevel@tonic-gate * the sendmail distribution. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * 10*11440SJohn.Beck@Sun.COM * $Id: mfapi.h,v 8.80 2009/11/26 00:57:08 ca Exp $ 110Sstevel@tonic-gate */ 120Sstevel@tonic-gate 130Sstevel@tonic-gate /* 140Sstevel@tonic-gate * MFAPI.H -- Global definitions for mail filter library and mail filters. 150Sstevel@tonic-gate */ 160Sstevel@tonic-gate 170Sstevel@tonic-gate #ifndef _LIBMILTER_MFAPI_H 180Sstevel@tonic-gate #define _LIBMILTER_MFAPI_H 190Sstevel@tonic-gate 200Sstevel@tonic-gate #ifdef __cplusplus 210Sstevel@tonic-gate extern "C" { 220Sstevel@tonic-gate #endif 230Sstevel@tonic-gate 240Sstevel@tonic-gate #ifndef SMFI_VERSION 25*11440SJohn.Beck@Sun.COM #if _FFR_MDS_NEGOTIATE 26*11440SJohn.Beck@Sun.COM #define SMFI_VERSION 0x01000002 /* libmilter version number */ 27*11440SJohn.Beck@Sun.COM 28*11440SJohn.Beck@Sun.COM /* first libmilter version that has MDS support */ 29*11440SJohn.Beck@Sun.COM #define SMFI_VERSION_MDS 0x01000002 30*11440SJohn.Beck@Sun.COM #else /* _FFR_MDS_NEGOTIATE */ 316562Sjbeck #define SMFI_VERSION 0x01000001 /* libmilter version number */ 32*11440SJohn.Beck@Sun.COM #endif /* _FFR_MDS_NEGOTIATE */ 330Sstevel@tonic-gate #endif /* ! SMFI_VERSION */ 340Sstevel@tonic-gate 353544Sjbeck #define SM_LM_VRS_MAJOR(v) (((v) & 0x7f000000) >> 24) 363544Sjbeck #define SM_LM_VRS_MINOR(v) (((v) & 0x007fff00) >> 8) 373544Sjbeck #define SM_LM_VRS_PLVL(v) ((v) & 0x0000007f) 383544Sjbeck 390Sstevel@tonic-gate #include <sys/types.h> 400Sstevel@tonic-gate #include <sys/socket.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #include <libmilter/mfdef.h> 430Sstevel@tonic-gate 440Sstevel@tonic-gate #define LIBMILTER_API extern 450Sstevel@tonic-gate 460Sstevel@tonic-gate #ifndef _SOCK_ADDR 470Sstevel@tonic-gate #define _SOCK_ADDR struct sockaddr 480Sstevel@tonic-gate #endif /* ! _SOCK_ADDR */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * libmilter functions return one of the following to indicate 523544Sjbeck * success/failure(/continue): 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate #define MI_SUCCESS 0 560Sstevel@tonic-gate #define MI_FAILURE (-1) 573544Sjbeck #if _FFR_WORKERS_POOL 583544Sjbeck #define MI_CONTINUE 1 593544Sjbeck #endif /* _FFR_WORKERS_POOL */ 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* "forward" declarations */ 620Sstevel@tonic-gate typedef struct smfi_str SMFICTX; 630Sstevel@tonic-gate typedef struct smfi_str *SMFICTX_PTR; 640Sstevel@tonic-gate 650Sstevel@tonic-gate typedef struct smfiDesc smfiDesc_str; 660Sstevel@tonic-gate typedef struct smfiDesc *smfiDesc_ptr; 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * Type which callbacks should return to indicate message status. 700Sstevel@tonic-gate * This may take on one of the SMFIS_* values listed below. 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate 730Sstevel@tonic-gate typedef int sfsistat; 740Sstevel@tonic-gate 750Sstevel@tonic-gate #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && \ 760Sstevel@tonic-gate __GNUC_MINOR__ >= 8 770Sstevel@tonic-gate #define SM__P(X) __PMT(X) 780Sstevel@tonic-gate #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */ 790Sstevel@tonic-gate #define SM__P(X) __P(X) 800Sstevel@tonic-gate #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */ 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* Some platforms don't define __P -- do it for them here: */ 830Sstevel@tonic-gate #ifndef __P 840Sstevel@tonic-gate #ifdef __STDC__ 850Sstevel@tonic-gate #define __P(X) X 860Sstevel@tonic-gate #else /* __STDC__ */ 870Sstevel@tonic-gate #define __P(X) () 880Sstevel@tonic-gate #endif /* __STDC__ */ 890Sstevel@tonic-gate #endif /* __P */ 900Sstevel@tonic-gate 910Sstevel@tonic-gate #if SM_CONF_STDBOOL_H 920Sstevel@tonic-gate #include <stdbool.h> 930Sstevel@tonic-gate #else /* SM_CONF_STDBOOL_H */ 940Sstevel@tonic-gate #ifndef __cplusplus 950Sstevel@tonic-gate #ifndef bool 960Sstevel@tonic-gate #ifndef __bool_true_false_are_defined 970Sstevel@tonic-gate typedef int bool; 980Sstevel@tonic-gate #define __bool_true_false_are_defined 1 990Sstevel@tonic-gate #endif /* ! __bool_true_false_are_defined */ 1000Sstevel@tonic-gate #endif /* bool */ 1010Sstevel@tonic-gate #endif /* ! __cplusplus */ 1020Sstevel@tonic-gate #endif /* SM_CONF_STDBOOL_H */ 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* 1050Sstevel@tonic-gate * structure describing one milter 1060Sstevel@tonic-gate */ 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate struct smfiDesc 1090Sstevel@tonic-gate { 1100Sstevel@tonic-gate char *xxfi_name; /* filter name */ 1110Sstevel@tonic-gate int xxfi_version; /* version code -- do not change */ 1120Sstevel@tonic-gate unsigned long xxfi_flags; /* flags */ 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* connection info filter */ 1150Sstevel@tonic-gate sfsistat (*xxfi_connect) SM__P((SMFICTX *, char *, 1160Sstevel@tonic-gate _SOCK_ADDR *)); 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* SMTP HELO command filter */ 1190Sstevel@tonic-gate sfsistat (*xxfi_helo) SM__P((SMFICTX *, char *)); 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate /* envelope sender filter */ 1220Sstevel@tonic-gate sfsistat (*xxfi_envfrom) SM__P((SMFICTX *, char **)); 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate /* envelope recipient filter */ 1250Sstevel@tonic-gate sfsistat (*xxfi_envrcpt) SM__P((SMFICTX *, char **)); 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* header filter */ 1280Sstevel@tonic-gate sfsistat (*xxfi_header) SM__P((SMFICTX *, char *, char *)); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /* end of header */ 1310Sstevel@tonic-gate sfsistat (*xxfi_eoh) SM__P((SMFICTX *)); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate /* body block */ 1340Sstevel@tonic-gate sfsistat (*xxfi_body) SM__P((SMFICTX *, unsigned char *, 1350Sstevel@tonic-gate size_t)); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* end of message */ 1380Sstevel@tonic-gate sfsistat (*xxfi_eom) SM__P((SMFICTX *)); 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* message aborted */ 1410Sstevel@tonic-gate sfsistat (*xxfi_abort) SM__P((SMFICTX *)); 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate /* connection cleanup */ 1440Sstevel@tonic-gate sfsistat (*xxfi_close) SM__P((SMFICTX *)); 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate /* any unrecognized or unimplemented command filter */ 1473544Sjbeck sfsistat (*xxfi_unknown) SM__P((SMFICTX *, const char *)); 1480Sstevel@tonic-gate 1492197Sjbeck /* SMTP DATA command filter */ 1500Sstevel@tonic-gate sfsistat (*xxfi_data) SM__P((SMFICTX *)); 1513544Sjbeck 1523544Sjbeck /* negotiation callback */ 1533544Sjbeck sfsistat (*xxfi_negotiate) SM__P((SMFICTX *, 1543544Sjbeck unsigned long, unsigned long, 1553544Sjbeck unsigned long, unsigned long, 1563544Sjbeck unsigned long *, unsigned long *, 1573544Sjbeck unsigned long *, unsigned long *)); 1583544Sjbeck 1593544Sjbeck #if 0 1603544Sjbeck /* signal handler callback, not yet implemented. */ 1613544Sjbeck int (*xxfi_signal) SM__P((int)); 1623544Sjbeck #endif 1633544Sjbeck 1640Sstevel@tonic-gate }; 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate LIBMILTER_API int smfi_opensocket __P((bool)); 1670Sstevel@tonic-gate LIBMILTER_API int smfi_register __P((struct smfiDesc)); 1680Sstevel@tonic-gate LIBMILTER_API int smfi_main __P((void)); 1690Sstevel@tonic-gate LIBMILTER_API int smfi_setbacklog __P((int)); 1700Sstevel@tonic-gate LIBMILTER_API int smfi_setdbg __P((int)); 1710Sstevel@tonic-gate LIBMILTER_API int smfi_settimeout __P((int)); 1720Sstevel@tonic-gate LIBMILTER_API int smfi_setconn __P((char *)); 1730Sstevel@tonic-gate LIBMILTER_API int smfi_stop __P((void)); 1740Sstevel@tonic-gate LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t)); 1753544Sjbeck LIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *, 1763544Sjbeck unsigned int *)); 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate /* 1790Sstevel@tonic-gate * What the filter might do -- values to be ORed together for 1800Sstevel@tonic-gate * smfiDesc.xxfi_flags. 1810Sstevel@tonic-gate */ 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate #define SMFIF_NONE 0x00000000L /* no flags */ 1840Sstevel@tonic-gate #define SMFIF_ADDHDRS 0x00000001L /* filter may add headers */ 1850Sstevel@tonic-gate #define SMFIF_CHGBODY 0x00000002L /* filter may replace body */ 1860Sstevel@tonic-gate #define SMFIF_MODBODY SMFIF_CHGBODY /* backwards compatible */ 1870Sstevel@tonic-gate #define SMFIF_ADDRCPT 0x00000004L /* filter may add recipients */ 1880Sstevel@tonic-gate #define SMFIF_DELRCPT 0x00000008L /* filter may delete recipients */ 1890Sstevel@tonic-gate #define SMFIF_CHGHDRS 0x00000010L /* filter may change/delete headers */ 1900Sstevel@tonic-gate #define SMFIF_QUARANTINE 0x00000020L /* filter may quarantine envelope */ 1910Sstevel@tonic-gate 1923544Sjbeck /* filter may change "from" (envelope sender) */ 1933544Sjbeck #define SMFIF_CHGFROM 0x00000040L 1943544Sjbeck #define SMFIF_ADDRCPT_PAR 0x00000080L /* add recipients incl. args */ 1953544Sjbeck 1963544Sjbeck /* filter can send set of symbols (macros) that it wants */ 1973544Sjbeck #define SMFIF_SETSYMLIST 0x00000100L 1983544Sjbeck 1993544Sjbeck 2003544Sjbeck /* 2013544Sjbeck * Macro "places"; 2023544Sjbeck * Notes: 2033544Sjbeck * - must be coordinated with libmilter/engine.c and sendmail/milter.c 2043544Sjbeck * - the order MUST NOT be changed as it would break compatibility between 2053544Sjbeck * different versions. It's ok to append new entries however 2063544Sjbeck * (hence the list is not sorted by the SMT protocol steps). 2073544Sjbeck */ 2083544Sjbeck 2093544Sjbeck #define SMFIM_FIRST 0 /* Do NOT use, internal marker only */ 2103544Sjbeck #define SMFIM_CONNECT 0 /* connect */ 2113544Sjbeck #define SMFIM_HELO 1 /* HELO/EHLO */ 2123544Sjbeck #define SMFIM_ENVFROM 2 /* MAIL From */ 2133544Sjbeck #define SMFIM_ENVRCPT 3 /* RCPT To */ 2143544Sjbeck #define SMFIM_DATA 4 /* DATA */ 2153544Sjbeck #define SMFIM_EOM 5 /* end of message (final dot) */ 2163544Sjbeck #define SMFIM_EOH 6 /* end of header */ 2173544Sjbeck #define SMFIM_LAST 6 /* Do NOT use, internal marker only */ 2183544Sjbeck 2190Sstevel@tonic-gate /* 2200Sstevel@tonic-gate * Continue processing message/connection. 2210Sstevel@tonic-gate */ 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate #define SMFIS_CONTINUE 0 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate /* 2260Sstevel@tonic-gate * Reject the message/connection. 2270Sstevel@tonic-gate * No further routines will be called for this message 2280Sstevel@tonic-gate * (or connection, if returned from a connection-oriented routine). 2290Sstevel@tonic-gate */ 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate #define SMFIS_REJECT 1 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate /* 2340Sstevel@tonic-gate * Accept the message, 2350Sstevel@tonic-gate * but silently discard the message. 2360Sstevel@tonic-gate * No further routines will be called for this message. 2370Sstevel@tonic-gate * This is only meaningful from message-oriented routines. 2380Sstevel@tonic-gate */ 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate #define SMFIS_DISCARD 2 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate /* 2430Sstevel@tonic-gate * Accept the message/connection. 2440Sstevel@tonic-gate * No further routines will be called for this message 2450Sstevel@tonic-gate * (or connection, if returned from a connection-oriented routine; 2460Sstevel@tonic-gate * in this case, it causes all messages on this connection 2470Sstevel@tonic-gate * to be accepted without filtering). 2480Sstevel@tonic-gate */ 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate #define SMFIS_ACCEPT 3 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate /* 2530Sstevel@tonic-gate * Return a temporary failure, i.e., 2540Sstevel@tonic-gate * the corresponding SMTP command will return a 4xx status code. 2550Sstevel@tonic-gate * In some cases this may prevent further routines from 2560Sstevel@tonic-gate * being called on this message or connection, 2570Sstevel@tonic-gate * although in other cases (e.g., when processing an envelope 2580Sstevel@tonic-gate * recipient) processing of the message will continue. 2590Sstevel@tonic-gate */ 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate #define SMFIS_TEMPFAIL 4 2620Sstevel@tonic-gate 2633544Sjbeck /* 2643544Sjbeck * Do not send a reply to the MTA 2653544Sjbeck */ 2663544Sjbeck 2673544Sjbeck #define SMFIS_NOREPLY 7 2683544Sjbeck 2693544Sjbeck /* 2703544Sjbeck * Skip over rest of same callbacks, e.g., body. 2713544Sjbeck */ 2723544Sjbeck 2733544Sjbeck #define SMFIS_SKIP 8 2743544Sjbeck 2753544Sjbeck /* xxfi_negotiate: use all existing protocol options/actions */ 2763544Sjbeck #define SMFIS_ALL_OPTS 10 2773544Sjbeck 2780Sstevel@tonic-gate #if 0 2790Sstevel@tonic-gate /* 2800Sstevel@tonic-gate * Filter Routine Details 2810Sstevel@tonic-gate */ 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate /* connection info filter */ 2840Sstevel@tonic-gate extern sfsistat xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *)); 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate /* 2870Sstevel@tonic-gate * xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection 2880Sstevel@tonic-gate * 2890Sstevel@tonic-gate * char *hostname; Host domain name, as determined by a reverse lookup 2900Sstevel@tonic-gate * on the host address. 2910Sstevel@tonic-gate * _SOCK_ADDR *hostaddr; Host address, as determined by a getpeername 2920Sstevel@tonic-gate * call on the SMTP socket. 2930Sstevel@tonic-gate */ 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* SMTP HELO command filter */ 2960Sstevel@tonic-gate extern sfsistat xxfi_helo __P((SMFICTX *, char *)); 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate /* 2990Sstevel@tonic-gate * xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command 3000Sstevel@tonic-gate * 3010Sstevel@tonic-gate * char *helohost; Value passed to HELO/EHLO command, which should be 3020Sstevel@tonic-gate * the domain name of the sending host (but is, in practice, 3030Sstevel@tonic-gate * anything the sending host wants to send). 3040Sstevel@tonic-gate */ 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate /* envelope sender filter */ 3070Sstevel@tonic-gate extern sfsistat xxfi_envfrom __P((SMFICTX *, char **)); 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate /* 3100Sstevel@tonic-gate * xxfi_envfrom(ctx, argv) Invoked on envelope from 3110Sstevel@tonic-gate * 3120Sstevel@tonic-gate * char **argv; Null-terminated SMTP command arguments; 3130Sstevel@tonic-gate * argv[0] is guaranteed to be the sender address. 3140Sstevel@tonic-gate * Later arguments are the ESMTP arguments. 3150Sstevel@tonic-gate */ 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate /* envelope recipient filter */ 3180Sstevel@tonic-gate extern sfsistat xxfi_envrcpt __P((SMFICTX *, char **)); 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate /* 3210Sstevel@tonic-gate * xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient 3220Sstevel@tonic-gate * 3230Sstevel@tonic-gate * char **argv; Null-terminated SMTP command arguments; 3240Sstevel@tonic-gate * argv[0] is guaranteed to be the recipient address. 3250Sstevel@tonic-gate * Later arguments are the ESMTP arguments. 3260Sstevel@tonic-gate */ 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate /* unknown command filter */ 3290Sstevel@tonic-gate 3303544Sjbeck extern sfsistat *xxfi_unknown __P((SMFICTX *, const char *)); 3310Sstevel@tonic-gate 3320Sstevel@tonic-gate /* 3330Sstevel@tonic-gate * xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not 3340Sstevel@tonic-gate * implemented. 3353544Sjbeck * const char *arg; Null-terminated SMTP command 3360Sstevel@tonic-gate */ 3370Sstevel@tonic-gate 3380Sstevel@tonic-gate /* header filter */ 3390Sstevel@tonic-gate extern sfsistat xxfi_header __P((SMFICTX *, char *, char *)); 3400Sstevel@tonic-gate 3410Sstevel@tonic-gate /* 3420Sstevel@tonic-gate * xxfi_header(ctx, headerf, headerv) Invoked on each message header. The 3430Sstevel@tonic-gate * content of the header may have folded white space (that is, multiple 3440Sstevel@tonic-gate * lines with following white space) included. 3450Sstevel@tonic-gate * 3460Sstevel@tonic-gate * char *headerf; Header field name 3470Sstevel@tonic-gate * char *headerv; Header field value 3480Sstevel@tonic-gate */ 3490Sstevel@tonic-gate 3500Sstevel@tonic-gate /* end of header */ 3510Sstevel@tonic-gate extern sfsistat xxfi_eoh __P((SMFICTX *)); 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate /* 3540Sstevel@tonic-gate * xxfi_eoh(ctx) Invoked at end of header 3550Sstevel@tonic-gate */ 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate /* body block */ 3580Sstevel@tonic-gate extern sfsistat xxfi_body __P((SMFICTX *, unsigned char *, size_t)); 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* 3610Sstevel@tonic-gate * xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may 3620Sstevel@tonic-gate * be multiple body chunks passed to the filter. End-of-lines are 3630Sstevel@tonic-gate * represented as received from SMTP (normally Carriage-Return/Line-Feed). 3640Sstevel@tonic-gate * 3650Sstevel@tonic-gate * unsigned char *bodyp; Pointer to body data 3660Sstevel@tonic-gate * size_t bodylen; Length of body data 3670Sstevel@tonic-gate */ 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate /* end of message */ 3700Sstevel@tonic-gate extern sfsistat xxfi_eom __P((SMFICTX *)); 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate /* 3730Sstevel@tonic-gate * xxfi_eom(ctx) Invoked at end of message. This routine can perform 3740Sstevel@tonic-gate * special operations such as modifying the message header, body, or 3750Sstevel@tonic-gate * envelope. 3760Sstevel@tonic-gate */ 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate /* message aborted */ 3790Sstevel@tonic-gate extern sfsistat xxfi_abort __P((SMFICTX *)); 3800Sstevel@tonic-gate 3810Sstevel@tonic-gate /* 3820Sstevel@tonic-gate * xxfi_abort(ctx) Invoked if message is aborted outside of the control of 3830Sstevel@tonic-gate * the filter, for example, if the SMTP sender issues an RSET command. If 3840Sstevel@tonic-gate * xxfi_abort is called, xxfi_eom will not be called and vice versa. 3850Sstevel@tonic-gate */ 3860Sstevel@tonic-gate 3870Sstevel@tonic-gate /* connection cleanup */ 3880Sstevel@tonic-gate extern sfsistat xxfi_close __P((SMFICTX *)); 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate /* 3910Sstevel@tonic-gate * xxfi_close(ctx) Invoked at end of the connection. This is called on 3920Sstevel@tonic-gate * close even if the previous mail transaction was aborted. 3930Sstevel@tonic-gate */ 3940Sstevel@tonic-gate #endif /* 0 */ 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate /* 3970Sstevel@tonic-gate * Additional information is passed in to the vendor filter routines using 3980Sstevel@tonic-gate * symbols. Symbols correspond closely to sendmail macros. The symbols 3990Sstevel@tonic-gate * defined depend on the context. The value of a symbol is accessed using: 4000Sstevel@tonic-gate */ 4010Sstevel@tonic-gate 4020Sstevel@tonic-gate /* Return the value of a symbol. */ 4030Sstevel@tonic-gate LIBMILTER_API char *smfi_getsymval __P((SMFICTX *, char *)); 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate /* 4060Sstevel@tonic-gate * Return the value of a symbol. 4070Sstevel@tonic-gate * 4080Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 4090Sstevel@tonic-gate * char *symname; The name of the symbol to access. 4100Sstevel@tonic-gate */ 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate /* 4130Sstevel@tonic-gate * Vendor filter routines that want to pass additional information back to 4140Sstevel@tonic-gate * the MTA for use in SMTP replies may call smfi_setreply before returning. 4150Sstevel@tonic-gate */ 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *)); 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate /* 4200Sstevel@tonic-gate * Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply 4210Sstevel@tonic-gate * is needed. 4220Sstevel@tonic-gate */ 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, 4250Sstevel@tonic-gate ...)); 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate /* 4280Sstevel@tonic-gate * Set the specific reply code to be used in response to the active 4290Sstevel@tonic-gate * command. If not specified, a generic reply code is used. 4300Sstevel@tonic-gate * 4310Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 4320Sstevel@tonic-gate * char *rcode; The three-digit (RFC 821) SMTP reply code to be 4330Sstevel@tonic-gate * returned, e.g., ``551''. 4340Sstevel@tonic-gate * char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''. 4350Sstevel@tonic-gate * char *message; The text part of the SMTP reply. 4360Sstevel@tonic-gate */ 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate /* 4390Sstevel@tonic-gate * The xxfi_eom routine is called at the end of a message (essentially, 4400Sstevel@tonic-gate * after the final DATA dot). This routine can call some special routines 4410Sstevel@tonic-gate * to modify the envelope, header, or body of the message before the 4420Sstevel@tonic-gate * message is enqueued. These routines must not be called from any vendor 4430Sstevel@tonic-gate * routine other than xxfi_eom. 4440Sstevel@tonic-gate */ 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *)); 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate /* 4490Sstevel@tonic-gate * Add a header to the message. It is not checked for standards 4500Sstevel@tonic-gate * compliance; the mail filter must ensure that no protocols are violated 4510Sstevel@tonic-gate * as a result of adding this header. 4520Sstevel@tonic-gate * 4530Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 4540Sstevel@tonic-gate * char *headerf; Header field name 4550Sstevel@tonic-gate * char *headerv; Header field value 4560Sstevel@tonic-gate */ 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *)); 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate /* 4610Sstevel@tonic-gate * Change/delete a header in the message. It is not checked for standards 4620Sstevel@tonic-gate * compliance; the mail filter must ensure that no protocols are violated 4630Sstevel@tonic-gate * as a result of adding this header. 4640Sstevel@tonic-gate * 4650Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 4660Sstevel@tonic-gate * char *headerf; Header field name 4670Sstevel@tonic-gate * int index; The Nth occurence of header field name 4680Sstevel@tonic-gate * char *headerv; New header field value (empty for delete header) 4690Sstevel@tonic-gate */ 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *)); 4720Sstevel@tonic-gate 4730Sstevel@tonic-gate /* 4740Sstevel@tonic-gate * Insert a header into the message. It is not checked for standards 4750Sstevel@tonic-gate * compliance; the mail filter must ensure that no protocols are violated 4760Sstevel@tonic-gate * as a result of adding this header. 4770Sstevel@tonic-gate * 4780Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 4790Sstevel@tonic-gate * int idx; index into the header list where the insertion should happen 4800Sstevel@tonic-gate * char *headerh; Header field name 4810Sstevel@tonic-gate * char *headerv; Header field value 4820Sstevel@tonic-gate */ 4830Sstevel@tonic-gate 4843544Sjbeck LIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *)); 4853544Sjbeck 4863544Sjbeck /* 4873544Sjbeck * Modify envelope sender address 4883544Sjbeck * 4893544Sjbeck * SMFICTX *ctx; Opaque context structure 4903544Sjbeck * char *mail; New envelope sender address 4913544Sjbeck * char *args; ESMTP arguments 4923544Sjbeck */ 4933544Sjbeck 4943544Sjbeck 4950Sstevel@tonic-gate LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *)); 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate /* 4980Sstevel@tonic-gate * Add a recipient to the envelope 4990Sstevel@tonic-gate * 5000Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 5010Sstevel@tonic-gate * char *rcpt; Recipient to be added 5020Sstevel@tonic-gate */ 5030Sstevel@tonic-gate 5043544Sjbeck LIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *)); 5053544Sjbeck 5063544Sjbeck /* 5073544Sjbeck * Add a recipient to the envelope 5083544Sjbeck * 5093544Sjbeck * SMFICTX *ctx; Opaque context structure 5103544Sjbeck * char *rcpt; Recipient to be added 5113544Sjbeck * char *args; ESMTP arguments 5123544Sjbeck */ 5133544Sjbeck 5143544Sjbeck 5150Sstevel@tonic-gate LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *)); 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate /* 5180Sstevel@tonic-gate * Send a "no-op" up to the MTA to tell it we're still alive, so long 5190Sstevel@tonic-gate * milter-side operations don't time out. 5200Sstevel@tonic-gate * 5210Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 5220Sstevel@tonic-gate */ 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate LIBMILTER_API int smfi_progress __P((SMFICTX *)); 5250Sstevel@tonic-gate 5260Sstevel@tonic-gate /* 5270Sstevel@tonic-gate * Delete a recipient from the envelope 5280Sstevel@tonic-gate * 5290Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 5300Sstevel@tonic-gate * char *rcpt; Envelope recipient to be deleted. This should be in 5310Sstevel@tonic-gate * exactly the form passed to xxfi_envrcpt or the address may 5320Sstevel@tonic-gate * not be deleted. 5330Sstevel@tonic-gate */ 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int)); 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate /* 5380Sstevel@tonic-gate * Replace the body of the message. This routine may be called multiple 5390Sstevel@tonic-gate * times if the body is longer than convenient to send in one call. End of 5400Sstevel@tonic-gate * line should be represented as Carriage-Return/Line Feed. 5410Sstevel@tonic-gate * 5420Sstevel@tonic-gate * char *bodyp; Pointer to block of body information to insert 5430Sstevel@tonic-gate * int bodylen; Length of data pointed at by bodyp 5440Sstevel@tonic-gate */ 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate /* 5470Sstevel@tonic-gate * If the message is aborted (for example, if the SMTP sender sends the 5480Sstevel@tonic-gate * envelope but then does a QUIT or RSET before the data is sent), 5490Sstevel@tonic-gate * xxfi_abort is called. This can be used to reset state. 5500Sstevel@tonic-gate */ 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate /* 5530Sstevel@tonic-gate * Quarantine an envelope 5540Sstevel@tonic-gate * 5550Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 5560Sstevel@tonic-gate * char *reason: explanation 5570Sstevel@tonic-gate */ 5580Sstevel@tonic-gate 5590Sstevel@tonic-gate LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason)); 5600Sstevel@tonic-gate 5610Sstevel@tonic-gate /* 5620Sstevel@tonic-gate * Connection-private data (specific to an SMTP connection) can be 5630Sstevel@tonic-gate * allocated using the smfi_setpriv routine; routines can access private 5640Sstevel@tonic-gate * data using smfi_getpriv. 5650Sstevel@tonic-gate */ 5660Sstevel@tonic-gate 5670Sstevel@tonic-gate LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *)); 5680Sstevel@tonic-gate 5690Sstevel@tonic-gate /* 5700Sstevel@tonic-gate * Set the private data pointer 5710Sstevel@tonic-gate * 5720Sstevel@tonic-gate * SMFICTX *ctx; Opaque context structure 5730Sstevel@tonic-gate * void *privatedata; Pointer to private data area 5740Sstevel@tonic-gate */ 5750Sstevel@tonic-gate 5760Sstevel@tonic-gate LIBMILTER_API void *smfi_getpriv __P((SMFICTX *)); 5770Sstevel@tonic-gate 5783544Sjbeck /* 5793544Sjbeck * Get the private data pointer 5803544Sjbeck * 5813544Sjbeck * SMFICTX *ctx; Opaque context structure 5823544Sjbeck * void *privatedata; Pointer to private data area 5833544Sjbeck */ 5843544Sjbeck 5853544Sjbeck LIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *)); 5863544Sjbeck 5873544Sjbeck /* 5883544Sjbeck * Set list of symbols (macros) to receive 5893544Sjbeck * 5903544Sjbeck * SMFICTX *ctx; Opaque context structure 5913544Sjbeck * int where; where in the SMTP dialogue should the macros be sent 5923544Sjbeck * char *macros; list of macros (space separated) 5933544Sjbeck */ 5943544Sjbeck 5953544Sjbeck #if _FFR_THREAD_MONITOR 5963544Sjbeck LIBMILTER_API int smfi_set_max_exec_time __P((unsigned int)); 5973544Sjbeck #endif /* _FFR_THREAD_MONITOR */ 5983544Sjbeck 5990Sstevel@tonic-gate #ifdef __cplusplus 6000Sstevel@tonic-gate } 6010Sstevel@tonic-gate #endif 6020Sstevel@tonic-gate 6030Sstevel@tonic-gate #endif /* !_LIBMILTER_MFAPI_H */ 604