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