#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
struct Whowas;
struct DNSReply;
struct hostent;
+struct Privs;
+struct AuthRequest;
/*
* Structures
* source file, or in the source file itself (when only used in that file).
*/
+#define PRIV_CHAN_LIMIT 1 /* no channel limit on oper */
+#define PRIV_MODE_LCHAN 2 /* oper can mode local chans */
+#define PRIV_WALK_LCHAN 3 /* oper can walk thru local modes */
+#define PRIV_DEOP_LCHAN 4 /* no deop oper on local chans */
+#define PRIV_SHOW_INVIS 5 /* show local invisible users */
+#define PRIV_SHOW_ALL_INVIS 6 /* show all invisible users */
+#define PRIV_UNLIMIT_QUERY 7 /* unlimit who queries */
+
+#define PRIV_KILL 8 /* oper can KILL */
+#define PRIV_LOCAL_KILL 9 /* oper can local KILL */
+#define PRIV_REHASH 10 /* oper can REHASH */
+#define PRIV_RESTART 11 /* oper can RESTART */
+#define PRIV_DIE 12 /* oper can DIE */
+#define PRIV_GLINE 13 /* oper can GLINE */
+#define PRIV_LOCAL_GLINE 14 /* oper can local GLINE */
+#define PRIV_JUPE 15 /* oper can JUPE */
+#define PRIV_LOCAL_JUPE 16 /* oper can local JUPE */
+#define PRIV_OPMODE 17 /* oper can OP/CLEARMODE */
+#define PRIV_LOCAL_OPMODE 18 /* oper can local OP/CLEARMODE */
+#define PRIV_SET 19 /* oper can SET */
+#define PRIV_WHOX 20 /* oper can use /who x */
+#define PRIV_BADCHAN 21 /* oper can BADCHAN */
+#define PRIV_LOCAL_BADCHAN 22 /* oper can local BADCHAN */
+#define PRIV_SEE_CHAN 23 /* oper can see in secret chans */
+
+#define PRIV_PROPAGATE 24 /* propagate oper status */
+#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_NBITS (8 * sizeof(unsigned long))
+
+#define _PRIV_IDX(priv) ((priv) / _PRIV_NBITS)
+#define _PRIV_BIT(priv) (1 << ((priv) % _PRIV_NBITS))
+
+struct Privs {
+ unsigned long priv_mask[(PRIV_LAST_PRIV / _PRIV_NBITS) + 1];
+};
+
struct Connection {
/*
* The following fields are allocated only for local clients
* 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 */
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 */
struct in_addr cli_ip; /* Real ip# NOT defined for remote servers! */
short cli_status; /* Client type */
unsigned char cli_local; /* local or remote client */
+ 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 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)
#define cli_ip(cli) ((cli)->cli_ip)
#define cli_status(cli) ((cli)->cli_status)
#define cli_local(cli) ((cli)->cli_local)
+#define cli_privs(cli) ((cli)->cli_privs)
#define cli_name(cli) ((cli)->cli_name)
#define cli_username(cli) ((cli)->cli_username)
#define cli_info(cli) ((cli)->cli_info)
#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)
#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)
#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 */
#define SetOper(x) (cli_flags(x) |= FLAGS_OPER)
#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 ClearAccess(x) (cli_flags(x) &= ~FLAGS_CHKACCESS)
#define ClearBurst(x) (cli_flags(x) &= ~FLAGS_BURST)
#define ClearOper(x) (cli_flags(x) &= ~FLAGS_OPER)
#define ClearUPing(x) (cli_flags(x) &= ~FLAGS_UPING)
#define ClearWallops(x) (cli_flags(x) &= ~FLAGS_WALLOP)
+#define ClearServNotice(x) (cli_flags(x) &= ~FLAGS_SERVNOTICE)
+
+/* free flags */
+#define FREEFLAG_SOCKET 0x0001 /* socket needs to be freed */
+#define FREEFLAG_TIMER 0x0002 /* timer needs to be freed */
/* server notice stuff */
#define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP)
#define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
+#define PrivSet(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] |= \
+ _PRIV_BIT(priv))
+#define PrivClr(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] &= \
+ ~(_PRIV_BIT(priv)))
+#define PrivHas(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] & \
+ _PRIV_BIT(priv))
+
+#define GrantPriv(cli, priv) (PrivSet(&(cli_privs(cli)), priv))
+#define RevokePriv(cli, priv) (PrivClr(&(cli_privs(cli)), priv))
+#define HasPriv(cli, priv) (PrivHas(&(cli_privs(cli)), priv))
+
typedef enum ShowIPType {
HIDE_IP,
SHOW_IP,
extern const char* get_client_name(const struct Client* sptr, int showip);
extern int client_get_ping(const struct Client* local_client);
-
+extern void client_drop_sendq(struct Connection* con);
+extern void client_add_sendq(struct Connection* con,
+ struct Connection** con_p);
+extern void client_set_privs(struct Client* client);
+extern int client_report_privs(struct Client* to, struct Client* client);
#endif /* INCLUDED_client_h */