2 * IRC - Internet Relay Chat, include/client.h
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
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)
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.
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.
23 #ifndef INCLUDED_client_h
24 #define INCLUDED_client_h
25 #ifndef INCLUDED_ircd_defs_h
26 #include "ircd_defs.h"
28 #ifndef INCLUDED_dbuf_h
31 #ifndef INCLUDED_msgq_h
34 #ifndef INCLUDED_ircd_events_h
35 #include "ircd_events.h"
37 #ifndef INCLUDED_ircd_handler_h
38 #include "ircd_handler.h"
40 #ifndef INCLUDED_sys_types_h
41 #include <sys/types.h> /* time_t, size_t */
42 #define INCLUDED_sys_types_h
44 #ifndef INCLUDED_netinet_in_h
45 #include <netinet/in.h> /* in_addr */
46 #define INCLUDED_netinet_in_h
63 * Only put structures here that are being used in a very large number of
64 * source files. Other structures go in the header file of there corresponding
65 * source file, or in the source file itself (when only used in that file).
68 typedef unsigned long flagpage_t;
70 #define FLAGSET_NBITS (8 * sizeof(flagpage_t))
71 #define FLAGSET_INDEX(flag) (flag / FLAGSET_NBITS)
72 #define FLAGSET_MASK(flag) (1<<(flag % FLAGSET_NBITS))
74 #define DECLARE_FLAGSET(name,max) \
77 unsigned long bits[((max + FLAGSET_NBITS - 1) / FLAGSET_NBITS)]; \
80 #define FLAGSET_ISSET(set,flag) ((set).bits[FLAGSET_INDEX(flag)] & FLAGSET_MASK(flag))
81 #define FLAGSET_SET(set, flag) (set).bits[FLAGSET_INDEX(flag)] |= FLAGSET_MASK(flag)
82 #define FLAGSET_CLEAR(set, flag) (set).bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag)
84 #define infousermodes "dioswkgx"
88 PRIV_CHAN_LIMIT, /* no channel limit on oper */
89 PRIV_MODE_LCHAN, /* oper can mode local chans */
90 PRIV_WALK_LCHAN, /* oper can walk thru local modes */
91 PRIV_DEOP_LCHAN, /* no deop oper on local chans */
92 PRIV_SHOW_INVIS, /* show local invisible users */
93 PRIV_SHOW_ALL_INVIS, /* show all invisible users */
94 PRIV_UNLIMIT_QUERY, /* unlimit who queries */
95 PRIV_KILL, /* oper can KILL */
96 PRIV_LOCAL_KILL, /* oper can local KILL */
97 PRIV_REHASH, /* oper can REHASH */
98 PRIV_RESTART, /* oper can RESTART */
99 PRIV_DIE, /* oper can DIE */
100 PRIV_GLINE, /* oper can GLINE */
101 PRIV_LOCAL_GLINE, /* oper can local GLINE */
102 PRIV_JUPE, /* oper can JUPE */
103 PRIV_LOCAL_JUPE, /* oper can local JUPE */
104 PRIV_OPMODE, /* oper can OP/CLEARMODE */
105 PRIV_LOCAL_OPMODE, /* oper can local OP/CLEARMODE */
106 PRIV_SET, /* oper can SET */
107 PRIV_WHOX, /* oper can use /who x */
108 PRIV_BADCHAN, /* oper can BADCHAN */
109 PRIV_LOCAL_BADCHAN, /* oper can local BADCHAN */
110 PRIV_SEE_CHAN, /* oper can see in secret chans */
111 PRIV_PROPAGATE, /* propagate oper status */
112 PRIV_DISPLAY, /* "Is an oper" displayed */
113 PRIV_SEE_OPERS, /* display hidden opers */
114 PRIV_WIDE_GLINE, /* oper can set wider G-lines */
115 PRIV_LIST_CHAN, /* oper can list secret channels */
117 PRIV_FORCE_LOCAL_OPMODE,
118 PRIV_LAST_PRIV /* must be the same as the last priv */
123 FLAG_PINGSENT, /* Unreplied ping sent */
124 FLAG_DEADSOCKET, /* Local socket is dead--Exiting soon */
125 FLAG_KILLED, /* Prevents "QUIT" from being sent for this */
126 FLAG_BLOCKED, /* socket is in a blocked condition */
127 FLAG_CLOSING, /* set when closing to suppress errors */
128 FLAG_UPING, /* has active UDP ping request */
129 FLAG_CHKACCESS, /* ok to check clients access if set */
130 FLAG_HUB, /* server is a hub */
131 FLAG_SERVICE, /* server is a service */
132 FLAG_LOCAL, /* set for local clients */
133 FLAG_GOTID, /* successful ident lookup achieved */
134 FLAG_DOID, /* I-lines say must use ident return */
135 FLAG_NONL, /* No \n in buffer */
136 FLAG_TS8, /* Why do you want to know? */
137 FLAG_MAP, /* Show server on the map */
138 FLAG_JUNCTION, /* Junction causing the net.burst */
139 FLAG_BURST, /* Server is receiving a net.burst */
140 FLAG_BURST_ACK, /* Server is waiting for eob ack */
141 FLAG_IPCHECK, /* Added or updated IPregistry data */
142 FLAG_LOCOP, /* Local operator -- SRB */
143 FLAG_SERVNOTICE, /* server notices such as kill */
144 FLAG_OPER, /* Operator */
145 FLAG_INVISIBLE, /* makes user invisible */
146 FLAG_WALLOP, /* send wallops to them */
147 FLAG_DEAF, /* Makes user deaf */
148 FLAG_CHSERV, /* Disallow KICK or MODE -o on the user;
149 don't display channels in /whois */
150 FLAG_DEBUG, /* send global debug/anti-hack info */
151 FLAG_ACCOUNT, /* account name has been set */
152 FLAG_HIDDENHOST, /* user's host is hidden */
154 FLAG_LOCAL_UMODES = FLAG_LOCOP, /* First local mode flag */
155 FLAG_GLOBAL_UMODES = FLAG_OPER /* First global mode flag */
158 DECLARE_FLAGSET(Privs, PRIV_LAST_PRIV);
159 DECLARE_FLAGSET(Flags, FLAG_LAST_FLAG);
164 * The following fields are allocated only for local clients
165 * (directly connected to *this* server with a socket.
166 * The first of them *MUST* be the "count"--it is the field
167 * to which the allocation is tied to! *Never* refer to
168 * these fields, if (from != self).
170 unsigned long con_magic; /* magic number */
171 struct Connection* con_next; /* Next connection with queued data */
172 struct Connection** con_prev_p; /* What points to us */
173 struct Client* con_client; /* Client associated with connection */
174 unsigned int con_count; /* Amount of data in buffer */
175 int con_fd; /* >= 0, for local clients */
176 int con_freeflag; /* indicates if connection can be freed */
177 int con_error; /* last socket level error for client */
178 unsigned int con_snomask; /* mask for server messages */
179 time_t con_nextnick; /* Next time a nick change is allowed */
180 time_t con_nexttarget;/* Next time a target change is allowed */
181 unsigned int con_cookie; /* Random number the user must PONG */
182 struct MsgQ con_sendQ; /* Outgoing message queue--if socket full */
183 struct DBuf con_recvQ; /* Hold for data incoming yet to be parsed */
184 unsigned int con_sendM; /* Statistics: protocol messages send */
185 unsigned int con_sendK; /* Statistics: total k-bytes send */
186 unsigned int con_receiveM;/* Statistics: protocol messages received */
187 unsigned int con_receiveK; /* Statistics: total k-bytes received */
188 unsigned short con_sendB; /* counters to count upto 1-k lots of bytes */
189 unsigned short con_receiveB; /* sent and received. */
190 struct Listener* con_listener; /* listening client which we accepted
192 struct SLink* con_confs; /* Configuration record associated */
193 HandlerType con_handler; /* message index into command table
195 struct hostent* con_dns_reply; /* DNS reply used during client
197 struct ListingArgs* con_listing;
198 unsigned int con_max_sendq; /* cached max send queue for client */
199 unsigned int con_ping_freq; /* cached ping freq from client conf
201 unsigned short con_lastsq; /* # 2k blocks when sendqueued called last */
202 unsigned short con_port; /* and the remote port# too :-) */
203 unsigned char con_targets[MAXTARGETS]; /* Hash values of current
205 char con_sock_ip[SOCKIPLEN + 1]; /* this is the ip address as a string */
206 char con_sockhost[HOSTLEN + 1]; /* This is the host name from the socket and
207 after which the connection was accepted. */
208 char con_passwd[PASSWDLEN + 1];
209 char con_buffer[BUFSIZE]; /* Incoming message buffer; or the error that
210 caused this clients socket to be `dead' */
211 struct Socket con_socket; /* socket descriptor for client */
212 struct Timer con_proc; /* process latent messages from client */
213 struct AuthRequest* con_auth; /* auth request for client */
216 #define CONNECTION_MAGIC 0x12f955f3
219 unsigned long cli_magic; /* magic number */
220 struct Client* cli_next; /* link in GlobalClientList */
221 struct Client* cli_prev; /* link in GlobalClientList */
222 struct Client* cli_hnext; /* link in hash table bucket or this */
223 struct Connection* cli_connect; /* Connection structure associated with us */
224 struct User* cli_user; /* ...defined, if this is a User */
225 struct Server* cli_serv; /* ...defined, if this is a server */
226 struct Whowas* cli_whowas; /* Pointer to ww struct to be freed on quit */
227 char cli_yxx[4]; /* Numeric Nick: YMM if this is a server,
228 XX0 if this is a user */
230 * XXX - move these to local part for next release
233 time_t cli_lasttime; /* last time data read from socket */
234 time_t cli_since; /* last time we parsed something, flood control */
236 time_t cli_firsttime; /* time client was created */
237 time_t cli_lastnick; /* TimeStamp on nick */
238 int cli_marker; /* /who processing marker */
239 struct Flags cli_flags; /* client flags */
240 unsigned int cli_hopcount; /* number of servers to this 0 = local */
241 struct in_addr cli_ip; /* Real ip# NOT defined for remote servers! */
242 short cli_status; /* Client type */
243 unsigned char cli_local; /* local or remote client */
244 struct Privs cli_privs; /* Oper privileges */
245 char cli_name[HOSTLEN + 1]; /* Unique name of the client, nick or host */
246 char cli_username[USERLEN + 1]; /* username here now for auth stuff */
247 char cli_info[REALLEN + 1]; /* Free form additional client information */
250 #define CLIENT_MAGIC 0x4ca08286
252 #define cli_verify(cli) ((cli)->cli_magic == CLIENT_MAGIC)
253 #define cli_magic(cli) ((cli)->cli_magic)
254 #define cli_next(cli) ((cli)->cli_next)
255 #define cli_prev(cli) ((cli)->cli_prev)
256 #define cli_hnext(cli) ((cli)->cli_hnext)
257 #define cli_connect(cli) ((cli)->cli_connect)
258 #define cli_from(cli) ((cli)->cli_connect->con_client)
259 #define cli_user(cli) ((cli)->cli_user)
260 #define cli_serv(cli) ((cli)->cli_serv)
261 #define cli_whowas(cli) ((cli)->cli_whowas)
262 #define cli_yxx(cli) ((cli)->cli_yxx)
263 #define cli_lasttime(cli) ((cli)->cli_lasttime)
264 #define cli_since(cli) ((cli)->cli_since)
265 #define cli_firsttime(cli) ((cli)->cli_firsttime)
266 #define cli_lastnick(cli) ((cli)->cli_lastnick)
267 #define cli_marker(cli) ((cli)->cli_marker)
268 #define cli_flags(cli) ((cli)->cli_flags)
269 #define cli_hopcount(cli) ((cli)->cli_hopcount)
270 #define cli_ip(cli) ((cli)->cli_ip)
271 #define cli_status(cli) ((cli)->cli_status)
272 #define cli_local(cli) ((cli)->cli_local)
273 #define cli_privs(cli) ((cli)->cli_privs)
274 #define cli_name(cli) ((cli)->cli_name)
275 #define cli_username(cli) ((cli)->cli_username)
276 #define cli_info(cli) ((cli)->cli_info)
278 #define cli_count(cli) ((cli)->cli_connect->con_count)
279 #define cli_fd(cli) ((cli)->cli_connect->con_fd)
280 #define cli_freeflag(cli) ((cli)->cli_connect->con_freeflag)
281 #define cli_error(cli) ((cli)->cli_connect->con_error)
282 #define cli_snomask(cli) ((cli)->cli_connect->con_snomask)
283 #define cli_nextnick(cli) ((cli)->cli_connect->con_nextnick)
284 #define cli_nexttarget(cli) ((cli)->cli_connect->con_nexttarget)
285 #define cli_cookie(cli) ((cli)->cli_connect->con_cookie)
286 #define cli_sendQ(cli) ((cli)->cli_connect->con_sendQ)
287 #define cli_recvQ(cli) ((cli)->cli_connect->con_recvQ)
288 #define cli_sendM(cli) ((cli)->cli_connect->con_sendM)
289 #define cli_sendK(cli) ((cli)->cli_connect->con_sendK)
290 #define cli_receiveM(cli) ((cli)->cli_connect->con_receiveM)
291 #define cli_receiveK(cli) ((cli)->cli_connect->con_receiveK)
292 #define cli_sendB(cli) ((cli)->cli_connect->con_sendB)
293 #define cli_receiveB(cli) ((cli)->cli_connect->con_receiveB)
294 #define cli_listener(cli) ((cli)->cli_connect->con_listener)
295 #define cli_confs(cli) ((cli)->cli_connect->con_confs)
296 #define cli_handler(cli) ((cli)->cli_connect->con_handler)
297 #define cli_dns_reply(cli) ((cli)->cli_connect->con_dns_reply)
298 #define cli_listing(cli) ((cli)->cli_connect->con_listing)
299 #define cli_max_sendq(cli) ((cli)->cli_connect->con_max_sendq)
300 #define cli_ping_freq(cli) ((cli)->cli_connect->con_ping_freq)
301 #define cli_lastsq(cli) ((cli)->cli_connect->con_lastsq)
302 #define cli_port(cli) ((cli)->cli_connect->con_port)
303 #define cli_targets(cli) ((cli)->cli_connect->con_targets)
304 #define cli_sock_ip(cli) ((cli)->cli_connect->con_sock_ip)
305 #define cli_sockhost(cli) ((cli)->cli_connect->con_sockhost)
306 #define cli_passwd(cli) ((cli)->cli_connect->con_passwd)
307 #define cli_buffer(cli) ((cli)->cli_connect->con_buffer)
308 #define cli_socket(cli) ((cli)->cli_connect->con_socket)
309 #define cli_proc(cli) ((cli)->cli_connect->con_proc)
310 #define cli_auth(cli) ((cli)->cli_connect->con_auth)
312 #define con_verify(con) ((con)->con_magic == CONNECTION_MAGIC)
313 #define con_magic(con) ((con)->con_magic)
314 #define con_next(con) ((con)->con_next)
315 #define con_prev_p(con) ((con)->con_prev_p)
316 #define con_client(con) ((con)->con_client)
317 #define con_count(con) ((con)->con_count)
318 #define con_fd(con) ((con)->con_fd)
319 #define con_freeflag(con) ((con)->con_freeflag)
320 #define con_error(con) ((con)->con_error)
321 #define con_snomask(con) ((con)->con_snomask)
322 #define con_nextnick(con) ((con)->con_nextnick)
323 #define con_nexttarget(con) ((con)->con_nexttarget)
324 #define con_cookie(con) ((con)->con_cookie)
325 #define con_sendQ(con) ((con)->con_sendQ)
326 #define con_recvQ(con) ((con)->con_recvQ)
327 #define con_sendM(con) ((con)->con_sendM)
328 #define con_sendK(con) ((con)->con_sendK)
329 #define con_receiveM(con) ((con)->con_receiveM)
330 #define con_receiveK(con) ((con)->con_receiveK)
331 #define con_sendB(con) ((con)->con_sendB)
332 #define con_receiveB(con) ((con)->con_receiveB)
333 #define con_listener(con) ((con)->con_listener)
334 #define con_confs(con) ((con)->con_confs)
335 #define con_handler(con) ((con)->con_handler)
336 #define con_dns_reply(con) ((con)->con_dns_reply)
337 #define con_listing(con) ((con)->con_listing)
338 #define con_max_sendq(con) ((con)->con_max_sendq)
339 #define con_ping_freq(con) ((con)->con_ping_freq)
340 #define con_lastsq(con) ((con)->con_lastsq)
341 #define con_port(con) ((con)->con_port)
342 #define con_targets(con) ((con)->con_targets)
343 #define con_sock_ip(con) ((con)->con_sock_ip)
344 #define con_sockhost(con) ((con)->con_sockhost)
345 #define con_passwd(con) ((con)->con_passwd)
346 #define con_buffer(con) ((con)->con_buffer)
347 #define con_socket(con) ((con)->con_socket)
348 #define con_proc(con) ((con)->con_proc)
349 #define con_auth(con) ((con)->con_auth)
351 #define STAT_CONNECTING 0x001 /* connecting to another server */
352 #define STAT_HANDSHAKE 0x002 /* pass - server sent */
353 #define STAT_ME 0x004 /* this server */
354 #define STAT_UNKNOWN 0x008 /* unidentified connection */
355 #define STAT_UNKNOWN_USER 0x010 /* Connect to client port */
356 #define STAT_UNKNOWN_SERVER 0x020 /* Connect to server port */
357 #define STAT_SERVER 0x040
358 #define STAT_USER 0x080
363 #define IsRegistered(x) (cli_status(x) & (STAT_SERVER | STAT_USER))
364 #define IsConnecting(x) (cli_status(x) == STAT_CONNECTING)
365 #define IsHandshake(x) (cli_status(x) == STAT_HANDSHAKE)
366 #define IsMe(x) (cli_status(x) == STAT_ME)
367 #define IsUnknown(x) (cli_status(x) & \
368 (STAT_UNKNOWN | STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER))
370 #define IsServerPort(x) (cli_status(x) == STAT_UNKNOWN_SERVER )
371 #define IsUserPort(x) (cli_status(x) == STAT_UNKNOWN_USER )
372 #define IsClient(x) (cli_status(x) & \
373 (STAT_HANDSHAKE | STAT_ME | STAT_UNKNOWN |\
374 STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER | STAT_SERVER | STAT_USER))
376 #define IsTrusted(x) (cli_status(x) & \
377 (STAT_CONNECTING | STAT_HANDSHAKE | STAT_ME | STAT_SERVER))
379 #define IsServer(x) (cli_status(x) == STAT_SERVER)
380 #define IsUser(x) (cli_status(x) == STAT_USER)
383 #define SetConnecting(x) (cli_status(x) = STAT_CONNECTING)
384 #define SetHandshake(x) (cli_status(x) = STAT_HANDSHAKE)
385 #define SetServer(x) (cli_status(x) = STAT_SERVER)
386 #define SetMe(x) (cli_status(x) = STAT_ME)
387 #define SetUser(x) (cli_status(x) = STAT_USER)
389 #define MyConnect(x) (cli_from(x) == (x))
390 #define MyUser(x) (MyConnect(x) && IsUser(x))
391 #define MyOper(x) (MyConnect(x) && IsOper(x))
392 #define Protocol(x) ((cli_serv(x))->prot)
394 #define PARSE_AS_SERVER(x) (cli_status(x) & \
395 (STAT_SERVER | STAT_CONNECTING | STAT_HANDSHAKE))
400 #define FlagSet(fset, flag) FLAGSET_SET(*fset, flag)
401 #define FlagClr(fset, flag) FLAGSET_CLEAR(*fset, flag)
402 #define FlagHas(fset, flag) FLAGSET_ISSET(*fset, flag)
403 #define SetFlag(cli, flag) FlagSet(&cli_flags(cli), flag)
404 #define ClrFlag(cli, flag) FlagClr(&cli_flags(cli), flag)
405 #define HasFlag(cli, flag) FlagHas(&cli_flags(cli), flag)
407 #define DoAccess(x) HasFlag(x, FLAG_CHKACCESS)
408 #define IsAnOper(x) (HasFlag(x, FLAG_OPER) || HasFlag(x, FLAG_LOCOP))
409 #define IsBlocked(x) HasFlag(x, FLAG_BLOCKED)
410 #define IsBurst(x) HasFlag(x, FLAG_BURST)
411 #define IsBurstAck(x) HasFlag(x, FLAG_BURST_ACK)
412 #define IsBurstOrBurstAck(x) (HasFlag(x, FLAG_BURST) || HasFlag(x, FLAG_BURST_ACK))
413 #define IsChannelService(x) HasFlag(x, FLAG_CHSERV)
414 #define IsDead(x) HasFlag(x, FLAG_DEADSOCKET)
415 #define IsDeaf(x) HasFlag(x, FLAG_DEAF)
416 #define IsIPChecked(x) HasFlag(x, FLAG_IPCHECK)
417 #define IsIdented(x) HasFlag(x, FLAG_GOTID)
418 #define IsInvisible(x) HasFlag(x, FLAG_INVISIBLE)
419 #define IsJunction(x) HasFlag(x, FLAG_JUNCTION)
420 #define IsLocOp(x) HasFlag(x, FLAG_LOCOP)
421 #define IsLocal(x) HasFlag(x, FLAG_LOCAL)
422 #define IsOper(x) HasFlag(x, FLAG_OPER)
423 #define IsUPing(x) HasFlag(x, FLAG_UPING)
424 #define NoNewLine(x) HasFlag(x, FLAG_NONL)
425 #define SendDebug(x) HasFlag(x, FLAG_DEBUG)
426 #define SendServNotice(x) HasFlag(x, FLAG_SERVNOTICE)
427 #define SendWallops(x) HasFlag(x, FLAG_WALLOP)
428 #define IsHub(x) HasFlag(x, FLAG_HUB)
429 #define IsService(x) HasFlag(x, FLAG_SERVICE)
430 #define IsAccount(x) HasFlag(x, FLAG_ACCOUNT)
431 #define IsHiddenHost(x) HasFlag(x, FLAG_HIDDENHOST)
432 #define IsPingSent(x) HasFlag(x, FLAG_PINGSENT)
434 #define IsPrivileged(x) (IsAnOper(x) || IsServer(x))
435 #define HasHiddenHost(x) (IsHiddenHost(x) && IsAccount(x))
437 #define SetAccess(x) SetFlag(x, FLAG_CHKACCESS)
438 #define SetBurst(x) SetFlag(x, FLAG_BURST)
439 #define SetBurstAck(x) SetFlag(x, FLAG_BURST_ACK)
440 #define SetChannelService(x) SetFlag(x, FLAG_CHSERV)
441 #define SetDeaf(x) SetFlag(x, FLAG_DEAF)
442 #define SetDebug(x) SetFlag(x, FLAG_DEBUG)
443 #define SetGotId(x) SetFlag(x, FLAG_GOTID)
444 #define SetIPChecked(x) SetFlag(x, FLAG_IPCHECK)
445 #define SetInvisible(x) SetFlag(x, FLAG_INVISIBLE)
446 #define SetJunction(x) SetFlag(x, FLAG_JUNCTION)
447 #define SetLocOp(x) SetFlag(x, FLAG_LOCOP)
448 #define SetOper(x) SetFlag(x, FLAG_OPER)
449 #define SetUPing(x) SetFlag(x, FLAG_UPING)
450 #define SetWallops(x) SetFlag(x, FLAG_WALLOP)
451 #define SetServNotice(x) SetFlag(x, FLAG_SERVNOTICE)
452 #define SetHub(x) SetFlag(x, FLAG_HUB)
453 #define SetService(x) SetFlag(x, FLAG_SERVICE)
454 #define SetAccount(x) SetFlag(x, FLAG_ACCOUNT)
455 #define SetHiddenHost(x) SetFlag(x, FLAG_HIDDENHOST)
456 #define SetPingSent(x) SetFlag(x, FLAG_PINGSENT)
458 #define SeeOper(sptr,acptr) (IsAnOper(acptr) && (HasPriv(acptr, PRIV_DISPLAY) \
459 || HasPriv(sptr, PRIV_SEE_OPERS)))
461 #define ClearAccess(x) ClrFlag(x, FLAG_CHKACCESS)
462 #define ClearBurst(x) ClrFlag(x, FLAG_BURST)
463 #define ClearBurstAck(x) ClrFlag(x, FLAG_BURST_ACK)
464 #define ClearChannelService(x) ClrFlag(x, FLAG_CHSERV)
465 #define ClearDeaf(x) ClrFlag(x, FLAG_DEAF)
466 #define ClearDebug(x) ClrFlag(x, FLAG_DEBUG)
467 #define ClearIPChecked(x) ClrFlag(x, FLAG_IPCHECK)
468 #define ClearInvisible(x) ClrFlag(x, FLAG_INVISIBLE)
469 #define ClearLocOp(x) ClrFlag(x, FLAG_LOCOP)
470 #define ClearOper(x) ClrFlag(x, FLAG_OPER)
471 #define ClearUPing(x) ClrFlag(x, FLAG_UPING)
472 #define ClearWallops(x) ClrFlag(x, FLAG_WALLOP)
473 #define ClearServNotice(x) ClrFlag(x, FLAG_SERVNOTICE)
474 #define ClearHiddenHost(x) ClrFlag(x, FLAG_HIDDENHOST)
475 #define ClearPingSent(x) ClrFlag(x, FLAG_PINGSENT)
478 #define FREEFLAG_SOCKET 0x0001 /* socket needs to be freed */
479 #define FREEFLAG_TIMER 0x0002 /* timer needs to be freed */
481 /* server notice stuff */
486 /* DON'T CHANGE THESE VALUES ! */
487 /* THE CLIENTS DEPEND ON IT ! */
488 #define SNO_OLDSNO 0x1 /* unsorted old messages */
489 #define SNO_SERVKILL 0x2 /* server kills (nick collisions) */
490 #define SNO_OPERKILL 0x4 /* oper kills */
491 #define SNO_HACK2 0x8 /* desyncs */
492 #define SNO_HACK3 0x10 /* temporary desyncs */
493 #define SNO_UNAUTH 0x20 /* unauthorized connections */
494 #define SNO_TCPCOMMON 0x40 /* common TCP or socket errors */
495 #define SNO_TOOMANY 0x80 /* too many connections */
496 #define SNO_HACK4 0x100 /* Uworld actions on channels */
497 #define SNO_GLINE 0x200 /* glines */
498 #define SNO_NETWORK 0x400 /* net join/break, etc */
499 #define SNO_IPMISMATCH 0x800 /* IP mismatches */
500 #define SNO_THROTTLE 0x1000 /* host throttle add/remove notices */
501 #define SNO_OLDREALOP 0x2000 /* old oper-only messages */
502 #define SNO_CONNEXIT 0x4000 /* client connect/exit (ugh) */
503 #define SNO_AUTO 0x8000 /* AUTO G-Lines */
504 #define SNO_DEBUG 0x10000 /* debugging messages (DEBUGMODE only) */
507 # define SNO_ALL 0x1ffff /* Don't make it larger then significant,
508 * that looks nicer */
510 # define SNO_ALL 0xffff
513 #define SNO_USER (SNO_ALL & ~SNO_OPER)
515 #define SNO_DEFAULT (SNO_NETWORK|SNO_OPERKILL|SNO_GLINE)
516 #define SNO_OPERDEFAULT (SNO_DEFAULT|SNO_HACK2|SNO_HACK4|SNO_THROTTLE|SNO_OLDSNO)
517 #define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP)
518 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
520 #define PrivSet(fset, flag) FLAGSET_SET(*fset, flag)
521 #define PrivClr(fset, flag) FLAGSET_CLEAR(*fset, flag)
522 #define PrivHas(fset, flag) FLAGSET_ISSET(*fset, flag)
524 #define GrantPriv(cli, priv) (PrivSet(&(cli_privs(cli)), priv))
525 #define RevokePriv(cli, priv) (PrivClr(&(cli_privs(cli)), priv))
526 #define HasPriv(cli, priv) (PrivHas(&(cli_privs(cli)), priv))
528 typedef enum ShowIPType {
534 extern const char* get_client_name(const struct Client* sptr, int showip);
535 extern int client_get_ping(const struct Client* local_client);
536 extern void client_drop_sendq(struct Connection* con);
537 extern void client_add_sendq(struct Connection* con,
538 struct Connection** con_p);
539 extern void client_set_privs(struct Client *client, struct ConfItem *oper);
540 extern int client_report_privs(struct Client* to, struct Client* client);
542 #endif /* INCLUDED_client_h */