Sync usage with man page.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / milter / milter.h
blobd2f20a1450e14b5752835835ff513fdd507b623b
1 /* $NetBSD$ */
3 #ifndef _MILTER_H_INCLUDED_
4 #define _MILTER_H_INCLUDED_
6 /*++
7 /* NAME
8 /* milter 3h
9 /* SUMMARY
10 /* smtp server
11 /* SYNOPSIS
12 /* Postfix MTA-side Milter implementation
13 /* DESCRIPTION
14 /* .nf
17 * Utility library.
19 #include <vstring.h>
20 #include <vstream.h>
21 #include <argv.h>
24 * Global library.
26 #include <attr.h>
29 * Each Milter handle is an element of a null-terminated linked list. The
30 * functions are virtual so that we can support multiple MTA-side Milter
31 * implementations. The Sendmail 8 and Sendmail X Milter-side APIs are too
32 * different to implement the MTA side as a single hybrid.
34 typedef struct MILTER {
35 char *name; /* full name including transport */
36 int flags; /* see below */
37 struct MILTER *next; /* linkage */
38 struct MILTERS *parent; /* parent information */
39 struct MILTER_MACROS *macros; /* private macros */
40 const char *(*conn_event) (struct MILTER *, const char *, const char *, const char *, unsigned, ARGV *);
41 const char *(*helo_event) (struct MILTER *, const char *, int, ARGV *);
42 const char *(*mail_event) (struct MILTER *, const char **, ARGV *);
43 const char *(*rcpt_event) (struct MILTER *, const char **, ARGV *);
44 const char *(*data_event) (struct MILTER *, ARGV *);
45 const char *(*message) (struct MILTER *, VSTREAM *, off_t, ARGV *, ARGV *);
46 const char *(*unknown_event) (struct MILTER *, const char *, ARGV *);
47 const char *(*other_event) (struct MILTER *);
48 void (*abort) (struct MILTER *);
49 void (*disc_event) (struct MILTER *);
50 int (*active) (struct MILTER *);
51 int (*send) (struct MILTER *, VSTREAM *);
52 void (*free) (struct MILTER *);
53 } MILTER;
55 #define MILTER_FLAG_NONE (0)
56 #define MILTER_FLAG_WANT_RCPT_REJ (1<<0) /* see S8_RCPT_MAILER_ERROR */
58 extern MILTER *milter8_create(const char *, int, int, int, const char *, const char *, struct MILTERS *);
59 extern MILTER *milter8_receive(VSTREAM *, struct MILTERS *);
62 * As of Sendmail 8.14 each milter can override the default macro list. If a
63 * Milter has its own macro list, a null member means use the global
64 * definition.
66 typedef struct MILTER_MACROS {
67 char *conn_macros; /* macros for connect event */
68 char *helo_macros; /* macros for HELO/EHLO command */
69 char *mail_macros; /* macros for MAIL FROM command */
70 char *rcpt_macros; /* macros for RCPT TO command */
71 char *data_macros; /* macros for DATA command */
72 char *eoh_macros; /* macros for end-of-headers */
73 char *eod_macros; /* macros for END-OF-DATA command */
74 char *unk_macros; /* macros for unknown command */
75 } MILTER_MACROS;
77 extern MILTER_MACROS *milter_macros_create(const char *, const char *,
78 const char *, const char *,
79 const char *, const char *,
80 const char *, const char *);
81 extern MILTER_MACROS *milter_macros_alloc(int);
82 extern void milter_macros_free(MILTER_MACROS *);
83 extern int milter_macros_print(ATTR_PRINT_MASTER_FN, VSTREAM *, int, void *);
84 extern int milter_macros_scan(ATTR_SCAN_MASTER_FN, VSTREAM *, int, void *);
86 #define MILTER_MACROS_ALLOC_ZERO 1 /* null pointer */
87 #define MILTER_MACROS_ALLOC_EMPTY 2 /* mystrdup(""); */
90 * A bunch of Milters.
92 typedef const char *(*MILTER_MAC_LOOKUP_FN) (const char *, void *);
93 typedef const char *(*MILTER_ADD_HEADER_FN) (void *, const char *, const char *, const char *);
94 typedef const char *(*MILTER_EDIT_HEADER_FN) (void *, ssize_t, const char *, const char *, const char *);
95 typedef const char *(*MILTER_DEL_HEADER_FN) (void *, ssize_t, const char *);
96 typedef const char *(*MILTER_EDIT_FROM_FN) (void *, const char *, const char *);
97 typedef const char *(*MILTER_EDIT_RCPT_FN) (void *, const char *);
98 typedef const char *(*MILTER_EDIT_RCPT_PAR_FN) (void *, const char *, const char *);
99 typedef const char *(*MILTER_EDIT_BODY_FN) (void *, int, VSTRING *);
101 typedef struct MILTERS {
102 MILTER *milter_list; /* linked list of Milters */
103 MILTER_MAC_LOOKUP_FN mac_lookup;
104 void *mac_context; /* macro lookup context */
105 struct MILTER_MACROS *macros;
106 void *chg_context; /* context for queue file changes */
107 MILTER_ADD_HEADER_FN add_header;
108 MILTER_EDIT_HEADER_FN upd_header;
109 MILTER_DEL_HEADER_FN del_header;
110 MILTER_EDIT_HEADER_FN ins_header;
111 MILTER_EDIT_FROM_FN chg_from;
112 MILTER_EDIT_RCPT_FN add_rcpt;
113 MILTER_EDIT_RCPT_PAR_FN add_rcpt_par;
114 MILTER_EDIT_RCPT_FN del_rcpt;
115 MILTER_EDIT_BODY_FN repl_body;
116 } MILTERS;
118 #define milter_create(milter_names, conn_timeout, cmd_timeout, msg_timeout, \
119 protocol, def_action, conn_macros, helo_macros, \
120 mail_macros, rcpt_macros, data_macros, eoh_macros, \
121 eod_macros, unk_macros) \
122 milter_new(milter_names, conn_timeout, cmd_timeout, msg_timeout, \
123 protocol, def_action, milter_macros_create(conn_macros, \
124 helo_macros, mail_macros, rcpt_macros, data_macros, \
125 eoh_macros, eod_macros, unk_macros))
127 extern MILTERS *milter_new(const char *, int, int, int, const char *,
128 const char *, MILTER_MACROS *);
129 extern void milter_macro_callback(MILTERS *, MILTER_MAC_LOOKUP_FN, void *);
130 extern void milter_edit_callback(MILTERS *milters, MILTER_ADD_HEADER_FN,
131 MILTER_EDIT_HEADER_FN, MILTER_EDIT_HEADER_FN,
132 MILTER_DEL_HEADER_FN, MILTER_EDIT_FROM_FN,
133 MILTER_EDIT_RCPT_FN, MILTER_EDIT_RCPT_PAR_FN,
134 MILTER_EDIT_RCPT_FN, MILTER_EDIT_BODY_FN,
135 void *);
136 extern const char *milter_conn_event(MILTERS *, const char *, const char *, const char *, unsigned);
137 extern const char *milter_helo_event(MILTERS *, const char *, int);
138 extern const char *milter_mail_event(MILTERS *, const char **);
139 extern const char *milter_rcpt_event(MILTERS *, int, const char **);
140 extern const char *milter_data_event(MILTERS *);
141 extern const char *milter_message(MILTERS *, VSTREAM *, off_t);
142 extern const char *milter_unknown_event(MILTERS *, const char *);
143 extern const char *milter_other_event(MILTERS *);
144 extern void milter_abort(MILTERS *);
145 extern void milter_disc_event(MILTERS *);
146 extern int milter_dummy(MILTERS *, VSTREAM *);
147 extern int milter_send(MILTERS *, VSTREAM *);
148 extern MILTERS *milter_receive(VSTREAM *, int);
149 extern void milter_free(MILTERS *);
152 * Milter body edit commands.
154 #define MILTER_BODY_START 1 /* start message body */
155 #define MILTER_BODY_LINE 2 /* message body line */
156 #define MILTER_BODY_END 3 /* end message body */
159 * Sendmail 8 macro names. We support forms with and without the {}.
161 #define S8_MAC__ "{_}" /* sender resolve */
162 #define S8_MAC_J "{j}" /* myhostname */
163 #define S8_MAC_V "{v}" /* mail_name + mail_version */
165 #define S8_MAC_DAEMON_NAME "{daemon_name}"
166 #define S8_MAC_IF_NAME "{if_name}"
167 #define S8_MAC_IF_ADDR "{if_addr}"
169 #define S8_MAC_CLIENT_ADDR "{client_addr}"
170 #define S8_MAC_CLIENT_CONN "{client_connections}"
171 #define S8_MAC_CLIENT_NAME "{client_name}"
172 #define S8_MAC_CLIENT_PORT "{client_port}"
173 #define S8_MAC_CLIENT_PTR "{client_ptr}"
174 #define S8_MAC_CLIENT_RES "{client_resolve}"
176 #define S8_MAC_TLS_VERSION "{tls_version}"
177 #define S8_MAC_CIPHER "{cipher}"
178 #define S8_MAC_CIPHER_BITS "{cipher_bits}"
179 #define S8_MAC_CERT_SUBJECT "{cert_subject}"
180 #define S8_MAC_CERT_ISSUER "{cert_issuer}"
182 #define S8_MAC_I "{i}" /* queue ID */
183 #define S8_MAC_AUTH_TYPE "{auth_type}" /* SASL method */
184 #define S8_MAC_AUTH_AUTHEN "{auth_authen}" /* SASL username */
185 #define S8_MAC_AUTH_AUTHOR "{auth_author}" /* SASL sender */
187 #define S8_MAC_MAIL_MAILER "{mail_mailer}" /* sender transport */
188 #define S8_MAC_MAIL_HOST "{mail_host}" /* sender nexthop */
189 #define S8_MAC_MAIL_ADDR "{mail_addr}" /* sender address */
191 #define S8_MAC_RCPT_MAILER "{rcpt_mailer}" /* recip transport */
192 #define S8_MAC_RCPT_HOST "{rcpt_host}" /* recip nexthop */
193 #define S8_MAC_RCPT_ADDR "{rcpt_addr}" /* recip address */
195 #define S8_RCPT_MAILER_ERROR "error" /* see MILTER_FLAG_WANT_RCPT_REJ */
197 /* LICENSE
198 /* .ad
199 /* .fi
200 /* The Secure Mailer license must be distributed with this software.
201 /* AUTHOR(S)
202 /* Wietse Venema
203 /* IBM T.J. Watson Research
204 /* P.O. Box 704
205 /* Yorktown Heights, NY 10598, USA
206 /*--*/
208 #endif