[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2004-11-24 16:01:53
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2004-11-24 16:00:55 UTC Modified files: include/IPcheck.h include/channel.h include/class.h include/client.h include/crule.h include/dbuf.h include/destruct_event.h include/fileio.h include/gline.h include/handlers.h include/hash.h include/ircd.h include/ircd_alloc.h include/ircd_chattr.h include/ircd_defs.h include/ircd_events.h include/ircd_features.h include/ircd_handler.h include/ircd_log.h include/ircd_osdep.h include/ircd_relay.h include/ircd_reply.h include/ircd_signal.h include/ircd_snprintf.h include/ircd_string.h include/ircd_tea.h include/jupe.h include/list.h include/listener.h include/match.h include/motd.h include/msg.h include/msgq.h include/numeric.h include/numnicks.h include/opercmds.h include/packet.h include/parse.h include/patchlevel.h include/querycmds.h include/random.h include/res.h include/s_auth.h include/s_bsd.h include/s_conf.h include/s_debug.h include/s_misc.h include/s_numeric.h include/s_serv.h include/s_stats.h include/s_user.h include/send.h include/struct.h include/supported.h include/uping.h include/userload.h include/whocmds.h include/whowas.h Added files: include/.cvsignore include/ircd_auth.h include/ircd_crypt.h include/ircd_crypt_native.h include/ircd_crypt_plain.h include/ircd_crypt_smd5.h include/ircd_reslib.h include/memdebug.h include/umkpasswd.h Removed files: include/fda.h include/iauth.h include/ircd_xopen.h include/support.h Log message: Author: zoltan <zo...@ir...> Log message: 2004-11-24 Toni García <zo...@ir...> 1.0.alpha13 * Comentarios para Doxygen * Excepciones de Silences * Soporte total de IPv6 * Sincronizacion Undernet ---------------------- diff included ---------------------- Index: ircd-ircdev/include/.cvsignore diff -u /dev/null ircd-ircdev/include/.cvsignore:1.1 --- /dev/null Wed Nov 24 08:00:55 2004 +++ ircd-ircdev/include/.cvsignore Wed Nov 24 08:00:42 2004 @@ -0,0 +1 @@ +patchlist.h Index: ircd-ircdev/include/IPcheck.h diff -u ircd-ircdev/include/IPcheck.h:1.2 ircd-ircdev/include/IPcheck.h:1.3 --- ircd-ircdev/include/IPcheck.h:1.2 Sun Feb 22 08:13:20 2004 +++ ircd-ircdev/include/IPcheck.h Wed Nov 24 08:00:43 2004 @@ -18,8 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: IPcheck.h,v 1.2 2004/02/22 16:13:20 zolty Exp $ - * + */ +/** @file + * @brief Interface to count users connected from particular IP addresses. + * @version $Id: IPcheck.h,v 1.3 2004/11/24 16:00:43 zolty Exp $ */ #ifndef INCLUDED_ipcheck_h #define INCLUDED_ipcheck_h @@ -28,19 +30,16 @@ #include <sys/types.h> /* time_t, size_t */ #define INCLUDED_sys_types_h #endif -#ifndef INCLUDED_netinet_in_h -#include <netinet/in.h> /* in_addr */ -#define INCLUDED_netinet_in_h -#endif struct Client; +struct irc_in_addr; /* * Prototypes */ extern void IPcheck_init(void); -extern int IPcheck_local_connect(struct in_addr ip, time_t* next_target_out); -extern void IPcheck_connect_fail(struct in_addr ip); +extern int IPcheck_local_connect(const struct irc_in_addr *ip, time_t *next_target_out); +extern void IPcheck_connect_fail(const struct irc_in_addr *ip); extern void IPcheck_connect_succeeded(struct Client *cptr); extern int IPcheck_remote_connect(struct Client *cptr, int is_burst); extern void IPcheck_disconnect(struct Client *cptr); Index: ircd-ircdev/include/channel.h diff -u ircd-ircdev/include/channel.h:1.5 ircd-ircdev/include/channel.h:1.6 --- ircd-ircdev/include/channel.h:1.5 Fri May 21 08:39:33 2004 +++ ircd-ircdev/include/channel.h Wed Nov 24 08:00:43 2004 @@ -19,8 +19,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: channel.h,v 1.5 2004/05/21 15:39:33 zolty Exp $ - * + */ +/** @file + * @brief Channel management and maintenance. + * @version $Id: channel.h,v 1.6 2004/11/24 16:00:43 zolty Exp $ */ #ifndef INCLUDED_channel_h #define INCLUDED_channel_h @@ -32,6 +34,9 @@ #include <sys/types.h> #define INCLUDED_sys_types_h #endif +#ifndef INCLUDED_res_h +#include "res.h" +#endif struct SLink; struct Client; @@ -40,17 +45,17 @@ * General defines */ -#define MAXMODEPARAMS 6 -#define MODEBUFLEN 200 +#define MAXMODEPARAMS 6 /**< Maximum number of mode parameters */ +#define MODEBUFLEN 200 /**< Maximum length of a mode */ -#define KEYLEN 23 +#define KEYLEN 23 /**< Maximum length of a key */ #if defined(UNDERNET) -#define PASSLEN 23 +#define PASSLEN 23 /**< Maximum length of a password */ #endif -#define CHANNELLEN 200 +#define CHANNELLEN 200 /**< Maximum length of a channel */ -#define MAXJOINARGS 15 /* number of slots for join buffer */ -#define STARTJOINLEN 10 /* fuzzy numbers */ +#define MAXJOINARGS 15 /**< number of slots for join buffer */ +#define STARTJOINLEN 10 /**< fuzzy numbers */ #define STARTCREATELEN 20 /* @@ -59,27 +64,32 @@ #define ChannelExists(n) (0 != FindChannel(n)) -#define CHFL_CHANOP 0x0001 /* Channel operator */ -#define CHFL_VOICE 0x0002 /* the power to speak */ -#define CHFL_DEOPPED 0x0004 /* Is de-opped by a server */ -#define CHFL_SERVOPOK 0x0008 /* Server op allowed */ -#define CHFL_ZOMBIE 0x0010 /* Kicked from channel */ -#define CHFL_BAN 0x0020 /* ban channel flag */ -#define CHFL_BAN_IPMASK 0x0040 /* ban mask is an IP-number mask */ -#define CHFL_BAN_OVERLAPPED 0x0080 /* ban overlapped, need bounce */ -#define CHFL_BURST_JOINED 0x0100 /* Just joined by net.junction */ -#define CHFL_BURST_BAN 0x0200 /* Ban part of last BURST */ -#define CHFL_BURST_BAN_WIPEOUT 0x0400 /* Ban will be wiped at end of BURST */ -#define CHFL_BANVALID 0x0800 /* CHFL_BANNED bit is valid */ -#define CHFL_BANNED 0x1000 /* Channel member is banned */ -#define CHFL_SILENCE_IPMASK 0x2000 /* silence mask is an IP-number mask */ +#define CHFL_CHANOP 0x0001 /**< Channel operator */ +#define CHFL_VOICE 0x0002 /**< the power to speak */ +#define CHFL_DEOPPED 0x0004 /**< Is de-opped by a server */ +#define CHFL_SERVOPOK 0x0008 /**< Server op allowed */ +#define CHFL_ZOMBIE 0x0010 /**< Kicked from channel */ +#define CHFL_BURST_JOINED 0x0100 /**< Just joined by net.junction */ +#define CHFL_BANVALID 0x0800 /**< CHFL_BANNED bit is valid */ +#define CHFL_BANNED 0x1000 /**< Channel member is banned */ +#define CHFL_SILENCE_IPMASK 0x2000 /**< silence mask is a CIDR */ #if defined(UNDERNET) -#define CHFL_BURST_ALREADY_OPPED 0x04000 /* In oob BURST, but was already joined and opped */ -#define CHFL_BURST_ALREADY_VOICED 0x08000 /* In oob BURST, but was already joined and voiced */ -#define CHFL_CHANNEL_MANAGER 0x10000 /* Set when creating channel or using Apass */ -#endif -#define CHFL_USER_PARTING 0x20000 /* User is already parting that channel */ -#define CHFL_DELAYED 0x40000 /* User's join message is delayed */ +#define CHFL_BURST_ALREADY_OPPED 0x04000 + /**< In oob BURST, but was already + * joined and opped + */ +#define CHFL_BURST_ALREADY_VOICED 0x08000 + /**, In oob BURST, but was already + * joined and voiced + */ +#define CHFL_CHANNEL_MANAGER 0x10000 /**< Set when creating channel or using + * Apass + */ +#endif +#define CHFL_USER_PARTING 0x20000 /**< User is already parting that + * channel + */ +#define CHFL_DELAYED 0x40000 /**< User's join message is delayed */ #define CHFL_OVERLAP (CHFL_CHANOP | CHFL_VOICE) #define CHFL_BANVALIDMASK (CHFL_BANVALID | CHFL_BANNED) @@ -87,54 +97,60 @@ /* Channel Visibility macros */ -#define MODE_CHANOP CHFL_CHANOP -#define MODE_VOICE CHFL_VOICE -#define MODE_PRIVATE 0x0004 -#define MODE_SECRET 0x0008 -#define MODE_MODERATED 0x0010 -#define MODE_TOPICLIMIT 0x0020 -#define MODE_INVITEONLY 0x0040 -#define MODE_NOPRIVMSGS 0x0080 -#define MODE_KEY 0x0100 -#define MODE_BAN 0x0200 -#define MODE_LIMIT 0x0400 -#define MODE_REGONLY 0x0800 /* Only +r users may join */ -#define MODE_DELJOINS 0x1000 /* New join messages are delayed */ -#define MODE_LISTED 0x10000 -#define MODE_SAVE 0x20000 /* save this mode-with-arg 'til later */ -#define MODE_FREE 0x40000 /* string needs to be passed to MyFree() */ -#define MODE_BURSTADDED 0x80000 /* channel was created by a BURST */ +#define MODE_CHANOP CHFL_CHANOP /**< +o Chanop */ +#define MODE_VOICE CHFL_VOICE /**< +v Voice */ +#define MODE_PRIVATE 0x0004 /**< +p Private */ +#define MODE_SECRET 0x0008 /**< +s Secret */ +#define MODE_MODERATED 0x0010 /**< +m Moderated */ +#define MODE_TOPICLIMIT 0x0020 /**< +t Topic Limited */ +#define MODE_INVITEONLY 0x0040 /**< +i Invite only */ +#define MODE_NOPRIVMSGS 0x0080 /**< +n No Private Messages */ +#define MODE_KEY 0x0100 /**< +k Keyed */ +#define MODE_BAN 0x0200 /**< +b Ban */ +#define MODE_LIMIT 0x0400 /**< +l Limit */ +#define MODE_REGONLY 0x0800 /**< Only +r users may join */ +#define MODE_DELJOINS 0x1000 /**< New join messages are delayed */ +#define MODE_SAVE 0x20000 /**< save this mode-with-arg 'til + * later */ +#define MODE_FREE 0x40000 /**< string needs to be passed to + * MyFree() */ +#define MODE_BURSTADDED 0x80000 /**< channel was created by a BURST */ #if defined(UNDERNET) #define MODE_UPASS 0x100000 #define MODE_APASS 0x200000 #endif -#define MODE_WASDELJOINS 0x400000 /* Not DELJOINS, but some joins pending */ -/* - * mode flags which take another parameter (With PARAmeterS) - */ +#define MODE_WASDELJOINS 0x400000 /**< Not DELJOINS, but some joins + * pending */ #if defined(UNDERNET) +/** mode flags which take another parameter (With PARAmeterS) + */ #define MODE_WPARAS (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT|MODE_APASS|MODE_UPASS) -#define infochanmodes feature_bool(FEAT_OPLEVELS) ? "AbiklmnopstuvrD" : "biklmnopstvrD" -#define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? "Abklouv" : "bklov" +/** Available Channel modes */ +#define infochanmodes feature_bool(FEAT_OPLEVELS) ? "AbiklmnopstUvrD" : "biklmnopstvrD" +/** Available Channel modes that take parameters */ +#define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? "AbkloUv" : "bklov" #else +/** mode flags which take another parameter (With PARAmeterS) + */ #define MODE_WPARAS (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT) +/** Available Channel modes */ #define infochanmodes "biklmnopstvrD" +/** Available Channel modes that take parameters */ #define infochanmodeswithparams "bklov" #endif #define HoldChannel(x) (!(x)) -/* name invisible */ +/** name invisible */ #define SecretChannel(x) ((x) && ((x)->mode.mode & MODE_SECRET)) -/* channel not shown but names are */ +/** channel not shown but names are */ #define HiddenChannel(x) ((x) && ((x)->mode.mode & MODE_PRIVATE)) -/* channel visible */ +/** channel visible */ #define ShowChannel(v,c) (PubChannel(c) || find_channel_member((v),(c)) || \ (IsAnOper(v) && HasPriv(v, PRIV_LIST_CHAN))) #define PubChannel(x) ((!x) || ((x)->mode.mode & \ (MODE_PRIVATE | MODE_SECRET)) == 0) -#define is_listed(x) ((x)->mode.mode & MODE_LISTED) #define IsGlobalChannel(name) (*(name) == '#') #define IsLocalChannel(name) (*(name) == '&') @@ -156,7 +172,7 @@ #define LISTARG_TOPICLIMITS 0x0001 #define LISTARG_SHOWSECRET 0x0002 -/* +/** * Maximum acceptable lag time in seconds: A channel younger than * this is not protected against hacking admins. * Mainly here to check if the TS clocks really sync (otherwise this @@ -169,14 +185,16 @@ */ #define TS_LAG_TIME 86400 -/* +/** * A Magic TS that is used for channels that are created by JOIN, * a channel with this TS accepts all TS without complaining that * it might receive later via MODE or CREATE. + * + * Part of the P9 compatibility, shouldn't occur on a P10 network. */ #define MAGIC_REMOTE_JOIN_TS 1270080000 -/* +/** * used in can_join to determine if an oper forced a join on a channel */ #define MAGIC_OPER_OVERRIDE 1000 @@ -192,16 +210,24 @@ * Structures */ +/** Information about a client on one channel + * + * This structure forms a sparse matrix with users down the side, and + * channels across the top. This matrix holds all the information about + * which users are on what channels, and what modes that user has on that + * channel (if they are op'd, voice'd and cached information if they are + * banned or not) + */ struct Membership { - struct Client* user; - struct Channel* channel; - struct Membership* next_member; - struct Membership* prev_member; - struct Membership* next_channel; - struct Membership* prev_channel; - unsigned int status; + struct Client* user; /**< The user */ + struct Channel* channel; /**< The channel */ + struct Membership* next_member; /**< The next user on this channel */ + struct Membership* prev_member; /**< The previous user on this channel*/ + struct Membership* next_channel; /**< Next channel this user is on */ + struct Membership* prev_channel; /**< Previous channel this user is on*/ + unsigned int status; /**< Flags for op'd, voice'd, etc */ #if defined(UNDERNET) - unsigned short oplevel; + unsigned short oplevel; /**< Op level */ #endif }; @@ -210,7 +236,7 @@ #define MAXOPLEVEL 999 #endif -#define IsZombie(x) ((x)->status & CHFL_ZOMBIE) +#define IsZombie(x) ((x)->status & CHFL_ZOMBIE) /**< see \ref zombie */ #define IsDeopped(x) ((x)->status & CHFL_DEOPPED) #define IsBanned(x) ((x)->status & CHFL_BANNED) #define IsBanValid(x) ((x)->status & CHFL_BANVALID) @@ -248,7 +274,7 @@ #define ClearBurstJoined(x) ((x)->status &= ~CHFL_BURST_JOINED) #define ClearDelayedJoin(x) ((x)->status &= ~CHFL_DELAYED) - +/** Mode information for a channel */ struct Mode { unsigned int mode; unsigned int limit; @@ -259,23 +285,49 @@ #endif }; +#define BAN_IPMASK 0x0001 /**< ban mask is an IP-number mask */ +#define BAN_OVERLAPPED 0x0002 /**< ban overlapped, need bounce */ +#define BAN_BURSTED 0x0004 /**< Ban part of last BURST */ +#define BAN_BURST_WIPEOUT 0x0008 /**< Ban will be wiped at EOB */ +#define BAN_EXCEPTION 0x0010 /**< Ban is an exception */ +#define BAN_DEL 0x4000 /**< Ban is being removed */ +#define BAN_ADD 0x8000 /**< Ban is being added */ + +/** A single ban for a channel. */ +struct Ban { + struct Ban* next; /**< next ban in the channel */ + struct irc_in_addr address; /**< addres for BAN_IPMASK bans */ + time_t when; /**< timestamp when ban was added */ + unsigned short flags; /**< modifier flags for the ban */ + unsigned char nu_len; /**< length of nick!user part of banstr */ + unsigned char addrbits; /**< netmask length for BAN_IPMASK bans */ + char *who; /**< name of client that set the ban */ + char *banstr; /**< hostmask that the ban matches */ +}; + +/** Information about a channel */ struct Channel { - struct Channel* next; - struct Channel* prev; - struct Channel* hnext; - struct DestructEvent* destruct_event; - time_t creationtime; - time_t topic_time; - unsigned int users; - struct Membership* members; - struct SLink* invites; - struct SLink* banlist; - struct Mode mode; - char topic[TOPICLEN + 1]; - char topic_nick[NICKLEN + 1]; - char chname[1]; + struct Channel* next; /**< next channel in the global channel list */ + struct Channel* prev; /**< previous channel */ + struct Channel* hnext; /**< Next channel in the hash table */ + struct DestructEvent* destruct_event; + time_t creationtime; /**< Creation time of this channel */ + time_t topic_time; /**< Modification time of the topic */ + unsigned int users; /**< Number of clients on this channel */ + struct Membership* members; /**< Pointer to the clients on this channel*/ + struct SLink* invites; /**< List of invites on this channel */ + struct Ban* banlist; /**< List of bans on this channel */ + struct Mode mode; /**< This channels mode */ + char topic[TOPICLEN + 1]; /**< Channels topic */ + char topic_nick[NICKLEN + 1]; /**< Nick of the person who set + * The topic + */ + char chname[1]; /**< Dynamically allocated string of the + * channel name + */ }; +/** Information about a /list in progress */ struct ListingArgs { time_t max_time; time_t min_time; @@ -284,63 +336,64 @@ unsigned int flags; time_t max_topic_time; time_t min_topic_time; - struct Channel *chptr; + unsigned int bucket; }; struct ModeBuf { - unsigned int mb_add; /* Modes to add */ - unsigned int mb_rem; /* Modes to remove */ - struct Client *mb_source; /* Source of MODE changes */ - struct Client *mb_connect; /* Connection of MODE changes */ - struct Channel *mb_channel; /* Channel they affect */ - unsigned int mb_dest; /* Destination of MODE changes */ - unsigned int mb_count; /* Number of modes w/args */ + unsigned int mb_add; /**< Modes to add */ + unsigned int mb_rem; /**< Modes to remove */ + struct Client *mb_source; /**< Source of MODE changes */ + struct Client *mb_connect; /**< Connection of MODE changes */ + struct Channel *mb_channel; /**< Channel they affect */ + unsigned int mb_dest; /**< Destination of MODE changes */ + unsigned int mb_count; /**< Number of modes w/args */ struct { - unsigned int mbm_type; /* Type of argument */ + unsigned int mbm_type; /**< Type of argument */ union { - unsigned int mbma_uint; /* A limit */ - char *mbma_string; /* A string */ - struct Client *mbma_client; /* A client */ - } mbm_arg; /* The mode argument */ + unsigned int mbma_uint; /**< A limit */ + char *mbma_string; /**< A string */ + struct Client *mbma_client; /**< A client */ + } mbm_arg; /**< The mode argument */ } mb_modeargs[MAXMODEPARAMS]; - /* A mode w/args */ + /**< A mode w/args */ }; -#define MODEBUF_DEST_CHANNEL 0x00001 /* Mode is flushed to channel */ -#define MODEBUF_DEST_SERVER 0x00002 /* Mode is flushed to server */ +#define MODEBUF_DEST_CHANNEL 0x00001 /**< Mode is flushed to channel */ +#define MODEBUF_DEST_SERVER 0x00002 /**< Mode is flushed to server */ -#define MODEBUF_DEST_OPMODE 0x00100 /* Send server mode as OPMODE */ -#define MODEBUF_DEST_DEOP 0x00200 /* Deop the offender */ -#define MODEBUF_DEST_BOUNCE 0x00400 /* Bounce the modes */ -#define MODEBUF_DEST_LOG 0x00800 /* Log the mode changes to OPATH */ - -#define MODEBUF_DEST_HACK2 0x02000 /* Send a HACK(2) notice, reverse */ -#define MODEBUF_DEST_HACK3 0x04000 /* Send a HACK(3) notice, TS == 0 */ -#define MODEBUF_DEST_HACK4 0x08000 /* Send a HACK(4) notice, TS == 0 */ +#define MODEBUF_DEST_OPMODE 0x00100 /**< Send server mode as OPMODE */ +#define MODEBUF_DEST_DEOP 0x00200 /**< Deop the offender */ +#define MODEBUF_DEST_BOUNCE 0x00400 /**< Bounce the modes */ +#define MODEBUF_DEST_LOG 0x00800 /**< Log the mode changes to OPATH */ + +#define MODEBUF_DEST_HACK2 0x02000 /**< Send a HACK(2) notice, reverse */ +#define MODEBUF_DEST_HACK3 0x04000 /**< Send a HACK(3) notice, TS == 0 */ +#define MODEBUF_DEST_HACK4 0x08000 /**< Send a HACK(4) notice, TS == 0 */ -#define MODEBUF_DEST_NOKEY 0x10000 /* Don't send the real key */ +#define MODEBUF_DEST_NOKEY 0x10000 /**< Don't send the real key */ #define MB_TYPE(mb, i) ((mb)->mb_modeargs[(i)].mbm_type) #define MB_UINT(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_uint) #define MB_STRING(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_string) #define MB_CLIENT(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_client) +/** A buffer represeting a list of joins to send */ struct JoinBuf { - struct Client *jb_source; /* Source of joins (ie, joiner) */ - struct Client *jb_connect; /* Connection of joiner */ - unsigned int jb_type; /* Type of join (JOIN or CREATE) */ - char *jb_comment; /* part comment */ - time_t jb_create; /* Creation timestamp */ - unsigned int jb_count; /* Number of channels */ - unsigned int jb_strlen; /* length so far */ + struct Client *jb_source; /**< Source of joins (ie, joiner) */ + struct Client *jb_connect; /**< Connection of joiner */ + unsigned int jb_type; /**< Type of join (JOIN or CREATE) */ + char *jb_comment; /**< part comment */ + time_t jb_create; /**< Creation timestamp */ + unsigned int jb_count; /**< Number of channels */ + unsigned int jb_strlen; /**< length so far */ struct Channel *jb_channels[MAXJOINARGS]; - /* channels joined or whatever */ + /**< channels joined or whatever */ }; -#define JOINBUF_TYPE_JOIN 0 /* send JOINs */ -#define JOINBUF_TYPE_CREATE 1 /* send CREATEs */ -#define JOINBUF_TYPE_PART 2 /* send PARTs */ -#define JOINBUF_TYPE_PARTALL 3 /* send local PARTs, but not remote */ +#define JOINBUF_TYPE_JOIN 0 /**< send JOINs */ +#define JOINBUF_TYPE_CREATE 1 /**< send CREATEs */ +#define JOINBUF_TYPE_PART 2 /**< send PARTs */ +#define JOINBUF_TYPE_PARTALL 3 /**< send local PARTs, but not remote */ extern struct Channel* GlobalChannelList; extern int LocalChanOperMode; @@ -350,7 +403,8 @@ */ extern void clean_channelname(char* name); extern void channel_modes(struct Client *cptr, char *mbuf, char *pbuf, - int buflen, struct Channel *chptr, struct Membership *member); + int buflen, struct Channel *chptr, + struct Membership *member); extern int set_mode(struct Client* cptr, struct Client* sptr, struct Channel* chptr, int parc, char* parv[], char* mbuf, char* pbuf, char* npbuf, int* badop); @@ -365,15 +419,6 @@ extern int can_join(struct Client *sptr, struct Channel *chptr, char *key); extern void add_user_to_channel(struct Channel* chptr, struct Client* who, unsigned int flags, int oplevel); -extern void cancel_mode(struct Client *sptr, struct Channel *chptr, char m, - const char *param, int *count); -extern void add_token_to_sendbuf(char *token, size_t *sblenp, int *firstp, - int *send_itp, char is_a_ban, int mode); -extern int add_banid(struct Client *cptr, struct Channel *chptr, char *banid, - int change, int firsttime); -extern struct SLink *next_removed_overlapped_ban(void); -extern void cancel_mode(struct Client *sptr, struct Channel *chptr, char m, - const char *param, int *count); extern void make_zombie(struct Membership* member, struct Client* who, struct Client* cptr, struct Client* sptr, struct Channel* chptr); @@ -382,7 +427,6 @@ int number_of_zombies(struct Channel *chptr); extern const char* find_no_nickchange_channel(struct Client* cptr); -extern struct Membership* IsMember(struct Client *cptr, struct Channel *chptr); extern struct Membership* find_channel_member(struct Client* cptr, struct Channel* chptr); extern int member_can_send_to_channel(struct Membership* member, int reveal); extern int client_can_send_to_channel(struct Client *cptr, struct Channel *chptr, int reveal); @@ -402,7 +446,6 @@ extern void send_channel_modes(struct Client *cptr, struct Channel *chptr); extern char *pretty_mask(char *mask); extern void del_invite(struct Client *cptr, struct Channel *chptr); -extern void list_next_channels(struct Client *cptr, int nr); extern void list_set_default(void); /* this belongs elsewhere! */ extern void RevealDelayedJoin(struct Membership *member); @@ -429,14 +472,14 @@ int parc, char *parv[], unsigned int flags, struct Membership* member); -#define MODE_PARSE_SET 0x01 /* actually set channel modes */ -#define MODE_PARSE_STRICT 0x02 /* +m +n +t style not supported */ -#define MODE_PARSE_FORCE 0x04 /* force the mode to be applied */ -#define MODE_PARSE_BOUNCE 0x08 /* we will be bouncing the modes */ -#define MODE_PARSE_NOTOPER 0x10 /* send "not chanop" to user */ -#define MODE_PARSE_NOTMEMBER 0x20 /* send "not member" to user */ -#define MODE_PARSE_WIPEOUT 0x40 /* wipe out +k and +l during burst */ -#define MODE_PARSE_BURST 0x80 /* be even more strict w/extra args */ +#define MODE_PARSE_SET 0x01 /**< actually set channel modes */ +#define MODE_PARSE_STRICT 0x02 /**< +m +n +t style not supported */ +#define MODE_PARSE_FORCE 0x04 /**< force the mode to be applied */ +#define MODE_PARSE_BOUNCE 0x08 /**< we will be bouncing the modes */ +#define MODE_PARSE_NOTOPER 0x10 /**< send "not chanop" to user */ +#define MODE_PARSE_NOTMEMBER 0x20 /**< send "not member" to user */ +#define MODE_PARSE_WIPEOUT 0x40 /**< wipe out +k and +l during burst */ +#define MODE_PARSE_BURST 0x80 /**< be even more strict w/extra args */ extern void joinbuf_init(struct JoinBuf *jbuf, struct Client *source, struct Client *connect, unsigned int type, @@ -444,5 +487,9 @@ extern void joinbuf_join(struct JoinBuf *jbuf, struct Channel *chan, unsigned int flags); extern int joinbuf_flush(struct JoinBuf *jbuf); +extern struct Ban *make_ban(const char *banstr); +extern struct Ban *find_ban(struct Client *cptr, struct Ban *banlist); +extern int apply_ban(struct Ban **banlist, struct Ban *newban); +extern void free_ban(struct Ban *ban); #endif /* INCLUDED_channel_h */ Index: ircd-ircdev/include/class.h diff -u ircd-ircdev/include/class.h:1.4 ircd-ircdev/include/class.h:1.5 --- ircd-ircdev/include/class.h:1.4 Fri May 21 08:39:34 2004 +++ ircd-ircdev/include/class.h Wed Nov 24 08:00:43 2004 @@ -19,8 +19,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: class.h,v 1.4 2004/05/21 15:39:34 zolty Exp $ - * + */ +/** @file + * @brief Declarations and interfaces for handling connection classes. + * @version $Id: class.h,v 1.5 2004/11/24 16:00:43 zolty Exp $ */ #ifndef INCLUDED_class_h #define INCLUDED_class_h @@ -37,37 +39,55 @@ /* * Structures */ +/** Represents a connection class. */ struct ConnectionClass { - struct ConnectionClass* next; - char *cc_name; - char *default_umode; - struct Privs privs; - struct Privs privs_dirty; - unsigned int max_sendq; - short ping_freq; - short conn_freq; - short max_links; - unsigned char valid; - int ref_count; + struct ConnectionClass* next; /**< Link to next connection class. */ + char *cc_name; /**< Name of connection class. */ + char *default_umode; /**< Default usermode for users + in this class. */ + struct Privs privs; /**< Privilege bits that are set on + or off. */ + struct Privs privs_dirty; /**< Indication of which bits in + ConnectionClass::privs are valid. */ + unsigned int max_sendq; /**< Maximum client SendQ in bytes. */ + unsigned int max_links; /**< Maximum connections allowed. */ + unsigned int ref_count; /**< Number of references to class. */ + unsigned short ping_freq; /**< Ping frequency for clients. */ + unsigned short conn_freq; /**< Auto-connect frequency. */ + unsigned char valid; /**< Valid flag (cleared after this + class is removed from the config).*/ }; /* * Macro's */ +/** Get class name for \a x. */ #define ConClass(x) ((x)->cc_name) +/** Get ping frequency for \a x. */ #define PingFreq(x) ((x)->ping_freq) +/** Get connection frequency for \a x. */ #define ConFreq(x) ((x)->conn_freq) +/** Get maximum links allowed for \a x. */ #define MaxLinks(x) ((x)->max_links) +/** Get maximum SendQ size for \a x. */ #define MaxSendq(x) ((x)->max_sendq) +/** Get number of references to \a x. */ #define Links(x) ((x)->ref_count) +/** Get class name for ConfItem \a x. */ #define ConfClass(x) ((x)->conn_class->cc_name) +/** Get ping frequency for ConfItem \a x. */ #define ConfPingFreq(x) ((x)->conn_class->ping_freq) +/** Get connection frequency for ConfItem \a x. */ #define ConfConFreq(x) ((x)->conn_class->conn_freq) +/** Get maximum links allowed for ConfItem \a x. */ #define ConfMaxLinks(x) ((x)->conn_class->max_links) +/** Get maximum SendQ size for ConfItem \a x. */ #define ConfSendq(x) ((x)->conn_class->max_sendq) +/** Get number of references to class in ConfItem \a x. */ #define ConfLinks(x) ((x)->conn_class->ref_count) +/** Get default usermode for ConfItem \a x. */ #define ConfUmode(x) ((x)->conn_class->default_umode) /* @@ -88,10 +108,10 @@ extern int get_conf_ping(const struct ConfItem *aconf); extern char *get_client_class(struct Client *acptr); extern void add_class(char *name, unsigned int ping, - unsigned int confreq, unsigned int maxli, unsigned int sendq); -extern void check_class(void); -extern void report_classes(struct Client *sptr, struct StatDesc *sd, int stat, - char *param); + unsigned int confreq, unsigned int maxli, + unsigned int sendq); +extern void report_classes(struct Client *sptr, const struct StatDesc *sd, + char *param); extern unsigned int get_sendq(struct Client* cptr); extern void class_send_meminfo(struct Client* cptr); Index: ircd-ircdev/include/client.h diff -u ircd-ircdev/include/client.h:1.6 ircd-ircdev/include/client.h:1.7 --- ircd-ircdev/include/client.h:1.6 Fri May 21 08:39:34 2004 +++ ircd-ircdev/include/client.h Wed Nov 24 08:00:43 2004 @@ -18,8 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: client.h,v 1.6 2004/05/21 15:39:34 zolty Exp $ - * + */ +/** @file + * @brief Structures and functions for handling local clients. + * @version $Id: client.h,v 1.7 2004/11/24 16:00:43 zolty Exp $ */ #ifndef INCLUDED_client_h #define INCLUDED_client_h @@ -39,14 +41,13 @@ #ifndef INCLUDED_ircd_handler_h #include "ircd_handler.h" #endif +#ifndef INCLUDED_res_h +#include "res.h" +#endif #ifndef INCLUDED_sys_types_h #include <sys/types.h> /* time_t, size_t */ #define INCLUDED_sys_types_h #endif -#ifndef INCLUDED_netinet_in_h -#include <netinet/in.h> /* in_addr */ -#define INCLUDED_netinet_in_h -#endif struct ConfItem; struct Listener; @@ -67,481 +68,662 @@ * source file, or in the source file itself (when only used in that file). */ +/** Single element in a flag bitset array. */ typedef unsigned long flagpage_t; +/** Number of bits in a flagpage_t. */ #define FLAGSET_NBITS (8 * sizeof(flagpage_t)) -#define FLAGSET_INDEX(flag) (flag / FLAGSET_NBITS) -#define FLAGSET_MASK(flag) (1<<(flag % FLAGSET_NBITS)) +/** Element number for flag \a flag. */ +#define FLAGSET_INDEX(flag) ((flag) / FLAGSET_NBITS) +/** Element bit for flag \a flag. */ +#define FLAGSET_MASK(flag) (1ul<<((flag) % FLAGSET_NBITS)) +/** Declare a flagset structure of a particular size. */ #define DECLARE_FLAGSET(name,max) \ struct name \ { \ unsigned long bits[((max + FLAGSET_NBITS - 1) / FLAGSET_NBITS)]; \ - }; + } -#define FLAGSET_ISSET(set,flag) ((set).bits[FLAGSET_INDEX(flag)] & FLAGSET_MASK(flag)) -#define FLAGSET_SET(set, flag) (set).bits[FLAGSET_INDEX(flag)] |= FLAGSET_MASK(flag) -#define FLAGSET_CLEAR(set, flag) (set).bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag) +/** Test whether a flag is set in a flagset. */ +#define FlagHas(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] & FLAGSET_MASK(flag)) +/** Set a flag in a flagset. */ +#define FlagSet(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] |= FLAGSET_MASK(flag)) +/** 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. */ #define infousermodes "dioswkgx" -enum Priv { - PRIV_CHAN_LIMIT, /* no channel limit on oper */ - PRIV_MODE_LCHAN, /* oper can mode local chans */ - PRIV_WALK_LCHAN, /* oper can walk thru local modes */ - PRIV_DEOP_LCHAN, /* no deop oper on local chans */ - PRIV_SHOW_INVIS, /* show local invisible users */ - PRIV_SHOW_ALL_INVIS, /* show all invisible users */ - PRIV_UNLIMIT_QUERY, /* unlimit who queries */ - - PRIV_KILL, /* oper can KILL */ - PRIV_LOCAL_KILL, /* oper can local KILL */ - PRIV_REHASH, /* oper can REHASH */ - PRIV_RESTART, /* oper can RESTART */ - PRIV_DIE, /* oper can DIE */ - PRIV_GLINE, /* oper can GLINE */ - PRIV_LOCAL_GLINE, /* oper can local GLINE */ - PRIV_JUPE, /* oper can JUPE */ - PRIV_LOCAL_JUPE, /* oper can local JUPE */ - PRIV_OPMODE, /* oper can OP/CLEARMODE */ - PRIV_LOCAL_OPMODE, /* oper can local OP/CLEARMODE */ - PRIV_SET, /* oper can SET */ - PRIV_WHOX, /* oper can use /who x */ - PRIV_BADCHAN, /* oper can BADCHAN */ - PRIV_LOCAL_BADCHAN, /* oper can local BADCHAN */ - PRIV_SEE_CHAN, /* oper can see in secret chans */ - PRIV_PROPAGATE, /* propagate oper status */ - PRIV_DISPLAY, /* "Is an oper" displayed */ - PRIV_SEE_OPERS, /* display hidden opers */ - PRIV_WIDE_GLINE, /* oper can set wider G-lines */ - 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_LAST_PRIV /* must be the same as the last priv */ -}; +/** Operator privileges. */ +enum Priv + { + PRIV_CHAN_LIMIT, /**< no channel limit on oper */ + PRIV_MODE_LCHAN, /**< oper can mode local chans */ + PRIV_WALK_LCHAN, /**< oper can walk through local modes */ + PRIV_DEOP_LCHAN, /**< no deop oper on local chans */ + PRIV_SHOW_INVIS, /**< show local invisible users */ + PRIV_SHOW_ALL_INVIS, /**< show all invisible users */ + PRIV_UNLIMIT_QUERY, /**< unlimit who queries */ + PRIV_KILL, /**< oper can KILL */ + PRIV_LOCAL_KILL, /**< oper can local KILL */ + PRIV_REHASH, /**< oper can REHASH */ + PRIV_RESTART, /**< oper can RESTART */ + PRIV_DIE, /**< oper can DIE */ + PRIV_GLINE, /**< oper can GLINE */ + PRIV_LOCAL_GLINE, /**< oper can local GLINE */ + PRIV_JUPE, /**< oper can JUPE */ + PRIV_LOCAL_JUPE, /**< oper can local JUPE */ + PRIV_OPMODE, /**< oper can OP/CLEARMODE */ + PRIV_LOCAL_OPMODE, /**< oper can local OP/CLEARMODE */ + PRIV_SET, /**< oper can SET */ + PRIV_WHOX, /**< oper can use /who x */ + PRIV_BADCHAN, /**< oper can BADCHAN */ + PRIV_LOCAL_BADCHAN, /**< oper can local BADCHAN */ + PRIV_SEE_CHAN, /**< oper can see in secret chans */ + PRIV_PROPAGATE, /**< propagate oper status */ + PRIV_DISPLAY, /**< "Is an oper" displayed */ + PRIV_SEE_OPERS, /**< display hidden opers */ + PRIV_WIDE_GLINE, /**< oper can set wider G-lines */ + 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_LAST_PRIV /**< number of privileges */ + }; -enum Flag { - FLAG_PINGSENT, /* Unreplied ping sent */ - FLAG_DEADSOCKET, /* Local socket is dead--Exiting soon */ - FLAG_KILLED, /* Prevents "QUIT" from being sent for this */ - FLAG_BLOCKED, /* socket is in a blocked condition */ - FLAG_CLOSING, /* set when closing to suppress errors */ - FLAG_UPING, /* has active UDP ping request */ - FLAG_CHKACCESS, /* ok to check clients access if set */ - FLAG_HUB, /* server is a hub */ - FLAG_SERVICE, /* server is a service */ - FLAG_LOCAL, /* set for local clients */ - FLAG_GOTID, /* successful ident lookup achieved */ - FLAG_DOID, /* I-lines say must use ident return */ - FLAG_NONL, /* No \n in buffer */ - FLAG_TS8, /* Why do you want to know? */ - FLAG_MAP, /* Show server on the map */ - FLAG_JUNCTION, /* Junction causing the net.burst */ - FLAG_BURST, /* Server is receiving a net.burst */ - FLAG_BURST_ACK, /* Server is waiting for eob ack */ - FLAG_IPCHECK, /* Added or updated IPregistry data */ - - FLAG_LOCOP, /* Local operator -- SRB */ - FLAG_SERVNOTICE, /* server notices such as kill */ - - FLAG_OPER, /* Operator */ - FLAG_INVISIBLE, /* makes user invisible */ - FLAG_WALLOP, /* send wallops to them */ - FLAG_DEAF, /* Makes user deaf */ - FLAG_CHSERV, /* Disallow KICK or MODE -o on the user; +/** Client flags and modes. + * Note that flags at least FLAG_LOCAL_UMODES but less than + * FLAG_GLOBAL_UMODES are treated as local modes, and flags at least + * FLAG_GLOBAL_UMODES (but less than FLAG_LAST_FLAG) are treated as + * global modes. + */ +enum Flag + { + FLAG_PINGSENT, /**< Unreplied ping sent */ + FLAG_DEADSOCKET, /**< Local socket is dead--Exiting soon */ + FLAG_KILLED, /**< Prevents "QUIT" from being sent for this */ + FLAG_BLOCKED, /**< socket is in a blocked condition */ + FLAG_CLOSING, /**< set when closing to suppress errors */ + FLAG_UPING, /**< has active UDP ping request */ + FLAG_HUB, /**< server is a hub */ + FLAG_SERVICE, /**< server is a service */ + FLAG_GOTID, /**< successful ident lookup achieved */ + FLAG_DOID, /**< I-lines say must use ident return */ + FLAG_NONL, /**< No \n in buffer */ + FLAG_TS8, /**< Why do you want to know? */ + FLAG_MAP, /**< Show server on the map */ + FLAG_JUNCTION, /**< Junction causing the net.burst. */ + FLAG_BURST, /**< Server is receiving a net.burst */ + FLAG_BURST_ACK, /**< Server is waiting for eob ack */ + FLAG_IPCHECK, /**< Added or updated IPregistry data */ + FLAG_IAUTHED, /**< Got IAUTH response for user */ + FLAG_LOCOP, /**< Local operator -- SRB */ + FLAG_SERVNOTICE, /**< server notices such as kill */ + FLAG_OPER, /**< Operator */ + FLAG_INVISIBLE, /**< makes user invisible */ + FLAG_WALLOP, /**< send wallops to them */ + FLAG_DEAF, /**< Makes user deaf */ + FLAG_CHSERV, /**< Disallow KICK or MODE -o on the user; don't display channels in /whois */ - FLAG_DEBUG, /* send global debug/anti-hack info */ + FLAG_DEBUG, /**< send global debug/anti-hack info */ #if defined(UNDERNET) - FLAG_ACCOUNT, /* account name has been set */ + FLAG_ACCOUNT, /**< account name has been set */ #endif - FLAG_HIDDENHOST, /* user's host is hidden */ - FLAG_LAST_FLAG, - FLAG_LOCAL_UMODES = FLAG_LOCOP, /* First local mode flag */ - FLAG_GLOBAL_UMODES = FLAG_OPER /* First global mode flag */ -}; - -DECLARE_FLAGSET(Privs, PRIV_LAST_PRIV) -DECLARE_FLAGSET(Flags, FLAG_LAST_FLAG) + FLAG_HIDDENHOST, /**< user's host is hidden */ + FLAG_LAST_FLAG, /**< number of flags */ + FLAG_LOCAL_UMODES = FLAG_LOCOP, /**< First local mode flag */ + FLAG_GLOBAL_UMODES = FLAG_OPER /**< First global mode flag */ + }; -struct Connection { - /* - * The following fields are allocated only for local clients - * (directly connected to *this* server with a socket. - * The first of them *MUST* be the "count"--it is the field - * 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 */ - time_t con_nexttarget;/* Next time a target change is allowed */ - unsigned int con_cookie; /* Random number the user must PONG */ - struct MsgQ con_sendQ; /* Outgoing message queue--if socket full */ - struct DBuf con_recvQ; /* Hold for data incoming yet to be parsed */ - unsigned int con_sendM; /* Statistics: protocol messages send */ - unsigned int con_sendK; /* Statistics: total k-bytes send */ - unsigned int con_receiveM;/* Statistics: protocol messages received */ - unsigned int con_receiveK; /* Statistics: total k-bytes received */ - unsigned short con_sendB; /* counters to count upto 1-k lots of bytes */ - unsigned short con_receiveB; /* sent and received. */ - struct Listener* con_listener; /* listening client which we accepted - from */ - struct SLink* con_confs; /* Configuration record associated */ - HandlerType con_handler; /* message index into command table - for parsing */ - struct hostent* con_dns_reply; /* DNS reply used during client - registration */ - struct ListingArgs* con_listing; - unsigned int con_max_sendq; /* cached max send queue for client */ - unsigned int con_ping_freq; /* cached ping freq from client conf - class */ - unsigned short con_lastsq; /* # 2k blocks when sendqueued called last */ - unsigned short con_port; /* and the remote port# too :-) */ - unsigned char con_targets[MAXTARGETS]; /* Hash values of current - targets */ - char con_sock_ip[SOCKIPLEN + 1]; /* this is the ip address as a string */ - char con_sockhost[HOSTLEN + 1]; /* This is the host name from the socket and - after which the connection was accepted. */ - 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 */ +/** Declare flagset type for operator privileges. */ +DECLARE_FLAGSET(Privs, PRIV_LAST_PRIV); +/** Declare flagset type for user flags. */ +DECLARE_FLAGSET(Flags, FLAG_LAST_FLAG); + +/** 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 Connection +{ + 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_freeflag; /**< indicates if connection can be freed */ + int con_error; /**< last socket level error for client */ + int con_sentalong; /**< sentalong marker for connection */ + unsigned int con_snomask; /**< mask for server messages */ + time_t con_nextnick; /**< Next time a nick change is allowed */ + time_t con_nexttarget;/**< Next time a target change is allowed */ + time_t con_lasttime; /**< Last time data read from socket */ + time_t con_since; /**< Last time we accepted a command */ + unsigned int con_cookie; /**< Random number the user must PONG */ + 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_receiveM; /**< Stats: protocol messages received */ + 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. */ + 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 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 + called last. */ + unsigned char con_targets[MAXTARGETS]; /**< Hash values of + current targets. */ + char con_sock_ip[SOCKIPLEN + 1]; /**< Remote IP address as a string. */ + char con_sockhost[HOSTLEN + 1]; /**< This is the host name from + the socket and after which the + connection was accepted. */ + char con_passwd[PASSWDLEN + 1]; /**< Password given by user. */ + char con_buffer[BUFSIZE]; /**< Incoming message buffer; or + the error that caused this + clients socket to close. */ + 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 */ + struct IAuthRequest* con_iauth; /**< iauth request for client */ }; +/** Magic constant to identify valid Connection structures. */ #define CONNECTION_MAGIC 0x12f955f3 +/** Represents a client anywhere on the network. */ 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 Connection* cli_connect; /* Connection structure associated with us */ - struct User* cli_user; /* ...defined, if this is a User */ - struct Server* cli_serv; /* ...defined, if this is a server */ - struct Whowas* cli_whowas; /* Pointer to ww struct to be freed on quit */ - char cli_yxx[4]; /* Numeric Nick: YMM if this is a server, - XX0 if this is a user */ - /* - * XXX - move these to local part for next release - * (lasttime, since) - */ - time_t cli_lasttime; /* last time data read from socket */ - time_t cli_since; /* last time we parsed something, flood control */ - - time_t cli_firsttime; /* time client was created */ - time_t cli_lastnick; /* TimeStamp on nick */ - int cli_marker; /* /who processing marker */ - struct Flags cli_flags; /* client flags */ - unsigned int cli_hopcount; /* number of servers to this 0 = local */ - 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 */ + 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 Connection* cli_connect; /**< Connection structure associated with us */ + struct User* cli_user; /**< Defined if this client is a user */ + struct Server* cli_serv; /**< Defined if this client is a server */ + struct Whowas* cli_whowas; /**< Pointer to ww struct to be freed on quit */ + char cli_yxx[4]; /**< Numeric Nick: YY if this is a + server, XXX if this is a user */ + time_t cli_firsttime; /**< time client was created */ + time_t cli_lastnick; /**< TimeStamp on nick */ + int cli_marker; /**< /who processing marker */ + struct Flags cli_flags; /**< client flags */ + 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 */ }; +/** 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) -#define cli_from(cli) ((cli)->cli_connect->con_client) +/** 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) -#define cli_lasttime(cli) ((cli)->cli_lasttime) -#define cli_since(cli) ((cli)->cli_since) +/** 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) -#define cli_local(cli) ((cli)->cli_local) +/** 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) +/** 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) -#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_nexttarget(cli) ((cli)->cli_connect->con_nexttarget) -#define cli_cookie(cli) ((cli)->cli_connect->con_cookie) -#define cli_sendQ(cli) ((cli)->cli_connect->con_sendQ) -#define cli_recvQ(cli) ((cli)->cli_connect->con_recvQ) -#define cli_sendM(cli) ((cli)->cli_connect->con_sendM) -#define cli_sendK(cli) ((cli)->cli_connect->con_sendK) -#define cli_receiveM(cli) ((cli)->cli_connect->con_receiveM) -#define cli_receiveK(cli) ((cli)->cli_connect->con_receiveK) -#define cli_sendB(cli) ((cli)->cli_connect->con_sendB) -#define cli_receiveB(cli) ((cli)->cli_connect->con_receiveB) -#define cli_listener(cli) ((cli)->cli_connect->con_listener) -#define cli_confs(cli) ((cli)->cli_connect->con_confs) -#define cli_handler(cli) ((cli)->cli_connect->con_handler) -#define cli_dns_reply(cli) ((cli)->cli_connect->con_dns_reply) -#define cli_listing(cli) ((cli)->cli_connect->con_listing) -#define cli_max_sendq(cli) ((cli)->cli_connect->con_max_sendq) -#define cli_ping_freq(cli) ((cli)->cli_connect->con_ping_freq) -#define cli_lastsq(cli) ((cli)->cli_connect->con_lastsq) -#define cli_port(cli) ((cli)->cli_connect->con_port) -#define cli_targets(cli) ((cli)->cli_connect->con_targets) -#define cli_sock_ip(cli) ((cli)->cli_connect->con_sock_ip) -#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) +/** 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 required PING/PONG cookie for client. */ +#define cli_cookie(cli) con_cookie(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 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. */ +#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 iauth request for client. */ +#define cli_iauth(cli) con_iauth(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) -#define con_fd(con) ((con)->con_fd) +/** 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 co... [truncated message content] |