7e37d4cb06752773db8191ab9c035b04640a0f49
[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 #include "client.h"
21
22 struct Client;
23 struct SLink;
24 struct TRecord;
25 struct Message;
26
27
28 /*
29  * General defines
30  */
31
32 /*-----------------------------------------------------------------------------
33  * Macros
34  */
35
36 #define CONF_ILLEGAL            0x80000000
37 #define CONF_MATCH              0x40000000
38 #define CONF_CLIENT             0x0002
39 #define CONF_SERVER             0x0004
40 #define CONF_OPERATOR           0x0020
41 #define CONF_LEAF               0x1000
42 #define CONF_HUB                0x4000
43 #define CONF_UWORLD             0x8000
44
45 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER)
46
47 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
48
49 /*
50  * Structures
51  */
52
53 struct ConfItem
54 {
55   struct ConfItem *next;
56   unsigned int status;      /* If CONF_ILLEGAL, delete when no clients */
57   unsigned int clients;     /* Number of *LOCAL* clients using this */
58   struct ConnectionClass *conn_class;  /* Class of connection */
59   struct in_addr ipnum;       /* ip number of host field */
60   char *host;
61   char *passwd;
62   char *name;
63   time_t hold; /* Hold until this time (calendar time) */
64   int dns_pending; /* a dns request is pending */
65   unsigned short port;
66   unsigned char bits; /* Number of bits for ipkills. */
67   struct Privs privs; /* Priviledges for opers. */
68   /* Used to detect if a privilege has been touched. */
69   struct Privs privs_dirty;
70 };
71
72 struct ServerConf {
73   struct ServerConf* next;
74   char*              hostname;
75   char*              passwd;
76   char*              alias;
77   struct in_addr     address;
78   int                port;
79   int                dns_pending;
80   int                connected;
81   time_t             hold;
82   struct ConnectionClass*  conn_class;
83 };
84
85 struct qline
86 {
87   struct qline *next;
88   char *chname;
89   char *reason;
90 };
91
92 struct DenyConf {
93   struct DenyConf*    next;
94   char*               hostmask;
95   char*               message;
96   char*               usermask;
97   unsigned int        address;
98   unsigned int        flags;
99   char                bits;        /* Number of bits for ipkills */
100 };
101
102 #define DENY_FLAGS_FILE     0x0001 /* Comment is a filename */
103 #define DENY_FLAGS_IP       0x0002 /* K-line by IP address */
104 #define DENY_FLAGS_REALNAME 0x0004 /* K-line by real name */
105
106 /*
107  * A line: A:<line 1>:<line 2>:<line 3>
108  */
109 struct LocalConf {
110   char*          name;
111   char*          description;
112   struct in_addr vhost_address;
113   unsigned int   numeric;
114   char*          location1;
115   char*          location2;
116   char*          contact;
117 };
118
119 struct MotdItem {
120   char line[82];
121   struct MotdItem *next;
122 };
123
124 struct MotdConf {
125   struct MotdConf* next;
126   char* hostmask;
127   char* path;
128 };
129
130 enum {
131   CRULE_AUTO = 1,
132   CRULE_ALL  = 2,
133   CRULE_MASK = 3
134 };
135
136 struct CRuleNode;
137
138 struct CRuleConf {
139   struct CRuleConf* next;
140   char*             hostmask;
141   char*             rule;
142   int               type;
143   struct CRuleNode* node;
144 };
145
146 struct TRecord {
147   struct TRecord *next;
148   char *hostmask;
149   struct MotdItem *tmotd;
150   struct tm tmotd_tm;
151 };
152
153 enum AuthorizationCheckResult {
154   ACR_OK,
155   ACR_NO_AUTHORIZATION,
156   ACR_TOO_MANY_IN_CLASS,
157   ACR_TOO_MANY_FROM_IP,
158   ACR_ALREADY_AUTHORIZED,
159   ACR_BAD_SOCKET
160 };
161
162 struct nick_host {
163   struct nick_host *next;
164   int nicklen; /* offset of @ part of server string */
165   char nick[1]; /* start of nick@server string */
166 };
167
168 struct s_map {
169   struct s_map *next;
170   struct Message *msg;
171   char *name;
172   char *command;
173   char *prepend;
174   struct nick_host *services;
175 };
176
177
178 /*
179  * GLOBALS
180  */
181 extern struct ConfItem* GlobalConfList;
182 extern int              GlobalConfCount;
183 extern struct tm        motd_tm;
184 extern struct MotdItem* motd;
185 extern struct MotdItem* rmotd;
186 extern struct TRecord*  tdata;
187 extern struct s_map*    GlobalServiceMapList;
188 extern struct qline*    GlobalQuarantineList;
189
190 /*
191  * Proto types
192  */
193
194 extern int init_conf(void);
195
196 extern const struct LocalConf* conf_get_local(void);
197 extern const struct MotdConf*  conf_get_motd_list(void);
198 extern const struct CRuleConf* conf_get_crule_list(void);
199 extern const struct DenyConf*  conf_get_deny_list(void);
200
201 extern const char* conf_eval_crule(const char* name, int mask);
202
203 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
204 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
205 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
206 extern struct ConfItem* conf_find_server(const char* name);
207
208 extern void det_confs_butmask(struct Client *cptr, int mask);
209 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
210 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
211                                         const char* host, int statmask);
212 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
213 extern int  conf_check_server(struct Client *cptr);
214 extern struct ConfItem* find_conf_name(const char* name, int statmask);
215 extern int rehash(struct Client *cptr, int sig);
216 extern void read_tlines(void);
217 extern int find_kill(struct Client *cptr);
218 extern int find_restrict(struct Client *cptr);
219 extern struct MotdItem* read_motd(const char* motdfile);
220 extern const char *find_quarantine(const char* chname);
221 extern void lookup_confhost(struct ConfItem *aconf);
222
223 extern void yyerror(const char *msg);
224
225 #endif /* INCLUDED_s_conf_h */