Author: Ghostwolf <foxxe@wtfs.net>
[ircu2.10.12-pk.git] / include / client.h
index 22125edef74c56a621ea33263ca5d938e2913c78..2e563456ff78727e269802120d5933a9a52c5e0e 100644 (file)
 #ifndef INCLUDED_ircd_defs_h
 #include "ircd_defs.h"
 #endif
-#ifndef INCLUDED_config_h
-#include "config.h"
-#endif
 #ifndef INCLUDED_dbuf_h
 #include "dbuf.h"
 #endif
 #ifndef INCLUDED_msgq_h
 #include "msgq.h"
 #endif
+#ifndef INCLUDED_ircd_events_h
+#include "ircd_events.h"
+#endif
 #ifndef INCLUDED_ircd_handler_h
 #include "ircd_handler.h"
 #endif
@@ -56,6 +56,7 @@ struct Whowas;
 struct DNSReply;
 struct hostent;
 struct Privs;
+struct AuthRequest;
 
 /*
  * Structures
@@ -94,7 +95,9 @@ struct Privs;
 #define PRIV_DISPLAY           25 /* "Is an oper" displayed */
 #define PRIV_SEE_OPERS         26 /* display hidden opers */
 
-#define PRIV_LAST_PRIV         26 /* must be the same as the last priv */
+#define PRIV_WIDE_GLINE                27 /* oper can set wider G-lines */
+
+#define PRIV_LAST_PRIV         27 /* must be the same as the last priv */
 
 #define _PRIV_NBITS            (8 * sizeof(unsigned long))
 
@@ -113,11 +116,13 @@ struct Connection {
    *  to which the allocation is tied to! *Never* refer to
    *  these fields, if (from != self).
    */
+  unsigned long       con_magic; /* magic number */
   struct Connection*  con_next;  /* Next connection with queued data */
   struct Connection** con_prev_p; /* What points to us */
   struct Client*      con_client; /* Client associated with connection */
   unsigned int        con_count; /* Amount of data in buffer */
   int                 con_fd;    /* >= 0, for local clients */
+  int                 con_freeflag; /* indicates if connection can be freed */
   int                 con_error; /* last socket level error for client */
   unsigned int        con_snomask; /* mask for server messages */
   time_t              con_nextnick; /* Next time a nick change is allowed */
@@ -152,9 +157,15 @@ struct Connection {
   char con_passwd[PASSWDLEN + 1];
   char con_buffer[BUFSIZE];     /* Incoming message buffer; or the error that
                                    caused this clients socket to be `dead' */
+  struct Socket       con_socket; /* socket descriptor for client */
+  struct Timer        con_proc; /* process latent messages from client */
+  struct AuthRequest* con_auth; /* auth request for client */
 };
 
+#define CONNECTION_MAGIC 0x12f955f3
+
 struct Client {
+  unsigned long  cli_magic;     /* magic number */
   struct Client* cli_next;      /* link in GlobalClientList */
   struct Client* cli_prev;      /* link in GlobalClientList */
   struct Client* cli_hnext;     /* link in hash table bucket or this */
@@ -185,6 +196,10 @@ struct Client {
   char cli_info[REALLEN + 1];   /* Free form additional client information */
 };
 
+#define CLIENT_MAGIC 0x4ca08286
+
+#define cli_verify(cli)                ((cli)->cli_magic == CLIENT_MAGIC)
+#define cli_magic(cli)         ((cli)->cli_magic)
 #define cli_next(cli)          ((cli)->cli_next)
 #define cli_prev(cli)          ((cli)->cli_prev)
 #define cli_hnext(cli)         ((cli)->cli_hnext)
@@ -211,6 +226,7 @@ struct Client {
 
 #define cli_count(cli)         ((cli)->cli_connect->con_count)
 #define cli_fd(cli)            ((cli)->cli_connect->con_fd)
+#define cli_freeflag(cli)      ((cli)->cli_connect->con_freeflag)
 #define cli_error(cli)         ((cli)->cli_connect->con_error)
 #define cli_snomask(cli)       ((cli)->cli_connect->con_snomask)
 #define cli_nextnick(cli)      ((cli)->cli_connect->con_nextnick)
@@ -238,12 +254,18 @@ struct Client {
 #define cli_sockhost(cli)      ((cli)->cli_connect->con_sockhost)
 #define cli_passwd(cli)                ((cli)->cli_connect->con_passwd)
 #define cli_buffer(cli)                ((cli)->cli_connect->con_buffer)
+#define cli_socket(cli)                ((cli)->cli_connect->con_socket)
+#define cli_proc(cli)          ((cli)->cli_connect->con_proc)
+#define cli_auth(cli)          ((cli)->cli_connect->con_auth)
 
+#define con_verify(con)                ((con)->con_magic == CONNECTION_MAGIC)
+#define con_magic(con)         ((con)->con_magic)
 #define con_next(con)          ((con)->con_next)
 #define con_prev_p(con)                ((con)->con_prev_p)
 #define con_client(con)                ((con)->con_client)
 #define con_count(con)         ((con)->con_count)
 #define con_fd(con)            ((con)->con_fd)
+#define con_freeflag(con)      ((con)->con_freeflag)
 #define con_error(con)         ((con)->con_error)
 #define con_snomask(con)       ((con)->con_snomask)
 #define con_nextnick(con)      ((con)->con_nextnick)
@@ -271,6 +293,9 @@ struct Client {
 #define con_sockhost(con)      ((con)->con_sockhost)
 #define con_passwd(con)                ((con)->con_passwd)
 #define con_buffer(con)                ((con)->con_buffer)
+#define con_socket(con)                ((con)->con_socket)
+#define con_proc(con)          ((con)->con_proc)
+#define con_auth(con)          ((con)->con_auth)
 
 #define STAT_CONNECTING         0x001 /* connecting to another server */
 #define STAT_HANDSHAKE          0x002 /* pass - server sent */
@@ -330,9 +355,13 @@ struct Client {
 #define FLAGS_WALLOP     0x0040 /* send wallops to them */
 #define FLAGS_SERVNOTICE 0x0080 /* server notices such as kill */
 #define FLAGS_BLOCKED    0x0100 /* socket is in a blocked condition */
+#define FLAGS_ACCOUNT    0x0200 /* account name has been set */
 #define FLAGS_CLOSING    0x0400 /* set when closing to suppress errors */
 #define FLAGS_UPING      0x0800 /* has active UDP ping request */
 #define FLAGS_CHKACCESS  0x1000 /* ok to check clients access if set */
+#define FLAGS_HUB        0x2000 /* server is a hub */
+#define FLAGS_SERVICE    0x4000 /* server is a service */
+#define FLAGS_HIDDENHOST 0x8000 /* user's host is hidden */
 #define FLAGS_LOCAL     0x00010000      /* set for local clients */
 #define FLAGS_GOTID     0x00020000      /* successful ident lookup achieved */
 #define FLAGS_DOID      0x00040000      /* I-lines say must use ident return */
@@ -349,7 +378,7 @@ struct Client {
 #define FLAGS_IPCHECK   0x40000000      /* Added or updated IPregistry data */
 
 #define SEND_UMODES \
-    (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP|FLAGS_DEAF|FLAGS_CHSERV|FLAGS_DEBUG)
+    (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP|FLAGS_DEAF|FLAGS_CHSERV|FLAGS_DEBUG|FLAGS_ACCOUNT|FLAGS_HIDDENHOST)
 #define ALL_UMODES (SEND_UMODES|FLAGS_SERVNOTICE|FLAGS_LOCOP)
 #define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID)
 
@@ -377,6 +406,11 @@ struct Client {
 #define SendDebug(x)            (cli_flags(x) & FLAGS_DEBUG)
 #define SendServNotice(x)       (cli_flags(x) & FLAGS_SERVNOTICE)
 #define SendWallops(x)          (cli_flags(x) & FLAGS_WALLOP)
+#define IsHub(x)                (cli_flags(x) & FLAGS_HUB)
+#define IsService(x)            (cli_flags(x) & FLAGS_SERVICE)
+#define IsAccount(x)            (cli_flags(x) & FLAGS_ACCOUNT)
+#define IsHiddenHost(x)                (cli_flags(x) & FLAGS_HIDDENHOST)
+#define HasHiddenHost(x)       (IsAccount(x) && IsHiddenHost(x))
 
 #define IsPrivileged(x)         (IsAnOper(x) || IsServer(x))
 
@@ -395,6 +429,10 @@ struct Client {
 #define SetUPing(x)             (cli_flags(x) |= FLAGS_UPING)
 #define SetWallops(x)           (cli_flags(x) |= FLAGS_WALLOP)
 #define SetServNotice(x)        (cli_flags(x) |= FLAGS_SERVNOTICE)
+#define SetHub(x)               (cli_flags(x) |= FLAGS_HUB)
+#define SetService(x)           (cli_flags(x) |= FLAGS_SERVICE)
+#define SetAccount(x)           (cli_flags(x) |= FLAGS_ACCOUNT)
+#define SetHiddenHost(x)       (cli_flags(x) |= FLAGS_HIDDENHOST)
 
 #define ClearAccess(x)          (cli_flags(x) &= ~FLAGS_CHKACCESS)
 #define ClearBurst(x)           (cli_flags(x) &= ~FLAGS_BURST)
@@ -409,6 +447,11 @@ struct Client {
 #define ClearUPing(x)           (cli_flags(x) &= ~FLAGS_UPING)
 #define ClearWallops(x)         (cli_flags(x) &= ~FLAGS_WALLOP)
 #define ClearServNotice(x)      (cli_flags(x) &= ~FLAGS_SERVNOTICE)
+#define ClearHiddenHost(x)     (cli_flags(x) &= ~FLAGS_HIDDENHOST)
+
+/* free flags */
+#define FREEFLAG_SOCKET        0x0001  /* socket needs to be freed */
+#define FREEFLAG_TIMER 0x0002  /* timer needs to be freed */
 
 /* server notice stuff */