Author: Bleep <helveytw@home.com>
[ircu2.10.12-pk.git] / include / s_conf.h
1 /*
2  * s_conf.h
3  *
4  * $Id$ 
5  */
6 #ifndef INCLUDED_s_conf_h
7 #define INCLUDED_s_conf_h
8 #ifndef INCLUDED_time_h
9 #include <time.h>              /* struct tm */
10 #define INCLUDED_time_h
11 #endif
12 #ifndef INCLUDED_sys_types_h
13 #include <sys/types.h>
14 #define INCLUDED_sys_types_h
15 #endif
16 #ifndef INCLUDED_netinet_in_h
17 #include <netinet/in.h>        /* struct in_addr */
18 #define INCLUDED_netinet_in_h
19 #endif
20
21 struct Client;
22 struct SLink;
23 struct TRecord;
24
25
26 /*
27  * General defines
28  */
29
30 /*-----------------------------------------------------------------------------
31  * Macros
32  */
33
34 #define CONF_ILLEGAL            0x80000000
35 #define CONF_MATCH              0x40000000
36 #define CONF_CLIENT             0x0002
37 #define CONF_SERVER             0x0004
38 #define CONF_LOCOP              0x0010
39 #define CONF_OPERATOR           0x0020
40 #define CONF_KILL               0x0080
41 #define CONF_LEAF               0x1000
42 #define CONF_HUB                0x4000
43 #define CONF_UWORLD             0x8000
44 #define CONF_IPKILL             0x00010000
45
46 #define CONF_OPS                (CONF_OPERATOR | CONF_LOCOP)
47 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPS | CONF_SERVER)
48 #define CONF_KLINE              (CONF_KILL | CONF_IPKILL)
49
50 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
51
52 /*
53  * Structures
54  */
55
56 struct ConfItem {
57   struct ConfItem*   next;
58   unsigned int       status;    /* If CONF_ILLEGAL, delete when no clients */
59   unsigned int       clients;   /* Number of *LOCAL* clients using this */
60   struct in_addr     ipnum;     /* ip number of host field */
61   char               bits;      /* Number of bits for ipkills */
62   char*              host;
63   char*              passwd;
64   char*              name;
65   unsigned short int port;
66   time_t             hold;      /* Hold until this time (calendar time) */
67   int                dns_pending; /* a dns request is pending */
68   struct ConnectionClass*  confClass; /* Class of connection */
69 };
70
71 struct ServerConf {
72   struct ServerConf* next;
73   char*              hostname;
74   char*              passwd;
75   char*              alias;
76   struct in_addr     address;
77   int                port;
78   int                dns_pending;
79   int                connected;
80   time_t             hold;
81   struct ConnectionClass*  confClass;
82 };
83
84 /*
85  * A line: A:<line 1>:<line 2>:<line 3>
86  */
87 struct LocalConf {
88   char*          name;
89   char*          description;
90   struct in_addr vhost_address;
91   unsigned int   numeric;
92   char*          location1;
93   char*          location2;
94   char*          contact;
95 };
96
97 struct MotdItem {
98   char line[82];
99   struct MotdItem *next;
100 };
101
102 struct MotdConf {
103   struct MotdConf* next;
104   char* hostmask;
105   char* path;
106 };
107
108 enum {
109   CRULE_AUTO = 1,
110   CRULE_ALL  = 2,
111   CRULE_MASK = 3
112 };
113
114 struct CRuleNode;
115
116 struct CRuleConf {
117   struct CRuleConf* next;
118   char*             hostmask;
119   char*             rule;
120   int               type;
121   struct CRuleNode* node;
122 };
123
124 struct TRecord {
125   struct TRecord *next;
126   char *hostmask;
127   struct MotdItem *tmotd;
128   struct tm tmotd_tm;
129 };
130
131 enum AuthorizationCheckResult {
132   ACR_OK,
133   ACR_NO_AUTHORIZATION,
134   ACR_TOO_MANY_IN_CLASS,
135   ACR_TOO_MANY_FROM_IP,
136   ACR_ALREADY_AUTHORIZED,
137   ACR_BAD_SOCKET
138 };
139
140 /*
141  * GLOBALS
142  */
143 extern struct ConfItem* GlobalConfList;
144 extern int              GlobalConfCount;
145 extern struct tm        motd_tm;
146 extern struct MotdItem* motd;
147 extern struct MotdItem* rmotd;
148 extern struct TRecord*  tdata;
149
150 /*
151  * Proto types
152  */
153
154 extern int init_conf(void);
155
156 extern const struct LocalConf* conf_get_local(void);
157 extern const struct MotdConf*  conf_get_motd_list(void);
158 extern const struct CRuleConf* conf_get_crule_list(void);
159
160 extern const char* conf_eval_crule(const char* name, int mask);
161
162 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
163 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
164 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
165 extern struct ConfItem* conf_find_server(const char* name);
166
167 extern void det_confs_butmask(struct Client *cptr, int mask);
168 extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
169 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
170 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
171                                         const char* host, int statmask);
172 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
173 extern int  conf_check_server(struct Client *cptr);
174 extern struct ConfItem* find_conf_name(const char* name, int statmask);
175 extern int rehash(struct Client *cptr, int sig);
176 extern void read_tlines(void);
177 extern int find_kill(struct Client *cptr);
178 extern int find_restrict(struct Client *cptr);
179 extern struct MotdItem* read_motd(const char* motdfile);
180
181 #endif /* INCLUDED_s_conf_h */