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