]> jfr.im git - solanum.git/blobdiff - authd/provider.h
authd/provider: add stats handling hooking
[solanum.git] / authd / provider.h
index 28deef649aee64231483ff460f3477cf6597f88c..c5462c9318e58e4deb41fef26724bf420159937d 100644 (file)
@@ -53,6 +53,7 @@ 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 */
 };
@@ -64,6 +65,12 @@ 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);
 
+struct auth_stats_handler
+{
+       const char letter;
+       authd_stat_handler handler;
+};
+
 struct auth_provider
 {
        rb_dlink_node node;
@@ -77,6 +84,8 @@ struct auth_provider
        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;
 };
 
@@ -96,35 +105,41 @@ 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 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_on(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 set_provider_off(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)
+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_on(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)
+static inline bool
+is_provider_done(struct auth_client *auth, provider_t provider)
 {
        return auth->providers_done & (1 << provider);
 }