]> jfr.im git - irc/rqf/shadowircd.git/blame - include/client.h
Pass certfp to other servers and show it in whois. Do not show it on connect.
[irc/rqf/shadowircd.git] / include / client.h
CommitLineData
212380e3 1/*
2 * charybdis: A useful ircd.
3 * client.h: The ircd client header.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2004 ircd-ratbox development team
8 * Copyright (C) 2005 William Pitcock and Jilles Tjoelker
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
54015b5f 25 * $Id: client.h 3446 2007-05-14 22:21:16Z jilles $
212380e3 26 */
27
28#ifndef INCLUDED_client_h
29#define INCLUDED_client_h
30
31#include "config.h"
32
33#if !defined(CONFIG_RATBOX_LEVEL_1)
34#error Incorrect config.h for this revision of ircd.
35#endif
36
37#include "ircd_defs.h"
212380e3 38#include "channel.h"
39#include "res.h"
40#include "snomask.h"
13ae2f4b 41#include "match.h"
212380e3 42#include "ircd.h"
34cb09ce 43#include "privilege.h"
212380e3 44
45/* other structs */
46struct Blacklist;
47
48/* we store ipv6 ips for remote clients, so this needs to be v6 always */
49#define HOSTIPLEN 53 /* sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255.ipv6") */
50#define PASSWDLEN 128
51#define CIPHERKEYLEN 64 /* 512bit */
52#define CLIENT_BUFSIZE 512 /* must be at least 512 bytes */
53
54#define IDLEN 10
55
56/*
57 * pre declare structs
58 */
59struct ConfItem;
60struct Whowas;
61struct DNSReply;
62struct Listener;
63struct Client;
64struct User;
65struct Server;
66struct LocalUser;
67struct AuthRequest;
68struct PreClient;
69struct ListClient;
994544c2 70struct scache_entry;
212380e3 71
212380e3 72/*
73 * Client structures
74 */
75struct User
76{
08d11e34
WP
77 rb_dlink_list channel; /* chain of channel pointer blocks */
78 rb_dlink_list invited; /* chain of invite pointer blocks */
c387fc41 79 char *away; /* pointer to away message */
212380e3 80 int refcnt; /* Number of times this block is referenced */
212380e3 81
82 char suser[NICKLEN+1];
83};
84
85struct Server
86{
6d70eae6 87 struct User *user; /* who activated this connection */
212380e3 88 char by[NICKLEN];
08d11e34
WP
89 rb_dlink_list servers;
90 rb_dlink_list users;
212380e3 91 int caps; /* capabilities bit-field */
92 char *fullcaps;
994544c2 93 struct scache_entry *nameinfo;
212380e3 94};
95
212380e3 96struct ZipStats
97{
b717a466
JT
98 unsigned long long in;
99 unsigned long long in_wire;
100 unsigned long long out;
101 unsigned long long out_wire;
102 double in_ratio;
212380e3 103 double out_ratio;
104};
105
106struct Client
107{
08d11e34
WP
108 rb_dlink_node node;
109 rb_dlink_node lnode;
6d70eae6
JT
110 struct User *user; /* ...defined, if this is a User */
111 struct Server *serv; /* ...defined, if this is a server */
112 struct Client *servptr; /* Points to server this Client is on */
113 struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
212380e3 114
6d70eae6 115 struct Whowas *whowas; /* Pointers to whowas structs */
212380e3 116 time_t tsinfo; /* TS on the nick, SVINFO on server */
117 unsigned int umodes; /* opers, normal users subset */
118 unsigned int flags; /* client flags */
119 unsigned int flags2; /* ugh. overflow */
120
121 unsigned int snomask; /* server notice mask */
122
123 int hopcount; /* number of servers to this 0 = local */
124 unsigned short status; /* Client type */
125 unsigned char handler; /* Handler index */
126 unsigned long serial; /* used to enforce 1 send per nick */
127
128 /* client->name is the unique name for a client nick or host */
129 char name[HOSTLEN + 1];
130
131 /*
132 * client->username is the username from ident or the USER message,
133 * If the client is idented the USER message is ignored, otherwise
134 * the username part of the USER message is put here prefixed with a
135 * tilde depending on the I:line, Once a client has registered, this
136 * field should be considered read-only.
137 */
138 char username[USERLEN + 1]; /* client's username */
139
140 /*
141 * client->host contains the resolved name or ip address
142 * as a string for the user, it may be fiddled with for oper spoofing etc.
143 */
144 char host[HOSTLEN + 1]; /* client's hostname */
145 char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */
146 char sockhost[HOSTIPLEN + 1]; /* clients ip */
147 char info[REALLEN + 1]; /* Free form additional client info */
148
149 char id[IDLEN]; /* UID/SID, unique on the network */
150
151 /* list of who has this client on their allow list, its counterpart
152 * is in LocalUser
153 */
08d11e34 154 rb_dlink_list on_allow_list;
212380e3 155
dada366b
JT
156 time_t first_received_message_time;
157 int received_number_of_privmsgs;
158 int flood_noticed;
159
6d70eae6
JT
160 struct LocalUser *localClient;
161 struct PreClient *preClient;
fcda5662
JT
162
163 time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */
54656d76 164 char *certfp; /* client certificate fingerprint */
212380e3 165};
166
167struct LocalUser
168{
08d11e34 169 rb_dlink_node tnode; /* This is the node for the local list type the client is on*/
212380e3 170 /*
171 * The following fields are allocated only for local clients
172 * (directly connected to *this* server with a socket.
173 */
174 /* Anti flooding part, all because of lamers... */
175 time_t last_join_time; /* when this client last
176 joined a channel */
177 time_t last_leave_time; /* when this client last
178 * left a channel */
179 int join_leave_count; /* count of JOIN/LEAVE in less than
180 MIN_JOIN_LEAVE_TIME seconds */
181 int oper_warn_count_down; /* warn opers of this possible
182 spambot every time this gets to 0 */
183 time_t last_caller_id_time;
212380e3 184
185 time_t lasttime; /* last time we parsed something */
186 time_t firsttime; /* time client was created */
187
188 /* Send and receive linebuf queues .. */
189 buf_head_t buf_sendq;
190 buf_head_t buf_recvq;
191 /*
192 * we want to use unsigned int here so the sizes have a better chance of
193 * staying the same on 64 bit machines. The current trend is to use
194 * I32LP64, (32 bit ints, 64 bit longs and pointers) and since ircd
195 * will NEVER run on an operating system where ints are less than 32 bits,
196 * it's a relatively safe bet to use ints. Since right shift operations are
197 * performed on these, it's not safe to allow them to become negative,
198 * which is possible for long running server connections. Unsigned values
199 * generally overflow gracefully. --Bleep
200 */
201 unsigned int sendM; /* Statistics: protocol messages send */
202 unsigned int sendK; /* Statistics: total k-bytes send */
203 unsigned int receiveM; /* Statistics: protocol messages received */
204 unsigned int receiveK; /* Statistics: total k-bytes received */
205 unsigned short sendB; /* counters to count upto 1-k lots of bytes */
206 unsigned short receiveB; /* sent and received. */
6d70eae6
JT
207 struct Listener *listener; /* listener accepted from */
208 struct ConfItem *att_conf; /* attached conf */
212380e3 209 struct server_conf *att_sconf;
210
3ea5fee7 211 struct rb_sockaddr_storage ip;
212380e3 212 time_t last_nick_change;
213 int number_of_nick_changes;
214
215 /*
216 * XXX - there is no reason to save this, it should be checked when it's
217 * received and not stored, this is not used after registration
218 *
219 * agreed. lets get rid of it someday! --nenolod
220 */
221 char *passwd;
969a1ae6 222 char *auth_user;
212380e3 223 char *opername; /* name of operator{} block being used or tried (challenge) */
224 char *challenge;
225 char *fullcaps;
226
227 int caps; /* capabilities bit-field */
08d11e34 228 rb_fde_t *F; /* >= 0, for local clients */
212380e3 229
230 /* time challenge response is valid for */
231 time_t chal_time;
232
cecb5c1e
JT
233 struct DNSQuery *dnsquery; /* for outgoing server's name lookup */
234
212380e3 235 time_t last_away; /* Away since... */
236 time_t last;
237
238 /* clients allowed to talk through +g */
08d11e34 239 rb_dlink_list allow_list;
212380e3 240
241 /* nicknames theyre monitoring */
08d11e34 242 rb_dlink_list monitor_list;
212380e3 243
244 /*
245 * Anti-flood stuff. We track how many messages were parsed and how
246 * many we were allowed in the current second, and apply a simple decay
247 * to avoid flooding.
248 * -- adrian
249 */
250 int allow_read; /* how many we're allowed to read in this second */
251 int actually_read; /* how many we've actually read in this second */
252 int sent_parsed; /* how many messages we've parsed in this second */
253 time_t last_knock; /* time of last knock */
254 unsigned long random_ping;
6d70eae6 255 struct AuthRequest *auth_request;
212380e3 256
58e8319c
VY
257 /* target change stuff */
258 uint32_t targets[10]; /* targets were aware of (fnv32(use_id(target_p))) */
259 unsigned int targinfo[2]; /* cyclic array, no in use */
212380e3 260 time_t target_last; /* last time we cleared a slot */
261
6d70eae6 262 struct ListClient *safelist_data;
212380e3 263
264 char *mangledhost; /* non-NULL if host mangling module loaded and
265 applicable to this client */
8db00894 266
16cb94cc 267 struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
c4a6078a 268 struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
f97867df 269 uint32_t localflags;
8db00894 270 struct ZipStats *zipstats; /* zipstats */
f97867df 271 uint16_t cork_count; /* used for corking/uncorking connections */
8db00894 272 struct ev_entry *event; /* used for associated events */
34cb09ce
WP
273
274 struct PrivilegeSet *privset; /* privset... */
212380e3 275};
276
277struct PreClient
278{
279 char spoofnick[NICKLEN + 1];
280 char spoofuser[USERLEN + 1];
281 char spoofhost[HOSTLEN + 1];
282
283 char sasl_agent[IDLEN];
284 unsigned char sasl_out;
285 unsigned char sasl_complete;
286
08d11e34 287 rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */
212380e3 288 struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */
07c8448a
JT
289
290 struct rb_sockaddr_storage lip; /* address of our side of the connection */
212380e3 291};
292
293struct ListClient
294{
295 unsigned int hash_indice;
296 unsigned int users_min, users_max;
297
298 /* It would be nice to add other modifiers,
299 * but not for 1.1 --nenolod
300 */
301};
302
212380e3 303/*
304 * status macros.
305 */
306#define STAT_CONNECTING 0x01
307#define STAT_HANDSHAKE 0x02
308#define STAT_ME 0x04
309#define STAT_UNKNOWN 0x08
310#define STAT_REJECT 0x10
311#define STAT_SERVER 0x20
312#define STAT_CLIENT 0x40
313
314
315#define IsRegisteredUser(x) ((x)->status == STAT_CLIENT)
316#define IsRegistered(x) (((x)->status > STAT_UNKNOWN) && ((x)->status != STAT_REJECT))
317#define IsConnecting(x) ((x)->status == STAT_CONNECTING)
318#define IsHandshake(x) ((x)->status == STAT_HANDSHAKE)
319#define IsMe(x) ((x)->status == STAT_ME)
320#define IsUnknown(x) ((x)->status == STAT_UNKNOWN)
321#define IsServer(x) ((x)->status == STAT_SERVER)
322#define IsClient(x) ((x)->status == STAT_CLIENT)
323#define IsReject(x) ((x)->status == STAT_REJECT)
324
325#define IsAnyServer(x) (IsServer(x) || IsHandshake(x) || IsConnecting(x))
326
327#define IsOper(x) ((x)->umodes & UMODE_OPER)
328#define IsAdmin(x) ((x)->umodes & UMODE_ADMIN)
329
330#define SetReject(x) {(x)->status = STAT_REJECT; \
331 (x)->handler = UNREGISTERED_HANDLER; }
332
333#define SetConnecting(x) {(x)->status = STAT_CONNECTING; \
334 (x)->handler = UNREGISTERED_HANDLER; }
335
336#define SetHandshake(x) {(x)->status = STAT_HANDSHAKE; \
337 (x)->handler = UNREGISTERED_HANDLER; }
338
339#define SetMe(x) {(x)->status = STAT_ME; \
340 (x)->handler = UNREGISTERED_HANDLER; }
341
342#define SetUnknown(x) {(x)->status = STAT_UNKNOWN; \
343 (x)->handler = UNREGISTERED_HANDLER; }
344
345#define SetServer(x) {(x)->status = STAT_SERVER; \
346 (x)->handler = SERVER_HANDLER; }
347
348#define SetClient(x) {(x)->status = STAT_CLIENT; \
349 (x)->handler = IsOper((x)) ? \
350 OPER_HANDLER : CLIENT_HANDLER; }
351#define SetRemoteClient(x) {(x)->status = STAT_CLIENT; \
352 (x)->handler = RCLIENT_HANDLER; }
353
354#define STAT_CLIENT_PARSE (STAT_UNKNOWN | STAT_CLIENT)
355#define STAT_SERVER_PARSE (STAT_CONNECTING | STAT_HANDSHAKE | STAT_SERVER)
356
357#define PARSE_AS_CLIENT(x) ((x)->status & STAT_CLIENT_PARSE)
358#define PARSE_AS_SERVER(x) ((x)->status & STAT_SERVER_PARSE)
359
360
361/*
362 * ts stuff
363 */
364#define TS_CURRENT 6
212380e3 365#define TS_MIN 6
212380e3 366
367#define TS_DOESTS 0x10000000
368#define DoesTS(x) ((x)->tsinfo & TS_DOESTS)
369
370#define has_id(source) ((source)->id[0] != '\0')
371#define use_id(source) ((source)->id[0] != '\0' ? (source)->id : (source)->name)
372
373/* if target is TS6, use id if it has one, else name */
374#define get_id(source, target) ((IsServer(target->from) && has_id(target->from)) ? \
375 use_id(source) : (source)->name)
376
377/* housekeeping flags */
378
379#define FLAGS_PINGSENT 0x0001 /* Unreplied ping sent */
380#define FLAGS_DEAD 0x0002 /* Local socket is dead--Exiting soon */
381#define FLAGS_KILLED 0x0004 /* Prevents "QUIT" from being sent for this */
382#define FLAGS_SENTUSER 0x0008 /* Client sent a USER command. */
2d2c402d 383#define FLAGS_CLICAP 0x0010 /* In CAP negotiation, wait for CAP END */
212380e3 384#define FLAGS_CLOSING 0x0020 /* set when closing to suppress errors */
2d2c402d 385#define FLAGS_PING_COOKIE 0x0040 /* has sent ping cookie */
212380e3 386#define FLAGS_GOTID 0x0080 /* successful ident lookup achieved */
2d2c402d 387#define FLAGS_FLOODDONE 0x0100 /* flood grace period over / reported */
212380e3 388#define FLAGS_NORMALEX 0x0400 /* Client exited normally */
6145bb60
VY
389#define FLAGS_MARK 0x10000 /* marked client */
390#define FLAGS_HIDDEN 0x20000 /* hidden server */
391#define FLAGS_EOB 0x40000 /* EOB */
392#define FLAGS_MYCONNECT 0x80000 /* MyConnect */
393#define FLAGS_IOERROR 0x100000 /* IO error */
394#define FLAGS_SERVICE 0x200000 /* network service */
395#define FLAGS_TGCHANGE 0x400000 /* we're allowed to clear something */
396#define FLAGS_DYNSPOOF 0x800000 /* dynamic spoof, only opers see ip */
212380e3 397
16cb94cc
WP
398/* flags for local clients, this needs stuff moved from above to here at some point */
399#define LFLAGS_SSL 0x00000001
400#define LFLAGS_FLUSH 0x00000002
8db00894
VY
401#define LFLAGS_CORK 0x00000004
402
212380e3 403/* umodes, settable flags */
404/* lots of this moved to snomask -- jilles */
405#define UMODE_SERVNOTICE 0x0001 /* server notices */
8e936daf
VY
406#define UMODE_WALLOP 0x0002 /* send wallops to them */
407#define UMODE_OPERWALL 0x0004 /* Operwalls */
408#define UMODE_INVISIBLE 0x0008 /* makes user invisible */
409#define UMODE_CALLERID 0x0010 /* block unless caller id's */
410#define UMODE_LOCOPS 0x0020 /* show locops */
411#define UMODE_SERVICE 0x0040
412#define UMODE_DEAF 0x0080
413#define UMODE_NOFORWARD 0x0100 /* don't forward */
414#define UMODE_REGONLYMSG 0x0200 /* only allow logged in users to msg */
212380e3 415
416/* user information flags, only settable by remote mode or local oper */
8e936daf
VY
417#define UMODE_OPER 0x1000 /* Operator */
418#define UMODE_ADMIN 0x2000 /* Admin on server */
419#define UMODE_SSLCLIENT 0x4000 /* using SSL */
212380e3 420
212380e3 421/* overflow flags */
422/* EARLIER FLAGS ARE IN s_newconf.h */
333d73ff 423#define FLAGS2_EXEMPTRESV 0x00400000
d5a432fa
VY
424#define FLAGS2_EXEMPTKLINE 0x00800000
425#define FLAGS2_EXEMPTFLOOD 0x01000000
333d73ff 426#define FLAGS2_IP_SPOOFING 0x10000000
212380e3 427#define FLAGS2_EXEMPTSPAMBOT 0x20000000
428#define FLAGS2_EXEMPTSHIDE 0x40000000
429#define FLAGS2_EXEMPTJUPE 0x80000000
430
431#define DEFAULT_OPER_UMODES (UMODE_SERVNOTICE | UMODE_OPERWALL | \
432 UMODE_WALLOP | UMODE_LOCOPS)
433#define DEFAULT_OPER_SNOMASK SNO_GENERAL
434
212380e3 435#define CLICAP_MULTI_PREFIX 0x0001
436#define CLICAP_SASL 0x0002
437
438/*
439 * flags macros.
440 */
441#define IsPerson(x) (IsClient(x) && (x)->user != NULL)
212380e3 442#define HasServlink(x) ((x)->flags & FLAGS_SERVLINK)
443#define SetServlink(x) ((x)->flags |= FLAGS_SERVLINK)
444#define MyConnect(x) ((x)->flags & FLAGS_MYCONNECT)
445#define SetMyConnect(x) ((x)->flags |= FLAGS_MYCONNECT)
446#define ClearMyConnect(x) ((x)->flags &= ~FLAGS_MYCONNECT)
447
448#define MyClient(x) (MyConnect(x) && IsClient(x))
449#define SetMark(x) ((x)->flags |= FLAGS_MARK)
450#define ClearMark(x) ((x)->flags &= ~FLAGS_MARK)
451#define IsMarked(x) ((x)->flags & FLAGS_MARK)
452#define SetHidden(x) ((x)->flags |= FLAGS_HIDDEN)
453#define ClearHidden(x) ((x)->flags &= ~FLAGS_HIDDEN)
454#define IsHidden(x) ((x)->flags & FLAGS_HIDDEN)
455#define ClearEob(x) ((x)->flags &= ~FLAGS_EOB)
456#define SetEob(x) ((x)->flags |= FLAGS_EOB)
457#define HasSentEob(x) ((x)->flags & FLAGS_EOB)
458#define IsDead(x) ((x)->flags & FLAGS_DEAD)
459#define SetDead(x) ((x)->flags |= FLAGS_DEAD)
460#define IsClosing(x) ((x)->flags & FLAGS_CLOSING)
461#define SetClosing(x) ((x)->flags |= FLAGS_CLOSING)
462#define IsIOError(x) ((x)->flags & FLAGS_IOERROR)
463#define SetIOError(x) ((x)->flags |= FLAGS_IOERROR)
464#define IsAnyDead(x) (IsIOError(x) || IsDead(x) || IsClosing(x))
465#define IsTGChange(x) ((x)->flags & FLAGS_TGCHANGE)
466#define SetTGChange(x) ((x)->flags |= FLAGS_TGCHANGE)
467#define ClearTGChange(x) ((x)->flags &= ~FLAGS_TGCHANGE)
468#define IsDynSpoof(x) ((x)->flags & FLAGS_DYNSPOOF)
469#define SetDynSpoof(x) ((x)->flags |= FLAGS_DYNSPOOF)
470#define ClearDynSpoof(x) ((x)->flags &= ~FLAGS_DYNSPOOF)
471
16cb94cc
WP
472/* local flags */
473
474#define IsSSL(x) ((x)->localClient->localflags & LFLAGS_SSL)
475#define SetSSL(x) ((x)->localClient->localflags |= LFLAGS_SSL)
476#define ClearSSL(x) ((x)->localClient->localflags &= ~LFLAGS_SSL)
477
478#define IsFlush(x) ((x)->localClient->localflags & LFLAGS_FLUSH)
479#define SetFlush(x) ((x)->localClient->localflags |= LFLAGS_FLUSH)
8db00894
VY
480#define ClearFlush(x) ((x)->localClient->localflags &= ~LFLAGS_FLUSH)
481
212380e3 482/* oper flags */
483#define MyOper(x) (MyConnect(x) && IsOper(x))
484
485#define SetOper(x) {(x)->umodes |= UMODE_OPER; \
486 if (MyClient((x))) (x)->handler = OPER_HANDLER;}
487
488#define ClearOper(x) {(x)->umodes &= ~(UMODE_OPER|UMODE_ADMIN); \
489 if (MyClient((x)) && !IsOper((x)) && !IsServer((x))) \
490 (x)->handler = CLIENT_HANDLER; }
491
212380e3 492/* umode flags */
493#define IsInvisible(x) ((x)->umodes & UMODE_INVISIBLE)
494#define SetInvisible(x) ((x)->umodes |= UMODE_INVISIBLE)
495#define ClearInvisible(x) ((x)->umodes &= ~UMODE_INVISIBLE)
5da17c50
WP
496#define IsSSLClient(x) ((x)->umodes & UMODE_SSLCLIENT)
497#define SetSSLClient(x) ((x)->umodes |= UMODE_SSLCLIENT)
498#define ClearSSLClient(x) ((x)->umodes &= ~UMODE_SSLCLIENT)
212380e3 499#define SendWallops(x) ((x)->umodes & UMODE_WALLOP)
212380e3 500#define SendLocops(x) ((x)->umodes & UMODE_LOCOPS)
501#define SendServNotice(x) ((x)->umodes & UMODE_SERVNOTICE)
502#define SendOperwall(x) ((x)->umodes & UMODE_OPERWALL)
212380e3 503#define IsSetCallerId(x) ((x)->umodes & UMODE_CALLERID)
504#define IsService(x) ((x)->umodes & UMODE_SERVICE)
505#define IsDeaf(x) ((x)->umodes & UMODE_DEAF)
506#define IsNoForward(x) ((x)->umodes & UMODE_NOFORWARD)
507#define IsSetRegOnlyMsg(x) ((x)->umodes & UMODE_REGONLYMSG)
508
212380e3 509#define SetGotId(x) ((x)->flags |= FLAGS_GOTID)
510#define IsGotId(x) (((x)->flags & FLAGS_GOTID) != 0)
511
512/*
513 * flags2 macros.
514 */
515#define IsExemptKline(x) ((x)->flags2 & FLAGS2_EXEMPTKLINE)
516#define SetExemptKline(x) ((x)->flags2 |= FLAGS2_EXEMPTKLINE)
212380e3 517#define IsExemptFlood(x) ((x)->flags2 & FLAGS2_EXEMPTFLOOD)
518#define SetExemptFlood(x) ((x)->flags2 |= FLAGS2_EXEMPTFLOOD)
519#define IsExemptSpambot(x) ((x)->flags2 & FLAGS2_EXEMPTSPAMBOT)
520#define SetExemptSpambot(x) ((x)->flags2 |= FLAGS2_EXEMPTSPAMBOT)
521#define IsExemptShide(x) ((x)->flags2 & FLAGS2_EXEMPTSHIDE)
522#define SetExemptShide(x) ((x)->flags2 |= FLAGS2_EXEMPTSHIDE)
523#define IsExemptJupe(x) ((x)->flags2 & FLAGS2_EXEMPTJUPE)
524#define SetExemptJupe(x) ((x)->flags2 |= FLAGS2_EXEMPTJUPE)
525#define IsExemptResv(x) ((x)->flags2 & FLAGS2_EXEMPTRESV)
526#define SetExemptResv(x) ((x)->flags2 |= FLAGS2_EXEMPTRESV)
527#define IsIPSpoof(x) ((x)->flags2 & FLAGS2_IP_SPOOFING)
528#define SetIPSpoof(x) ((x)->flags2 |= FLAGS2_IP_SPOOFING)
529
212380e3 530/* for local users: flood grace period is over
531 * for servers: mentioned in networknotice.c notice
532 */
2d2c402d
JT
533#define IsFloodDone(x) ((x)->flags & FLAGS_FLOODDONE)
534#define SetFloodDone(x) ((x)->flags |= FLAGS_FLOODDONE)
212380e3 535
16cb94cc
WP
536/* These also operate on the uplink from which it came */
537#define IsCork(x) (MyConnect(x) ? (x)->localClient->cork_count : (x)->from->localClient->cork_count)
538#define SetCork(x) (MyConnect(x) ? (x)->localClient->cork_count++ : (x)->from->localClient->cork_count++ )
8db00894
VY
539#define ClearCork(x) (MyConnect(x) ? (x)->localClient->cork_count-- : (x)->from->localClient->cork_count--)
540
212380e3 541/*
542 * definitions for get_client_name
543 */
544#define HIDE_IP 0
545#define SHOW_IP 1
546#define MASK_IP 2
547
548extern void check_banned_lines(void);
549extern void check_klines_event(void *unused);
550extern void check_klines(void);
212380e3 551extern void check_dlines(void);
552extern void check_xlines(void);
553
554extern const char *get_client_name(struct Client *client, int show_ip);
212380e3 555extern const char *log_client_name(struct Client *, int);
556extern int is_remote_connect(struct Client *);
557extern void init_client(void);
6d70eae6 558extern struct Client *make_client(struct Client *from);
212380e3 559extern void free_pre_client(struct Client *client);
560extern void free_client(struct Client *client);
561
562extern int exit_client(struct Client *, struct Client *, struct Client *, const char *);
563
564extern void error_exit_client(struct Client *, int);
565
566
567
568extern void count_local_client_memory(size_t * count, size_t * memory);
569extern void count_remote_client_memory(size_t * count, size_t * memory);
570
6d70eae6
JT
571extern struct Client *find_chasing(struct Client *, const char *, int *);
572extern struct Client *find_person(const char *);
573extern struct Client *find_named_person(const char *);
574extern struct Client *next_client(struct Client *, const char *);
212380e3 575
bfccb2c0 576#define accept_message(s, t) ((s) == (t) || (rb_dlinkFind((s), &((t)->localClient->allow_list))))
212380e3 577extern void del_all_accepts(struct Client *client_p);
578
25b1f927 579extern void dead_link(struct Client *client_p, int sendqex);
212380e3 580extern int show_ip(struct Client *source_p, struct Client *target_p);
581extern int show_ip_conf(struct ConfItem *aconf, struct Client *target_p);
582
583extern void initUser(void);
584extern void free_user(struct User *, struct Client *);
6d70eae6
JT
585extern struct User *make_user(struct Client *);
586extern struct Server *make_server(struct Client *);
212380e3 587extern void close_connection(struct Client *);
588extern void init_uid(void);
589extern char *generate_uid(void);
590
16cb94cc 591void allocate_away(struct Client *);
ece36b7b
VY
592void free_away(struct Client *);
593
212380e3 594#endif /* INCLUDED_client_h */