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_LEAF               0x1000
41 #define CONF_HUB                0x4000
42 #define CONF_UWORLD             0x8000
43
44 #define CONF_OPS                (CONF_OPERATOR | CONF_LOCOP)
45 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPS | CONF_SERVER)
46
47 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
48
49 /*
50  * Structures
51  */
52
53 struct ConfItem {
54   struct ConfItem*         next;
55   unsigned int             status;      /* If CONF_ILLEGAL, delete when no clients */
56   unsigned int             clients;     /* Number of *LOCAL* clients using this */
57   struct ConnectionClass*  conn_class;  /* Class of connection */
58   struct in_addr           ipnum;       /* ip number of host field */
59   char*                    host;
60   char*                    passwd;
61   char*                    name;
62   time_t                   hold;        /* Hold until this time (calendar time) */
63   int                      dns_pending; /* a dns request is pending */
64   unsigned short           port;
65   char                     bits;        /* Number of bits for ipkills */
66 };
67
68 struct ServerConf {
69   struct ServerConf* next;
70   char*              hostname;
71   char*              passwd;
72   char*              alias;
73   struct in_addr     address;
74   int                port;
75   int                dns_pending;
76   int                connected;
77   time_t             hold;
78   struct ConnectionClass*  conn_class;
79 };
80
81 struct DenyConf {
82   struct DenyConf*    next;
83   char*               hostmask;
84   char*               message;
85   char*               usermask;
86   unsigned int        s_addr;
87   char                is_file;
88   char                ip_kill;
89   char                bits;        /* Number of bits for ipkills */
90 };
91
92 /*
93  * A line: A:<line 1>:<line 2>:<line 3>
94  */
95 struct LocalConf {
96   char*          name;
97   char*          description;
98   struct in_addr vhost_address;
99   unsigned int   numeric;
100   char*          location1;
101   char*          location2;
102   char*          contact;
103 };
104
105 struct MotdItem {
106   char line[82];
107   struct MotdItem *next;
108 };
109
110 struct MotdConf {
111   struct MotdConf* next;
112   char* hostmask;
113   char* path;
114 };
115
116 enum {
117   CRULE_AUTO = 1,
118   CRULE_ALL  = 2,
119   CRULE_MASK = 3
120 };
121
122 struct CRuleNode;
123
124 struct CRuleConf {
125   struct CRuleConf* next;
126   char*             hostmask;
127   char*             rule;
128   int               type;
129   struct CRuleNode* node;
130 };
131
132 struct TRecord {
133   struct TRecord *next;
134   char *hostmask;
135   struct MotdItem *tmotd;
136   struct tm tmotd_tm;
137 };
138
139 enum AuthorizationCheckResult {
140   ACR_OK,
141   ACR_NO_AUTHORIZATION,
142   ACR_TOO_MANY_IN_CLASS,
143   ACR_TOO_MANY_FROM_IP,
144   ACR_ALREADY_AUTHORIZED,
145   ACR_BAD_SOCKET
146 };
147
148 /*
149  * GLOBALS
150  */
151 extern struct ConfItem* GlobalConfList;
152 extern int              GlobalConfCount;
153 extern struct tm        motd_tm;
154 extern struct MotdItem* motd;
155 extern struct MotdItem* rmotd;
156 extern struct TRecord*  tdata;
157
158 /*
159  * Proto types
160  */
161
162 extern int init_conf(void);
163
164 extern const struct LocalConf* conf_get_local(void);
165 extern const struct MotdConf*  conf_get_motd_list(void);
166 extern const struct CRuleConf* conf_get_crule_list(void);
167 extern const struct DenyConf*  conf_get_deny_list(void);
168
169 extern const char* conf_eval_crule(const char* name, int mask);
170
171 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
172 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
173 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
174 extern struct ConfItem* conf_find_server(const char* name);
175
176 extern void det_confs_butmask(struct Client *cptr, int mask);
177 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
178 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
179                                         const char* host, int statmask);
180 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
181 extern int  conf_check_server(struct Client *cptr);
182 extern struct ConfItem* find_conf_name(const char* name, int statmask);
183 extern int rehash(struct Client *cptr, int sig);
184 extern void read_tlines(void);
185 extern int find_kill(struct Client *cptr);
186 extern int find_restrict(struct Client *cptr);
187 extern struct MotdItem* read_motd(const char* motdfile);
188
189 #endif /* INCLUDED_s_conf_h */