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