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