Doxyfile s_auth.h.
[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 /** Stores state of the DNS and RFC 1413 ident lookups for a client. */
33 struct AuthRequest {
34   struct AuthRequest* next;      /**< linked list node ptr */
35   struct AuthRequest* prev;      /**< linked list node ptr */
36   struct Client*      client;    /**< pointer to client struct for request */
37   unsigned int        flags;     /**< current state of request */
38   int                 fd;        /**< file descriptor for auth queries */
39   struct Socket       socket;    /**< socket descriptor for auth queries */
40   struct Timer        timeout;   /**< timeout timer for auth queries */
41 };
42
43 /*
44  * flag values for AuthRequest
45  * NAMESPACE: AM_xxx - Authentication Module
46  */
47 #define AM_AUTH_CONNECTING   0x01 /**< waiting for ident connect to complete */
48 #define AM_AUTH_PENDING      0x02 /**< ident connected, waiting for response */
49 #define AM_DNS_PENDING       0x04 /**< dns request sent, waiting for response */
50
51 #define AM_SOCKET            0x40 /**< socket structure not destroyed */
52 #define AM_TIMEOUT           0x80 /**< timer structure not destroyed */
53
54 /** If any of AM_FREE_MASK bits are set, operations are still in progress. */
55 #define AM_FREE_MASK         (AM_SOCKET | AM_TIMEOUT)
56
57 #define SetDNSPending(x)     ((x)->flags |= AM_DNS_PENDING)
58 #define ClearDNSPending(x)   ((x)->flags &= ~AM_DNS_PENDING)
59 #define IsDNSPending(x)      ((x)->flags &  AM_DNS_PENDING)
60
61 #define SetAuthConnect(x)    ((x)->flags |= AM_AUTH_CONNECTING)
62 #define ClearAuthConnect(x)  ((x)->flags &= ~AM_AUTH_CONNECTING)
63 #define IsAuthConnect(x)     ((x)->flags &  AM_AUTH_CONNECTING)
64
65 #define SetAuthPending(x)    ((x)->flags |= AM_AUTH_PENDING)
66 #define ClearAuthPending(x)  ((x)->flags &= AM_AUTH_PENDING)
67 #define IsAuthPending(x)     ((x)->flags &  AM_AUTH_PENDING)
68
69 #define ClearAuth(x)         ((x)->flags &= ~(AM_AUTH_PENDING | AM_AUTH_CONNECTING))
70 #define IsDoingAuth(x)       ((x)->flags &  (AM_AUTH_PENDING | AM_AUTH_CONNECTING))
71
72 extern void start_auth(struct Client *);
73 extern void read_auth_reply(struct AuthRequest* req);
74 extern void send_auth_query(struct AuthRequest* req);
75 extern void destroy_auth_request(struct AuthRequest *req, int send_reports);
76
77 #endif /* INCLUDED_s_auth_h */
78