auth-server-connection.h revision 0cb5a9bfbf40b3b323956792aa13d342a459585e
183bea41fa640dc8117f3eb45ff935cd81377a84Timo Sirainen#ifndef AUTH_SERVER_CONNECTION_H
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen#define AUTH_SERVER_CONNECTION_H
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenstruct auth_client {
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int pid;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct auth_server_connection *connections;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct timeout *to_reconnect;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen time_t missing_sockets_start_time;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int conn_waiting_handshake_count;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen buffer_t *available_auth_mechs;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int request_id_counter;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int last_used_auth_process;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen auth_connect_notify_callback_t *connect_notify_callback;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen void *connect_notify_context;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int reconnect:1;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen};
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenstruct auth_server_connection {
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct auth_server_connection *next;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen pool_t pool;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen int refcount;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct auth_client *client;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen const char *path;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen int fd;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct io *io;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct timeout *to;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct istream *input;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct ostream *output;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int server_pid;
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainen unsigned int connect_uid;
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen buffer_t *auth_mechs_buf;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen const struct auth_mech_desc *available_auth_mechs;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int available_auth_mechs_count;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen struct hash_table *requests;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int version_received:1;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int handshake_received:1;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen unsigned int has_plain_mech:1;
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen};
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenstruct auth_server_connection *
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenauth_server_connection_new(struct auth_client *client, const char *path);
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenvoid auth_server_connection_destroy(struct auth_server_connection **conn,
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen bool reconnect);
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenstruct auth_server_connection *
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenauth_server_connection_find_path(struct auth_client *client, const char *path);
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenstruct auth_server_connection *
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenauth_server_connection_find_mech(struct auth_client *client,
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen const char *name, const char **error_r);
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen#endif
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen