auth-client.h revision 2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen#ifndef __AUTH_CLIENT_H
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen#define __AUTH_CLIENT_H
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen#include "../auth/auth-client-interface.h"
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenstruct auth_client;
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenstruct auth_request;
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* reply is NULL if auth connection died */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainentypedef void auth_request_callback_t(struct auth_request *request,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen struct auth_client_request_reply *reply,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen const unsigned char *data, void *context);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainentypedef void auth_connect_notify_callback_t(struct auth_client *client,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen int connected, void *context);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Create new authentication client. */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenstruct auth_client *auth_client_new(unsigned int client_pid);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenvoid auth_client_free(struct auth_client *client);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenint auth_client_is_connected(struct auth_client *client);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenvoid auth_client_set_connect_notify(struct auth_client *client,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen auth_connect_notify_callback_t *callback,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen void *context);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenenum auth_mech auth_client_get_available_mechs(struct auth_client *client);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenvoid auth_client_connect_missing_servers(struct auth_client *client);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Create a new authentication request. callback is called whenever something
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen happens for the request. */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenstruct auth_request *
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenauth_client_request_new(struct auth_client *client,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen enum auth_mech mech, enum auth_protocol protocol,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen auth_request_callback_t *callback, void *context,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen const char **error_r);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Continue authentication. Call when
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen reply->result == AUTH_CLIENT_REQUEST_CONTINUE */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenvoid auth_client_request_continue(struct auth_request *request,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen const unsigned char *data, size_t data_size);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Abort ongoing authentication request. */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenvoid auth_client_request_abort(struct auth_request *request);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Return ID of this request. */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenunsigned int auth_client_request_get_id(struct auth_request *request);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Return the PID of the server that handled this request. */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenunsigned int auth_client_request_get_server_pid(struct auth_request *request);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen#endif