1 /* 2 * Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 * 9 * 10 * $Id: milter.h,v 8.24.16.8 2000/09/17 17:04:24 gshapiro Exp $ 11 */ 12 13 /* 14 ** MILTER.H -- Global definitions for mail filter and MTA. 15 */ 16 17 #ifndef _LIBMILTER_MILTER_H 18 # define _LIBMILTER_MILTER_H 1 19 20 #include "libmilter/mfapi.h" 21 #include "sendmail.h" 22 23 /* Shared protocol constants */ 24 # define MILTER_LEN_BYTES 4 /* length of 32 bit integer in bytes */ 25 # define MILTER_OPTLEN (MILTER_LEN_BYTES * 3) /* length of options */ 26 # define MILTER_CHUNK_SIZE 65535 /* body chunk size */ 27 28 /* address families */ 29 # define SMFIA_UNKNOWN 'U' /* unknown */ 30 # define SMFIA_UNIX 'L' /* unix/local */ 31 # define SMFIA_INET '4' /* inet */ 32 # define SMFIA_INET6 '6' /* inet6 */ 33 34 /* commands: don't use anything smaller than ' ' */ 35 # define SMFIC_ABORT 'A' /* Abort */ 36 # define SMFIC_BODY 'B' /* Body chunk */ 37 # define SMFIC_CONNECT 'C' /* Connection information */ 38 # define SMFIC_MACRO 'D' /* Define macro */ 39 # define SMFIC_BODYEOB 'E' /* final body chunk (End) */ 40 # define SMFIC_HELO 'H' /* HELO/EHLO */ 41 # define SMFIC_HEADER 'L' /* Header */ 42 # define SMFIC_MAIL 'M' /* MAIL from */ 43 # define SMFIC_EOH 'N' /* EOH */ 44 # define SMFIC_OPTNEG 'O' /* Option negotiation */ 45 # define SMFIC_QUIT 'Q' /* QUIT */ 46 # define SMFIC_RCPT 'R' /* RCPT to */ 47 48 /* actions (replies) */ 49 # define SMFIR_ADDRCPT '+' /* add recipient */ 50 # define SMFIR_DELRCPT '-' /* remove recipient */ 51 # define SMFIR_ACCEPT 'a' /* accept */ 52 # define SMFIR_REPLBODY 'b' /* replace body (chunk) */ 53 # define SMFIR_CONTINUE 'c' /* continue */ 54 # define SMFIR_DISCARD 'd' /* discard */ 55 # define SMFIR_CHGHEADER 'm' /* change header */ 56 # define SMFIR_PROGRESS 'p' /* progress */ 57 # define SMFIR_REJECT 'r' /* reject */ 58 # define SMFIR_TEMPFAIL 't' /* tempfail */ 59 # define SMFIR_ADDHEADER 'h' /* add header */ 60 # define SMFIR_REPLYCODE 'y' /* reply code etc */ 61 62 /* What the MTA can send/filter wants in protocol */ 63 # define SMFIP_NOCONNECT 0x00000001L /* MTA should not send connect info */ 64 # define SMFIP_NOHELO 0x00000002L /* MTA should not send HELO info */ 65 # define SMFIP_NOMAIL 0x00000004L /* MTA should not send MAIL info */ 66 # define SMFIP_NORCPT 0x00000008L /* MTA should not send RCPT info */ 67 # define SMFIP_NOBODY 0x00000010L /* MTA should not send body */ 68 # define SMFIP_NOHDRS 0x00000020L /* MTA should not send headers */ 69 # define SMFIP_NOEOH 0x00000040L /* MTA should not send EOH */ 70 71 # define SMFI_V1_PROT 0x0000003FL /* The protocol of V1 filter */ 72 # define SMFI_V2_PROT 0x0000007FL /* The protocol of V2 filter */ 73 # define SMFI_CURR_PROT SMFI_V2_PROT /* The current version */ 74 75 /* socket and thread portability */ 76 # include <pthread.h> 77 typedef pthread_t sthread_t; 78 typedef int socket_t; 79 80 # define MAX_MACROS_ENTRIES 4 /* max size of macro pointer array */ 81 82 /* 83 ** context for milter 84 ** implementation hint: 85 ** macros are stored in mac_buf[] as sequence of: 86 ** macro_name \0 macro_value 87 ** (just as read from the MTA) 88 ** mac_ptr is a list of pointers into mac_buf to the beginning of each 89 ** entry, i.e., macro_name, macro_value, ... 90 */ 91 92 struct smfi_str 93 { 94 sthread_t ctx_id; /* thread id */ 95 socket_t ctx_sd; /* socket descriptor */ 96 int ctx_dbg; /* debug level */ 97 time_t ctx_timeout; /* timeout */ 98 int ctx_state; /* state */ 99 smfiDesc_ptr ctx_smfi; /* filter description */ 100 u_long ctx_pflags; /* protocol flags */ 101 char **ctx_mac_ptr[MAX_MACROS_ENTRIES]; 102 char *ctx_mac_buf[MAX_MACROS_ENTRIES]; 103 char *ctx_reply; /* reply code */ 104 void *ctx_privdata; /* private data */ 105 }; 106 107 #endif /* !_LIBMILTER_MILTER_H */ 108