smtp-server-private.h revision 1e3de3981ee5b13f59d84c6f9cd3722ae3084852
#ifndef SMTP_SERVER_PRIVATE_H
#define SMTP_SERVER_PRIVATE_H
#include "connection.h"
#include "smtp-server.h"
#define SMTP_SERVER_DEFAULT_MAX_BAD_COMMANDS 10
#define SMTP_SERVER_DEFAULT_CAPABILITIES \
struct smtp_server_reply;
struct smtp_server_command;
struct smtp_server_connection;
enum smtp_server_command_state {
/* New command; callback to command start handler executing. */
/* This command is being processed; command data is fully read, but no
reply is yet submitted */
/* A reply is submitted for this command. If not all command data was
read by the handler, it is first skipped on the input. If this is a
multi-reply command (LMTP->DATA), not all replies may be submitted
yet. */
/* Request is ready for sending reply; a reply is submitted and the
command payload is fully read. If this is a multi-reply command
(LMTP->DATA), not all replies may be submitted yet. In that case the
command state goes back to PROCESSING once the all submitted replies
are sent. */
/* The reply for the command is sent */
/* Request is aborted; still lingering due to references */
};
struct smtp_server_reply_content {
unsigned int status;
const char *status_prefix;
};
struct smtp_server_reply {
struct smtp_server_command *command;
unsigned int index;
/* replies may share content */
struct smtp_server_reply_content *content;
bool submitted:1;
bool sent:1;
};
struct smtp_server_command_reg {
const char *name;
};
struct smtp_server_command {
struct smtp_server_cmd_ctx context;
const struct smtp_server_command_reg *reg;
unsigned int refcount;
unsigned int replies_expected;
unsigned int replies_submitted;
/* private hooks */
/* next: command is next to reply but has not submittted all replies yet */
/* replied: command has submitted all replies */
/* completed: server is about to send last replies for this command */
/* destroy: command is about to be destroyed */
/* private context data */
void *data;
bool input_locked:1;
bool input_captured:1;
bool reply_early:1;
};
struct smtp_server_state_data {
enum smtp_server_state state;
unsigned int pending_mail_cmds, pending_rcpt_cmds;
struct smtp_server_transaction *trans;
struct istream_chain *data_chain;
unsigned int data_chunks;
bool data_failed:1;
};
struct smtp_server_connection {
struct connection conn;
struct smtp_server *server;
unsigned int refcount;
struct smtp_server_settings set;
const struct smtp_server_callbacks *callbacks;
void *context;
unsigned int socket_family;
unsigned int proxy_ttl_plus_1;
unsigned int proxy_timeout_secs;
unsigned int id;
struct ostream *raw_output;
struct ssl_iostream *ssl_iostream;
struct smtp_command_parser *smtp_parser;
unsigned int command_queue_count;
unsigned int bad_counter;
char *disconnect_reason;
struct smtp_server_state_data state;
struct smtp_server_stats stats;
bool started:1;
bool halted:1;
bool ssl_start:1;
bool ssl_secured:1;
bool authenticated:1;
bool created_from_streams:1;
bool corked:1;
bool disconnected:1;
bool closing:1;
bool closed:1;
bool input_broken:1;
bool input_locked:1;
bool handling_input:1;
bool rawlog_checked:1;
bool rawlog_enabled:1;
};
struct smtp_server {
struct smtp_server_settings set;
struct connection_list *conn_list;
bool commands_unsorted:1;
};
static inline const char *
{
return "[INVALID]";
}
static inline const char *
{
}
struct smtp_server_connection *conn);
/*
* Reply
*/
const char **error_r);
const char **error_r);
/*
* Command
*/
struct smtp_server_command *
struct smtp_server_command *
static inline bool
{
}
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
const char *params);
/*
* Connection
*/
typedef void smtp_server_input_callback_t(void *context);
struct connection_list *smtp_server_connection_list_init(void);
struct smtp_server_connection *conn);
struct smtp_server_connection *conn,
enum smtp_server_state state);
struct smtp_server_transaction *
const struct smtp_proxy_data *proxy_data);
/*
* Transaction
*/
struct smtp_server_transaction *
const struct smtp_address *mail_from,
const struct smtp_params_mail *params,
struct smtp_server_recipient *
const struct smtp_address *rcpt_to,
const struct smtp_params_rcpt *params);
unsigned int
#endif