summaryrefslogtreecommitdiffstats
path: root/src/lmtp/lmtp-client.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:36:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:36:47 +0000
commit0441d265f2bb9da249c7abf333f0f771fadb4ab5 (patch)
tree3f3789daa2f6db22da6e55e92bee0062a7d613fe /src/lmtp/lmtp-client.h
parentInitial commit. (diff)
downloaddovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.tar.xz
dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.zip
Adding upstream version 1:2.3.21+dfsg1.upstream/1%2.3.21+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lmtp/lmtp-client.h')
-rw-r--r--src/lmtp/lmtp-client.h124
1 files changed, 124 insertions, 0 deletions
diff --git a/src/lmtp/lmtp-client.h b/src/lmtp/lmtp-client.h
new file mode 100644
index 0000000..0e7d963
--- /dev/null
+++ b/src/lmtp/lmtp-client.h
@@ -0,0 +1,124 @@
+#ifndef CLIENT_H
+#define CLIENT_H
+
+#include "net.h"
+#include "smtp-server.h"
+
+#define CLIENT_MAIL_DATA_MAX_INMEMORY_SIZE (1024*128)
+
+struct mail_storage;
+struct mail_deliver_context;
+union lmtp_module_context;
+struct lmtp_recipient;
+struct client;
+
+struct lmtp_local_deliver_context {
+ struct mail *src_mail;
+ const char *session_id;
+ struct timeval delivery_time_started;
+
+ struct mail_user *rcpt_user;
+ const char *rcpt_default_mailbox;
+
+ const struct mail_storage_settings *mail_set;
+ const struct smtp_submit_settings *smtp_set;
+ const struct lda_settings *lda_set;
+
+ struct mail_deliver_session *session;
+};
+
+struct client_state {
+ enum smtp_server_state state;
+ char *args;
+ unsigned int session_id_seq;
+
+ struct istream *data_input;
+ uoff_t data_size;
+
+ struct timeval data_end_timeval;
+
+ struct ostream *mail_data_output;
+
+ const char *added_headers_local;
+ const char *added_headers_proxy;
+};
+
+struct lmtp_client_vfuncs {
+ void (*destroy)(struct client *client);
+
+ void (*trans_start)(struct client *client,
+ struct smtp_server_transaction *trans);
+ void (*trans_free)(struct client *client,
+ struct smtp_server_transaction *trans);
+
+ int (*cmd_mail)(struct client *client, struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_mail *data);
+ int (*cmd_rcpt)(struct client *client, struct smtp_server_cmd_ctx *cmd,
+ struct lmtp_recipient *lrcpt);
+ int (*cmd_data)(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_transaction *trans,
+ struct istream *data_input, uoff_t data_size);
+
+ int (*local_deliver)(struct client *client,
+ struct lmtp_recipient *lrcpt,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_transaction *trans,
+ struct lmtp_local_deliver_context *lldctx);
+};
+
+struct client {
+ struct client *prev, *next;
+ pool_t pool;
+
+ struct lmtp_client_vfuncs v;
+ struct event *event;
+
+ const struct setting_parser_info *user_set_info;
+ const struct mail_user_settings *user_set;
+ const struct lda_settings *unexpanded_lda_set;
+ const struct lmtp_settings *lmtp_set;
+ const struct master_service_settings *service_set;
+
+ struct smtp_server_connection *conn;
+
+ struct ip_addr remote_ip, local_ip, real_local_ip, real_remote_ip;
+ in_port_t remote_port, local_port, real_local_port, real_remote_port;
+
+ struct mail_user *raw_mail_user;
+ const char *my_domain;
+
+ pool_t state_pool;
+ struct client_state state;
+ struct istream *dot_input;
+ struct lmtp_local *local;
+ struct lmtp_proxy *proxy;
+
+ /* Module-specific contexts. */
+ ARRAY(union lmtp_module_context *) module_contexts;
+
+ bool disconnected:1;
+ bool destroyed:1;
+};
+
+struct lmtp_module_register {
+ unsigned int id;
+};
+
+union lmtp_module_context {
+ struct lmtp_client_vfuncs super;
+ struct lmtp_module_register *reg;
+};
+extern struct lmtp_module_register lmtp_module_register;
+
+struct client *client_create(int fd_in, int fd_out,
+ const struct master_service_connection *conn);
+void client_destroy(struct client **client, const char *enh_code,
+ const char *reason) ATTR_NULL(2, 3);
+
+void client_state_reset(struct client *client);
+void client_update_data_state(struct client *client, const char *new_args);
+
+void clients_destroy(void);
+
+#endif