1 /* $NetBSD: mail_proto.h,v 1.4 2022/10/08 16:12:45 christos Exp $ */ 2 3 #ifndef _MAIL_PROTO_H_INCLUDED_ 4 #define _MAIL_PROTO_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* mail_proto 3h 9 /* SUMMARY 10 /* mail internal and external protocol support 11 /* SYNOPSIS 12 /* #include <mail_proto.h> 13 /* DESCRIPTION 14 /* .nf 15 16 /* 17 * System library. 18 */ 19 #include <stdarg.h> 20 #include <string.h> 21 22 /* 23 * Utility library. 24 */ 25 #include <vstream.h> 26 #include <iostuff.h> 27 #include <attr.h> 28 29 /* 30 * External protocols. 31 */ 32 #define MAIL_PROTO_SMTP "SMTP" 33 #define MAIL_PROTO_ESMTP "ESMTP" 34 #define MAIL_PROTO_QMQP "QMQP" 35 36 /* 37 * Names of services: these are the names of the UNIX-domain socket or 38 * FIFO that a service listens on. 39 */ 40 #define MAIL_SERVICE_BOUNCE "bounce" 41 #define MAIL_SERVICE_CLEANUP "cleanup" 42 #define MAIL_SERVICE_DEFER "defer" 43 #define MAIL_SERVICE_FORWARD "forward" 44 #define MAIL_SERVICE_LOCAL "local" 45 #define MAIL_SERVICE_PICKUP "pickup" 46 #define MAIL_SERVICE_QUEUE "qmgr" 47 #define MAIL_SERVICE_TLSMGR "tlsmgr" 48 #define MAIL_SERVICE_RESOLVE "resolve" 49 #define MAIL_SERVICE_REWRITE "rewrite" 50 #define MAIL_SERVICE_VIRTUAL "virtual" 51 #define MAIL_SERVICE_SMTP "smtp" 52 #define MAIL_SERVICE_SMTPD "smtpd" 53 #define MAIL_SERVICE_SHOWQ "showq" 54 #define MAIL_SERVICE_ERROR "error" 55 #define MAIL_SERVICE_RETRY "retry" 56 #define MAIL_SERVICE_FLUSH "flush" 57 #define MAIL_SERVICE_VERIFY "verify" 58 #define MAIL_SERVICE_TRACE "trace" 59 #define MAIL_SERVICE_RELAY "relay" 60 #define MAIL_SERVICE_PROXYMAP "proxymap" 61 #define MAIL_SERVICE_PROXYWRITE "proxywrite" 62 #define MAIL_SERVICE_SCACHE "scache" 63 #define MAIL_SERVICE_DNSBLOG "dnsblog" 64 #define MAIL_SERVICE_TLSPROXY "tlsproxy" 65 #define MAIL_SERVICE_POSTLOG "postlog" 66 67 /* 68 * Mail source classes. Used to specify policy decisions for content 69 * inspection and SMTPUTF8 detection. 70 */ 71 #define MAIL_SRC_NAME_SENDMAIL "sendmail" /* sendmail(1) */ 72 #define MAIL_SRC_NAME_SMTPD "smtpd" /* smtpd(8) */ 73 #define MAIL_SRC_NAME_QMQPD "qmqpd" /* qmqpd(8) */ 74 #define MAIL_SRC_NAME_FORWARD "forward" /* local(8) forward/alias */ 75 #define MAIL_SRC_NAME_BOUNCE "bounce"/* bounce(8) */ 76 #define MAIL_SRC_NAME_NOTIFY "notify"/* protocol etc. errors */ 77 #define MAIL_SRC_NAME_VERIFY "verify"/* protocol etc. errors */ 78 #define MAIL_SRC_NAME_ALL "all" /* all sources */ 79 80 #define MAIL_SRC_MASK_SENDMAIL (1<<0) /* sendmail(1) */ 81 #define MAIL_SRC_MASK_SMTPD (1<<1) /* smtpd(8) */ 82 #define MAIL_SRC_MASK_QMQPD (1<<2) /* qmqpd(8) */ 83 #define MAIL_SRC_MASK_FORWARD (1<<3) /* local(8) forward/alias */ 84 #define MAIL_SRC_MASK_BOUNCE (1<<4) /* bounce(8) */ 85 #define MAIL_SRC_MASK_NOTIFY (1<<5) /* protocol etc. errors */ 86 #define MAIL_SRC_MASK_VERIFY (1<<6) /* protocol etc. errors */ 87 88 #define MAIL_SRC_MASK_ALL \ 89 ( MAIL_SRC_MASK_SENDMAIL | MAIL_SRC_MASK_SMTPD \ 90 | MAIL_SRC_MASK_QMQPD | MAIL_SRC_MASK_FORWARD \ 91 | MAIL_SRC_MASK_BOUNCE | MAIL_SRC_MASK_NOTIFY \ 92 | MAIL_SRC_MASK_VERIFY) 93 94 /* 95 * Well-known socket or FIFO directories. The main difference is in file 96 * access permissions. 97 */ 98 #define MAIL_CLASS_PUBLIC "public" 99 #define MAIL_CLASS_PRIVATE "private" 100 101 /* 102 * Generic triggers. 103 */ 104 #define TRIGGER_REQ_WAKEUP 'W' /* wakeup */ 105 106 /* 107 * Queue manager requests. 108 */ 109 #define QMGR_REQ_SCAN_DEFERRED 'D' /* scan deferred queue */ 110 #define QMGR_REQ_SCAN_INCOMING 'I' /* scan incoming queue */ 111 #define QMGR_REQ_FLUSH_DEAD 'F' /* flush dead xport/site */ 112 #define QMGR_REQ_SCAN_ALL 'A' /* ignore time stamps */ 113 114 /* 115 * Functional interface. 116 */ 117 extern VSTREAM *mail_connect(const char *, const char *, int); 118 extern VSTREAM *mail_connect_wait(const char *, const char *); 119 extern int mail_command_client(const char *, const char *, const char *,...); 120 extern int mail_command_server(VSTREAM *,...); 121 extern int mail_trigger(const char *, const char *, const char *, ssize_t); 122 extern char *mail_pathname(const char *, const char *); 123 124 /* 125 * Each Postfix internal service identifies the protocol that it intends to 126 * use. On the receiver end, this information does not contribute to the 127 * reported number of received attributes (it is a constant). 128 */ 129 #define MAIL_ATTR_PROTO "protocol" 130 131 #define MAIL_ATTR_PROTO_ANVIL "anvil_protocol" 132 #define MAIL_ATTR_PROTO_BOUNCE "delivery_status_protocol" 133 #define MAIL_ATTR_PROTO_CLEANUP "cleanup_protocol" 134 #define MAIL_ATTR_PROTO_DELIVER "delivery_request_protocol" 135 #define MAIL_ATTR_PROTO_FLUSH "queue_flush_protocol" 136 #define MAIL_ATTR_PROTO_POSTDROP "postdrop_protocol" 137 #define MAIL_ATTR_PROTO_PROXYMAP "proxymap_protocol" 138 #define MAIL_ATTR_PROTO_SCACHE "connection_cache_protocol" 139 #define MAIL_ATTR_PROTO_SHOWQ "mail_queue_list_protocol" 140 #define MAIL_ATTR_PROTO_TLSMGR "tlsmgr_protocol" 141 #define MAIL_ATTR_PROTO_TLSPROXY "tlsproxy_protocol" 142 #define MAIL_ATTR_PROTO_TRIVIAL "trivial_rewrite_protocol" 143 #define MAIL_ATTR_PROTO_VERIFY "address_verification_prrotocol" 144 145 /* 146 * Attribute names. 147 */ 148 #define MAIL_ATTR_REQ "request" 149 #define MAIL_ATTR_NREQ "nrequest" 150 #define MAIL_ATTR_STATUS "status" 151 152 #define MAIL_ATTR_FLAGS "flags" 153 #define MAIL_ATTR_QUEUE "queue_name" 154 #define MAIL_ATTR_QUEUEID "queue_id" 155 #define MAIL_ATTR_SENDER "sender" 156 #define MAIL_ATTR_RCPT_COUNT "recipient_count" 157 #define MAIL_ATTR_ORCPT "original_recipient" 158 #define MAIL_ATTR_RECIP "recipient" 159 #define MAIL_ATTR_WHY "reason" 160 #define MAIL_ATTR_VERPDL "verp_delimiters" 161 #define MAIL_ATTR_SITE "site" 162 #define MAIL_ATTR_OFFSET "offset" 163 #define MAIL_ATTR_SIZE "size" 164 #define MAIL_ATTR_ERRTO "errors-to" 165 #define MAIL_ATTR_RRCPT "return-receipt" 166 #define MAIL_ATTR_TIME "time" 167 #define MAIL_ATTR_LOCALTIME "localtime" 168 #define MAIL_ATTR_CREATE_TIME "create_time" 169 #define MAIL_ATTR_RULE "rule" 170 #define MAIL_ATTR_ADDR "address" 171 #define MAIL_ATTR_TRANSPORT "transport" 172 #define MAIL_ATTR_NEXTHOP "nexthop" 173 #define MAIL_ATTR_TRACE_FLAGS "trace_flags" 174 #define MAIL_ATTR_ADDR_STATUS "recipient_status" 175 #define MAIL_ATTR_ACTION "action" 176 #define MAIL_ATTR_TABLE "table" 177 #define MAIL_ATTR_KEY "key" 178 #define MAIL_ATTR_VALUE "value" 179 #define MAIL_ATTR_INSTANCE "instance" 180 #define MAIL_ATTR_SASL_METHOD "sasl_method" 181 #define MAIL_ATTR_SASL_USERNAME "sasl_username" 182 #define MAIL_ATTR_SASL_SENDER "sasl_sender" 183 #define MAIL_ATTR_ETRN_DOMAIN "etrn_domain" 184 #define MAIL_ATTR_DUMMY "dummy" 185 #define MAIL_ATTR_STRESS "stress" 186 #define MAIL_ATTR_LOG_IDENT "log_ident" 187 #define MAIL_ATTR_RWR_CONTEXT "rewrite_context" 188 #define MAIL_ATTR_POL_CONTEXT "policy_context" 189 #define MAIL_ATTR_FORCED_EXPIRE "forced_expire" 190 191 #define MAIL_ATTR_RWR_LOCAL "local" 192 #define MAIL_ATTR_RWR_REMOTE "remote" 193 194 #define MAIL_ATTR_TTL "ttl" 195 #define MAIL_ATTR_LABEL "label" 196 #define MAIL_ATTR_PROP "property" 197 #define MAIL_ATTR_FUNC "function" 198 #define MAIL_ATTR_CCERT_SUBJECT "ccert_subject" 199 #define MAIL_ATTR_CCERT_ISSUER "ccert_issuer" 200 #define MAIL_ATTR_CCERT_CERT_FPRINT "ccert_fingerprint" 201 #define MAIL_ATTR_CCERT_PKEY_FPRINT "ccert_pubkey_fingerprint" 202 #define MAIL_ATTR_CRYPTO_PROTOCOL "encryption_protocol" 203 #define MAIL_ATTR_CRYPTO_CIPHER "encryption_cipher" 204 #define MAIL_ATTR_CRYPTO_KEYSIZE "encryption_keysize" 205 206 /* 207 * Suffixes for sender_name, sender_domain etc. 208 */ 209 #define MAIL_ATTR_S_NAME "_name" 210 #define MAIL_ATTR_S_DOMAIN "_domain" 211 212 /* 213 * Special names for RBL results. 214 */ 215 #define MAIL_ATTR_RBL_WHAT "rbl_what" 216 #define MAIL_ATTR_RBL_DOMAIN "rbl_domain" 217 #define MAIL_ATTR_RBL_REASON "rbl_reason" 218 #define MAIL_ATTR_RBL_TXT "rbl_txt" /* LaMont compatibility */ 219 #define MAIL_ATTR_RBL_CLASS "rbl_class" 220 #define MAIL_ATTR_RBL_CODE "rbl_code" 221 #define MAIL_ATTR_RBL_ADDR "rbl_addr" 222 223 /* 224 * The following attribute names are stored in queue files. Changing this 225 * means lots of work to maintain backwards compatibility with queued mail. 226 */ 227 #define MAIL_ATTR_ENCODING "encoding" /* internal encoding */ 228 #define MAIL_ATTR_ENC_8BIT "8bit" /* 8BITMIME equivalent */ 229 #define MAIL_ATTR_ENC_7BIT "7bit" /* 7BIT equivalent */ 230 #define MAIL_ATTR_ENC_NONE "" /* encoding unknown */ 231 232 #define MAIL_ATTR_LOG_CLIENT_NAME "log_client_name" /* client hostname */ 233 #define MAIL_ATTR_LOG_CLIENT_ADDR "log_client_address" /* client address */ 234 #define MAIL_ATTR_LOG_CLIENT_PORT "log_client_port" /* client port */ 235 #define MAIL_ATTR_LOG_HELO_NAME "log_helo_name" /* SMTP helo name */ 236 #define MAIL_ATTR_LOG_PROTO_NAME "log_protocol_name" /* SMTP/ESMTP/QMQP */ 237 #define MAIL_ATTR_LOG_ORIGIN "log_message_origin" /* name[addr]:port */ 238 239 #define MAIL_ATTR_ACT_CLIENT "client"/* client name addr */ 240 #define MAIL_ATTR_ACT_CLIENT_NAME "client_name" /* client name */ 241 #define MAIL_ATTR_ACT_CLIENT_ADDR "client_address" /* client address */ 242 #define MAIL_ATTR_ACT_CLIENT_PORT "client_port" /* client TCP port */ 243 #define MAIL_ATTR_ACT_CLIENT_AF "client_address_type" /* AF_INET etc. */ 244 #define MAIL_ATTR_ACT_HELO_NAME "helo_name" /* SMTP helo name */ 245 #define MAIL_ATTR_ACT_PROTO_NAME "protocol_name" /* SMTP/ESMTP/QMQP */ 246 #define MAIL_ATTR_ACT_REVERSE_CLIENT_NAME "reverse_client_name" 247 #define MAIL_ATTR_ACT_FORWARD_CLIENT_NAME "forward_client_name" 248 249 #define MAIL_ATTR_ACT_SERVER_ADDR "server_address" /* server address */ 250 #define MAIL_ATTR_ACT_SERVER_PORT "server_port" /* server TCP port */ 251 252 #define MAIL_ATTR_PROTO_STATE "protocol_state" /* MAIL/RCPT/... */ 253 #define MAIL_ATTR_ORG_NONE "unknown" /* origin unknown */ 254 #define MAIL_ATTR_ORG_LOCAL "local" /* local submission */ 255 256 /* 257 * XCLIENT/XFORWARD in SMTP. 258 */ 259 #define XCLIENT_CMD "XCLIENT" /* XCLIENT command */ 260 #define XCLIENT_NAME "NAME" /* client name */ 261 #define XCLIENT_REVERSE_NAME "REVERSE_NAME" /* reverse client name */ 262 #ifdef FORWARD_CLIENT_NAME 263 #define XCLIENT_FORWARD_NAME "FORWARD_NAME" /* forward client name */ 264 #endif 265 #define XCLIENT_ADDR "ADDR" /* client address */ 266 #define XCLIENT_PORT "PORT" /* client port */ 267 #define XCLIENT_PROTO "PROTO" /* client protocol */ 268 #define XCLIENT_HELO "HELO" /* client helo */ 269 #define XCLIENT_LOGIN "LOGIN" /* SASL login name */ 270 #define XCLIENT_DESTADDR "DESTADDR" /* server address */ 271 #define XCLIENT_DESTPORT "DESTPORT" /* server port */ 272 273 #define XCLIENT_UNAVAILABLE "[UNAVAILABLE]" /* permanently unavailable */ 274 #define XCLIENT_TEMPORARY "[TEMPUNAVAIL]" /* temporarily unavailable */ 275 276 #define XFORWARD_CMD "XFORWARD" /* XFORWARD command */ 277 #define XFORWARD_NAME "NAME" /* client name */ 278 #define XFORWARD_ADDR "ADDR" /* client address */ 279 #define XFORWARD_PORT "PORT" /* client port */ 280 #define XFORWARD_PROTO "PROTO" /* client protocol */ 281 #define XFORWARD_HELO "HELO" /* client helo */ 282 #define XFORWARD_IDENT "IDENT" /* message identifier */ 283 #define XFORWARD_DOMAIN "SOURCE"/* origin type */ 284 #define XFORWARD_DOM_LOCAL "LOCAL" /* local origin */ 285 #define XFORWARD_DOM_REMOTE "REMOTE"/* remote origin */ 286 287 #define XFORWARD_UNAVAILABLE "[UNAVAILABLE]" /* attribute unavailable */ 288 289 /* 290 * DSN support. 291 */ 292 #define MAIL_ATTR_DSN_STATUS "status"/* XXX Postfix <2.3 compat */ 293 #define MAIL_ATTR_DSN_DTYPE "diag_type" /* dsn diagnostic code */ 294 #define MAIL_ATTR_DSN_DTEXT "diag_text" /* dsn diagnostic code */ 295 #define MAIL_ATTR_DSN_MTYPE "mta_type" /* dsn remote MTA */ 296 #define MAIL_ATTR_DSN_MNAME "mta_mname" /* dsn remote MTA */ 297 #define MAIL_ATTR_DSN_ACTION "action"/* XXX Postfix <2.3 compat */ 298 #define MAIL_ATTR_DSN_ENVID "envelope_id" /* dsn envelope id */ 299 #define MAIL_ATTR_DSN_RET "ret_flags" /* dsn full/headers */ 300 #define MAIL_ATTR_DSN_NOTIFY "notify_flags" /* dsn notify flags */ 301 #define MAIL_ATTR_DSN_ORCPT "dsn_orig_rcpt" /* dsn original recipient */ 302 #define MAIL_ATTR_SMTPUTF8 "smtputf8" /* RFC6531 support */ 303 304 /* 305 * SMTP reply footer support. 306 */ 307 #define MAIL_ATTR_SERVER_NAME "server_name" 308 309 /* LICENSE 310 /* .ad 311 /* .fi 312 /* The Secure Mailer license must be distributed with this software. 313 /* AUTHOR(S) 314 /* Wietse Venema 315 /* IBM T.J. Watson Research 316 /* P.O. Box 704 317 /* Yorktown Heights, NY 10598, USA 318 /* 319 /* Wietse Venema 320 /* Google, Inc. 321 /* 111 8th Avenue 322 /* New York, NY 10011, USA 323 /*--*/ 324 325 #endif 326