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