xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/deliver_request.h (revision 33881f779a77dce6440bdc44610d94de75bebefe)
1 /*	$NetBSD: deliver_request.h,v 1.3 2020/03/18 19:05:16 christos Exp $	*/
2 
3 #ifndef _DELIVER_REQUEST_H_INCLUDED_
4 #define _DELIVER_REQUEST_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	deliver_request 3h
9 /* SUMMARY
10 /*	mail delivery request protocol, server side
11 /* SYNOPSIS
12 /*	#include <deliver_request.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * System library.
18   */
19 #include <sys_defs.h>
20 #include <stdarg.h>
21 
22  /*
23   * Utility library.
24   */
25 #include <vstring.h>
26 #include <vstream.h>
27 
28  /*
29   * Global library.
30   */
31 #include <recipient_list.h>
32 #include <dsn.h>
33 #include <msg_stats.h>
34 
35  /*
36   * Structure of a server mail delivery request.
37   */
38 typedef struct DELIVER_REQUEST {
39     VSTREAM *fp;			/* stream, shared lock */
40     int     flags;			/* see below */
41     char   *queue_name;			/* message queue name */
42     char   *queue_id;			/* message queue id */
43     long    data_offset;		/* offset to message */
44     long    data_size;			/* message size */
45     char   *nexthop;			/* next hop name */
46     char   *encoding;			/* content encoding */
47     int     smtputf8;			/* SMTPUTF8 level */
48     char   *sender;			/* envelope sender */
49     MSG_STATS msg_stats;		/* time profile */
50     RECIPIENT_LIST rcpt_list;		/* envelope recipients */
51     DSN    *hop_status;			/* DSN status */
52     char   *client_name;		/* client hostname */
53     char   *client_addr;		/* client address */
54     char   *client_port;		/* client port */
55     char   *client_proto;		/* client protocol */
56     char   *client_helo;		/* helo parameter */
57     char   *sasl_method;		/* SASL method */
58     char   *sasl_username;		/* SASL user name */
59     char   *sasl_sender;		/* SASL sender */
60     char   *log_ident;			/* original queue ID */
61     char   *rewrite_context;		/* address rewrite context */
62     char   *dsn_envid;			/* DSN envelope ID */
63     int     dsn_ret;			/* DSN full/header notification */
64 } DELIVER_REQUEST;
65 
66  /*
67   * Since we can't send null pointers, null strings represent unavailable
68   * attributes instead. They're less likely to explode in our face, too.
69   */
70 #define DEL_REQ_ATTR_AVAIL(a)	(*(a))
71 
72  /*
73   * How to deliver, really?
74   */
75 #define DEL_REQ_FLAG_DEFLT	(DEL_REQ_FLAG_SUCCESS | DEL_REQ_FLAG_BOUNCE)
76 #define DEL_REQ_FLAG_SUCCESS	(1<<0)	/* delete successful recipients */
77 #define DEL_REQ_FLAG_BOUNCE	(1<<1)	/* unimplemented */
78 
79 #define DEL_REQ_FLAG_MTA_VRFY	(1<<8)	/* MTA-requested address probe */
80 #define DEL_REQ_FLAG_USR_VRFY	(1<<9)	/* user-requested address probe */
81 #define DEL_REQ_FLAG_RECORD	(1<<10)	/* record and deliver */
82 #define DEL_REQ_FLAG_CONN_LOAD	(1<<11)	/* Consult opportunistic cache */
83 #define DEL_REQ_FLAG_CONN_STORE	(1<<12)	/* Update opportunistic cache */
84 #define DEL_REQ_FLAG_REC_DLY_SENT	(1<<13)	/* Record delayed delivery */
85 
86  /*
87   * Cache Load and Store as value or mask. Use explicit _MASK for multi-bit
88   * values.
89   */
90 #define DEL_REQ_FLAG_CONN_MASK \
91 	(DEL_REQ_FLAG_CONN_LOAD | DEL_REQ_FLAG_CONN_STORE)
92 
93  /*
94   * For compatibility, the old confusing names.
95   */
96 #define DEL_REQ_FLAG_VERIFY	DEL_REQ_FLAG_MTA_VRFY
97 #define DEL_REQ_FLAG_EXPAND	DEL_REQ_FLAG_USR_VRFY
98 
99  /*
100   * Mail that uses the trace(8) service, and maybe more.
101   */
102 #define DEL_REQ_TRACE_FLAGS_MASK \
103 	(DEL_REQ_FLAG_MTA_VRFY | DEL_REQ_FLAG_USR_VRFY | DEL_REQ_FLAG_RECORD \
104 	| DEL_REQ_FLAG_REC_DLY_SENT)
105 #define DEL_REQ_TRACE_FLAGS(f)	((f) & DEL_REQ_TRACE_FLAGS_MASK)
106 
107  /*
108   * Mail that is not delivered (i.e. uses the trace(8) service only).
109   */
110 #define DEL_REQ_TRACE_ONLY_MASK \
111 	(DEL_REQ_FLAG_MTA_VRFY | DEL_REQ_FLAG_USR_VRFY)
112 #define DEL_REQ_TRACE_ONLY(f)	((f) & DEL_REQ_TRACE_ONLY_MASK)
113 
114  /*
115   * Per-recipient delivery status. Not to be confused with per-delivery
116   * request status.
117   */
118 #define DEL_RCPT_STAT_OK	0
119 #define DEL_RCPT_STAT_DEFER	1
120 #define DEL_RCPT_STAT_BOUNCE	2
121 #define DEL_RCPT_STAT_TODO	3
122 
123  /*
124   * Delivery request status. Note that there are only FINAL and DEFER. This
125   * is because delivery status information can be lost when a delivery agent
126   * or queue manager process terminates prematurely. The only distinctions we
127   * can rely on are "final delivery completed" (positive confirmation that
128   * all recipients are marked as done) and "everything else". In the absence
129   * of a definitive statement the queue manager will always have to be
130   * prepared for all possibilities.
131   */
132 #define DEL_STAT_FINAL	0		/* delivered or bounced */
133 #define DEL_STAT_DEFER	(-1)		/* not delivered or bounced */
134 
135 typedef struct VSTREAM _deliver_vstream_;
136 extern DELIVER_REQUEST *deliver_request_read(_deliver_vstream_ *);
137 extern int deliver_request_done(_deliver_vstream_ *, DELIVER_REQUEST *, int);
138 
139 extern int PRINTFLIKE(4, 5) reject_deliver_request(const char *,
140 		         DELIVER_REQUEST *, const char *, const char *,...);
141 
142 /* LICENSE
143 /* .ad
144 /* .fi
145 /*	The Secure Mailer license must be distributed with this software.
146 /* AUTHOR(S)
147 /*	Wietse Venema
148 /*	IBM T.J. Watson Research
149 /*	P.O. Box 704
150 /*	Yorktown Heights, NY 10598, USA
151 /*
152 /*	Wietse Venema
153 /*	Google, Inc.
154 /*	111 8th Avenue
155 /*	New York, NY 10011, USA
156 /*--*/
157 
158 #endif
159