Home | History | Annotate | Line # | Download | only in smtpd
      1 /*	$NetBSD: smtpd_proxy.h,v 1.2 2026/05/09 18:49:21 christos 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 *request;			/* proxy request buffer */
     31     VSTRING *reply;			/* proxy reply buffer */
     32     SMTPD_PROXY_CMD_FN cmd;
     33     SMTPD_PROXY_REC_FPRINTF_FN rec_fprintf;
     34     SMTPD_PROXY_REC_PUT_FN rec_put;
     35     /* Private. */
     36     int     flags;
     37     VSTREAM *service_stream;
     38     const char *service_name;
     39     int     timeout;
     40     const char *ehlo_name;
     41     const char *mail_from;
     42     int     reqtls_esmtp_hdr_seen;
     43 } SMTPD_PROXY;
     44 
     45 #define SMTPD_PROXY_FLAG_SPEED_ADJUST	(1<<0)
     46 #define SMTPD_PROXY_FLAG_REQTLS_HDR	(1<<1)
     47 
     48 #define SMTPD_PROXY_NAME_SPEED_ADJUST	"speed_adjust"
     49 
     50 #define SMTPD_PROX_WANT_BAD	0xff	/* Do not use */
     51 #define SMTPD_PROX_WANT_NONE	'\0'	/* Do not receive reply */
     52 #define SMTPD_PROX_WANT_ANY	'0'	/* Expect any reply */
     53 #define SMTPD_PROX_WANT_OK	'2'	/* Expect 2XX reply */
     54 #define SMTPD_PROX_WANT_MORE	'3'	/* Expect 3XX reply */
     55 
     56 extern int smtpd_proxy_create(SMTPD_STATE *, int, const char *, int, const char *, const char *);
     57 extern void smtpd_proxy_close(SMTPD_STATE *);
     58 extern void smtpd_proxy_free(SMTPD_STATE *);
     59 extern int smtpd_proxy_parse_opts(const char *, const char *);
     60 
     61 /* LICENSE
     62 /* .ad
     63 /* .fi
     64 /*	The Secure Mailer license must be distributed with this software.
     65 /* AUTHOR(S)
     66 /*	Wietse Venema
     67 /*	IBM T.J. Watson Research
     68 /*	P.O. Box 704
     69 /*	Yorktown Heights, NY 10598, USA
     70 /*
     71 /*	Wietse Venema
     72 /*	porcupine.org
     73 /*--*/
     74