IPv6 support (hopefully with fewer future transition pains)
[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 address; /* ip and port */
56   char *host;
57   char *passwd;
58   char *name;
59   time_t hold; /* Hold until this time (calendar time) */
60   int dns_pending; /* a dns request is pending */
61   unsigned char bits; /* Number of bits for ipkills. */
62   struct Privs privs; /* Priviledges for opers. */
63   /* Used to detect if a privilege has been touched. */
64   struct Privs privs_dirty;
65 };
66
67 struct ServerConf {
68   struct ServerConf* next;
69   char*              hostname;
70   char*              passwd;
71   char*              alias;
72   struct irc_in_addr address;
73   int                dns_pending;
74   int                connected;
75   time_t             hold;
76   struct ConnectionClass*  conn_class;
77 };
78
79 struct qline
80 {
81   struct qline *next;
82   char *chname;
83   char *reason;
84 };
85
86 struct DenyConf {
87   struct DenyConf*    next;
88   char*               hostmask;
89   char*               message;
90   char*               usermask;
91   struct irc_in_addr  address;
92   unsigned int        flags;
93   unsigned char       bits;        /* Number of bits for ipkills */
94 };
95
96 #define DENY_FLAGS_FILE     0x0001 /* Comment is a filename */
97 #define DENY_FLAGS_IP       0x0002 /* K-line by IP address */
98 #define DENY_FLAGS_REALNAME 0x0004 /* K-line by real name */
99
100 /*
101  * A line: A:<line 1>:<line 2>:<line 3>
102  */
103 struct LocalConf {
104   char*          name;
105   char*          description;
106   struct irc_in_addr vhost_address;
107   unsigned int   numeric;
108   char*          location1;
109   char*          location2;
110   char*          contact;
111 };
112
113 struct MotdItem {
114   char line[82];
115   struct MotdItem *next;
116 };
117
118 struct MotdConf {
119   struct MotdConf* next;
120   char* hostmask;
121   char* path;
122 };
123
124 enum {
125   CRULE_AUTO = 1,
126   CRULE_ALL  = 2,
127   CRULE_MASK = 3
128 };
129
130 struct CRuleNode;
131
132 struct CRuleConf {
133   struct CRuleConf* next;
134   char*             hostmask;
135   char*             rule;
136   int               type;
137   struct CRuleNode* node;
138 };
139
140 struct TRecord {
141   struct TRecord *next;
142   char *hostmask;
143   struct MotdItem *tmotd;
144   struct tm tmotd_tm;
145 };
146
147 enum AuthorizationCheckResult {
148   ACR_OK,
149   ACR_NO_AUTHORIZATION,
150   ACR_TOO_MANY_IN_CLASS,
151   ACR_TOO_MANY_FROM_IP,
152   ACR_ALREADY_AUTHORIZED,
153   ACR_BAD_SOCKET
154 };
155
156 struct nick_host {
157   struct nick_host *next;
158   int nicklen; /* offset of @ part of server string */
159   char nick[1]; /* start of nick@server string */
160 };
161
162 struct s_map {
163   struct s_map *next;
164   struct Message *msg;
165   char *name;
166   char *command;
167   char *prepend;
168   struct nick_host *services;
169 };
170
171
172 /*
173  * GLOBALS
174  */
175 extern struct ConfItem* GlobalConfList;
176 extern int              GlobalConfCount;
177 extern struct tm        motd_tm;
178 extern struct MotdItem* motd;
179 extern struct MotdItem* rmotd;
180 extern struct TRecord*  tdata;
181 extern struct s_map*    GlobalServiceMapList;
182 extern struct qline*    GlobalQuarantineList;
183
184 /*
185  * Proto types
186  */
187
188 extern int init_conf(void);
189
190 extern const struct LocalConf* conf_get_local(void);
191 extern const struct MotdConf*  conf_get_motd_list(void);
192 extern const struct CRuleConf* conf_get_crule_list(void);
193 extern const struct DenyConf*  conf_get_deny_list(void);
194
195 extern const char* conf_eval_crule(const char* name, int mask);
196
197 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
198 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
199 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
200 extern struct ConfItem* conf_find_server(const char* name);
201
202 extern void det_confs_butmask(struct Client *cptr, int mask);
203 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
204 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
205                                         const char* host, int statmask);
206 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
207 extern int  conf_check_server(struct Client *cptr);
208 extern struct ConfItem* find_conf_name(const char* name, int statmask);
209 extern int rehash(struct Client *cptr, int sig);
210 extern void read_tlines(void);
211 extern int find_kill(struct Client *cptr);
212 extern int find_restrict(struct Client *cptr);
213 extern struct MotdItem* read_motd(const char* motdfile);
214 extern const char *find_quarantine(const char* chname);
215 extern void lookup_confhost(struct ConfItem *aconf);
216
217 extern void yyerror(const char *msg);
218
219 #endif /* INCLUDED_s_conf_h */