c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef AUTH_REQUEST_HANDLER_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define AUTH_REQUEST_HANDLER_H
657afb33796f8216c568ad813627da89970760beTimo Sirainen
70905e51a5148bd5613cb04720807177474a2496Timo Sirainenstruct auth_request;
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainenstruct auth_client_connection;
ad49932dae8ba31e07544b66bbc4f4de707a751cTimo Sirainenstruct auth_master_connection;
226259ee6fb9830dafc1a5ba1e95bf5a4345b406Timo Sirainenstruct auth_stream_reply;
70905e51a5148bd5613cb04720807177474a2496Timo Sirainen
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainenenum auth_client_result {
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen AUTH_CLIENT_RESULT_CONTINUE = 1,
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen AUTH_CLIENT_RESULT_SUCCESS,
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen AUTH_CLIENT_RESULT_FAILURE
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen};
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen
226259ee6fb9830dafc1a5ba1e95bf5a4345b406Timo Sirainentypedef void
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainenauth_client_request_callback_t(const char *reply, struct auth_client_connection *conn);
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainentypedef void
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainenauth_master_request_callback_t(const char *reply, struct auth_master_connection *conn);
657afb33796f8216c568ad813627da89970760beTimo Sirainen
657afb33796f8216c568ad813627da89970760beTimo Sirainenstruct auth_request_handler *
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainenauth_request_handler_create(bool token_auth, auth_client_request_callback_t *callback,
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainen struct auth_client_connection *conn,
6aafdd81aa1e12c127941c1ebd87e8ee4697ec3eTimo Sirainen auth_master_request_callback_t *master_callback);
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen
5363f51ad46344f4e5952f2fef211a7cf8f95ddcTimo Sirainenvoid auth_request_handler_destroy(struct auth_request_handler **handler);
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainenvoid auth_request_handler_unref(struct auth_request_handler **handler);
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainenvoid auth_request_handler_abort_requests(struct auth_request_handler *handler);
fbee9bffb56d882b98146dd0de76a5bcccc2bdc3Timo Sirainen
70905e51a5148bd5613cb04720807177474a2496Timo Sirainenvoid auth_request_handler_set(struct auth_request_handler *handler,
70905e51a5148bd5613cb04720807177474a2496Timo Sirainen unsigned int connect_uid,
70905e51a5148bd5613cb04720807177474a2496Timo Sirainen unsigned int client_pid);
70905e51a5148bd5613cb04720807177474a2496Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenbool auth_request_handler_auth_begin(struct auth_request_handler *handler,
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen const char *args);
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainenbool auth_request_handler_auth_continue(struct auth_request_handler *handler,
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen const char *args);
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainenvoid auth_request_handler_reply(struct auth_request *request,
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen enum auth_client_result result,
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen const void *reply, size_t reply_size);
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainenvoid auth_request_handler_reply_continue(struct auth_request *request,
50782de8a9d5ebe11ee61496b4e695a1d3875230Timo Sirainen const void *reply, size_t reply_size);
a7e2c98560cf54dc656711a237cb07da8a5a9ee4Timo Sirainenunsigned int
a7e2c98560cf54dc656711a237cb07da8a5a9ee4Timo Sirainenauth_request_handler_get_request_count(struct auth_request_handler *handler);
daa7e7459749ae8f82cd3eed9c44522d81c609a3Timo Sirainenbool auth_request_handler_master_request(struct auth_request_handler *handler,
ad49932dae8ba31e07544b66bbc4f4de707a751cTimo Sirainen struct auth_master_connection *master,
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch unsigned int id, unsigned int client_id,
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch const char *const *params);
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainenvoid auth_request_handler_cancel_request(struct auth_request_handler *handler,
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainen unsigned int client_id);
657afb33796f8216c568ad813627da89970760beTimo Sirainen
2872c818f9c6704609f4d67d984b033a63e3a108Timo Sirainenvoid auth_request_handler_flush_failures(bool flush_all);
657afb33796f8216c568ad813627da89970760beTimo Sirainen
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainenvoid auth_request_handler_init(void);
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainenvoid auth_request_handler_deinit(void);
657afb33796f8216c568ad813627da89970760beTimo Sirainen
657afb33796f8216c568ad813627da89970760beTimo Sirainen#endif