Update patchlevel for 2.10.12.04 release.
[ircu2.10.12-pk.git] / include / client.h
index d0ee1273cebebfe6ef6bb71dc53243493794ab9d..6e23e42361433855c1778b5e6f1fd49d01bb6920 100644 (file)
@@ -89,7 +89,7 @@ typedef unsigned long flagpage_t;
 /** Clear a flag in a flagset. */
 #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag))
 
-/** String containig valid user modes, in no particular order. */
+/** String containing valid user modes, in no particular order. */
 #define infousermodes "dioswkgx"
 
 /** Operator privileges. */
@@ -125,6 +125,7 @@ enum Priv
     PRIV_LIST_CHAN, /**< oper can list secret channels */
     PRIV_FORCE_OPMODE, /**< can hack modes on quarantined channels */
     PRIV_FORCE_LOCAL_OPMODE, /**< can hack modes on quarantined local channels */
+    PRIV_APASS_OPMODE, /**< can hack modes +A/-A/+U/-U */
     PRIV_LAST_PRIV /**< number of privileges */
   };
 
@@ -143,6 +144,7 @@ enum Flag
     FLAG_CLOSING,                   /**< set when closing to suppress errors */
     FLAG_UPING,                     /**< has active UDP ping request */
     FLAG_HUB,                       /**< server is a hub */
+    FLAG_IPV6,                      /**< server understands P10 IPv6 addrs */
     FLAG_SERVICE,                   /**< server is a service */
     FLAG_GOTID,                     /**< successful ident lookup achieved */
     FLAG_DOID,                      /**< I-lines say must use ident return */
@@ -175,6 +177,8 @@ DECLARE_FLAGSET(Privs, PRIV_LAST_PRIV);
 /** Declare flagset type for user flags. */
 DECLARE_FLAGSET(Flags, FLAG_LAST_FLAG);
 
+#include "capab.h" /* client capabilities */
+
 /** Represents a local connection.
  * This contains a lot of stuff irrelevant to server connections, but
  * those are so rare as to not be worth special-casing.
@@ -206,9 +210,8 @@ struct Connection
   struct SLink*       con_confs;     /**< Associated configuration records. */
   HandlerType         con_handler;   /**< Message index into command table
                                         for parsing. */
-  struct DNSReply*    con_dns_reply; /**< DNS reply received during client
-                                       registration. */
   struct ListingArgs* con_listing;   /**< Current LIST status. */
+  unsigned long       con_unreg;     /**< Indicate what still needs to be done */
   unsigned int        con_max_sendq; /**< cached max send queue for client */
   unsigned int        con_ping_freq; /**< cached ping freq */
   unsigned short      con_lastsq;    /**< # 2k blocks when sendqueued
@@ -227,6 +230,9 @@ struct Connection
                                       client */
   struct Timer        con_proc;      /**< process latent messages from
                                       client */
+  struct Privs        con_privs;     /**< Oper privileges */
+  struct CapSet       con_capab;     /**< Client capabilities (from us) */
+  struct CapSet       con_active;    /**< Active capabilities (to us) */
   struct AuthRequest* con_auth;      /**< auth request for client */
   struct IAuthRequest* con_iauth;    /**< iauth request for client */
 };
@@ -253,12 +259,18 @@ struct Client {
   unsigned int   cli_hopcount;    /**< number of servers to this 0 = local */
   struct irc_in_addr cli_ip;      /**< Real IP of client */
   short          cli_status;      /**< Client type */
-  struct Privs   cli_privs;       /**< Oper privileges */
   char cli_name[HOSTLEN + 1];     /**< Unique name of the client, nick or host */
-  char cli_username[USERLEN + 1]; /**< username here now for auth stuff */
+  char cli_username[USERLEN + 1]; /**< Username determined by ident lookup */
   char cli_info[REALLEN + 1];     /**< Free form additional client information */
 };
 
+#define CLIREG_NICK    0x0001  /**< Client must set nickname */
+#define CLIREG_USER    0x0002  /**< Client must set username */
+#define CLIREG_COOKIE  0x0004  /**< Client must return cookie */
+#define CLIREG_CAP     0x0008  /**< Client in capability negotiation */
+
+#define CLIREG_INIT    (CLIREG_NICK | CLIREG_USER | CLIREG_COOKIE)
+
 /** Magic constant to identify valid Client structures. */
 #define CLIENT_MAGIC 0x4ca08286
 
@@ -305,7 +317,13 @@ struct Client {
 /** 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)         ((cli)->cli_privs)
+#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 flags for remaining registration tasks */
+#define cli_unreg(cli)         con_unreg(cli_connect(cli))
 /** Get client name. */
 #define cli_name(cli)          ((cli)->cli_name)
 /** Get client username (ident). */
@@ -347,8 +365,6 @@ struct Client {
 #define cli_confs(cli)         con_confs(cli_connect(cli))
 /** Get handler type for client. */
 #define cli_handler(cli)       con_handler(cli_connect(cli))
-/** Get DNS reply for client. */
-#define cli_dns_reply(cli)     con_dns_reply(cli_connect(cli))
 /** Get LIST status for client. */
 #define cli_listing(cli)       con_listing(cli_connect(cli))
 /** Get cached max SendQ for client. */
@@ -428,10 +444,10 @@ struct Client {
 #define con_confs(con)         ((con)->con_confs)
 /** Get command handler for the connection. */
 #define con_handler(con)       ((con)->con_handler)
-/** Get DNS reply for the connection. */
-#define con_dns_reply(con)     ((con)->con_dns_reply)
 /** Get the LIST status for the connection. */
 #define con_listing(con)       ((con)->con_listing)
+/** Get remining steps before registration completes. */
+#define con_unreg(con)          ((con)->con_unreg)
 /** 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. */
@@ -452,6 +468,12 @@ struct Client {
 #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)
 /** Get the iauth request for the connection. */
@@ -574,6 +596,8 @@ struct Client {
 #define SendWallops(x)          HasFlag(x, FLAG_WALLOP)
 /** Return non-zero if the client claims to be a hub. */
 #define IsHub(x)                HasFlag(x, FLAG_HUB)
+/** Return non-zero if the client understands IPv6 addresses in P10. */
+#define IsIPv6(x)               HasFlag(x, FLAG_IPV6)
 /** Return non-zero if the client claims to be a services server. */
 #define IsService(x)            HasFlag(x, FLAG_SERVICE)
 /** Return non-zero if the client has an account stamp. */
@@ -620,6 +644,8 @@ struct Client {
 #define SetServNotice(x)        SetFlag(x, FLAG_SERVNOTICE)
 /** Mark a client as being a hub server. */
 #define SetHub(x)               SetFlag(x, FLAG_HUB)
+/** Mark a client as being an IPv6-grokking server. */
+#define SetIPv6(x)              SetFlag(x, FLAG_IPV6)
 /** Mark a client as being a services server. */
 #define SetService(x)           SetFlag(x, FLAG_SERVICE)
 /** Mark a client as having an account stamp. */
@@ -711,7 +737,16 @@ struct Client {
 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
 
 /** Test whether a privilege has been granted to a client. */
-#define HasPriv(cli, priv)  FlagHas(&cli_privs(cli), priv)
+#define HasPriv(cli, priv)  FlagHas(cli_privs(cli), priv)
+/** Grant a privilege to a client. */
+#define SetPriv(cli, priv)  FlagSet(cli_privs(cli), priv)
+/** Revoke a privilege from a client. */
+#define ClrPriv(cli, priv)  FlagClr(cli_privs(cli), priv)
+
+/** Test whether a client has a capability */
+#define HasCap(cli, cap)    CapHas(cli_capab(cli), (cap))
+/** Test whether a client has the capability active */
+#define CapActive(cli, cap) CapHas(cli_active(cli), (cap))
 
 #define HIDE_IP 0 /**< Do not show IP address in get_client_name() */
 #define SHOW_IP 1 /**< Show ident and IP address in get_client_name() */