-#define cli_next(cli) ((cli)->next)
-#define cli_prev(cli) ((cli)->prev)
-#define cli_hnext(cli) ((cli)->hnext)
-#define cli_from(cli) ((cli)->from)
-#define cli_user(cli) ((cli)->user)
-#define cli_serv(cli) ((cli)->serv)
-#define cli_whowas(cli) ((cli)->whowas)
-#define cli_yxx(cli) ((cli)->yxx)
-#define cli_lasttime(cli) ((cli)->lasttime)
-#define cli_since(cli) ((cli)->since)
-#define cli_firsttime(cli) ((cli)->firsttime)
-#define cli_lastnick(cli) ((cli)->lastnick)
-#define cli_marker(cli) ((cli)->marker)
-#define cli_flags(cli) ((cli)->flags)
-#define cli_hopcount(cli) ((cli)->hopcount)
-#define cli_ip(cli) ((cli)->ip)
-#define cli_status(cli) ((cli)->status)
-#define cli_local(cli) ((cli)->local)
-#define cli_name(cli) ((cli)->name)
-#define cli_username(cli) ((cli)->username)
-#define cli_info(cli) ((cli)->info)
-
-#define cli_count(cli) ((cli)->count)
-#define cli_fd(cli) ((cli)->fd)
-#define cli_error(cli) ((cli)->error)
-#define cli_snomask(cli) ((cli)->snomask)
-#define cli_nextnick(cli) ((cli)->nextnick)
-#define cli_nexttarget(cli) ((cli)->nexttarget)
-#define cli_cookie(cli) ((cli)->cookie)
-#define cli_sendQ(cli) ((cli)->sendQ)
-#define cli_recvQ(cli) ((cli)->recvQ)
-#define cli_sendM(cli) ((cli)->sendM)
-#define cli_sendK(cli) ((cli)->sendK)
-#define cli_receiveM(cli) ((cli)->receiveM)
-#define cli_receiveK(cli) ((cli)->receiveK)
-#define cli_sendB(cli) ((cli)->sendB)
-#define cli_receiveB(cli) ((cli)->receiveB)
-#define cli_listener(cli) ((cli)->listener)
-#define cli_confs(cli) ((cli)->confs)
-#define cli_handler(cli) ((cli)->handler)
-#define cli_dns_reply(cli) ((cli)->dns_reply)
-#define cli_listing(cli) ((cli)->listing)
-#define cli_max_sendq(cli) ((cli)->max_sendq)
-#define cli_ping_freq(cli) ((cli)->ping_freq)
-#define cli_lastsq(cli) ((cli)->lastsq)
-#define cli_port(cli) ((cli)->port)
-#define cli_targets(cli) ((cli)->targets)
-#define cli_sock_ip(cli) ((cli)->sock_ip)
-#define cli_sockhost(cli) ((cli)->sockhost)
-#define cli_passwd(cli) ((cli)->passwd)
-#define cli_buffer(cli) ((cli)->buffer)
-
-#define STAT_CONNECTING 0x001 /* connecting to another server */
-#define STAT_HANDSHAKE 0x002 /* pass - server sent */
-#define STAT_ME 0x004 /* this server */
-#define STAT_UNKNOWN 0x008 /* unidentified connection */
-#define STAT_UNKNOWN_USER 0x010 /* Connect to client port */
-#define STAT_UNKNOWN_SERVER 0x020 /* Connect to server port */
-#define STAT_SERVER 0x040
-#define STAT_USER 0x080
+/** Magic constant to identify valid Client structures. */
+#define CLIENT_MAGIC 0x4ca08286
+
+/** Verify that a client is valid. */
+#define cli_verify(cli) ((cli)->cli_magic == CLIENT_MAGIC)
+/** Get client's magic number. */
+#define cli_magic(cli) ((cli)->cli_magic)
+/** Get global next client. */
+#define cli_next(cli) ((cli)->cli_next)
+/** Get global previous client. */
+#define cli_prev(cli) ((cli)->cli_prev)
+/** Get next client in hash bucket chain. */
+#define cli_hnext(cli) ((cli)->cli_hnext)
+/** Get connection associated with client. */
+#define cli_connect(cli) ((cli)->cli_connect)
+/** Get local client that links us to \a cli. */
+#define cli_from(cli) con_client(cli_connect(cli))
+/** Get User structure for client, if client is a user. */
+#define cli_user(cli) ((cli)->cli_user)
+/** Get Server structure for client, if client is a server. */
+#define cli_serv(cli) ((cli)->cli_serv)
+/** Get Whowas link for client. */
+#define cli_whowas(cli) ((cli)->cli_whowas)
+/** Get client numnick. */
+#define cli_yxx(cli) ((cli)->cli_yxx)
+/** Get time we last read data from the client socket. */
+#define cli_lasttime(cli) con_lasttime(cli_connect(cli))
+/** Get time we last parsed something from the client. */
+#define cli_since(cli) con_since(cli_connect(cli))
+/** Get time client was created. */
+#define cli_firsttime(cli) ((cli)->cli_firsttime)
+/** Get time client last changed nickname. */
+#define cli_lastnick(cli) ((cli)->cli_lastnick)
+/** Get WHO marker for client. */
+#define cli_marker(cli) ((cli)->cli_marker)
+/** Get flags flagset for client. */
+#define cli_flags(cli) ((cli)->cli_flags)
+/** Get hop count to client. */
+#define cli_hopcount(cli) ((cli)->cli_hopcount)
+/** Get client IP address. */
+#define cli_ip(cli) ((cli)->cli_ip)
+/** Get status bitmask for client. */
+#define cli_status(cli) ((cli)->cli_status)
+/** Return non-zero if the client is local. */
+#define cli_local(cli) (cli_from(cli) == cli)
+/** Get oper privileges for client. */
+#define cli_privs(cli) con_privs(cli_connect(cli))
+/** Get client capabilities for client */
+#define cli_capab(cli) con_capab(cli_connect(cli))
+/** Get active client capabilities for client */
+#define cli_active(cli) con_active(cli_connect(cli))
+/** Get client name. */
+#define cli_name(cli) ((cli)->cli_name)
+/** Get client username (ident). */
+#define cli_username(cli) ((cli)->cli_username)
+/** Get client realname (information field). */
+#define cli_info(cli) ((cli)->cli_info)
+/** Get client account string. */
+#define cli_account(cli) (cli_user(cli) ? cli_user(cli)->account : "0")
+
+/** Get number of incoming bytes queued for client. */
+#define cli_count(cli) con_count(cli_connect(cli))
+/** Get file descriptor for sending in client's direction. */
+#define cli_fd(cli) con_fd(cli_connect(cli))
+/** Get free flags for the client's connection. */
+#define cli_freeflag(cli) con_freeflag(cli_connect(cli))
+/** Get last error code for the client's connection. */
+#define cli_error(cli) con_error(cli_connect(cli))
+/** Get server notice mask for the client. */
+#define cli_snomask(cli) con_snomask(cli_connect(cli))
+/** Get next time a nick change is allowed for the client. */
+#define cli_nextnick(cli) con_nextnick(cli_connect(cli))
+/** Get next time a target change is allowed for the client. */
+#define cli_nexttarget(cli) con_nexttarget(cli_connect(cli))
+/** Get SendQ for client. */
+#define cli_sendQ(cli) con_sendQ(cli_connect(cli))
+/** Get RecvQ for client. */
+#define cli_recvQ(cli) con_recvQ(cli_connect(cli))
+/** Get count of messages sent to client. */
+#define cli_sendM(cli) con_sendM(cli_connect(cli))
+/** Get number of messages received from client. */
+#define cli_receiveM(cli) con_receiveM(cli_connect(cli))
+/** Get number of bytes (modulo 1024) sent to client. */
+#define cli_sendB(cli) con_sendB(cli_connect(cli))
+/** Get number of bytes (modulo 1024) received from client. */
+#define cli_receiveB(cli) con_receiveB(cli_connect(cli))
+/** Get listener that accepted the client's connection. */
+#define cli_listener(cli) con_listener(cli_connect(cli))
+/** Get list of attached conf lines. */
+#define cli_confs(cli) con_confs(cli_connect(cli))
+/** Get handler type for client. */
+#define cli_handler(cli) con_handler(cli_connect(cli))
+/** Get LIST status for client. */
+#define cli_listing(cli) con_listing(cli_connect(cli))
+/** Get cached max SendQ for client. */
+#define cli_max_sendq(cli) con_max_sendq(cli_connect(cli))
+/** Get ping frequency for client. */
+#define cli_ping_freq(cli) con_ping_freq(cli_connect(cli))
+/** Get lastsq for client's connection. */
+#define cli_lastsq(cli) con_lastsq(cli_connect(cli))
+/** Get the array of current targets for the client. */
+#define cli_targets(cli) con_targets(cli_connect(cli))
+/** Get the string form of the client's IP address. */
+#define cli_sock_ip(cli) con_sock_ip(cli_connect(cli))
+/** Get the resolved hostname for the client. */
+#define cli_sockhost(cli) con_sockhost(cli_connect(cli))
+/** Get the client's password. */
+#define cli_passwd(cli) con_passwd(cli_connect(cli))
+/** Get the unprocessed input buffer for a client's connection. */
+#define cli_buffer(cli) con_buffer(cli_connect(cli))
+/** Get the Socket structure for sending to a client. */
+#define cli_socket(cli) con_socket(cli_connect(cli))
+/** Get Timer for processing waiting messages from the client. */
+#define cli_proc(cli) con_proc(cli_connect(cli))
+/** Get auth request for client. */
+#define cli_auth(cli) con_auth(cli_connect(cli))
+/** Get sentalong marker for client. */
+#define cli_sentalong(cli) con_sentalong(cli_connect(cli))
+
+/** Verify that a connection is valid. */
+#define con_verify(con) ((con)->con_magic == CONNECTION_MAGIC)
+/** Get connection's magic number. */
+#define con_magic(con) ((con)->con_magic)
+/** Get global next connection. */
+#define con_next(con) ((con)->con_next)
+/** Get global previous connection. */
+#define con_prev_p(con) ((con)->con_prev_p)
+/** Get locally connected client for connection. */
+#define con_client(con) ((con)->con_client)
+/** Get number of unprocessed data bytes from connection. */
+#define con_count(con) ((con)->con_count)
+/** Get file descriptor for connection. */
+#define con_fd(con) s_fd(&(con)->con_socket)
+/** Get freeable flags for connection. */
+#define con_freeflag(con) ((con)->con_freeflag)
+/** Get last error code on connection. */
+#define con_error(con) ((con)->con_error)
+/** Get sentalong marker for connection. */
+#define con_sentalong(con) ((con)->con_sentalong)
+/** Get server notice mask for connection. */
+#define con_snomask(con) ((con)->con_snomask)
+/** Get next nick change time for connection. */
+#define con_nextnick(con) ((con)->con_nextnick)
+/** Get next new target time for connection. */
+#define con_nexttarget(con) ((con)->con_nexttarget)
+/** Get last time we read from the connection. */
+#define con_lasttime(con) ((con)->con_lasttime)
+/** Get last time we accepted a command from the connection. */
+#define con_since(con) ((con)->con_since)
+/** Get SendQ for connection. */
+#define con_sendQ(con) ((con)->con_sendQ)
+/** Get RecvQ for connection. */
+#define con_recvQ(con) ((con)->con_recvQ)
+/** Get number of messages sent to connection. */
+#define con_sendM(con) ((con)->con_sendM)
+/** Get number of messages received from connection. */
+#define con_receiveM(con) ((con)->con_receiveM)
+/** Get number of bytes (modulo 1024) sent to connection. */
+#define con_sendB(con) ((con)->con_sendB)
+/** Get number of bytes (modulo 1024) received from connection. */
+#define con_receiveB(con) ((con)->con_receiveB)
+/** Get listener that accepted the connection. */
+#define con_listener(con) ((con)->con_listener)
+/** Get list of ConfItems attached to the connection. */
+#define con_confs(con) ((con)->con_confs)
+/** Get command handler for the connection. */
+#define con_handler(con) ((con)->con_handler)
+/** Get the LIST status for the connection. */
+#define con_listing(con) ((con)->con_listing)
+/** Get the maximum permitted SendQ size for the connection. */
+#define con_max_sendq(con) ((con)->con_max_sendq)
+/** Get the ping frequency for the connection. */
+#define con_ping_freq(con) ((con)->con_ping_freq)
+/** Get the lastsq for the connection. */
+#define con_lastsq(con) ((con)->con_lastsq)
+/** Get the current targets array for the connection. */
+#define con_targets(con) ((con)->con_targets)
+/** Get the string-formatted IP address for the connection. */
+#define con_sock_ip(con) ((con)->con_sock_ip)
+/** Get the resolved hostname for the connection. */
+#define con_sockhost(con) ((con)->con_sockhost)
+/** Get the password sent by the remote end of the connection. */
+#define con_passwd(con) ((con)->con_passwd)
+/** Get the buffer of unprocessed incoming data from the connection. */
+#define con_buffer(con) ((con)->con_buffer)
+/** Get the Socket for the connection. */
+#define con_socket(con) ((con)->con_socket)
+/** Get the Timer for processing more data from the connection. */
+#define con_proc(con) ((con)->con_proc)
+/** Get the oper privilege set for the connection. */
+#define con_privs(con) (&(con)->con_privs)
+/** Get the peer's capabilities for the connection. */
+#define con_capab(con) (&(con)->con_capab)
+/** Get the active capabilities for the connection. */
+#define con_active(con) (&(con)->con_active)
+/** Get the auth request for the connection. */
+#define con_auth(con) ((con)->con_auth)
+
+#define STAT_CONNECTING 0x001 /**< connecting to another server */
+#define STAT_HANDSHAKE 0x002 /**< pass - server sent */
+#define STAT_ME 0x004 /**< this server */
+#define STAT_UNKNOWN 0x008 /**< unidentified connection */
+#define STAT_UNKNOWN_USER 0x010 /**< connection on a client port */
+#define STAT_UNKNOWN_SERVER 0x020 /**< connection on a server port */
+#define STAT_SERVER 0x040 /**< fully registered server */
+#define STAT_USER 0x080 /**< fully registered user */