static const struct submission_client_vfuncs submission_client_vfuncs = {
client_default_destroy,
+
+ .cmd_helo = client_default_cmd_helo,
+
+ .cmd_mail = client_default_cmd_mail,
+ .cmd_rcpt = client_default_cmd_rcpt,
+ .cmd_rset = client_default_cmd_rset,
+ .cmd_data = client_default_cmd_data,
+
+ .cmd_vrfy = client_default_cmd_vrfy,
+
+ .cmd_noop = client_default_cmd_noop,
+ .cmd_quit = client_default_cmd_quit,
};
struct submission_client_vfuncs {
void (*destroy)(struct client *client, const char *prefix,
const char *reason);
+
+ int (*cmd_helo)(struct client *client, struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_helo *data);
+
+ 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 submission_recipient *rcpt,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_rcpt *data);
+ int (*cmd_rset)(struct client *client, struct smtp_server_cmd_ctx *cmd);
+ 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 (*cmd_vrfy)(struct client *client, struct smtp_server_cmd_ctx *cmd,
+ const char *param);
+
+ int (*cmd_noop)(struct client *client, struct smtp_server_cmd_ctx *cmd);
+ int (*cmd_quit)(struct client *client, struct smtp_server_cmd_ctx *cmd);
};
struct client {
if (!data->first ||
smtp_server_connection_get_state(client->conn)
- >= SMTP_SERVER_STATE_READY) {
- return submission_backend_cmd_helo(client->backend_default,
- cmd, data);
- }
+ >= SMTP_SERVER_STATE_READY)
+ return client->v.cmd_helo(client, cmd, data);
/* respond right away */
submission_helo_reply_submit(cmd, data);
return 1;
}
+int client_default_cmd_helo(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_helo *data)
+{
+ return submission_backend_cmd_helo(client->backend_default, cmd, data);
+}
+
+
/*
* MAIL command
*/
client->state.backend = client->backend_default;
+ return client->v.cmd_mail(client, cmd, data);
+}
+
+int client_default_cmd_mail(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_mail *data)
+{
return submission_backend_cmd_mail(client->state.backend, cmd, data);
}
struct smtp_server_cmd_rcpt *data)
{
struct client *client = conn_ctx;
- struct smtp_server_transaction *trans;
struct submission_recipient *rcpt;
rcpt = submission_recipient_create(client, data->path);
data->trans_context = rcpt;
data->hook_finished = submission_rcpt_finished;
+ return client->v.cmd_rcpt(client, rcpt, cmd, data);
+}
+
+int client_default_cmd_rcpt(struct client *client ATTR_UNUSED,
+ struct submission_recipient *rcpt,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_rcpt *data)
+{
+ struct smtp_server_transaction *trans;
+
trans = smtp_server_connection_get_transaction(cmd->conn);
if (trans != NULL)
submission_backend_trans_start(rcpt->backend, trans);
int cmd_rset(void *conn_ctx, struct smtp_server_cmd_ctx *cmd)
{
struct client *client = conn_ctx;
+
+ return client->v.cmd_rset(client, cmd);
+}
+
+int client_default_cmd_rset(struct client *client,
+ struct smtp_server_cmd_ctx *cmd)
+{
struct submission_backend *backend = client->state.backend;
if (backend == NULL)
i_stream_unref(&inputs[0]);
i_stream_unref(&inputs[1]);
- ret = submission_backends_cmd_data(client, cmd, trans,
- data_input, data_size);
+ ret = client->v.cmd_data(client, cmd, trans, data_input, data_size);
i_stream_unref(&data_input);
return ret;
return 0;
}
+int client_default_cmd_data(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_transaction *trans,
+ struct istream *data_input, uoff_t data_size)
+{
+ return submission_backends_cmd_data(client, cmd, trans,
+ data_input, data_size);
+}
+
/*
* BURL command
*/
{
struct client *client = conn_ctx;
+ return client->v.cmd_vrfy(client, cmd, param);
+}
+
+int client_default_cmd_vrfy(struct client *client,
+ struct smtp_server_cmd_ctx *cmd, const char *param)
+{
return submission_backend_cmd_vrfy(client->backend_default, cmd, param);
}
{
struct client *client = conn_ctx;
+ return client->v.cmd_noop(client, cmd);
+}
+
+int client_default_cmd_noop(struct client *client,
+ struct smtp_server_cmd_ctx *cmd)
+{
return submission_backend_cmd_noop(client->backend_default, cmd);
}
smtp_server_command_add_hook(cmd->cmd, SMTP_SERVER_COMMAND_HOOK_NEXT,
cmd_quit_next, quit_cmd);
+ return client->v.cmd_quit(client, cmd);
+}
+
+int client_default_cmd_quit(struct client *client,
+ struct smtp_server_cmd_ctx *cmd)
+{
return submission_backend_cmd_quit(client->backend_default, cmd);
}
+
#ifndef SUBMISSION_COMMANDS_H
#define SUBMISSION_COMMANDS_H
+/*
+ * HELO command
+ */
+
void submission_helo_reply_submit(struct smtp_server_cmd_ctx *cmd,
struct smtp_server_cmd_helo *data);
+
int cmd_helo(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_cmd_helo *data);
+int client_default_cmd_helo(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_helo *data);
+
+/*
+ * MAIL command
+ */
+
int cmd_mail(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_cmd_mail *data);
+
+int client_default_cmd_mail(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_mail *data);
+
+/*
+ * RCPT command
+ */
+
int cmd_rcpt(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_cmd_rcpt *data);
+
+int client_default_cmd_rcpt(struct client *client ATTR_UNUSED,
+ struct submission_recipient *rcpt,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_rcpt *data);
+
+/*
+ * RSET command
+ */
+
int cmd_rset(void *conn_ctx, struct smtp_server_cmd_ctx *cmd);
+int client_default_cmd_rset(struct client *client,
+ struct smtp_server_cmd_ctx *cmd);
+
+/*
+ * DATA/BDAT commands
+ */
+
int cmd_data_begin(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_transaction *trans,
struct istream *data_input);
int cmd_data_continue(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_transaction *trans);
+
+int client_default_cmd_data(struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_transaction *trans,
+ struct istream *data_input, uoff_t data_size);
+
+/*
+ * BURL command
+ */
+
void cmd_burl(struct smtp_server_cmd_ctx *cmd, const char *params);
+/*
+ * VRFY command
+ */
+
int cmd_vrfy(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
const char *param);
+int client_default_cmd_vrfy(struct client *client,
+ struct smtp_server_cmd_ctx *cmd, const char *param);
+
+/*
+ * NOOP command
+ */
+
int cmd_noop(void *conn_ctx, struct smtp_server_cmd_ctx *cmd);
+
+int client_default_cmd_noop(struct client *client,
+ struct smtp_server_cmd_ctx *cmd);
+
+/*
+ * QUIT command
+ */
+
int cmd_quit(void *conn_ctx, struct smtp_server_cmd_ctx *cmd);
+int client_default_cmd_quit(struct client *client,
+ struct smtp_server_cmd_ctx *cmd);
+
#endif