PageRenderTime 35ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/include/client.h

https://bitbucket.org/rizon/ircd/
C Header | 654 lines | 449 code | 99 blank | 106 comment | 18 complexity | a5e10162ff37a5e9cac522a69b36ab2d MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /*
  2. * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
  3. * client.h: The ircd client header.
  4. *
  5. * Copyright (C) 2002 by the past and present ircd coders, and others.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  20. * USA
  21. *
  22. * $Id: client.h 489 2007-07-04 03:56:19Z jon $
  23. */
  24. #ifndef INCLUDED_client_h
  25. #define INCLUDED_client_h
  26. #include "fdlist.h"
  27. #include "setup.h"
  28. #include "ircd_defs.h"
  29. #include "ircd_handler.h"
  30. #include "dbuf.h"
  31. #include "channel.h"
  32. #include "irc_res.h"
  33. #define HOSTIPLEN 53 /* sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255.ipv6") */
  34. #define PASSWDLEN 20
  35. #define CIPHERKEYLEN 64 /* 512bit */
  36. #define IDLEN 12 /* this is the maximum length, not the actual
  37. generated length; DO NOT CHANGE! */
  38. /*
  39. * pre declare structs
  40. */
  41. struct AccessItem;
  42. struct Whowas;
  43. struct DNSReply;
  44. struct Listener;
  45. struct Client;
  46. struct LocalUser;
  47. /*
  48. * Client structures
  49. */
  50. struct Server
  51. {
  52. char by[NICKLEN]; /* who activated this connection */
  53. struct ConfItem *sconf; /* ConfItem connect{} pointer for this server */
  54. dlink_list servers; /* Servers on this server */
  55. dlink_list users; /* Users on this server */
  56. int dep_servers; /* Total number of dependent servers on all levels */
  57. int dep_users; /* Total number of dependent users on all levels */
  58. };
  59. struct SlinkRpl
  60. {
  61. int command;
  62. int datalen;
  63. int gotdatalen;
  64. int readdata;
  65. unsigned char *data;
  66. };
  67. struct ZipStats
  68. {
  69. unsigned long in;
  70. unsigned long in_wire;
  71. unsigned long out;
  72. unsigned long out_wire;
  73. double in_ratio;
  74. double out_ratio;
  75. };
  76. struct ListTask
  77. {
  78. int hash_index; /* the bucket we are currently in */
  79. dlink_list show_mask; /* show these channels.. */
  80. dlink_list hide_mask; /* ..and hide these ones */
  81. unsigned int users_min, users_max;
  82. unsigned int created_min, created_max;
  83. unsigned int topicts_min, topicts_max;
  84. };
  85. struct Client
  86. {
  87. dlink_node node;
  88. dlink_node lnode; /* Used for Server->servers/users */
  89. struct Client *hnext; /* For client hash table lookups by name */
  90. struct Client *idhnext; /* For SID hash table lookups by sid */
  91. struct Server *serv; /* ...defined, if this is a server */
  92. struct Client *servptr; /* Points to server this Client is on */
  93. struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
  94. struct Whowas *whowas; /* Pointers to whowas structs */
  95. time_t lasttime; /* ...should be only LOCAL clients? --msa */
  96. time_t firsttime; /* time client was created */
  97. time_t since; /* last time we parsed something */
  98. time_t tsinfo; /* TS on the nick, SVINFO on server */
  99. unsigned long connect_id; /* unique connection ID */
  100. unsigned int umodes; /* opers, normal users subset */
  101. uint64_t flags; /* client flags */
  102. unsigned int servicestamp; /* services stamp (set via SVSMODE +d) */
  103. unsigned short hopcount; /* number of servers to this 0 = local */
  104. unsigned short status; /* Client type */
  105. unsigned char handler; /* Handler index */
  106. unsigned long serial; /* used to enforce 1 send per nick */
  107. unsigned long lazyLinkClientExists; /* This client exists on the
  108. * bit mapped lazylink servers
  109. * mapped here
  110. */
  111. char *away;
  112. /*
  113. * client->name is the unique name for a client nick or host
  114. */
  115. char name[HOSTLEN + 1];
  116. char id[IDLEN + 1]; /* client ID, unique ID per client */
  117. char suser[NICKLEN + 1]; /* nick core to which this client is identified in services */
  118. /*
  119. * client->llname is used to store the clients requested nick
  120. * temporarily for new connections.
  121. */
  122. char llname[NICKLEN];
  123. /*
  124. * client->username is the username from ident or the USER message,
  125. * If the client is idented the USER message is ignored, otherwise
  126. * the username part of the USER message is put here prefixed with a
  127. * tilde depending on the I:line, Once a client has registered, this
  128. * field should be considered read-only.
  129. */
  130. char username[USERLEN + 1]; /* client's username */
  131. /*
  132. * client->host contains the resolved name or ip address
  133. * as a string for the user, it may be fiddled with for oper spoofing etc.
  134. * once it's changed the *real* address goes away. This should be
  135. * considered a read-only field after the client has registered.
  136. */
  137. char host[HOSTLEN + 1]; /* client's hostname */
  138. /*
  139. * client->realhost contains a static version of client->host
  140. * This is to keep the original hostname when using the cloaking system.
  141. * This allows clients to set/unset their cloaked hosts at will.
  142. */
  143. char realhost[HOSTLEN + 1]; /* client's static hostname */
  144. /*
  145. * client->info for unix clients will normally contain the info from the
  146. * gcos field in /etc/passwd but anything can go here.
  147. */
  148. char info[REALLEN + 1]; /* Free form additional client info */
  149. char client_host[HOSTLEN + 1];
  150. char client_server[HOSTLEN + 1];
  151. /* client->sockhost contains the ip address gotten from the socket as a
  152. * string, this field should be considered read-only once the connection
  153. * has been made. (set in s_bsd.c only)
  154. */
  155. char sockhost[HOSTIPLEN + 1]; /* This is the host name from the
  156. socket ip address as string */
  157. /* caller ID allow list */
  158. /* This has to be here, since a client on an on_allow_list could
  159. * be a remote client. simpler to keep both here.
  160. */
  161. dlink_list allow_list; /* clients I'll allow to talk to me */
  162. dlink_list on_allow_list; /* clients that have =me= on their allow list */
  163. dlink_list channel; /* chain of channel pointer blocks */
  164. struct LocalUser *localClient;
  165. #ifdef HAVE_LIBCRYPTO
  166. char certfp[SHA_DIGEST_LENGTH]; /* cert fingerprint */
  167. #endif
  168. };
  169. struct LocalUser
  170. {
  171. /*
  172. * The following fields are allocated only for local clients
  173. * (directly connected to *this* server with a socket.
  174. */
  175. unsigned int registration;
  176. unsigned int cap_client; /* Client capabilities (from us) */
  177. unsigned int cap_active; /* Active capabilities (to us) */
  178. /* Anti flooding part, all because of lamers... */
  179. time_t last_away; /* Away since... */
  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 reject_delay;
  189. time_t last_caller_id_time;
  190. time_t first_received_message_time;
  191. int received_number_of_privmsgs;
  192. int flood_noticed;
  193. dlink_node lclient_node;
  194. time_t last_kill_time; /* when this client last send kill */
  195. int kill_count;
  196. unsigned int operflags; /* oper priv flags */
  197. struct ListTask *list_task;
  198. /* Send and receive dbufs .. */
  199. struct dbuf_queue buf_sendq;
  200. struct dbuf_queue buf_recvq;
  201. struct
  202. {
  203. unsigned int messages; /* Statistics: protocol messages sent/received */
  204. uint64_t bytes; /* Statistics: total bytes sent/received */
  205. } recv, send;
  206. struct Listener *listener; /* listener accepted from */
  207. dlink_list confs; /* Configuration record associated */
  208. dlink_list invited; /* chain of invite pointer blocks */
  209. struct irc_ssaddr ip;
  210. int aftype; /* Makes life easier for DNS res in IPV6 */
  211. struct DNSQuery *dns_query; /* result returned from resolver query */
  212. unsigned long serverMask; /* Only used for Lazy Links */
  213. time_t last; /* Last time we got a PRIVMSG */
  214. time_t last_nick_change;
  215. int number_of_nick_changes;
  216. char *passwd;
  217. int caps; /* server capabilities bit-field */
  218. int enc_caps; /* cipher capabilities bit-field */
  219. char cgisockhost[HOSTIPLEN + 1]; /* This is the host name from the
  220. socket ip address as string */
  221. #ifdef HAVE_LIBCRYPTO
  222. struct EncCapability *in_cipher;
  223. struct EncCapability *out_cipher;
  224. char in_key[CIPHERKEYLEN];
  225. char out_key[CIPHERKEYLEN];
  226. #endif
  227. fde_t fd;
  228. fde_t ctrlfd; /* For servers: control fd used for sending commands
  229. to servlink */
  230. struct SlinkRpl slinkrpl; /* slink reply being parsed */
  231. char *slinkq; /* sendq for control data */
  232. int slinkq_ofs; /* ofset into slinkq */
  233. int slinkq_len; /* length remaining after slinkq_ofs */
  234. struct ZipStats zipstats;
  235. /* Anti-flood stuff. We track how many messages were parsed and how
  236. * many we were allowed in the current second, and apply a simple
  237. * decay to avoid flooding.
  238. * -- adrian
  239. */
  240. int allow_read; /* how many we're allowed to read in this second */
  241. int sent_parsed; /* how many messages we've parsed in this second */
  242. time_t last_knock; /* time of last knock */
  243. unsigned long random_ping;
  244. char *response; /* expected response from client */
  245. char *auth_oper; /* Operator to become if they supply the response. */
  246. dlink_list dnsbl_queries; /* Pending DNS queries blocking registration */
  247. };
  248. /*
  249. * status macros.
  250. */
  251. #define STAT_CONNECTING 0x01
  252. #define STAT_HANDSHAKE 0x02
  253. #define STAT_ME 0x04
  254. #define STAT_UNKNOWN 0x08
  255. #define STAT_SERVER 0x10
  256. #define STAT_CLIENT 0x20
  257. #define REG_NEED_USER 0x1
  258. #define REG_NEED_NICK 0x2
  259. #define REG_NEED_CAP 0x4
  260. #define REG_NEED_DNSBL 0x8
  261. #define REG_INIT (REG_NEED_USER|REG_NEED_NICK)
  262. #define HasID(x) ((x)->id[0] != '\0')
  263. #define ID(x) (HasID(x) ? (x)->id : (x)->name)
  264. #define ID_or_name(x,client_p) ((IsCapable(client_p, CAP_TS6) && HasID(x)) ? (x)->id : (x)->name)
  265. #define IsRegistered(x) ((x)->status > STAT_UNKNOWN)
  266. #define IsConnecting(x) ((x)->status == STAT_CONNECTING)
  267. #define IsHandshake(x) ((x)->status == STAT_HANDSHAKE)
  268. #define IsMe(x) ((x)->status == STAT_ME)
  269. #define IsUnknown(x) ((x)->status == STAT_UNKNOWN)
  270. #define IsServer(x) ((x)->status == STAT_SERVER)
  271. #define IsClient(x) ((x)->status == STAT_CLIENT)
  272. #define IsOper(x) ((x)->umodes & UMODE_OPER)
  273. #define IsAdmin(x) ((x)->umodes & UMODE_ADMIN)
  274. #define SetConnecting(x) {(x)->status = STAT_CONNECTING; \
  275. (x)->handler = UNREGISTERED_HANDLER; }
  276. #define SetHandshake(x) {(x)->status = STAT_HANDSHAKE; \
  277. (x)->handler = UNREGISTERED_HANDLER; }
  278. #define SetMe(x) {(x)->status = STAT_ME; \
  279. (x)->handler = UNREGISTERED_HANDLER; }
  280. #define SetUnknown(x) {(x)->status = STAT_UNKNOWN; \
  281. (x)->handler = UNREGISTERED_HANDLER; }
  282. #define SetServer(x) {(x)->status = STAT_SERVER; \
  283. (x)->handler = SERVER_HANDLER; }
  284. #define SetClient(x) {(x)->status = STAT_CLIENT; \
  285. (x)->handler = IsOper((x)) ? \
  286. OPER_HANDLER : CLIENT_HANDLER; }
  287. #define SetEob(x) ((x)->flags |= FLAGS_EOB)
  288. #define HasSentEob(x) ((x)->flags & FLAGS_EOB)
  289. /*
  290. * ts stuff
  291. */
  292. #define TS_CURRENT 6 /* current TS protocol version */
  293. #ifdef TS5_ONLY
  294. #define TS_MIN 5
  295. #else
  296. #define TS_MIN 3 /* minimum supported TS protocol version */
  297. #endif
  298. #define TS_DOESTS 0x20000000
  299. #define DoesTS(x) ((x)->tsinfo == TS_DOESTS)
  300. #define CAP_MULTI_PREFIX 0x00000001
  301. #define CAP_UHNAMES 0x00000002
  302. /* housekeeping flags */
  303. #define FLAGS_PINGSENT 0x0000000000000001ULL /* Unreplied ping sent */
  304. #define FLAGS_DEADSOCKET 0x0000000000000002ULL /* Local socket is dead--Exiting soon */
  305. #define FLAGS_KILLED 0x0000000000000004ULL /* Prevents "QUIT" from being sent for this */
  306. #define FLAGS_CLOSING 0x0000000000000008ULL /* set when closing to suppress errors */
  307. #define FLAGS_GOTID 0x0000000000000010ULL /* successful ident lookup achieved */
  308. #define FLAGS_NEEDID 0x0000000000000020ULL /* I-lines say must use ident return */
  309. #define FLAGS_SENDQEX 0x0000000000000040ULL /* Sendq exceeded */
  310. #define FLAGS_IPHASH 0x0000000000000080ULL /* iphashed this client */
  311. #define FLAGS_CRYPTIN 0x0000000000000100ULL /* incoming data must be decrypted */
  312. #define FLAGS_CRYPTOUT 0x0000000000000200ULL /* outgoing data must be encrypted */
  313. #define FLAGS_WAITAUTH 0x0000000000000400ULL /* waiting for CRYPTLINK AUTH command */
  314. #define FLAGS_SERVLINK 0x0000000000000800ULL /* servlink has servlink process */
  315. #define FLAGS_MARK 0x0000000000001000ULL /* marked client */
  316. #define FLAGS_CANFLOOD 0x0000000000002000ULL /* client has the ability to flood */
  317. #define FLAGS_EXEMPTGLINE 0x0000000000004000ULL /* client can't be G-lined */
  318. #define FLAGS_EXEMPTKLINE 0x0000000000008000ULL /* client is exempt from kline */
  319. #define FLAGS_NOLIMIT 0x0000000000010000ULL /* client is exempt from limits */
  320. #define FLAGS_RESTRICTED 0x0000000000020000ULL /* client cannot op others */
  321. #define FLAGS_PING_COOKIE 0x0000000000040000ULL /* PING Cookie */
  322. #define FLAGS_IDLE_LINED 0x0000000000080000ULL /* client is exempt from idle-time limits */
  323. #define FLAGS_IP_SPOOFING 0x0000000000100000ULL /* client IP is spoofed */
  324. #define FLAGS_FLOODDONE 0x0000000000200000ULL /* Flood grace period has been ended. */
  325. #define FLAGS_EOB 0x0000000000400000ULL /* server has received EOB */
  326. #define FLAGS_HIDDEN 0x0000000000800000ULL /* a hidden server. not shown in /links */
  327. #define FLAGS_BLOCKED 0x0000000001000000ULL /* must wait for COMM_SELECT_WRITE */
  328. #define FLAGS_SBLOCKED 0x0000000002000000ULL /* slinkq is blocked */
  329. #define FLAGS_USERHOST 0x0000000004000000ULL /* client is in userhost hash */
  330. #define FLAGS_BURSTED 0x0000000008000000ULL /* user was already bursted */
  331. #define FLAGS_EXEMPTRESV 0x0000000010000000ULL /* client is exempt from RESV */
  332. #define FLAGS_GOTUSER 0x0000000020000000ULL /* if we received a USER command */
  333. #define FLAGS_PINGWARNING 0x0000000040000000ULL /* unreplied ping warning already sent */
  334. #define FLAGS_FINISHED_AUTH 0x0000000080000000ULL /* Client has been released from auth */
  335. #define FLAGS_SERVICES 0x0000000100000000ULL /* client is a services server or client */
  336. /* umodes, settable flags */
  337. #define UMODE_SERVNOTICE 0x00000001 /* server notices such as kill */
  338. #define UMODE_CCONN 0x00000002 /* Client Connections */
  339. #define UMODE_REJ 0x00000004 /* Bot Rejections */
  340. #define UMODE_SKILL 0x00000008 /* Server Killed */
  341. #define UMODE_FULL 0x00000010 /* Full messages */
  342. #define UMODE_SPY 0x00000020 /* see STATS / LINKS */
  343. #define UMODE_DEBUG 0x00000040 /* 'debugging' info */
  344. #define UMODE_NCHANGE 0x00000080 /* Nick change notice */
  345. #define UMODE_WALLOP 0x00000100 /* send wallops to them */
  346. #define UMODE_OPERWALL 0x00000200 /* Operwalls */
  347. #define UMODE_INVISIBLE 0x00000400 /* makes user invisible */
  348. #define UMODE_BOTS 0x00000800 /* shows bots */
  349. #define UMODE_EXTERNAL 0x00001000 /* show servers introduced and splitting */
  350. #define UMODE_CALLERID 0x00002000 /* block unless caller id's */
  351. #define UMODE_SOFTCALLERID 0x00004000 /* block unless on common channel */
  352. #define UMODE_UNAUTH 0x00008000 /* show unauth connects here */
  353. #define UMODE_LOCOPS 0x00010000 /* show locops */
  354. #define UMODE_DEAF 0x00020000 /* don't receive channel messages */
  355. #define UMODE_CLOAK 0x00040000 /* user has their hostname cloaked */
  356. #define UMODE_SSL 0x00080000 /* client is connected via SSL */
  357. #define UMODE_REGNICK 0x00100000 /* client has identified for their nick */
  358. #define UMODE_REGONLY 0x00200000 /* only accept privmsgs from +r users */
  359. #define UMODE_NOCTCP 0x00400000 /* block ctcp messages to user */
  360. #define UMODE_HIDECHANNELS 0x00800000 /* suppress output of channel list on WHOIS */
  361. #define UMODE_WEBIRC 0x01000000 /* cgi:irc user */
  362. /* user information flags, only settable by remote mode or local oper */
  363. #define UMODE_ROUTING 0x10000000 /* Routing Team umode */
  364. #define UMODE_OPER 0x20000000 /* Operator */
  365. #define UMODE_ADMIN 0x40000000 /* Admin on server */
  366. #define UMODE_NETADMIN 0x80000000 /* Network Administrator */
  367. #define UMODE_ALL UMODE_SERVNOTICE
  368. #define SEND_UMODES (UMODE_INVISIBLE | UMODE_OPER | UMODE_WALLOP | UMODE_SPY | \
  369. UMODE_ADMIN | UMODE_CLOAK | UMODE_SSL | UMODE_REGNICK | UMODE_ROUTING | \
  370. UMODE_REGONLY | UMODE_NETADMIN | UMODE_HIDECHANNELS | UMODE_WEBIRC)
  371. /* oper priv flags */
  372. #define OPER_FLAG_GLOBAL_KILL 0x00000001 /* oper can global kill */
  373. #define OPER_FLAG_REMOTE 0x00000002 /* oper can do squits/connects */
  374. #define OPER_FLAG_UNKLINE 0x00000004 /* oper can use unkline */
  375. #define OPER_FLAG_GLINE 0x00000008 /* oper can use gline */
  376. #define OPER_FLAG_N 0x00000010 /* oper can umode n */
  377. #define OPER_FLAG_K 0x00000020 /* oper can kill/kline */
  378. #define OPER_FLAG_X 0x00000040 /* oper can xline */
  379. #define OPER_FLAG_DIE 0x00000080 /* oper can die */
  380. #define OPER_FLAG_REHASH 0x00000100 /* oper can rehash */
  381. #define OPER_FLAG_ADMIN 0x00000200 /* oper can set umode +a */
  382. #define OPER_FLAG_HIDDEN_ADMIN 0x00000400 /* admin is hidden */
  383. #define OPER_FLAG_OPERWALL 0x00000800 /* */
  384. #define OPER_FLAG_OPER_SPY 0x00001000 /* */
  385. #define OPER_FLAG_REMOTEBAN 0x00002000 /* */
  386. #define OPER_FLAG_HIDDEN_OPER 0x00004000 /* */
  387. #define SetOFlag(x, y) ((x)->localClient->operflags |= (y))
  388. /* flags macros. */
  389. #define IsAuthFinished(x) ((x)->flags & FLAGS_FINISHED_AUTH)
  390. #define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET)
  391. #define SetDead(x) ((x)->flags |= FLAGS_DEADSOCKET)
  392. #define IsClosing(x) ((x)->flags & FLAGS_CLOSING)
  393. #define SetClosing(x) ((x)->flags |= FLAGS_CLOSING)
  394. #define IsKilled(x) ((x)->flags & FLAGS_KILLED)
  395. #define SetKilled(x) ((x)->flags |= FLAGS_KILLED)
  396. #define IsCryptIn(x) ((x)->flags & FLAGS_CRYPTIN)
  397. #define SetCryptIn(x) ((x)->flags |= FLAGS_CRYPTIN)
  398. #define IsCryptOut(x) ((x)->flags & FLAGS_CRYPTOUT)
  399. #define SetCryptOut(x) ((x)->flags |= FLAGS_CRYPTOUT)
  400. #define IsWaitAuth(x) ((x)->flags & FLAGS_WAITAUTH)
  401. #define SetWaitAuth(x) ((x)->flags |= FLAGS_WAITAUTH)
  402. #define ClearWaitAuth(x) ((x)->flags &= ~FLAGS_WAITAUTH)
  403. #define HasServlink(x) ((x)->flags & FLAGS_SERVLINK)
  404. #define SetServlink(x) ((x)->flags |= FLAGS_SERVLINK)
  405. #define MyConnect(x) ((x)->localClient != NULL)
  406. #define MyClient(x) (MyConnect(x) && IsClient(x))
  407. #define SetMark(x) ((x)->flags |= FLAGS_MARK)
  408. #define ClearMark(x) ((x)->flags &= ~FLAGS_MARK)
  409. #define IsMarked(x) ((x)->flags & FLAGS_MARK)
  410. #define SetCanFlood(x) ((x)->flags |= FLAGS_CANFLOOD)
  411. #define IsCanFlood(x) ((x)->flags & FLAGS_CANFLOOD)
  412. #define IsDefunct(x) ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING| \
  413. FLAGS_KILLED))
  414. #define IsServices(x) ((x)->flags & FLAGS_SERVICES)
  415. #define SetServices(x) ((x)->flags |= FLAGS_SERVICES)
  416. #define ClearServices(x) ((x)->flags &= ~FLAGS_SERVICES)
  417. /* oper flags */
  418. #define MyOper(x) (MyConnect(x) && IsOper(x))
  419. #define SetOper(x) {(x)->umodes |= UMODE_OPER; \
  420. if (!IsServer((x))) (x)->handler = OPER_HANDLER;}
  421. #define ClearOper(x) {(x)->umodes &= ~(UMODE_OPER|UMODE_ADMIN); \
  422. if (!IsOper((x)) && !IsServer((x))) \
  423. (x)->handler = CLIENT_HANDLER; }
  424. #define IsPrivileged(x) (IsOper(x) || IsServer(x) || IsServices(x))
  425. /* umode flags */
  426. #define IsInvisible(x) ((x)->umodes & UMODE_INVISIBLE)
  427. #define SendWallops(x) ((x)->umodes & UMODE_WALLOP)
  428. #define IsSetCallerId(x) ((x)->umodes & \
  429. (UMODE_CALLERID|UMODE_SOFTCALLERID))
  430. #define IsSoftCallerId(x) ((x)->umodes & UMODE_SOFTCALLERID)
  431. #define IsCallerId(x) ((x)->umodes & UMODE_CALLERID)
  432. #define IsDeaf(x) ((x)->umodes & UMODE_DEAF)
  433. #define IsNoCTCP(x) ((x)->umodes & UMODE_NOCTCP)
  434. #define SetCloaked(x) ((x)->umodes |= UMODE_CLOAK)
  435. #define ClearCloaked(x) ((x)->umodes &= ~UMODE_CLOAK)
  436. #define IsCloaked(x) ((x)->umodes & UMODE_CLOAK)
  437. #define SetSSL(x) ((x)->umodes |= UMODE_SSL)
  438. #define ClearSSL(x) ((x)->umodes &= ~UMODE_SSL)
  439. #define IsSSL(x) ((x)->umodes & UMODE_SSL)
  440. #define SetRegNick(x) ((x)->umodes |= UMODE_REGNICK)
  441. #define ClearRegNick(x) ((x)->umodes &= ~UMODE_REGNICK)
  442. #define IsRegNick(x) ((x)->umodes & UMODE_REGNICK)
  443. #define SetRegOnly(x) ((x)->umodes |= UMODE_REGONLY)
  444. #define ClearRegOnly(x) ((x)->umodes &= ~UMODE_REGONLY)
  445. #define IsRegOnly(x) ((x)->umodes & UMODE_REGONLY)
  446. #define SetNetAdmin(x) ((x)->umodes |= UMODE_NETADMIN)
  447. #define ClearNetAdmin(x) ((x)->umodes &= ~UMODE_NETADMIN)
  448. #define IsNetAdmin(x) ((x)->umodes & UMODE_NETADMIN)
  449. #define SetRouting(x) ((x)->umodes |= UMODE_ROUTING)
  450. #define ClearRouting(x) ((x)->umodes &= ~UMODE_ROUTING)
  451. #define IsRouting(x) ((x)->umodes & UMODE_ROUTING)
  452. #define SetHideChannels(x) ((x)->umodes |= UMODE_HIDECHANNELS)
  453. #define ClearHideChannels(x) ((x)->umodes &= ~UMODE_HIDECHANNELS)
  454. #define IsHideChannels(x) ((x)->umodes & UMODE_HIDECHANNELS)
  455. #define IsSpy(x) ((x)->umodes & UMODE_SPY)
  456. #define SetWebIrc(x) ((x)->umodes |= UMODE_WEBIRC)
  457. #define ClearWebIrc(x) ((x)->umodes &= ~UMODE_WEBIRC)
  458. #define IsWebIrc(x) ((x)->umodes & UMODE_WEBIRC)
  459. #define SetSendQExceeded(x) ((x)->flags |= FLAGS_SENDQEX)
  460. #define IsSendQExceeded(x) ((x)->flags & FLAGS_SENDQEX)
  461. #define SetIpHash(x) ((x)->flags |= FLAGS_IPHASH)
  462. #define ClearIpHash(x) ((x)->flags &= ~FLAGS_IPHASH)
  463. #define IsIpHash(x) ((x)->flags & FLAGS_IPHASH)
  464. #define SetUserHost(x) ((x)->flags |= FLAGS_USERHOST)
  465. #define ClearUserHost(x) ((x)->flags &= ~FLAGS_USERHOST)
  466. #define IsUserHostIp(x) ((x)->flags & FLAGS_USERHOST)
  467. #define SetPingSent(x) ((x)->flags |= FLAGS_PINGSENT)
  468. #define IsPingSent(x) ((x)->flags & FLAGS_PINGSENT)
  469. #define ClearPingSent(x) ((x)->flags &= ~FLAGS_PINGSENT)
  470. #define SetPingWarning(x) ((x)->flags |= FLAGS_PINGWARNING)
  471. #define IsPingWarning(x) ((x)->flags & FLAGS_PINGWARNING)
  472. #define ClearPingWarning(x) ((x)->flags &= ~FLAGS_PINGWARNING)
  473. #define SetNeedId(x) ((x)->flags |= FLAGS_NEEDID)
  474. #define IsNeedId(x) ((x)->flags & FLAGS_NEEDID)
  475. #define SetGotId(x) ((x)->flags |= FLAGS_GOTID)
  476. #define IsGotId(x) ((x)->flags & FLAGS_GOTID)
  477. #define IsExemptKline(x) ((x)->flags & FLAGS_EXEMPTKLINE)
  478. #define SetExemptKline(x) ((x)->flags |= FLAGS_EXEMPTKLINE)
  479. #define IsExemptLimits(x) ((x)->flags & FLAGS_NOLIMIT)
  480. #define SetExemptLimits(x) ((x)->flags |= FLAGS_NOLIMIT)
  481. #define IsExemptGline(x) ((x)->flags & FLAGS_EXEMPTGLINE)
  482. #define SetExemptGline(x) ((x)->flags |= FLAGS_EXEMPTGLINE)
  483. #define IsExemptResv(x) ((x)->flags & FLAGS_EXEMPTRESV)
  484. #define SetExemptResv(x) ((x)->flags |= FLAGS_EXEMPTRESV)
  485. #define SetIPSpoof(x) ((x)->flags |= FLAGS_IP_SPOOFING)
  486. #define IsIPSpoof(x) ((x)->flags & FLAGS_IP_SPOOFING)
  487. #define IsIdlelined(x) ((x)->flags & FLAGS_IDLE_LINED)
  488. #define SetIdlelined(x) ((x)->flags |= FLAGS_IDLE_LINED)
  489. #define IsRestricted(x) ((x)->flags & FLAGS_RESTRICTED)
  490. #define SetRestricted(x) ((x)->flags |= FLAGS_RESTRICTED)
  491. #define IsFloodDone(x) ((x)->flags & FLAGS_FLOODDONE)
  492. #define SetFloodDone(x) ((x)->flags |= FLAGS_FLOODDONE)
  493. #define HasPingCookie(x) ((x)->flags & FLAGS_PING_COOKIE)
  494. #define SetPingCookie(x) ((x)->flags |= FLAGS_PING_COOKIE)
  495. #define IsHidden(x) ((x)->flags & FLAGS_HIDDEN)
  496. #define SetHidden(x) ((x)->flags |= FLAGS_HIDDEN)
  497. #define IsSendqBlocked(x) ((x)->flags & FLAGS_BLOCKED)
  498. #define SetSendqBlocked(x) ((x)->flags |= FLAGS_BLOCKED)
  499. #define ClearSendqBlocked(x) ((x)->flags &= ~FLAGS_BLOCKED)
  500. #define IsSlinkqBlocked(x) ((x)->flags & FLAGS_SBLOCKED)
  501. #define SetSlinkqBlocked(x) ((x)->flags |= FLAGS_SBLOCKED)
  502. #define ClearSlinkqBlocked(x) ((x)->flags &= ~FLAGS_SBLOCKED)
  503. #define IsBursted(x) ((x)->flags & FLAGS_BURSTED)
  504. #define SetBursted(x) ((x)->flags |= FLAGS_BURSTED)
  505. #define ClearBursted(x) ((x)->flags &= ~FLAGS_BURSTED)
  506. #define IsCaptured(x) ((x)->handler == DUMMY_HANDLER)
  507. #define SetCaptured(x) ((x)->handler = DUMMY_HANDLER)
  508. #define ClearCaptured(x) ((x)->handler = CLIENT_HANDLER)
  509. /* operflags macros */
  510. #define ClearOperFlags(x) ((x)->localClient->operflags = 0)
  511. #define IsOperGlobalKill(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_GLOBAL_KILL : 0)
  512. #define IsOperRemote(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_REMOTE : 0)
  513. #define IsOperUnkline(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_UNKLINE : 0)
  514. #define IsOperGline(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_GLINE : 0)
  515. #define IsOperN(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_N : 0)
  516. #define IsOperK(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_K : 0)
  517. #define IsOperDie(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_DIE : 0)
  518. #define IsOperRehash(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_REHASH : 0)
  519. #define IsOperAdmin(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_ADMIN : 0)
  520. #define IsOperHiddenAdmin(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_HIDDEN_ADMIN : 0)
  521. #define IsOperX(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_X : 0)
  522. #define IsOperWall(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_OPERWALL : 0)
  523. #define IsOperRemoteBan(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_REMOTEBAN : 0)
  524. #define IsOperHidden(x) (MyConnect(x) ? (x)->localClient->operflags & OPER_FLAG_HIDDEN_OPER : 0)
  525. /*
  526. * definitions for get_client_name
  527. * TBD - make this an enum
  528. */
  529. #define HIDE_IP 0
  530. #define SHOW_IP 1
  531. #define MASK_IP 2
  532. #define HIDE_REALHOST 3
  533. extern struct Client me;
  534. extern dlink_list listing_client_list;
  535. extern dlink_list global_client_list;
  536. extern int accept_message(struct Client *, struct Client *);
  537. extern void set_initial_nick(struct Client *, struct Client *, const char *);
  538. extern void exit_client(struct Client *, struct Client *, const char *);
  539. extern void check_conf_klines(void);
  540. extern void init_client(void);
  541. extern void del_from_accept(struct Client *, struct Client *);
  542. extern void del_all_accepts(struct Client *);
  543. extern void del_all_their_accepts(struct Client *);
  544. extern void change_local_nick(struct Client *, struct Client *, const char *);
  545. extern void change_local_host(struct Client *, const char *, const char *);
  546. extern void dead_link_on_write(struct Client *, int);
  547. extern void dead_link_on_read(struct Client *, int);
  548. extern void exit_aborted_clients(void);
  549. extern void free_exited_clients(void);
  550. extern struct Client *make_client(struct Client *);
  551. extern struct Client *find_chasing(struct Client *, struct Client *, const char *, int *);
  552. extern struct Client *find_person(const struct Client *const, const char *);
  553. extern const char *get_client_name(struct Client *, int);
  554. extern void ban_them(struct Client *, struct ConfItem *);
  555. #endif /* INCLUDED_client_h */