1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* client.h: The ircd client header. |
4 |
* |
5 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
* |
22 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#ifndef INCLUDED_client_h |
26 |
#define INCLUDED_client_h |
27 |
|
28 |
#include "setup.h" |
29 |
#include "ircd_handler.h" |
30 |
#include "channel.h" |
31 |
|
32 |
#define PASSWDLEN 20 |
33 |
#define CIPHERKEYLEN 64 /* 512bit */ |
34 |
#define IDLEN 12 /* this is the maximum length, not the actual |
35 |
generated length; DO NOT CHANGE! */ |
36 |
|
37 |
/* |
38 |
* pre declare structs |
39 |
*/ |
40 |
struct AccessItem; |
41 |
struct Whowas; |
42 |
struct DNSReply; |
43 |
struct Listener; |
44 |
struct Client; |
45 |
struct LocalUser; |
46 |
|
47 |
struct Server |
48 |
{ |
49 |
char by[NICKLEN]; /* who activated this connection */ |
50 |
/* TBD - Add back support for user@host info in /TRACE */ |
51 |
struct ConfItem *sconf; /* ConfItem connect{} pointer for this server */ |
52 |
dlink_list servers; /* Servers on this server */ |
53 |
dlink_list users; /* Users on this server */ |
54 |
int dep_servers; /* Total number of dependent servers on all levels */ |
55 |
int dep_users; /* Total number of dependent users on all levels */ |
56 |
dlink_list leafs_hubs; /* leafs and hubs masks for server */ |
57 |
}; |
58 |
|
59 |
struct SlinkRpl |
60 |
{ |
61 |
int command; |
62 |
int datalen; |
63 |
int gotdatalen; |
64 |
int readdata; |
65 |
unsigned char *data; |
66 |
}; |
67 |
|
68 |
struct ZipStats |
69 |
{ |
70 |
unsigned long in; |
71 |
unsigned long in_wire; |
72 |
unsigned long out; |
73 |
unsigned long out_wire; |
74 |
double in_ratio; |
75 |
double out_ratio; |
76 |
}; |
77 |
|
78 |
struct ListTask |
79 |
{ |
80 |
int hash_index; /* the bucket we are currently in */ |
81 |
dlink_list show_mask; /* show these channels.. */ |
82 |
dlink_list hide_mask; /* ..and hide these ones */ |
83 |
unsigned int users_min, users_max; |
84 |
unsigned int created_min, created_max; |
85 |
unsigned int topicts_min, topicts_max; |
86 |
}; |
87 |
|
88 |
/* For accept processing */ |
89 |
struct Accept |
90 |
{ |
91 |
dlink_node node; |
92 |
char *nick; |
93 |
char *user; |
94 |
char *host; |
95 |
}; |
96 |
|
97 |
struct Client |
98 |
{ |
99 |
dlink_node node; |
100 |
dlink_node lnode; /* Used for Server->servers/users */ |
101 |
|
102 |
struct Client *hnext; /* For client hash table lookups by name */ |
103 |
struct Client *idhnext; /* For SID hash table lookups by sid */ |
104 |
|
105 |
struct Server* serv; /* ...defined, if this is a server */ |
106 |
struct Client* servptr; /* Points to server this Client is on */ |
107 |
struct Client* from; /* == self, if Local Client, *NEVER* NULL! */ |
108 |
|
109 |
time_t lasttime; /* ...should be only LOCAL clients? --msa */ |
110 |
time_t firsttime; /* time client was created */ |
111 |
time_t since; /* last time we parsed something */ |
112 |
time_t tsinfo; /* TS on the nick, SVINFO on server */ |
113 |
unsigned long connect_id; /* unique connection ID */ |
114 |
unsigned int umodes; /* opers, normal users subset */ |
115 |
unsigned int flags; /* client flags */ |
116 |
|
117 |
unsigned short hopcount; /* number of servers to this 0 = local */ |
118 |
unsigned short status; /* Client type */ |
119 |
unsigned char handler; /* Handler index */ |
120 |
|
121 |
char *away; |
122 |
|
123 |
/* |
124 |
* client->name is the unique name for a client nick or host |
125 |
*/ |
126 |
char name[HOSTLEN + 1]; |
127 |
char id[IDLEN + 1]; /* client ID, unique ID per client */ |
128 |
|
129 |
/* |
130 |
* client->username is the username from ident or the USER message, |
131 |
* If the client is idented the USER message is ignored, otherwise |
132 |
* the username part of the USER message is put here prefixed with a |
133 |
* tilde depending on the I:line, Once a client has registered, this |
134 |
* field should be considered read-only. |
135 |
*/ |
136 |
char username[USERLEN + 1]; /* client's username */ |
137 |
|
138 |
/* |
139 |
* client->host contains the resolved name or ip address |
140 |
* as a string for the user, it may be fiddled with for oper spoofing etc. |
141 |
* once it's changed the *real* address goes away. This should be |
142 |
* considered a read-only field after the client has registered. |
143 |
*/ |
144 |
char host[HOSTLEN + 1]; /* client's hostname */ |
145 |
|
146 |
/* |
147 |
* client->info for unix clients will normally contain the info from the |
148 |
* gcos field in /etc/passwd but anything can go here. |
149 |
*/ |
150 |
char info[REALLEN + 1]; /* Free form additional client info */ |
151 |
|
152 |
/* client->sockhost contains the ip address gotten from the socket as a |
153 |
* string |
154 |
*/ |
155 |
char sockhost[HOSTIPLEN + 1]; /* This is the host name from the |
156 |
socket ip address as string */ |
157 |
dlink_list whowas; /* Pointers to whowas structs */ |
158 |
dlink_list channel; /* chain of channel pointer blocks */ |
159 |
|
160 |
struct LocalUser *localClient; |
161 |
}; |
162 |
|
163 |
struct LocalUser |
164 |
{ |
165 |
/* |
166 |
* The following fields are allocated only for local clients |
167 |
* (directly connected to *this* server with a socket. |
168 |
*/ |
169 |
/* Anti flooding part, all because of lamers... */ |
170 |
time_t last_away; /* Away since... */ |
171 |
time_t last_join_time; /* when this client last |
172 |
joined a channel */ |
173 |
time_t last_leave_time; /* when this client last |
174 |
* left a channel */ |
175 |
int join_leave_count; /* count of JOIN/LEAVE in less than |
176 |
MIN_JOIN_LEAVE_TIME seconds */ |
177 |
int oper_warn_count_down; /* warn opers of this possible |
178 |
spambot every time this gets to 0 */ |
179 |
time_t reject_delay; |
180 |
time_t last_caller_id_time; |
181 |
time_t first_received_message_time; |
182 |
int received_number_of_privmsgs; |
183 |
|
184 |
dlink_node lclient_node; |
185 |
|
186 |
unsigned int operflags; /* oper priv flags */ |
187 |
|
188 |
struct ListTask *list_task; |
189 |
/* Send and receive dbufs .. */ |
190 |
struct dbuf_queue buf_sendq; |
191 |
struct dbuf_queue buf_recvq; |
192 |
|
193 |
struct { |
194 |
unsigned int messages; /* Statistics: protocol messages sent/received */ |
195 |
uint64_t bytes; /* Statistics: total bytes sent/received */ |
196 |
} recv, send; |
197 |
|
198 |
struct Listener *listener; /* listener accepted from */ |
199 |
struct ClassItem *class; /* Client's class */ |
200 |
struct irc_ssaddr ip; |
201 |
int aftype; /* Makes life easier for DNS res in IPV6 */ |
202 |
struct DNSQuery *dns_query; /* result returned from resolver query */ |
203 |
|
204 |
time_t last; /* Last time client sent a PRIVMSG */ |
205 |
time_t last_nick_change; |
206 |
int number_of_nick_changes; |
207 |
|
208 |
char *passwd; |
209 |
int caps; /* capabilities bit-field */ |
210 |
int enc_caps; /* cipher capabilities bit-field */ |
211 |
|
212 |
#ifdef HAVE_LIBCRYPTO |
213 |
struct EncCapability *in_cipher; |
214 |
struct EncCapability *out_cipher; |
215 |
|
216 |
char in_key[CIPHERKEYLEN]; |
217 |
char out_key[CIPHERKEYLEN]; |
218 |
#endif |
219 |
|
220 |
fde_t fd; |
221 |
fde_t ctrlfd; /* For servers: control fd used for sending commands |
222 |
to servlink */ |
223 |
|
224 |
struct SlinkRpl slinkrpl; /* slink reply being parsed */ |
225 |
char *slinkq; /* sendq for control data */ |
226 |
int slinkq_ofs; /* ofset into slinkq */ |
227 |
int slinkq_len; /* length remaining after slinkq_ofs */ |
228 |
|
229 |
struct ZipStats zipstats; |
230 |
|
231 |
/* Anti-flood stuff. We track how many messages were parsed and how |
232 |
* many we were allowed in the current second, and apply a simple |
233 |
* decay to avoid flooding. |
234 |
* -- adrian |
235 |
*/ |
236 |
int allow_read; /* how many we're allowed to read in this second */ |
237 |
int sent_parsed; /* how many messages we've parsed in this second */ |
238 |
time_t last_knock; /* time of last knock */ |
239 |
unsigned long random_ping; |
240 |
unsigned long serial; /* used to enforce 1 send per nick */ |
241 |
|
242 |
char* response; /* expected response from client */ |
243 |
char* auth_oper; /* Operator to become if they supply the response.*/ |
244 |
|
245 |
dlink_list watches; /**< chain of Watch pointer blocks */ |
246 |
|
247 |
/* caller ID allow list */ |
248 |
dlink_list acceptlist; /* clients I'll allow to talk to me */ |
249 |
dlink_list invited; /* chain of invite pointer blocks */ |
250 |
}; |
251 |
|
252 |
/* |
253 |
* status macros. |
254 |
*/ |
255 |
#define STAT_CONNECTING 0x01 |
256 |
#define STAT_HANDSHAKE 0x02 |
257 |
#define STAT_ME 0x04 |
258 |
#define STAT_UNKNOWN 0x08 |
259 |
#define STAT_SERVER 0x10 |
260 |
#define STAT_CLIENT 0x20 |
261 |
|
262 |
#define HasID(x) ((x)->id[0] != '\0') |
263 |
#define ID(x) (HasID(x) ? (x)->id : (x)->name) |
264 |
#define ID_or_name(x,client_p) ((IsCapable(client_p, CAP_TS6) && HasID(x)) ? (x)->id : (x)->name) |
265 |
|
266 |
#define IsRegistered(x) ((x)->status > STAT_UNKNOWN) |
267 |
#define IsConnecting(x) ((x)->status == STAT_CONNECTING) |
268 |
#define IsHandshake(x) ((x)->status == STAT_HANDSHAKE) |
269 |
#define IsMe(x) ((x)->status == STAT_ME) |
270 |
#define IsUnknown(x) ((x)->status == STAT_UNKNOWN) |
271 |
#define IsServer(x) ((x)->status == STAT_SERVER) |
272 |
#define IsClient(x) ((x)->status == STAT_CLIENT) |
273 |
|
274 |
#define IsOper(x) ((x)->umodes & UMODE_OPER) |
275 |
#define IsAdmin(x) ((x)->umodes & UMODE_ADMIN) |
276 |
|
277 |
#define SetConnecting(x) {(x)->status = STAT_CONNECTING; \ |
278 |
(x)->handler = UNREGISTERED_HANDLER; } |
279 |
|
280 |
#define SetHandshake(x) {(x)->status = STAT_HANDSHAKE; \ |
281 |
(x)->handler = UNREGISTERED_HANDLER; } |
282 |
|
283 |
#define SetMe(x) {(x)->status = STAT_ME; \ |
284 |
(x)->handler = UNREGISTERED_HANDLER; } |
285 |
|
286 |
#define SetUnknown(x) {(x)->status = STAT_UNKNOWN; \ |
287 |
(x)->handler = UNREGISTERED_HANDLER; } |
288 |
|
289 |
#define SetServer(x) {(x)->status = STAT_SERVER; \ |
290 |
(x)->handler = SERVER_HANDLER; } |
291 |
|
292 |
#define SetClient(x) {(x)->status = STAT_CLIENT; \ |
293 |
(x)->handler = IsOper((x)) ? \ |
294 |
OPER_HANDLER : CLIENT_HANDLER; } |
295 |
|
296 |
#define SetEob(x) ((x)->flags |= FLAGS_EOB) |
297 |
#define HasSentEob(x) ((x)->flags & FLAGS_EOB) |
298 |
|
299 |
/* |
300 |
* ts stuff |
301 |
*/ |
302 |
#define TS_CURRENT 6 /* current TS protocol version */ |
303 |
#ifdef TS5_ONLY |
304 |
#define TS_MIN 5 |
305 |
#else |
306 |
#define TS_MIN 3 /* minimum supported TS protocol version */ |
307 |
#endif |
308 |
#define TS_DOESTS 0x20000000 |
309 |
#define DoesTS(x) ((x)->tsinfo == TS_DOESTS) |
310 |
|
311 |
|
312 |
/* housekeeping flags */ |
313 |
#define FLAGS_PINGSENT 0x00000001 /* Unreplied ping sent */ |
314 |
#define FLAGS_DEADSOCKET 0x00000002 /* Local socket is dead--Exiting soon */ |
315 |
#define FLAGS_KILLED 0x00000004 /* Prevents "QUIT" from being sent for this */ |
316 |
#define FLAGS_CLOSING 0x00000008 /* set when closing to suppress errors */ |
317 |
#define FLAGS_GOTID 0x00000010 /* successful ident lookup achieved */ |
318 |
#define FLAGS_NEEDID 0x00000020 /* I-lines say must use ident return */ |
319 |
#define FLAGS_SENDQEX 0x00000040 /* Sendq exceeded */ |
320 |
#define FLAGS_IPHASH 0x00000080 /* iphashed this client */ |
321 |
#define FLAGS_CRYPTIN 0x00000100 /* incoming data must be decrypted */ |
322 |
#define FLAGS_CRYPTOUT 0x00000200 /* outgoing data must be encrypted */ |
323 |
#define FLAGS_WAITAUTH 0x00000400 /* waiting for CRYPTLINK AUTH command */ |
324 |
#define FLAGS_SERVLINK 0x00000800 /* servlink has servlink process */ |
325 |
#define FLAGS_MARK 0x00001000 /* marked client */ |
326 |
#define FLAGS_CANFLOOD 0x00002000 /* client has the ability to flood */ |
327 |
#define FLAGS_EXEMPTGLINE 0x00004000 /* client can't be G-lined */ |
328 |
#define FLAGS_EXEMPTKLINE 0x00008000 /* client is exempt from kline */ |
329 |
#define FLAGS_NOLIMIT 0x00010000 /* client is exempt from limits */ |
330 |
#define FLAGS_RESTRICTED 0x00020000 /* client cannot op others */ |
331 |
#define FLAGS_PING_COOKIE 0x00040000 /* PING Cookie */ |
332 |
#define FLAGS_IDLE_LINED 0x00080000 /* client is exempt from idle-time limits */ |
333 |
#define FLAGS_IP_SPOOFING 0x00100000 /* client IP is spoofed */ |
334 |
#define FLAGS_FLOODDONE 0x00200000 /* Flood grace period has been ended. */ |
335 |
#define FLAGS_EOB 0x00400000 /* server has received EOB */ |
336 |
#define FLAGS_HIDDEN 0x00800000 /* a hidden server. not shown in /links */ |
337 |
#define FLAGS_BLOCKED 0x01000000 /* must wait for COMM_SELECT_WRITE */ |
338 |
#define FLAGS_SBLOCKED 0x02000000 /* slinkq is blocked */ |
339 |
#define FLAGS_USERHOST 0x04000000 /* client is in userhost hash */ |
340 |
#define FLAGS_BURSTED 0x08000000 /* user was already bursted */ |
341 |
#define FLAGS_EXEMPTRESV 0x10000000 /* client is exempt from RESV */ |
342 |
#define FLAGS_GOTUSER 0x20000000 /* if we received a USER command */ |
343 |
#define FLAGS_PINGWARNING 0x40000000 /* unreplied ping warning already sent */ |
344 |
#define FLAGS_FLOOD_NOTICED 0x80000000 /* if we already sent a notice to opers */ |
345 |
|
346 |
|
347 |
/* umodes, settable flags */ |
348 |
#define UMODE_SERVNOTICE 0x00001 /* server notices such as kill */ |
349 |
#define UMODE_CCONN 0x00002 /* Client Connections */ |
350 |
#define UMODE_REJ 0x00004 /* Bot Rejections */ |
351 |
#define UMODE_SKILL 0x00008 /* Server Killed */ |
352 |
#define UMODE_FULL 0x00010 /* Full messages */ |
353 |
#define UMODE_SPY 0x00020 /* see STATS / LINKS */ |
354 |
#define UMODE_DEBUG 0x00040 /* 'debugging' info */ |
355 |
#define UMODE_NCHANGE 0x00080 /* Nick change notice */ |
356 |
#define UMODE_WALLOP 0x00100 /* send wallops to them */ |
357 |
#define UMODE_OPERWALL 0x00200 /* Operwalls */ |
358 |
#define UMODE_INVISIBLE 0x00400 /* makes user invisible */ |
359 |
#define UMODE_BOTS 0x00800 /* shows bots */ |
360 |
#define UMODE_EXTERNAL 0x01000 /* show servers introduced and splitting */ |
361 |
#define UMODE_CALLERID 0x02000 /* block unless caller id's */ |
362 |
#define UMODE_SOFTCALLERID 0x04000 /* block unless on common channel */ |
363 |
#define UMODE_UNAUTH 0x08000 /* show unauth connects here */ |
364 |
#define UMODE_LOCOPS 0x10000 /* show locops */ |
365 |
#define UMODE_DEAF 0x20000 /* don't receive channel messages */ |
366 |
|
367 |
/* user information flags, only settable by remote mode or local oper */ |
368 |
#define UMODE_OPER 0x40000 /* Operator */ |
369 |
#define UMODE_ADMIN 0x80000 /* Admin on server */ |
370 |
#define UMODE_ALL UMODE_SERVNOTICE |
371 |
|
372 |
#define SEND_UMODES (UMODE_INVISIBLE | UMODE_OPER | UMODE_WALLOP | \ |
373 |
UMODE_ADMIN) |
374 |
|
375 |
|
376 |
/* oper priv flags */ |
377 |
#define OPER_FLAG_GLOBAL_KILL 0x00000001 /* oper can global kill */ |
378 |
#define OPER_FLAG_REMOTE 0x00000002 /* oper can do squits/connects */ |
379 |
#define OPER_FLAG_UNKLINE 0x00000004 /* oper can use unkline */ |
380 |
#define OPER_FLAG_GLINE 0x00000008 /* oper can use gline */ |
381 |
#define OPER_FLAG_N 0x00000010 /* oper can umode n */ |
382 |
#define OPER_FLAG_K 0x00000020 /* oper can kill/kline */ |
383 |
#define OPER_FLAG_X 0x00000040 /* oper can xline */ |
384 |
#define OPER_FLAG_DIE 0x00000080 /* oper can die */ |
385 |
#define OPER_FLAG_REHASH 0x00000100 /* oper can rehash */ |
386 |
#define OPER_FLAG_ADMIN 0x00000200 /* oper can set umode +a */ |
387 |
#define OPER_FLAG_HIDDEN_ADMIN 0x00000400 /* admin is hidden */ |
388 |
#define OPER_FLAG_OPERWALL 0x00000800 /* */ |
389 |
#define OPER_FLAG_OPER_SPY 0x00001000 /* */ |
390 |
#define OPER_FLAG_REMOTEBAN 0x00002000 /* */ |
391 |
#define OPER_FLAG_HIDDEN_OPER 0x00004000 /* */ |
392 |
|
393 |
#define SetOFlag(x, y) ((x)->localClient->operflags |= (y)) |
394 |
|
395 |
|
396 |
/* flags macros. */ |
397 |
#define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET) |
398 |
#define SetDead(x) ((x)->flags |= FLAGS_DEADSOCKET) |
399 |
#define IsClosing(x) ((x)->flags & FLAGS_CLOSING) |
400 |
#define SetClosing(x) ((x)->flags |= FLAGS_CLOSING) |
401 |
#define IsKilled(x) ((x)->flags & FLAGS_KILLED) |
402 |
#define SetKilled(x) ((x)->flags |= FLAGS_KILLED) |
403 |
#define IsCryptIn(x) ((x)->flags & FLAGS_CRYPTIN) |
404 |
#define SetCryptIn(x) ((x)->flags |= FLAGS_CRYPTIN) |
405 |
#define IsCryptOut(x) ((x)->flags & FLAGS_CRYPTOUT) |
406 |
#define SetCryptOut(x) ((x)->flags |= FLAGS_CRYPTOUT) |
407 |
#define IsWaitAuth(x) ((x)->flags & FLAGS_WAITAUTH) |
408 |
#define SetWaitAuth(x) ((x)->flags |= FLAGS_WAITAUTH) |
409 |
#define ClearWaitAuth(x) ((x)->flags &= ~FLAGS_WAITAUTH) |
410 |
#define HasServlink(x) ((x)->flags & FLAGS_SERVLINK) |
411 |
#define SetServlink(x) ((x)->flags |= FLAGS_SERVLINK) |
412 |
#define MyConnect(x) ((x)->localClient != NULL) |
413 |
#define MyClient(x) (MyConnect(x) && IsClient(x)) |
414 |
#define SetMark(x) ((x)->flags |= FLAGS_MARK) |
415 |
#define ClearMark(x) ((x)->flags &= ~FLAGS_MARK) |
416 |
#define IsMarked(x) ((x)->flags & FLAGS_MARK) |
417 |
#define SetCanFlood(x) ((x)->flags |= FLAGS_CANFLOOD) |
418 |
#define IsCanFlood(x) ((x)->flags & FLAGS_CANFLOOD) |
419 |
#define IsDefunct(x) ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING| \ |
420 |
FLAGS_KILLED)) |
421 |
|
422 |
/* oper flags */ |
423 |
#define MyOper(x) (MyConnect(x) && IsOper(x)) |
424 |
|
425 |
#define SetOper(x) {(x)->umodes |= UMODE_OPER; \ |
426 |
if (!IsServer((x))) (x)->handler = OPER_HANDLER;} |
427 |
|
428 |
#define ClearOper(x) {(x)->umodes &= ~(UMODE_OPER|UMODE_ADMIN); \ |
429 |
if (!IsOper((x)) && !IsServer((x))) \ |
430 |
(x)->handler = CLIENT_HANDLER; } |
431 |
|
432 |
#define IsInvisible(x) ((x)->umodes & UMODE_INVISIBLE) |
433 |
#define SendWallops(x) ((x)->umodes & UMODE_WALLOP) |
434 |
#define IsSetCallerId(x) ((x)->umodes & \ |
435 |
(UMODE_CALLERID|UMODE_SOFTCALLERID)) |
436 |
#define IsSoftCallerId(x) ((x)->umodes & UMODE_SOFTCALLERID) |
437 |
#define IsDeaf(x) ((x)->umodes & UMODE_DEAF) |
438 |
|
439 |
#define SetFloodNoticed(x) ((x)->flags |= FLAGS_FLOOD_NOTICED) |
440 |
#define ClearFloodNoticed(x) ((x)->flags &= ~FLAGS_FLOOD_NOTICED) |
441 |
#define IsFloodNoticed(x) ((x)->flags & FLAGS_FLOOD_NOTICED) |
442 |
|
443 |
#define SetSendQExceeded(x) ((x)->flags |= FLAGS_SENDQEX) |
444 |
#define IsSendQExceeded(x) ((x)->flags & FLAGS_SENDQEX) |
445 |
|
446 |
#define SetIpHash(x) ((x)->flags |= FLAGS_IPHASH) |
447 |
#define ClearIpHash(x) ((x)->flags &= ~FLAGS_IPHASH) |
448 |
#define IsIpHash(x) ((x)->flags & FLAGS_IPHASH) |
449 |
|
450 |
#define SetUserHost(x) ((x)->flags |= FLAGS_USERHOST) |
451 |
#define ClearUserHost(x) ((x)->flags &= ~FLAGS_USERHOST) |
452 |
#define IsUserHostIp(x) ((x)->flags & FLAGS_USERHOST) |
453 |
|
454 |
#define SetPingSent(x) ((x)->flags |= FLAGS_PINGSENT) |
455 |
#define IsPingSent(x) ((x)->flags & FLAGS_PINGSENT) |
456 |
#define ClearPingSent(x) ((x)->flags &= ~FLAGS_PINGSENT) |
457 |
|
458 |
#define SetPingWarning(x) ((x)->flags |= FLAGS_PINGWARNING) |
459 |
#define IsPingWarning(x) ((x)->flags & FLAGS_PINGWARNING) |
460 |
#define ClearPingWarning(x) ((x)->flags &= ~FLAGS_PINGWARNING) |
461 |
|
462 |
#define SetNeedId(x) ((x)->flags |= FLAGS_NEEDID) |
463 |
#define IsNeedId(x) ((x)->flags & FLAGS_NEEDID) |
464 |
|
465 |
#define SetGotId(x) ((x)->flags |= FLAGS_GOTID) |
466 |
#define IsGotId(x) ((x)->flags & FLAGS_GOTID) |
467 |
|
468 |
#define IsExemptKline(x) ((x)->flags & FLAGS_EXEMPTKLINE) |
469 |
#define SetExemptKline(x) ((x)->flags |= FLAGS_EXEMPTKLINE) |
470 |
#define IsExemptLimits(x) ((x)->flags & FLAGS_NOLIMIT) |
471 |
#define SetExemptLimits(x) ((x)->flags |= FLAGS_NOLIMIT) |
472 |
#define IsExemptGline(x) ((x)->flags & FLAGS_EXEMPTGLINE) |
473 |
#define SetExemptGline(x) ((x)->flags |= FLAGS_EXEMPTGLINE) |
474 |
#define IsExemptResv(x) ((x)->flags & FLAGS_EXEMPTRESV) |
475 |
#define SetExemptResv(x) ((x)->flags |= FLAGS_EXEMPTRESV) |
476 |
#define SetIPSpoof(x) ((x)->flags |= FLAGS_IP_SPOOFING) |
477 |
#define IsIPSpoof(x) ((x)->flags & FLAGS_IP_SPOOFING) |
478 |
|
479 |
#define IsIdlelined(x) ((x)->flags & FLAGS_IDLE_LINED) |
480 |
#define SetIdlelined(x) ((x)->flags |= FLAGS_IDLE_LINED) |
481 |
#define IsRestricted(x) ((x)->flags & FLAGS_RESTRICTED) |
482 |
#define SetRestricted(x) ((x)->flags |= FLAGS_RESTRICTED) |
483 |
|
484 |
#define IsFloodDone(x) ((x)->flags & FLAGS_FLOODDONE) |
485 |
#define SetFloodDone(x) ((x)->flags |= FLAGS_FLOODDONE) |
486 |
#define HasPingCookie(x) ((x)->flags & FLAGS_PING_COOKIE) |
487 |
#define SetPingCookie(x) ((x)->flags |= FLAGS_PING_COOKIE) |
488 |
#define IsHidden(x) ((x)->flags & FLAGS_HIDDEN) |
489 |
#define SetHidden(x) ((x)->flags |= FLAGS_HIDDEN) |
490 |
|
491 |
#define IsSendqBlocked(x) ((x)->flags & FLAGS_BLOCKED) |
492 |
#define SetSendqBlocked(x) ((x)->flags |= FLAGS_BLOCKED) |
493 |
#define ClearSendqBlocked(x) ((x)->flags &= ~FLAGS_BLOCKED) |
494 |
#define IsSlinkqBlocked(x) ((x)->flags & FLAGS_SBLOCKED) |
495 |
#define SetSlinkqBlocked(x) ((x)->flags |= FLAGS_SBLOCKED) |
496 |
#define ClearSlinkqBlocked(x) ((x)->flags &= ~FLAGS_SBLOCKED) |
497 |
|
498 |
#define IsBursted(x) ((x)->flags & FLAGS_BURSTED) |
499 |
#define SetBursted(x) ((x)->flags |= FLAGS_BURSTED) |
500 |
#define ClearBursted(x) ((x)->flags &= ~FLAGS_BURSTED) |
501 |
|
502 |
#define IsCaptured(x) ((x)->handler == DUMMY_HANDLER) |
503 |
#define SetCaptured(x) ((x)->handler = DUMMY_HANDLER) |
504 |
#define ClearCaptured(x) ((x)->handler = CLIENT_HANDLER) |
505 |
|
506 |
/* operflags macros */ |
507 |
#define ClearOperFlags(x) ((x)->localClient->operflags = 0) |
508 |
#define IsOperGlobalKill(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_GLOBAL_KILL : 0) |
509 |
#define IsOperRemote(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_REMOTE : 0) |
510 |
#define IsOperUnkline(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_UNKLINE : 0) |
511 |
#define IsOperGline(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_GLINE : 0) |
512 |
#define IsOperN(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_N : 0) |
513 |
#define IsOperK(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_K : 0) |
514 |
#define IsOperDie(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_DIE : 0) |
515 |
#define IsOperRehash(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_REHASH : 0) |
516 |
#define IsOperAdmin(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_ADMIN : 0) |
517 |
#define IsOperHiddenAdmin(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_HIDDEN_ADMIN : 0) |
518 |
#define IsOperX(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_X : 0) |
519 |
#define IsOperWall(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_OPERWALL : 0) |
520 |
#define IsOperRemoteBan(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_REMOTEBAN : 0) |
521 |
#define IsOperHidden(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_HIDDEN_OPER : 0) |
522 |
|
523 |
/* |
524 |
* definitions for get_client_name |
525 |
* TBD - make this an enum |
526 |
*/ |
527 |
#define HIDE_IP 0 |
528 |
#define SHOW_IP 1 |
529 |
#define MASK_IP 2 |
530 |
|
531 |
EXTERN struct Client me; |
532 |
EXTERN dlink_list listing_client_list; |
533 |
EXTERN dlink_list global_client_list; |
534 |
|
535 |
void init_client(void); |
536 |
void dead_link_on_write(struct Client *, int); |
537 |
void dead_link_on_read(struct Client *, int); |
538 |
void exit_aborted_clients(void); |
539 |
void free_exited_clients(void); |
540 |
|
541 |
EXTERN int accept_message(struct Client *, struct Client *); |
542 |
EXTERN struct Accept *find_accept(const char *, const char *, |
543 |
const char *, struct Client *, int); |
544 |
EXTERN void del_accept(struct Accept *, struct Client *); |
545 |
EXTERN void set_initial_nick(struct Client *, const char *); |
546 |
EXTERN void exit_client(struct Client *, struct Client *, const char *); |
547 |
EXTERN void check_conf_klines(void); |
548 |
EXTERN void change_local_nick(struct Client *, struct Client *, const char *); |
549 |
EXTERN void report_error(int, const char *, const char *, int); |
550 |
EXTERN struct Client *make_client(struct Client *); |
551 |
EXTERN struct Client *find_chasing(struct Client *, struct Client *, const char *, int *); |
552 |
EXTERN struct Client *find_person(const struct Client *const, const char *); |
553 |
EXTERN const char *get_client_name(struct Client *, int); |
554 |
EXTERN void log_user_exit(struct Client *); |
555 |
EXTERN void log_oper_action(int type, const struct Client *, const char *, ...); |
556 |
|
557 |
#endif /* INCLUDED_client_h */ |