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