X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/460032e61f0b10137442b66ffa203dae5343344b..ee7f92714ad53c5bc362447fc98670d873863411:/authd/provider.h diff --git a/authd/provider.h b/authd/provider.h index 01c71cf4..c5462c93 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -22,6 +22,7 @@ #define __CHARYBDIS_AUTHD_PROVIDER_H__ #include "stdinc.h" +#include "authd.h" #include "rb_dictionary.h" #define MAX_PROVIDERS 32 /* This should be enough */ @@ -34,14 +35,6 @@ typedef enum PROVIDER_BLACKLIST, } provider_t; -typedef enum -{ - L_DEBUG = 'D', - L_INFO = 'I', - L_WARN = 'W', - L_CRIT ='C', -} notice_level_t; - struct auth_client { uint16_t cid; /* Client ID */ @@ -59,6 +52,8 @@ struct auth_client uint32_t providers; /* Providers at work, * none left when set to 0 */ + uint32_t providers_done; /* Providers completed */ + bool providers_starting; /* Providers are still warming up */ void *data[MAX_PROVIDERS]; /* Provider-specific data slots */ }; @@ -68,7 +63,13 @@ typedef void (*provider_destroy_t)(void); typedef bool (*provider_start_t)(struct auth_client *); typedef void (*provider_cancel_t)(struct auth_client *); -typedef void (*provider_complete_t)(struct auth_client *, provider_t provider); +typedef void (*provider_complete_t)(struct auth_client *, provider_t); + +struct auth_stats_handler +{ + const char letter; + authd_stat_handler handler; +}; struct auth_provider { @@ -82,6 +83,10 @@ struct auth_provider provider_start_t start; /* Perform authentication */ provider_cancel_t cancel; /* Authentication cancelled */ provider_complete_t completed; /* Callback for when other performers complete (think dependency chains) */ + + struct auth_stats_handler stats_handler; + + struct auth_opts_handler *opt_handlers; }; extern rb_dlink_list auth_providers; @@ -100,29 +105,43 @@ void cancel_providers(struct auth_client *auth); void provider_done(struct auth_client *auth, provider_t id); void accept_client(struct auth_client *auth, provider_t id); -void reject_client(struct auth_client *auth, provider_t id, const char *reason); - -void notice_client(struct auth_client *auth, const char *fmt, ...); -void warn_opers(notice_level_t level, const char *fmt, ...); +void reject_client(struct auth_client *auth, provider_t id, const char *data, const char *reason); void handle_new_connection(int parc, char *parv[]); +void handle_cancel_connection(int parc, char *parv[]); /* Provider is operating on this auth_client (set this if you have async work to do) */ -static inline void set_provider(struct auth_client *auth, provider_t provider) +static inline void +set_provider_on(struct auth_client *auth, provider_t provider) { auth->providers |= (1 << provider); } /* Provider is no longer operating on this auth client (you should use provider_done) */ -static inline void unset_provider(struct auth_client *auth, provider_t provider) +static inline void +set_provider_off(struct auth_client *auth, provider_t provider) { auth->providers &= ~(1 << provider); } +/* Set the provider to done (you should use provider_done) */ +static inline void +set_provider_done(struct auth_client *auth, provider_t provider) +{ + auth->providers_done |= (1 << provider); +} + /* Check if provider is operating on this auth client */ -static inline bool is_provider(struct auth_client *auth, provider_t provider) +static inline bool +is_provider_on(struct auth_client *auth, provider_t provider) { return auth->providers & (1 << provider); } +static inline bool +is_provider_done(struct auth_client *auth, provider_t provider) +{ + return auth->providers_done & (1 << provider); +} + #endif /* __CHARYBDIS_AUTHD_PROVIDER_H__ */