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_res_h
43 #ifndef INCLUDED_sys_types_h
44 #include <sys/types.h> /* time_t, size_t */
45 #define INCLUDED_sys_types_h
62 * Only put structures here that are being used in a very large number of
63 * source files. Other structures go in the header file of there corresponding
64 * source file, or in the source file itself (when only used in that file).
67 typedef unsigned long flagpage_t;
69 #define FLAGSET_NBITS (8 * sizeof(flagpage_t))
70 #define FLAGSET_INDEX(flag) (flag / FLAGSET_NBITS)
71 #define FLAGSET_MASK(flag) (1<<(flag % FLAGSET_NBITS))
73 #define DECLARE_FLAGSET(name,max) \
76 unsigned long bits[((max + FLAGSET_NBITS - 1) / FLAGSET_NBITS)]; \
79 #define FLAGSET_ISSET(set,flag) ((set).bits[FLAGSET_INDEX(flag)] & FLAGSET_MASK(flag))
80 #define FLAGSET_SET(set, flag) (set).bits[FLAGSET_INDEX(flag)] |= FLAGSET_MASK(flag)
81 #define FLAGSET_CLEAR(set, flag) (set).bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag)
83 #define infousermodes "dioswkgx"
87 PRIV_CHAN_LIMIT, /* no channel limit on oper */
88 PRIV_MODE_LCHAN, /* oper can mode local chans */
89 PRIV_WALK_LCHAN, /* oper can walk thru local modes */
90 PRIV_DEOP_LCHAN, /* no deop oper on local chans */
91 PRIV_SHOW_INVIS, /* show local invisible users */
92 PRIV_SHOW_ALL_INVIS, /* show all invisible users */
93 PRIV_UNLIMIT_QUERY, /* unlimit who queries */
94 PRIV_KILL, /* oper can KILL */
95 PRIV_LOCAL_KILL, /* oper can local KILL */
96 PRIV_REHASH, /* oper can REHASH */
97 PRIV_RESTART, /* oper can RESTART */
98 PRIV_DIE, /* oper can DIE */
99 PRIV_GLINE, /* oper can GLINE */
100 PRIV_LOCAL_GLINE, /* oper can local GLINE */
101 PRIV_JUPE, /* oper can JUPE */
102 PRIV_LOCAL_JUPE, /* oper can local JUPE */
103 PRIV_OPMODE, /* oper can OP/CLEARMODE */
104 PRIV_LOCAL_OPMODE, /* oper can local OP/CLEARMODE */
105 PRIV_SET, /* oper can SET */
106 PRIV_WHOX, /* oper can use /who x */
107 PRIV_BADCHAN, /* oper can BADCHAN */
108 PRIV_LOCAL_BADCHAN, /* oper can local BADCHAN */
109 PRIV_SEE_CHAN, /* oper can see in secret chans */
110 PRIV_PROPAGATE, /* propagate oper status */
111 PRIV_DISPLAY, /* "Is an oper" displayed */
112 PRIV_SEE_OPERS, /* display hidden opers */
113 PRIV_WIDE_GLINE, /* oper can set wider G-lines */
114 PRIV_LIST_CHAN, /* oper can list secret channels */
115 PRIV_FORCE_OPMODE, /* can hack modes on quarantined channels */
116 PRIV_FORCE_LOCAL_OPMODE, /* can hack modes on quarantined local channels */
117 PRIV_LAST_PRIV /* must be the same as the last priv */
122 FLAG_PINGSENT, /* Unreplied ping sent */
123 FLAG_DEADSOCKET, /* Local socket is dead--Exiting soon */
124 FLAG_KILLED, /* Prevents "QUIT" from being sent for this */
125 FLAG_BLOCKED, /* socket is in a blocked condition */
126 FLAG_CLOSING, /* set when closing to suppress errors */
127 FLAG_UPING, /* has active UDP ping request */
128 FLAG_CHKACCESS, /* ok to check clients access if set */
129 FLAG_HUB, /* server is a hub */
130 FLAG_SERVICE, /* server is a service */
131 FLAG_LOCAL, /* set for local clients */
132 FLAG_GOTID, /* successful ident lookup achieved */
133 FLAG_DOID, /* I-lines say must use ident return */
134 FLAG_NONL, /* No \n in buffer */
135 FLAG_TS8, /* Why do you want to know? */
136 FLAG_MAP, /* Show server on the map */
137 FLAG_JUNCTION, /* Junction causing the net.burst */
138 FLAG_BURST, /* Server is receiving a net.burst */
139 FLAG_BURST_ACK, /* Server is waiting for eob ack */
140 FLAG_IPCHECK, /* Added or updated IPregistry data */
141 FLAG_IAUTHED, /* Got IAUTH response for user */
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 DNSReply* 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 */
214 struct IAuthRequest* con_iauth; /* iauth request for client */
217 #define CONNECTION_MAGIC 0x12f955f3
220 unsigned long cli_magic; /* magic number */
221 struct Client* cli_next; /* link in GlobalClientList */
222 struct Client* cli_prev; /* link in GlobalClientList */
223 struct Client* cli_hnext; /* link in hash table bucket or this */
224 struct Connection* cli_connect; /* Connection structure associated with us */
225 struct User* cli_user; /* ...defined, if this is a User */
226 struct Server* cli_serv; /* ...defined, if this is a server */
227 struct Whowas* cli_whowas; /* Pointer to ww struct to be freed on quit */
228 char cli_yxx[4]; /* Numeric Nick: YMM if this is a server,
229 XX0 if this is a user */
231 * XXX - move these to local part for next release
234 time_t cli_lasttime; /* last time data read from socket */
235 time_t cli_since; /* last time we parsed something, flood control */
237 time_t cli_firsttime; /* time client was created */
238 time_t cli_lastnick; /* TimeStamp on nick */
239 int cli_marker; /* /who processing marker */
240 struct Flags cli_flags; /* client flags */
241 unsigned int cli_hopcount; /* number of servers to this 0 = local */
242 struct irc_in_addr cli_ip; /* Real IP of client */
243 short cli_status; /* Client type */
244 unsigned char cli_local; /* local or remote client */
245 struct Privs cli_privs; /* Oper privileges */
246 char cli_name[HOSTLEN + 1]; /* Unique name of the client, nick or host */
247 char cli_username[USERLEN + 1]; /* username here now for auth stuff */
248 char cli_info[REALLEN + 1]; /* Free form additional client information */
251 #define CLIENT_MAGIC 0x4ca08286
253 #define cli_verify(cli) ((cli)->cli_magic == CLIENT_MAGIC)
254 #define cli_magic(cli) ((cli)->cli_magic)
255 #define cli_next(cli) ((cli)->cli_next)
256 #define cli_prev(cli) ((cli)->cli_prev)
257 #define cli_hnext(cli) ((cli)->cli_hnext)
258 #define cli_connect(cli) ((cli)->cli_connect)
259 #define cli_from(cli) ((cli)->cli_connect->con_client)
260 #define cli_user(cli) ((cli)->cli_user)
261 #define cli_serv(cli) ((cli)->cli_serv)
262 #define cli_whowas(cli) ((cli)->cli_whowas)
263 #define cli_yxx(cli) ((cli)->cli_yxx)
264 #define cli_lasttime(cli) ((cli)->cli_lasttime)
265 #define cli_since(cli) ((cli)->cli_since)
266 #define cli_firsttime(cli) ((cli)->cli_firsttime)
267 #define cli_lastnick(cli) ((cli)->cli_lastnick)
268 #define cli_marker(cli) ((cli)->cli_marker)
269 #define cli_flags(cli) ((cli)->cli_flags)
270 #define cli_hopcount(cli) ((cli)->cli_hopcount)
271 #define cli_ip(cli) ((cli)->cli_ip)
272 #define cli_status(cli) ((cli)->cli_status)
273 #define cli_local(cli) ((cli)->cli_local)
274 #define cli_privs(cli) ((cli)->cli_privs)
275 #define cli_name(cli) ((cli)->cli_name)
276 #define cli_username(cli) ((cli)->cli_username)
277 #define cli_info(cli) ((cli)->cli_info)
279 #define cli_count(cli) ((cli)->cli_connect->con_count)
280 #define cli_fd(cli) ((cli)->cli_connect->con_fd)
281 #define cli_freeflag(cli) ((cli)->cli_connect->con_freeflag)
282 #define cli_error(cli) ((cli)->cli_connect->con_error)
283 #define cli_snomask(cli) ((cli)->cli_connect->con_snomask)
284 #define cli_nextnick(cli) ((cli)->cli_connect->con_nextnick)
285 #define cli_nexttarget(cli) ((cli)->cli_connect->con_nexttarget)
286 #define cli_cookie(cli) ((cli)->cli_connect->con_cookie)
287 #define cli_sendQ(cli) ((cli)->cli_connect->con_sendQ)
288 #define cli_recvQ(cli) ((cli)->cli_connect->con_recvQ)
289 #define cli_sendM(cli) ((cli)->cli_connect->con_sendM)
290 #define cli_sendK(cli) ((cli)->cli_connect->con_sendK)
291 #define cli_receiveM(cli) ((cli)->cli_connect->con_receiveM)
292 #define cli_receiveK(cli) ((cli)->cli_connect->con_receiveK)
293 #define cli_sendB(cli) ((cli)->cli_connect->con_sendB)
294 #define cli_receiveB(cli) ((cli)->cli_connect->con_receiveB)
295 #define cli_listener(cli) ((cli)->cli_connect->con_listener)
296 #define cli_confs(cli) ((cli)->cli_connect->con_confs)
297 #define cli_handler(cli) ((cli)->cli_connect->con_handler)
298 #define cli_dns_reply(cli) ((cli)->cli_connect->con_dns_reply)
299 #define cli_listing(cli) ((cli)->cli_connect->con_listing)
300 #define cli_max_sendq(cli) ((cli)->cli_connect->con_max_sendq)
301 #define cli_ping_freq(cli) ((cli)->cli_connect->con_ping_freq)
302 #define cli_lastsq(cli) ((cli)->cli_connect->con_lastsq)
303 #define cli_port(cli) ((cli)->cli_connect->con_port)
304 #define cli_targets(cli) ((cli)->cli_connect->con_targets)
305 #define cli_sock_ip(cli) ((cli)->cli_connect->con_sock_ip)
306 #define cli_sockhost(cli) ((cli)->cli_connect->con_sockhost)
307 #define cli_passwd(cli) ((cli)->cli_connect->con_passwd)
308 #define cli_buffer(cli) ((cli)->cli_connect->con_buffer)
309 #define cli_socket(cli) ((cli)->cli_connect->con_socket)
310 #define cli_proc(cli) ((cli)->cli_connect->con_proc)
311 #define cli_auth(cli) ((cli)->cli_connect->con_auth)
312 #define cli_iauth(cli) ((cli)->cli_connect->con_iauth)
314 #define con_verify(con) ((con)->con_magic == CONNECTION_MAGIC)
315 #define con_magic(con) ((con)->con_magic)
316 #define con_next(con) ((con)->con_next)
317 #define con_prev_p(con) ((con)->con_prev_p)
318 #define con_client(con) ((con)->con_client)
319 #define con_count(con) ((con)->con_count)
320 #define con_fd(con) ((con)->con_fd)
321 #define con_freeflag(con) ((con)->con_freeflag)
322 #define con_error(con) ((con)->con_error)
323 #define con_snomask(con) ((con)->con_snomask)
324 #define con_nextnick(con) ((con)->con_nextnick)
325 #define con_nexttarget(con) ((con)->con_nexttarget)
326 #define con_cookie(con) ((con)->con_cookie)
327 #define con_sendQ(con) ((con)->con_sendQ)
328 #define con_recvQ(con) ((con)->con_recvQ)
329 #define con_sendM(con) ((con)->con_sendM)
330 #define con_sendK(con) ((con)->con_sendK)
331 #define con_receiveM(con) ((con)->con_receiveM)
332 #define con_receiveK(con) ((con)->con_receiveK)
333 #define con_sendB(con) ((con)->con_sendB)
334 #define con_receiveB(con) ((con)->con_receiveB)
335 #define con_listener(con) ((con)->con_listener)
336 #define con_confs(con) ((con)->con_confs)
337 #define con_handler(con) ((con)->con_handler)
338 #define con_dns_reply(con) ((con)->con_dns_reply)
339 #define con_listing(con) ((con)->con_listing)
340 #define con_max_sendq(con) ((con)->con_max_sendq)
341 #define con_ping_freq(con) ((con)->con_ping_freq)
342 #define con_lastsq(con) ((con)->con_lastsq)
343 #define con_port(con) ((con)->con_port)
344 #define con_targets(con) ((con)->con_targets)
345 #define con_sock_ip(con) ((con)->con_sock_ip)
346 #define con_sockhost(con) ((con)->con_sockhost)
347 #define con_passwd(con) ((con)->con_passwd)
348 #define con_buffer(con) ((con)->con_buffer)
349 #define con_socket(con) ((con)->con_socket)
350 #define con_proc(con) ((con)->con_proc)
351 #define con_auth(con) ((con)->con_auth)
352 #define con_iauth(con) ((con)->con_iauth)
354 #define STAT_CONNECTING 0x001 /* connecting to another server */
355 #define STAT_HANDSHAKE 0x002 /* pass - server sent */
356 #define STAT_ME 0x004 /* this server */
357 #define STAT_UNKNOWN 0x008 /* unidentified connection */
358 #define STAT_UNKNOWN_USER 0x010 /* Connect to client port */
359 #define STAT_UNKNOWN_SERVER 0x020 /* Connect to server port */
360 #define STAT_SERVER 0x040
361 #define STAT_USER 0x080
366 #define IsRegistered(x) (cli_status(x) & (STAT_SERVER | STAT_USER))
367 #define IsConnecting(x) (cli_status(x) == STAT_CONNECTING)
368 #define IsHandshake(x) (cli_status(x) == STAT_HANDSHAKE)
369 #define IsMe(x) (cli_status(x) == STAT_ME)
370 #define IsUnknown(x) (cli_status(x) & \
371 (STAT_UNKNOWN | STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER))
373 #define IsServerPort(x) (cli_status(x) == STAT_UNKNOWN_SERVER )
374 #define IsUserPort(x) (cli_status(x) == STAT_UNKNOWN_USER )
375 #define IsClient(x) (cli_status(x) & \
376 (STAT_HANDSHAKE | STAT_ME | STAT_UNKNOWN |\
377 STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER | STAT_SERVER | STAT_USER))
379 #define IsTrusted(x) (cli_status(x) & \
380 (STAT_CONNECTING | STAT_HANDSHAKE | STAT_ME | STAT_SERVER))
382 #define IsServer(x) (cli_status(x) == STAT_SERVER)
383 #define IsUser(x) (cli_status(x) == STAT_USER)
386 #define SetConnecting(x) (cli_status(x) = STAT_CONNECTING)
387 #define SetHandshake(x) (cli_status(x) = STAT_HANDSHAKE)
388 #define SetServer(x) (cli_status(x) = STAT_SERVER)
389 #define SetMe(x) (cli_status(x) = STAT_ME)
390 #define SetUser(x) (cli_status(x) = STAT_USER)
392 #define MyConnect(x) (cli_from(x) == (x))
393 #define MyUser(x) (MyConnect(x) && IsUser(x))
394 #define MyOper(x) (MyConnect(x) && IsOper(x))
395 #define Protocol(x) ((cli_serv(x))->prot)
397 #define PARSE_AS_SERVER(x) (cli_status(x) & \
398 (STAT_SERVER | STAT_CONNECTING | STAT_HANDSHAKE))
403 #define FlagSet(fset, flag) FLAGSET_SET(*fset, flag)
404 #define FlagClr(fset, flag) FLAGSET_CLEAR(*fset, flag)
405 #define FlagHas(fset, flag) FLAGSET_ISSET(*fset, flag)
406 #define SetFlag(cli, flag) FlagSet(&cli_flags(cli), flag)
407 #define ClrFlag(cli, flag) FlagClr(&cli_flags(cli), flag)
408 #define HasFlag(cli, flag) FlagHas(&cli_flags(cli), flag)
410 #define DoAccess(x) HasFlag(x, FLAG_CHKACCESS)
411 #define IsAnOper(x) (HasFlag(x, FLAG_OPER) || HasFlag(x, FLAG_LOCOP))
412 #define IsBlocked(x) HasFlag(x, FLAG_BLOCKED)
413 #define IsBurst(x) HasFlag(x, FLAG_BURST)
414 #define IsBurstAck(x) HasFlag(x, FLAG_BURST_ACK)
415 #define IsBurstOrBurstAck(x) (HasFlag(x, FLAG_BURST) || HasFlag(x, FLAG_BURST_ACK))
416 #define IsChannelService(x) HasFlag(x, FLAG_CHSERV)
417 #define IsDead(x) HasFlag(x, FLAG_DEADSOCKET)
418 #define IsDeaf(x) HasFlag(x, FLAG_DEAF)
419 #define IsIPChecked(x) HasFlag(x, FLAG_IPCHECK)
420 #define IsIAuthed(x) HasFlag(x, FLAG_IAUTHED)
421 #define IsIdented(x) HasFlag(x, FLAG_GOTID)
422 #define IsInvisible(x) HasFlag(x, FLAG_INVISIBLE)
423 #define IsJunction(x) HasFlag(x, FLAG_JUNCTION)
424 #define IsLocOp(x) HasFlag(x, FLAG_LOCOP)
425 #define IsLocal(x) HasFlag(x, FLAG_LOCAL)
426 #define IsOper(x) HasFlag(x, FLAG_OPER)
427 #define IsUPing(x) HasFlag(x, FLAG_UPING)
428 #define NoNewLine(x) HasFlag(x, FLAG_NONL)
429 #define SendDebug(x) HasFlag(x, FLAG_DEBUG)
430 #define SendServNotice(x) HasFlag(x, FLAG_SERVNOTICE)
431 #define SendWallops(x) HasFlag(x, FLAG_WALLOP)
432 #define IsHub(x) HasFlag(x, FLAG_HUB)
433 #define IsService(x) HasFlag(x, FLAG_SERVICE)
434 #define IsAccount(x) HasFlag(x, FLAG_ACCOUNT)
435 #define IsHiddenHost(x) HasFlag(x, FLAG_HIDDENHOST)
436 #define IsPingSent(x) HasFlag(x, FLAG_PINGSENT)
438 #define IsPrivileged(x) (IsAnOper(x) || IsServer(x))
439 #define HasHiddenHost(x) (IsHiddenHost(x) && IsAccount(x))
441 #define SetAccess(x) SetFlag(x, FLAG_CHKACCESS)
442 #define SetBurst(x) SetFlag(x, FLAG_BURST)
443 #define SetBurstAck(x) SetFlag(x, FLAG_BURST_ACK)
444 #define SetChannelService(x) SetFlag(x, FLAG_CHSERV)
445 #define SetDeaf(x) SetFlag(x, FLAG_DEAF)
446 #define SetDebug(x) SetFlag(x, FLAG_DEBUG)
447 #define SetGotId(x) SetFlag(x, FLAG_GOTID)
448 #define SetIPChecked(x) SetFlag(x, FLAG_IPCHECK)
449 #define SetIAuthed(x) SetFlag(x, FLAG_IAUTHED)
450 #define SetInvisible(x) SetFlag(x, FLAG_INVISIBLE)
451 #define SetJunction(x) SetFlag(x, FLAG_JUNCTION)
452 #define SetLocOp(x) SetFlag(x, FLAG_LOCOP)
453 #define SetOper(x) SetFlag(x, FLAG_OPER)
454 #define SetUPing(x) SetFlag(x, FLAG_UPING)
455 #define SetWallops(x) SetFlag(x, FLAG_WALLOP)
456 #define SetServNotice(x) SetFlag(x, FLAG_SERVNOTICE)
457 #define SetHub(x) SetFlag(x, FLAG_HUB)
458 #define SetService(x) SetFlag(x, FLAG_SERVICE)
459 #define SetAccount(x) SetFlag(x, FLAG_ACCOUNT)
460 #define SetHiddenHost(x) SetFlag(x, FLAG_HIDDENHOST)
461 #define SetPingSent(x) SetFlag(x, FLAG_PINGSENT)
463 #define SeeOper(sptr,acptr) (IsAnOper(acptr) && (HasPriv(acptr, PRIV_DISPLAY) \
464 || HasPriv(sptr, PRIV_SEE_OPERS)))
466 #define ClearAccess(x) ClrFlag(x, FLAG_CHKACCESS)
467 #define ClearBurst(x) ClrFlag(x, FLAG_BURST)
468 #define ClearBurstAck(x) ClrFlag(x, FLAG_BURST_ACK)
469 #define ClearChannelService(x) ClrFlag(x, FLAG_CHSERV)
470 #define ClearDeaf(x) ClrFlag(x, FLAG_DEAF)
471 #define ClearDebug(x) ClrFlag(x, FLAG_DEBUG)
472 #define ClearIPChecked(x) ClrFlag(x, FLAG_IPCHECK)
473 #define ClearInvisible(x) ClrFlag(x, FLAG_INVISIBLE)
474 #define ClearLocOp(x) ClrFlag(x, FLAG_LOCOP)
475 #define ClearOper(x) ClrFlag(x, FLAG_OPER)
476 #define ClearUPing(x) ClrFlag(x, FLAG_UPING)
477 #define ClearWallops(x) ClrFlag(x, FLAG_WALLOP)
478 #define ClearServNotice(x) ClrFlag(x, FLAG_SERVNOTICE)
479 #define ClearHiddenHost(x) ClrFlag(x, FLAG_HIDDENHOST)
480 #define ClearPingSent(x) ClrFlag(x, FLAG_PINGSENT)
483 #define FREEFLAG_SOCKET 0x0001 /* socket needs to be freed */
484 #define FREEFLAG_TIMER 0x0002 /* timer needs to be freed */
486 /* server notice stuff */
491 /* DON'T CHANGE THESE VALUES ! */
492 /* THE CLIENTS DEPEND ON IT ! */
493 #define SNO_OLDSNO 0x1 /* unsorted old messages */
494 #define SNO_SERVKILL 0x2 /* server kills (nick collisions) */
495 #define SNO_OPERKILL 0x4 /* oper kills */
496 #define SNO_HACK2 0x8 /* desyncs */
497 #define SNO_HACK3 0x10 /* temporary desyncs */
498 #define SNO_UNAUTH 0x20 /* unauthorized connections */
499 #define SNO_TCPCOMMON 0x40 /* common TCP or socket errors */
500 #define SNO_TOOMANY 0x80 /* too many connections */
501 #define SNO_HACK4 0x100 /* Uworld actions on channels */
502 #define SNO_GLINE 0x200 /* glines */
503 #define SNO_NETWORK 0x400 /* net join/break, etc */
504 #define SNO_IPMISMATCH 0x800 /* IP mismatches */
505 #define SNO_THROTTLE 0x1000 /* host throttle add/remove notices */
506 #define SNO_OLDREALOP 0x2000 /* old oper-only messages */
507 #define SNO_CONNEXIT 0x4000 /* client connect/exit (ugh) */
508 #define SNO_AUTO 0x8000 /* AUTO G-Lines */
509 #define SNO_DEBUG 0x10000 /* debugging messages (DEBUGMODE only) */
512 # define SNO_ALL 0x1ffff /* Don't make it larger then significant,
513 * that looks nicer */
515 # define SNO_ALL 0xffff
518 #define SNO_USER (SNO_ALL & ~SNO_OPER)
520 #define SNO_DEFAULT (SNO_NETWORK|SNO_OPERKILL|SNO_GLINE)
521 #define SNO_OPERDEFAULT (SNO_DEFAULT|SNO_HACK2|SNO_HACK4|SNO_THROTTLE|SNO_OLDSNO)
522 #define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP)
523 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
525 #define PrivSet(fset, flag) FLAGSET_SET(*fset, flag)
526 #define PrivClr(fset, flag) FLAGSET_CLEAR(*fset, flag)
527 #define PrivHas(fset, flag) FLAGSET_ISSET(*fset, flag)
529 #define GrantPriv(cli, priv) (PrivSet(&(cli_privs(cli)), priv))
530 #define RevokePriv(cli, priv) (PrivClr(&(cli_privs(cli)), priv))
531 #define HasPriv(cli, priv) (PrivHas(&(cli_privs(cli)), priv))
533 typedef enum ShowIPType {
539 extern const char* get_client_name(const struct Client* sptr, int showip);
540 extern const char* client_get_default_umode(const struct Client* sptr);
541 extern int client_get_ping(const struct Client* local_client);
542 extern void client_drop_sendq(struct Connection* con);
543 extern void client_add_sendq(struct Connection* con,
544 struct Connection** con_p);
545 extern void client_set_privs(struct Client *client, struct ConfItem *oper);
546 extern int client_report_privs(struct Client* to, struct Client* client);
548 #endif /* INCLUDED_client_h */