315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen#ifndef CLIENT_H
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen#define CLIENT_H
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo Sirainen#include "net.h"
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch#include "smtp-server.h"
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
c5c61a6a9d748525ff3b2dd2705844464bed324fTimo Sirainen#define CLIENT_MAIL_DATA_MAX_INMEMORY_SIZE (1024*128)
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainenstruct client_state {
ed45903d7ad49b3d54f0883b203632fbccf8eff2Timo Sirainen const char *name;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch unsigned int session_id_seq;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct timeval data_end_timeval;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen struct ostream *mail_data_output;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch const char *added_headers_local;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch const char *added_headers_proxy;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen};
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainenstruct client {
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen struct client *prev, *next;
2fb9ae42f9e36388ec6db24188b9108434043fd0Timo Sirainen pool_t pool;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
2fb9ae42f9e36388ec6db24188b9108434043fd0Timo Sirainen const struct setting_parser_info *user_set_info;
32efae185f1f86167b3f00ea84f8502940c6c677Timo Sirainen const struct lda_settings *unexpanded_lda_set;
458acd7b39c84bae0d18c36ff9ddff9a49b4ae4aTimo Sirainen const struct lmtp_settings *lmtp_set;
30fc0b14f0d99a86c04aacff311e4cf2ddd5ff12Timo Sirainen const struct master_service_settings *service_set;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct smtp_server_connection *conn;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch enum smtp_server_state last_state;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen struct ip_addr remote_ip, local_ip;
009217abb57a24a4076092e8e4e165545747839eStephan Bosch in_port_t remote_port, local_port;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen struct mail_user *raw_mail_user;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen const char *my_domain;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen pool_t state_pool;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen struct client_state state;
c4390dad33b03dd51ba2a475f550347c86ebdb9aTimo Sirainen struct istream *dot_input;
2b7d6fbaadd62e66c858bae0358232c02369b43bStephan Bosch struct lmtp_local *local;
c2ebc8f28b5504f280cd5d4adfe57ed70f9a7d83Timo Sirainen struct lmtp_proxy *proxy;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool disconnected:1;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch bool destroyed:1;
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen};
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
823802b00ed82188e8666ad980379070e89c9009Stephan Boschstruct client *client_create(int fd_in, int fd_out,
2fb9ae42f9e36388ec6db24188b9108434043fd0Timo Sirainen const struct master_service_connection *conn);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschvoid client_destroy(struct client *client, const char *enh_code,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen const char *reason) ATTR_NULL(2, 3);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschvoid client_disconnect(struct client *client, const char *enh_code,
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch const char *reason) ATTR_NULL(2, 3);
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschconst char *client_state_get_name(struct client *client);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschvoid client_state_reset(struct client *client);
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainenvoid clients_destroy(void);
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen#endif