/** Element number for flag \a flag. */
#define FLAGSET_INDEX(flag) ((flag) / FLAGSET_NBITS)
/** Element bit for flag \a flag. */
-#define FLAGSET_MASK(flag) (1<<((flag) % FLAGSET_NBITS))
+#define FLAGSET_MASK(flag) (1ul<<((flag) % FLAGSET_NBITS))
/** Declare a flagset structure of a particular size. */
#define DECLARE_FLAGSET(name,max) \
/** 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. */
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 */
/** 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.
struct MsgQ con_sendQ; /**< Outgoing message queue */
struct DBuf con_recvQ; /**< Incoming data yet to be parsed */
unsigned int con_sendM; /**< Stats: protocol messages sent */
- unsigned int con_sendK; /**< Stats: total k-bytes sent */
unsigned int con_receiveM; /**< Stats: protocol messages received */
- unsigned int con_receiveK; /**< Stats: total k-bytes received */
- unsigned short con_sendB; /**< Bytes sent, mod 1024. */
- unsigned short con_receiveB; /**< Bytes received, mod 1024. */
+ uint64_t con_sendB; /**< Bytes sent. */
+ uint64_t con_receiveB; /**< Bytes received. */
struct Listener* con_listener; /**< Listening socket which we accepted
from. */
struct SLink* con_confs; /**< Associated configuration records. */
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
client */
struct Timer con_proc; /**< process latent messages from
client */
+ struct Privs con_privs; /**< Oper privileges */
+ struct CapSet con_capab; /**< Client capabilities */
+ struct CapSet con_active; /**< Active client capabilities */
struct AuthRequest* con_auth; /**< auth request for client */
struct IAuthRequest* con_iauth; /**< iauth request for 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_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
/** 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). */
#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 kilobytes sent to client. */
-#define cli_sendK(cli) con_sendK(cli_connect(cli))
/** Get number of messages received from client. */
#define cli_receiveM(cli) con_receiveM(cli_connect(cli))
-/** Get number of kilobytes received from client. */
-#define cli_receiveK(cli) con_receiveK(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 con_recvQ(con) ((con)->con_recvQ)
/** Get number of messages sent to connection. */
#define con_sendM(con) ((con)->con_sendM)
-/** Get number of kilobytes sent to connection. */
-#define con_sendK(con) ((con)->con_sendK)
/** Get number of messages received from connection. */
#define con_receiveM(con) ((con)->con_receiveM)
-/** Get number of kilobytes received from connection. */
-#define con_receiveK(con) ((con)->con_receiveK)
/** 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_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. */
#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. */
#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. */
#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. */
#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() */