1 /*	$NetBSD: smtpd_proxy.h,v 1.1.1.2 2010/06/17 18:07:07 tron Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	smtpd_proxy 3h
6 /* SUMMARY
7 /*	SMTP server pass-through proxy client
8 /* SYNOPSIS
9 /*	#include <smtpd.h>
10 /*	#include <smtpd_proxy.h>
11 /* DESCRIPTION
12 /* .nf
13 
14  /*
15   * Utility library.
16   */
17 #include <vstream.h>
18 #include <vstring.h>
19 
20  /*
21   * Application-specific.
22   */
23 typedef int PRINTFPTRLIKE(3, 4) (*SMTPD_PROXY_CMD_FN) (SMTPD_STATE *, int, const char *,...);
24 typedef int PRINTFPTRLIKE(3, 4) (*SMTPD_PROXY_REC_FPRINTF_FN) (VSTREAM *, int, const char *,...);
25 typedef int (*SMTPD_PROXY_REC_PUT_FN) (VSTREAM *, int, const char *, ssize_t);
26 
27 typedef struct SMTPD_PROXY {
28     /* Public. */
29     VSTREAM *stream;
30     VSTRING *buffer;			/* proxy query/reply buffer */
31     SMTPD_PROXY_CMD_FN cmd;
32     SMTPD_PROXY_REC_FPRINTF_FN rec_fprintf;
33     SMTPD_PROXY_REC_PUT_FN rec_put;
34     /* Private. */
35     int     flags;
36     VSTREAM *service_stream;
37     const char *service_name;
38     int     timeout;
39     const char *ehlo_name;
40     const char *mail_from;
41 } SMTPD_PROXY;
42 
43 #define SMTPD_PROXY_FLAG_SPEED_ADJUST	(1<<0)
44 
45 #define SMTPD_PROXY_NAME_SPEED_ADJUST	"speed_adjust"
46 
47 #define SMTPD_PROX_WANT_BAD	0xff	/* Do not use */
48 #define SMTPD_PROX_WANT_NONE	'\0'	/* Do not receive reply */
49 #define SMTPD_PROX_WANT_ANY	'0'	/* Expect any reply */
50 #define SMTPD_PROX_WANT_OK	'2'	/* Expect 2XX reply */
51 #define SMTPD_PROX_WANT_MORE	'3'	/* Expect 3XX reply */
52 
53 extern int smtpd_proxy_create(SMTPD_STATE *, int, const char *, int, const char *, const char *);
54 extern void smtpd_proxy_close(SMTPD_STATE *);
55 extern void smtpd_proxy_free(SMTPD_STATE *);
56 extern int smtpd_proxy_parse_opts(const char *, const char *);
57 
58 /* LICENSE
59 /* .ad
60 /* .fi
61 /*	The Secure Mailer license must be distributed with this software.
62 /* AUTHOR(S)
63 /*	Wietse Venema
64 /*	IBM T.J. Watson Research
65 /*	P.O. Box 704
66 /*	Yorktown Heights, NY 10598, USA
67 /*--*/
68