]>
Commit | Line | Data |
---|---|---|
3bd189cb JR |
1 | /************************************************************************ |
2 | * IRC - Internet Relay Chat, common/struct_def.h | |
3 | * Copyright (C) 1990 Jarkko Oikarinen and | |
4 | * University of Oulu, Computing Center | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 1, or (at your option) | |
9 | * any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | * | |
20 | * $Id: struct_def.h,v 1.150 2008/06/10 02:26:58 chopin Exp $ | |
21 | */ | |
22 | ||
23 | typedef struct ConfItem aConfItem; | |
24 | typedef struct ListItem aListItem; | |
25 | typedef struct Client aClient; | |
26 | typedef struct Channel aChannel; | |
27 | typedef struct User anUser; | |
28 | typedef struct Server aServer; | |
29 | typedef struct Service aService; | |
30 | typedef struct SLink Link; | |
31 | typedef struct invSLink invLink; | |
32 | typedef struct SMode Mode; | |
33 | typedef struct fdarray FdAry; | |
34 | typedef struct CPing aCPing; | |
35 | typedef struct Zdata aZdata; | |
36 | typedef struct LineItem aMotd; | |
37 | #if defined(USE_IAUTH) | |
38 | typedef struct LineItem aExtCf; | |
39 | typedef struct LineItem aExtData; | |
40 | #endif | |
41 | ||
42 | #define HOSTLEN 63 /* Length of hostname. Updated to */ | |
43 | /* comply with RFC1123 */ | |
44 | ||
45 | #if defined(INET6) && (INET6_ADDRSTRLEN > HOSTLEN) | |
46 | #error HOSTLEN must not be smaller than INET6_ADDRSTRLEN | |
47 | #endif | |
48 | ||
49 | #define NICKLEN 15 /* Must be the same network-wide. */ | |
50 | #define UIDLEN 9 /* must not be bigger than NICKLEN --Beeth */ | |
51 | #define USERLEN 10 | |
52 | #define REALLEN 50 | |
53 | #define TOPICLEN 255 | |
54 | #define CHANNELLEN 50 | |
55 | #define PASSWDLEN 20 | |
56 | #define KEYLEN 23 | |
57 | #define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ | |
58 | #define MAXRECIPIENTS 20 | |
59 | #define MAXBANS 64 | |
60 | #define MAXBANLENGTH 2048 | |
61 | #define BANLEN (USERLEN + NICKLEN + HOSTLEN + 3) | |
62 | #define MAXPENALTY 10 | |
63 | #define CHIDLEN 5 /* WARNING: *DONT* CHANGE THIS!!!! */ | |
64 | #define SIDLEN 4 /* WARNING: *DONT* CHANGE THIS!!!! */ | |
65 | #define MAXMODEPARAMS 3 /* WARNING: *DONT* CHANGE THIS!!!! */ | |
66 | #define DELAYCHASETIMELIMIT 1800 /* WARNING: *DONT* CHANGE THIS!!!! */ | |
67 | #define LDELAYCHASETIMELIMIT 5400 /* WARNING: *DONT* CHANGE THIS!!!! */ | |
68 | ||
69 | #define READBUF_SIZE 16384 /* used in s_bsd.c *AND* s_zip.c ! */ | |
70 | ||
71 | /* | |
72 | * Make up some numbers which should reflect average leaf server connect | |
73 | * queue max size. | |
74 | * queue=(<# of channels> * <channel size> + <user size> * <# of users>) * 2 | |
75 | * pool=<queue per client> * <avg. # of clients having data in queue> | |
76 | */ | |
77 | #define QUEUELEN (((MAXCONNECTIONS / 10) * (CHANNELLEN + BANLEN + 16) +\ | |
78 | (HOSTLEN * 4 + REALLEN + NICKLEN + USERLEN + 24) *\ | |
79 | (MAXCONNECTIONS / 2)) * 2) | |
80 | ||
81 | #define BUFFERPOOL (DBUFSIZ * MAXCONNECTIONS * 2) + \ | |
82 | (QUEUELEN * MAXSERVERS) | |
83 | ||
84 | #define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) | |
85 | ||
86 | /* | |
87 | ** 'offsetof' is defined in ANSI-C. The following definition | |
88 | ** is not absolutely portable (I have been told), but so far | |
89 | ** it has worked on all machines I have needed it. The type | |
90 | ** should be size_t but... --msa | |
91 | */ | |
92 | #ifndef offsetof | |
93 | #define offsetof(t,m) (int)((&((t *)0L)->m)) | |
94 | #endif | |
95 | ||
96 | #define elementsof(x) (sizeof(x)/sizeof(x[0])) | |
97 | ||
98 | /* | |
99 | ** flags for bootup options (command line flags) | |
100 | */ | |
101 | #define BOOT_CONSOLE 0x001 | |
102 | #define BOOT_QUICK 0x002 | |
103 | #define BOOT_DEBUG 0x004 | |
104 | #define BOOT_INETD 0x008 | |
105 | #define BOOT_TTY 0x010 | |
106 | ||
107 | #define BOOT_AUTODIE 0x040 | |
108 | #define BOOT_BADTUNE 0x080 | |
109 | #define BOOT_PROT 0x100 | |
110 | #define BOOT_STRICTPROT 0x200 | |
111 | #define BOOT_NOIAUTH 0x400 | |
112 | #define BOOT_STANDALONE 0x800 | |
113 | ||
114 | typedef enum Status { | |
115 | STAT_CONNECTING = -4, | |
116 | STAT_HANDSHAKE, /* -3 */ | |
117 | STAT_UNKNOWN, /* -2 */ | |
118 | STAT_ME, /* -1 */ | |
119 | STAT_SERVER, /* 0 */ | |
120 | STAT_CLIENT, /* 1 */ | |
121 | STAT_OPER, /* 2 */ | |
122 | STAT_SERVICE, /* 3 */ | |
123 | STAT_UNREG, /* 4 */ | |
124 | STAT_MAX /* 5 -- size of handler[] table we need */ | |
125 | } Status; | |
126 | ||
127 | /* | |
128 | * status macros. | |
129 | */ | |
130 | #define IsRegisteredUser(x) (((x)->status == STAT_CLIENT || \ | |
131 | (x)->status == STAT_OPER) && (x)->user) | |
132 | #define IsRegistered(x) ((x)->status >= STAT_SERVER || \ | |
133 | (x)->status == STAT_ME) | |
134 | #define IsConnecting(x) ((x)->status == STAT_CONNECTING) | |
135 | #define IsHandshake(x) ((x)->status == STAT_HANDSHAKE) | |
136 | #define IsMe(x) ((x)->status == STAT_ME) | |
137 | #define IsUnknown(x) ((x)->status == STAT_UNKNOWN) | |
138 | #define IsServer(x) ((x)->status == STAT_SERVER) | |
139 | #define IsClient(x) ((x)->status == STAT_CLIENT || \ | |
140 | (x)->status == STAT_OPER) | |
141 | #define IsService(x) ((x)->status == STAT_SERVICE && (x)->service) | |
142 | ||
143 | #define SetConnecting(x) ((x)->status = STAT_CONNECTING) | |
144 | #define SetHandshake(x) ((x)->status = STAT_HANDSHAKE) | |
145 | #define SetMe(x) ((x)->status = STAT_ME) | |
146 | #define SetUnknown(x) ((x)->status = STAT_UNKNOWN) | |
147 | #define SetServer(x) ((x)->status = STAT_SERVER) | |
148 | #define SetClient(x) ((x)->status = IsAnOper((x)) ? STAT_OPER : STAT_CLIENT) | |
149 | #define SetService(x) ((x)->status = STAT_SERVICE) | |
150 | ||
151 | #define FLAGS_PINGSENT 0x0000001 /* Unreplied ping sent */ | |
152 | #define FLAGS_DEADSOCK 0x0000002 /* Local socket is dead--Exiting soon */ | |
153 | #define FLAGS_KILLED 0x0000004 /* Prevents "QUIT" from being sent for this */ | |
154 | #define FLAGS_BLOCKED 0x0000008 /* socket is in blocked condition [unused] */ | |
155 | #ifdef UNIXPORT | |
156 | #define FLAGS_UNIX 0x0000010 /* socket is in the unix domain, not inet */ | |
157 | #endif | |
158 | #define FLAGS_CLOSING 0x0000020 /* set when closing to suppress errors */ | |
159 | #define FLAGS_LISTEN 0x0000040 /* used to mark clients which we listen() on */ | |
160 | #define FLAGS_XAUTHDONE 0x0000080 /* iauth is finished with this client */ | |
161 | #define FLAGS_DOINGDNS 0x0000100 /* client is waiting for a DNS response */ | |
162 | #define FLAGS_AUTH 0x0000200 /* client is waiting on rfc931 response */ | |
163 | #define FLAGS_WRAUTH 0x0000400 /* set if we havent writen to ident server */ | |
164 | #define FLAGS_LOCAL 0x0000800 /* set for local clients */ | |
165 | #define FLAGS_GOTID 0x0001000 /* successful ident lookup achieved */ | |
166 | #define FLAGS_XAUTH 0x0002000 /* waiting on external authentication */ | |
167 | #define FLAGS_WXAUTH 0x0004000 /* same as above, but also prevent parsing */ | |
168 | #define FLAGS_NONL 0x0008000 /* No \n in buffer */ | |
169 | #define FLAGS_CBURST 0x0010000 /* set to mark connection burst being sent */ | |
170 | #define FLAGS_QUIT 0x0040000 /* QUIT :comment shows it's not a split */ | |
171 | #define FLAGS_SPLIT 0x0080000 /* client QUITting because of a netsplit */ | |
172 | #define FLAGS_HIDDEN 0x0100000 /* netsplit is behind a hostmask, | |
173 | also used for marking clients in who_find | |
174 | */ | |
175 | #define FLAGS_UNKCMD 0x0200000 /* has sent an unknown command */ | |
176 | #define FLAGS_ZIP 0x0400000 /* link is zipped */ | |
177 | #define FLAGS_ZIPRQ 0x0800000 /* zip requested */ | |
178 | #define FLAGS_ZIPSTART 0x1000000 /* start of zip (ignore any CRLF) */ | |
179 | #define FLAGS_SQUIT 0x2000000 /* This is set when we send the last | |
180 | ** server, so we know we have to send | |
181 | ** a SQUIT. */ | |
182 | #define FLAGS_EOB 0x4000000 /* EOB received */ | |
183 | #define FLAGS_LISTENINACTIVE 0x8000000 /* Listener does not listen() */ | |
184 | #ifdef JAPANESE | |
185 | #define FLAGS_JP 0x10000000 /* jp version, used both for chans and servs */ | |
186 | #endif | |
187 | ||
188 | #define FLAGS_OPER 0x0001 /* operator */ | |
189 | #define FLAGS_LOCOP 0x0002 /* local operator -- SRB */ | |
190 | #define FLAGS_WALLOP 0x0004 /* send wallops to them */ | |
191 | #define FLAGS_INVISIBLE 0x0008 /* makes user invisible */ | |
192 | #define FLAGS_RESTRICT 0x0010 /* restricted user */ | |
193 | #define FLAGS_AWAY 0x0020 /* user is away */ | |
194 | #define FLAGS_EXEMPT 0x0040 /* user is exempted from k-lines */ | |
195 | #ifdef XLINE | |
196 | #define FLAGS_XLINED 0x0100 /* X-lined client */ | |
197 | #endif | |
198 | #define SEND_UMODES (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP|FLAGS_AWAY|FLAGS_RESTRICT) | |
199 | #define ALL_UMODES (SEND_UMODES|FLAGS_LOCOP) | |
200 | ||
201 | /* | |
202 | * user flags macros. | |
203 | */ | |
204 | #define IsOper(x) ((x)->user && (x)->user->flags & FLAGS_OPER) | |
205 | #define IsLocOp(x) ((x)->user && (x)->user->flags & FLAGS_LOCOP) | |
206 | #define IsInvisible(x) ((x)->user->flags & FLAGS_INVISIBLE) | |
207 | #define IsRestricted(x) ((x)->user && \ | |
208 | (x)->user->flags & FLAGS_RESTRICT) | |
209 | #define IsAnOper(x) ((x)->user && \ | |
210 | (x)->user->flags & (FLAGS_OPER|FLAGS_LOCOP)) | |
211 | #define IsPerson(x) ((x)->user && IsClient(x)) | |
212 | #define IsPrivileged(x) (IsServer(x) || IsAnOper(x)) | |
213 | #define SendWallops(x) ((x)->user->flags & FLAGS_WALLOP) | |
214 | #ifdef UNIXPORT | |
215 | #define IsUnixSocket(x) ((x)->flags & FLAGS_UNIX) | |
216 | #endif | |
217 | #define IsListener(x) ((x)->flags & FLAGS_LISTEN) | |
218 | #define IsListenerInactive(x) ((x)->flags & FLAGS_LISTENINACTIVE) | |
219 | #define IsLocal(x) (MyConnect(x) && (x)->flags & FLAGS_LOCAL) | |
220 | #define IsDead(x) ((x)->flags & FLAGS_DEADSOCK) | |
221 | #define IsBursting(x) (!((x)->flags & FLAGS_EOB)) | |
222 | #define IsKlineExempt(x) ((x)->user && (x)->user->flags & FLAGS_EXEMPT) | |
223 | ||
224 | #define SetDead(x) ((x)->flags |= FLAGS_DEADSOCK) | |
225 | #define CBurst(x) ((x)->flags & FLAGS_CBURST) | |
226 | #define SetOper(x) ((x)->user->flags |= FLAGS_OPER, \ | |
227 | (x)->status = STAT_OPER) | |
228 | #define SetLocOp(x) ((x)->user->flags |= FLAGS_LOCOP, \ | |
229 | (x)->status = STAT_OPER) | |
230 | #define SetInvisible(x) ((x)->user->flags |= FLAGS_INVISIBLE) | |
231 | #define SetRestricted(x) ((x)->user->flags |= FLAGS_RESTRICT) | |
232 | #define SetWallops(x) ((x)->user->flags |= FLAGS_WALLOP) | |
233 | #ifdef UNIXPORT | |
234 | #define SetUnixSock(x) ((x)->flags |= FLAGS_UNIX) | |
235 | #endif | |
236 | #define SetDNS(x) ((x)->flags |= FLAGS_DOINGDNS) | |
237 | #define SetDoneXAuth(x) ((x)->flags |= FLAGS_XAUTHDONE) | |
238 | #define SetEOB(x) ((x)->flags |= FLAGS_EOB) | |
239 | #define SetListenerInactive(x) ((x)->flags |= FLAGS_LISTENINACTIVE) | |
240 | #define SetKlineExempt(x) ((x)->user->flags |= FLAGS_EXEMPT) | |
241 | ||
242 | #define DoingDNS(x) ((x)->flags & FLAGS_DOINGDNS) | |
243 | #define DoingAuth(x) ((x)->flags & FLAGS_AUTH) | |
244 | #define DoingXAuth(x) ((x)->flags & FLAGS_XAUTH) | |
245 | #define WaitingXAuth(x) ((x)->flags & FLAGS_WXAUTH) | |
246 | #define DoneXAuth(x) ((x)->flags & FLAGS_XAUTHDONE) | |
247 | #define NoNewLine(x) ((x)->flags & FLAGS_NONL) | |
248 | ||
249 | #define ClearOper(x) ((x)->user->flags &= ~FLAGS_OPER, \ | |
250 | (x)->status = STAT_CLIENT) | |
251 | #define ClearLocOp(x) ((x)->user->flags &= ~FLAGS_LOCOP, \ | |
252 | (x)->status = STAT_CLIENT) | |
253 | #define ClearInvisible(x) ((x)->user->flags &= ~FLAGS_INVISIBLE) | |
254 | #define ClearRestricted(x) ((x)->user->flags &= ~FLAGS_RESTRICT) | |
255 | #define ClearWallops(x) ((x)->user->flags &= ~FLAGS_WALLOP) | |
256 | #define ClearDNS(x) ((x)->flags &= ~FLAGS_DOINGDNS) | |
257 | #define ClearAuth(x) ((x)->flags &= ~FLAGS_AUTH) | |
258 | #define ClearXAuth(x) ((x)->flags &= ~FLAGS_XAUTH) | |
259 | #define ClearWXAuth(x) ((x)->flags &= ~FLAGS_WXAUTH) | |
260 | #define ClearListenerInactive(x) ((x)->flags &= ~FLAGS_LISTENINACTIVE) | |
261 | #ifdef XLINE | |
262 | #define IsXlined(x) ((x)->user && (x)->user->flags & FLAGS_XLINED) | |
263 | #define SetXlined(x) ((x)->user->flags |= FLAGS_XLINED) | |
264 | #define ClearXlined(x) ((x)->user->flags &= ~FLAGS_XLINED) | |
265 | #endif | |
266 | ||
267 | ||
268 | /* | |
269 | * defined debugging levels | |
270 | */ | |
271 | #define DEBUG_FATAL 0 | |
272 | #define DEBUG_ERROR 1 /* report_error() and other errors that are found */ | |
273 | #define DEBUG_READ 2 | |
274 | #define DEBUG_WRITE 2 | |
275 | #define DEBUG_NOTICE 3 | |
276 | #define DEBUG_DNS 4 /* used by all DNS related routines - a *lot* */ | |
277 | #define DEBUG_INFO 5 /* general usful info */ | |
278 | #define DEBUG_NUM 6 /* numerics */ | |
279 | #define DEBUG_SEND 7 /* everything that is sent out */ | |
280 | #define DEBUG_DEBUG 8 /* anything to do with debugging, ie unimportant :) */ | |
281 | #define DEBUG_MALLOC 9 /* malloc/free calls */ | |
282 | #define DEBUG_LIST 10 /* debug list use */ | |
283 | #define DEBUG_L10 10 | |
284 | #define DEBUG_L11 11 | |
285 | ||
286 | /* | |
287 | * defines for curses in client | |
288 | */ | |
289 | #define DUMMY_TERM 0 | |
290 | #define CURSES_TERM 1 | |
291 | #define TERMCAP_TERM 2 | |
292 | ||
293 | struct CPing { | |
294 | u_short port; /* port to send pings to */ | |
295 | u_long rtt; /* average RTT */ | |
296 | u_long ping; | |
297 | u_long seq; /* # sent still in the "window" */ | |
298 | u_long lseq; /* sequence # of last sent */ | |
299 | u_long recvd; /* # received still in the "window" */ | |
300 | u_long lrecvd; /* # received */ | |
301 | }; | |
302 | ||
303 | struct ConfItem { | |
304 | u_int status; /* If CONF_ILLEGAL, delete when no clients */ | |
305 | int clients; /* Number of *LOCAL* clients using this */ | |
306 | struct IN_ADDR ipnum; /* ip number of host field */ | |
307 | char *host; | |
308 | char *passwd; | |
309 | char *name; | |
310 | char *name2; | |
311 | #ifdef XLINE | |
312 | char *name3; | |
313 | #endif | |
314 | int port; | |
315 | long flags; /* I-line flags */ | |
316 | int pref; /* preference value */ | |
317 | struct CPing *ping; | |
318 | time_t hold; /* Hold action until this time (calendar time) */ | |
319 | char *source_ip; | |
320 | #ifndef VMSP | |
321 | aClass *class; /* Class of connection */ | |
322 | #endif | |
323 | struct ConfItem *next; | |
324 | }; | |
325 | ||
326 | struct ListItem { | |
327 | char *nick; | |
328 | char *user; | |
329 | char *host; | |
330 | }; | |
331 | ||
332 | /* these define configuration lines (A:, M:, I:, K:, etc.) */ | |
333 | #define CONF_ILLEGAL 0x80000000 | |
334 | #define CONF_MATCH 0x40000000 | |
335 | #define CONF_QUARANTINED_SERVER 0x000001 | |
336 | #define CONF_CLIENT 0x000002 | |
337 | ||
338 | #define CONF_CONNECT_SERVER 0x000008 | |
339 | #define CONF_NOCONNECT_SERVER 0x000010 | |
340 | #define CONF_ZCONNECT_SERVER 0x000020 | |
341 | ||
342 | #define CONF_OPERATOR 0x000080 | |
343 | #define CONF_ME 0x000100 | |
344 | #define CONF_KILL 0x000200 | |
345 | #define CONF_ADMIN 0x000400 | |
346 | #define CONF_CLASS 0x001000 | |
347 | #define CONF_SERVICE 0x002000 | |
348 | #define CONF_LEAF 0x004000 | |
349 | #define CONF_LISTEN_PORT 0x008000 | |
350 | #define CONF_HUB 0x010000 | |
351 | #define CONF_VER 0x020000 | |
352 | #define CONF_BOUNCE 0x040000 | |
353 | #define CONF_OTHERKILL 0x080000 | |
354 | #define CONF_DENY 0x100000 | |
355 | #ifdef TKLINE | |
356 | #define CONF_TKILL 0x200000 | |
357 | #define CONF_TOTHERKILL 0x400000 | |
358 | #endif | |
359 | #ifdef XLINE | |
360 | #define CONF_XLINE 0x800000 | |
361 | #endif | |
362 | #define CONF_OPS CONF_OPERATOR | |
363 | #define CONF_SERVER_MASK (CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER |\ | |
364 | CONF_ZCONNECT_SERVER) | |
365 | #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_SERVICE | CONF_OPS | \ | |
366 | CONF_SERVER_MASK) | |
367 | ||
368 | #define CFLAG_RESTRICTED 0x00001 | |
369 | #define CFLAG_RNODNS 0x00002 | |
370 | #define CFLAG_RNOIDENT 0x00004 | |
371 | #define CFLAG_KEXEMPT 0x00008 | |
372 | #define CFLAG_NORESOLVE 0x00010 | |
373 | #define CFLAG_FALL 0x00020 | |
374 | #define CFLAG_NORESOLVEMATCH 0x00040 | |
375 | #ifdef XLINE | |
376 | #define CFLAG_XEXEMPT 0x00080 | |
377 | #endif | |
378 | ||
379 | #define IsConfRestricted(x) ((x)->flags & CFLAG_RESTRICTED) | |
380 | #define IsConfRNoDNS(x) ((x)->flags & CFLAG_RNODNS) | |
381 | #define IsConfRNoIdent(x) ((x)->flags & CFLAG_RNOIDENT) | |
382 | #define IsConfKlineExempt(x) ((x)->flags & CFLAG_KEXEMPT) | |
383 | #define IsConfNoResolve(x) ((x)->flags & CFLAG_NORESOLVE) | |
384 | #define IsConfNoResolveMatch(x) ((x)->flags & CFLAG_NORESOLVEMATCH) | |
385 | #define IsConfFallThrough(x) ((x)->flags & CFLAG_FALL) | |
386 | #ifdef XLINE | |
387 | #define IsConfXlineExempt(x) ((x)->flags & CFLAG_XEXEMPT) | |
388 | #endif | |
389 | ||
390 | #define PFLAG_DELAYED 0x00001 | |
391 | #define PFLAG_SERVERONLY 0x00002 | |
392 | ||
393 | #define IsConfDelayed(x) ((x)->flags & PFLAG_DELAYED) | |
394 | #define IsConfServeronly(x) ((x)->flags & PFLAG_SERVERONLY) | |
395 | ||
396 | #define IsIllegal(x) ((x)->status & CONF_ILLEGAL) | |
397 | ||
398 | typedef struct { | |
399 | u_long pi_id; | |
400 | u_long pi_seq; | |
401 | struct timeval pi_tv; | |
402 | aConfItem *pi_cp; | |
403 | } Ping; | |
404 | ||
405 | ||
406 | #define PING_REPLY 0x01 | |
407 | #define PING_CPING 0x02 | |
408 | ||
409 | #ifdef ZIP_LINKS | |
410 | /* the minimum amount of data needed to trigger compression */ | |
411 | # define ZIP_MINIMUM 4096 | |
412 | ||
413 | /* the maximum amount of data to be compressed (can actually be a bit more) */ | |
414 | # define ZIP_MAXIMUM 8192 /* WARNING: *DON'T* CHANGE THIS!!!! */ | |
415 | ||
416 | struct Zdata { | |
417 | z_stream *in; /* input zip stream data */ | |
418 | z_stream *out; /* output zip stream data */ | |
419 | Bytef outbuf[ZIP_MAXIMUM]; /* outgoing (unzipped) buffer */ | |
420 | int outcount; /* size of outbuf content */ | |
421 | }; | |
422 | #endif | |
423 | ||
424 | struct LineItem | |
425 | { | |
426 | char *line; | |
427 | struct LineItem *next; | |
428 | }; | |
429 | ||
430 | /* | |
431 | * Client structures | |
432 | */ | |
433 | struct User { | |
434 | Link *channel; /* chain of channel pointer blocks */ | |
435 | invLink *invited; /* chain of invite pointer blocks */ | |
436 | Link *uwas; /* chain of whowas pointer blocks */ | |
437 | char *away; /* pointer to away message */ | |
438 | time_t last; /* "idle" time */ | |
439 | int refcnt; /* Number of times this block is referenced | |
440 | ** from aClient (field user), aServer (field | |
441 | ** by) and whowas array (field ww_user). | |
442 | */ | |
443 | int joined; /* number of channels joined */ | |
444 | int flags; /* user modes */ | |
445 | struct Server *servp; | |
446 | /* | |
447 | ** In a perfect world the 'server' name | |
448 | ** should not be needed, a pointer to the | |
449 | ** client describing the server is enough. | |
450 | ** Unfortunately, in reality, server may | |
451 | ** not yet be in links while USER is | |
452 | ** introduced... --msa | |
453 | ** I think it's not true anymore --Beeth | |
454 | */ | |
455 | u_int hashv; | |
456 | aClient *uhnext; | |
457 | aClient *bcptr; | |
458 | char username[USERLEN+1]; | |
459 | char uid[UIDLEN+1]; | |
460 | char host[HOSTLEN+1]; | |
461 | char *server; | |
462 | u_int hhashv; /* hostname hash value */ | |
463 | u_int iphashv; /* IP hash value */ | |
464 | struct User *hhnext; /* next entry in hostname hash */ | |
465 | struct User *iphnext; /* next entry in IP hash */ | |
466 | /* sip MUST be the last in this struct!!! */ | |
467 | char sip[1]; /* ip as a string, big enough for ipv6 | |
468 | * allocated to real size in make_user */ | |
469 | ||
470 | }; | |
471 | ||
472 | struct Server { | |
473 | char namebuf[HOSTLEN+1]; | |
474 | anUser *user; /* who activated this connection */ | |
475 | aClient *up; /* uplink for this server */ | |
476 | aConfItem *nline; /* N-line pointer for this server */ | |
477 | int version; /* version id for local client */ | |
478 | int snum; | |
479 | int refcnt; /* Number of times this block is referenced | |
480 | ** from anUser (field servp), aService (field | |
481 | ** servp) and aClient (field serv) */ | |
482 | int usercnt[3]; /* # of clients - visible, invisible, opers */ | |
483 | struct Server *nexts, *prevs, *shnext; | |
484 | aClient *bcptr; | |
485 | aClient *maskedby; /* Pointer to server masking this server. | |
486 | ** Self if not masked, *NEVER* NULL. */ | |
487 | char by[NICKLEN+1]; | |
488 | char byuid[UIDLEN + 1]; | |
489 | char sid[SIDLEN + 1];/* The Server ID. */ | |
490 | char verstr[11]; /* server version, PATCHLEVEL format */ | |
491 | u_int sidhashv; /* Raw hash value. */ | |
492 | aServer *sidhnext; /* Next server in the sid hash. */ | |
493 | time_t lastload; /* penalty like counters, see s_serv.c | |
494 | ** should be in the local part, but.. */ | |
495 | int servers; /* Number of downlinks of this server. */ | |
496 | aClient *left, *right; /* Left and right nodes in server tree. */ | |
497 | aClient *down; /* Ptr to first downlink of this server. */ | |
498 | }; | |
499 | ||
500 | struct Service { | |
501 | char namebuf[HOSTLEN+1]; | |
502 | int wants; | |
503 | int type; | |
504 | char *server; | |
505 | aServer *servp; | |
506 | struct Service *nexts, *prevs; | |
507 | aClient *bcptr; | |
508 | char dist[HOSTLEN+1]; | |
509 | }; | |
510 | ||
511 | struct Client { | |
512 | struct Client *next,*prev, *hnext; | |
513 | anUser *user; /* ...defined, if this is a User */ | |
514 | aServer *serv; /* ...defined, if this is a server */ | |
515 | aService *service; | |
516 | u_int hashv; /* raw hash value */ | |
517 | long flags; /* client flags */ | |
518 | aClient *from; /* == self, if Local Client, *NEVER* NULL! */ | |
519 | int fd; /* >= 0, for local clients */ | |
520 | int hopcount; /* number of servers to this 0 = local */ | |
521 | short status; /* Client type */ | |
522 | char *name; /* Pointer to unique name of the client */ | |
523 | char namebuf[NICKLEN+1]; /* nick of the client */ | |
524 | char username[USERLEN+1]; /* username here now for auth stuff */ | |
525 | char *info; /* Free form additional client information */ | |
526 | /* | |
527 | ** The following fields are allocated only for local clients | |
528 | ** (directly connected to *this* server with a socket. | |
529 | ** The first of them *MUST* be the "count"--it is the field | |
530 | ** to which the allocation is tied to! *Never* refer to | |
531 | ** these fields, if (from != self). | |
532 | */ | |
533 | int count; /* Amount of data in buffer */ | |
534 | char buffer[BUFSIZE]; /* Incoming message buffer */ | |
535 | #ifdef ZIP_LINKS | |
536 | aZdata *zip; /* zip data */ | |
537 | #endif | |
538 | short lastsq; /* # of 2k blocks when sendqueued called last*/ | |
539 | dbuf sendQ; /* Outgoing message queue--if socket full */ | |
540 | dbuf recvQ; /* Hold for data incoming yet to be parsed */ | |
541 | long sendM; /* Statistics: protocol messages send */ | |
542 | long receiveM; /* Statistics: protocol messages received */ | |
543 | unsigned long long sendB; /* Statistics: total bytes send */ | |
544 | unsigned long long receiveB; /* Statistics: total bytes received */ | |
545 | time_t lasttime; /* last time we received data */ | |
546 | time_t firsttime; /* time client was created */ | |
547 | time_t since; /* last time we parsed something */ | |
548 | aClient *acpt; /* listening client which we accepted from */ | |
549 | Link *confs; /* Configuration record associated */ | |
550 | int ping; | |
551 | int authfd; /* fd for rfc931 authentication */ | |
552 | char *auth; | |
553 | u_short port; /* and the remote port# too :-) */ | |
554 | struct IN_ADDR ip; /* keep real ip# too */ | |
555 | struct hostent *hostp; | |
556 | char sockhost[HOSTLEN+1]; /* This is the host name from the socket | |
557 | ** and after which the connection was | |
558 | ** accepted. | |
559 | */ | |
560 | char passwd[PASSWDLEN+1]; | |
561 | char exitc; | |
562 | char *reason; /* additional exit message */ | |
563 | #ifdef XLINE | |
564 | /* Those logically should be in anUser struct, but would be null for | |
565 | ** all remote users... so better waste two pointers for all local | |
566 | ** non-users than two pointers for all remote users. --B. */ | |
567 | char *user2; /* 2nd param of USER */ | |
568 | char *user3; /* 3rd param of USER */ | |
569 | #endif | |
570 | ||
571 | }; | |
572 | ||
573 | #define CLIENT_LOCAL_SIZE sizeof(aClient) | |
574 | #define CLIENT_REMOTE_SIZE offsetof(aClient,count) | |
575 | ||
576 | /* | |
577 | * statistics structures | |
578 | */ | |
579 | struct stats { | |
580 | u_int is_cl; /* number of client connections */ | |
581 | u_int is_sv; /* number of server connections */ | |
582 | u_int is_ni; /* connection but no idea who it was | |
583 | * (can be a P: line that has been removed -krys) */ | |
584 | unsigned long long is_cbs; /* bytes sent to clients */ | |
585 | unsigned long long is_cbr; /* bytes received to clients */ | |
586 | unsigned long long is_sbs; /* bytes sent to servers */ | |
587 | unsigned long long is_sbr; /* bytes received to servers */ | |
588 | time_t is_cti; /* time spent connected by clients */ | |
589 | time_t is_sti; /* time spent connected by servers */ | |
590 | u_int is_ac; /* connections accepted */ | |
591 | u_int is_ref; /* accepts refused */ | |
592 | u_int is_unco; /* unknown commands */ | |
593 | u_int is_wrdi; /* command going in wrong direction */ | |
594 | u_int is_unpf; /* unknown prefix */ | |
595 | u_int is_empt; /* empty message */ | |
596 | u_int is_num; /* numeric message */ | |
597 | u_int is_kill; /* number of kills generated on collisions */ | |
598 | u_int is_save; /* number of saved clients */ | |
599 | u_int is_fake; /* MODE 'fakes' */ | |
600 | u_int is_reop; /* number of local reops */ | |
601 | u_int is_rreop; /* number of remote reops */ | |
602 | u_int is_asuc; /* successful auth requests */ | |
603 | u_int is_abad; /* bad auth requests */ | |
604 | u_int is_udpok; /* packets recv'd on udp port */ | |
605 | u_int is_udperr; /* packets recvfrom errors on udp port */ | |
606 | u_int is_udpdrop; /* packets recv'd but dropped on udp port */ | |
607 | u_int is_loc; /* local connections made */ | |
608 | u_int is_nosrv; /* user without server */ | |
609 | u_long is_wwcnt; /* number of nicks overwritten in whowas[] */ | |
610 | unsigned long long is_wwt; /* sum of elapsed time on when | |
611 | ** overwriting whowas[] */ | |
612 | u_long is_wwMt; /* max elapsed time on when overwriting whowas[] */ | |
613 | u_long is_wwmt; /* min elapsed time on when overwriting whowas[] */ | |
614 | u_long is_lkcnt; /* number of nicks overwritten in locked[] */ | |
615 | unsigned long long is_lkt; /* sum of elapsed time on when | |
616 | ** overwriting locked[]*/ | |
617 | u_long is_lkMt; /* max elapsed time on when overwriting locked[] */ | |
618 | u_long is_lkmt; /* min elapsed time on when overwriting locked[] */ | |
619 | u_int is_ckl; /* calls to check_link() */ | |
620 | u_int is_cklQ; /* rejected: SendQ too high */ | |
621 | u_int is_ckly; /* rejected: link too young */ | |
622 | u_int is_cklno; /* rejected: "flood" */ | |
623 | u_int is_cklok; /* accepted */ | |
624 | u_int is_cklq; /* accepted early */ | |
625 | }; | |
626 | ||
627 | /* mode structure for channels */ | |
628 | ||
629 | struct SMode { | |
630 | u_int mode; | |
631 | int limit; | |
632 | char key[KEYLEN+1]; | |
633 | }; | |
634 | ||
635 | /* Message table structure */ | |
636 | ||
637 | typedef int (*CmdHandler)(aClient *, aClient *, int, char **); | |
638 | ||
639 | struct Cmd { | |
640 | CmdHandler handler; /* command */ | |
641 | u_int count; /* total count */ | |
642 | u_int rcount; /* remote count */ | |
643 | u_long bytes; | |
644 | u_long rbytes; | |
645 | }; | |
646 | ||
647 | struct Message { | |
648 | char *cmd; | |
649 | int minparams; | |
650 | int maxparams; | |
651 | struct Cmd handlers[STAT_MAX]; | |
652 | }; | |
653 | ||
654 | /* fd array structure */ | |
655 | ||
656 | struct fdarray { | |
657 | int fd[MAXCONNECTIONS]; | |
658 | int highest; | |
659 | }; | |
660 | ||
661 | /* general link structure used for chains */ | |
662 | ||
663 | struct SLink { | |
664 | struct SLink *next; | |
665 | union { | |
666 | aClient *cptr; | |
667 | aChannel *chptr; | |
668 | aConfItem *aconf; | |
669 | aListItem *alist; | |
670 | char *cp; | |
671 | int i; | |
672 | } value; | |
673 | int flags; | |
674 | }; | |
675 | ||
676 | /* link structure used for invites */ | |
677 | ||
678 | struct invSLink { | |
679 | struct invSLink *next; | |
680 | aChannel *chptr; | |
681 | char *who; | |
682 | int flags; | |
683 | }; | |
684 | ||
685 | /* channel structure */ | |
686 | ||
687 | struct Channel { | |
688 | struct Channel *nextch, *prevch, *hnextch; | |
689 | u_int hashv; /* raw hash value */ | |
690 | Mode mode; | |
691 | char topic[TOPICLEN+1]; | |
692 | #ifdef TOPIC_WHO_TIME | |
693 | char topic_nuh[BANLEN+1]; | |
694 | time_t topic_t; | |
695 | #endif | |
696 | int users; /* current membership total */ | |
697 | Link *members; /* channel members */ | |
698 | Link *invites; /* outstanding invitations */ | |
699 | Link *mlist; /* list of extended modes: +b/+e/+I */ | |
700 | Link *clist; /* list of local! connections which are members */ | |
701 | time_t history; /* channel history (aka channel delay) */ | |
702 | time_t reop; /* server reop stamp for !channels */ | |
703 | #ifdef JAPANESE | |
704 | int flags; | |
705 | #endif | |
706 | char chname[1]; | |
707 | }; | |
708 | ||
709 | /* | |
710 | ** Channel Related macros follow | |
711 | */ | |
712 | ||
713 | /* Channel related flags */ | |
714 | ||
715 | #define CHFL_UNIQOP 0x0001 /* Channel creator */ | |
716 | #define CHFL_CHANOP 0x0002 /* Channel operator */ | |
717 | #define CHFL_VOICE 0x0004 /* the power to speak */ | |
718 | #define CHFL_BAN 0x0008 /* ban channel flag */ | |
719 | #define CHFL_EXCEPTION 0x0010 /* exception channel flag */ | |
720 | #define CHFL_INVITE 0x0020 /* invite channel flag */ | |
721 | #define CHFL_REOPLIST 0x0040 /* reoplist channel flag */ | |
722 | ||
723 | /* Channel Visibility macros */ | |
724 | ||
725 | #define MODE_UNIQOP CHFL_UNIQOP | |
726 | #define MODE_CHANOP CHFL_CHANOP | |
727 | #define MODE_VOICE CHFL_VOICE | |
728 | #define MODE_PRIVATE 0x00008 | |
729 | #define MODE_SECRET 0x00010 | |
730 | #define MODE_MODERATED 0x00020 | |
731 | #define MODE_TOPICLIMIT 0x00040 | |
732 | #define MODE_INVITEONLY 0x00080 | |
733 | #define MODE_NOPRIVMSGS 0x00100 | |
734 | #define MODE_KEY 0x00200 | |
735 | #define MODE_BAN 0x00400 | |
736 | #define MODE_LIMIT 0x00800 | |
737 | #define MODE_ANONYMOUS 0x01000 | |
738 | #define MODE_QUIET 0x02000 | |
739 | #define MODE_EXCEPTION 0x04000 | |
740 | #define MODE_INVITE 0x08000 | |
741 | #define MODE_REOP 0x10000 | |
742 | #define MODE_REOPLIST 0x20000 | |
743 | #define MODE_FLAGS 0x3ffff | |
744 | /* | |
745 | * mode flags which take another parameter (With PARAmeterS) | |
746 | */ | |
747 | #define MODE_WPARAS (MODE_UNIQOP|MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY\ | |
748 | |MODE_LIMIT|MODE_INVITE|MODE_EXCEPTION|MODE_REOPLIST) | |
749 | /* | |
750 | * Undefined here, these are used in conjunction with the above modes in | |
751 | * the source. | |
752 | #define MODE_DEL 0x40000000 | |
753 | #define MODE_ADD 0x80000000 | |
754 | */ | |
755 | ||
756 | #define HoldChannel(x) (!(x)) | |
757 | /* name invisible */ | |
758 | #define SecretChannel(x) ((x) && ((x)->mode.mode & MODE_SECRET)) | |
759 | /* channel not shown but names are */ | |
760 | #define HiddenChannel(x) ((x) && ((x)->mode.mode & MODE_PRIVATE)) | |
761 | /* channel visible */ | |
762 | #define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) | |
763 | #define IsAnonymous(c) ((c) && ((c)->mode.mode & MODE_ANONYMOUS)) | |
764 | #define PubChannel(x) ((!x) || ((x)->mode.mode &\ | |
765 | (MODE_PRIVATE | MODE_SECRET)) == 0) | |
766 | ||
767 | /* | |
768 | #define IsMember(u, c) (assert(*(c)->chname != '\0'), find_user_link((c)->members, u) ? 1 : 0) | |
769 | #define IsMember(u, c) (find_user_link((c)->members, u) ? 1 : 0) | |
770 | */ | |
771 | #define IsMember(u, c) (u && (u)->user && \ | |
772 | find_channel_link((u)->user->channel, c) ? 1 : 0) | |
773 | # define IsChannelName(n) ((n) && (*(n) == '#' || *(n) == '&' ||\ | |
774 | *(n) == '+' || \ | |
775 | (*(n) == '!' && cid_ok(n, CHIDLEN)))) | |
776 | #define IsQuiet(x) ((x)->mode.mode & MODE_QUIET) | |
777 | #define UseModes(n) ((n) && (*(n) == '#' || *(n) == '&' || \ | |
778 | *(n) == '!')) | |
779 | ||
780 | /* Misc macros */ | |
781 | ||
782 | #define BadPtr(x) (!(x) || (*(x) == '\0')) | |
783 | #define BadTo(x) (BadPtr((x)) ? "*" : (x)) | |
784 | ||
785 | #define MyConnect(x) ((x)->fd >= 0) | |
786 | #define MyClient(x) (MyConnect(x) && IsClient(x)) | |
787 | #define MyPerson(x) (MyConnect(x) && IsPerson(x)) | |
788 | #define MyOper(x) (MyConnect(x) && IsOper(x)) | |
789 | #define MyService(x) (MyConnect(x) && IsService(x)) | |
790 | #define ME me.name | |
791 | #define MES me.serv->sid | |
792 | ||
793 | #define GotDependantClient(x) (x->prev && \ | |
794 | ((IsRegisteredUser(x->prev) && \ | |
795 | x->prev->user->servp == x->serv) || \ | |
796 | (IsService(x->prev) && \ | |
797 | x->prev->service->servp == x->serv))) | |
798 | ||
799 | #define IsMasked(x) (x && x->serv && x->serv->maskedby != x) | |
800 | ||
801 | #define IsSplit() (iconf.split == 1) | |
802 | ||
803 | typedef struct { | |
804 | u_long is_user[2]; /* users, non[0] invis and invis[1] */ | |
805 | u_long is_serv; /* servers */ | |
806 | u_long is_eobservers; /* number of servers which sent EOB */ | |
807 | u_long is_masked; /* masked servers. */ | |
808 | u_long is_service; /* services */ | |
809 | u_long is_chan; /* channels */ | |
810 | u_long is_chanmem; | |
811 | u_long is_chanusers; /* channels users */ | |
812 | u_long is_hchan; /* channels in history */ | |
813 | u_long is_hchanmem; | |
814 | u_long is_cchan; /* channels in cache */ | |
815 | u_long is_cchanmem; | |
816 | u_long is_away; /* away sets */ | |
817 | u_long is_awaymem; | |
818 | u_long is_oper; /* opers */ | |
819 | u_long is_bans; /* bans */ | |
820 | u_long is_banmem; | |
821 | u_long is_invite; /* invites */ | |
822 | u_long is_class; /* classes */ | |
823 | u_long is_conf; /* conf lines */ | |
824 | u_long is_confmem; | |
825 | u_long is_conflink; /* attached conf lines */ | |
826 | u_long is_myclnt; /* local clients */ | |
827 | u_long is_myserv; /* local servers */ | |
828 | u_long is_myservice; /* local services */ | |
829 | u_long is_unknown; /* unknown (local) connections */ | |
830 | u_long is_wwusers; /* users kept for whowas[] */ | |
831 | u_long is_wwaways; /* aways in users in whowas[] */ | |
832 | u_long is_wwawaysmem; | |
833 | u_long is_wwuwas; /* uwas links */ | |
834 | u_long is_localc; /* local items (serv+service+client+..) */ | |
835 | u_long is_remc; /* remote clients */ | |
836 | u_long is_users; /* user structs */ | |
837 | u_long is_useri; /* user invites */ | |
838 | u_long is_userc; /* user links to channels */ | |
839 | u_long is_auth; /* OTHER ident reply block */ | |
840 | u_long is_authmem; | |
841 | u_int is_dbuf; /* number of dbuf allocated (originally) */ | |
842 | u_int is_dbufnow; /* number of dbuf allocated */ | |
843 | u_int is_dbufuse; /* number of dbuf in use */ | |
844 | u_int is_dbufmin; /* min number of dbuf in use */ | |
845 | u_int is_dbufmax; /* max number of dbuf in use */ | |
846 | u_int is_dbufmore; /* how many times we increased the bufferpool*/ | |
847 | u_long is_m_users; /* maximum users connected */ | |
848 | time_t is_m_users_t; /* timestamp of last maximum users */ | |
849 | u_long is_m_serv; /* maximum servers connected */ | |
850 | u_long is_m_service; /* maximum services connected */ | |
851 | u_long is_m_myclnt; /* maximum local clients */ | |
852 | time_t is_m_myclnt_t; /* timestamp of last maximum local clients */ | |
853 | u_long is_m_myserv; /* maximum local servers */ | |
854 | u_long is_m_myservice; /* maximum local services */ | |
855 | u_long is_l_myclnt; /* last local user count */ | |
856 | time_t is_l_myclnt_t; /* timestamp for last count */ | |
857 | #ifdef DELAY_CLOSE | |
858 | u_long is_delayclose; /* number of fds that got delayed close() */ | |
859 | u_int is_delayclosewait; /* number of fds that wait for delayed close() */ | |
860 | #endif | |
861 | } istat_t; | |
862 | ||
863 | /* String manipulation macros */ | |
864 | ||
865 | /* strncopynt --> strncpyzt to avoid confusion, sematics changed | |
866 | N must be now the number of bytes in the array --msa */ | |
867 | #define strncpyzt(x, y, N) do{(void)strncpy(x,y,N);x[N-1]='\0';}while(0) | |
868 | #define StrEq(x,y) (!strcmp((x),(y))) | |
869 | ||
870 | /* used in SetMode() in channel.c and m_umode() in s_msg.c */ | |
871 | ||
872 | #define MODE_NULL 0 | |
873 | #define MODE_ADD 0x40000000 | |
874 | #define MODE_DEL 0x20000000 | |
875 | ||
876 | /* return values for hunt_server() */ | |
877 | ||
878 | #define HUNTED_NOSUCH (-1) /* if the hunted server is not found */ | |
879 | #define HUNTED_ISME 0 /* if this server should execute the command */ | |
880 | #define HUNTED_PASS 1 /* if message passed onwards successfully */ | |
881 | ||
882 | /* used when sending to $#mask or $$mask */ | |
883 | ||
884 | #define MATCH_SERVER 1 | |
885 | #define MATCH_HOST 2 | |
886 | ||
887 | /* used for sendto_serv */ | |
888 | ||
889 | #define SV_OLD 0x0000 | |
890 | #define SV_UID 0x0001 | |
891 | #define SV_2_11 SV_UID | |
892 | ||
893 | /* used for sendto_flag */ | |
894 | ||
895 | typedef struct { | |
896 | int svc_chan; | |
897 | char *svc_chname; | |
898 | struct Channel *svc_ptr; | |
899 | int fd; | |
900 | } SChan; | |
901 | ||
902 | typedef enum ServerChannels { | |
903 | SCH_ERROR, | |
904 | SCH_NOTICE, | |
905 | SCH_KILL, | |
906 | SCH_CHAN, | |
907 | SCH_NUM, | |
908 | SCH_SERVER, | |
909 | SCH_HASH, | |
910 | SCH_LOCAL, | |
911 | SCH_SERVICE, | |
912 | SCH_DEBUG, | |
913 | SCH_AUTH, | |
914 | SCH_SAVE, | |
915 | SCH_WALLOP, | |
916 | #ifdef CLIENTS_CHANNEL | |
917 | SCH_CLIENT, | |
918 | #endif | |
919 | SCH_OPER, | |
920 | SCH_MAX | |
921 | } ServerChannels; | |
922 | ||
923 | /* used for async dns values */ | |
924 | ||
925 | #define ASYNC_NONE (-1) | |
926 | #define ASYNC_CLIENT 0 | |
927 | #define ASYNC_CONNECT 1 | |
928 | #define ASYNC_CONF 2 | |
929 | #define ASYNC_SERVER 3 | |
930 | ||
931 | /* Client exit codes for log file */ | |
932 | #define EXITC_UNDEF '-' /* unregistered client */ | |
933 | #define EXITC_REG '0' /* normal exit */ | |
934 | #define EXITC_AUTHFAIL 'A' /* Authentication failure (iauth problem) */ | |
935 | #define EXITC_AUTHTOUT 'a' /* Authentication time out */ | |
936 | #define EXITC_CLONE 'C' /* CLONE_CHECK */ | |
937 | #define EXITC_DIE 'd' /* server died */ | |
938 | #define EXITC_DEAD 'D' /* socket died */ | |
939 | #define EXITC_ERROR 'E' /* socket error */ | |
940 | #define EXITC_FLOOD 'F' /* client flooding */ | |
941 | #define EXITC_FAILURE 'f' /* connect failure */ | |
942 | #define EXITC_GHMAX 'G' /* global clients per host max limit */ | |
943 | #define EXITC_GUHMAX 'g' /* global clients per user@host max limit */ | |
944 | #define EXITC_NOILINE 'I' /* No matching I:line */ | |
945 | #define EXITC_KLINE 'k' /* K-lined */ | |
946 | #define EXITC_KILL 'K' /* KILLed */ | |
947 | #define EXITC_LHMAX 'L' /* local clients per host max limit */ | |
948 | #define EXITC_LUHMAX 'l' /* local clients per user@host max limit */ | |
949 | #define EXITC_MBUF 'M' /* mem alloc error */ | |
950 | #define EXITC_PING 'P' /* ping timeout */ | |
951 | #define EXITC_BADPASS 'p' /* bad password */ | |
952 | #define EXITC_SENDQ 'Q' /* send queue exceeded */ | |
953 | #define EXITC_REF 'R' /* Refused */ | |
954 | #ifdef TKLINE | |
955 | #define EXITC_TKLINE 't' /* tkline */ | |
956 | #endif | |
957 | #define EXITC_AREF 'U' /* Unauthorized by iauth */ | |
958 | #define EXITC_AREFQ 'u' /* Unauthorized by iauth, be quiet */ | |
959 | #define EXITC_VIRUS 'v' /* joined a channel used by PrettyPark virus */ | |
960 | #ifdef XLINE | |
961 | #define EXITC_XLINE 'X' /* Forbidden GECOS */ | |
962 | #endif | |
963 | #define EXITC_YLINEMAX 'Y' /* Y:line max clients limit */ | |
964 | ||
965 | /* eXternal authentication slave OPTions */ | |
966 | #define XOPT_REQUIRED 0x01 /* require authentication be done by iauth */ | |
967 | #define XOPT_NOTIMEOUT 0x02 /* disallow iauth time outs */ | |
968 | #define XOPT_EXTWAIT 0x10 /* extend registration ping timeout */ | |
969 | #define XOPT_EARLYPARSE 0x20 /* allow early parsing and send USER/PASS | |
970 | information to iauth */ | |
971 | ||
972 | /* misc defines */ | |
973 | ||
974 | #define FLUSH_BUFFER -2 | |
975 | #define UTMP "/etc/utmp" | |
976 | #define COMMA "," | |
977 | ||
978 | #define SAP struct SOCKADDR * | |
979 | ||
980 | /* safety checks */ | |
981 | #if ! (UIDLEN <= NICKLEN) | |
982 | # error UIDLEN must not be bigger than NICKLEN | |
983 | #endif | |
984 | #if ! (UIDLEN > SIDLEN) | |
985 | # error UIDLEN must be bigger than SIDLEN | |
986 | #endif | |
987 | #if (NICKLEN < LOCALNICKLEN) | |
988 | # error LOCALNICKLEN must not be bigger than NICKLEN | |
989 | #endif | |
990 | ||
991 | /* | |
992 | * base for channel IDs and UIDs | |
993 | */ | |
994 | #define CHIDNB 36 | |
995 | ||
996 | ||
997 | /* Defines used for SET command */ | |
998 | #define TSET_ACONNECT 0x001 | |
999 | #define TSET_POOLSIZE 0x002 | |
1000 | #define TSET_CACCEPT 0x004 | |
1001 | #define TSET_SPLIT 0x008 | |
1002 | #define TSET_SHOWALL (int) ~0 | |
1003 | ||
1004 | /* Runtime configuration structure */ | |
1005 | typedef struct | |
1006 | { | |
1007 | int aconnect; /* 0 - OFF 1 - ON */ | |
1008 | int split; /* 0 - NO 1 - YES */ | |
1009 | int split_minservers; | |
1010 | int split_minusers; | |
1011 | int caccept; /* 0 - OFF 1 - ON 2 - SPLIT */ | |
1012 | } iconf_t; | |
1013 | ||
1014 | /* O:line flags, used also in is_allowed() */ | |
1015 | #define ACL_LOCOP 0x00001 | |
1016 | #define ACL_KILLLOCAL 0x00002 | |
1017 | #define ACL_KILLREMOTE 0x00004 | |
1018 | #define ACL_KILL (ACL_KILLLOCAL|ACL_KILLREMOTE) | |
1019 | #define ACL_SQUITLOCAL 0x00008 | |
1020 | #define ACL_SQUITREMOTE 0x00010 | |
1021 | #define ACL_SQUIT (ACL_SQUITLOCAL|ACL_SQUITREMOTE) | |
1022 | #define ACL_CONNECTLOCAL 0x00020 | |
1023 | #define ACL_CONNECTREMOTE 0x00040 | |
1024 | #define ACL_CONNECT (ACL_CONNECTLOCAL|ACL_CONNECTREMOTE) | |
1025 | #define ACL_CLOSE 0x00080 | |
1026 | #define ACL_HAZH 0x00100 | |
1027 | #define ACL_DNS 0x00200 | |
1028 | #define ACL_REHASH 0x00400 | |
1029 | #define ACL_RESTART 0x00800 | |
1030 | #define ACL_DIE 0x01000 | |
1031 | #define ACL_SET 0x02000 | |
1032 | #define ACL_TKLINE 0x04000 | |
1033 | #define ACL_UNTKLINE ACL_TKLINE | |
1034 | #define ACL_CLIENTS 0x08000 | |
1035 | #define ACL_CANFLOOD 0x10000 | |
1036 | #define ACL_NOPENALTY 0x20000 | |
1037 | #define ACL_TRACE 0x40000 | |
1038 | #define ACL_KLINE 0x80000 | |
1039 | #define ACL_SIDTRACE 0x100000 | |
1040 | ||
1041 | #define ACL_ALL_REMOTE (ACL_KILLREMOTE|ACL_SQUITREMOTE|ACL_CONNECTREMOTE) | |
1042 | #define ACL_ALL 0x1FFFFF | |
1043 | ||
1044 | #ifdef CLIENTS_CHANNEL | |
1045 | /* information scope of &CLIENTS channel. */ | |
1046 | #define CCL_CONN 0x01 /* connections */ | |
1047 | #define CCL_CONNINFO 0x02 /* if connections, then with realname */ | |
1048 | #define CCL_QUIT 0x04 /* quits */ | |
1049 | #define CCL_QUITINFO 0x08 /* if quits, then with quit message */ | |
1050 | #define CCL_NICK 0x10 /* nick changes */ | |
1051 | #endif | |
1052 |