Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / include / s_auth.h
1 /************************************************************************
2  *   IRC - Internet Relay Chat, include/s_auth.h
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 1, or (at your option)
7  *   any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the Free Software
16  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  *   $Id$
19  */
20 #ifndef INCLUDED_s_auth_h
21 #define INCLUDED_s_auth_h
22 #ifndef INCLUDED_sys_types_h
23 #include <sys/types.h>
24 #define INCLUDED_sys_types_h
25 #endif
26 #ifndef INCLUDED_ircd_events_h
27 #include "ircd_events.h"
28 #endif
29
30 struct Client;
31
32 struct AuthRequest {
33   struct AuthRequest* next;      /* linked list node ptr */
34   struct AuthRequest* prev;      /* linked list node ptr */
35   struct Client*      client;    /* pointer to client struct for request */
36   unsigned int        flags;     /* current state of request */
37   int                 fd;        /* file descriptor for auth queries */
38   struct Socket       socket;    /* socket descriptor for auth queries */
39   struct Timer        timeout;   /* timeout timer for auth queries */
40 };
41
42 /*
43  * flag values for AuthRequest
44  * NAMESPACE: AM_xxx - Authentication Module
45  */
46 #define AM_AUTH_CONNECTING   0x01
47 #define AM_AUTH_PENDING      0x02
48 #define AM_DNS_PENDING       0x04
49
50 #define AM_SOCKET            0x40 /* socket structure not destroyed */
51 #define AM_TIMEOUT           0x80 /* timer structure not destroyed */
52
53 #define AM_FREE_MASK         (AM_SOCKET | AM_TIMEOUT)
54
55 #define SetDNSPending(x)     ((x)->flags |= AM_DNS_PENDING)
56 #define ClearDNSPending(x)   ((x)->flags &= ~AM_DNS_PENDING)
57 #define IsDNSPending(x)      ((x)->flags &  AM_DNS_PENDING)
58
59 #define SetAuthConnect(x)    ((x)->flags |= AM_AUTH_CONNECTING)
60 #define ClearAuthConnect(x)  ((x)->flags &= ~AM_AUTH_CONNECTING)
61 #define IsAuthConnect(x)     ((x)->flags &  AM_AUTH_CONNECTING)
62
63 #define SetAuthPending(x)    ((x)->flags |= AM_AUTH_PENDING)
64 #define ClearAuthPending(x)  ((x)->flags &= AM_AUTH_PENDING)
65 #define IsAuthPending(x)     ((x)->flags &  AM_AUTH_PENDING)
66
67 #define ClearAuth(x)         ((x)->flags &= ~(AM_AUTH_PENDING | AM_AUTH_CONNECTING))
68 #define IsDoingAuth(x)       ((x)->flags &  (AM_AUTH_PENDING | AM_AUTH_CONNECTING))
69
70
71 extern struct AuthRequest* AuthPollList; /* GLOBAL - auth queries pending io */
72
73 extern void start_auth(struct Client *);
74 extern void read_auth_reply(struct AuthRequest* req);
75 extern void send_auth_query(struct AuthRequest* req);
76 extern void destroy_auth_request(struct AuthRequest *req, int send_reports);
77
78 #endif /* INCLUDED_s_auth_h */
79