client-common.h revision 12cf3d0e03fc70fb0c8b91bc8fd83b4e14d7cdef
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen#ifndef __CLIENT_COMMON_H
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen#define __CLIENT_COMMON_H
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen#include "network.h"
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen#include "master.h"
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen#include "sasl-server.h"
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenstruct client {
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen struct ip_addr local_ip;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen struct ip_addr ip;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int local_port, remote_port;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen struct ssl_proxy *proxy;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen int fd;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen char *auth_mech_name;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen struct auth_request *auth_request;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int master_tag;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen master_callback_t *master_callback;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen sasl_server_callback_t *sasl_callback;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen char *virtual_user;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int tls:1;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int secured:1;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int authenticating:1;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int waiting_auth_reply:1;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen /* ... */
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen};
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenstruct client *client_create(int fd, bool ssl, const struct ip_addr *local_ip,
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen const struct ip_addr *ip);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid client_syslog(struct client *client, const char *msg);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenunsigned int clients_get_count(void);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid clients_notify_auth_connected(void);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid client_destroy_oldest(void);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid clients_destroy_all(void);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid clients_init(void);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid clients_deinit(void);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen#endif
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen