aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--smtpd/envelope.c45
-rw-r--r--smtpd/smtpd.h23
3 files changed, 69 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 60f4d388..2d8b10d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ missing
parse.c
stamp-h1
ylwrap
+tags
diff --git a/smtpd/envelope.c b/smtpd/envelope.c
index da8cdbfd..0bc58d37 100644
--- a/smtpd/envelope.c
+++ b/smtpd/envelope.c
@@ -44,6 +44,7 @@
#include "smtpd.h"
#include "log.h"
+static int ascii_load_uint8(uint8_t *, char *);
static int ascii_load_uint16(uint16_t *, char *);
static int ascii_load_uint32(uint32_t *, char *);
static int ascii_load_time(time_t *, char *);
@@ -55,7 +56,9 @@ static int ascii_load_mailaddr(struct mailaddr *, char *);
static int ascii_load_flags(enum envelope_flags *, char *);
static int ascii_load_mta_relay_url(struct relayhost *, char *);
static int ascii_load_bounce_type(enum bounce_type *, char *);
+static int ascii_load_dsn_ret(enum dsn_ret *, char *);
+static int ascii_dump_uint8(uint8_t, char *, size_t);
static int ascii_dump_uint16(uint16_t, char *, size_t);
static int ascii_dump_uint32(uint32_t, char *, size_t);
static int ascii_dump_time(time_t, char *, size_t);
@@ -118,6 +121,10 @@ envelope_load_buffer(struct envelope *ep, const char *ibuf, size_t buflen)
EVP_BOUNCE_TYPE,
EVP_BOUNCE_DELAY,
EVP_BOUNCE_EXPIRE,
+ EVP_DSN_ENVID,
+ EVP_DSN_NOTIFY,
+ EVP_DSN_ORCPT,
+ EVP_DSN_RET
};
char *field, *nextline;
char lbuf[sizeof(*ep)], *buf;
@@ -416,6 +423,15 @@ envelope_ascii_load(enum envelope_field field, struct envelope *ep, char *buf)
return ascii_load_time(&ep->agent.bounce.delay, buf);
case EVP_BOUNCE_EXPIRE:
return ascii_load_time(&ep->agent.bounce.expire, buf);
+ case EVP_DSN_NOTIFY:
+ return ascii_load_uint8(&ep->dsn.notify_flags, buf);
+ case EVP_DSN_ORCPT:
+ return ascii_load_mailaddr(&ep->dsn.orcpt, buf);
+ case EVP_DSN_RET:
+ return ascii_load_dsn_ret(&ep->dsn.ret, buf);
+ case EVP_DSN_ENVID:
+ return ascii_load_string(ep->dsn.envid, buf,
+ sizeof ep->dsn.envid);
}
return 0;
}
@@ -498,6 +514,17 @@ envelope_ascii_dump(enum envelope_field field, const struct envelope *ep,
}
static int
+ascii_load_uint8(uint8_t *dest, char *buf)
+{
+ const char *errstr;
+
+ *dest = strtonum(buf, 0, 0xff, &errstr);
+ if (errstr)
+ return 0;
+ return 1;
+}
+
+static int
ascii_load_uint16(uint16_t *dest, char *buf)
{
const char *errstr;
@@ -646,6 +673,24 @@ ascii_load_bounce_type(enum bounce_type *dest, char *buf)
}
static int
+ascii_load_dsn_ret(enum dsn_ret *ret, char *buf)
+{
+ if (strcasecmp(buf, "HDRS") == 0)
+ *ret = DSN_RETHDRS;
+ else if (strcasecmp(buf, "FULL") == 0)
+ *ret = DSN_RETFULL;
+ else
+ return 0;
+ return 1;
+}
+
+static int
+ascii_dump_uint8(uint8_t src, char *dest, size_t len)
+{
+ return bsnprintf(dest, len, "%d", src);
+}
+
+static int
ascii_dump_uint16(uint16_t src, char *dest, size_t len)
{
return bsnprintf(dest, len, "%d", src);
diff --git a/smtpd/smtpd.h b/smtpd/smtpd.h
index b9d7f344..11872c5b 100644
--- a/smtpd/smtpd.h
+++ b/smtpd/smtpd.h
@@ -445,6 +445,23 @@ enum envelope_flags {
EF_INFLIGHT = 0x20,
};
+#define DSN_SUCCESS 0x01
+#define DSN_FAILURE 0x02
+#define DSN_DELAY 0x04
+#define DSN_NEVER 0x08
+
+enum dsn_ret {
+ DSN_RETFULL = 1,
+ DSN_RETHDRS
+};
+
+struct dsn {
+ struct mailaddr orcpt;
+ char envid[101];
+ uint8_t notify_flags;
+ enum dsn_ret ret;
+};
+
#define SMTPD_ENVELOPE_VERSION 1
struct envelope {
TAILQ_ENTRY(envelope) entry;
@@ -477,6 +494,8 @@ struct envelope {
time_t lasttry;
time_t nexttry;
time_t lastbounce;
+
+ struct dsn dsn;
};
enum envelope_field {
@@ -509,6 +528,10 @@ enum envelope_field {
EVP_BOUNCE_TYPE,
EVP_BOUNCE_DELAY,
EVP_BOUNCE_EXPIRE,
+ EVP_DSN_ENVID,
+ EVP_DSN_NOTIFY,
+ EVP_DSN_ORCPT,
+ EVP_DSN_RET,
};
struct listener {