From: Stephan Bosch Date: Fri, 2 Nov 2018 22:48:48 +0000 (+0100) Subject: lmtp: Implement basic client vfuncs. X-Git-Tag: 2.3.9~996 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df7ff5ca1a2fb4ef987563f3f08c1ca9c8827bd5;p=thirdparty%2Fdovecot%2Fcore.git lmtp: Implement basic client vfuncs. Currently, only client_destroy can be overriden. --- diff --git a/src/lmtp/client.c b/src/lmtp/client.c index f3820d8de5..777929754e 100644 --- a/src/lmtp/client.c +++ b/src/lmtp/client.c @@ -26,13 +26,14 @@ #define CLIENT_IDLE_TIMEOUT_MSECS (1000*60*5) +static const struct smtp_server_callbacks lmtp_callbacks; +static const struct lmtp_client_vfuncs lmtp_client_vfuncs; + static struct client *clients = NULL; static unsigned int clients_count = 0; static bool verbose_proctitle = FALSE; -static const struct smtp_server_callbacks lmtp_callbacks; - static const char *client_remote_id(struct client *client) { const char *addr; @@ -125,6 +126,7 @@ struct client *client_create(int fd_in, int fd_out, pool = pool_alloconly_create("lmtp client", 2048); client = p_new(pool, struct client, 1); client->pool = pool; + client->v = lmtp_client_vfuncs; client->remote_ip = conn->remote_ip; client->remote_port = conn->remote_port; client->local_ip = conn->local_ip; @@ -189,6 +191,13 @@ void client_state_reset(struct client *client) void client_destroy(struct client *client, const char *enh_code, const char *reason) +{ + client->v.destroy(client, enh_code, reason); +} + +static void +client_default_destroy(struct client *client, const char *enh_code, + const char *reason) { if (client->destroyed) return; @@ -336,3 +345,7 @@ static const struct smtp_server_callbacks lmtp_callbacks = { .conn_is_trusted = client_connection_is_trusted }; + +static const struct lmtp_client_vfuncs lmtp_client_vfuncs = { + .destroy = client_default_destroy, +}; diff --git a/src/lmtp/client.h b/src/lmtp/client.h index ff5bf6ec4b..e74be37642 100644 --- a/src/lmtp/client.h +++ b/src/lmtp/client.h @@ -6,6 +6,8 @@ #define CLIENT_MAIL_DATA_MAX_INMEMORY_SIZE (1024*128) +struct client; + struct client_state { const char *name; unsigned int session_id_seq; @@ -18,10 +20,17 @@ struct client_state { const char *added_headers_proxy; }; +struct lmtp_client_vfuncs { + void (*destroy)(struct client *client, const char *enh_code, + const char *reason); +}; + struct client { struct client *prev, *next; pool_t pool; + struct lmtp_client_vfuncs v; + const struct setting_parser_info *user_set_info; const struct lda_settings *unexpanded_lda_set; const struct lmtp_settings *lmtp_set;