Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / include / client.h
1 /*
2  * IRC - Internet Relay Chat, include/client.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 2, 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  *
21  * $Id$
22  */
23 #ifndef INCLUDED_client_h
24 #define INCLUDED_client_h
25 #ifndef INCLUDED_ircd_defs_h
26 #include "ircd_defs.h"
27 #endif
28 #ifndef INCLUDED_dbuf_h
29 #include "dbuf.h"
30 #endif
31 #ifndef INCLUDED_msgq_h
32 #include "msgq.h"
33 #endif
34 #ifndef INCLUDED_ircd_handler_h
35 #include "ircd_handler.h"
36 #endif
37 #ifndef INCLUDED_sys_types_h
38 #include <sys/types.h>          /* time_t, size_t */
39 #define INCLUDED_sys_types_h
40 #endif
41 #ifndef INCLUDED_netinet_in_h
42 #include <netinet/in.h>         /* in_addr */
43 #define INCLUDED_netinet_in_h
44 #endif
45
46 struct ConfItem;
47 struct Listener;
48 struct ListingArgs;
49 struct SLink;
50 struct Server;
51 struct User;
52 struct Whowas;
53 struct DNSReply;
54 struct hostent;
55 struct Privs;
56
57 /*
58  * Structures
59  *
60  * Only put structures here that are being used in a very large number of
61  * source files. Other structures go in the header file of there corresponding
62  * source file, or in the source file itself (when only used in that file).
63  */
64
65 #define PRIV_CHAN_LIMIT          1 /* no channel limit on oper */
66 #define PRIV_MODE_LCHAN          2 /* oper can mode local chans */
67 #define PRIV_WALK_LCHAN          3 /* oper can walk thru local modes */
68 #define PRIV_DEOP_LCHAN          4 /* no deop oper on local chans */
69 #define PRIV_SHOW_INVIS          5 /* show local invisible users */
70 #define PRIV_SHOW_ALL_INVIS      6 /* show all invisible users */
71 #define PRIV_UNLIMIT_QUERY       7 /* unlimit who queries */
72
73 #define PRIV_KILL                8 /* oper can KILL */
74 #define PRIV_LOCAL_KILL          9 /* oper can local KILL */
75 #define PRIV_REHASH             10 /* oper can REHASH */
76 #define PRIV_RESTART            11 /* oper can RESTART */
77 #define PRIV_DIE                12 /* oper can DIE */
78 #define PRIV_GLINE              13 /* oper can GLINE */
79 #define PRIV_LOCAL_GLINE        14 /* oper can local GLINE */
80 #define PRIV_JUPE               15 /* oper can JUPE */
81 #define PRIV_LOCAL_JUPE         16 /* oper can local JUPE */
82 #define PRIV_OPMODE             17 /* oper can OP/CLEARMODE */
83 #define PRIV_LOCAL_OPMODE       18 /* oper can local OP/CLEARMODE */
84 #define PRIV_SET                19 /* oper can SET */
85 #define PRIV_WHOX               20 /* oper can use /who x */
86 #define PRIV_BADCHAN            21 /* oper can BADCHAN */
87 #define PRIV_LOCAL_BADCHAN      22 /* oper can local BADCHAN */
88 #define PRIV_SEE_CHAN           23 /* oper can see in secret chans */
89
90 #define PRIV_PROPAGATE          24 /* propagate oper status */
91 #define PRIV_DISPLAY            25 /* "Is an oper" displayed */
92 #define PRIV_SEE_OPERS          26 /* display hidden opers */
93
94 #define PRIV_LAST_PRIV          26 /* must be the same as the last priv */
95
96 #define _PRIV_NBITS             (8 * sizeof(unsigned long))
97
98 #define _PRIV_IDX(priv)         ((priv) / _PRIV_NBITS)
99 #define _PRIV_BIT(priv)         (1 << ((priv) % _PRIV_NBITS))
100
101 struct Privs {
102   unsigned long priv_mask[(PRIV_LAST_PRIV / _PRIV_NBITS) + 1];
103 };
104
105 struct Connection {
106   /*
107    *  The following fields are allocated only for local clients
108    *  (directly connected to *this* server with a socket.
109    *  The first of them *MUST* be the "count"--it is the field
110    *  to which the allocation is tied to! *Never* refer to
111    *  these fields, if (from != self).
112    */
113   struct Connection*  con_next;  /* Next connection with queued data */
114   struct Connection** con_prev_p; /* What points to us */
115   struct Client*      con_client; /* Client associated with connection */
116   unsigned int        con_count; /* Amount of data in buffer */
117   int                 con_fd;    /* >= 0, for local clients */
118   int                 con_error; /* last socket level error for client */
119   unsigned int        con_snomask; /* mask for server messages */
120   time_t              con_nextnick; /* Next time a nick change is allowed */
121   time_t              con_nexttarget;/* Next time a target change is allowed */
122   unsigned int        con_cookie; /* Random number the user must PONG */
123   struct MsgQ         con_sendQ; /* Outgoing message queue--if socket full */
124   struct DBuf         con_recvQ; /* Hold for data incoming yet to be parsed */
125   unsigned int        con_sendM; /* Statistics: protocol messages send */
126   unsigned int        con_sendK; /* Statistics: total k-bytes send */
127   unsigned int        con_receiveM;/* Statistics: protocol messages received */
128   unsigned int        con_receiveK; /* Statistics: total k-bytes received */
129   unsigned short      con_sendB; /* counters to count upto 1-k lots of bytes */
130   unsigned short      con_receiveB; /* sent and received. */
131   struct Listener*    con_listener; /* listening client which we accepted
132                                        from */
133   struct SLink*       con_confs; /* Configuration record associated */
134   HandlerType         con_handler; /* message index into command table
135                                       for parsing */
136   struct DNSReply*    con_dns_reply; /* DNS reply used during client
137                                         registration */
138   struct ListingArgs* con_listing;
139   unsigned int        con_max_sendq; /* cached max send queue for client */
140   unsigned int        con_ping_freq; /* cached ping freq from client conf
141                                         class */
142   unsigned short      con_lastsq; /* # 2k blocks when sendqueued called last */
143   unsigned short      con_port;  /* and the remote port# too :-) */
144   unsigned char       con_targets[MAXTARGETS]; /* Hash values of current
145                                                   targets */
146   char con_sock_ip[SOCKIPLEN + 1]; /* this is the ip address as a string */
147   char con_sockhost[HOSTLEN + 1]; /* This is the host name from the socket and
148                                     after which the connection was accepted. */
149   char con_passwd[PASSWDLEN + 1];
150   char con_buffer[BUFSIZE];     /* Incoming message buffer; or the error that
151                                    caused this clients socket to be `dead' */
152 };
153
154 struct Client {
155   struct Client* cli_next;      /* link in GlobalClientList */
156   struct Client* cli_prev;      /* link in GlobalClientList */
157   struct Client* cli_hnext;     /* link in hash table bucket or this */
158   struct Connection* cli_connect; /* Connection structure associated with us */
159   struct User*   cli_user;      /* ...defined, if this is a User */
160   struct Server* cli_serv;      /* ...defined, if this is a server */
161   struct Whowas* cli_whowas;    /* Pointer to ww struct to be freed on quit */
162   char           cli_yxx[4];    /* Numeric Nick: YMM if this is a server,
163                                    XX0 if this is a user */
164   /*
165    * XXX - move these to local part for next release
166    * (lasttime, since)
167    */
168   time_t         cli_lasttime;  /* last time data read from socket */
169   time_t         cli_since;     /* last time we parsed something, flood control */
170                                 
171   time_t         cli_firsttime; /* time client was created */
172   time_t         cli_lastnick;  /* TimeStamp on nick */
173   int            cli_marker;    /* /who processing marker */
174   unsigned int   cli_flags;     /* client flags */
175   unsigned int   cli_hopcount;  /* number of servers to this 0 = local */
176   struct in_addr cli_ip;        /* Real ip# NOT defined for remote servers! */
177   short          cli_status;    /* Client type */
178   unsigned char  cli_local;     /* local or remote client */
179   struct Privs   cli_privs;     /* Oper privileges */
180   char cli_name[HOSTLEN + 1];   /* Unique name of the client, nick or host */
181   char cli_username[USERLEN + 1]; /* username here now for auth stuff */
182   char cli_info[REALLEN + 1];   /* Free form additional client information */
183 };
184
185 #define cli_next(cli)           ((cli)->cli_next)
186 #define cli_prev(cli)           ((cli)->cli_prev)
187 #define cli_hnext(cli)          ((cli)->cli_hnext)
188 #define cli_connect(cli)        ((cli)->cli_connect)
189 #define cli_from(cli)           ((cli)->cli_connect->con_client)
190 #define cli_user(cli)           ((cli)->cli_user)
191 #define cli_serv(cli)           ((cli)->cli_serv)
192 #define cli_whowas(cli)         ((cli)->cli_whowas)
193 #define cli_yxx(cli)            ((cli)->cli_yxx)
194 #define cli_lasttime(cli)       ((cli)->cli_lasttime)
195 #define cli_since(cli)          ((cli)->cli_since)
196 #define cli_firsttime(cli)      ((cli)->cli_firsttime)
197 #define cli_lastnick(cli)       ((cli)->cli_lastnick)
198 #define cli_marker(cli)         ((cli)->cli_marker)
199 #define cli_flags(cli)          ((cli)->cli_flags)
200 #define cli_hopcount(cli)       ((cli)->cli_hopcount)
201 #define cli_ip(cli)             ((cli)->cli_ip)
202 #define cli_status(cli)         ((cli)->cli_status)
203 #define cli_local(cli)          ((cli)->cli_local)
204 #define cli_privs(cli)          ((cli)->cli_privs)
205 #define cli_name(cli)           ((cli)->cli_name)
206 #define cli_username(cli)       ((cli)->cli_username)
207 #define cli_info(cli)           ((cli)->cli_info)
208
209 #define cli_count(cli)          ((cli)->cli_connect->con_count)
210 #define cli_fd(cli)             ((cli)->cli_connect->con_fd)
211 #define cli_error(cli)          ((cli)->cli_connect->con_error)
212 #define cli_snomask(cli)        ((cli)->cli_connect->con_snomask)
213 #define cli_nextnick(cli)       ((cli)->cli_connect->con_nextnick)
214 #define cli_nexttarget(cli)     ((cli)->cli_connect->con_nexttarget)
215 #define cli_cookie(cli)         ((cli)->cli_connect->con_cookie)
216 #define cli_sendQ(cli)          ((cli)->cli_connect->con_sendQ)
217 #define cli_recvQ(cli)          ((cli)->cli_connect->con_recvQ)
218 #define cli_sendM(cli)          ((cli)->cli_connect->con_sendM)
219 #define cli_sendK(cli)          ((cli)->cli_connect->con_sendK)
220 #define cli_receiveM(cli)       ((cli)->cli_connect->con_receiveM)
221 #define cli_receiveK(cli)       ((cli)->cli_connect->con_receiveK)
222 #define cli_sendB(cli)          ((cli)->cli_connect->con_sendB)
223 #define cli_receiveB(cli)       ((cli)->cli_connect->con_receiveB)
224 #define cli_listener(cli)       ((cli)->cli_connect->con_listener)
225 #define cli_confs(cli)          ((cli)->cli_connect->con_confs)
226 #define cli_handler(cli)        ((cli)->cli_connect->con_handler)
227 #define cli_dns_reply(cli)      ((cli)->cli_connect->con_dns_reply)
228 #define cli_listing(cli)        ((cli)->cli_connect->con_listing)
229 #define cli_max_sendq(cli)      ((cli)->cli_connect->con_max_sendq)
230 #define cli_ping_freq(cli)      ((cli)->cli_connect->con_ping_freq)
231 #define cli_lastsq(cli)         ((cli)->cli_connect->con_lastsq)
232 #define cli_port(cli)           ((cli)->cli_connect->con_port)
233 #define cli_targets(cli)        ((cli)->cli_connect->con_targets)
234 #define cli_sock_ip(cli)        ((cli)->cli_connect->con_sock_ip)
235 #define cli_sockhost(cli)       ((cli)->cli_connect->con_sockhost)
236 #define cli_passwd(cli)         ((cli)->cli_connect->con_passwd)
237 #define cli_buffer(cli)         ((cli)->cli_connect->con_buffer)
238
239 #define con_next(con)           ((con)->con_next)
240 #define con_prev_p(con)         ((con)->con_prev_p)
241 #define con_client(con)         ((con)->con_client)
242 #define con_count(con)          ((con)->con_count)
243 #define con_fd(con)             ((con)->con_fd)
244 #define con_error(con)          ((con)->con_error)
245 #define con_snomask(con)        ((con)->con_snomask)
246 #define con_nextnick(con)       ((con)->con_nextnick)
247 #define con_nexttarget(con)     ((con)->con_nexttarget)
248 #define con_cookie(con)         ((con)->con_cookie)
249 #define con_sendQ(con)          ((con)->con_sendQ)
250 #define con_recvQ(con)          ((con)->con_recvQ)
251 #define con_sendM(con)          ((con)->con_sendM)
252 #define con_sendK(con)          ((con)->con_sendK)
253 #define con_receiveM(con)       ((con)->con_receiveM)
254 #define con_receiveK(con)       ((con)->con_receiveK)
255 #define con_sendB(con)          ((con)->con_sendB)
256 #define con_receiveB(con)       ((con)->con_receiveB)
257 #define con_listener(con)       ((con)->con_listener)
258 #define con_confs(con)          ((con)->con_confs)
259 #define con_handler(con)        ((con)->con_handler)
260 #define con_dns_reply(con)      ((con)->con_dns_reply)
261 #define con_listing(con)        ((con)->con_listing)
262 #define con_max_sendq(con)      ((con)->con_max_sendq)
263 #define con_ping_freq(con)      ((con)->con_ping_freq)
264 #define con_lastsq(con)         ((con)->con_lastsq)
265 #define con_port(con)           ((con)->con_port)
266 #define con_targets(con)        ((con)->con_targets)
267 #define con_sock_ip(con)        ((con)->con_sock_ip)
268 #define con_sockhost(con)       ((con)->con_sockhost)
269 #define con_passwd(con)         ((con)->con_passwd)
270 #define con_buffer(con)         ((con)->con_buffer)
271
272 #define STAT_CONNECTING         0x001 /* connecting to another server */
273 #define STAT_HANDSHAKE          0x002 /* pass - server sent */
274 #define STAT_ME                 0x004 /* this server */
275 #define STAT_UNKNOWN            0x008 /* unidentified connection */
276 #define STAT_UNKNOWN_USER       0x010 /* Connect to client port */
277 #define STAT_UNKNOWN_SERVER     0x020 /* Connect to server port */
278 #define STAT_SERVER             0x040
279 #define STAT_USER               0x080
280
281 /*
282  * status macros.
283  */
284 #define IsRegistered(x)         (cli_status(x) & (STAT_SERVER | STAT_USER))
285 #define IsConnecting(x)         (cli_status(x) == STAT_CONNECTING)
286 #define IsHandshake(x)          (cli_status(x) == STAT_HANDSHAKE)
287 #define IsMe(x)                 (cli_status(x) == STAT_ME)
288 #define IsUnknown(x)            (cli_status(x) & \
289         (STAT_UNKNOWN | STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER))
290
291 #define IsServerPort(x)         (cli_status(x) == STAT_UNKNOWN_SERVER )
292 #define IsUserPort(x)           (cli_status(x) == STAT_UNKNOWN_USER )
293 #define IsClient(x)             (cli_status(x) & \
294         (STAT_HANDSHAKE | STAT_ME | STAT_UNKNOWN |\
295          STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER | STAT_SERVER | STAT_USER))
296
297 #define IsTrusted(x)            (cli_status(x) & \
298         (STAT_CONNECTING | STAT_HANDSHAKE | STAT_ME | STAT_SERVER))
299
300 #define IsServer(x)             (cli_status(x) == STAT_SERVER)
301 #define IsUser(x)               (cli_status(x) == STAT_USER)
302
303
304 #define SetConnecting(x)        (cli_status(x) = STAT_CONNECTING)
305 #define SetHandshake(x)         (cli_status(x) = STAT_HANDSHAKE)
306 #define SetServer(x)            (cli_status(x) = STAT_SERVER)
307 #define SetMe(x)                (cli_status(x) = STAT_ME)
308 #define SetUser(x)              (cli_status(x) = STAT_USER)
309
310 #define MyConnect(x)    (cli_from(x) == (x))
311 #define MyUser(x)       (MyConnect(x) && IsUser(x))
312 #define MyOper(x)       (MyConnect(x) && IsOper(x))
313 #define Protocol(x)     ((cli_serv(x))->prot)
314
315 #define PARSE_AS_SERVER(x) (cli_status(x) & \
316             (STAT_SERVER | STAT_CONNECTING | STAT_HANDSHAKE))
317
318 /*
319  * FLAGS macros
320  */
321 #define FLAGS_PINGSENT   0x0001 /* Unreplied ping sent */
322 #define FLAGS_DEADSOCKET 0x0002 /* Local socket is dead--Exiting soon */
323 #define FLAGS_KILLED     0x0004 /* Prevents "QUIT" from being sent for this */
324 #define FLAGS_OPER       0x0008 /* Operator */
325 #define FLAGS_LOCOP      0x0010 /* Local operator -- SRB */
326 #define FLAGS_INVISIBLE  0x0020 /* makes user invisible */
327 #define FLAGS_WALLOP     0x0040 /* send wallops to them */
328 #define FLAGS_SERVNOTICE 0x0080 /* server notices such as kill */
329 #define FLAGS_BLOCKED    0x0100 /* socket is in a blocked condition */
330 #define FLAGS_CLOSING    0x0400 /* set when closing to suppress errors */
331 #define FLAGS_UPING      0x0800 /* has active UDP ping request */
332 #define FLAGS_CHKACCESS  0x1000 /* ok to check clients access if set */
333 #define FLAGS_LOCAL     0x00010000      /* set for local clients */
334 #define FLAGS_GOTID     0x00020000      /* successful ident lookup achieved */
335 #define FLAGS_DOID      0x00040000      /* I-lines say must use ident return */
336 #define FLAGS_NONL      0x00080000      /* No \n in buffer */
337 #define FLAGS_TS8       0x00100000      /* Why do you want to know? */
338 #define FLAGS_MAP       0x00800000      /* Show server on the map */
339 #define FLAGS_JUNCTION  0x01000000      /* Junction causing the net.burst */
340 #define FLAGS_DEAF      0x02000000      /* Makes user deaf */
341 #define FLAGS_CHSERV    0x04000000      /* Disallow KICK or MODE -o on the user;
342                                            don't display channels in /whois */
343 #define FLAGS_BURST     0x08000000      /* Server is receiving a net.burst */
344 #define FLAGS_BURST_ACK 0x10000000      /* Server is waiting for eob ack */
345 #define FLAGS_DEBUG     0x20000000      /* send global debug/anti-hack info */
346 #define FLAGS_IPCHECK   0x40000000      /* Added or updated IPregistry data */
347
348 #define SEND_UMODES \
349     (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP|FLAGS_DEAF|FLAGS_CHSERV|FLAGS_DEBUG)
350 #define ALL_UMODES (SEND_UMODES|FLAGS_SERVNOTICE|FLAGS_LOCOP)
351 #define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID)
352
353 /*
354  * flags macros.
355  */
356 #define DoAccess(x)             (cli_flags(x) & FLAGS_CHKACCESS)
357 #define IsAnOper(x)             (cli_flags(x) & (FLAGS_OPER|FLAGS_LOCOP))
358 #define IsBlocked(x)            (cli_flags(x) & FLAGS_BLOCKED)
359 #define IsBurst(x)              (cli_flags(x) & FLAGS_BURST)
360 #define IsBurstAck(x)           (cli_flags(x) & FLAGS_BURST_ACK)
361 #define IsBurstOrBurstAck(x)    (cli_flags(x) & (FLAGS_BURST|FLAGS_BURST_ACK))
362 #define IsChannelService(x)     (cli_flags(x) & FLAGS_CHSERV)
363 #define IsDead(x)               (cli_flags(x) & FLAGS_DEADSOCKET)
364 #define IsDeaf(x)               (cli_flags(x) & FLAGS_DEAF)
365 #define IsIPChecked(x)          (cli_flags(x) & FLAGS_IPCHECK)
366 #define IsIdented(x)            (cli_flags(x) & FLAGS_GOTID)
367 #define IsInvisible(x)          (cli_flags(x) & FLAGS_INVISIBLE)
368 #define IsJunction(x)           (cli_flags(x) & FLAGS_JUNCTION)
369 #define IsLocOp(x)              (cli_flags(x) & FLAGS_LOCOP)
370 #define IsLocal(x)              (cli_flags(x) & FLAGS_LOCAL)
371 #define IsOper(x)               (cli_flags(x) & FLAGS_OPER)
372 #define IsUPing(x)              (cli_flags(x) & FLAGS_UPING)
373 #define NoNewLine(x)            (cli_flags(x) & FLAGS_NONL)
374 #define SendDebug(x)            (cli_flags(x) & FLAGS_DEBUG)
375 #define SendServNotice(x)       (cli_flags(x) & FLAGS_SERVNOTICE)
376 #define SendWallops(x)          (cli_flags(x) & FLAGS_WALLOP)
377
378 #define IsPrivileged(x)         (IsAnOper(x) || IsServer(x))
379
380 #define SetAccess(x)            (cli_flags(x) |= FLAGS_CHKACCESS)
381 #define SetBurst(x)             (cli_flags(x) |= FLAGS_BURST)
382 #define SetBurstAck(x)          (cli_flags(x) |= FLAGS_BURST_ACK)
383 #define SetChannelService(x)    (cli_flags(x) |= FLAGS_CHSERV)
384 #define SetDeaf(x)              (cli_flags(x) |= FLAGS_DEAF)
385 #define SetDebug(x)             (cli_flags(x) |= FLAGS_DEBUG)
386 #define SetGotId(x)             (cli_flags(x) |= FLAGS_GOTID)
387 #define SetIPChecked(x)         (cli_flags(x) |= FLAGS_IPCHECK)
388 #define SetInvisible(x)         (cli_flags(x) |= FLAGS_INVISIBLE)
389 #define SetJunction(x)          (cli_flags(x) |= FLAGS_JUNCTION)
390 #define SetLocOp(x)             (cli_flags(x) |= FLAGS_LOCOP)
391 #define SetOper(x)              (cli_flags(x) |= FLAGS_OPER)
392 #define SetUPing(x)             (cli_flags(x) |= FLAGS_UPING)
393 #define SetWallops(x)           (cli_flags(x) |= FLAGS_WALLOP)
394 #define SetServNotice(x)        (cli_flags(x) |= FLAGS_SERVNOTICE)
395
396 #define ClearAccess(x)          (cli_flags(x) &= ~FLAGS_CHKACCESS)
397 #define ClearBurst(x)           (cli_flags(x) &= ~FLAGS_BURST)
398 #define ClearBurstAck(x)        (cli_flags(x) &= ~FLAGS_BURST_ACK)
399 #define ClearChannelService(x)  (cli_flags(x) &= ~FLAGS_CHSERV)
400 #define ClearDeaf(x)            (cli_flags(x) &= ~FLAGS_DEAF)
401 #define ClearDebug(x)           (cli_flags(x) &= ~FLAGS_DEBUG)
402 #define ClearIPChecked(x)       (cli_flags(x) &= ~FLAGS_IPCHECK)
403 #define ClearInvisible(x)       (cli_flags(x) &= ~FLAGS_INVISIBLE)
404 #define ClearLocOp(x)           (cli_flags(x) &= ~FLAGS_LOCOP)
405 #define ClearOper(x)            (cli_flags(x) &= ~FLAGS_OPER)
406 #define ClearUPing(x)           (cli_flags(x) &= ~FLAGS_UPING)
407 #define ClearWallops(x)         (cli_flags(x) &= ~FLAGS_WALLOP)
408 #define ClearServNotice(x)      (cli_flags(x) &= ~FLAGS_SERVNOTICE)
409
410 /* server notice stuff */
411
412 #define SNO_ADD         1
413 #define SNO_DEL         2
414 #define SNO_SET         3
415                                 /* DON'T CHANGE THESE VALUES ! */
416                                 /* THE CLIENTS DEPEND ON IT  ! */
417 #define SNO_OLDSNO      0x1     /* unsorted old messages */
418 #define SNO_SERVKILL    0x2     /* server kills (nick collisions) */
419 #define SNO_OPERKILL    0x4     /* oper kills */
420 #define SNO_HACK2       0x8     /* desyncs */
421 #define SNO_HACK3       0x10    /* temporary desyncs */
422 #define SNO_UNAUTH      0x20    /* unauthorized connections */
423 #define SNO_TCPCOMMON   0x40    /* common TCP or socket errors */
424 #define SNO_TOOMANY     0x80    /* too many connections */
425 #define SNO_HACK4       0x100   /* Uworld actions on channels */
426 #define SNO_GLINE       0x200   /* glines */
427 #define SNO_NETWORK     0x400   /* net join/break, etc */
428 #define SNO_IPMISMATCH  0x800   /* IP mismatches */
429 #define SNO_THROTTLE    0x1000  /* host throttle add/remove notices */
430 #define SNO_OLDREALOP   0x2000  /* old oper-only messages */
431 #define SNO_CONNEXIT    0x4000  /* client connect/exit (ugh) */
432 #define SNO_DEBUG       0x8000  /* debugging messages (DEBUGMODE only) */
433
434 #ifdef DEBUGMODE
435 # define SNO_ALL        0xffff  /* Don't make it larger then significant,
436                                  * that looks nicer */
437 #else
438 # define SNO_ALL        0x7fff
439 #endif
440
441 #define SNO_USER        (SNO_ALL & ~SNO_OPER)
442
443 #define SNO_DEFAULT (SNO_NETWORK|SNO_OPERKILL|SNO_GLINE)
444 #define SNO_OPERDEFAULT (SNO_DEFAULT|SNO_HACK2|SNO_HACK4|SNO_THROTTLE|SNO_OLDSNO)
445 #define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP)
446 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
447
448 #define PrivSet(pset, priv)     ((pset)->priv_mask[_PRIV_IDX(priv)] |= \
449                                  _PRIV_BIT(priv))
450 #define PrivClr(pset, priv)     ((pset)->priv_mask[_PRIV_IDX(priv)] &= \
451                                  ~(_PRIV_BIT(priv)))
452 #define PrivHas(pset, priv)     ((pset)->priv_mask[_PRIV_IDX(priv)] & \
453                                  _PRIV_BIT(priv))
454
455 #define GrantPriv(cli, priv)    (PrivSet(&(cli_privs(cli)), priv))
456 #define RevokePriv(cli, priv)   (PrivClr(&(cli_privs(cli)), priv))
457 #define HasPriv(cli, priv)      (PrivHas(&(cli_privs(cli)), priv))
458
459 typedef enum ShowIPType {
460   HIDE_IP,
461   SHOW_IP,
462   MASK_IP
463 } ShowIPType;
464
465 extern const char* get_client_name(const struct Client* sptr, int showip);
466 extern int client_get_ping(const struct Client* local_client);
467 extern void client_drop_sendq(struct Connection* con);
468 extern void client_add_sendq(struct Connection* con,
469                              struct Connection** con_p);
470 extern void client_set_privs(struct Client* client);
471 extern int client_report_privs(struct Client* to, struct Client* client);
472
473 #endif /* INCLUDED_client_h */
474