]> jfr.im git - solanum.git/blobdiff - authd/provider.h
m_kline: check only the added K-line
[solanum.git] / authd / provider.h
index 34a0b5c36dd6b2fd4f99ead980f8454e8621cca2..74e1309eda0fbd3b008f5db05116091898416c7c 100644 (file)
@@ -44,7 +44,9 @@ struct auth_client_data
 
 struct auth_client
 {
-       uint16_t cid;                           /* Client ID */
+       uint32_t cid;                           /* Client ID */
+
+       int protocol;                           /* IP protocol (TCP/SCTP) */
 
        char l_ip[HOSTIPLEN + 1];               /* Listener IP address */
        uint16_t l_port;                        /* Listener port */
@@ -59,6 +61,7 @@ struct auth_client
 
        bool providers_starting;                /* Providers are still warming up */
        bool providers_cancelled;               /* Providers are being cancelled */
+       unsigned int providers_active;          /* Number of active providers */
        unsigned int refcount;                  /* Held references */
 
        struct auth_client_data *data;          /* Provider-specific data */
@@ -116,7 +119,7 @@ void destroy_providers(void);
 void cancel_providers(struct auth_client *auth);
 
 void provider_done(struct auth_client *auth, uint32_t id);
-void accept_client(struct auth_client *auth, uint32_t id);
+void accept_client(struct auth_client *auth);
 void reject_client(struct auth_client *auth, uint32_t id, const char *data, const char *fmt, ...);
 
 void handle_new_connection(int parc, char *parv[]);
@@ -176,31 +179,6 @@ get_provider_status(struct auth_client *auth, uint32_t provider)
        return auth->data[provider].status;
 }
 
-/* Set a provider's raw status */
-static inline void
-set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status)
-{
-       auth->data[provider].status = status;
-}
-
-/* Set the provider as running
- * If you're doing asynchronous work call this */
-static inline void
-set_provider_running(struct auth_client *auth, uint32_t provider)
-{
-       auth_client_ref(auth);
-       set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING);
-}
-
-/* Provider is no longer operating on this auth client
- * You should use provider_done and not this */
-static inline void
-set_provider_done(struct auth_client *auth, uint32_t provider)
-{
-       set_provider_status(auth, provider, PROVIDER_STATUS_DONE);
-       auth_client_unref(auth);
-}
-
 /* Check if provider is operating on this auth client */
 static inline bool
 is_provider_running(struct auth_client *auth, uint32_t provider)
@@ -215,6 +193,19 @@ is_provider_done(struct auth_client *auth, uint32_t provider)
        return get_provider_status(auth, provider) == PROVIDER_STATUS_DONE;
 }
 
+/* Check if provider doesn't exist or has finished on this client */
+static inline bool
+run_after_provider(struct auth_client *auth, const char *name)
+{
+       uint32_t id;
+
+       if (get_provider_id(name, &id)) {
+               return get_provider_status(auth, id) == PROVIDER_STATUS_DONE;
+       } else {
+               return true;
+       }
+}
+
 /* Get provider auth client data */
 static inline void *
 get_provider_data(struct auth_client *auth, uint32_t id)