* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __CHARYBDIS_AUTHD_PROVIDER_H__
-#define __CHARYBDIS_AUTHD_PROVIDER_H__
+#ifndef __SOLANUM_AUTHD_PROVIDER_H__
+#define __SOLANUM_AUTHD_PROVIDER_H__
#include "stdinc.h"
#include "authd.h"
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 */
char username[USERLEN + 1]; /* Used for ident lookup */
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 */
extern struct auth_provider rdns_provider;
extern struct auth_provider ident_provider;
-extern struct auth_provider blacklist_provider;
+extern struct auth_provider dnsbl_provider;
extern struct auth_provider opm_provider;
-extern rb_dictionary *auth_providers;
+extern rb_dlink_list auth_providers;
extern rb_dictionary *auth_clients;
void load_provider(struct auth_provider *provider);
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[]);
/* Get a provider by name */
static inline struct auth_provider *
-get_provider(const char *name)
+find_provider(const char *name)
{
- return rb_dictionary_retrieve(auth_providers, name);
+ rb_dlink_node *ptr;
+
+ RB_DLINK_FOREACH(ptr, auth_providers.head)
+ {
+ struct auth_provider *provider = ptr->data;
+
+ if(strcasecmp(provider->name, name) == 0)
+ return provider;
+ }
+
+ return NULL;
}
/* Get a provider's id by name */
static inline bool
get_provider_id(const char *name, uint32_t *id)
{
- struct auth_provider *provider = get_provider(name);
+ struct auth_provider *provider = find_provider(name);
if(provider != NULL)
{
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)
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)
return auth->data[id].timeout;
}
-#endif /* __CHARYBDIS_AUTHD_PROVIDER_H__ */
+#endif /* __SOLANUM_AUTHD_PROVIDER_H__ */