Adaugă codul complet al proiectului underchat-ircd

This commit is contained in:
mihaiitdata committed 2026-02-13 00:04:12 +02:00
1 parent caba5224bf
commit 5fdc1cc27c
462 files changed
+164488

No files matched your search

+1
View File
@@ -0,0 +1 @@
patchlist.h
+27
View File
@@ -0,0 +1,27 @@
/** @file IPcheck.h
* @brief Interface to count users connected from particular IP addresses.
* @version $Id: IPcheck.h 1329 2005-03-19 23:22:09Z entrope $
*/
#ifndef INCLUDED_ipcheck_h
#define INCLUDED_ipcheck_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* time_t, size_t */
#define INCLUDED_sys_types_h
#endif
struct Client;
struct irc_in_addr;
/*
* Prototypes
*/
extern void IPcheck_init(void);
extern int IPcheck_local_connect(const struct irc_in_addr *ip, time_t *next_target_out);
extern void IPcheck_connect_fail(const struct Client *cptr, int disconnect);
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);
extern unsigned short IPcheck_nr(struct Client* cptr);
#endif /* INCLUDED_ipcheck_h */
+64
View File
@@ -0,0 +1,64 @@
#ifndef INCLUDED_capab_h
#define INCLUDED_capab_h
/*
* IRC - Internet Relay Chat, include/capab.h
* Copyright (C) 2004 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface and public definitions for capabilities extension
* @version $Id: capab.h 1349 2005-04-05 01:46:05Z entrope $
*/
#ifndef INCLUDED_client_h
#include "client.h"
#endif
#define CAPFL_HIDDEN 0x0001 /**< Do not advertize this capability */
#define CAPFL_PROHIBIT 0x0002 /**< Client may not set this capability */
#define CAPFL_PROTO 0x0004 /**< Cap must be acknowledged by client */
#define CAPFL_STICKY 0x0008 /**< Cap may not be cleared once set */
#define CAPLIST \
_CAP(USERPFX, 0, "undernet.org/userpfx")
/** Client capabilities */
enum Capab {
#define _CAP(cap, flags, name, feat) CAP_ ## cap
_CAP(NONE, CAPFL_HIDDEN|CAPFL_PROHIBIT, "none", 0),
_CAP(NAMESX, 0, "multi-prefix", 0),
_CAP(UHNAMES, 0, "userhost-in-names", 0),
_CAP(EXTJOIN, 0, "extended-join", 0),
_CAP(AWAYNOTIFY, 0, "away-notify", 0),
_CAP(ACCNOTIFY, 0, "account-notify", 0),
_CAP(SASL, 0, "sasl", 0),
#ifdef USE_SSL
_CAP(TLS, 0, "tls", 0),
#endif
/* CAPLIST, */
#undef _CAP
_CAP_LAST_CAP
};
DECLARE_FLAGSET(CapSet, _CAP_LAST_CAP);
#define CapHas(cs, cap) FlagHas(cs, cap)
#define CapSet(cs, cap) FlagSet(cs, cap)
#define CapClr(cs, cap) FlagClr(cs, cap)
extern void client_check_caps(struct Client *client, struct Client *replyto);
#endif /* INCLUDED_capab_h */
+572
View File
@@ -0,0 +1,572 @@
/*
* IRC - Internet Relay Chat, ircd/channel.h
* Copyright (C) 1990 Jarkko Oikarinen
* Copyright (C) 1996 - 1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Channel management and maintenance.
* @version $Id: channel.h 1913 2009-07-04 22:46:00Z entrope $
*/
#ifndef INCLUDED_channel_h
#define INCLUDED_channel_h
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h" /* NICKLEN */
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
struct SLink;
struct Client;
/*
* General defines
*/
#define MAXMODEPARAMS 6 /**< Maximum number of mode parameters */
#define MODEBUFLEN 200 /**< Maximum length of a mode */
#define KEYLEN 23 /**< Maximum length of a key */
#define CHANNELLEN 200 /**< Maximum length of a channel */
#define MAXJOINARGS 15 /**< number of slots for join buffer */
#define STARTJOINLEN 10 /**< fuzzy numbers */
#define STARTCREATELEN 20
/*
* Macro's
*/
#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_BURST_JOINED 0x0100 /**< Just joined by net.junction */
#define CHFL_BANNED 0x1000 /**< Channel member is banned */
#define CHFL_SILENCE_IPMASK 0x2000 /**< silence mask is a CIDR */
#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
*/
#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_HALFOPPED 0x400000
/**< In oob BURST, but was already
* joined and halfopped
*/
#define CHFL_HALFOP 0x800000 /**< Channel half operator */
#define CHFL_OVERLAP (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE)
#define CHFL_VOICED_OR_OPPED (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE)
#define MBFL_BANVALID 0x0001 /**< MBFL_BANNED bit is valid */
#define MBFL_BANNED 0x0002 /**< Channel member is banned */
#define MBFL_BANVALID_QUIET 0x0004 /**< MBFL_BANNED_QUIET bit is valid */
#define MBFL_BANNED_QUIET 0x0008 /**< Channel member is banned from speaking */
#define MBFL_BANVALID_NICK 0x0010 /**< MBFL_BANNED_NICK bit is valid */
#define MBFL_BANNED_NICK 0x0020 /**< Channel member is banned from changing nick */
#define MBFL_EXCEPTVALID 0x0040 /**< MBFL_EXCEPTED is valid */
#define MBFL_EXCEPTED 0x0080 /**< Channel member is ban excepted */
#define MBFL_EXCEPTVALID_QUIET 0x0100 /**< MBFL_EXCEPTED_QUIET is valid */
#define MBFL_EXCEPTED_QUIET 0x0200 /**< Channel member is ban excepted */
#define MBFL_EXCEPTVALID_NICK 0x0400 /**< MBFL_EXCEPTED_NICK is valid */
#define MBFL_EXCEPTED_NICK 0x0800 /**< Channel member is ban excepted */
/* Channel Visibility macros */
#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_REGISTERED 0x2000 /**< Channel marked as registered
* (for future semantic expansion) */
#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_UPASS 0x100000
#define MODE_APASS 0x200000
#define MODE_WASDELJOINS 0x400000 /**< Not DELJOINS, but some joins
* pending */
#define MODE_HALFOP CHFL_HALFOP /**< +h Halfop */
#define MODE_EXCEPT 0x1000000 /**< +e Ban exception */
#define MODE_REDIRECT 0x2000000 /**< +L Channel redirect */
#define EXMODE_ADMINONLY 0x00000001 /**< +a User mode +a only may join */
#define EXMODE_OPERONLY 0x00000002 /**< +O User mode +o only may join */
#define EXMODE_REGMODERATED 0x00000004 /**< +M Like +m but allows registered users too */
#define EXMODE_NONOTICES 0x00000008 /**< +N No notices allowed to the channel */
#define EXMODE_PERSIST 0x00000010 /**< +z Channel remains even if empty */
#define EXMODE_SSLONLY 0x00000020 /**< +Z Only SSL users (user mode +z) may join */
#define EXMODE_NOQUITPARTS 0x00000040 /**< +Q Strip QUIT/PART messages */
#define EXMODE_NOCTCPS 0x00000080 /**< +C Block CTCP messages */
#define EXMODE_NOMULTITARG 0x00000100 /**< +T Block messages with a list of targets */
#define EXMODE_NOCOLOR 0x00000200 /**< +c Block messages containing color */
#define EXMODE_STRIPCOLOR 0x00000400 /**< +S Strip color from messages */
/** mode flags which take another parameter (With PARAmeterS)
*/
#define MODE_WPARAS (MODE_CHANOP|MODE_HALFOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT|MODE_APASS|MODE_UPASS)
/** Available Channel modes */
#define infochanmodes feature_bool(FEAT_OPLEVELS) ? "AabCcDdhikLlMmNnOopQRrSsTtUvZz" : "abCcDdhikLlMmNnOopQRrSsTtvZz"
/** Available Channel modes that take parameters */
#define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? \
(feature_bool(FEAT_HALFOPS) ? "AbhkLloUv" : "AbkLloUv") : \
(feature_bool(FEAT_HALFOPS) ? "bhkLlov" : "bkLlov")
#define HoldChannel(x) (!(x))
/** name invisible */
#define SecretChannel(x) ((x) && ((x)->mode.mode & MODE_SECRET))
/** channel not shown but names are */
#define HiddenChannel(x) ((x) && ((x)->mode.mode & MODE_PRIVATE))
/** channel visible */
#define ShowChannel(v,c) (PubChannel(c) || find_channel_member((v),(c)))
#define PubChannel(x) ((!x) || ((x)->mode.mode & \
(MODE_PRIVATE | MODE_SECRET)) == 0)
#define IsGlobalChannel(name) (*(name) == '#')
#define IsLocalChannel(name) (*(name) == '&')
#define IsChannelName(name) (IsGlobalChannel(name) || IsLocalChannel(name))
typedef enum ChannelGetType {
CGT_NO_CREATE,
CGT_CREATE
} ChannelGetType;
/* used in SetMode() in channel.c and m_umode() in s_msg.c */
#define MODE_NULL 0
#define MODE_ADD 0x40000000
#define MODE_DEL 0x20000000
/* used in ListingArgs.flags */
#define LISTARG_TOPICLIMITS 0x0001
#define LISTARG_SHOWSECRET 0x0002
#define LISTARG_NEGATEWILDCARD 0x0004
#define LISTARG_SHOWMODES 0x0008
/**
* 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
* will start causing HACK notices.
* This value must be the same on all servers.
*
* This value has been increased to 1 day in order to distinguish this
* "normal" type of HACK wallops / desyncs, from possiblity still
* existing bugs.
*/
#define TS_LAG_TIME 86400
extern const char* const PartFmt1;
extern const char* const PartFmt2;
extern const char* const PartFmt1serv;
extern const char* const PartFmt2serv;
/*
* 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; /**< 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 */
unsigned int banflags; /**< Ban cache flags */
unsigned short oplevel; /**< Op level */
};
#define MAXOPLEVELDIGITS 3
#define MAXOPLEVEL 999
#define IsZombie(x) ((x)->status & CHFL_ZOMBIE) /**< see \ref zombie */
#define IsDeopped(x) ((x)->status & CHFL_DEOPPED)
#define IsBanned(x) ((x)->banflags & MBFL_BANNED)
#define IsBanValid(x) ((x)->banflags & MBFL_BANVALID)
#define IsBannedQuiet(x) ((x)->banflags & MBFL_BANNED_QUIET)
#define IsBanValidQuiet(x) ((x)->banflags & MBFL_BANVALID_QUIET)
#define IsBannedNick(x) ((x)->banflags & MBFL_BANNED_NICK)
#define IsBanValidNick(x) ((x)->banflags & MBFL_BANVALID_NICK)
#define IsChanOp(x) ((x)->status & CHFL_CHANOP)
#define IsHalfOp(x) ((x)->status & CHFL_HALFOP)
#define ExtBanTypes(x) ((x)->extbantype)
#define OpLevel(x) ((x)->oplevel)
#define HasVoice(x) ((x)->status & CHFL_VOICE)
#define IsServOpOk(x) ((x)->status & CHFL_SERVOPOK)
#define IsBurstJoined(x) ((x)->status & CHFL_BURST_JOINED)
#define IsVoicedOrOpped(x) ((x)->status & CHFL_VOICED_OR_OPPED)
#define IsChannelManager(x) ((x)->status & CHFL_CHANNEL_MANAGER)
#define IsUserParting(x) ((x)->status & CHFL_USER_PARTING)
#define IsDelayedJoin(x) ((x)->status & CHFL_DELAYED)
#define IsExcepted(x) ((x)->banflags & MBFL_EXCEPTED)
#define IsExceptValid(x) ((x)->banflags & MBFL_EXCEPTVALID)
#define IsExceptedQuiet(x) ((x)->banflags & MBFL_EXCEPTED_QUIET)
#define IsExceptValidQuiet(x) ((x)->banflags & MBFL_EXCEPTVALID_QUIET)
#define IsExceptedNick(x) ((x)->banflags & MBFL_EXCEPTED_NICK)
#define IsExceptValidNick(x) ((x)->banflags & MBFL_EXCEPTVALID_NICK)
#define SetBanned(x) ((x)->banflags |= MBFL_BANNED)
#define SetBanValid(x) ((x)->banflags |= MBFL_BANVALID)
#define SetBannedQuiet(x) ((x)->banflags |= MBFL_BANNED_QUIET)
#define SetBanValidQuiet(x) ((x)->banflags |= MBFL_BANVALID_QUIET)
#define SetBannedNick(x) ((x)->banflags |= MBFL_BANNED_NICK)
#define SetBanValidNick(x) ((x)->banflags |= MBFL_BANVALID_NICK)
#define SetDeopped(x) ((x)->status |= CHFL_DEOPPED)
#define SetServOpOk(x) ((x)->status |= CHFL_SERVOPOK)
#define SetBurstJoined(x) ((x)->status |= CHFL_BURST_JOINED)
#define SetZombie(x) ((x)->status |= CHFL_ZOMBIE)
#define SetChannelManager(x) ((x)->status |= CHFL_CHANNEL_MANAGER)
#define SetOpLevel(x, v) (void)((x)->oplevel = (v))
#define SetUserParting(x) ((x)->status |= CHFL_USER_PARTING)
#define SetDelayedJoin(x) ((x)->status |= CHFL_DELAYED)
#define SetExcepted(x) ((x)->banflags |= MBFL_EXCEPTED)
#define SetExceptValid(x) ((x)->banflags |= MBFL_EXCEPTVALID)
#define SetExceptedQuiet(x) ((x)->banflags |= MBFL_EXCEPTED_QUIET)
#define SetExceptValidQuiet(x) ((x)->banflags |= MBFL_EXCEPTVALID_QUIET)
#define SetExceptedNick(x) ((x)->banflags |= MBFL_EXCEPTED_NICK)
#define SetExceptValidNick(x) ((x)->banflags |= MBFL_EXCEPTVALID_NICK)
#define ClearBanned(x) ((x)->banflags &= ~MBFL_BANNED)
#define ClearBanValid(x) ((x)->banflags &= ~MBFL_BANVALID)
#define ClearBannedQuiet(x) ((x)->banflags &= ~MBFL_BANNED_QUIET)
#define ClearBanValidQuiet(x) ((x)->banflags &= ~MBFL_BANVALID_QUIET)
#define ClearBannedNick(x) ((x)->banflags &= ~MBFL_BANNED_NICK)
#define ClearBanValidNick(x)((x)->banflags &= ~MBFL_BANVALID_NICK)
#define ClearDeopped(x) ((x)->status &= ~CHFL_DEOPPED)
#define ClearServOpOk(x) ((x)->status &= ~CHFL_SERVOPOK)
#define ClearBurstJoined(x) ((x)->status &= ~CHFL_BURST_JOINED)
#define ClearDelayedJoin(x) ((x)->status &= ~CHFL_DELAYED)
#define ClearExcepted(x) ((x)->banflags &= ~MBFL_EXCEPTED)
#define ClearExceptValid(x) ((x)->banflags &= ~MBFL_EXCEPTVALID)
#define ClearExceptedQuiet(x) ((x)->banflags &= ~MBFL_EXCEPTED_QUIET)
#define ClearExceptValidQuiet(x) ((x)->banflags &= ~MBFL_EXCEPTVALID_QUIET)
#define ClearExceptedNick(x) ((x)->banflags &= ~MBFL_EXCEPTED_NICK)
#define ClearExceptValidNick(x) ((x)->banflags &= ~MBFL_EXCEPTVALID_NICK)
/** Mode information for a channel */
struct Mode {
unsigned int mode;
unsigned int exmode;
unsigned int limit;
char key[KEYLEN + 1];
char upass[KEYLEN + 1];
char apass[KEYLEN + 1];
char redir[CHANNELLEN + 1];
};
#define EBAN_NONE 0x00000000 /* Passed to find_ban() when no extended ban type is specified. */
#define EBAN_EXCEPTLIST 0x10000000 /* Only ever passed to find_ban() so wont conflic with EBAN_NOCHILD. */
#define EBAN_NOCHILD 0x10000000 /* Extended Ban cannot have a nested extended ban. */
#define EBAN_NEGATEMASK 0x20000000 /* Mask is negated (extended ban applies to users who do not match). */
#define EBAN_QUIET 0x00000001 /* Extended Ban quiets matching users. */
#define EBAN_NICK 0x00000002 /* Extended Ban stops matching users changing nick. */
#define EBAN_JOIN 0x00000010 /* Extended Ban checks the specified channels ban list. */
#define EBAN_ACCOUNT 0x00000020 /* Extended Ban matches against a users account names. */
#define EBAN_CHANNEL 0x00000040 /* Extended Ban matches against channels the user is a member of. */
#define EBAN_REALNAME 0x00000080 /* Extended Ban matches against a users real name. */
#define EBAN_MARK 0x00000100 /* Extended Ban matches marks on all users. */
#define EBAN_MARKUA 0x00000200 /* Extended Ban matches marks on unauthenticated users. */
#define EBAN_TYPES 0x000003FF /* Mask of all extended ban types. */
#define EBAN_CRITERIA 0xF0000000 /* Mask of all extended ban criteria. */
#define EBAN_MASKTYPE 0x000003F0 /* Mask of all mask types. */
#define EBAN_ACTIVITY 0x0000000F /* Mask of all extended bans that block a specific activity. */
struct ExtBanInfo {
char banchar;
int flags;
int feat;
};
struct ExtBan {
int flags; /**< Flags describing this extended ban. */
unsigned int prefixlen; /**< Length of the extended ban prefix. */
unsigned int nu_len; /**< length of nick!user part of mask. */
char delimiter; /**< Character used as the delimiter. */
char mask[NICKLEN+USERLEN+HOSTLEN+3]; /**< Mask to match the client against. */
};
#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_EXTENDED 0x0020 /**< Ban is an Extended Ban */
#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; /**< address for BAN_IPMASK bans */
struct ExtBan extban; /**< extended ban info */
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[NICKLEN+1]; /**< name of client that set the ban */
char banstr[NICKLEN+USERLEN+HOSTLEN+3]; /**< hostmask that the ban matches */
};
/** Information about a channel */
struct Channel {
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 */
unsigned int nonsslusers; /**< Number of clients without user mode +z */
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 Ban* exceptlist; /**< List of excepts on this channel */
struct Mode mode; /**< This channels mode */
char topic[TOPICLEN + 1]; /**< Channels topic */
char topic_nick[NICKLEN + USERLEN + HOSTLEN + 3]; /**< 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;
unsigned int max_users;
unsigned int min_users;
unsigned int flags;
time_t max_topic_time;
time_t min_topic_time;
unsigned int bucket;
char wildcard[CHANNELLEN + 1];
};
struct ModeBuf {
unsigned int mb_add; /**< Modes to add */
unsigned int mb_exadd; /**< Extended modes to add */
unsigned int mb_rem; /**< Modes to remove */
unsigned int mb_exrem; /**< Extended 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 */
union {
unsigned int mbma_uint; /**< A limit */
char *mbma_string; /**< A string */
struct Client *mbma_client; /**< A client */
} mbm_arg; /**< The mode argument */
unsigned short mbm_oplevel; /**< Oplevel for a bounce */
} mb_modeargs[MAXMODEPARAMS];
/**< 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_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 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)
#define MB_OPLEVEL(mb, i) ((mb)->mb_modeargs[(i)].mbm_oplevel)
/** 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 Channel *jb_channels[MAXJOINARGS];
/**< 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 */
extern struct Channel* GlobalChannelList;
extern int LocalChanOperMode;
/*
* Proto types
*/
extern void channel_modes(struct Client *cptr, char *mbuf, char *pbuf,
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);
extern void send_hack_notice(struct Client *cptr, struct Client *sptr,
int parc, char *parv[], int badop, int mtype);
extern struct Channel *get_channel(struct Client *cptr,
char *chname, ChannelGetType flag);
extern struct Membership* find_member_link(struct Channel * chptr,
const struct Client* cptr);
extern int sub1_from_channel(struct Channel* chptr);
extern int destruct_channel(struct Channel* chptr);
extern void add_user_to_channel(struct Channel* chptr, struct Client* who,
unsigned int flags, int oplevel);
extern void make_zombie(struct Membership* member, struct Client* who,
struct Client* cptr, struct Client* sptr,
struct Channel* chptr);
extern struct Client* find_chasing(struct Client* sptr, const char* user, int* chasing);
void add_invite(struct Client *cptr, struct Channel *chptr);
int number_of_zombies(struct Channel *chptr);
extern const char* find_no_nickchange_channel(struct Client* cptr);
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);
extern void remove_user_from_channel(struct Client *sptr, struct Channel *chptr);
extern void remove_user_from_all_channels(struct Client* cptr);
extern int is_chan_op(struct Client *cptr, struct Channel *chptr);
extern int is_zombie(struct Client *cptr, struct Channel *chptr);
extern int is_half_op(struct Client *cptr, struct Channel *chptr);
extern int has_voice(struct Client *cptr, struct Channel *chptr);
/*
NOTE: pointer is compared, and not dereferenced, called by
add_target with a void*, since targets could be anything,
this function can't make any assumptions that it has a channel
*/
extern int IsInvited(struct Client* cptr, const void* chptr);
extern void send_channel_modes(struct Client *cptr, struct Channel *chptr);
extern char *pretty_mask(char *mask);
extern char *pretty_extmask(char *mask);
extern void del_invite(struct Client *cptr, struct Channel *chptr);
extern void list_set_default(void); /* this belongs elsewhere! */
extern void RevealDelayedJoinIfNeeded(struct Client *sptr, struct Channel *chptr);
extern void RevealDelayedJoin(struct Membership *member);
extern void CheckDelayedJoins(struct Channel *chan);
extern void modebuf_init(struct ModeBuf *mbuf, struct Client *source,
struct Client *connect, struct Channel *chan,
unsigned int dest);
extern void modebuf_mode(struct ModeBuf *mbuf, unsigned int mode);
extern void modebuf_mode_uint(struct ModeBuf *mbuf, unsigned int mode,
unsigned int uint);
extern void modebuf_mode_string(struct ModeBuf *mbuf, unsigned int mode,
char *string, int free);
extern void modebuf_mode_client(struct ModeBuf *mbuf, unsigned int mode,
struct Client *client, int oplevel);
extern int modebuf_flush(struct ModeBuf *mbuf);
extern void modebuf_extract(struct ModeBuf *mbuf, char *buf, int oplevels);
extern void mode_ban_invalidate(struct Channel *chan);
extern void mode_except_invalidate(struct Channel *chan);
extern void mode_invite_clear(struct Channel *chan);
extern int mode_parse(struct ModeBuf *mbuf, struct Client *cptr,
struct Client *sptr, struct Channel *chptr,
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_ISHALFOP 0x100 /**< op and halfop differentiation */
extern void joinbuf_init(struct JoinBuf *jbuf, struct Client *source,
struct Client *connect, unsigned int type,
char *comment, time_t create);
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, int extbantype, int level);
extern int apply_ban(struct Ban **banlist, struct Ban *newban, int free);
extern int apply_except(struct Ban **banlist, struct Ban *newban, int do_free);
extern void free_ban(struct Ban *ban);
extern int SetAutoChanModes(struct Channel *chptr);
extern int common_chan_count(struct Client *a, struct Client *b, int max);
#endif /* INCLUDED_channel_h */
+156
View File
@@ -0,0 +1,156 @@
/*
* IRC - Internet Relay Chat, include/class.h
* Copyright (C) 1990 Darren Reed
* Copyright (C) 1996 - 1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Declarations and interfaces for handling connection classes.
* @version $Id: class.h 1511 2005-10-05 01:53:30Z entrope $
*/
#ifndef INCLUDED_class_h
#define INCLUDED_class_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#include "client.h"
struct ConfItem;
struct StatDesc;
/* Class restriction FlagSet */
enum ClassRestrictFlag {
CRFLAG_JOIN, /**< User cannot join channerls. */
CRFLAG_PRIVMSG, /**< User cannot send PRIVMSG/NOTICE to users not on common channels. */
CRFLAG_UMODE, /**< User cannot change his/her own user modes. */
CRFLAG_LAST_FLAG
};
/** Declare flagset type for Class restriction flags. */
DECLARE_FLAGSET(ClassRestrictFlags, CRFLAG_LAST_FLAG);
/*
* Structures
*/
/** Represents a connection class. */
struct ConnectionClass {
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. */
char *autojoinchan; /**< Auto join channel list. */
char *autojoinnotice; /**< Auto join notice. */
unsigned int snomask; /**< Default server notice mask. */
struct Privs privs; /**< Privilege bits that are set on
or off. */
struct Privs privs_dirty; /**< Indication of which bits in
ConnectionClass::privs are valid. */
struct ClassRestrictFlags restrictflags; /**< Class restrictions applied to users. */
unsigned int max_sendq; /**< Maximum client SendQ in bytes. */
unsigned int max_recvq; /**< Maximum client RecvQ in bytes. */
unsigned int max_links; /**< Maximum connections allowed. */
unsigned int max_chans; /**< Maximum channels allowed to join. */
unsigned int ref_count; /**< Number of references to class. */
signed int lag_min; /**< Minimum number of seconds for fake lag. */
signed int lag_factor; /**< Factor by which the message length is divided to add to fake lag. */
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 maximum RecvQ size for \a x. */
#define MaxRecvq(x) ((x)->max_recvq)
/** Get maximum channel limit for \a x. */
#define MaxChans(x) ((x)->max_chans)
/** Get number of references to \a x. */
#define Links(x) ((x)->ref_count)
/** Get fake lag minimum for \a x. */
#define LagMin(x) ((x)->lag_min)
/** Get fake lag factor for \a x. */
#define LagFactor(x) ((x)->lag_factor)
/** 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 maximum RecvQ size for ConfItem \a x. */
#define ConfRecvq(x) ((x)->conn_class->max_recvq)
/** 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)
/** Get default snomask for ConfItem \a x. */
#define ConfSnoMask(x) ((x)->conn_class->snomask)
/** Get autojoin channel list for ConfItem \a x. */
#define ConfAjoinChan(x) ((x)->conn_class->autojoinchan)
/** Get autojoin channel notice for ConfItem \a x. */
#define ConfAjoinNotice(x) ((x)->conn_class->autojoinnotice)
/** Find a valid configuration class by name. */
#define find_class(name) do_find_class((name), 0)
/*
* Proto types
*/
extern void init_class(void);
extern const struct ConnectionClass* get_class_list(void);
extern void class_mark_delete(void);
extern void class_delete_marked(void);
extern struct ConnectionClass *do_find_class(const char *name, int extras);
extern struct ConnectionClass *make_class(void);
extern void free_class(struct ConnectionClass * tmp);
extern char *get_conf_class(const struct ConfItem *aconf);
extern int get_conf_ping(const struct ConfItem *aconf);
extern char *get_client_class(struct Client *acptr);
extern struct ConnectionClass *get_client_class_conf(struct Client *acptr);
extern void add_class(char *name, unsigned int ping,
unsigned int confreq, unsigned int maxli,
unsigned int sendq, unsigned int recvq);
extern void report_classes(struct Client *sptr, const struct StatDesc *sd,
char *param);
extern unsigned int get_sendq(struct Client* cptr);
extern unsigned int get_recvq(struct Client *cptr);
extern int get_lag_min(struct Client *cptr);
extern int get_lag_factor(struct Client *cptr);
extern unsigned int get_client_maxchans(struct Client *acptr);
extern void class_send_meminfo(struct Client* cptr);
#endif /* INCLUDED_class_h */
+1128
View File
File diff suppressed because it is too large. Load diff
+21
View File
@@ -0,0 +1,21 @@
/** @file crule.h
* @brief Interfaces and declarations for connection rule checking.
* @version $Id: crule.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_crule_h
#define INCLUDED_crule_h
/*
* Proto types
*/
/*
* opaque node pointer
*/
struct CRuleNode;
extern void crule_free(struct CRuleNode** elem);
extern int crule_eval(struct CRuleNode* rule);
extern struct CRuleNode* crule_parse(const char* rule);
#endif /* INCLUDED_crule_h */
+62
View File
@@ -0,0 +1,62 @@
/*
* IRC - Internet Relay Chat, include/dbuf.h
* Copyright (C) 1990 Markku Savela
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interfaces and declarations for dealing with data buffers.
* @version $Id: dbuf.h 1216 2004-10-05 00:51:56Z entrope $
*/
#ifndef INCLUDED_dbuf_h
#define INCLUDED_dbuf_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* size_t */
#define INCLUDED_sys_types_h
#endif
/*
* These two globals should be considered read only
*/
extern int DBufAllocCount;
extern int DBufUsedCount;
struct DBufBuffer;
/** Queue of data chunks. */
struct DBuf {
unsigned int length; /**< Current number of bytes stored */
struct DBufBuffer *head; /**< First data buffer, if length > 0 */
struct DBufBuffer *tail; /**< Last data buffer, if length > 0 */
};
/** Return number of bytes in a DBuf. */
#define DBufLength(dyn) ((dyn)->length)
/** Release the entire content of a DBuf. */
#define DBufClear(dyn) dbuf_delete((dyn), DBufLength(dyn))
/*
* Prototypes
*/
extern void dbuf_delete(struct DBuf *dyn, unsigned int length);
extern int dbuf_put(struct DBuf *dyn, const char *buf, unsigned int length);
extern const char *dbuf_map(const struct DBuf *dyn, unsigned int *length);
extern unsigned int dbuf_get(struct DBuf *dyn, char *buf, unsigned int length);
extern unsigned int dbuf_getmsg(struct DBuf *dyn, char *buf, unsigned int length);
extern void dbuf_count_memory(size_t *allocated, size_t *used);
#endif /* INCLUDED_dbuf_h */
+49
View File
@@ -0,0 +1,49 @@
#ifndef INCLUDED_destruct_event_h
#define INCLUDED_destruct_event_h
/*
* IRC - Internet Relay Chat, include/destruct_event.h
* Copyright (C) 2002 Carlo Wood <carlo@alinoe.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Functions for handling timed channel destruction events.
* @version $Id: destruct_event.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_config_h
#include "config.h"
#endif
#ifndef INCLUDED_channel_h
#include "channel.h"
#endif
#ifndef INCLUDED_ircd_events_h
#include "ircd_events.h"
#endif
/** Structure describing a destruction event. */
struct DestructEvent {
struct DestructEvent* next_event; /**< Next event in the queue. */
struct DestructEvent* prev_event; /**< Previous event in the queue. */
time_t expires; /**< When the destruction should happen. */
struct Channel* chptr; /**< Channel to destroy. */
};
extern void schedule_destruct_event_1m(struct Channel* chptr);
extern void schedule_destruct_event_48h(struct Channel* chptr);
extern void remove_destruct_event(struct Channel* chptr);
extern void exec_expired_destruct_events(struct Event* ev);
#endif /* INCLUDED_destruct_event_h */
+56
View File
@@ -0,0 +1,56 @@
/** @file fileio.h
* @brief ANSI FILE* clone API declarations.
* @version $Id: fileio.h 1219 2004-10-05 01:45:24Z entrope $
*/
#ifndef INCLUDED_fileio_h
#define INCLUDED_fileio_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* size_t */
#define INCLUDED_sys_types_h
#endif
struct stat;
/** A mirror of the ANSI FILE struct, but it works for any
* file descriptor. FileBufs are allocated when a file is opened with
* fbopen, and they are freed when the file is closed using fbclose.
* (Some OSes limit the range of file descriptors in a FILE*, for
* example to fit in "char".)
*/
typedef struct FileBuf FBFILE;
/*
* open a file and return a FBFILE*, see fopen(3)
*/
extern FBFILE *fbopen(const char *filename, const char *mode);
/*
* associate a file descriptor with a FBFILE*
* if a FBFILE* is associated here it MUST be closed using fbclose
* see fdopen(3)
*/
extern FBFILE *fdbopen(int fd, const char *mode);
/*
* close a file opened with fbopen, see fclose(3)
*/
extern void fbclose(FBFILE * fb);
/*
* return the next character from the file, EOF on end of file
* see fgetc(3)
*/
extern int fbgetc(FBFILE * fb);
/*
* return next string in a file up to and including the newline character
* see fgets(3)
*/
extern char *fbgets(char *buf, size_t len, FBFILE * fb);
/*
* write a null terminated string to a file, see fputs(3)
*/
extern int fbputs(const char *str, FBFILE * fb);
/*
* return the status of the file associated with fb, see fstat(3)
*/
extern int fbstat(struct stat *sb, FBFILE * fb);
#endif /* INCLUDED_fileio_h */
+151
View File
@@ -0,0 +1,151 @@
#ifndef INCLUDED_gline_h
#define INCLUDED_gline_h
/*
* IRC - Internet Relay Chat, include/gline.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 1996 -1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Structures and APIs for G-line manipulation.
* @version $Id: gline.h 1913 2009-07-04 22:46:00Z entrope $
*/
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
struct Client;
struct StatDesc;
#define GLINE_MAX_EXPIRE 604800 /**< max expire: 7 days */
/** Local state of a G-line. */
enum GlineLocalState {
GLOCAL_GLOBAL, /**< G-line state unmodified locally. */
GLOCAL_ACTIVATED, /**< G-line state locally activated. */
GLOCAL_DEACTIVATED /**< G-line state locally deactivated. */
};
/** Description of a G-line. */
struct Gline {
struct Gline *gl_next; /**< Next G-line in linked list. */
struct Gline**gl_prev_p; /**< Previous pointer to this G-line. */
char *gl_user; /**< Username mask (or channel/realname mask). */
char *gl_host; /**< Host portion of mask. */
char *gl_reason; /**< Reason for G-line. */
time_t gl_expire; /**< Expiration timestamp. */
time_t gl_lastmod; /**< Last modification timestamp. */
time_t gl_lifetime; /**< Record expiration timestamp. */
struct irc_in_addr gl_addr; /**< IP address (for IP-based G-lines). */
unsigned char gl_bits; /**< Bits in gl_addr used in the mask. */
unsigned int gl_flags; /**< G-line status flags. */
enum GlineLocalState gl_state;/**< G-line local state. */
};
/** Action to perform on a G-line. */
enum GlineAction {
GLINE_ACTIVATE, /**< G-line should be activated. */
GLINE_DEACTIVATE, /**< G-line should be deactivated. */
GLINE_LOCAL_ACTIVATE, /**< G-line should be locally activated. */
GLINE_LOCAL_DEACTIVATE, /**< G-line should be locally deactivated. */
GLINE_MODIFY /**< G-line should be modified. */
};
#define GLINE_ACTIVE 0x00001 /**< G-line is active. */
#define GLINE_IPMASK 0x00002 /**< gl_addr and gl_bits fields are valid. */
#define GLINE_BADCHAN 0x00004 /**< G-line prohibits users from joining a channel. */
#define GLINE_LOCAL 0x00008 /**< G-line only applies to this server. */
#define GLINE_ANY 0x00010 /**< Search flag: Find any G-line. */
#define GLINE_FORCE 0x00020 /**< Override normal limits on G-lines. */
#define GLINE_EXACT 0x00040 /**< Exact match only (no wildcards). */
#define GLINE_LDEACT 0x00080 /**< Locally deactivated. */
#define GLINE_GLOBAL 0x00100 /**< Find only global G-lines. */
#define GLINE_LASTMOD 0x00200 /**< Find only G-lines with non-zero lastmod. */
#define GLINE_OPERFORCE 0x00400 /**< Oper forcing G-line to be set. */
#define GLINE_REALNAME 0x00800 /**< G-line matches only the realname field. */
#define GLINE_VERSION 0x10000 /**< G-line matches only the CTCP version. */
#define GLINE_EXPIRE 0x01000 /**< Expiration time update */
#define GLINE_LIFETIME 0x02000 /**< Record lifetime update */
#define GLINE_REASON 0x04000 /**< Reason update */
/** Controllable flags that can be set on an actual G-line. */
#define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME | GLINE_VERSION)
/** Mask for G-line activity flags. */
#define GLINE_ACTMASK (GLINE_ACTIVE | GLINE_LDEACT)
/** Mask for G-line update flags. */
#define GLINE_UPDATE (GLINE_EXPIRE | GLINE_LIFETIME | GLINE_REASON)
/** Test whether \a g is active. */
#define GlineIsActive(g) ((((g)->gl_flags & GLINE_ACTIVE) && \
(g)->gl_state != GLOCAL_DEACTIVATED) || \
(g)->gl_state == GLOCAL_ACTIVATED)
/** Test whether \a g is remotely (globally) active. */
#define GlineIsRemActive(g) ((g)->gl_flags & GLINE_ACTIVE)
/** Test whether \a g is an IP-based G-line. */
#define GlineIsIpMask(g) ((g)->gl_flags & GLINE_IPMASK)
/** Test whether \a g is a realname-based G-line. */
#define GlineIsRealName(g) ((g)->gl_flags & GLINE_REALNAME)
/** Test whether \a g is a CTCP version-based G-line. */
#define GlineIsVersion(g) ((g)->gl_flags & GLINE_VERSION)
/** Test whether \a g is a BADCHAN. */
#define GlineIsBadChan(g) ((g)->gl_flags & GLINE_BADCHAN)
/** Test whether \a g is local to this server. */
#define GlineIsLocal(g) ((g)->gl_flags & GLINE_LOCAL)
/** Return user mask of a G-line. */
#define GlineUser(g) ((g)->gl_user)
/** Return host mask of a G-line. */
#define GlineHost(g) ((g)->gl_host)
/** Return reason/message of a G-line. */
#define GlineReason(g) ((g)->gl_reason)
/** Return last modification time of a G-line. */
#define GlineLastMod(g) ((g)->gl_lastmod)
extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags);
extern int gline_activate(struct Client *cptr, struct Client *sptr,
struct Gline *gline, time_t lastmod,
unsigned int flags);
extern int gline_deactivate(struct Client *cptr, struct Client *sptr,
struct Gline *gline, time_t lastmod,
unsigned int flags);
extern int gline_modify(struct Client *cptr, struct Client *sptr,
struct Gline *gline, enum GlineAction action,
char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags);
extern int gline_destroy(struct Client *cptr, struct Client *sptr,
struct Gline *gline);
extern struct Gline *gline_find(char *userhost, unsigned int flags);
extern struct Gline *gline_lookup(struct Client *cptr, unsigned int flags);
extern void gline_free(struct Gline *gline);
extern void gline_burst(struct Client *cptr);
extern int gline_resend(struct Client *cptr, struct Gline *gline);
extern int gline_list(struct Client *sptr, char *userhost);
extern void gline_stats(struct Client *sptr, const struct StatDesc *sd,
char *param);
extern int gline_memory_count(size_t *gl_size);
extern int gline_remove(struct Client* sptr, char *userhost, char *reason);
#endif /* INCLUDED_gline_h */
+276
View File
@@ -0,0 +1,276 @@
/*
* IRC - Internet Relay Chat, include/handlers.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Declarations for all protocol message handler functions.
* @version $Id: handlers.h 1925 2010-01-02 20:33:10Z klmitch $
*/
#ifndef INCLUDED_handlers_h
#define INCLUDED_handlers_h
/** @page m_functions Protocol Message Handlers
*
* m_functions execute protocol messages on this server:
* int m_func(struct Client* cptr, struct Client* sptr, int parc, char* parv[]);
*
* cptr is always NON-NULL, pointing to a *LOCAL* client
* structure (with an open socket connected!). This
* identifies the physical socket where the message
* originated (or which caused the m_function to be
* executed--some m_functions may call others...).
*
* sptr is the source of the message, defined by the
* prefix part of the message if present. If not
* or prefix not found, then sptr==cptr.
*
* (!IsServer(cptr)) => (cptr == sptr), because
* prefixes are taken *only* from servers...
*
* (IsServer(cptr))
* (sptr == cptr) => the message didn't
* have the prefix.
*
* (sptr != cptr && IsServer(sptr) means
* the prefix specified servername. (?)
*
* (sptr != cptr && !IsServer(sptr) means
* that message originated from a remote
* user (not local).
*
*
* combining
*
* (!IsServer(sptr)) means that, sptr can safely
* taken as defining the target structure of the
* message in this server.
*
* *Always* true (if 'parse' and others are working correct):
*
* 1) sptr->from == cptr (note: cptr->from == cptr)
*
* 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
* *cannot* be a local connection, unless it's
* actually cptr!). [MyConnect(x) should probably
* be defined as (x == x->from) --msa ]
*
* parc number of variable parameter strings (if zero,
* parv is allowed to be NULL)
*
* parv a NULL terminated list of parameter pointers,
*
* parv[0], sender (prefix string), if not present
* this points to an empty string.
* parv[1]...parv[parc-1]
* pointers to additional parameters
* parv[parc] == NULL, *always*
*
* note: it is guaranteed that parv[0]..parv[parc-1] are all
* non-NULL pointers.
*/
struct Client;
extern int m_admin(struct Client*, struct Client*, int, char*[]);
extern int m_authenticate(struct Client*, struct Client*, int, char*[]);
extern int m_away(struct Client*, struct Client*, int, char*[]);
extern int m_cap(struct Client*, struct Client*, int, char*[]);
extern int m_cnotice(struct Client*, struct Client*, int, char*[]);
extern int m_cprivmsg(struct Client*, struct Client*, int, char*[]);
extern int m_fingerprint(struct Client*, struct Client*, int, char*[]);
extern int m_gline(struct Client*, struct Client*, int, char*[]);
extern int m_help(struct Client*, struct Client*, int, char*[]);
extern int m_ignore(struct Client*, struct Client*, int, char*[]);
extern int m_info(struct Client*, struct Client*, int, char*[]);
extern int m_invite(struct Client*, struct Client*, int, char*[]);
extern int m_ircops(struct Client*, struct Client*, int, char*[]);
extern int m_isnef(struct Client*, struct Client*, int, char*[]);
extern int m_ison(struct Client*, struct Client*, int, char*[]);
extern int m_join(struct Client*, struct Client*, int, char*[]);
extern int m_jupe(struct Client*, struct Client*, int, char*[]);
extern int m_kick(struct Client*, struct Client*, int, char*[]);
extern int m_links(struct Client*, struct Client*, int, char*[]);
extern int m_links_redirect(struct Client*, struct Client*, int, char*[]);
extern int m_list(struct Client*, struct Client*, int, char*[]);
extern int m_lusers(struct Client*, struct Client*, int, char*[]);
extern int m_map(struct Client*, struct Client*, int, char*[]);
extern int m_map_redirect(struct Client*, struct Client*, int, char*[]);
extern int m_mkpasswd(struct Client*, struct Client*, int, char*[]);
extern int m_mode(struct Client*, struct Client*, int, char*[]);
extern int m_motd(struct Client*, struct Client*, int, char*[]);
extern int m_names(struct Client*, struct Client*, int, char*[]);
extern int m_nick(struct Client*, struct Client*, int, char*[]);
extern int m_not_oper(struct Client*, struct Client*, int, char*[]);
extern int m_notice(struct Client*, struct Client*, int, char*[]);
extern int mr_notice(struct Client*, struct Client*, int, char*[]);
extern int m_oper(struct Client*, struct Client*, int, char*[]);
extern int m_opermotd(struct Client*, struct Client*, int, char*[]);
extern int m_part(struct Client*, struct Client*, int, char*[]);
extern int mr_pass(struct Client*, struct Client*, int, char*[]);
extern int m_ping(struct Client*, struct Client*, int, char*[]);
extern int m_pong(struct Client*, struct Client*, int, char*[]);
extern int m_private(struct Client*, struct Client*, int, char*[]);
extern int m_privmsg(struct Client*, struct Client*, int, char*[]);
extern int m_proto(struct Client*, struct Client*, int, char*[]);
extern int m_protoctl(struct Client*, struct Client*, int, char*[]);
extern int m_pseudo(struct Client*, struct Client*, int, char*[]);
extern int m_quit(struct Client*, struct Client*, int, char*[]);
extern int m_registered(struct Client*, struct Client*, int, char*[]);
extern int m_rules(struct Client*, struct Client*, int, char*[]);
extern int m_sethost(struct Client*, struct Client*, int, char*[]);
extern int m_shun(struct Client*, struct Client*, int, char*[]);
extern int m_silence(struct Client*, struct Client*, int, char*[]);
extern int m_starttls(struct Client*, struct Client*, int, char*[]);
extern int m_stats(struct Client*, struct Client*, int, char*[]);
extern int m_time(struct Client*, struct Client*, int, char*[]);
extern int m_topic(struct Client*, struct Client*, int, char*[]);
extern int m_trace(struct Client*, struct Client*, int, char*[]);
extern int m_unregistered(struct Client*, struct Client*, int, char*[]);
extern int m_unsupported(struct Client*, struct Client*, int, char*[]);
extern int m_user(struct Client*, struct Client*, int, char*[]);
extern int m_userhost(struct Client*, struct Client*, int, char*[]);
extern int m_userip(struct Client*, struct Client*, int, char*[]);
extern int m_version(struct Client*, struct Client*, int, char*[]);
extern int m_wallchops(struct Client*, struct Client*, int, char*[]);
extern int m_wallhops(struct Client*, struct Client*, int, char*[]);
extern int m_wallvoices(struct Client*, struct Client*, int, char*[]);
extern int m_watch(struct Client*, struct Client*, int, char*[]);
extern int m_webirc(struct Client*, struct Client*, int, char*[]);
extern int m_who(struct Client*, struct Client*, int, char*[]);
extern int m_whois(struct Client*, struct Client*, int, char*[]);
extern int m_whowas(struct Client*, struct Client*, int, char*[]);
extern int m_zline(struct Client*, struct Client*, int, char*[]);
extern int mo_admin(struct Client*, struct Client*, int, char*[]);
extern int mo_asll(struct Client*, struct Client*, int, char*[]);
extern int mo_check(struct Client*, struct Client*, int, char*[]);
extern int mo_clearmode(struct Client*, struct Client*, int, char*[]);
extern int mo_close(struct Client*, struct Client*, int, char*[]);
extern int mo_connect(struct Client*, struct Client*, int, char*[]);
extern int mo_die(struct Client*, struct Client*, int, char*[]);
extern int mo_get(struct Client*, struct Client*, int, char*[]);
extern int mo_gline(struct Client*, struct Client*, int, char*[]);
extern int mo_info(struct Client*, struct Client*, int, char*[]);
extern int mo_jupe(struct Client*, struct Client*, int, char*[]);
extern int mo_kill(struct Client*, struct Client*, int, char*[]);
extern int mo_notice(struct Client*, struct Client*, int, char*[]);
extern int mo_oper(struct Client*, struct Client*, int, char*[]);
extern int mo_opmode(struct Client*, struct Client*, int, char*[]);
extern int mo_ping(struct Client*, struct Client*, int, char*[]);
extern int mo_privmsg(struct Client*, struct Client*, int, char*[]);
extern int mo_privs(struct Client*, struct Client*, int, char*[]);
extern int mo_rehash(struct Client*, struct Client*, int, char*[]);
extern int mo_remove(struct Client*, struct Client*, int, char*[]);
extern int mo_reset(struct Client*, struct Client*, int, char*[]);
extern int mo_restart(struct Client*, struct Client*, int, char*[]);
extern int mo_rping(struct Client*, struct Client*, int, char*[]);
extern int mo_set(struct Client*, struct Client*, int, char*[]);
extern int mo_sethost(struct Client*, struct Client*, int, char*[]);
extern int mo_settime(struct Client*, struct Client*, int, char*[]);
extern int mo_shun(struct Client*, struct Client*, int, char*[]);
extern int mo_squit(struct Client*, struct Client*, int, char*[]);
extern int mo_stats(struct Client*, struct Client*, int, char*[]);
extern int mo_tempshun(struct Client*, struct Client*, int, char*[]);
extern int mo_trace(struct Client*, struct Client*, int, char*[]);
extern int mo_uping(struct Client*, struct Client*, int, char*[]);
extern int mo_version(struct Client*, struct Client*, int, char*[]);
extern int mo_wallops(struct Client*, struct Client*, int, char*[]);
extern int mo_wallusers(struct Client*, struct Client*, int, char*[]);
extern int mo_xquery(struct Client*, struct Client*, int, char*[]);
extern int mo_zline(struct Client*, struct Client*, int, char*[]);
extern int mr_error(struct Client*, struct Client*, int, char*[]);
extern int mr_error(struct Client*, struct Client*, int, char*[]);
extern int mr_pong(struct Client*, struct Client*, int, char*[]);
extern int mr_server(struct Client*, struct Client*, int, char*[]);
extern int ms_account(struct Client*, struct Client*, int, char*[]);
extern int ms_admin(struct Client*, struct Client*, int, char*[]);
extern int ms_asll(struct Client*, struct Client*, int, char*[]);
extern int ms_away(struct Client*, struct Client*, int, char*[]);
extern int ms_burst(struct Client*, struct Client*, int, char*[]);
extern int ms_clearmode(struct Client*, struct Client*, int, char*[]);
extern int ms_connect(struct Client*, struct Client*, int, char*[]);
extern int ms_create(struct Client*, struct Client*, int, char*[]);
extern int ms_destruct(struct Client*, struct Client*, int, char*[]);
extern int ms_desynch(struct Client*, struct Client*, int, char*[]);
extern int ms_end_of_burst(struct Client*, struct Client*, int, char*[]);
extern int ms_end_of_burst_ack(struct Client*, struct Client*, int, char*[]);
extern int ms_error(struct Client*, struct Client*, int, char*[]);
extern int ms_fake(struct Client*, struct Client*, int, char*[]);
extern int ms_gline(struct Client*, struct Client*, int, char*[]);
extern int ms_info(struct Client*, struct Client*, int, char*[]);
extern int ms_invite(struct Client*, struct Client*, int, char*[]);
extern int ms_join(struct Client*, struct Client*, int, char*[]);
extern int ms_jupe(struct Client*, struct Client*, int, char*[]);
extern int ms_kick(struct Client*, struct Client*, int, char*[]);
extern int ms_kill(struct Client*, struct Client*, int, char*[]);
extern int ms_links(struct Client*, struct Client*, int, char*[]);
extern int ms_lusers(struct Client*, struct Client*, int, char*[]);
extern int ms_mark(struct Client*, struct Client*, int, char*[]);
extern int ms_mode(struct Client*, struct Client*, int, char*[]);
extern int ms_motd(struct Client*, struct Client*, int, char*[]);
extern int ms_names(struct Client*, struct Client*, int, char*[]);
extern int ms_nick(struct Client*, struct Client*, int, char*[]);
extern int ms_notice(struct Client*, struct Client*, int, char*[]);
extern int ms_oper(struct Client*, struct Client*, int, char*[]);
extern int ms_opermotd(struct Client*, struct Client*, int, char*[]);
extern int ms_opmode(struct Client*, struct Client*, int, char*[]);
extern int ms_part(struct Client*, struct Client*, int, char*[]);
extern int ms_ping(struct Client*, struct Client*, int, char*[]);
extern int ms_pong(struct Client*, struct Client*, int, char*[]);
extern int ms_privmsg(struct Client*, struct Client*, int, char*[]);
extern int ms_privs(struct Client*, struct Client*, int, char*[]);
extern int ms_quit(struct Client*, struct Client*, int, char*[]);
extern int ms_rehash(struct Client*, struct Client*, int, char*[]);
extern int ms_remove(struct Client*, struct Client*, int, char*[]);
extern int ms_rping(struct Client*, struct Client*, int, char*[]);
extern int ms_rpong(struct Client*, struct Client*, int, char*[]);
extern int ms_rules(struct Client*, struct Client*, int, char*[]);
extern int ms_sasl(struct Client*, struct Client*, int, char*[]);
extern int ms_server(struct Client*, struct Client*, int, char*[]);
extern int ms_settime(struct Client*, struct Client*, int, char*[]);
extern int ms_shun(struct Client*, struct Client*, int, char*[]);
extern int ms_silence(struct Client*, struct Client*, int, char*[]);
extern int ms_smo(struct Client*, struct Client*, int, char*[]);
extern int ms_sno(struct Client*, struct Client*, int, char*[]);
extern int ms_squit(struct Client*, struct Client*, int, char*[]);
extern int ms_stats(struct Client*, struct Client*, int, char*[]);
extern int ms_svsident(struct Client*, struct Client*, int, char*[]);
extern int ms_svsinfo(struct Client*, struct Client*, int, char*[]);
extern int ms_svsjoin(struct Client*, struct Client*, int, char*[]);
extern int ms_svsmode(struct Client*, struct Client*, int, char*[]);
extern int ms_svsnick(struct Client*, struct Client*, int, char*[]);
extern int ms_svsnoop(struct Client*, struct Client*, int, char*[]);
extern int ms_svspart(struct Client*, struct Client*, int, char*[]);
extern int ms_svsquit(struct Client*, struct Client*, int, char*[]);
extern int ms_swhois(struct Client*, struct Client*, int, char*[]);
extern int ms_tempshun(struct Client*, struct Client*, int, char*[]);
extern int ms_topic(struct Client*, struct Client*, int, char*[]);
extern int ms_trace(struct Client*, struct Client*, int, char*[]);
extern int ms_uping(struct Client*, struct Client*, int, char*[]);
extern int ms_version(struct Client*, struct Client*, int, char*[]);
extern int ms_wallchops(struct Client*, struct Client*, int, char*[]);
extern int ms_wallhops(struct Client*, struct Client*, int, char*[]);
extern int ms_wallops(struct Client*, struct Client*, int, char*[]);
extern int ms_wallusers(struct Client*, struct Client*, int, char*[]);
extern int ms_wallvoices(struct Client*, struct Client*, int, char*[]);
extern int ms_whois(struct Client*, struct Client*, int, char*[]);
extern int ms_xquery(struct Client*, struct Client*, int, char*[]);
extern int ms_xreply(struct Client*, struct Client*, int, char*[]);
extern int ms_zline(struct Client*, struct Client*, int, char*[]);
#endif /* INCLUDED_handlers_h */
+103
View File
@@ -0,0 +1,103 @@
/*
* IRC - Internet Relay Chat, include/hash.h
* Copyright (C) 1998 by Andrea "Nemesi" Cocito
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Hash table management APIs.
* @version $Id: hash.h 1343 2005-03-30 03:48:22Z entrope $
*/
#ifndef INCLUDED_hash_h
#define INCLUDED_hash_h
struct Client;
struct Channel;
struct StatDesc;
struct Watch;
/*
* general defines
*/
/** Size of client and channel hash tables.
* Both must be of the same size.
*/
#define HASHSIZE 32000
/*
* Structures
*/
/*
* Macros for internal use
*/
/*
* Externally visible pseudofunctions (macro interface to internal functions)
*/
/* Raw calls, expect a core if you pass a NULL or zero-length name */
/** Search for a channel by name. */
#define SeekChannel(name) hSeekChannel((name))
/** Search for any client by name. */
#define SeekClient(name) hSeekClient((name), ~0)
/** Search for a registered user by name. */
#define SeekUser(name) hSeekClient((name), (STAT_USER))
/** Search for a server by name. */
#define SeekServer(name) hSeekClient((name), (STAT_ME | STAT_SERVER))
/** Search for a watch by name. */
#define SeekWatch(name) hSeekWatch((name))
/* Safer macros with sanity check on name, WARNING: these are _macros_,
no side effects allowed on <name> ! */
/** Search for a channel by name. */
#define FindChannel(name) (BadPtr((name)) ? 0 : SeekChannel(name))
/** Search for any client by name. */
#define FindClient(name) (BadPtr((name)) ? 0 : SeekClient(name))
/** Search for a registered user by name. */
#define FindUser(name) (BadPtr((name)) ? 0 : SeekUser(name))
/** Search for a server by name. */
#define FindServer(name) (BadPtr((name)) ? 0 : SeekServer(name))
/** Search for a watch by name. */
#define FindWatch(name) (BadPtr((name)) ? 0 : SeekWatch(name))
/*
* Proto types
*/
extern void init_hash(void); /* Call me on startup */
extern int hAddClient(struct Client *cptr);
extern int hAddChannel(struct Channel *chptr);
extern int hAddWatch(struct Watch *wptr);
extern int hRemClient(struct Client *cptr);
extern int hChangeClient(struct Client *cptr, const char *newname);
extern int hRemChannel(struct Channel *chptr);
extern int hRemWatch(struct Watch *wptr);
extern struct Client *hSeekClient(const char *name, int TMask);
extern struct Channel *hSeekChannel(const char *name);
extern struct Watch *hSeekWatch(const char *name);
extern int m_hash(struct Client *cptr, struct Client *sptr, int parc, char *parv[]);
extern int isNickJuped(const char *nick);
extern int addNickJupes(const char *nicks);
extern void clearNickJupes(void);
extern void stats_nickjupes(struct Client* to, const struct StatDesc* sd,
char* param);
extern void list_next_channels(struct Client *cptr);
#endif /* INCLUDED_hash_h */
+59
View File
@@ -0,0 +1,59 @@
/** @file ircd.h
* @brief Global data for the daemon.
* @version $Id: ircd.h 1229 2004-10-05 04:14:44Z entrope $
*/
#ifndef INCLUDED_ircd_h
#define INCLUDED_ircd_h
#ifndef INCLUDED_struct_h
#include "struct.h" /* struct Client */
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* size_t, time_t */
#endif
/** Describes status for a daemon. */
struct Daemon
{
int argc; /**< Number of command-line arguments. */
char** argv; /**< Array of command-line arguments. */
pid_t pid; /**< %Daemon's process id. */
uid_t uid; /**< %Daemon's user id. */
uid_t euid; /**< %Daemon's effective user id. */
unsigned int bootopt; /**< Boot option flags. */
int pid_fd; /**< File descriptor for process id file. */
};
/*
* Macros
*/
#define TStime() (CurrentTime + TSoffset) /**< Current network time*/
#define OLDEST_TS 780000000 /**< Any TS older than this is bogus */
#define BadPtr(x) (!(x) || (*(x) == '\0')) /**< Is \a x a bad string? */
/* Miscellaneous defines */
#define UDP_PORT 7007 /**< Default port for server-to-server pings. */
#define MINOR_PROTOCOL "09" /**< Minimum protocol version supported. */
#define MAJOR_PROTOCOL "10" /**< Current protocol version. */
#define BASE_VERSION "u2.10" /**< Base name of IRC daemon version. */
/*
* Proto types
*/
extern void server_die(const char* message);
extern void server_panic(const char* message);
extern void server_restart(const char* message);
extern struct Client me;
extern time_t CurrentTime;
extern struct Client* GlobalClientList;
extern time_t TSoffset;
extern int GlobalRehashFlag; /* 1 if SIGHUP is received */
extern int GlobalRestartFlag; /* 1 if SIGINT is received */
extern char* configfile;
extern int debuglevel;
extern char* debugmode;
extern int running;
#endif /* INCLUDED_ircd_h */
+81
View File
@@ -0,0 +1,81 @@
/*
* IRC - Internet Relay Chat, include/ircd_alloc.h
* Copyright (C) 1999 Thomas Helvey <tomh@inxpress.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Commentary by Bleep (Thomas Helvey)
*/
/** @file
* @brief IRC daemon memory allocation functions.
* @version $Id: ircd_alloc.h 1306 2005-01-27 04:07:46Z entrope $
*/
#ifndef INCLUDED_ircd_alloc_h
#define INCLUDED_ircd_alloc_h
/*
* memory resource allocation and test functions
*/
/** Type of handler for out-of-memory conditions. */
typedef void (*OutOfMemoryHandler)(void);
extern void set_nomem_handler(OutOfMemoryHandler handler);
/* The mappings for the My* functions... */
/** Helper macro for standard allocations. */
#define MyMalloc(size) \
DoMalloc(size, "malloc", __FILE__, __LINE__)
/** Helper macro for zero-initialized allocations. */
#define MyCalloc(nelem, size) \
DoMallocZero((size) * (nelem), "calloc", __FILE__, __LINE__)
/** Helper macro for freeing memory. */
#define MyFree(p) \
if (p) \
DoFree(p, __FILE__, __LINE__)
/** Helper macro for reallocating memory. */
#define MyRealloc(p, size) \
DoRealloc(p, size, __FILE__, __LINE__)
/* First version: fast non-debugging macros... */
#ifndef MDEBUG
#ifndef INCLUDED_stdlib_h
#include <stdlib.h> /* free */
#define INCLUDED_stdlib_h
#endif
/** Implementation macro for freeing memory. */
#define DoFree(x, file, line) do { free((x)); (x) = 0; } while(0)
extern void* DoMalloc(size_t len, const char*, const char*, int);
extern void* DoMallocZero(size_t len, const char*, const char*, int);
extern void *DoRealloc(void *, size_t, const char*, int);
/* Second version: slower debugging versions... */
#else /* defined(MDEBUG) */
#include <sys/types.h>
#include "memdebug.h"
#define DoMalloc(size, type, file, line) \
dbg_malloc(size, type, file, line)
#define DoMallocZero(size, type, file, line) \
dbg_malloc_zero(size, type, file, line)
#define DoFree(p, file, line) \
do { dbg_free(p, file, line); (p) = 0; } while (0)
#define DoRealloc(p, size, file, line) \
dbg_realloc(p, size, file, line)
#endif /* defined(MDEBUG) */
#endif /* INCLUDED_ircd_alloc_h */
+130
View File
@@ -0,0 +1,130 @@
/*
* IRC - Internet Relay Chat, include/ircd_chattr.h
* Copyright (C) 1998 Andrea Cocito
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Character attribute definitions and arrays.
* @version $Id: ircd_chattr.h 1221 2004-10-05 02:10:00Z entrope $
*
* This character set code is adapted from Nemesi's Tools Library,
* which gives us the prefix NTL_ on these macros.
*/
#ifndef INCLUDED_ircd_chattr_h
#define INCLUDED_ircd_chattr_h
#ifndef INCLUDED_limits_h
#include <limits.h>
#define INCLUDED_limits_h
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
/*
* Character attribute macros
*/
#define NTL_ALNUM 0x0001 /**< (NTL_ALPHA | NTL_DIGIT) */
#define NTL_ALPHA 0x0002 /**< (NTL_LOWER | NTL_UPPER) */
#define NTL_CNTRL 0x0004 /**< \\000 - \\037 == 0x00 - 0x1F */
#define NTL_DIGIT 0x0008 /**< 0123456789 */
#define NTL_GRAPH 0x0010 /**< (NTL_ALNUM | NTL_PUNCT) */
#define NTL_LOWER 0x0020 /**< abcdefghijklmnopqrstuvwxyz{|}~ */
#define NTL_PRINT 0x0040 /**< (NTL_GRAPH | ' ') */
#define NTL_PUNCT 0x0080 /**< !"#$%&'()*+,-./:;<=>?\@_` */
#define NTL_SPACE 0x0100 /**< \\011\\012\\013\\014\\015\\040 */
#define NTL_UPPER 0x0200 /**< ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ */
#define NTL_IRCCH 0x0400 /**< Channel's names charset */
#define NTL_IRCCL 0x0800 /**< Force toLower() in ch-name */
#define NTL_IRCNK 0x1000 /**< Nick names charset, aka isvalid() */
#define NTL_IRCUI 0x2000 /**< UserIDs charset, IRCHN plus tilde */
#define NTL_IRCHN 0x4000 /**< Hostnames charset (weak, RFC 1033) */
#define NTL_IRCIP 0x8000 /**< Numeric IPs charset (DIGIT and .) */
#define NTL_EOL 0x10000 /**< \\r\\n */
#define NTL_KTIME 0x20000 /**< Valid character for a k:line time */
#define NTL_CHPFX 0x40000 /**< channel prefix char # & + */
#define NTL_IRCIP6 0x80000 /**< Numeric IPv6 character (hex or colon) */
/*
* Tables used for translation and classification macros
*/
/** Array mapping characters to RFC 1459 lower-case versions.
* Yes, the variable name lies about the encoding.
*/
extern const char ToLowerTab_8859_1[];
/** Array mapping characters to RFC 1459 upper-case versions.
* Yes, the variable name lies about the encoding.
*/
extern const char ToUpperTab_8859_1[];
/** Array mapping characters to attribute bitmasks. */
extern const unsigned int IRCD_CharAttrTab[];
/*
* Translation macros for channel name case translation
* NOTE: Channel names are supposed to be lower case insensitive for
* ISO 8859-1 character sets.
*/
/** Convert a character to its lower-case equivalent. */
#define ToLower(c) (ToLowerTab_8859_1[(c) - CHAR_MIN])
/** Convert a character to its upper-case equivalent. */
#define ToUpper(c) (ToUpperTab_8859_1[(c) - CHAR_MIN])
/*
* Character classification macros
* NOTE: The IsUpper and IsLower macros do not apply to the complete
* ISO 8859-1 character set, unlike the ToUpper and ToLower macros above.
* IsUpper and IsLower only apply for comparisons of the US ASCII subset.
*/
/** Test whether a character is alphanumeric. */
#define IsAlnum(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_ALNUM)
/** Test whether a character is alphabetic. */
#define IsAlpha(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_ALPHA)
/** Test whether a character is a digit. */
#define IsDigit(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_DIGIT)
/** Test whether a character is lower case. */
#define IsLower(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_LOWER)
/** Test whether a character is whitespace. */
#define IsSpace(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_SPACE)
/** Test whether a character is upper case. */
#define IsUpper(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_UPPER)
/** Test whether a character is a control character. */
#define IsCntrl(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_CNTRL)
/** Test whether a character is valid in a channel name. */
#define IsChannelChar(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCCH)
/** Test whether a character is a lower-case channel name character. */
#define IsChannelLower(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCCL)
/** Test whether a character is a channel prefix. */
#define IsChannelPrefix(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_CHPFX)
/** Test whether a character is valid in a nickname. */
#define IsNickChar(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCNK)
/** Test whether a character is valid in a userid. */
#define IsUserChar(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCUI)
/** Test whether a character is valid in a hostname. */
#define IsHostChar(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCHN)
/** Test whether a character is valid in an IPv4 address. */
#define IsIPChar(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCIP)
/** Test whether a character is valid in an IPv6 address. */
#define IsIP6Char(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_IRCIP6)
/** Test whether a character is an end-of-line character. */
#define IsEol(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_EOL)
/** Test whether a character is valid in a K: line expiration string. */
#define IsKTimeChar(c) (IRCD_CharAttrTab[(c) - CHAR_MIN] & NTL_KTIME)
#endif /* INCLUDED_ircd_chattr_h */
+15
View File
@@ -0,0 +1,15 @@
/** @file ircd_cloaking.h
* @brief Public declarations and APIs for IP and host cloaking functions.
* @version $Id$
*/
#ifndef INCLUDED_ircd_cloaking_h
#define INCLUDED_ircd_cloaking_h
#include "res.h"
extern char *hidehost_ipv4(struct irc_in_addr *ip);
extern char *hidehost_ipv6(struct irc_in_addr *ip);
extern char *hidehost_normalhost(char *host, int components);
#endif /* INCLUDED_ircd_cloaking_h */
+71
View File
@@ -0,0 +1,71 @@
/*
* IRC - Internet Relay Chat, include/ircd_crypt.h
* Copyright (C) 2002 hikari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Core password encryption and hashing APIs.
* @version $Id: ircd_crypt.h 1264 2004-11-07 21:04:59Z entrope $
*/
#ifndef INCLUDED_ircd_crypt_h
#define INCLUDED_ircd_crypt_h
/* forward planning for modularisation */
struct crypt_mech_s {
char* mechname; /* name of the mechanism */
char* shortname; /* short name of the module */
char* description; /* description of the mechanism */
const char* (*crypt_function)(const char *, const char *);
/* pointer to the crypt function */
char* crypt_token; /* what identifies a password string
as belonging to this mechanism */
int crypt_token_size; /* how long is the token */
};
typedef struct crypt_mech_s crypt_mech_t;
struct crypt_mechs_s;
typedef struct crypt_mechs_s crypt_mechs_t;
struct crypt_mechs_s {
crypt_mech_t* mech;
crypt_mechs_t* next;
crypt_mechs_t* prev;
};
/* access macros */
#define MechName(x) x->mechname
#define ShortName(x) x->shortname
#define Description(x) x->description
#define CryptFunc(x) x->crypt_function
#define CryptTok(x) x->crypt_token
#define CryptTokSize(x) x->crypt_token_size
/* exported functions */
extern void ircd_crypt_init(void);
extern char* ircd_crypt(const char* key, const char* salt);
extern int ircd_crypt_register_mech(crypt_mech_t* mechanism);
extern int ircd_crypt_unregister_mech(crypt_mech_t* mechanism);
extern int oper_password_match(const char* to_match, const char* passwd);
/* exported variables */
extern crypt_mechs_t* crypt_mechs_root;
#endif /* INCLUDED_ircd_crypt_h */
+27
View File
@@ -0,0 +1,27 @@
/*
* IRC - Internet Relay Chat, include/ircd_crypt_bcrypt.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Bcrypt password hashing APIs.
*/
#ifndef INCLUDED_ircd_crypt_bcrypt_h
#define INCLUDED_ircd_crypt_bcrypt_h
extern void ircd_register_crypt_bcrypt(void);
extern const char* ircd_crypt_bcrypt(const char* key, const char* salt);
#endif /* INCLUDED_ircd_crypt_bcrypt_h */
+12
View File
@@ -0,0 +1,12 @@
/** @file
* @brief Native crypt() function declarations.
* @version $Id: ircd_crypt_native.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_ircd_crypt_native_h
#define INCLUDED_ircd_crypt_native_h
extern const char* ircd_crypt_native(const char* key, const char* salt);
extern void ircd_register_crypt_native(void);
#endif /* INCLUDED_ircd_crypt_native_h */
+31
View File
@@ -0,0 +1,31 @@
/*
* IRC - Internet Relay Chat, include/ircd_crypt_plain.h
* Copyright (C) 2002 hikari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Declarations for plaintext password "crypting".
* @version $Id: ircd_crypt_plain.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_ircd_crypt_plain_h
#define INCLUDED_ircd_crypt_plain_h
extern const char* ircd_crypt_plain(const char* key, const char* salt);
extern void ircd_register_crypt_plain(void);
#endif /* INCLUDED_ircd_crypt_plain_h */
+30
View File
@@ -0,0 +1,30 @@
/*
* IRC - Internet Relay Chat, include/ircd_crypt_smd5.h
* Copyright (C) 2002 hikari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Declarations for salted MD5 password crypting.
* @version $Id: ircd_crypt_smd5.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_ircd_crypt_smd5_h
#define INCLUDED_ircd_crypt_smd5_h
extern const char* ircd_crypt_smd5(const char* key, const char* salt);
extern void ircd_register_crypt_smd5(void);
#endif /* INCLUDED_ircd_crypt_smd5_h */
+113
View File
@@ -0,0 +1,113 @@
/*
* IRC - Internet Relay Chat, include/ircd_defs.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Commentary by Bleep (Thomas Helvey)
*/
#ifndef INCLUDED_ircd_defs_h
#define INCLUDED_ircd_defs_h
/** @file
* @brief Definitions used everywhere in the server.
*
* NOTE: Changing any of these definitions (except for the
* target-related ones at the bottom) is equivalent to a protocol
* revision. Every server on a given network must use the same values.
* @version $Id: ircd_defs.h 3 2010-03-03 17:36:26Z jobe1986 $
*/
/** Maximum length allowed for a nickname.
* Because certain networks are very helpful in finding bugs, the below
* is a default that can easily be overridden in CFLAGS. Just add
* -DNICKLEN=15 to CFLAGS during configure, and you can forget about
* it. Thanks for helping debug guys.
* See also F:NICKLEN in ircd.conf.
*/
#ifndef NICKLEN
#define NICKLEN 30
#endif
/** Maximum length allowed of a user name, including an optional
* leading '~' if the user name has not been authenticated by an auth (RFC 931)
* server query.
*/
#define USERLEN 10
/** Exactly long enough to hold one (1) segment of FQDN or hostname.
* This is due to an historical misinterpretation of RFC 1034.
* 3.1. Name space specifications and terminology
*
* The domain name space is a tree structure. Each node and leaf on the
* tree corresponds to a resource set (which may be empty). The domain
* system makes no distinctions between the uses of the interior nodes and
* leaves, and this memo uses the term "node" to refer to both.
*
* Each node has a label, which is zero to 63 octets in length. Brother
* nodes may not have the same label, although the same label can be used
* for nodes which are not brothers. One label is reserved, and that is
* the null (i.e., zero length) label used for the root.
*
* This has proven not to be a problem in the past as connections with FQDN's
* of greater than 63 characters are rejected by the server, and most FQDN's
* are shorter. It is possible to have a valid FQDN longer than 63 characters.
*/
#define HOSTLEN 75
/** Maximum length for the account name, which can be set
* with the ACCOUNT (AC) command. This is used for keeping track of who's
* logged into which account, for the benefit of irc services.
*/
#define ACCOUNTLEN 15
/** Maximum length for user supplied information about a client
* connection (gcos). This information is set at client/server registration
* time.
*/
#define REALLEN 50
/** Maximum length for user supplied information about a clients version. This
* information is set at client/server after a reply to CTCP VERSION.
*/
#define VERSIONLEN 250
/** Maximum length for a password used for connecting servers and clients.
*/
#define PASSWDLEN 20
/** Maximum length for a password used with the login-on-connect feature, and
* it should match the length used by your service bot (e.g. gnuworld)
*/
#define ACCPASSWDLEN 40
/** Maximum length of a numeric IP (v4 or v6) address.
* "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"
*/
#define SOCKIPLEN 45
/** Maximum length for channel topics and kill comments.
*/
#define TOPICLEN 250
/** Maximum length for away messages.
*/
#define AWAYLEN 250
/** Exactly long enough to hold one protocol message (RFC 1459)
* including the line termination (\\r\\n). DO NOT CHANGE THIS!!!!
*/
#define BUFSIZE 512
/** Maximum available targets for a user. */
#define MAXTARGETS 20
/** Starting free targets for a user. */
#define STARTTARGETS 10
/** Target number to start assigning new targets. */
#define RESERVEDTARGETS 12
/** Extended ban prefix character. */
#define EXTBANPREFIX '~'
#endif /* INCLUDED_ircd_defs_h */
+319
View File
@@ -0,0 +1,319 @@
#ifndef INCLUDED_ircd_events_h
#define INCLUDED_ircd_events_h
/*
* IRC - Internet Relay Chat, include/ircd_events.h
* Copyright (C) 2001 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface and public definitions for event loop.
* @version $Id: ircd_events.h 1794 2007-04-01 02:11:41Z entrope $
*/
#ifndef INCLUDED_config_h
#include "config.h"
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* time_t */
#define INCLUDED_sys_types_h
#endif
#ifdef USE_SSL
#ifndef INCLUDED_ssl_h
#include "ssl.h"
#endif
#endif /* USE_SSL */
struct Event;
/** Generic callback for event activity. */
typedef void (*EventCallBack)(struct Event*);
/** State of a Socket structure. */
enum SocketState {
SS_CONNECTING, /**< Connection in progress on socket */
SS_LISTENING, /**< Socket is a listening socket */
SS_CONNECTED, /**< Socket is a connected socket */
SS_DATAGRAM, /**< Socket is a datagram socket */
SS_CONNECTDG, /**< Socket is a connected datagram socket */
SS_NOTSOCK /**< Socket isn't a socket at all */
};
/** Type of a Timer (how its expiration is measured). */
enum TimerType {
TT_ABSOLUTE, /**< timer that runs at a specific time */
TT_RELATIVE, /**< timer that runs so many seconds in the future */
TT_PERIODIC /**< timer that runs periodically */
};
/** Type of event that generated a callback. */
enum EventType {
ET_READ, /**< Readable event detected */
ET_WRITE, /**< Writable event detected */
ET_ACCEPT, /**< Connection can be accepted */
ET_CONNECT, /**< Connection completed */
ET_EOF, /**< End-of-file on connection */
ET_ERROR, /**< Error condition detected */
ET_SIGNAL, /**< A signal was received */
ET_EXPIRE, /**< A timer expired */
ET_DESTROY /**< The generator is being destroyed */
};
/** Common header for event generators. */
struct GenHeader {
struct GenHeader* gh_next; /**< linked list of generators */
struct GenHeader** gh_prev_p; /**< previous pointer to this generator */
#ifdef IRCD_THREADED
struct GenHeader* gh_qnext; /**< linked list of generators in queue */
struct GenHeader** gh_qprev_p; /**< previous pointer to this generator */
struct Event* gh_head; /**< head of event queue */
struct Event* gh_tail; /**< tail of event queue */
#endif
unsigned int gh_flags; /**< generator flags */
unsigned int gh_ref; /**< reference count */
EventCallBack gh_call; /**< generator callback function */
void* gh_data; /**< extra data */
union {
void* ed_ptr; /**< engine data as pointer */
int ed_int; /**< engine data as integer */
} gh_engdata;/**< engine data */
};
#define GEN_DESTROY 0x0001 /**< generator is to be destroyed */
#define GEN_MARKED 0x0002 /**< generator is marked for destruction */
#define GEN_ACTIVE 0x0004 /**< generator is active */
#define GEN_READD 0x0008 /**< generator (timer) must be re-added */
#define GEN_ERROR 0x0010 /**< an error occurred on the generator */
/** Socket event generator.
* Note: The socket state overrides the socket event mask; that is, if
* it's an SS_CONNECTING socket, the engine selects its own definition
* of what that looks like and ignores s_events. s_events is meaningful
* only for SS_CONNECTED, SS_DATAGRAM, and SS_CONNECTDG, but may be set
* prior to the state transition, if desired.
*/
struct Socket {
struct GenHeader s_header; /**< generator information */
enum SocketState s_state; /**< state socket's in */
unsigned int s_events; /**< events socket is interested in */
int s_fd; /**< file descriptor for socket */
#ifdef USE_SSL
SSL* ssl; /**< if not NULL, use SSL routines on socket */
#endif /* USE_SSL */
};
#define SOCK_EVENT_READABLE 0x0001 /**< interested in readable */
#define SOCK_EVENT_WRITABLE 0x0002 /**< interested in writable */
/** Bitmask of possible event interests for a socket. */
#define SOCK_EVENT_MASK (SOCK_EVENT_READABLE | SOCK_EVENT_WRITABLE)
#define SOCK_ACTION_SET 0x0000 /**< set interest set as follows */
#define SOCK_ACTION_ADD 0x1000 /**< add to interest set */
#define SOCK_ACTION_DEL 0x2000 /**< remove from interest set */
#define SOCK_ACTION_MASK 0x3000 /**< mask out the actions */
/** Retrieve state of the Socket \a sock. */
#define s_state(sock) ((sock)->s_state)
/** Retrieve interest mask of the Socket \a sock. */
#define s_events(sock) ((sock)->s_events)
/** Retrieve file descriptor of the Socket \a sock. */
#define s_fd(sock) ((sock)->s_fd)
/** Retrieve user data pointer of the Socket \a sock. */
#define s_data(sock) ((sock)->s_header.gh_data)
/** Retrieve engine data integer of the Socket \a sock. */
#define s_ed_int(sock) ((sock)->s_header.gh_engdata.ed_int)
/** Retrieve engine data pointer of the Socket \a sock. */
#define s_ed_ptr(sock) ((sock)->s_header.gh_engdata.ed_ptr)
/** Retrieve whether the Socket \a sock is active. */
#define s_active(sock) ((sock)->s_header.gh_flags & GEN_ACTIVE)
/** Signal event generator. */
struct Signal {
struct GenHeader sig_header; /**< generator information */
int sig_signal; /**< signal number */
};
/** Retrieve signal number of the Signal \a sig. */
#define sig_signal(sig) ((sig)->sig_signal)
/** Retrieve user data pointer of the Signal \a sig. */
#define sig_data(sig) ((sig)->sig_header.gh_data)
/** Retrieve engine data integer of the Signal \a sig. */
#define sig_ed_int(sig) ((sig)->sig_header.gh_engdata.ed_int)
/** Retrieve engine data pointer of the Signal \a sig. */
#define sig_ed_ptr(sig) ((sig)->sig_header.gh_engdata.ed_ptr)
/** Retrieve whether the Signal \a sig is active. */
#define sig_active(sig) ((sig)->sig_header.gh_flags & GEN_ACTIVE)
/** Timer event generator. */
struct Timer {
struct GenHeader t_header; /**< generator information */
enum TimerType t_type; /**< what type of timer this is */
time_t t_value; /**< value timer was added with */
time_t t_expire; /**< time at which timer expires */
};
/** Retrieve type of the Timer \a tim. */
#define t_type(tim) ((tim)->t_type)
/** Retrieve interval of the Timer \a tim. */
#define t_value(tim) ((tim)->t_value)
/** Retrieve expiration time of the Timer \a tim. */
#define t_expire(tim) ((tim)->t_expire)
/** Retrieve user data pointer of the Timer \a tim. */
#define t_data(tim) ((tim)->t_header.gh_data)
/** Retrieve engine data integer of the Timer \a tim. */
#define t_ed_int(tim) ((tim)->t_header.gh_engdata.ed_int)
/** Retrieve engine data pointer of the Timer \a tim. */
#define t_ed_ptr(tim) ((tim)->t_header.gh_engdata.ed_ptr)
/** Retrieve whether the Timer \a tim is active. */
#define t_active(tim) ((tim)->t_header.gh_flags & GEN_ACTIVE)
/** Retrieve whether the Timer \a tim is enqueued. */
#define t_onqueue(tim) ((tim)->t_header.gh_prev_p)
/** Event activity descriptor. */
struct Event {
struct Event* ev_next; /**< linked list of events on queue */
struct Event** ev_prev_p; /**< previous pointer to this event */
enum EventType ev_type; /**< Event type */
int ev_data; /**< extra data, like errno value */
union {
struct GenHeader* gen_header; /**< Generator header */
struct Socket* gen_socket; /**< Socket generating event */
struct Signal* gen_signal; /**< Signal generating event */
struct Timer* gen_timer; /**< Timer generating event */
} ev_gen; /**< object generating event */
};
/** Retrieve the type of the Event \a ev. */
#define ev_type(ev) ((ev)->ev_type)
/** Retrieve the extra data of the Event \a ev. */
#define ev_data(ev) ((ev)->ev_data)
/** Retrieve the Socket that generated the Event \a ev. */
#define ev_socket(ev) ((ev)->ev_gen.gen_socket)
/** Retrieve the Signal that generated the Event \a ev. */
#define ev_signal(ev) ((ev)->ev_gen.gen_signal)
/** Retrieve the Timer that generated the Event \a ev. */
#define ev_timer(ev) ((ev)->ev_gen.gen_timer)
/** List of all event generators. */
struct Generators {
struct GenHeader* g_socket; /**< list of socket generators */
struct GenHeader* g_signal; /**< list of signal generators */
struct GenHeader* g_timer; /**< list of timer generators */
};
/** Returns 1 if successfully initialized, 0 if not.
* @param[in] max_sockets Number of sockets to support.
*/
typedef int (*EngineInit)(int max_sockets);
/** Tell engine about new signal.
* @param[in] sig Signal event generator to add.
*/
typedef void (*EngineSignal)(struct Signal* sig);
/** Tell engine about new socket.
* @param[in] sock Socket event generator to add.
*/
typedef int (*EngineAdd)(struct Socket* sock);
/** Tell engine about socket's new_state.
* @param[in] sock Socket whose state is changing.
* @param[in] new_state New state for socket.
*/
typedef void (*EngineState)(struct Socket* sock, enum SocketState new_state);
/** Tell engine about socket's new event interests.
* @param[in] sock Socket whose interest mask is changing.
* @param[in] new_events New event mask to set (not SOCK_ACTION_ADD or SOCK_ACTION_DEL).
*/
typedef void (*EngineEvents)(struct Socket* sock, unsigned int new_events);
/** Tell engine a socket is going away.
* @param[in] sock Socket being destroyed.
*/
typedef void (*EngineDelete)(struct Socket* sock);
/** The actual event loop.
* @param[in] gens List of event generators.
*/
typedef void (*EngineLoop)(struct Generators* gens);
/** Structure for an event engine to describe itself. */
struct Engine {
const char* eng_name; /**< a name for the engine */
EngineInit eng_init; /**< initialize engine */
EngineSignal eng_signal; /**< express interest in a signal (may be NULL) */
EngineAdd eng_add; /**< express interest in a socket */
EngineState eng_state; /**< mention a change in state to engine */
EngineEvents eng_events; /**< express interest in socket events */
EngineDelete eng_closing; /**< socket is being closed */
EngineLoop eng_loop; /**< actual event loop */
};
/** Increment the reference count of \a gen. */
#define gen_ref_inc(gen) (((struct GenHeader*) (gen))->gh_ref++)
/** Decrement the reference count of \a gen. */
#define gen_ref_dec(gen) \
do { \
struct GenHeader* _gen = (struct GenHeader*) (gen); \
if (!--_gen->gh_ref && (_gen->gh_flags & GEN_DESTROY)) { \
gen_dequeue(_gen); \
event_generate(ET_DESTROY, _gen, 0); \
} \
} while (0)
/** Clear the error flag for \a gen. */
#define gen_clear_error(gen) \
(((struct GenHeader*) (gen))->gh_flags &= ~GEN_ERROR)
void gen_dequeue(void* arg);
void event_init(int max_sockets);
void event_loop(void);
void event_generate(enum EventType type, void* arg, int data);
struct Timer* timer_init(struct Timer* timer);
void timer_add(struct Timer* timer, EventCallBack call, void* data,
enum TimerType type, time_t value);
void timer_del(struct Timer* timer);
void timer_chg(struct Timer* timer, enum TimerType type, time_t value);
void timer_run(void);
/** Retrieve the next timer's expiration time from Generators \a gen. */
#define timer_next(gen) ((gen)->g_timer ? ((struct Timer*)(gen)->g_timer)->t_expire : 0)
void signal_add(struct Signal* signal, EventCallBack call, void* data,
int sig);
int socket_add(struct Socket* sock, EventCallBack call, void* data,
enum SocketState state, unsigned int events, int fd);
void socket_del(struct Socket* sock);
void socket_state(struct Socket* sock, enum SocketState state);
void socket_events(struct Socket* sock, unsigned int events);
const char* engine_name(void);
#ifdef DEBUGMODE
/* These routines pretty-print names for states and types for debug printing */
const char* state_to_name(enum SocketState state);
const char* timer_to_name(enum TimerType type);
const char* event_to_name(enum EventType type);
const char* gen_flags(unsigned int flags);
const char* sock_flags(unsigned int flags);
#endif /* DEBUGMODE */
#endif /* INCLUDED_ircd_events_h */
+345
View File
@@ -0,0 +1,345 @@
#ifndef INCLUDED_features_h
#define INCLUDED_features_h
/*
* IRC - Internet Relay Chat, include/features.h
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Public interfaces and declarations for dealing with configurable features.
* @version $Id: ircd_features.h 1774 2007-03-17 03:48:49Z klmitch $
*/
struct Client;
struct StatDesc;
extern struct Client his;
/** Contains all feature settings for ircu.
* For documentation of each, see doc/readme.features.
*/
enum Feature {
/* Misc. features */
FEAT_LOG,
FEAT_DOMAINNAME,
FEAT_RELIABLE_CLOCK,
FEAT_BUFFERPOOL,
FEAT_HAS_FERGUSON_FLUSHER,
FEAT_CLIENT_FLOOD,
FEAT_SERVER_PORT,
FEAT_NODEFAULTMOTD,
FEAT_MOTD_BANNER,
FEAT_PROVIDER,
FEAT_KILL_IPMISMATCH,
FEAT_IDLE_FROM_MSG,
FEAT_HUB,
FEAT_WALLOPS_OPER_ONLY,
FEAT_NODNS,
FEAT_RANDOM_SEED,
FEAT_DEFAULT_LIST_PARAM,
FEAT_NICKNAMEHISTORYLENGTH,
FEAT_HOST_HIDING,
FEAT_HIDDEN_HOST,
FEAT_HIDDEN_IP,
FEAT_CONNEXIT_NOTICES,
FEAT_OPLEVELS,
FEAT_ZANNELS,
FEAT_LOCAL_CHANNELS,
FEAT_TOPIC_BURST,
FEAT_DISABLE_GLINES,
/* features that probably should not be touched */
FEAT_KILLCHASETIMELIMIT,
FEAT_MAXCHANNELSPERUSER,
FEAT_NICKLEN,
FEAT_AVBANLEN,
FEAT_MAXBANS,
FEAT_MAXSILES,
FEAT_HANGONGOODLINK,
FEAT_HANGONRETRYDELAY,
FEAT_CONNECTTIMEOUT,
FEAT_MAXIMUM_LINKS,
FEAT_PINGFREQUENCY,
FEAT_CONNECTFREQUENCY,
FEAT_DEFAULTMAXSENDQLENGTH,
FEAT_GLINEMAXUSERCOUNT,
FEAT_SOCKSENDBUF,
FEAT_SOCKRECVBUF,
FEAT_IPCHECK_CLONE_LIMIT,
FEAT_IPCHECK_CLONE_PERIOD,
FEAT_IPCHECK_CLONE_DELAY,
FEAT_CHANNELLEN,
/* Some misc. default paths */
FEAT_MPATH,
FEAT_RPATH,
FEAT_PPATH,
/* Networking features */
FEAT_TOS_SERVER,
FEAT_TOS_CLIENT,
FEAT_POLLS_PER_LOOP,
FEAT_IRCD_RES_RETRIES,
FEAT_IRCD_RES_TIMEOUT,
FEAT_AUTH_TIMEOUT,
FEAT_ANNOUNCE_INVITES,
/* features that affect all operators */
FEAT_CONFIG_OPERCMDS,
/* HEAD_IN_SAND Features */
FEAT_HIS_SNOTICES,
FEAT_HIS_SNOTICES_OPER_ONLY,
FEAT_HIS_DEBUG_OPER_ONLY,
FEAT_HIS_WALLOPS,
FEAT_HIS_MAP,
FEAT_HIS_LINKS,
FEAT_HIS_TRACE,
FEAT_HIS_STATS_a,
FEAT_HIS_STATS_c,
FEAT_HIS_STATS_d,
FEAT_HIS_STATS_e,
FEAT_HIS_STATS_f,
FEAT_HIS_STATS_g,
FEAT_HIS_STATS_i,
FEAT_HIS_STATS_j,
FEAT_HIS_STATS_J,
FEAT_HIS_STATS_k,
FEAT_HIS_STATS_l,
FEAT_HIS_STATS_L,
FEAT_HIS_STATS_M,
FEAT_HIS_STATS_m,
FEAT_HIS_STATS_o,
FEAT_HIS_STATS_p,
FEAT_HIS_STATS_q,
FEAT_HIS_STATS_R,
FEAT_HIS_STATS_r,
FEAT_HIS_STATS_S,
FEAT_HIS_STATS_t,
FEAT_HIS_STATS_T,
FEAT_HIS_STATS_u,
FEAT_HIS_STATS_U,
FEAT_HIS_STATS_v,
FEAT_HIS_STATS_w,
FEAT_HIS_STATS_x,
FEAT_HIS_STATS_y,
FEAT_HIS_STATS_z,
FEAT_HIS_STATS_IAUTH,
FEAT_HIS_WHOIS_SERVERNAME,
FEAT_HIS_WHOIS_IDLETIME,
FEAT_HIS_WHOIS_LOCALCHAN,
FEAT_HIS_WHO_SERVERNAME,
FEAT_HIS_WHO_HOPCOUNT,
FEAT_HIS_MODEWHO,
FEAT_HIS_BANWHO,
FEAT_HIS_KILLWHO,
FEAT_HIS_REWRITE,
FEAT_HIS_REMOTE,
FEAT_HIS_NETSPLIT,
FEAT_HIS_SERVERNAME,
FEAT_HIS_SERVERINFO,
FEAT_HIS_URLSERVERS,
/* Misc. random stuff */
FEAT_NETWORK,
FEAT_URL_CLIENTS,
FEAT_URLREG,
/* Nefarious FEAT_'s */
FEAT_CHECK,
FEAT_CHECK_EXTENDED,
FEAT_MAX_CHECK_OUTPUT,
FEAT_OPER_WHOIS_PARANOIA,
FEAT_OPER_HIDE,
FEAT_AUTOCHANMODES,
FEAT_AUTOCHANMODES_LIST,
FEAT_UHNAMES,
FEAT_RESTARTPASS,
FEAT_DIEPASS,
FEAT_HIS_STATS_W,
FEAT_WHOIS_OPER,
FEAT_WHOIS_ADMIN,
FEAT_WHOIS_SERVICE,
FEAT_TARGET_LIMITING,
FEAT_OPER_XTRAOP,
FEAT_REMOTE_OPER,
FEAT_OPERMOTD,
FEAT_RULES,
FEAT_DISABLE_SHUNS,
FEAT_SHUNMAXUSERCOUNT,
FEAT_HIS_SHUN_REASON,
FEAT_HIS_GLINE_REASON,
FEAT_NOIDENT,
FEAT_EXTENDED_ACCOUNTS,
FEAT_LOGIN_ON_CONNECT,
FEAT_LOC_SENDHOST,
FEAT_LOC_SENDSSLFP,
FEAT_LOC_DEFAULT_SERVICE,
FEAT_LOC_TIMEOUT,
FEAT_STRICTUSERNAME,
FEAT_APASS_CANSEND,
FEAT_HOST_IN_TOPIC,
FEAT_HIS_STATS_s,
FEAT_SETHOST,
FEAT_FLEXIBLEKEYS,
FEAT_HIS_STATS_E,
FEAT_SASL_SERVER,
FEAT_LISTDELAY,
FEAT_ALLOW_OPLEVEL_CHANGE,
FEAT_NETWORK_REHASH,
FEAT_LIST_SHOWMODES_OPERONLY,
FEAT_LIST_PRIVATE_CHANNELS,
FEAT_MAXWATCHS,
FEAT_HIS_STATS_Z,
FEAT_SASL_TIMEOUT,
FEAT_NOMULTITARGETS,
FEAT_HIS_IRCOPS,
FEAT_HIS_IRCOPS_SERVERS,
FEAT_SASL_SENDHOST,
FEAT_SASL_AUTOHIDEHOST,
FEAT_SNOMASK_DEFAULT,
FEAT_SNOMASK_OPERDEFAULT,
FEAT_TPATH,
FEAT_CHMODE_m_NONICKCHANGE,
FEAT_CHMODE_r_NONICKCHANGE,
FEAT_SILENCE_CHANMSGS,
FEAT_CHANNEL_CREATE_IRCOPONLY,
FEAT_JOIN_ON_REMOVEDELAY,
FEAT_DERESTRICT_HIDECHANS,
FEAT_VALID_UTF8_CHANNELS_ONLY,
/* Extended channel modes */
FEAT_CHMODE_a,
FEAT_CHMODE_c,
FEAT_CHMODE_C,
FEAT_CHMODE_L,
FEAT_CHMODE_M,
FEAT_CHMODE_N,
FEAT_CHMODE_O,
FEAT_CHMODE_Q,
FEAT_CHMODE_S,
FEAT_CHMODE_T,
FEAT_CHMODE_Z,
FEAT_HALFOPS,
FEAT_EXCEPTS,
FEAT_MAXEXCEPTS,
FEAT_AVEXCEPTLEN,
FEAT_CHMODE_e_CHMODEEXCEPTION,
FEAT_HALFOP_DEHALFOP_SELF,
FEAT_CHMODE_Z_STRICT,
FEAT_MAX_BOUNCE,
/* Extended bans */
FEAT_EXTBANS,
FEAT_EXTBAN_j_MAXDEPTH,
FEAT_EXTBAN_j_MAXPERCHAN,
FEAT_EXTBAN_a,
FEAT_EXTBAN_c,
FEAT_EXTBAN_j,
FEAT_EXTBAN_n,
FEAT_EXTBAN_q,
FEAT_EXTBAN_r,
FEAT_EXTBAN_m,
FEAT_EXTBAN_M,
/* Some misc. Nefarious default paths */
FEAT_OMPATH,
FEAT_EPATH,
/* Host hiding FEAT_'s */
FEAT_HIDDEN_HOST_QUIT,
FEAT_HIDDEN_HOST_SET_MESSAGE,
FEAT_HIDDEN_HOST_UNSET_MESSAGE,
FEAT_ALLOWRMX,
FEAT_OPERHOST_HIDING,
FEAT_HIDDEN_OPERHOST,
FEAT_HOST_HIDING_STYLE,
FEAT_HOST_HIDING_PREFIX,
FEAT_HOST_HIDING_KEY1,
FEAT_HOST_HIDING_KEY2,
FEAT_HOST_HIDING_KEY3,
FEAT_HOST_HIDING_COMPONANTS,
FEAT_HOST_HIDING_COMPONENTS,
/* CTCP VERSION FEAT_'s */
FEAT_CTCP_VERSIONING,
FEAT_CTCP_VERSIONING_KILL,
FEAT_CTCP_VERSIONING_CHAN,
FEAT_CTCP_VERSIONING_CHANNAME,
FEAT_CTCP_VERSIONING_USEMSG,
FEAT_CTCP_VERSIONING_NOTICE,
FEAT_CTCP_VERSIONING_NICK,
/* GeoIP FEAT_'s */
FEAT_GEOIP_ENABLE,
FEAT_MMDB_FILE,
FEAT_GEOIP_FILE,
FEAT_GEOIP_IPV6_FILE,
/* SSL FEAT_'s */
FEAT_SSL_CERTFILE,
FEAT_SSL_KEYFILE,
FEAT_SSL_CACERTFILE,
FEAT_SSL_VERIFYCERT,
FEAT_SSL_NOSELFSIGNED,
FEAT_SSL_REQUIRECLIENTCERT,
FEAT_SSL_NOSSLV2,
FEAT_SSL_NOSSLV3,
FEAT_SSL_NOTLSV1,
FEAT_SSL_CIPHERS,
/* ZLINE FEAT_'s */
FEAT_DISABLE_ZLINES,
FEAT_HIS_ZLINE_REASON,
FEAT_ZLINEMAXUSERCOUNT,
/* CAP FEAT_'s */
FEAT_CAP_multi_prefix,
FEAT_CAP_userhost_in_names,
FEAT_CAP_extended_join,
FEAT_CAP_away_notify,
FEAT_CAP_account_notify,
FEAT_CAP_sasl,
#ifdef USE_SSL
FEAT_CAP_tls,
#endif
FEAT_UPING_ENABLE,
FEAT_UPING_PORT,
FEAT_LAST_F
};
extern void feature_init(void);
extern int feature_set(struct Client* from, const char* const* fields,
int count);
extern int feature_reset(struct Client* from, const char* const* fields,
int count);
extern int feature_get(struct Client* from, const char* const* fields,
int count);
extern void feature_unmark(void);
extern void feature_mark(void);
extern void feature_report(struct Client* to, const struct StatDesc* sd,
char* param);
extern int feature_int(enum Feature feat);
extern int feature_bool(enum Feature feat);
extern const char *feature_str(enum Feature feat);
#endif /* INCLUDED_features_h */
+21
View File
@@ -0,0 +1,21 @@
/** @file ircd_geoip.h
* @brief GeoIP routine definitions.
* @version $Id$
*/
#ifndef INCLUDED_ircd_geoip_h
#define INCLUDED_ircd_geoip_h
#include "client.h"
extern void geoip_init(void);
extern void geoip_apply(struct Client* cptr);
extern void geoip_apply_mark(struct Client* cptr, char* country, char* continent, char* countryname);
extern void geoip_handle_enable(void);
extern void geoip_handle_mmdb_file(void);
extern void geoip_handle_file(void);
extern void geoip_handle_ipv6_file(void);
extern const char* geoip_version(void);
extern const char* geoip_libmmdb_version(void);
#endif /* INCLUDED_ircd_geoip_h */
+53
View File
@@ -0,0 +1,53 @@
/*
* IRC - Internet Relay Chat, include/ircd_handler.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Message handler types and definitions.
* @version $Id: ircd_handler.h 1228 2004-10-05 04:11:36Z entrope $
*/
#ifndef INCLUDED_ircd_handler_h
#define INCLUDED_ircd_handler_h
struct Client;
/*
* MessageHandler
*/
/** Enumerated type for client message handlers. */
typedef enum HandlerType {
UNREGISTERED_HANDLER, /**< Used for unregistered clients. */
CLIENT_HANDLER, /**< Used for local users. */
SERVER_HANDLER, /**< Used for server conections. */
OPER_HANDLER, /**< Used for IRC operators. */
SERVICE_HANDLER, /**< Used for services connections. */
LAST_HANDLER_TYPE /**< NUmber of handler types. */
} HandlerType;
/**
* MessageHandler function.
* @param[in] cptr Client that sent us the message.
* @param[in] sptr Original source of message.
* @param[in] parc Number of arguments.
* @param[in] parv Argument vector.
*/
typedef int (*MessageHandler)(struct Client* cptr, struct Client* sptr, int parc, char*parv[]);
#endif /* INCLUDED_ircd_handler_h */
+157
View File
@@ -0,0 +1,157 @@
/* - Internet Relay Chat, include/ircd_log.h
* Copyright (C) 1999 Thomas Helvey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief IRC logging interface.
* @version $Id: ircd_log.h 1392 2005-05-01 16:11:01Z entrope $
*/
#ifndef INCLUDED_ircd_log_h
#define INCLUDED_ircd_log_h
#ifndef INCLUDED_stdarg_h
#include <stdarg.h> /* va_list */
#define INCLUDED_stdarg_h
#endif
#ifndef INCLUDED_stdlib_h
#include <stdlib.h> /* abort */
#define INCLUDED_stdlib_h
#endif
struct Client;
/* WARNING WARNING WARNING -- Order is important; these enums are
* used as indexes into arrays.
*/
/** Level of a log message. */
enum LogLevel {
L_CRIT, /**< Critical failure. */
L_ERROR, /**< Serious error. */
L_WARNING, /**< Recoverable warning. */
L_NOTICE, /**< Important status messages. */
L_TRACE, /**< Client exit and kill logging. */
L_INFO, /**< Logging of other operator commands. */
L_DEBUG, /**< Debug message output. */
L_LAST_LEVEL /**< Count of valid LogLevel values. */
};
/** Log systems. */
enum LogSys {
LS_SYSTEM, /**< Operational status changes. */
LS_CONFIG, /**< Configuration errors and warnings. */
LS_OPERMODE, /**< Uses of OPMODE, CLEARMODE< etc. */
LS_GLINE, /**< Adding, (de-)activating or removing GLINEs. */
LS_JUPE, /**< Adding, (de-)activating or removing JUPEs. */
LS_WHO, /**< Use of extended WHO privileges. */
LS_NETWORK, /**< New server connections. */
LS_OPERKILL, /**< Kills by IRC operators. */
LS_SERVKILL, /**< Kills by servers. */
LS_USER, /**< User exits. */
LS_OPER, /**< Users becoming operators. */
LS_RESOLVER, /**< DNS resolver errors. */
LS_SOCKET, /**< Unexpected socket operation errors. */
LS_IAUTH, /**< IAuth status. */
LS_DEBUG, /**< Debug messages. */
LS_LAST_SYSTEM /**< Count of valid LogSys values. */
};
extern void log_debug_init(int usetty);
extern void log_init(const char *process_name);
extern void log_reopen(void);
extern void log_close(void);
extern void log_write(enum LogSys subsys, enum LogLevel severity,
unsigned int flags, const char *fmt, ...);
extern void log_vwrite(enum LogSys subsys, enum LogLevel severity,
unsigned int flags, const char *fmt, va_list vl);
extern void log_write_kill(const struct Client *victim,
const struct Client *killer,
const char *inpath,
const char *path,
const char *msg);
#define LOG_NOSYSLOG 0x01 /**< Do not send message to syslog. */
#define LOG_NOFILELOG 0x02 /**< Do not send message to a log file. */
#define LOG_NOSNOTICE 0x04 /**< Do not send message via server notice. */
/** Bitmask of suppression flags for log_write() and log_vwrite(). */
#define LOG_NOMASK (LOG_NOSYSLOG | LOG_NOFILELOG | LOG_NOSNOTICE)
extern char *log_canon(const char *subsys);
extern int log_set_file(const char *subsys, const char *filename);
extern char *log_get_file(const char *subsys);
extern int log_set_facility(const char *subsys, const char *facility);
extern char *log_get_facility(const char *subsys);
extern int log_set_snomask(const char *subsys, const char *facility);
extern char *log_get_snomask(const char *subsys);
extern int log_set_level(const char *subsys, const char *level);
extern char *log_get_level(const char *subsys);
extern int log_set_default(const char *facility);
extern char *log_get_default(void);
extern void log_feature_unmark(void);
extern int log_feature_mark(int flag);
extern void log_feature_report(struct Client *to, int flag);
extern int log_inassert;
#endif /* INCLUDED_ircd_log_h */
/* The rest of this file implements our own custom version of assert.
* This version will log the assertion failure using the LS_SYSTEM log
* stream, thus putting the assertion failure message into a useful
* place, rather than elsewhere, as is currently the case...
*/
/* We've been included twice; clean up before creating assert() again */
#ifdef _ircd_log_assert
# undef _ircd_log_assert
# undef assert
#endif
/* gcc has a nice way of hinting that an expression is expected to
* produce a specific result, which can improve optimization.
* Unfortunately, all the world's not gcc (at least, not yet), and not
* all gcc's support it. I don't know exactly when it appeared, but
* it does appear to be in all versions from 3 and up. So, we'll
* create a dummy define if (we think) this version of gcc doesn't
* have it...
*/
#ifndef _log_builtin_expect
# define _log_builtin_expect
# if __GNUC__ < 3
# define __builtin_expect(expr, expect) (expr)
# endif
#endif
/* let's try not to clash with the system assert()... */
#ifndef assert
# ifdef NDEBUG
# define assert(expr) ((void)0)
# else
# define assert(expr) \
((void)(__builtin_expect(!!(expr), 1) ? 0 : \
(__builtin_expect(log_inassert, 0) ? (abort(), 0) : \
((log_inassert = 1), /* inhibit looping in assert() */ \
log_write(LS_SYSTEM, L_CRIT, 0, "Assertion failure at %s:%d: " \
"\"%s\"", __FILE__, __LINE__, #expr), abort(), 0))))
# endif
#endif
+44
View File
@@ -0,0 +1,44 @@
/*
* IRC - Internet Relay Chat, include/ircd_md5.h
*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* ircuified 2002 by hikari
*/
/** @file
* @brief MD5 implementation for ircu.
* @version $Id: ircd_md5.h 1234 2004-10-05 22:51:47Z entrope $
*/
#ifndef ircd_md5_h
#define ircd_md5_h
/** Typedef for an unsigned 32-bit integer. */
typedef unsigned int uint32;
/** MD5 context structure. */
struct MD5Context {
uint32 buf[4]; /**< Current digest state/value. */
uint32 bits[2]; /**< Number of bits hashed so far. */
unsigned char in[64]; /**< Residual input buffer. */
};
void MD5Init(struct MD5Context *);
void MD5Update(struct MD5Context *, unsigned const char *, unsigned);
void MD5Final(unsigned char digest[16], struct MD5Context *);
void MD5Transform(uint32 buf[4], uint32 const in[16]);
void DoMD5(unsigned char *mdout, unsigned char *src, unsigned long n);
char *crypt_md5(const char *pw, const char *salt);
/** Helper typedef for the MD5 context structure. */
typedef struct MD5Context MD5_CTX;
#endif /* ircd_md5_h */
+59
View File
@@ -0,0 +1,59 @@
/** @file ircd_osdep.h
* @brief Public definitions and APIs for OS-dependent operations.
* @version $Id: ircd_osdep.h 1626 2006-03-14 03:45:52Z entrope $
*/
#ifndef INCLUDED_ircd_osdep_h
#define INCLUDED_ircd_osdep_h
struct Client;
struct irc_sockaddr;
struct MsgQ;
/** Result of an input/output operation. */
typedef enum IOResult {
IO_FAILURE = -1, /**< Serious I/O error (not due to blocking). */
IO_BLOCKED = 0, /**< I/O could not start because it would block. */
IO_SUCCESS = 1 /**< I/O succeeded. */
} IOResult;
/*
* NOTE: osdep.c files should never need to know the actual size of a
* Client struct. When passed as a parameter, the pointer just needs
* to be forwarded to the enumeration function.
*/
/** Callback function to show rusage information.
* @param cptr Client to receive the message.
* @param msg Text message to send to user.
*/
typedef void (*EnumFn)(struct Client* cptr, const char* msg);
extern int os_disable_options(int fd);
extern int os_get_rusage(struct Client* cptr, int uptime, EnumFn enumerator);
extern int os_get_sockerr(int fd);
extern int os_get_sockname(int fd, struct irc_sockaddr* sin_out);
extern int os_get_peername(int fd, struct irc_sockaddr* sin_out);
extern int os_socket(const struct irc_sockaddr* local, int type, const char* port_name, int family);
extern int os_accept(int fd, struct irc_sockaddr* peer);
extern IOResult os_sendto_nonb(int fd, const char* buf, unsigned int length,
unsigned int* length_out, unsigned int flags,
const struct irc_sockaddr* peer);
extern IOResult os_recv_nonb(int fd, char* buf, unsigned int length,
unsigned int* length_out);
extern IOResult os_send_nonb(int fd, const char* buf, unsigned int length,
unsigned int* length_out);
extern IOResult os_sendv_nonb(int fd, struct MsgQ* buf,
unsigned int* len_in, unsigned int* len_out);
extern IOResult os_recvfrom_nonb(int fd, char* buf, unsigned int len,
unsigned int* length_out,
struct irc_sockaddr* from_out);
extern IOResult os_connect_nonb(int fd, const struct irc_sockaddr* sin);
extern int os_set_fdlimit(unsigned int max_descriptors);
extern int os_set_listen(int fd, int backlog);
extern int os_set_nonblocking(int fd);
extern int os_set_reuseaddr(int fd);
extern int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize);
extern int os_set_tos(int fd,int tos,int family);
extern int os_socketpair(int sv[2]);
#endif /* INCLUDED_ircd_osdep_h */
+48
View File
@@ -0,0 +1,48 @@
#ifndef INCLUDED_IRCD_RELAY_H
#define INCLUDED_IRCD_RELAY_H
/*
* IRC - Internet Relay Chat, include/ircd_relay.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface to functions for relaying messages.
* @version $Id: ircd_relay.h 1231 2004-10-05 04:21:37Z entrope $
*/
struct Client;
extern void relay_channel_message(struct Client* sptr, const char* name, const char* text, int targets);
extern void relay_channel_notice(struct Client* sptr, const char* name, const char* text, int targets);
extern void relay_directed_message(struct Client* sptr, char* name, char* server, const char* text);
extern void relay_directed_notice(struct Client* sptr, char* name, char* server, const char* text);
extern void relay_masked_message(struct Client* sptr, const char* mask, const char* text);
extern void relay_masked_notice(struct Client* sptr, const char* mask, const char* text);
extern void relay_private_message(struct Client* sptr, const char* name, const char* text);
extern void relay_private_notice(struct Client* sptr, const char* name, const char* text);
extern void server_relay_channel_message(struct Client* sptr, const char* name, const char* text);
extern void server_relay_channel_notice(struct Client* sptr, const char* name, const char* text);
extern void server_relay_masked_message(struct Client* sptr, const char* mask, const char* text);
extern void server_relay_masked_notice(struct Client* sptr, const char* mask, const char* text);
extern void server_relay_private_message(struct Client* sptr, const char* name, const char* text);
extern void server_relay_private_notice(struct Client* sptr, const char* name, const char* text);
#endif /* INCLUDED_IRCD_RELAY_H */
+36
View File
@@ -0,0 +1,36 @@
/*
* IRC - Internet Relay Chat, include/ircd_reply.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interfaces for sending common replies to users.
* @version $Id: ircd_reply.h 1224 2004-10-05 02:39:38Z entrope $
*/
#ifndef INCLUDED_ircd_reply_h
#define INCLUDED_ircd_reply_h
struct Client;
extern int protocol_violation(struct Client* cptr, const char* pattern, ...);
extern int need_more_params(struct Client* cptr, const char* cmd);
extern int send_reply(struct Client* to, int reply, ...);
#define SND_EXPLICIT 0x40000000 /**< first arg is a pattern to use */
#endif /* INCLUDED_ircd_reply_h */
+75
View File
@@ -0,0 +1,75 @@
/*
* include/ircd_reslib.h
* (C)opyright 1992 Darren Reed.
*/
/** @file
* @brief Interface from ircd resolver to its support functions.
* @version $Id: ircd_reslib.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_ircdreslib_h
#define INCLUDED_ircdreslib_h
#include <netdb.h>
/*
* Inline versions of get/put short/long. Pointer is advanced.
*/
/** Get a 16-bit network endian value from \a cp and assign to \a s. */
#define IRC_NS_GET16(s, cp) { \
const unsigned char *t_cp = (const unsigned char *)(cp); \
(s) = ((uint16_t)t_cp[0] << 8) \
| ((uint16_t)t_cp[1]) \
; \
(cp) += NS_INT16SZ; \
}
/** Get a 32-bit network endian value from \a cp and assign to \a s. */
#define IRC_NS_GET32(l, cp) { \
const unsigned char *t_cp = (const unsigned char *)(cp); \
(l) = ((uint32_t)t_cp[0] << 24) \
| ((uint32_t)t_cp[1] << 16) \
| ((uint32_t)t_cp[2] << 8) \
| ((uint32_t)t_cp[3]) \
; \
(cp) += NS_INT32SZ; \
}
/** Put \a s at \a cp as a 16-bit network endian value. */
#define IRC_NS_PUT16(s, cp) { \
uint16_t t_s = (uint16_t)(s); \
unsigned char *t_cp = (unsigned char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += NS_INT16SZ; \
}
/** Put \a s at \a cp as a 32-bit network endian value. */
#define IRC_NS_PUT32(l, cp) { \
uint32_t t_l = (uint32_t)(l); \
unsigned char *t_cp = (unsigned char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += NS_INT32SZ; \
}
/** Maximum number of nameservers to bother with. */
#define IRCD_MAXNS 8
int irc_res_init(void);
int irc_dn_expand(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, int dstsiz);
int irc_ns_name_uncompress(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, size_t dstsiz);
int irc_ns_name_unpack(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, unsigned char *dst, size_t dstsiz);
int irc_ns_name_ntop(const char *src, char *dst, size_t dstsiz);
int irc_dn_comp(const char *src, unsigned char *dst, int dstsiz, unsigned char **dnptrs, unsigned char **lastdnptr);
int irc_dn_skipname(const unsigned char *ptr, const unsigned char *eom);
int irc_ns_name_skip(const unsigned char **ptrptr, const unsigned char *eom);
unsigned int irc_ns_get16(const unsigned char *src);
unsigned long irc_ns_get32(const unsigned char *src);
void irc_ns_put16(unsigned int src, unsigned char *dst);
void irc_ns_put32(unsigned long src, unsigned char *dst);
int irc_ns_name_pton(const char *src, unsigned char *dst, size_t dstsiz);
int irc_ns_name_pack(const unsigned char *src, unsigned char *dst, int dstsiz, const unsigned char **dnptrs, const unsigned char **lastdnptr);
int irc_res_mkquery(const char *dname, int class, int type, unsigned char *buf, int buflen);
#endif /* INCLUDED_res_h */
+16
View File
@@ -0,0 +1,16 @@
/** @file ircd_signal.h
* @brief Interface to signal handler subsystem.
* @version $Id: ircd_signal.h 1618 2006-02-16 03:27:41Z entrope $
*/
#ifndef INCLUDED_ircd_signal_h
#define INCLUDED_ircd_signal_h
typedef void (*SigChldCallBack)(pid_t child_pid, void *datum, int status);
extern void setup_signals(void);
extern void register_child(pid_t child, SigChldCallBack call, void *datum);
extern void unregister_child(pid_t child);
extern void reap_children(void);
#endif /* INCLUDED_ircd_signal_h */
+321
View File
@@ -0,0 +1,321 @@
#ifndef INCLUDED_ircd_snprintf_h
#define INCLUDED_ircd_snprintf_h
/*
* IRC - Internet Relay Chat, include/ircd_snprintf.h
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief IRC-specific printf() clone interface.
* @version $Id: ircd_snprintf.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_stdarg_h
#include <stdarg.h>
#define INCLUDED_stdarg_h
#endif
struct Client;
/** structure passed as argument for %v conversion */
struct VarData {
size_t vd_chars; /**< number of characters inserted */
size_t vd_overflow; /**< number of characters that couldn't be */
const char *vd_format; /**< format string */
va_list vd_args; /**< arguments for %v */
};
#ifndef HAVE_VA_COPY
#if HAVE___VA_COPY
#define va_copy(DEST, SRC) __va_copy(DEST, SRC)
#else
/** Fallback macro to copy to \a DEST from \a SRC. */
#define va_copy(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof(DEST))
#endif
#endif
extern int ircd_snprintf(struct Client *dest, char *buf, size_t buf_len,
const char *format, ...);
extern int ircd_vsnprintf(struct Client *dest, char *buf, size_t buf_len,
const char *format, va_list args);
/** @fn int ircd_snprintf(struct Client *dest, char *buf, size_t
buf_len, const char *format, ...)
**
** These functions are intended to be a complete replacement for
** sprintf and sprintf_irc. They are a (nearly) complete
** reimplementation, and of course they're snprintf clones, making it
** more difficult for accidental buffer overflows to crop up.
**
** First off, what's missing? These functions support all ANSI C
** conversion specifiers and selected ones from ISO 9x, with the
** exception of all floating-point conversions. The floating-point
** conversions are tricky, and will likely be dependent on the
** representation of a floating-point number on a particular
** architecture. While that representation is likely to conform to
** some standard, it is not currently used in ircu, so seemed like a
** good thing to omit, given the difficulty of implementing it.
**
** There are two more things missing from this implementation that
** would be required by ANSI; the first is support for multibyte
** character strings, and the second is support for locales, neither
** of which have any relevance for ircu, so again omission seemed to
** be a good policy. Additionally, %#x always causes '0x' (or '0X')
** to be printed, even if the number is zero.
**
** These functions also have some extensions not seen in a
** standards-compliant implementation; technically, the ISO 9x
** extensions fall into this category, for instance. The ISO 9x
** extensions supported are type extensions--%ju, %tu, and %zu, for
** instance; %qu and %hhu are also supported. The extensions added
** for use in ircu are %Tu, which takes a time_t, and the new %C
** conversion, which inserts either a numeric or a nick, dependant on
** the &lt;dest> parameter. The GNU %m extension, which inserts the
** strerror() string corresponding to the current value of errno, is
** also supported, as is a special %v extension, which essentially
** does a recursive call to ircd_snprintf.
**
** The following description is descended from the Linux manpage for
** the printf family of functions.
**
** The format string is composed of zero or more directives:
** ordinary characters (not %), which are copied unchanged to the
** output stream; and conversion specifications, each of which results
** in fetching zero or more subsequent arguments. Each conversion
** specification is introduced by the character %. The arguments must
** correspond properly (after type promotion) with the conversion
** specifier. After the %, the following appear in sequence:
**
** <ul><li>Zero or more of the following flags:<dl>
**
** <dt>#</dt>
** <dd>specifying that the value should be converted to an
** "alternate form." For c, d, i, n, p, s, and u conversions,
** this option has no effect. For o conversions, the precision
** of the number is increased to force the first character of the
** output string to a zero (except if a zero value is printed
** with an explicit precision of zero). For x and X conversions,
** the string '0x' (or '0X' for X conversions) is prepended to
** it. For e, E, f, g, and G conversions, the result will always
** contain a decimal point, even if no digits follow it
** (normally, a decimal point appears in the results of those
** conversions only if a digit follows). For g and G
** conversions, trailing zeros are not removed from the result as
** they would otherwise be. For C conversions, if the
** destination is local and the origin is a user, the
** nick!user\@host form is used.</dd>
**
** <dt>0</dt>
** <dd> specifying zero padding. For all conversions except n, the
** converted value is padded on the left with zeros rather than
** blanks. If a precision is given with a numeric conversion (d,
** i, o, u, i, x, and X), the 0 flag is ignored.</dd>
**
** <dt>-</dt>
** <dd>(a negative field width flag) indicates the converted value is
** to be left adjusted on the field boundary. Except for n
** conversions, the converted value is padded on the right with
** blanks, rather than on the left with blanks or zeros. A -
** overrides a 0 if both are given.</dd>
**
** <dt>' ' (a space)</dt>
** <dd>specifying that a blank should be left before a
** positive number produced by a signed conversion (d, e, E, f,
** g, G, or i).</dd>
**
** <dt>+</dt>
** <dd>specifying that a sign always be placed before a number
** produced by a signed conversion. A + overrides a space if
** both are used.</dd>
**
** <dt>:</dt>
** <dd>specifying that a struct Client name should be preceded by a
** ':' character if the destination is a user.</dd>
** </dl></li>
**
** <li>An optional decimal digit string specifying a minimum field
** width. If the converted value has fewer characters than the
** field width, it will be padded with spaces on the left (or right,
** if the left-adjustment flag has been given) to fill out the field
** width.</li>
**
** <li>An optional precision, in the form of a period (`.') followed by
** an optional digit string. If the digit string is omitted, the
** precision is taken as zero. This gives the minimum number of
** digits to appear for d, i, o, u, x, and X conversions, the number
** of digits to appear after the decimal-point for e, E, and f
** conversions, the maximum number of significant digits for g and G
** conversions, or the maximum number of characters to be printed
** from a string for s conversions.</li>
**
** <li>The optional character h, specifying that a following d, i, o, u,
** x, or X conversion corresponds to a short int or unsigned short
** int argument, or that a following n conversion corresponds to a
** pointer to a short int argument. If the h character is given
** again, char is used instead of short int.</li>
**
** <li>The optional character l (ell) specifying that a following d, i,
** o, u, x, or X conversion applies to a pointer to a long int or
** unsigned long int argument, or that a following n conversion
** corresponds to a pointer to a long int argument.</li>
**
** <li>The character L specifying that a following e, E, f, g, or G
** conversion corresponds to a long double argument, or a following
** d, i, o, u, x, or X conversion corresponds to a long long
** argument. Note that long long is not specified in ANSI C and
** therefore not portable to all architectures.</li>
**
** <li>The optional character q. This is equivalent to L.</li>
**
** <li>A j character specifying that the following integer (d, i, o, u,
** x, or X) conversion corresponds to an intmax_t argument.</li>
**
** <li>A t character specifying that the following integer (d, i, o, u,
** x, or X) conversion corresponds to a ptrdiff_t argument.</li>
**
** <li>A z character specifying that the following integer (d, i, o, u,
** x, or X) conversion corresponds to a size_t argument.</li>
**
** <li>A T character specifying that the following integer (d, i, o, u,
** x, or X) conversion corresponds to a time_t argument.</li>
**
** <li>A character that specifies the type of conversion to be applied.</li>
** </ul>
**
** A field width or precision, or both, may be indicated by an
** asterisk `*' instead of a digit string. In this case, an int
** argument supplies the field width or precision. A negative field
** width is treated as a left adjustment flag followed by a positive
** field width; a negative precision is treated as though it were
** missing.
**
** The conversion specifiers and their meanings are:
**
** <dl>
** <dt>diouxX</dt>
** <dd>The int (or appropriate variant) argument is converted
** to signed decimal (d and i), unsigned octal (o),
** unsigned decimal (u), or unsigned hexadecimal (x and
** X) notation. The letters abcdef are used for x
** conversions; the letters ABCDEF are used for X
** conversions. The precision, if any, gives the minimum
** number of digits that must appear; if the converted
** value requires fewer digits, it is padded on the left
** with zeros.</dd>
**
** <dt>eE [NOT IMPLEMENTED]</dt>
** <dd>The double argument is rounded and
** converted in the style [-]d.dddedd where there is one
** digit before the decimal-point character and the
** number of digits after it is equal to the precision;
** if the precision is missing, it is taken as 6; if the
** precision is zero, no decimal-point character appears.
** An E conversion uses the letter E (rather than e) to
** introduce the exponent. The exponent always contains
** at least two digits; if the value is zero, the
** exponent is 00.</dd>
**
** <dt>f [NOT IMPLEMENTED]</dt>
** <dd>The double argument is rounded and
** converted to decimal notation in the style
** [-]ddd.ddd, where the number of digits after the
** decimal-point character is equal to the precision
** specification. If the precision is missing, it is
** taken as 6; if the precision is explicitly zero, no
** decimal-point character appears. If a decimal point
** appears, at least one digit appears before it.</dd>
**
** <dt>g [NOT IMPLEMENTED]</dt>
** <dd>The double argument is converted in
** style f or e (or E for G conversions). The precision
** specifies the number of significant digits. If the
** precision is missing, 6 digits are given; if the
** precision is zero, it is treated as 1. Style e is
** used if the exponent from its conversion is less than
** -4 or greater than or equal to the precision.
** Trailing zeros are removed from the fractional part of
** the result; a decimal point appears only if it is
** followed by at least one digit.</dd>
**
** <dt>c</dt>
** <dd>The int argument is converted to an unsigned char, and
** the resulting character is written.</dd>
**
** <dt>s</dt>
** <dd>The "char *" argument is expected to be a pointer to
** an array of character type (pointer to a string).
** Characters from the array are written up to (but not
** including) a terminating NUL character; if a precision
** is specified, no more than the number specified are
** written. If a precision is given, no null character
** need be present; if the precision is not specified, or
** is greater than the size of the array, the array must
** contain a terminating NUL character.</dd>
**
** <dt>p</dt>
** <dd>The "void *" pointer argument is printed in
** hexadecimal (as if by %#x or %#lx).</dd>
**
** <dt>n</dt>
** <dd>The number of characters written so far is stored into
** the integer indicated by the ``int *'' (or variant)
** pointer argument. No argument is converted.</dd>
**
** <dt>m</dt>
** <dd>The error message associated with the current value of
** errno is printed as if by %s.</dd>
**
** <dt>C</dt>
** <dd>The client argument identifier is printed under the
** control of the &lt;dest> argument; if &lt;dest> is NULL or
** is a user, the client's name (nickname or server name)
** is printed; otherwise, the client's network numeric is
** printed.</dd>
**
** <dt>H</dt>
** <dd>The channel argument identifier (channel name) is
** printed.</dd>
**
** <dt>v</dt>
** <dd>The argument given must be a pointer to a struct
** VarData with vd_format and vd_args must be initialized
** appropriately. On return, vd_chars will contain the
** number of characters added to the buffer, and
** vd_overflow will contain the number of characters that
** could not be added due to buffer overflow or due to a
** precision.</dd>
**
** <dt>%<dt>
** <dd>A `%' is written. No argument is converted. The
** complete conversion specification is `%%'.</dd>
** </dl>
**
** In no case does a non-existent or small field width cause
** truncation of a field; if the result of a conversion is wider than
** the field width, the field is expanded to contain the conversion
** result.
**
** @param[in] dest Client receiving of message.
** @param[out] buf Output buffer for formatted message.
** @param[in] buf_len Number of bytes that can be written to \a buf.
** @param[in] format Format string for message.
** @return Number of bytes that would be written to \a buf without truncation.
*/
#endif /* INCLUDED_ircd_snprintf_h */
+143
View File
@@ -0,0 +1,143 @@
/** @file ircd_string.h
* @brief Public declarations and APIs for string operations.
* @version $Id: ircd_string.h 1478 2005-09-12 03:40:17Z entrope $
*/
#ifndef INCLUDED_ircd_string_h
#define INCLUDED_ircd_string_h
#include <string.h> /* for DupString()'s strcpy, strlen */
#ifndef INCLUDED_ircd_chattr_h
#include "ircd_chattr.h"
#endif
struct irc_in_addr;
/*
* Macros
*/
/** Check whether \a x is a NULL or empty string. */
#define EmptyString(x) (!(x) || !(*x))
extern int string_has_wildcards(const char* str);
extern int string_is_valid_utf8(const char* str);
extern int string_contains_non_ascii (const char* str);
extern int string_character_structure_is_sane(const char* str);
extern char* ircd_strncpy(char* dest, const char* src, size_t len);
extern int ircd_strcmp(const char *a, const char *b);
extern int ircd_strncmp(const char *a, const char *b, size_t n);
extern int unique_name_vector(char* names, char token,
char** vector, int size);
extern int token_vector(char* names, char token,
char** vector, int size);
extern const char* ircd_ntoa(const struct irc_in_addr* addr);
extern const char* ircd_ntoa_r(char* buf, const struct irc_in_addr* addr);
#define ircd_aton(ADDR, STR) ipmask_parse((STR), (ADDR), NULL)
extern int ipmask_parse(const char *in, struct irc_in_addr *mask, unsigned char *bits_ptr);
extern char* host_from_uh(char* buf, const char* userhost, size_t len);
extern char* ircd_strtok(char** save, char* str, char* fs);
extern char* canonize(char* buf);
extern char* itoa(int n);
extern unsigned long ParseInterval(const char *interval);
extern int is_timestamp(char *str);
extern const char* StripColor(const char* text);
extern int HasColor(const char* text);
extern int check_if_ipmask(const char *mask);
extern int valid_username(const char* name);
extern int valid_hostname(const char* name);
#define COLOR_BOLD 2 /**< Bold text */
#define COLOR_COLOR 3 /**< Color text */
#define COLOR_ITALIC 29 /**< Italic text */
#define COLOR_NORMAL 15 /**< Normal text */
#define COLOR_REVERSE 22 /**< Reverse text */
#define COLOR_UNDERLINE 31 /**< Underlined text */
/** Make \a y a duplicate \a x, a la strdup(). */
#define DupString(x, y) (strcpy((x = (char*) MyMalloc(strlen(y) + 1)), y))
/* String classification pseudo-functions, when others are needed add them,
strIsXxxxx(s) is true when IsXxxxx(c) is true for every char in s */
/** Test whether all characters in \a s are alphanumeric. */
#define strIsAlnum(s) (strChattr(s) & NTL_ALNUM)
/** Test whether all characters in \a s are alphabetic. */
#define strIsAlpha(s) (strChattr(s) & NTL_ALPHA)
/** Test whether all characters in \a s are digits. */
#define strIsDigit(s) (strChattr(s) & NTL_DIGIT)
/** Test whether all characters in \a s are lower case. */
#define strIsLower(s) (strChattr(s) & NTL_LOWER)
/** Test whether all characters in \a s are whitespace. */
#define strIsSpace(s) (strChattr(s) & NTL_SPACE)
/** Test whether all characters in \a s are upper case. */
#define strIsUpper(s) (strChattr(s) & NTL_UPPER)
/** Test whether all characters in \a s are channel name characters. */
#define strIsIrcCh(s) (strChattr(s) & NTL_IRCCH)
/** Test whether all characters in \a s are forced to lower-case in channel names. */
#define strIsIrcCl(s) (strChattr(s) & NTL_IRCCL)
/** Test whether all characters in \a s are valid in nicknames. */
#define strIsIrcNk(s) (strChattr(s) & NTL_IRCNK)
/** Test whether all characters in \a s are valid in a user field. */
#define strIsIrcUi(s) (strChattr(s) & NTL_IRCUI)
/** Test whether all characters in \a s are valid in host names. */
#define strIsIrcHn(s) (strChattr(s) & NTL_IRCHN)
/** Test whether all characters in \a s are valid in IP addresses. */
#define strIsIrcIp(s) (strChattr(s) & NTL_IRCIP)
/*
* Critical small functions to inline even in separate compilation
* when FORCEINLINE is defined (provided you have a compiler that supports
* `inline').
*/
/** Declaration for strChattr(). */
#define NTL_HDR_strChattr unsigned int strChattr(const char *s)
/** Body for strChattr(). */
#define NTL_SRC_strChattr const char *rs = s; \
unsigned int x = ~0; \
while(*rs) \
x &= IRCD_CharAttrTab[*rs++ - CHAR_MIN]; \
return x;
/*
* XXX - bleah should return 1 if different 0 if the same
*/
/** Declaration for strCasediff(). */
#define NTL_HDR_strCasediff int strCasediff(const char *a, const char *b)
/** Body for strCasediff(). */
#define NTL_SRC_strCasediff const char *ra = a; \
const char *rb = b; \
while(ToLower(*ra) == ToLower(*rb++)) \
if(!*ra++) \
return 0; \
return 1;
#ifndef FORCEINLINE
extern NTL_HDR_strChattr;
extern NTL_HDR_strCasediff;
#else /* FORCEINLINE */
#ifdef __cplusplus
inline NTL_HDR_strChattr { NTL_SRC_strChattr }
inline NTL_HDR_strCasediff { NTL_SRC_strCasediff }
#else
static __inline__ NTL_HDR_strChattr { NTL_SRC_strChattr }
static __inline__ NTL_HDR_strCasediff { NTL_SRC_strCasediff }
#endif
#endif /* FORCEINLINE */
#endif /* INCLUDED_ircd_string_h */
+87
View File
@@ -0,0 +1,87 @@
#ifndef INCLUDED_jupe_h
#define INCLUDED_jupe_h
/*
* IRC - Internet Relay Chat, include/jupe.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface and declarations for juped server handling.
* @version $Id: jupe.h 1208 2004-10-03 14:12:35Z entrope $
*/
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
struct Client;
#define JUPE_MAX_EXPIRE 604800 /**< Maximum jupe expiration time (7 days). */
/** Describes a juped server.
* A hub will not accept new connections from a juped server.
*/
struct Jupe {
struct Jupe* ju_next; /**< Pointer to next Jupe. */
struct Jupe** ju_prev_p; /**< Pointer to previous next pointer. */
char* ju_server; /**< Name of server to jupe. */
char* ju_reason; /**< Reason for the jupe. */
time_t ju_expire; /**< Expiration time of the jupe. */
time_t ju_lastmod; /**< Last modification time (if any) for the jupe. */
unsigned int ju_flags; /**< Status flags for the jupe. */
};
#define JUPE_ACTIVE 0x0001 /**< Jupe is globally active. */
#define JUPE_LOCAL 0x0002 /**< Jupe only applies to this server. */
#define JUPE_LDEACT 0x0004 /**< Jupe is locally deactivated */
#define JUPE_MASK (JUPE_ACTIVE | JUPE_LOCAL)
#define JUPE_ACTMASK (JUPE_ACTIVE | JUPE_LDEACT)
/** Test whether \a j is active. */
#define JupeIsActive(j) (((j)->ju_flags & JUPE_ACTMASK) == JUPE_ACTIVE)
/** Test whether \a j is globally (remotely) active. */
#define JupeIsRemActive(j) ((j)->ju_flags & JUPE_ACTIVE)
/** Test whether \a j is local. */
#define JupeIsLocal(j) ((j)->ju_flags & JUPE_LOCAL)
/** Get the server name for \a j. */
#define JupeServer(j) ((j)->ju_server)
/** Get the reason fro \a j. */
#define JupeReason(j) ((j)->ju_reason)
/** Get the last modification time for \a j. */
#define JupeLastMod(j) ((j)->ju_lastmod)
extern int jupe_add(struct Client *cptr, struct Client *sptr, char *server,
char *reason, time_t expire, time_t lastmod,
unsigned int flags);
extern int jupe_activate(struct Client *cptr, struct Client *sptr,
struct Jupe *jupe, time_t lastmod,
unsigned int flags);
extern int jupe_deactivate(struct Client *cptr, struct Client *sptr,
struct Jupe *jupe, time_t lastmod,
unsigned int flags);
extern struct Jupe* jupe_find(char *server);
extern void jupe_free(struct Jupe *jupe);
extern void jupe_burst(struct Client *cptr);
extern int jupe_resend(struct Client *cptr, struct Jupe *jupe);
extern int jupe_list(struct Client *sptr, char *server);
extern int jupe_memory_count(size_t *ju_size);
#endif /* INCLUDED_jupe_h */
+65
View File
@@ -0,0 +1,65 @@
/** @file list.h
* @brief Singly and doubly linked list manipulation interface.
* @version $Id: list.h 1417 2005-05-30 21:07:33Z entrope $
*/
#ifndef INCLUDED_list_h
#define INCLUDED_list_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* time_t, size_t */
#define INCLUDED_sys_types_h
#endif
struct Client;
struct Connection;
struct Channel;
struct ConfItem;
struct Watch;
/*
* Structures
*/
/** Node in a singly linked list. */
struct SLink {
struct SLink *next; /**< Next element in list. */
union {
struct Client *cptr; /**< List element as a client. */
struct Channel *chptr; /**< List element as a channel. */
struct ConfItem *aconf; /**< List element as a configuration item. */
struct Watch *wptr; /**< List element as a watch. */
char *cp; /**< List element as a string. */
} value; /**< Value of list element. */
unsigned int flags; /**< Modifier flags for list element. */
};
/** Node in a doubly linked list. */
struct DLink {
struct DLink* next; /**< Next element in list. */
struct DLink* prev; /**< Previous element in list. */
union {
struct Client* cptr; /**< List element as a client. */
struct Channel* chptr; /**< List element as a channel. */
char* ch; /**< List element as a string. */
} value; /**< Value of list element. */
};
/*
* Proto types
*/
extern void free_link(struct SLink *lp);
extern struct SLink *make_link(void);
extern void init_list(void);
extern struct Client *make_client(struct Client *from, int status);
extern void free_connection(struct Connection *con);
extern void free_client(struct Client *cptr);
extern struct Server *make_server(struct Client *cptr);
extern void remove_client_from_list(struct Client *cptr);
extern void add_client_to_list(struct Client *cptr);
extern struct DLink *add_dlink(struct DLink **lpp, struct Client *cp);
extern void remove_dlink(struct DLink **lpp, struct DLink *lp);
extern struct ConfItem *make_conf(int type);
extern void free_conf(struct ConfItem *aconf);
extern void send_listinfo(struct Client *cptr, char *name);
#endif /* INCLUDED_list_h */
+96
View File
@@ -0,0 +1,96 @@
/* - Internet Relay Chat, include/listener.h
* Copyright (C) 1999 Thomas Helvey <tomh@inxpress.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface and declarations for handling listening sockets.
* @version $Id: listener.h 1732 2006-12-07 05:14:51Z entrope $
*/
#ifndef INCLUDED_listener_h
#define INCLUDED_listener_h
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h" /* HOSTLEN */
#endif
#ifndef INCLUDED_ircd_events_h
#include "ircd_events.h"
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
#ifndef INCLUDED_client_h
#include "client.h" /* flagset stuff. oh well. */
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* size_t, broken BSD system headers */
#define INCLUDED_sys_types_h
#endif
struct Client;
struct StatDesc;
enum ListenerFlag {
/** Port is currently accepting connections. */
LISTEN_ACTIVE,
/** Port is hidden from /STATS P output. */
LISTEN_HIDDEN,
/** Port accepts only server connections. */
LISTEN_SERVER,
/** Port listens for IPv4 connections. */
LISTEN_IPV4,
/** Port listens for IPv6 connections. */
LISTEN_IPV6,
/** Port is SSL enabled. */
LISTEN_SSL,
/** Sentinel for counting listener flags. */
LISTEN_LAST_FLAG
};
DECLARE_FLAGSET(ListenerFlags, LISTEN_LAST_FLAG);
/** Describes a single listening port. */
struct Listener {
struct Listener* next; /**< list node pointer */
struct ListenerFlags flags; /**< on-off flags for listener */
int fd_v4; /**< file descriptor for IPv4 */
int fd_v6; /**< file descriptor for IPv6 */
int ref_count; /**< number of connection references */
unsigned char mask_bits; /**< number of bits in mask address */
int index; /**< index into poll array */
time_t last_accept; /**< last time listener accepted */
struct irc_sockaddr addr; /**< virtual address and port */
struct irc_in_addr mask; /**< listener hostmask */
struct Socket socket_v4; /**< describe IPv4 socket to event system */
struct Socket socket_v6; /**< describe IPv6 socket to event system */
};
#define listener_server(LISTENER) FlagHas(&(LISTENER)->flags, LISTEN_SERVER)
#define listener_active(LISTENER) FlagHas(&(LISTENER)->flags, LISTEN_ACTIVE)
#define listener_ssl(LISTENER) FlagHas(&(LISTENER)->flags, LISTEN_SSL)
extern void add_listener(int port, const char* vaddr_ip,
const char* mask,
const struct ListenerFlags *flags);
extern void close_listener(struct Listener* listener);
extern void close_listeners(void);
extern void count_listener_memory(int* count_out, size_t* size_out);
extern const char* get_listener_name(const struct Listener* listener);
extern void mark_listeners_closing(void);
extern void show_ports(struct Client* client, const struct StatDesc* sd,
char* param);
extern void release_listener(struct Listener* listener);
#endif /* INCLUDED_listener_h */
+37
View File
@@ -0,0 +1,37 @@
/*
* IRC - Internet Relay Chat, include/mark.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 2005 Neil Spierling <sirvulcan@sirvulcan.co.nz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file mark.h
* @brief Mark define's.
* @version $Id: mark.h 2669 2009-11-09 02:53:31Z jobe1986 $
*/
#ifndef INCLUDED_mark_h
#define INCLUDED_mark_h
#define MARK_WEBIRC "WEBIRC" /**< WEBIRC mark. */
#define MARK_GEOIP "GEOIP" /**< GEOIP mark. */
#define MARK_CVERSION "CVERSION" /**< Client Version mark */
#define MARK_SSLCLIFP "SSLCLIFP" /**< SSL client certificate fingerprint */
#define MARK_DNSBL_DATA "DNSBL_DATA" /**< Alias to MARK */
#define MARK_MARK "MARK" /**< List of single word tags */
#define MARK_KILL "KILL" /**< KILL block exemption mark */
#endif /* INCLUDED_mark_h */
+35
View File
@@ -0,0 +1,35 @@
/** @file match.h
* @brief Interface for matching strings to IRC masks.
* @version $Id: match.h 1478 2005-09-12 03:40:17Z entrope $
*/
#ifndef INCLUDED_match_h
#define INCLUDED_match_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* XXX - broken BSD system headers */
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
/*
* Prototypes
*/
/*
* XXX - match returns 0 if a match is found. Smelly interface
* needs to be fixed. --Bleep
*/
extern int mmatch(const char *old_mask, const char *new_mask);
extern int match(const char *ma, const char *na);
extern char *collapse(char *pattern);
extern int matchcomp(char *cmask, int *minlen, int *charset, const char *mask);
extern int matchexec(const char *string, const char *cmask, int minlen);
extern int matchdecomp(char *mask, const char *cmask);
extern int mmexec(const char *wcm, int wminlen, const char *rcm, int rminlen);
extern int ipmask_check(const struct irc_in_addr *addr, const struct irc_in_addr *mask, unsigned char bits);
extern struct irc_in_addr ipmask_clean(struct irc_in_addr *mask, unsigned char bits);
#endif /* INCLUDED_match_h */
+8
View File
@@ -0,0 +1,8 @@
/* This file should only ever be included from ircd_alloc.h */
void *dbg_malloc(size_t size, const char *type, const char *file, int line);
void *dbg_malloc_zero(size_t size, const char *type, const char *file, int line);
void *dbg_realloc(void *ptr, size_t size, const char *file, int line);
void dbg_free(void *ptr, const char *file, int line);
size_t fda_get_byte_count(void);
size_t fda_get_block_count(void);
+117
View File
@@ -0,0 +1,117 @@
#ifndef INCLUDED_motd_h
#define INCLUDED_motd_h
/*
* IRC - Internet Relay Chat, include/motd.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Message-of-the-day manipulation interface and declarations.
* @version $Id: motd.h 1248 2004-10-17 01:58:17Z entrope $
*/
#ifndef INCLUDED_time_h
#include <time.h> /* struct tm */
#define INCLUDED_time_h
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_res_H
#include "res.h"
#endif
struct Client;
struct TRecord;
struct StatDesc;
/** Type of MOTD. */
enum MotdType {
MOTD_UNIVERSAL, /**< MOTD for all users */
MOTD_HOSTMASK, /**< MOTD selected by hostmask */
MOTD_IPMASK, /**< MOTD selected by IP mask */
MOTD_CLASS, /**< MOTD selected by connection class */
MOTD_COUNTRY, /**< MOTD selected by country code */
MOTD_CONTINENT, /**< MOTD selected by continent code */
MOTD_OPER, /**< MOTD for OPERMOTD */
MOTD_RULES /**< MOTD for RULES (OK it's actually the RULES file but it makes more sense to make use fo the MOTD system) */
};
/** Entry for a single Message Of The Day (MOTD). */
struct Motd {
struct Motd* next; /**< Next MOTD in the linked list. */
enum MotdType type; /**< Type of MOTD. */
char* hostmask; /**< Hostmask if type==MOTD_HOSTMASK,
class name if type==MOTD_CLASS,
text IP mask if type==MOTD_IPMASK. */
struct irc_in_addr address; /**< Address if type==MOTD_IPMASK. */
unsigned char addrbits; /**< Number of bits checked in Motd::address. */
char* path; /**< Pathname of MOTD file. */
int maxcount; /**< Number of lines for MOTD. */
struct MotdCache* cache; /**< MOTD cache entry. */
};
/** Length of one MOTD line(80 chars + '\\0'). */
#define MOTD_LINESIZE 81
/** Maximum number of lines for local MOTD */
#define MOTD_MAXLINES 100
/** Maximum number of lines for remote MOTD */
#define MOTD_MAXREMOTE 3
/** Cache entry for the contents of a MOTD file. */
struct MotdCache {
struct MotdCache* next; /**< Next MotdCache in list. */
struct MotdCache** prev_p; /**< Pointer to previous node's next pointer. */
int ref; /**< Number of references to this entry. */
char* path; /**< Pathname of file. */
int maxcount; /**< Number of lines allocated for message. */
struct tm modtime; /**< Last modification time from file. */
int count; /**< Actual number of lines used in message. */
char motd[1][MOTD_LINESIZE]; /**< Message body. */
};
/* motd_send sends a MOTD off to a user */
int motd_send(struct Client* cptr);
/* motd_send_type sends the MOTD of the specified type off to a user */
int motd_send_type(struct Client* cptr, int type);
/* motd_signon sends a MOTD off to a newly-registered user */
void motd_signon(struct Client* cptr);
/* motd_recache causes all the MOTD caches to be cleared */
void motd_recache(void);
/* motd_init initializes the MOTD routines, including reading the
* ircd.motd and remote.motd files into cache
*/
void motd_init(void);
/* This routine adds a MOTD */
void motd_add(const char *hostmask, const char *path, int type);
/* This routine clears the list of MOTDs */
void motd_clear(void);
/* This is called to report T-lines */
void motd_report(struct Client *to, const struct StatDesc *sd,
char *param);
void motd_memory_count(struct Client *cptr);
#endif /* INCLUDED_motd_h */
+542
View File
@@ -0,0 +1,542 @@
/*
* IRC - Internet Relay Chat, include/msg.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Command and token declarations and structures.
* @version $Id: msg.h 1925 2010-01-02 20:33:10Z klmitch $
*/
#ifndef INCLUDED_msg_h
#define INCLUDED_msg_h
#ifndef INCLUDED_ircd_handler_h
#include "ircd_handler.h"
#endif
struct Client;
/*
* General defines
*/
#define MAXPARA 15
/*-----------------------------------------------------------------------------
* Macros
*/
/*
* Tokenization:
* Each command must have a TOK_COMMAND and MSG_COMMAND definition.
* If you don't want one or the other, make them the same.
* Also each command has a "msgclass" used for debugging purposes.
*/
/* *INDENT-OFF* */
#define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define TOK_PRIVATE "P"
#define CMD_PRIVATE MSG_PRIVATE, TOK_PRIVATE
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "H"
#define CMD_WHO MSG_WHO, TOK_WHO
#define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "W"
#define CMD_WHOIS MSG_WHOIS, TOK_WHOIS
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "X"
#define CMD_WHOWAS MSG_WHOWAS, TOK_WHOWAS
#define MSG_USER "USER" /* USER */
#define TOK_USER "USER"
#define CMD_USER MSG_USER, TOK_USER
#define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "N"
#define CMD_NICK MSG_NICK, TOK_NICK
#define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "S"
#define CMD_SERVER MSG_SERVER, TOK_SERVER
#define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "LIST"
#define CMD_LIST MSG_LIST, TOK_LIST
#define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC "T"
#define CMD_TOPIC MSG_TOPIC, TOK_TOPIC
#define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "I"
#define CMD_INVITE MSG_INVITE, TOK_INVITE
#define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "V"
#define CMD_VERSION MSG_VERSION, TOK_VERSION
#define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "Q"
#define CMD_QUIT MSG_QUIT, TOK_QUIT
#define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "SQ"
#define CMD_SQUIT MSG_SQUIT, TOK_SQUIT
#define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "D"
#define CMD_KILL MSG_KILL, TOK_KILL
#define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "F"
#define CMD_INFO MSG_INFO, TOK_INFO
#define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "LI"
#define CMD_LINKS MSG_LINKS, TOK_LINKS
#define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "R"
#define CMD_STATS MSG_STATS, TOK_STATS
#define MSG_HELP "HELP" /* HELP */
#define TOK_HELP "HELP"
#define CMD_HELP MSG_HELP, TOK_HELP
#define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "Y"
#define CMD_ERROR MSG_ERROR, TOK_ERROR
#define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "A"
#define CMD_AWAY MSG_AWAY, TOK_AWAY
#define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "CO"
#define CMD_CONNECT MSG_CONNECT, TOK_CONNECT
#define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "MAP"
#define CMD_MAP MSG_MAP, TOK_MAP
#define MSG_PING "PING" /* PING */
#define TOK_PING "G"
#define CMD_PING MSG_PING, TOK_PING
#define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "Z"
#define CMD_PONG MSG_PONG, TOK_PONG
#define MSG_OPER "OPER" /* OPER */
#define TOK_OPER "OPER"
#define CMD_OPER MSG_OPER, TOK_OPER
#define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "PA"
#define CMD_PASS MSG_PASS, TOK_PASS
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "WA"
#define CMD_WALLOPS MSG_WALLOPS, TOK_WALLOPS
#define MSG_WALLUSERS "WALLUSERS" /* WALL */
#define TOK_WALLUSERS "WU"
#define CMD_WALLUSERS MSG_WALLUSERS, TOK_WALLUSERS
#define MSG_DESYNCH "DESYNCH" /* DESY */
#define TOK_DESYNCH "DS"
#define CMD_DESYNCH MSG_DESYNCH, TOK_DESYNCH
#define MSG_TIME "TIME" /* TIME */
#define TOK_TIME "TI"
#define CMD_TIME MSG_TIME, TOK_TIME
#define MSG_SETTIME "SETTIME" /* SETT */
#define TOK_SETTIME "SE"
#define CMD_SETTIME MSG_SETTIME, TOK_SETTIME
#define MSG_RPING "RPING" /* RPIN */
#define TOK_RPING "RI"
#define CMD_RPING MSG_RPING, TOK_RPING
#define MSG_RPONG "RPONG" /* RPON */
#define TOK_RPONG "RO"
#define CMD_RPONG MSG_RPONG, TOK_RPONG
#define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "E"
#define CMD_NAMES MSG_NAMES, TOK_NAMES
#define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "AD"
#define CMD_ADMIN MSG_ADMIN, TOK_ADMIN
#define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "TR"
#define CMD_TRACE MSG_TRACE, TOK_TRACE
#define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "O"
#define CMD_NOTICE MSG_NOTICE, TOK_NOTICE
#define MSG_WALLCHOPS "WALLCHOPS" /* WC */
#define TOK_WALLCHOPS "WC"
#define CMD_WALLCHOPS MSG_WALLCHOPS, TOK_WALLCHOPS
#define MSG_WALLVOICES "WALLVOICES" /* WV */
#define TOK_WALLVOICES "WV"
#define CMD_WALLVOICES MSG_WALLVOICES, TOK_WALLVOICES
#define MSG_CPRIVMSG "CPRIVMSG" /* CPRI */
#define TOK_CPRIVMSG "CP"
#define CMD_CPRIVMSG MSG_CPRIVMSG, TOK_CPRIVMSG
#define MSG_CNOTICE "CNOTICE" /* CNOT */
#define TOK_CNOTICE "CN"
#define CMD_CNOTICE MSG_CNOTICE, TOK_CNOTICE
#define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "J"
#define CMD_JOIN MSG_JOIN, TOK_JOIN
#define MSG_PART "PART" /* PART */
#define TOK_PART "L"
#define CMD_PART MSG_PART, TOK_PART
#define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "LU"
#define CMD_LUSERS MSG_LUSERS, TOK_LUSERS
#define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "MO"
#define CMD_MOTD MSG_MOTD, TOK_MOTD
#define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "M"
#define CMD_MODE MSG_MODE, TOK_MODE
#define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "K"
#define CMD_KICK MSG_KICK, TOK_KICK
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "USERHOST"
#define CMD_USERHOST MSG_USERHOST, TOK_USERHOST
#define MSG_USERIP "USERIP" /* USER -> USIP */
#define TOK_USERIP "USERIP"
#define CMD_USERIP MSG_USERIP, TOK_USERIP
#define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "ISON"
#define CMD_ISON MSG_ISON, TOK_ISON
#define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "SQUERY"
#define CMD_SQUERY MSG_SQUERY, TOK_SQUERY
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "SERVLIST"
#define CMD_SERVLIST MSG_SERVLIST, TOK_SERVLIST
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "SERVSET"
#define CMD_SERVSET MSG_SERVSET, TOK_SERVSET
#define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "RH"
#define CMD_REHASH MSG_REHASH, TOK_REHASH
#define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "RESTART"
#define CMD_RESTART MSG_RESTART, TOK_RESTART
#define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "CLOSE"
#define CMD_CLOSE MSG_CLOSE, TOK_CLOSE
#define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "DIE"
#define CMD_DIE MSG_DIE, TOK_DIE
#define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "HASH"
#define CMD_HASH MSG_HASH, TOK_HASH
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "DNS"
#define CMD_DNS MSG_DNS, TOK_DNS
#define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U"
#define CMD_SILENCE MSG_SILENCE, TOK_SILENCE
#define MSG_GLINE "GLINE" /* GLIN */
#define TOK_GLINE "GL"
#define CMD_GLINE MSG_GLINE, TOK_GLINE
#define MSG_BURST "BURST" /* BURS */
#define TOK_BURST "B"
#define CMD_BURST MSG_BURST, TOK_BURST
#define MSG_UPING "UPING" /* UPIN */
#define TOK_UPING "UP"
#define CMD_UPING MSG_UPING, TOK_UPING
#define MSG_CREATE "CREATE" /* CREA */
#define TOK_CREATE "C"
#define CMD_CREATE MSG_CREATE, TOK_CREATE
#define MSG_DESTRUCT "DESTRUCT" /* DEST */
#define TOK_DESTRUCT "DE"
#define CMD_DESTRUCT MSG_DESTRUCT, TOK_DESTRUCT
#define MSG_END_OF_BURST "END_OF_BURST" /* END_ */
#define TOK_END_OF_BURST "EB"
#define CMD_END_OF_BURST MSG_END_OF_BURST, TOK_END_OF_BURST
#define MSG_END_OF_BURST_ACK "EOB_ACK" /* EOB_ */
#define TOK_END_OF_BURST_ACK "EA"
#define CMD_END_OF_BURST_ACK MSG_END_OF_BURST_ACK, TOK_END_OF_BURST_ACK
#define MSG_PROTO "PROTO" /* PROTO */
#define TOK_PROTO "PROTO" /* PROTO */
#define CMD_PROTO MSG_PROTO, TOK_PROTO
#define MSG_JUPE "JUPE" /* JUPE */
#define TOK_JUPE "JU"
#define CMD_JUPE MSG_JUPE, TOK_JUPE
#define MSG_OPMODE "OPMODE" /* OPMO */
#define TOK_OPMODE "OM"
#define CMD_OPMODE MSG_OPMODE, TOK_OPMODE
#define MSG_CLEARMODE "CLEARMODE" /* CLMO */
#define TOK_CLEARMODE "CM"
#define CMD_CLEARMODE MSG_CLEARMODE, TOK_CLEARMODE
#define MSG_ACCOUNT "ACCOUNT" /* ACCO */
#define TOK_ACCOUNT "AC"
#define CMD_ACCOUNT MSG_ACCOUNT, TOK_ACCOUNT
#define MSG_ASLL "ASLL" /* ASLL */
#define TOK_ASLL "LL"
#define CMD_ASLL MSG_ASLL, TOK_ASLL
#define MSG_POST "POST" /* POST */
#define TOK_POST "POST"
#define MSG_SET "SET" /* SET */
#define TOK_SET "SET"
#define MSG_RESET "RESET" /* RESE */
#define TOK_RESET "RESET"
#define MSG_GET "GET" /* GET */
#define TOK_GET "GET"
#define MSG_PRIVS "PRIVS" /* PRIV */
#define TOK_PRIVS "PRIVS"
#define CMD_PRIVS MSG_PRIVS, TOK_PRIVS
#define MSG_CAP "CAP"
#define TOK_CAP "CAP"
#define CMD_CAP MSG_CAP, TOK_CAP
#define MSG_XQUERY "XQUERY"
#define TOK_XQUERY "XQ"
#define CMD_XQUERY MSG_XQUERY, TOK_XQUERY
#define MSG_XREPLY "XREPLY"
#define TOK_XREPLY "XR"
#define CMD_XREPLY MSG_XREPLY, TOK_XREPLY
#define MSG_ISNEF "ISNEF"
#define TOK_ISNEF "ISNEF"
#define CMD_ISNEF MSG_ISNEF, TOK_ISNEF
#define MSG_CHECK "CHECK"
#define TOK_CHECK "CC"
#define CMD_CHECK MSG_CHECK, TOK_CHECK
#define MSG_PROTOCTL "PROTOCTL"
#define TOK_PROTOCTL "PROTOCTL"
#define CMD_PROTOCTL MSG_PROTOCTL, CMD_PROTOCTL
#define MSG_SVSIDENT "SVSIDENT"
#define TOK_SVSIDENT "SID"
#define CMD_SVSIDENT MSG_SVSIDENT, TOK_SVSIDENT
#define MSG_SVSINFO "SVSINFO"
#define TOK_SVSINFO "SI"
#define CMD_SVSINFO MSG_SVSINFO, TOK_SVSINFO
#define MSG_SVSQUIT "SVSQUIT"
#define TOK_SVSQUIT "SX"
#define CMD_SVSQUIT MSG_SVSQUIT, TOK_SVSQUIT
#define MSG_SNO "SNO"
#define TOK_SNO "SNO"
#define CMD_SNO MSG_SNO, TOK_SNO
#define MSG_SMO "SMO"
#define TOK_SMO "SMO"
#define CMD_SMO MSG_SMO, TOK_SMO
#define MSG_WEBIRC "WEBIRC"
#define TOK_WEBIRC "WEBIRC"
#define CMD_WEBIRC MSG_WEBIRC, TOK_WEBIRC
#define MSG_MARK "MARK"
#define TOK_MARK "MK"
#define CMD_MARK MSG_MARK, TOK_MARK
#define MSG_SVSNOOP "SVSNOOP"
#define TOK_SVSNOOP "SO"
#define CMD_SVSNOOP MSG_SVSNOOP, TOK_SVSNOOP
#define MSG_SVSMODE "SVSMODE"
#define TOK_SVSMODE "SM"
#define CMD_SVSMODE MSG_SVSMODE, TOK_SVSMODE
#define MSG_SVSNICK "SVSNICK"
#define TOK_SVSNICK "SN"
#define CMD_SVSNICK MSG_SVSNICK, TOK_SVSNICK
#define MSG_SVSPART "SVSPART"
#define TOK_SVSPART "SP"
#define CMD_SVSPART MSG_SVSPART, TOK_SVSPART
#define MSG_SVSJOIN "SVSJOIN"
#define TOK_SVSJOIN "SJ"
#define CMD_SVSJOIN MSG_SVSJOIN, TOK_SVSJOIN
#define MSG_SWHOIS "SWHOIS"
#define TOK_SWHOIS "SW"
#define CMD_SWHOIS MSG_SWHOIS, TOK_SWHOIS
#define MSG_FAKE "FAKE"
#define TOK_FAKE "FA"
#define CMD_FAKE MSG_FAKE, TOK_FAKE
#define MSG_MKPASSWD "MKPASSWD"
#define TOK_MKPASSWD "MKPASSWD"
#define CMD_MKPASSWD MSG_MKPASSWD, TOK_MKPASSWD
#define MSG_OPERMOTD "OPERMOTD"
#define TOK_OPERMOTD "OPM"
#define CMD_OPERMOTD MSG_OPERMOTD, TOK_OPERMOTD
#define MSG_RULES "RULES"
#define TOK_RULES "RL"
#define CMD_RULES MSG_RULES, TOK_RULES
#define MSG_SHUN "SHUN"
#define TOK_SHUN "SU"
#define CMD_SHUN MSG_SHUN, TOK_SHUN
#define MSG_SETHOST "SETHOST"
#define TOK_SETHOST "SETHOST"
#define CMD_SETHOST MSG_SETHOST, TOK_SETHOST
#define MSG_FINGERPRINT "FINGERPRINT"
#define TOK_FINGERPRINT "FINGERPRINT"
#define CMD_FINGERPRINT MSG_FINGERPRINT, TOK_FINGERPRINT
#define MSG_STARTTLS "STARTTLS"
#define TOK_STARTTLS "STARTTLS"
#define CMD_STARTTLS MSG_STARTTLS, TOK_STARTTLS
#define MSG_WALLHOPS "WALLHOPS"
#define TOK_WALLHOPS "WH"
#define CMD_WALLHOPS MSG_WALLHOPS, TOK_WALLHOPS
#define MSG_AUTHENTICATE "AUTHENTICATE"
#define TOK_AUTHENTICATE "AUTHENTICATE"
#define CMD_AUTHENTICATE MSG_AUTHENTICATE, TOK_AUTHENTICATE
#define MSG_SASL "SASL"
#define TOK_SASL "SASL"
#define CMD_SASL MSG_SASL, TOK_SASL
#define MSG_REMOVE "REMOVE"
#define TOK_REMOVE "RM"
#define CMD_REMOVE MSG_REMOVE, TOK_REMOVE
#define MSG_WATCH "WATCH"
#define TOK_WATCH "WATCH"
#define CMD_WATCH MSG_WATCH, TOK_WATCH
#define MSG_ZLINE "ZLINE"
#define TOK_ZLINE "ZL"
#define CMD_ZLINE MSG_ZLINE, TOK_ZLINE
#define MSG_IRCOPS "IRCOPS"
#define TOK_IRCOPS "IRCOPS"
#define CMD_IRCOPS MSG_IRCOPS, TOK_IRCOPS
#define MSG_TEMPSHUN "TEMPSHUN"
#define TOK_TEMPSHUN "TS"
#define CMD_TEMPSHUN MSG_TEMPSHUN, TOK_TEMPSHUN
/*
* Constants
*/
#define MFLG_SLOW 0x01 /** Limit command usage to
* once per 2 seconds (for
* local users). */
#define MFLG_UNREG 0x02 /** Command available to
* unregistered clients. */
#define MFLG_IGNORE 0x04 /** Silently ignore command from
* unregistered clients. */
#define MFLG_EXTRA 0x08 /** Handler requests that
* mptr->extra be passed in
* parv[1]. */
#define MFLG_NOSHUN 0x10 /** Command is SHUN exempt. */
/*
* Structures
*/
/** Information on how to parse a message. */
struct Message {
char *cmd; /**< command string */
char *tok; /**< token (shorter command string) */
unsigned int count; /**< number of times message used */
unsigned int parameters; /**< minimum number of parameters */
unsigned int flags; /**< MFLG_* flags for command */
unsigned int bytes; /**< bytes received for this message */
void *extra; /**< extra pointer to be passed in parv[1] */
/*
* cptr = Connected client ptr
* sptr = Source client ptr
* parc = parameter count
* parv = parameter variable array
*/
/* handlers:
* UNREGISTERED, CLIENT, SERVER, OPER, SERVICE, LAST
*/
MessageHandler handlers[LAST_HANDLER_TYPE];
char *help;
};
extern struct Message msgtab[];
#endif /* INCLUDED_msg_h */
+90
View File
@@ -0,0 +1,90 @@
#ifndef INCLUDED_msgq_h
#define INCLUDED_msgq_h
/*
* IRC - Internet Relay Chat, include/msgq.h
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Outbound message queue interface and declarations.
* @version $Id: msgq.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h" /* BUFSIZE */
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_stdarg_h
#include <stdarg.h>
#define INCLUDED_stdarg_h
#endif
struct iovec;
struct Client;
struct StatDesc;
struct Msg;
struct MsgBuf;
/** Queue of individual messages. */
struct MsgQList {
struct Msg *head; /**< First Msg in queue list */
struct Msg *tail; /**< Last Msg in queue list */
};
/** Entire two-priority message queue for a destination. */
struct MsgQ {
unsigned int length; /**< Current number of bytes stored */
unsigned int count; /**< Current number of messages stored */
struct MsgQList queue; /**< Normal Msg queue */
struct MsgQList prio; /**< Priority Msg queue */
};
/** Returns the current number of bytes stored in \a mq. */
#define MsgQLength(mq) ((mq)->length)
/** Returns the current number of messages stored in \a mq. */
#define MsgQCount(mq) ((mq)->count)
/** Scratch the current content of the buffer.
* Release all allocated buffers and make it empty.
*/
#define MsgQClear(mq) msgq_delete((mq), MsgQLength(mq))
/*
* Prototypes
*/
extern void msgq_init(struct MsgQ *mq);
extern void msgq_delete(struct MsgQ *mq, unsigned int length);
extern int msgq_mapiov(const struct MsgQ *mq, struct iovec *iov, int count,
unsigned int *len);
extern struct MsgBuf *msgq_make(struct Client *dest, const char *format, ...);
extern struct MsgBuf *msgq_vmake(struct Client *dest, const char *format,
va_list args);
extern void msgq_append(struct Client *dest, struct MsgBuf *mb,
const char *format, ...);
extern void msgq_clean(struct MsgBuf *mb);
extern void msgq_add(struct MsgQ *mq, struct MsgBuf *mb, int prio);
extern void msgq_count_memory(struct Client *cptr,
size_t *msg_alloc, size_t *msg_used);
extern void msgq_histogram(struct Client *cptr, const struct StatDesc *sd,
char *param);
extern unsigned int msgq_bufleft(struct MsgBuf *mb);
#endif /* INCLUDED_msgq_h */
+585
View File
@@ -0,0 +1,585 @@
/*
* IRC - Internet Relay Chat, include/numeric.h
* Copyright (C) 1990 Jarkko Oikarinen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Declarations of numeric replies and supporting functions.
* @version $Id: numeric.h 1905 2009-02-09 01:30:13Z entrope $
*/
#ifndef INCLUDED_numeric_h
#define INCLUDED_numeric_h
/** Numeric reply information. */
typedef struct Numeric {
int value; /**< Numeric response. */
const char* format; /**< Format string to follow :My.Server NNN Dest */
const char* str; /**< Text form for numeric. */
} Numeric;
/*
* Prototypes
*/
extern char* rpl_str(int numeric);
extern const struct Numeric* get_error_numeric(int err);
/*
* References:
* aircd - aircd source. Doesn't appear to be available on the web.
* anywhere. Ask me (Isomer) if you'd like a copy. (it's gpl)
* Numeric List - http://www.contactor.se/~dast/irc/numerics.txt
*/
/*
* Reserve numerics 000-099 for server-client connections where the client
* is local to the server. If any server is passed a numeric in this range
* from another server then it is remapped to 100-199. -avalon
*/
#define RPL_WELCOME 1
#define RPL_YOURHOST 2
#define RPL_CREATED 3
#define RPL_MYINFO 4
#define RPL_ISUPPORT 5 /* Undernet/Dalnet extension */
/* RPL_MAP 6 unreal */
/* RPL_MAPEND 7 unreal */
#define RPL_SNOMASK 8 /* Undernet extension */
#define RPL_BOUNCE 10 /* Nefarious extension */
/* RPL_BOUNCE 10 efnet, IRCnet extension
(server redirect) */
/* RPL_YOURCOOKIE 14 IRCnet extension */
#define RPL_MAP 15 /* Undernet extension */
#define RPL_MAPMORE 16 /* Undernet extension */
#define RPL_MAPEND 17 /* Undernet extension */
#define RPL_APASSWARN_SET 30 /* Undernet extension */
#define RPL_APASSWARN_SECRET 31 /* Undernet extension */
#define RPL_APASSWARN_CLEAR 32 /* Undernet extension */
/* RPL_YOURID 42 IRCnet extension */
/* RPL_ATTEMPTINGJUNC 50 aircd extension */
/* RPL_ATTEMPTINGREROUTE 51 aircd extension */
/*
* Numberic replies from server commands.
* These are currently in the range 200-399.
*/
#define RPL_TRACELINK 200
#define RPL_TRACECONNECTING 201
#define RPL_TRACEHANDSHAKE 202
#define RPL_TRACEUNKNOWN 203
#define RPL_TRACEOPERATOR 204
#define RPL_TRACEUSER 205
#define RPL_TRACESERVER 206
#define RPL_TRACENEWTYPE 208
#define RPL_TRACECLASS 209
/* RPL_STATS 210 aircd extension, used instead of having
multiple stats numerics */
/* RPL_TRACERECONNECT 210 IRCnet extension */
#define RPL_STATSLINKINFO 211
#define RPL_STATSCOMMANDS 212
#define RPL_STATSCLINE 213
/* RPL_STATSOLDNLINE 214 unreal */
#define RPL_STATSNLINE 214 /* unused */
#define RPL_STATSILINE 215
#define RPL_STATSKLINE 216
#define RPL_STATSPLINE 217 /* Undernet extension */
/* RPL_STATSQLINE 217 Various */
#define RPL_STATSYLINE 218
#define RPL_ENDOFSTATS 219 /* See also RPL_STATSDLINE */
/* RPL_STATSPLINE 220 Hybrid - Because 217 was for
old Q: lines. */
/* RPL_STATSBLINE 220 Numerics List: Dalnet,unreal */
#define RPL_STATSWLINE 220
#define RPL_UMODEIS 221
/* RPL_SQLINE_NICK 222 Numerics List: Dalnet */
#define RPL_STATSJLINE 222 /* Undernet extension */
#define RPL_STATSELINE 223 /* Nefarious extension */
/* RPL_STATSELINE 223 dalnet */
/* RPL_STATSGLINE 223 unreal */
/* RPL_STATSFLINE 224 Hybrid extension,Dalnet */
/* RPL_STATSTLINE 224 unreal */
/* RPL_STATSDLINE 225 Hybrid extension */
/* RPL_STATSZLINE 225 Dalnet
RPL_STATSELINE 225 unreal
RPL_STATSCOUNT 226 Dalnet
RPL_STATSNLINE 226 unreal
RPL_STATSGLINE 227 Dalnet
RPL_STATSVLINE 227 unreal */
#define RPL_STATSALINE 226 /* Hybrid, Undernet */
#define RPL_STATSQLINE 228 /* Undernet extension */
/* RPL_SERVICEINFO 231 unused */
/* RPL_ENDOFSERVICES 232 unused */
#define RPL_RULES 232
/* RPL_SERVICE 233 unused */
/* RPL_SERVLIST 234 unused */
/* RPL_SERVLISTEND 235 unused */
#define RPL_STATSVERBOSE 236 /* Undernet verbose server list */
#define RPL_STATSENGINE 237 /* Undernet engine name */
#define RPL_STATSFLINE 238 /* Undernet feature lines */
/* RPL_STATSIAUTH 239 IRCnet extension */
/* RPL_STATSVLINE 240 IRCnet extension */
/* RPL_STATSXLINE 240 austnet */
#define RPL_STATSLLINE 241 /* Undernet dynamicly loaded modules */
#define RPL_STATSUPTIME 242
#define RPL_STATSOLINE 243
#define RPL_STATSHLINE 244
#define RPL_STATSSLINE 245
/* RPL_STATSSLINE 245 Reserved / Dalnet / IRCnet / EFnet */
/* RPL_STATSSPING 246 Numerics List: IRCnet */
#define RPL_STATSTLINE 246 /* Undernet extension */
/* RPL_STATSULINE 246 Dalnet */
#define RPL_STATSGLINE 247 /* Undernet extension */
/* RPL_STATSXLINE 247 hybrid extension,PTlink,unreal */
/* RPL_STATSBLINE 247 Numerics List: IRCnet */
#define RPL_STATSULINE 248 /* Undernet extension */
/* RPL_STATSDEFINE 248 Numerics List: IRCnet */
#define RPL_STATSDEBUG 249 /* Extension to RFC1459 */
#define RPL_STATSCONN 250 /* Undernet extension */
/* RPL_STATSDLINE 250 Numerics List: IRCnet */
#define RPL_LUSERCLIENT 251
#define RPL_LUSEROP 252
#define RPL_LUSERUNKNOWN 253
#define RPL_LUSERCHANNELS 254
#define RPL_LUSERME 255
#define RPL_ADMINME 256
#define RPL_ADMINLOC1 257
#define RPL_ADMINLOC2 258
#define RPL_ADMINEMAIL 259
/* RPL_TRACELOG 261 unused */
#define RPL_TRACEEND 262 /* efnet/IRCnet */
/* RPL_LOAD_THROTTLED 263 efnet/hybrid */
/* RPL_TRYAGAIN 263 Numerics List: IRCnet */
/* RPL_LOAD2HI 263 Dalnet */
#define RPL_CURRENT_LOCAL 265 /* aircd/efnet/hybrid/dalnet */
#define RPL_CURRENT_GLOBAL 266 /* aircd/efnet/hybrid/dalnet */
/* RPL_START_NETSTAT 267 aircd */
/* RPL_NETSTAT 268 aircd */
/* RPL_END_NETSTAT 269 aircd */
#define RPL_PRIVS 270 /* Undernet extension - privs */
#define RPL_SILELIST 271 /* Undernet extension */
#define RPL_ENDOFSILELIST 272 /* Undernet extension */
/* RPL_NOTIFY 273 aircd */
/* RPL_END_NOTIFY 274 aircd */
/* RPL_STATSDELTA 274 IRCnet extension */
#define RPL_STATSDLINE 275 /* Undernet extension */
#define RPL_STATSRLINE 276 /* Undernet extension */
#define RPL_GLIST 280 /* Undernet extension */
#define RPL_ENDOFGLIST 281 /* Undernet extension */
#define RPL_JUPELIST 282 /* Undernet extension - jupe -Kev */
#define RPL_ENDOFJUPELIST 283 /* Undernet extension - jupe -Kev */
#define RPL_FEATURE 284 /* Undernet extension - features */
/* RPL_CHANINFO_HANDLE 285 aircd */
/* RPL_CHANINFO_USERS 286 aircd */
#define RPL_CHKHEAD 286 /* QuakeNet - Asuka / Nefarious */
/* RPL_CHANINFO_CHOPS 287 aircd */
#define RPL_CHANUSER 287 /* QuakeNet - Asuka / Nefarious */
/* RPL_CHANINFO_VOICES 288 aircd */
/* RPL_CHANINFO_AWAY 289 aircd */
/* RPL_CHANINFO_OPERS 290 aircd */
/* RPL_HELPHDR 290 Numeric List: Dalnet */
#define RPL_DATASTR 290 /* QuakeNet - Asuka / Nefarious */
/* RPL_CHANINFO_BANNED 291 aircd */
/* RPL_HELPOP 291 Numeric List: Dalnet */
#define RPL_ENDOFCHECK 291 /* QuakeNet - Asuka / Nefarious */
/* RPL_CHANINFO_BANS 292 aircd */
/* RPL_HELPTLR 292 Numeric List: Dalnet */
#define ERR_SEARCHNOMATCH 292 /* QuakeNet - Asuka / Nefarious */
/* RPL_CHANINFO_INVITE 293 aircd */
/* RPL_HELPHLP 293 Numeric List: Dalnet */
/* RPL_CHANINFO_INVITES 294 aircd */
/* RPL_HELPFWD 294 Numeric List: Dalnet */
/* RPL_CHANINFO_KICK 295 aircd */
/* RPL_HELPIGN 295 Numeric List: Dalnet */
/* RPL_CHANINFO_KICKS 296 aircd */
/* RPL_END_CHANINFO 299 aircd */
/* RPL_NONE 300 unused */
#define RPL_AWAY 301
#define RPL_USERHOST 302
#define RPL_ISON 303
/* RPL_TEXT 304 unused */
#define RPL_UNAWAY 305
#define RPL_NOWAWAY 306
/* NotAway, aircd */
/* RPL_WHOISREGNICK 307 Numeric List: Dalnet */
/* RPL_SUSERHOST 307 austnet */
/* RPL_NOTIFYACTION 308 aircd */
/* RPL_WHOISADMIN 308 Numeric List: Dalnet */
#define RPL_RULESSTART 308
/* RPL_NICKTRACE 309 aircd */
/* RPL_WHOISSADMIN 309 Numeric List: Dalnet */
#define RPL_ENDOFRULES 309
/* RPL_WHOISHELPER 309 austnet */
/* RPL_WHOISSVCMSG 310 Dalnet */
/* RPL_WHOISHELPOP 310 unreal */
/* RPL_WHOISSERVICE 310 austnet */
#define RPL_WHOISSERVICE 310 /* Nefarious extension */
#define RPL_WHOISUSER 311 /* See also RPL_ENDOFWHOIS */
#define RPL_WHOISSERVER 312
#define RPL_WHOISOPERATOR 313
#define RPL_WHOWASUSER 314 /* See also RPL_ENDOFWHOWAS */
#define RPL_ENDOFWHO 315 /* See RPL_WHOREPLY/RPL_WHOSPCRPL */
/* RPL_WHOISCHANOP 316 removed from RFC1459 */
#define RPL_WHOISPRIVDEAF 316 /* Nefarious extension */
#define RPL_WHOISIDLE 317
#define RPL_ENDOFWHOIS 318 /* See RPL_WHOISUSER/RPL_WHOISSERVER/
RPL_WHOISOPERATOR/RPL_WHOISIDLE */
#define RPL_WHOISCHANNELS 319
/* RPL_WHOIS_HIDDEN 320 Anothernet +h, ick! */
#define RPL_WHOISSPECIAL 320 /* Unreal extension; also used to indicate +r to others */
#define RPL_LISTSTART 321
#define RPL_LIST 322
#define RPL_LISTEND 323
#define RPL_CHANNELMODEIS 324
/* RPL_CHANNELPASSIS 325 IRCnet extension */
/* RPL_UNIQOPIS 325 IRCnet extension */
#define RPL_WHOISWEBIRC 325
/* RPL_NOCHANPASS 326 IRCnet extension */
/* RPL_CHPASSUNKNOWN 327 IRCnet extension */
/* RPL_CHANNEL_URL 328 dalnet, anothernet */
#define RPL_CREATIONTIME 329
/* RPL_WHOWAS_TIME 330 ? */
#define RPL_WHOISACCOUNT 330
#define RPL_NOTOPIC 331
#define RPL_TOPIC 332
#define RPL_TOPICWHOTIME 333 /* Undernet extension */
#define RPL_LISTUSAGE 334 /* Undernet extension */
/* RPL_COMMANDSYNTAX 334 Dalnet */
/* RPL_LISTSYNTAX 334 unreal */
#define RPL_WHOISBOT 335 /* Unreal extension */
#define RPL_INVITELIST 336 /* ircd-hybrid extension */
#define RPL_ENDOFINVITELIST 337 /* ircd-hybrid extension */
/* RPL_CHANPASSOK 338 IRCnet extension (?)*/
#define RPL_WHOISACTUALLY 338 /* Undernet extension, dalnet */
/* RPL_BADCHANPASS 339 IRCnet extension (?) */
#define RPL_WHOISMARKS 339 /* Nefarious extension */
#define RPL_USERIP 340 /* Undernet extension */
#define RPL_INVITING 341
/* RPL_SUMMONING 342 removed from RFC1459 */
#define RPL_WHOISKILL 343 /* Nefarious extension */
#define RPL_ISSUEDINVITE 345 /* Undernet extension */
#define RPL_INVEXLIST 346 /* Reply to "MODE +I", RFC2812 calls it RPL_INVITELIST */
#define RPL_ENDOFINVEXLIST 347 /* Reply to "MODE +I", RFC2812 calls it RPL_ENDOFINVITELIST */
#define RPL_EXCEPTLIST 348 /* IRCnet/Nefarious extension */
#define RPL_ENDOFEXCEPTLIST 349 /* IRCnet/Nefarious extension */
#define RPL_VERSION 351
#define RPL_WHOREPLY 352 /* See also RPL_ENDOFWHO */
#define RPL_NAMREPLY 353 /* See also RPL_ENDOFNAMES */
#define RPL_WHOSPCRPL 354 /* Undernet extension,
See also RPL_ENDOFWHO */
#define RPL_DELNAMREPLY 355 /* QuakeNet extension */
/* RPL_KILLDONE 361 not used */
#define RPL_CLOSING 362
#define RPL_CLOSEEND 363
#define RPL_LINKS 364
#define RPL_ENDOFLINKS 365
#define RPL_ENDOFNAMES 366 /* See RPL_NAMREPLY */
#define RPL_BANLIST 367
#define RPL_ENDOFBANLIST 368
#define RPL_ENDOFWHOWAS 369
#define RPL_INFO 371
#define RPL_MOTD 372
/* RPL_INFOSTART 373 not used */
#define RPL_ENDOFINFO 374
#define RPL_MOTDSTART 375
#define RPL_ENDOFMOTD 376
/* RPL_KICKEXPIRED 377 aircd */
/* RPL_SPAM 377 austnet */
/* RPL_BANEXPIRED 378 aircd */
/* RPL_KICKLINKED 379 aircd */
/* RPL_BANLINKED 380 aircd */
#define RPL_YOUREOPER 381
#define RPL_REHASHING 382
/* RPL_YOURSERVICE 383 Numeric List: various */
/* RPL_MYPORTIS 384 not used */
/* RPL_NOTOPERANYMORE 385 Extension to RFC1459, not used */
#define RPL_IRCOPSHEADER 386 /* Nefarious extension */
#define RPL_IRCOPS 387 /* Nefarious extension */
#define RPL_ENDOFIRCOPS 388 /* Nefarious extension */
/* RPL_QLIST 386 unreal */
/* RPL_ENDOFQLIST 387 unreal */
/* RPL_ALIST 388 unreal */
/* RPL_ENDOFALIST 389 unreal */
#define RPL_TIME 391
/* RPL_START_USERS 392 Dalnet/EFnet/IRCnet */
/* RPL_USERS 393 Dalnet/EFnet/IRCnet */
/* RPL_END_USERS 394 Dalnet/EFnet/IRCnet */
/* RPL_NOUSERS 395 Dalnet/EFnet/IRCnet */
#define RPL_HOSTHIDDEN 396 /* UMODE +x completed succesfuly */
/*
* Errors are in the range from 400-599 currently and are grouped by what
* commands they come from.
*/
/* ERR_FIRSTERROR 400 unused */
#define ERR_NOSUCHNICK 401
#define ERR_NOSUCHSERVER 402
#define ERR_NOSUCHCHANNEL 403
#define ERR_CANNOTSENDTOCHAN 404
#define ERR_TOOMANYCHANNELS 405
#define ERR_WASNOSUCHNICK 406
#define ERR_TOOMANYTARGETS 407
/* ERR_NOSUCHSERVICE 408 IRCnet */
/* ERR_NOCOLORSONCHAN 408 Dalnet */
#define ERR_NOORIGIN 409
#define ERR_UNKNOWNCAPCMD 410
#define ERR_NORECIPIENT 411
#define ERR_NOTEXTTOSEND 412
#define ERR_NOTOPLEVEL 413
#define ERR_WILDTOPLEVEL 414
/* ERR_BADMASK 415 IRCnet extension */
#define ERR_QUERYTOOLONG 416 /* Undernet extension */
/* ERR_TOOMANYMATCHES 416 IRCnet extension */
#define ERR_INPUTTOOLONG 417
/* ERR_LENGTHTRUNCATED 419 aircd */
#define ERR_UNKNOWNCOMMAND 421
#define ERR_NOMOTD 422
#define ERR_NOADMININFO 423
/* ERR_FILEERROR 424 removed from RFC1459 */
/* ERR_TOOMANYAWAY 429 Dalnet */
#define ERR_NONICKNAMEGIVEN 431
#define ERR_ERRONEUSNICKNAME 432
#define ERR_NICKNAMEINUSE 433
/* ERR_SERVICENAMEINUSE 434 ? */
#define ERR_NORULES 434
/* ERR_SERVICECONFUSED 435 ? */
/* ERR_BANONCHAN 435 dalnet */
#define ERR_NICKCOLLISION 436
#define ERR_BANNICKCHANGE 437 /* Undernet extension */
/* ERR_UNAVAILRESOURCE 437 IRCnet extension */
#define ERR_NICKTOOFAST 438 /* Undernet extension */
/* ERR_DEAD 438 IRCnet reserved for later use */
#define ERR_TARGETTOOFAST 439 /* Undernet extension */
#define ERR_SERVICESDOWN 440 /* Dalnet,unreal,Undernet */
#define ERR_USERNOTINCHANNEL 441
#define ERR_NOTONCHANNEL 442
#define ERR_USERONCHANNEL 443
/* ERR_NOLOGIN 444 removed from RFC1459 */
/* ERR_SUMMONDISABLED 445 removed from RFC1459 */
/* ERR_USERSDISABLED 446 removed from RFC1459 */
/* ERR_NONICKCHANGE 447 unreal */
#define ERR_NOTREGISTERED 451
/* ERR_IDCOLLISION 452 IRCnet extension ? */
/* ERR_NICKLOST 453 IRCnet extension ? */
/* ERR_HOSTILENAME 455 unreal */
/* ERR_NOHIDING 459 unreal */
/* ERR_NOTFORHALFOPS 460 unreal */
#define ERR_NEEDMOREPARAMS 461
#define ERR_ALREADYREGISTRED 462
#define ERR_NOPERMFORHOST 463
#define ERR_PASSWDMISMATCH 464
#define ERR_YOUREBANNEDCREEP 465
#define ERR_YOUWILLBEBANNED 466
#define ERR_KEYSET 467 /* Undernet extension */
#define ERR_INVALIDUSERNAME 468 /* Undernet extension */
/* ERR_ONLYSERVERSCANCHANGE 468 Dalnet,unreal */
/* ERR_LINKSET 469 unreal */
#define ERR_SSLONLYCHAN 469 /* Nefarious extension */
/* ERR_LINKCHANNEL 470 unreal */
#define ERR_OPERONLYCHAN 470 /* Nefarious extension */
/* ERR_KICKEDFROMCHAN 470 aircd */
#define ERR_CHANNELISFULL 471
#define ERR_UNKNOWNMODE 472
#define ERR_INVITEONLYCHAN 473
#define ERR_BANNEDFROMCHAN 474
#define ERR_BADCHANNELKEY 475
#define ERR_BADCHANMASK 476 /* Undernet extension */
#define ERR_NEEDREGGEDNICK 477 /* DalNet&Undernet Extention */
#define ERR_BANLISTFULL 478 /* Undernet extension */
/* ERR_LINKFAIL 479 unreal */
#define ERR_BADCHANNAME 479 /* EFNet extension */
/* 479 Undernet extension badchan */
/* ERR_CANNOTKNOCK 480 unreal */
#define ERR_ADMINONLYCHAN 480 /* Nefarious extension */
/* ERR_NOULINE 480 austnet */
#define ERR_NOPRIVILEGES 481
#define ERR_CHANOPRIVSNEEDED 482
#define ERR_CANTKILLSERVER 483
#define ERR_ISCHANSERVICE 484 /* Undernet extension */
/* ERR_DESYNC 484 Dalnet,PTlink */
/* ERR_ATTACKDENY 484 unreal */
/* ERR_RESTRICTED 484 IRCnet extension */
/* ERR_UNIQOPRIVSNEEDED 485 IRCnet extension */
/* ERR_KILLDENY 485 unreal */
/* ERR_CANTKICKADMIN 485 PTlink */
#define ERR_COMMONCHANSONLY 485 /* Nefarious extension */
/* ERR_HTMDISABLED 486 unreal */
#define ERR_ACCOUNTONLY 486 /* Nefarious extension */
/* ERR_CHANTOORECENT 487 IRCnet extension (?) */
#define ERR_PRIVDEAF 487 /* Nefarious extension */
/* ERR_TSLESSCHAN 488 IRCnet extension (?) */
#define ERR_EXCEPTLISTFULL 488 /* Nefarious extention */
#define ERR_VOICENEEDED 489 /* Undernet extension */
#define ERR_LINKSET 490 /* Nefarious extension */
#define ERR_NOOPERHOST 491
/* ERR_NOSERVICEHOST 492 IRCnet extension */
#define ERR_NOFEATURE 493 /* Undernet extension - features */
#define ERR_BADFEATVALUE 494 /* Undernet extension - features */
#define ERR_BADLOGTYPE 495 /* Undernet extension - features */
#define ERR_BADLOGSYS 496 /* Undernet extension - features */
#define ERR_BADLOGVALUE 497 /* Undernet extension - features */
#define ERR_ISOPERLCHAN 498 /* Undernet extension */
#define ERR_UMODEUNKNOWNFLAG 501
#define ERR_USERSDONTMATCH 502
/* ERR_GHOSTEDCLIENT 503 efnet */
/* ERR_VWORLDWARN 503 austnet */
#define ERR_SILELISTFULL 511 /* Undernet extension */
/* ERR_NOTIFYFULL 512 aircd */
/* ERR_TOOMANYWATCH 512 Numeric List: Dalnet */
#define ERR_TOOMANYWATCH 512 /* Dalnet extension */
/* #define ERR_NOSUCHGLINE 512 *//* Undernet extension (old) */
#define ERR_BADPING 513 /* Undernet extension */
/* ERR_NEEDPONG 512 Numeric List: Dalnet */
#define ERR_NOSUCHJUPE 514 /* Undernet extension - jupe -Kev */
/* ERR_TOOMANYDCC 514 dalnet */
#define ERR_BADEXPIRE 515 /* Undernet extension - jupe -Kev */
#define ERR_DONTCHEAT 516 /* Undernet extension */
#define ERR_DISABLED 517 /* Undernet extension -Kev */
/* ERR_NOINVITE 518 unreal */
#define ERR_LONGMASK 518 /* Undernet extension -Kev */
/* ERR_ADMONLY 519 unreal */
#define ERR_TOOMANYUSERS 519 /* Undernet extension -Kev */
/* ERR_OPERONLY 520 unreal */
#define ERR_MASKTOOWIDE 520 /* Undernet extension -Kev */
/* ERR_WHOTRUNC 520 austnet */
#define ERR_NOSUCHGLINE 521 /* Undernet extension (new) */
/* ERR_LISTSYNTAX 521 dalnet
ERR_LISTSYNTAX 521 dalnet
ERR_WHOSYNTAX 522 dalnet
ERR_WHOLIMEXCEED 523 dalnet */
#define ERR_QUARANTINED 524 /* Undernet extension -Vampire */
#define ERR_INVALIDKEY 525 /* Undernet extension */
#define ERR_BADHOSTMASK 530 /* Nefarious extension (SETHOST) */
#define ERR_HOSTUNAVAIL 531 /* Nefarious extension (SETHOST) */
#define ERR_SSLCLIFP 532 /* Nefarious extension */
#define RPL_OMOTDSTART 535
#define RPL_OMOTD 536
#define RPL_ENDOFOMOTD 537
#define ERR_HALFCANTKICKOP 539 /* Nefarious extension */
#define RPL_STATSSHUN 542
#define ERR_NOSUCHSHUN 543
#define RPL_ENDOFSLIST 545
#define RPL_STATSZLINE 546 /* Nefarious extension */
#define ERR_NOSUCHZLINE 547 /* Nefarious extension */
#define RPL_ZLIST 548 /* Nefarious extension */
#define RPL_ENDOFZLIST 549 /* Nefarious extension */
#define ERR_INVALIDMASK 550 /* Nefarious extension */
#define ERR_LINKCHAN 551 /* Nefarious extension */
#define ERR_LINKSELF 552 /* Nefarious extension */
#define ERR_NOTLOWEROPLEVEL 560 /* Undernet extension */
#define ERR_NOTMANAGER 561 /* Undernet extension */
#define ERR_CHANSECURED 562 /* Undernet extension */
#define ERR_UPASSSET 563 /* Undernet extension */
#define ERR_UPASSNOTSET 564 /* Undernet extension */
/* ERR_NOMANAGER_LONG 565 no longer used */
#define ERR_NOMANAGER 566 /* Undernet extension */
#define ERR_UPASS_SAME_APASS 567 /* Undernet extension */
#define ERR_NOOMOTD 568
#define RPL_LOGON 600 /* Dalnet extension */
#define RPL_LOGOFF 601 /* Dalnet extension */
#define RPL_WATCHOFF 602 /* Dalnet extension */
#define RPL_WATCHSTAT 603 /* Dalnet extension */
#define RPL_NOWON 604 /* Dalnet extension */
#define RPL_NOWOFF 605 /* Dalnet extension */
#define RPL_WATCHLIST 606 /* Dalnet extension */
#define RPL_ENDOFWATCHLIST 607 /* Dalnet extension */
/* RPL_LOGON 600 dalnet,unreal
RPL_LOGOFF 601 dalnet,unreal
RPL_WATCHOFF 602 dalnet,unreal
RPL_WATCHSTAT 603 dalnet,unreal
RPL_NOWON 604 dalnet,unreal
RPL_NOWOFF 605 dalnet,unreal
RPL_WATCHLIST 606 dalnet,unreal
RPL_ENDOFWATCHLIST 607 dalnet,unreal
RPL_MAPMORE 610 unreal
RPL_MAPMORE 615 PTlink
RPL_DCCSTATUS 617 dalnet
RPL_DCCLIST 618 dalnet
RPL_ENDOFDCCLIST 619 dalnet
RPL_DCCINFO 620 dalnet
RPL_DUMPING 640 unreal
RPL_DUMPRPL 641 unreal
RPL_EODUMP 642 unreal
*/
#define RPL_SSLFP 613 /* Nefarious extension */
#define ERR_NOSSLFP 614 /* Nefarious extension */
#define RPL_WHOISSSLFP 616 /* Nefarious extension */
#define RPL_STARTTLS 670 /* Nefarious extension */
#define RPL_WHOISSSL 671 /* Nefarious extension (SSL WHOIS) */
#define ERR_STARTTLS 691 /* Nefarious extension */
#define RPL_HELPSTART 704 /* RatBox */
#define RPL_HELPTXT 705 /* RatBox */
#define RPL_ENDOFHELP 706 /* RatBox */
#define RPL_LOGGEDIN 900 /* IRCv3 - SASL extension */
#define RPL_LOGGEDOUT 901 /* IRCv3 - SASL extension */
#define RPL_SASLSUCCESS 903 /* IRCv3 - SASL extension */
#define ERR_SASLFAIL 904 /* IRCv3 - SASL extension */
#define ERR_SASLTOOLONG 905 /* IRCv3 - SASL extension */
#define ERR_SASLABORTED 906 /* IRCv3 - SASL extension */
#define ERR_SASLALREADY 907 /* IRCv3 - SASL extension */
#define ERR_SASLMECHS 908 /* IRCv3 - SASL extension */
#define ERR_CANNOTCHANGECHANMODE 974 /* Nefarious extension */
#define ERR_LASTERROR 975
#endif /* INCLUDED_numeric_h */
+91
View File
@@ -0,0 +1,91 @@
/*
* IRC - Internet Relay Chat, include/h.h
* Copyright (C) 1996 - 1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface for numeric nickname functions.
* @version $Id: numnicks.h 1274 2004-12-16 03:28:52Z entrope $
*/
#ifndef INCLUDED_numnicks_h
#define INCLUDED_numnicks_h
#ifndef INCLUDED_client_h
#include "client.h"
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
/*
* General defines
*/
/*
* used for buffer size calculations in channel.c
*/
/** Maximum length of a full user numnick. */
#define NUMNICKLEN 5 /* strlen("YYXXX") */
/*
* Macros
*/
/** Provide format string arguments for a user's numnick.
* Use this macro as follows: sprintf(buf, "%s%s ...", NumNick(cptr), ...);
*/
#define NumNick(c) cli_yxx((cli_user(c))->server), cli_yxx(c)
/** Provide format string arguments for a server's numnick.
* Use this macro as follows: sprintf(buf, "%s ...", NumServ(cptr), ...);
*/
#define NumServ(c) cli_yxx(c)
/** Provide format string arguments for a server's capacity mask.
* Use this macro as follows: sprintf(buf, "%s%s ...", NumServCap(cptr), ...);
*/
#define NumServCap(c) cli_yxx(c), (cli_serv(c))->nn_capacity
/*
* Structures
*/
struct Client;
/*
* Proto types
*/
extern void SetRemoteNumNick(struct Client* cptr, const char* yxx);
extern int SetLocalNumNick(struct Client* cptr);
extern void RemoveYXXClient(struct Client* server, const char* yxx);
extern void SetServerYXX(struct Client* cptr,
struct Client* server, const char* yxx);
extern void ClearServerYXX(const struct Client* server);
extern void SetYXXCapacity(struct Client* myself, unsigned int max_clients);
extern void SetYXXServerName(struct Client* myself, unsigned int numeric);
extern int markMatchexServer(const char* cmask, int minlen);
extern struct Client* find_match_server(char* mask);
extern struct Client* findNUser(const char* yxx);
extern struct Client* FindNServer(const char* numeric);
extern unsigned int base64toint(const char* str);
extern const char* inttobase64(char* buf, unsigned int v, unsigned int count);
extern const char* iptobase64(char* buf, const struct irc_in_addr* addr, unsigned int count, int v6_ok);
extern void base64toip(const char* s, struct irc_in_addr* addr);
#endif /* INCLUDED_numnicks_h */
+28
View File
@@ -0,0 +1,28 @@
/** @file opercmds.h
* @brief Declarations of AsLL ping helper commands.
* @version $Id: opercmds.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_opercmds_h
#define INCLUDED_opercmds_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
struct Client;
/*
* General defines
*/
/*-----------------------------------------------------------------------------
* Macro's
*/
/*
* Proto types
*/
extern char *militime(char* sec, char* usec);
extern char *militime_float(char *start);
#endif /* INCLUDED_opercmds_h */
+22
View File
@@ -0,0 +1,22 @@
/** @file packet.h
* @brief Declarations for packet handling functions.
* @version $Id: packet.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_packet_h
#define INCLUDED_packet_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
struct Client;
/*
* Prototypes
*/
extern int server_dopacket(struct Client* cptr, const char* buffer, int length);
extern int connect_dopacket(struct Client* cptr, const char* buffer, int length);
extern int client_dopacket(struct Client* cptr, unsigned int length);
#endif /* INCLUDED_packet_h */
+22
View File
@@ -0,0 +1,22 @@
/** @file parse.h
* @brief Declarations for parsing input from users and other servers.
* @version $Id: parse.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_parse_h
#define INCLUDED_parse_h
struct Client;
struct s_map;
/*
* Prototypes
*/
extern int parse_client(struct Client *cptr, char *buffer, char *bufend);
extern int parse_server(struct Client *cptr, char *buffer, char *bufend);
extern void initmsgtree(void);
extern int register_mapping(struct s_map *map);
extern int unregister_mapping(struct s_map *map);
#endif /* INCLUDED_parse_h */
+36
View File
@@ -0,0 +1,36 @@
/*
* IRC - Internet Relay Chat, include/patchlevel.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: patchlevel.h 1942 2010-02-02 23:29:03Z entrope $
*
*/
#define PATCHLEVEL "14+Nefarious(2.0.0)"
#define RELEASE ".12."
/*
* Deliberate empty lines
*/
/* Do NOT edit those: */
#ifndef BASE_VERSION
#define BASE_VERSION "u2.10"
#endif
#ifndef MAJOR_PROTOCOL
#define MAJOR_PROTOCOL "10"
#endif
+119
View File
@@ -0,0 +1,119 @@
/** @file
* @brief Interface and declarations for client counting functions.
* @version $Id: querycmds.h 1212 2004-10-03 17:02:23Z entrope $
*/
#ifndef INCLUDED_querycmds_h
#define INCLUDED_querycmds_h
#ifndef INCLUDED_ircd_features_h
#include "ircd_features.h" /* feature_str() */
#endif
struct Client;
/*
* Structs
*/
/** Counts types of clients, servers, etc.\ on the network. */
struct UserStatistics {
/* Local connections: */
unsigned int unknowns; /**< Clients of types: unknown, connecting, handshake */
unsigned int local_servers; /**< Directly connected servers. */
unsigned int local_clients; /**< Directly connected clients. */
unsigned int local_clients_max; /**< Maximum number of Directly connected clients. */
/* Global counts: */
unsigned int servers; /**< Known servers, including #me. */
unsigned int clients; /**< Registered users. */
unsigned int clients_max; /**< Maximum number of Registered users. */
/* Global user mode changes: */
unsigned int inv_clients; /**< Registered invisible users. */
unsigned int opers; /**< Registered IRC operators. */
/* Misc: */
unsigned int channels; /**< Existing channels. */
};
extern struct UserStatistics UserStats;
/*
* Macros
*/
/* Macros for remote connections: */
/** Count \a cptr as a new remote client. */
#define Count_newremoteclient(UserStats, cptr) \
do { \
++UserStats.clients; \
++(cli_serv(cptr)->clients); \
if (UserStats.clients > UserStats.clients_max) { \
UserStats.clients_max = UserStats.clients; \
save_tunefile(); \
} \
} while (0)
/** Count a new remote server. */
#define Count_newremoteserver(UserStats) (++UserStats.servers)
/** Count a remote user quit. */
#define Count_remoteclientquits(UserStats,cptr) \
do { \
--UserStats.clients; \
if (!IsServer(cptr)) \
--(cli_serv(cli_user(cptr)->server)->clients); \
} while (0)
/** Count a remote server quit. */
#define Count_remoteserverquits(UserStats) (--UserStats.servers)
/* Macros for local connections: */
/** Count a new local unknown connection. */
#define Count_newunknown(UserStats) (++UserStats.unknowns)
/** Update counters when \a cptr goes from unknown to registered. */
#define Count_unknownbecomesclient(cptr, UserStats) \
do { \
--UserStats.unknowns; ++UserStats.local_clients; ++UserStats.clients; \
if (match(feature_str(FEAT_DOMAINNAME), cli_sockhost(cptr)) == 0) \
++current_load.local_count; \
if (UserStats.local_clients > max_client_count) \
max_client_count = UserStats.local_clients; \
if (UserStats.local_clients > UserStats.local_clients_max) { \
UserStats.local_clients_max = UserStats.local_clients; \
save_tunefile(); \
} \
if (UserStats.clients > UserStats.clients_max) { \
UserStats.clients_max = UserStats.local_clients_max; \
save_tunefile(); \
} \
if (UserStats.local_clients + UserStats.local_servers > max_connection_count) \
{ \
max_connection_count = UserStats.local_clients + UserStats.local_servers; \
if (max_connection_count % 10 == 0) \
sendto_opmask_butone(0, SNO_OLDSNO, "Maximum connections: %d (%d clients)", \
max_connection_count, max_client_count); \
} \
} while(0)
/** Update counters when \a cptr goes from unknown to server. */
#define Count_unknownbecomesserver(UserStats) do { --UserStats.unknowns; ++UserStats.local_servers; ++UserStats.servers; } while(0)
/** Update counters when \a cptr (a local user) disconnects. */
#define Count_clientdisconnects(cptr, UserStats) \
do \
{ \
--UserStats.local_clients; --UserStats.clients; \
if (match(feature_str(FEAT_DOMAINNAME), cli_sockhost(cptr)) == 0) \
--current_load.local_count; \
} while(0)
/** Update counters when a local server disconnects. */
#define Count_serverdisconnects(UserStats) do { --UserStats.local_servers; --UserStats.servers; } while(0)
/** Update counters when an unknown client disconnects. */
#define Count_unknowndisconnects(UserStats) (--UserStats.unknowns)
/*
* Prototypes
*/
void load_tunefile(void);
void save_tunefile(void);
#endif /* INCLUDED_querycmds_h */
+19
View File
@@ -0,0 +1,19 @@
/** @file random.h
* @brief 32-bit pseudo-random number generator interface.
* @version $Id: random.h 1213 2004-10-03 17:53:13Z entrope $
*/
#ifndef INCLUDED_random_h
#define INCLUDED_random_h
struct Client;
/*
* Proto types
*/
extern int random_seed_set(struct Client* from, const char* const* fields,
int count);
extern unsigned int ircrandom(void);
#endif /* INCLUDED_random_h */
+161
View File
@@ -0,0 +1,161 @@
/** @file
* @brief IRC resolver API.
* @version $Id: res.h 1823 2007-08-09 03:41:18Z entrope $
*/
#ifndef INCLUDED_res_h
#define INCLUDED_res_h
#ifndef INCLUDED_config_h
#include "config.h"
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_sys_socket_h
#include <sys/socket.h>
#define INCLUDED_sys_socket_h
#endif
#include <netdb.h>
#ifndef INCLUDED_netinet_in_h
#include <netinet/in.h>
#define INCLUDED_netinet_in_h
#endif
#ifdef HAVE_STDINT_H
#ifndef INCLUDED_stdint_h
#include <stdint.h>
#define INCLUDED_stdint_h
#endif
#endif
struct Client;
struct StatDesc;
/* Here we define some values lifted from nameser.h */
#define NS_INT16SZ 2 /**< Size of a 16-bit value. */
#define NS_INT32SZ 4 /**< Size of a 32-bit value. */
#define NS_CMPRSFLGS 0xc0 /**< Prefix flags that indicate special types */
#define NS_MAXCDNAME 255 /**< Maximum length of a compressed domain name. */
#define QUERY 0 /**< Forward (normal) DNS query operation. */
#define NO_ERRORS 0 /**< No errors processing a query. */
#define SERVFAIL 2 /**< Server error while processing a query. */
#define NXDOMAIN 3 /**< Domain name in query does not exist. */
#define T_A 1 /**< Hostname -> IPv4 query type. */
#define T_AAAA 28 /**< Hostname -> IPv6 query type. */
#define T_PTR 12 /**< IP(v4 or v6) -> hostname query type. */
#define T_CNAME 5 /**< Canonical name resolution query type. */
#define C_IN 1 /**< Internet query class. */
#define QFIXEDSZ 4 /**< Length of fixed-size part of query. */
#define HFIXEDSZ 12 /**< Length of fixed-size DNS header. */
/** Structure to store an IP address. */
struct irc_in_addr
{
unsigned short in6_16[8]; /**< IPv6 encoded parts, little-endian. */
};
/** Structure to store an IP address and port number. */
struct irc_sockaddr
{
struct irc_in_addr addr; /**< IP address. */
unsigned short port; /**< Port number, host-endian. */
};
/** DNS callback function signature. */
typedef void (*dns_callback_f)(void *vptr, const struct irc_in_addr *addr, const char *h_name);
/** DNS query and response header. */
typedef struct
{
unsigned id :16; /**< query identification number */
#ifdef WORDS_BIGENDIAN
/* fields in third byte */
unsigned qr: 1; /**< response flag */
unsigned opcode: 4; /**< purpose of message */
unsigned aa: 1; /**< authoritive answer */
unsigned tc: 1; /**< truncated message */
unsigned rd: 1; /**< recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /**< recursion available */
unsigned unused :1; /**< unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /**< authentic data from named */
unsigned cd: 1; /**< checking disabled by resolver */
unsigned rcode :4; /**< response code */
#else
/* fields in third byte */
unsigned rd :1; /**< recursion desired */
unsigned tc :1; /**< truncated message */
unsigned aa :1; /**< authoritive answer */
unsigned opcode :4; /**< purpose of message */
unsigned qr :1; /**< response flag */
/* fields in fourth byte */
unsigned rcode :4; /**< response code */
unsigned cd: 1; /**< checking disabled by resolver */
unsigned ad: 1; /**< authentic data from named */
unsigned unused :1; /**< unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /**< recursion available */
#endif
/* remaining bytes */
unsigned qdcount :16; /**< number of question entries */
unsigned ancount :16; /**< number of answer entries */
unsigned nscount :16; /**< number of authority entries */
unsigned arcount :16; /**< number of resource entries */
} HEADER;
extern void restart_resolver(void);
extern void clear_nameservers(void);
extern void add_nameserver(const char *ipaddr);
extern void add_local_domain(char *hname, size_t size);
extern size_t cres_mem(struct Client* cptr);
extern void delete_resolver_queries(const void *vptr);
extern void report_dns_servers(struct Client *source_p, const struct StatDesc *sd, char *param);
extern void gethost_byname(const char *name, dns_callback_f callback, void *ctx);
extern void gethost_byaddr(const struct irc_in_addr *addr, dns_callback_f callback, void *ctx);
/** Evaluate to non-zero if \a ADDR is an unspecified (all zeros) address. */
#define irc_in_addr_unspec(ADDR) (((ADDR)->in6_16[0] == 0) \
&& ((ADDR)->in6_16[1] == 0) \
&& ((ADDR)->in6_16[2] == 0) \
&& ((ADDR)->in6_16[3] == 0) \
&& ((ADDR)->in6_16[4] == 0) \
&& ((ADDR)->in6_16[6] == 0) \
&& ((ADDR)->in6_16[7] == 0) \
&& ((ADDR)->in6_16[5] == 0 \
|| (ADDR)->in6_16[5] == 65535))
/** Evaluate to non-zero if \a ADDR is a valid address (not all 0s and not all 1s). */
#define irc_in_addr_valid(ADDR) (((ADDR)->in6_16[0] && ~(ADDR)->in6_16[0]) \
|| (ADDR)->in6_16[1] != (ADDR)->in6_16[0] \
|| (ADDR)->in6_16[2] != (ADDR)->in6_16[0] \
|| (ADDR)->in6_16[3] != (ADDR)->in6_16[0] \
|| (ADDR)->in6_16[4] != (ADDR)->in6_16[0] \
|| (ADDR)->in6_16[5] != (ADDR)->in6_16[0] \
|| (ADDR)->in6_16[6] != (ADDR)->in6_16[0] \
|| (ADDR)->in6_16[7] != (ADDR)->in6_16[0])
/** Evaluate to non-zero if \a ADDR (of type struct irc_in_addr) is an IPv4 address. */
#define irc_in_addr_is_ipv4(ADDR) (!(ADDR)->in6_16[0] && !(ADDR)->in6_16[1] && !(ADDR)->in6_16[2] \
&& !(ADDR)->in6_16[3] && !(ADDR)->in6_16[4] \
&& ((!(ADDR)->in6_16[5] && (ADDR)->in6_16[6]) \
|| (ADDR)->in6_16[5] == 65535))
/** Evaluate to non-zero if \a A is a different IP than \a B. */
#define irc_in_addr_cmp(A,B) (irc_in_addr_is_ipv4(A) ? ((A)->in6_16[6] != (B)->in6_16[6] \
|| (A)->in6_16[7] != (B)->in6_16[7] || !irc_in_addr_is_ipv4(B)) \
: memcmp((A), (B), sizeof(struct irc_in_addr)))
/** Evaluate to non-zero if \a ADDR is a loopback address. */
#define irc_in_addr_is_loopback(ADDR) (!(ADDR)->in6_16[0] && !(ADDR)->in6_16[1] && !(ADDR)->in6_16[2] \
&& !(ADDR)->in6_16[3] && !(ADDR)->in6_16[4] \
&& ((!(ADDR)->in6_16[5] \
&& ((!(ADDR)->in6_16[6] && (ADDR)->in6_16[7] == htons(1)) \
|| (ntohs((ADDR)->in6_16[6]) & 0xff00) == 0x7f00)) \
|| (((ADDR)->in6_16[5] == 65535) \
&& (ntohs((ADDR)->in6_16[6]) & 0xff00) == 0x7f00)))
/** Evaluate to non-zero if \a A is the same type of IP address (IPv4 or IPv6) as \a B. */
#define irc_in_addr_type_cmp(A,B) ((irc_in_addr_is_ipv4(A) && irc_in_addr_is_ipv4(B)) || \
(!irc_in_addr_is_ipv4(A) && !irc_in_addr_is_ipv4(B)))
#endif
+71
View File
@@ -0,0 +1,71 @@
/************************************************************************
* IRC - Internet Relay Chat, include/s_auth.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Interface for DNS and ident lookups.
* @version $Id: s_auth.h 1925 2010-01-02 20:33:10Z klmitch $
*/
#ifndef INCLUDED_s_auth_h
#define INCLUDED_s_auth_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_ircd_events_h
#include "ircd_events.h"
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
struct Client;
struct AuthRequest;
struct StatDesc;
extern void start_auth(struct Client *);
extern int auth_ping_timeout(struct Client *);
extern int auth_set_pong(struct AuthRequest *auth, unsigned int cookie);
extern int auth_set_user(struct AuthRequest *auth, const char *username, const char *hostname, const char *servername, const char *userinfo);
extern int auth_set_nick(struct AuthRequest *auth, const char *nickname);
extern int auth_set_password(struct AuthRequest *auth, const char *password);
extern int auth_set_webirc(struct AuthRequest *auth, const char *password, const char *username, const char *hostname, const char *ip, const char *opts);
extern int auth_set_webirc_trusted(struct AuthRequest *auth, const char *password, const char *username, const char *hostname, const char *ip, const char *opts);
extern void auth_send_event(const char *event, const char *paramstring);
extern int auth_set_account(struct AuthRequest *auth, const char *account);
extern void auth_set_originalip(struct AuthRequest *auth, const struct irc_in_addr addr);
extern int auth_cap_start(struct AuthRequest *auth);
extern int auth_cap_done(struct AuthRequest *auth);
extern void auth_end_loc(struct AuthRequest *auth);
extern void destroy_auth_request(struct AuthRequest *req);
extern int auth_restart(void);
extern int auth_spawn(int argc, char *argv[]);
extern void auth_send_exit(struct Client *cptr);
extern void auth_send_xreply(struct Client *sptr, const char *routing, const char *reply);
extern void auth_mark_closing(void);
extern void auth_close_unused(void);
extern void report_iauth_conf(struct Client *cptr, const struct StatDesc *sd, char *param);
extern void report_iauth_stats(struct Client *cptr, const struct StatDesc *sd, char *param);
/* SASL via IAuth */
extern int auth_iauth_handles_sasl(void);
extern int auth_send_sasl_start(struct Client *cptr, const char *mechanism, const char *certfp);
extern int auth_send_sasl_host(struct Client *cptr, const char *username, const char *host, const char *ip);
extern int auth_send_sasl_data(struct Client *cptr, const char *data);
#endif /* INCLUDED_s_auth_h */
+77
View File
@@ -0,0 +1,77 @@
/** @file s_bsd.h
* @brief Wrapper functions to avoid direct use of BSD APIs.
* @version $Id: s_bsd.h 1764 2007-02-25 15:41:49Z entrope $
*/
#ifndef INCLUDED_s_bsd_h
#define INCLUDED_s_bsd_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* size_t, time_t */
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_netinet_in_h
#include <netinet/in.h>
#define INCLUDED_netinet_in_h
#endif
struct Client;
struct ConfItem;
struct Listener;
struct MsgQ;
struct irc_in_addr;
/*
* TCP window sizes
* Set server window to a large value for fat pipes,
* set client to a smaller size to allow TCP flow control
* to reduce flooding
*/
/** Default TCP window size for server connections. */
#define SERVER_TCP_WINDOW 61440
/** Default TCP window size for client connections. */
#define CLIENT_TCP_WINDOW 2048
extern void report_error(const char* text, const char* who, int err);
/*
* text for report_error
*/
extern const char* const BIND_ERROR_MSG;
extern const char* const LISTEN_ERROR_MSG;
extern const char* const NONB_ERROR_MSG;
extern const char* const REUSEADDR_ERROR_MSG;
extern const char* const SOCKET_ERROR_MSG;
extern const char* const CONNLIMIT_ERROR_MSG;
extern const char* const ACCEPT_ERROR_MSG;
extern const char* const PEERNAME_ERROR_MSG;
extern const char* const POLL_ERROR_MSG;
extern const char* const SELECT_ERROR_MSG;
extern const char* const CONNECT_ERROR_MSG;
extern const char* const SETBUFS_ERROR_MSG;
extern const char* const TOS_ERROR_MSG;
extern const char* const REGISTER_ERROR_MSG;
extern int HighestFd;
extern struct Client* LocalClientArray[MAXCONNECTIONS];
extern struct irc_sockaddr VirtualHost_v4;
extern struct irc_sockaddr VirtualHost_v6;
extern struct irc_sockaddr VirtualHost_dns_v4;
extern struct irc_sockaddr VirtualHost_dns_v6;
/*
* Proto types
*/
extern unsigned int deliver_it(struct Client *cptr, struct MsgQ *buf);
extern int connect_server(struct ConfItem* aconf, struct Client* by);
extern int net_close_unregistered_connections(struct Client* source);
extern void close_connection(struct Client *cptr);
#ifdef USE_SSL
extern void add_connection(struct Listener* listener, int fd, void *ssl);
#else
extern void add_connection(struct Listener* listener, int fd);
#endif /* USE_SSL */
extern int read_message(time_t delay);
extern void init_server_identity(void);
extern void close_connections(int close_stderr);
extern int init_connection_limits(void);
extern void update_write(struct Client* cptr);
#endif /* INCLUDED_s_bsd_h */
+294
View File
@@ -0,0 +1,294 @@
/** @file s_conf.h
* @brief ircd configuration file API.
* @version $Id: s_conf.h 1462 2005-08-21 13:46:08Z entrope $
*/
#ifndef INCLUDED_s_conf_h
#define INCLUDED_s_conf_h
#ifndef INCLUDED_time_h
#include <time.h> /* struct tm */
#define INCLUDED_time_h
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#include "client.h"
struct Client;
struct SLink;
struct Message;
/*
* General defines
*/
/*-----------------------------------------------------------------------------
* Macros
*/
#define CONF_ILLEGAL 0x80000000 /**< Delete the ConfItem when no remaining clients. */
#define CONF_CLIENT 0x0002 /**< ConfItem describes a Client block */
#define CONF_SERVER 0x0004 /**< ConfItem describes a Connect block */
#define CONF_OPERATOR 0x0020 /**< ConfItem describes an Operator block */
#define CONF_UWORLD 0x8000 /**< ConfItem describes a Uworld server */
#define CONF_AUTOCONNECT 0x0001 /**< Autoconnect to a server */
#define CONF_SSL 0x0080 /**< Connect using SSL */
#define CONF_NOIDENTTILDE 0x0100 /**< Client should not get a ~ prefix if no ident */
/** Indicates ConfItem types that count associated clients. */
#define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER)
/** Checks whether the CONF_ILLEGAL bit is set on \a x. */
#define IsIllegal(x) ((x)->status & CONF_ILLEGAL)
/* WEBIRC FlagSet */
enum WebIRCFlag {
WFLAG_USERIDENT, /**< use USER username as ident */
WFLAG_NOIDENT, /**< ignore ident reply */
WFLAG_STRIPSSLFP, /**< strip SSL client certificate fingerprint */
WFLAG_USEOPTIONS, /**< enable and use IRCv3 WEBIRC options parameter */
WFLAG_TRUSTACCOUNT, /**< trust account option */
WFLAG_LAST_FLAG
};
/** Declare flagset type for WEBIRC flags. */
DECLARE_FLAGSET(WebIRCFlags, WFLAG_LAST_FLAG);
/*
* Structures
*/
/** Configuration item to limit peer or client access. */
struct ConfItem
{
struct ConfItem *next; /**< Next ConfItem in #GlobalConfList */
unsigned int status; /**< Set of CONF_* bits. */
unsigned int clients; /**< Number of *LOCAL* clients using this */
unsigned int maximum; /**< For CONF_SERVER, max hops.
For CONF_CLIENT, max connects per IP. */
struct ConnectionClass *conn_class; /**< Class of connection */
struct irc_sockaddr origin; /**< Local address for outbound connections */
struct irc_sockaddr address; /**< IP and port */
char *username; /**< For CONF_CLIENT and CONF_OPERATOR, username mask. */
char *host; /**< Peer hostname (for outbound connections) */
char *from_host; /**< Hostname/IP mask for inbound server connections */
char *origin_name; /**< Text form of origin address */
char *passwd; /**< Password field */
char *sslfp; /**< SSL certificate fingerprint */
char *sslciphers; /**< SSL ciphers list */
char *name; /**< Name of peer */
char *hub_limit; /**< Mask that limits servers allowed behind
this one. */
char *countrymask; /**< Mask for country code. */
char *continentmask; /**< Mask for continent code. */
char *redirserver; /**< Redirect to this server. */
int redirport; /**< Redirect to this port. */
char *autojoinchan; /**< Auto join channel list. */
char *autojoinnotice; /**< Auto join notice. */
char *swhois; /**< SWHOIS string to apply to user on OPER. */
time_t hold; /**< Earliest time to attempt an outbound
connect on this ConfItem. */
int dns_pending; /**< A dns request is pending. */
int flags; /**< Additional modifiers for item. */
int addrbits; /**< Number of bits valid in ConfItem::address. */
int from_addrbits; /**< Number of bits valid in from_host IP mask. */
struct irc_in_addr from_address; /**< Parsed IP address for from_host. */
unsigned int snomask; /**< Default server notice mask. */
int hidehostcomps; /**< Host name components to hide. */
struct Privs privs; /**< Privileges for opers. */
/** Used to detect if a privilege has been set by this ConfItem. */
struct Privs privs_dirty;
};
/** Channel quarantine structure. */
struct qline
{
struct qline *next; /**< Next qline in #GlobalQuarantineList. */
char *chname; /**< Quarantined channel name. */
char *reason; /**< Reason for quarantine. */
};
/** Local K-line structure. */
struct DenyConf {
struct DenyConf* next; /**< Next DenyConf in #denyConfList. */
char* hostmask; /**< Mask for IP or hostname. */
char* message; /**< Message to send to denied users. */
char* usermask; /**< Mask for client's username. */
char* realmask; /**< Mask for realname. */
char* countrymask; /**< Mask for country code. */
char* continentmask; /**< Mask for continent code. */
char* version; /**< Mask for CTCP version. */
char* mark; /**< Mark to be applied to auth exempt users. */
struct irc_in_addr address; /**< Address for IP-based denies. */
unsigned int flags; /**< Interpretation flags for the above. */
unsigned char bits; /**< Number of bits for ipkills */
};
#define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */
#define DENY_FLAGS_AUTHEX 0x0002 /**< K-line does not match authed users */
/** Local server configuration. */
struct LocalConf {
char* name; /**< Name of server. */
char* description; /**< Description of server. */
unsigned int numeric; /**< Globally assigned server numnick. */
char* location1; /**< First line of location information. */
char* location2; /**< Second line of location information. */
char* contact; /**< Admin contact information. */
};
enum {
CRULE_AUTO = 1, /**< CRule applies to automatic connections. */
CRULE_ALL = 2, /**< CRule applies to oper-requested connections. */
CRULE_MASK = 3
};
/** Connection rule configuration. */
struct CRuleConf {
struct CRuleConf* next; /**< Next CRule in cruleConfList. */
char* hostmask; /**< Mask of affected server names. */
char* rule; /**< Text version of the rule. */
int type; /**< One of CRULE_AUTO or CRULE_ALL. */
struct CRuleNode* node; /**< Parsed form of the rule. */
};
/** Authorization check result. */
enum AuthorizationCheckResult {
ACR_OK, /**< User accepted. */
ACR_NO_AUTHORIZATION, /**< No matching ConfItem for the user. */
ACR_TOO_MANY_IN_CLASS, /**< Connection class was already full. */
ACR_TOO_MANY_FROM_IP, /**< User's IP already has max connections. */
ACR_ALREADY_AUTHORIZED, /**< User already had an attached ConfItem. */
ACR_BAD_SOCKET /**< Client has bad file descriptor. */
};
/** Target description for service commands. */
struct nick_host {
struct nick_host *next; /**< Next nick_host struct in struct s_map. */
int nicklen; /**< offset of @ part of server string */
char nick[1]; /**< start of nick\@server string */
};
#define SMAP_FAST 1 /**< Command does not have MFLG_SLOW. */
/** Target set for a service pseudo-command. */
struct s_map {
struct s_map *next; /**< Next element in #GlobalServiceMapList. */
struct Message *msg; /**< Message element formed for this mapping. */
char *name; /**< Text name of the mapping. */
char *command; /**< Command name to use. */
char *prepend; /**< Extra text to prepend to user's text. */
char *defaulttext; /**< Default text to send if none supplied. */
unsigned int flags; /**< Bitwise map of SMAP_* flags. */
struct nick_host *services; /**< Linked list of possible targets. */
};
/* WebIRC configuration. */
struct WebIRCConf {
struct WebIRCConf* next;
char* hostmask;
char* usermask;
struct irc_in_addr address;
unsigned char bits;
char* passwd;
char* ident;
char* description;
struct WebIRCFlags flags;
};
/* SpoofHost configuration. */
struct SHostConf {
struct SHostConf* next;
char* spoofhost;
char* hostmask;
char* usermask;
struct irc_in_addr address;
unsigned char bits;
char* passwd;
int flags;
};
#define SHFLAG_AUTOAPPLY 0x1 /* SpoofHost is automatically applied on connect. */
#define SHFLAG_NOPASS 0x2 /* SpoofHost has no password. */
#define SHFLAG_ISMASK 0x4 /* SpoofHost is a wild card host. */
#define SHFLAG_MATCHUSER 0x8 /* SpoofHost automatic application matches against USER user name too. */
/* Except configuration. */
struct ExceptConf {
struct ExceptConf* next;
char* hostmask;
char* usermask;
struct irc_in_addr address;
unsigned char bits;
int flags;
};
#define EFLAG_SHUN 0x001 /**< Matching users are exempt from SHUN */
#define EFLAG_KLINE 0x002 /**< Matching users are exempt from Kill blocks */
#define EFLAG_GLINE 0x004 /**< Matching users are exempt from GLINE */
#define EFLAG_ZLINE 0x008 /**< Matching users are exempt from ZLINE */
#define EFLAG_IDENT 0x010 /**< Matching users are exempt from ident lookups */
#define EFLAG_RDNS 0x020 /**< Matching users are exempt from rDNS lookups */
#define EFLAG_IPCHECK 0x040 /**< Matching users are exempt from IPcheck checks */
#define EFLAG_TARGLIMIT 0x080 /**< Matching users are exempt from target limiting */
#define EFLAG_LISTDELAY 0x100 /**< Matching users are exempt from LISTDELAY */
/*
* GLOBALS
*/
extern struct ConfItem* GlobalConfList;
extern int GlobalConfCount;
extern struct s_map* GlobalServiceMapList;
extern struct qline* GlobalQuarantineList;
extern char * GlobalForwards[256];
/*
* Proto types
*/
extern int init_conf(void);
extern const struct LocalConf* conf_get_local(void);
extern const struct CRuleConf* conf_get_crule_list(void);
extern const struct DenyConf* conf_get_deny_list(void);
extern const struct WebIRCConf* conf_get_webirc_list(void);
extern const struct SHostConf* conf_get_shost_list(void);
extern const struct ExceptConf* conf_get_except_list(void);
extern const char* conf_eval_crule(const char* name, int mask);
extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
extern struct ConfItem* conf_find_server(const char* name);
extern void det_confs_butmask(struct Client *cptr, int mask);
extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
extern struct ConfItem* find_conf_exact(const char* name, struct Client *cptr, int statmask);
extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
extern int conf_check_server(struct Client *cptr);
extern int rehash(struct Client *cptr, int sig);
extern int find_kill(struct Client *cptr);
extern const char *find_quarantine(const char* chname);
extern void lookup_confhost(struct ConfItem *aconf);
extern void conf_parse_userhost(struct ConfItem *aconf, char *host);
extern struct ConfItem *conf_debug_iline(const char *client);
extern void free_mapping(struct s_map *smap);
extern struct WebIRCConf* find_webirc_conf(struct Client *cptr, char *passwd, int* status);
extern struct SHostConf* find_shost_conf(struct Client *cptr, char *host, char *passwd, int *status);
extern int get_except_flags(struct Client *cptr);
extern int find_except_conf(struct Client *cptr, int flags);
extern int find_except_conf_by_ip(const struct irc_in_addr *addr, int flags);
extern struct ConfItem* get_client_conf(struct Client *acptr);
extern void yyerror(const char *msg);
extern int verify_sslclifp(struct Client* cptr, struct ConfItem* aconf);
extern int find_mark(struct Client* sptr, const char* dnsbl);
extern int find_mark_match(struct Client* sptr, const char* mask);
extern int add_mark(struct Client* sptr, const char* dnsbl);
extern int del_marks(struct Client* sptr);
#endif /* INCLUDED_s_conf_h */
+68
View File
@@ -0,0 +1,68 @@
/* @file s_debug.h
* @brief Debug APIs for the ircd.
* @version $Id: s_debug.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_s_debug_h
#define INCLUDED_s_debug_h
#ifndef INCLUDED_config_h
#include "config.h" /* Needed for DEBUGMODE */
#endif
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h" /* Needed for HOSTLEN */
#endif
#ifndef INCLUDED_stdarg_h
#include <stdarg.h>
#define INCLUDED_stdarg_h
#endif
struct Client;
struct StatDesc;
#ifdef DEBUGMODE
/*
* Macro's
*/
/** If DEBUGMODE is defined, output the debug message.
* @param x A two-or-more element list containing level, format and arguments.
*/
#define Debug(x) debug x
#define LOGFILE LPATH /**< Path to debug log file. */
/*
* defined debugging levels
*/
#define DEBUG_FATAL 0 /**< fatal error */
#define DEBUG_ERROR 1 /**< report_error() and other errors that are found */
#define DEBUG_NOTICE 3 /**< somewhat useful, but non-critical, messages */
#define DEBUG_DNS 4 /**< used by all DNS related routines - a *lot* */
#define DEBUG_INFO 5 /**< general useful info */
#define DEBUG_SEND 7 /**< everything that is sent out */
#define DEBUG_DEBUG 8 /**< everything that is received */
#define DEBUG_MALLOC 9 /**< malloc/free calls */
#define DEBUG_LIST 10 /**< debug list use */
#define DEBUG_ENGINE 11 /**< debug event engine; can dump gigabyte logs */
/*
* proto types
*/
extern void vdebug(int level, const char *form, va_list vl);
extern void debug(int level, const char *form, ...);
extern void send_usage(struct Client *cptr, const struct StatDesc *sd,
char *param);
#else /* !DEBUGMODE */
#define Debug(x)
#define LOGFILE "/dev/null"
#endif /* !DEBUGMODE */
extern const char* debug_serveropts(void);
extern void debug_init(int use_tty);
extern void count_memory(struct Client *cptr, const struct StatDesc *sd,
char *param);
#endif /* INCLUDED_s_debug_h */
+94
View File
@@ -0,0 +1,94 @@
/** @file s_misc.h
* @brief Miscellaneous support functions and declarations.
* @version $Id: s_misc.h 1436 2005-06-27 13:11:52Z entrope $
*/
#ifndef INCLUDED_s_misc_h
#define INCLUDED_s_misc_h
#ifndef INCLUDED_stdarg_h
#include <stdarg.h> /* va_list */
#define INCLUDED_stdarg_h
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* time_t */
#define INCLUDED_sys_types_h
#endif
struct Client;
struct StatDesc;
struct ConfItem;
/*-----------------------------------------------------------------------------
* Macros
*/
/** Return value from various functions to indicate the source has
* been disconnected. */
#define CPTR_KILLED -2
/*
* Structures
*/
#ifdef HAVE_INTTYPES_H
# ifndef INCLUDED_inttypes_h
# include <inttypes.h>
# define INCLUDED_inttypes_h
# endif
#else
# ifdef HAVE_STDINT_H
# ifndef INCLUDED_stdint_h
# include <stdint.h>
# define INCLUDED_stdint_h
# endif
# endif
#endif
/** Structure used to count many server-wide statistics. */
struct ServerStatistics {
unsigned int is_cl; /**< number of client connections */
unsigned int is_sv; /**< number of server connections */
unsigned int is_ni; /**< connection but no idea who it was */
uint64_t is_cbs; /**< bytes sent to clients */
uint64_t is_cbr; /**< bytes received to clients */
uint64_t is_sbs; /**< bytes sent to servers */
uint64_t is_sbr; /**< bytes received to servers */
uint64_t is_cti; /**< time spent connected by clients */
uint64_t is_sti; /**< time spent connected by servers */
unsigned int is_ac; /**< connections accepted */
unsigned int is_ref; /**< accepts refused */
unsigned int is_unco; /**< unknown commands */
unsigned int is_wrdi; /**< command going in wrong direction */
unsigned int is_unpf; /**< unknown prefix */
unsigned int is_empt; /**< empty message */
unsigned int is_num; /**< numeric message */
unsigned int is_kill; /**< number of kills generated on collisions */
unsigned int is_fake; /**< MODE 'fakes' */
unsigned int is_asuc; /**< successful auth requests */
unsigned int is_abad; /**< bad auth requests */
unsigned int is_loc; /**< local connections made */
unsigned int uping_recv; /**< UDP Pings received */
};
/*
* Prototypes
*/
extern int check_registered(struct Client *sptr);
extern int check_registered_user(struct Client *sptr);
extern int exit_client(struct Client *cptr, struct Client *bcptr,
struct Client *sptr, const char *comment);
extern char *myctime(time_t value);
extern int exit_client_msg(struct Client *cptr, struct Client *bcptr,
struct Client *sptr, const char *pattern, ...);
extern void initstats(void);
extern char *date(time_t clock);
extern int vexit_client_msg(struct Client *cptr, struct Client *bcptr,
struct Client *sptr, const char *pattern, va_list vl);
extern void tstats(struct Client *cptr, const struct StatDesc *sd,
char *param);
extern struct ServerStatistics* ServerStats;
#endif /* INCLUDED_s_misc_h */
+17
View File
@@ -0,0 +1,17 @@
/** @file s_numeric.h
* @brief Send a numeric message to a client.
* @version $Id: s_numeric.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_s_numeric_h
#define INCLUDED_s_numeric_h
struct Client;
/*
* Prototypes
*/
extern int do_numeric(int numeric, int nnn, struct Client *cptr, struct Client *sptr,
int parc, char *parv[]);
#endif /* INCLUDED_s_numeric_h */
+27
View File
@@ -0,0 +1,27 @@
/** @file s_serv.h
* @brief Miscellaneous server support functions.
* @version $Id: s_serv.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_s_serv_h
#define INCLUDED_s_serv_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
struct ConfItem;
struct Client;
extern unsigned int max_connection_count;
extern unsigned int max_client_count;
/*
* Prototypes
*/
extern int exit_new_server(struct Client* cptr, struct Client* sptr,
const char* host, time_t timestamp, const char* fmt, ...);
extern int a_kills_b_too(struct Client *a, struct Client *b);
extern int server_estab(struct Client *cptr, struct ConfItem *aconf);
#endif /* INCLUDED_s_serv_h */
+65
View File
@@ -0,0 +1,65 @@
/*
* IRC - Internet Relay Chat, include/s_stats.h
* Copyright (C) 2000 Joseph Bongaarts
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Report configuration lines and other statistics from this server.
* @version $Id: s_stats.h 1521 2005-10-12 01:13:48Z entrope $
*/
#ifndef INCLUDED_s_stats_h
#define INCLUDED_s_stats_h
#ifndef INCLUDED_features_h
#include "ircd_features.h"
#endif
struct Client;
struct StatDesc;
/** Statistics callback function.
* @param[in] cptr Client requesting statistics.
* @param[in] sd Stats descriptor for request.
* @param[in] param Extra parameter from user (may be NULL).
*/
typedef void (*StatFunc)(struct Client *cptr, const struct StatDesc *sd, char *param);
/** Statistics entry. */
struct StatDesc
{
char sd_c; /**< stats character (or '\\0') */
char *sd_name; /**< full name for stats */
unsigned int sd_flags; /**< flags to control the stats */
enum Feature sd_control; /**< feature controlling stats */
StatFunc sd_func; /**< function to dispatch to */
int sd_funcdata; /**< extra data for the function */
char *sd_desc; /**< descriptive text */
};
#define STAT_FLAG_OPERONLY 0x01 /**< Oper-only stat */
#define STAT_FLAG_OPERFEAT 0x02 /**< Oper-only if the feature is true */
#define STAT_FLAG_LOCONLY 0x04 /**< Local user only */
#define STAT_FLAG_CASESENS 0x08 /**< Flag is case-sensitive */
#define STAT_FLAG_VARPARAM 0x10 /**< May have an extra parameter */
extern void stats_init(void);
const struct StatDesc *stats_find(const char *name_or_char);
#endif /* INCLUDED_s_stats_h */
+127
View File
@@ -0,0 +1,127 @@
/** @file s_user.h
* @brief Miscellaneous user-related helper functions.
* @version $Id: s_user.h 1818 2007-07-14 02:40:01Z isomer $
*/
#ifndef INCLUDED_s_user_h
#define INCLUDED_s_user_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
struct Client;
struct User;
struct Channel;
struct MsgBuf;
struct Flags;
/*
* Macros
*/
/**
* Nick flood limit.
* Minimum time between nick changes.
* (The first two changes are allowed quickly after another however).
*/
#define NICK_DELAY 30
/**
* Target flood time.
* Minimum time between target changes.
* (MAXTARGETS are allowed simultaneously however).
* Its set to a power of 2 because we devide through it quite a lot.
*/
#define TARGET_DELAY 128
/* return values for hunt_server() */
#define HUNTED_NOSUCH (-1) /**< if the hunted server is not found */
#define HUNTED_ISME 0 /**< if this server should execute the command */
#define HUNTED_PASS 1 /**< if message passed onwards successfully */
/* send sets for send_umode() */
#define ALL_UMODES 0 /**< both local and global user modes */
#define SEND_UMODES 1 /**< global user modes only */
#define SEND_UMODES_BUT_OPER 2 /**< global user modes except for FLAG_OPER */
/* used when sending to #mask or $mask */
#define MATCH_SERVER 1 /**< flag for relay_masked_message (etc) to indicate the mask matches a server name */
#define MATCH_HOST 2 /**< flag for relay_masked_message (etc) to indicate the mask matches host name */
/* used for parsing user modes */
#define ALLOWMODES_ANY 0 /**< Allow any user mode */
#define ALLOWMODES_DEFAULT 1 /**< Only allow the subset of modes that are legit defaults */
#define ALLOWMODES_SVSMODE 2 /**< Allow any user mode to be changed ignoring restrictions */
/** Formatter function for send_user_info().
* @param who Client being displayed.
* @param sptr Client requesting information.
* @param buf Message buffer that should receive the response text.
*/
typedef void (*InfoFormatter)(struct Client* who, struct Client *sptr, struct MsgBuf* buf);
/*
* Prototypes
*/
extern struct User* make_user(struct Client *cptr);
extern void free_user(struct User *user);
extern int register_user(struct Client* cptr, struct Client *sptr);
extern void user_count_memory(size_t* count_out, size_t* bytes_out);
extern int set_nick_name(struct Client* cptr, struct Client* sptr,
const char* nick, int parc, char* parv[],
int svsnick);
extern void send_umode_out(struct Client* cptr, struct Client* sptr,
struct Flags* old, int prop);
extern int whisper(struct Client* source, const char* nick,
const char* channel, const char* text, int is_notice);
extern void send_user_info(struct Client* to, char* names, int rpl,
InfoFormatter fmt);
extern int hide_hostmask(struct Client *cptr);
extern int unhide_hostmask(struct Client *cptr);
extern int set_user_mode(struct Client *cptr, struct Client *sptr,
int parc, char *parv[], int allow_modes);
extern int is_silenced(struct Client *sptr, struct Client *acptr, int ischanmsg);
extern int hunt_server_cmd(struct Client *from, const char *cmd,
const char *tok, struct Client *one,
int MustBeOper, const char *pattern, int server,
int parc, char *parv[]);
extern int hunt_server_prio_cmd(struct Client *from, const char *cmd,
const char *tok, struct Client *one,
int MustBeOper, const char *pattern,
int server, int parc, char *parv[]);
extern struct Client* next_client(struct Client* next, const char* ch);
extern char *umode_str(struct Client *cptr);
extern void send_umode(struct Client *cptr, struct Client *sptr,
struct Flags *old, int sendset);
extern void set_snomask(struct Client *, unsigned int, int);
extern int is_snomask(char *);
extern int check_target_limit(struct Client *sptr, void *target, const char *name,
int created);
extern void add_target(struct Client *sptr, void *target);
extern unsigned int umode_make_snomask(unsigned int oldmask, char *arg,
int what);
extern int send_supported(struct Client *cptr);
extern int do_nick_name(char* nick);
extern void user_setcloaked(struct Client *cptr);
extern void init_isupport(void);
extern void del_isupport(const char *name);
extern void add_isupport_s(const char *name, const char *value);
extern void add_isupport_i(const char *name, int value);
#define NAMES_ALL 1 /**< List all users in channel */
#define NAMES_VIS 2 /**< List only visible users in non-secret channels */
#define NAMES_EON 4 /**< Add an 'End Of Names' reply to the end */
#define NAMES_DEL 8 /**< Show delayed joined users only */
void do_names(struct Client* sptr, struct Channel* chptr, int filter);
extern int abort_sasl(struct Client* cptr, int timeout);
#endif /* INCLUDED_s_user_h */
+160
View File
@@ -0,0 +1,160 @@
/** @file send.h
* @brief Send messages to certain targets.
* @version $Id: send.h 1274 2004-12-16 03:28:52Z entrope $
*/
#ifndef INCLUDED_send_h
#define INCLUDED_send_h
#ifndef INCLUDED_stdarg_h
#include <stdarg.h> /* va_list */
#define INCLUDED_stdarg_h
#endif
#ifndef INCLUDED_time_h
#include <time.h> /* time_t */
#define INCLUDED_time_h
#endif
struct Channel;
struct Client;
struct DBuf;
struct MsgBuf;
/*
* Prototypes
*/
extern struct SLink *opsarray[];
extern void send_buffer(struct Client* to, struct MsgBuf* buf, int prio);
extern void kill_highest_sendq(int servers_too);
extern void flush_connections(struct Client* cptr);
extern void send_queued(struct Client *to);
/* Send a raw message to one client; USE ONLY IF YOU MUST SEND SOMETHING
* WITHOUT A PREFIX!
*/
extern void sendrawto_one(struct Client *to, const char *pattern, ...);
/* Send a command to one client */
extern void sendcmdto_one(struct Client *from, const char *cmd,
const char *tok, struct Client *to,
const char *pattern, ...);
/* Same as above, except it puts the message on the priority queue */
extern void sendcmdto_prio_one(struct Client *from, const char *cmd,
const char *tok, struct Client *to,
const char *pattern, ...);
/* Send command to servers by flags except one */
extern void sendcmdto_flag_serv_butone(struct Client *from, const char *cmd,
const char *tok, struct Client *one,
int require, int forbid,
const char *pattern, ...);
/* Send command to all servers except one */
extern void sendcmdto_serv_butone(struct Client *from, const char *cmd,
const char *tok, struct Client *one,
const char *pattern, ...);
/* Send command to all channels user is on */
extern void sendcmdto_common_channels_butone(struct Client *from,
const char *cmd,
const char *tok,
struct Client *one,
const char *pattern, ...);
/* Send command to all channels user is on with or without a specified capability */
extern void sendcmdto_common_channels_capab_butone(struct Client *from,
const char *cmd,
const char *tok,
struct Client *one,
int withcap,
int skipcap,
const char *pattern, ...);
/* Send command to all channel users on this server */
extern void sendcmdto_channel_butserv_butone(struct Client *from,
const char *cmd,
const char *tok,
struct Channel *to,
struct Client *one,
unsigned int skip,
const char *pattern, ...);
/* Send command to all channel users on this server with or without a specified capbility */
extern void sendcmdto_channel_capab_butserv_butone(struct Client *from,
const char *cmd,
const char *tok, struct Channel *to,
struct Client *one,
unsigned int skip,
int withcap,
int skipcap,
const char *pattern, ...);
/* Send command to all servers interested in a channel */
extern void sendcmdto_channel_servers_butone(struct Client *from,
const char *cmd,
const char *tok,
struct Channel *to,
struct Client *one,
unsigned int skip,
const char *pattern, ...);
/* Send command to all interested channel users */
extern void sendcmdto_channel_butone(struct Client *from, const char *cmd,
const char *tok, struct Channel *to,
struct Client *one, unsigned int skip,
unsigned char prefix, const char *pattern, ...);
#define SKIP_DEAF 0x01 /**< skip users that are +d */
#define SKIP_BURST 0x02 /**< skip users that are bursting */
#define SKIP_NONOPS 0x04 /**< skip users that aren't chanops */
#define SKIP_NONVOICES 0x08 /**< skip users that aren't voiced (includes
chanops and halfops) */
#define SKIP_NONHOPS 0x10 /**< skip users that aren't halfopped (includes
chanops) */
/* Send command to all users having a particular flag set */
extern void sendwallto_group_butone(struct Client *from, int type,
struct Client *one, const char *pattern,
...);
#define WALL_DESYNCH 1 /**< send as a DESYNCH message */
#define WALL_WALLOPS 2 /**< send to all +w opers */
#define WALL_WALLUSERS 3 /**< send to all +w users */
/* Send command to all matching clients */
extern void sendcmdto_match_butone(struct Client *from, const char *cmd,
const char *tok, const char *to,
struct Client *one, unsigned int who,
const char *pattern, ...);
/* Send server notice to servers and opers but one--one can be NULL */
extern void sendto_opmask_butone_global(struct Client *one, unsigned int mask,
const char *pattern, ...);
/* Send server notice to opers but one--one can be NULL */
extern void sendto_opmask_butone(struct Client *one, unsigned int mask,
const char *pattern, ...);
/* Send server notice to opers from from but one--one can be NULL */
extern void sendto_opmask_butone_from(struct Client *from, struct Client *one,
unsigned int mask, const char *pattern, ...);
/* Same as above, but rate limited */
extern void sendto_opmask_butone_ratelimited(struct Client *one,
unsigned int mask, time_t *rate,
const char *pattern, ...);
/* Same as above, but with variable argument list */
extern void vsendto_opmask_butone(struct Client *from, struct Client *one,
unsigned int mask, const char *pattern, va_list vl);
/* Send server notice to users with the supplied mode but one--one can be NULL */
extern void sendto_mode_butone(struct Client *one, struct Client *from, const char *mode,
const char *pattern, ...);
/* Same as above, but with variable argument list */
extern void vsendto_mode_butone(struct Client *one, struct Client *from, const char *mode,
const char *pattern, va_list vl);
#endif /* INCLUDED_send_h */
+150
View File
@@ -0,0 +1,150 @@
#ifndef INCLUDED_shun_h
#define INCLUDED_shun_h
/*
* IRC - Internet Relay Chat, include/shun.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 1996 -1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Structures and APIs for Shun manipulation.
* @version $Id: shun.h 1913 2009-07-04 22:46:00Z entrope $
*/
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
struct Client;
struct StatDesc;
#define SHUN_MAX_EXPIRE 604800 /**< max expire: 7 days */
/** Local state of a Shun. */
enum ShunLocalState {
SLOCAL_GLOBAL, /**< Shun state unmodified locally. */
SLOCAL_ACTIVATED, /**< Shun state locally activated. */
SLOCAL_DEACTIVATED /**< Shun state locally deactivated. */
};
/** Description of a Shun. */
struct Shun {
struct Shun *sh_next; /**< Next Shun in linked list. */
struct Shun **sh_prev_p; /**< Previous pointer to this Shun. */
char *sh_user; /**< Username mask (or channel/realname mask). */
char *sh_host; /**< Host portion of mask. */
char *sh_reason; /**< Reason for Shun. */
time_t sh_expire; /**< Expiration timestamp. */
time_t sh_lastmod; /**< Last modification timestamp. */
time_t sh_lifetime; /**< Record expiration timestamp. */
struct irc_in_addr sh_addr; /**< IP address (for IP-based Shuns). */
unsigned char sh_bits; /**< Bits in sh_addr used in the mask. */
unsigned int sh_flags; /**< Shun status flags. */
enum ShunLocalState sh_state; /**< Shun local state. */
};
/** Action to perform on a Shun. */
enum ShunAction {
SHUN_ACTIVATE, /**< Shun should be activated. */
SHUN_DEACTIVATE, /**< Shun should be deactivated. */
SHUN_LOCAL_ACTIVATE, /**< Shun should be locally activated. */
SHUN_LOCAL_DEACTIVATE, /**< Shun should be locally deactivated. */
SHUN_MODIFY /**< Shun should be modified. */
};
#define SHUN_ACTIVE 0x00001 /**< Shun is active. */
#define SHUN_IPMASK 0x00002 /**< sh_addr and sh_bits fields are valid. */
#define SHUN_LOCAL 0x00008 /**< Shun only applies to this server. */
#define SHUN_ANY 0x00010 /**< Search flag: Find any Shun. */
#define SHUN_FORCE 0x00020 /**< Override normal limits on Shuns. */
#define SHUN_EXACT 0x00040 /**< Exact match only (no wildcards). */
#define SHUN_LDEACT 0x00080 /**< Locally deactivated. */
#define SHUN_GLOBAL 0x00100 /**< Find only global Shuns. */
#define SHUN_LASTMOD 0x00200 /**< Find only Shuns with non-zero lastmod. */
#define SHUN_OPERFORCE 0x00400 /**< Oper forcing Shun to be set. */
#define SHUN_REALNAME 0x00800 /**< Shun matches only the realname field. */
#define SHUN_VERSION 0x00004 /**< Shun matches only the CTCP version. */
#define SHUN_EXPIRE 0x01000 /**< Expiration time update */
#define SHUN_LIFETIME 0x02000 /**< Record lifetime update */
#define SHUN_REASON 0x04000 /**< Reason update */
/** Controllable flags that can be set on an actual Shun. */
#define SHUN_MASK (SHUN_ACTIVE | SHUN_LOCAL | SHUN_REALNAME | SHUN_VERSION)
/** Mask for Shun activity flags. */
#define SHUN_ACTMASK (SHUN_ACTIVE | SHUN_LDEACT)
/** Mask for Shun update flags. */
#define SHUN_UPDATE (SHUN_EXPIRE | SHUN_LIFETIME | SHUN_REASON)
/** Test whether \a s is active. */
#define ShunIsActive(s) ((((s)->sh_flags & SHUN_ACTIVE) && \
(s)->sh_state != SLOCAL_DEACTIVATED) || \
(s)->sh_state == SLOCAL_ACTIVATED)
/** Test whether \a s is remotely (globally) active. */
#define ShunIsRemActive(s) ((s)->sh_flags & SHUN_ACTIVE)
/** Test whether \a s is an IP-based Shun. */
#define ShunIsIpMask(s) ((s)->sh_flags & SHUN_IPMASK)
/** Test whether \a s is a realname-based Shun. */
#define ShunIsRealName(s) ((s)->sh_flags & SHUN_REALNAME)
/** Test whether \a s is a CTCP version-based Shun. */
#define ShunIsVersion(s) ((s)->sh_flags & SHUN_VERSION)
/** Test whether \a s is local to this server. */
#define ShunIsLocal(s) ((s)->sh_flags & SHUN_LOCAL)
/** Return user mask of a Shun. */
#define ShunUser(s) ((s)->sh_user)
/** Return host mask of a Shun. */
#define ShunHost(s) ((s)->sh_host)
/** Return reason/message of a Shun. */
#define ShunReason(s) ((s)->sh_reason)
/** Return last modification time of a Shun. */
#define ShunLastMod(s) ((s)->sh_lastmod)
extern int shun_add(struct Client *cptr, struct Client *sptr, char *userhost,
char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags);
extern int shun_activate(struct Client *cptr, struct Client *sptr,
struct Shun *shun, time_t lastmod,
unsigned int flags);
extern int shun_deactivate(struct Client *cptr, struct Client *sptr,
struct Shun *shun, time_t lastmod,
unsigned int flags);
extern int shun_modify(struct Client *cptr, struct Client *sptr,
struct Shun *shun, enum ShunAction action,
char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags);
extern int shun_destroy(struct Client *cptr, struct Client *sptr,
struct Shun *shun);
extern struct Shun *shun_find(char *userhost, unsigned int flags);
extern struct Shun *shun_lookup(struct Client *cptr, unsigned int flags);
extern void shun_free(struct Shun *shun);
extern void shun_burst(struct Client *cptr);
extern int shun_resend(struct Client *cptr, struct Shun *shun);
extern int shun_list(struct Client *sptr, char *userhost);
extern void shun_stats(struct Client *sptr, const struct StatDesc *sd,
char *param);
extern int shun_memory_count(size_t *sh_size);
extern int shun_remove(struct Client* sptr, char *userhost, char *reason);
extern void expire_shuns(void);
#endif /* INCLUDED_shun_h */
+63
View File
@@ -0,0 +1,63 @@
/************************************************************************
* IRC - Internet Relay Chat, ircd/ssl.c
* Copyright (C) 2013 Matthew Beeching (Jobe)
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Implimentation of common SSL functions.
* @version $Id:$
*/
#include "config.h"
#include "ircd_osdep.h"
#ifndef INCLUDED_ssl_h
#define INCLUDED_ssl_h
#ifdef USE_SSL
#include <openssl/ssl.h>
struct Socket;
struct Listener;
struct ConfItem;
extern int ssl_init(void);
extern int ssl_reinit(int sig);
extern void ssl_add_connection(struct Listener *listener, int fd);
extern int ssl_murder(void *ssl, int fd, const char *buf);
extern void ssl_free(struct Socket *socketh);
extern int ssl_connect(struct Socket* sock, struct ConfItem *aconf);
extern int ssl_is_init_finished(SSL *s);
extern int ssl_starttls(struct Client *cptr);
extern void ssl_abort(struct Client *cptr);
extern int ssl_accept(struct Client *cptr);
extern IOResult ssl_recv(struct Socket *socket, struct Client *cptr, char* buf, unsigned int length, unsigned int* count_out);
extern IOResult ssl_sendv(struct Socket *socket, struct Client *cptr, struct MsgQ* buf, unsigned int* count_in, unsigned int* count_out);
extern int ssl_send(struct Client *cptr, const char *buf, unsigned int len);
extern char *ssl_get_cipher(SSL *ssl);
extern char* ssl_get_fingerprint(SSL *ssl);
extern const char* ssl_get_verify_result(SSL *ssl);
extern char *ssl_error_str(int err, int my_errno);
#endif /* USE_SSL */
#endif /* INCLUDED_ssl_h */
+105
View File
@@ -0,0 +1,105 @@
/*
* IRC - Internet Relay Chat, include/struct.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 1996 -1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Structure definitions for users and servers.
* @version $Id: struct.h 1746 2007-01-15 03:08:23Z entrope $
*/
#ifndef INCLUDED_struct_h
#define INCLUDED_struct_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* time_t */
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h" /* sizes */
#endif
struct DLink;
struct Client;
struct User;
struct Membership;
struct SLink;
/** Describes a server on the network. */
struct Server {
struct Client* up; /**< Server one closer to me */
struct DLink* down; /**< List with downlink servers */
struct DLink* updown; /**< own Dlink in up->serv->down struct */
struct Client** client_list; /**< List with client pointers on this server */
struct User* user; /**< who activated this connection */
time_t timestamp; /**< Remotely determined connect try time */
time_t ghost; /**< Local time at which a new server
caused a Ghost */
int lag; /**< Approximation of the amount of lag to this server */
unsigned int clients; /**< Number of clients on the server */
unsigned short prot; /**< Major protocol */
unsigned int nn_mask; /**< Number of clients supported by server, minus 1 */
char nn_capacity[4]; /**< Numeric representation of server capacity */
int asll_rtt; /**< AsLL round-trip time */
int asll_to; /**< AsLL upstream lag */
int asll_from; /**< AsLL downstream lag */
time_t asll_last; /**< Last time we sent or received an AsLL ping */
char *last_error_msg; /**< Allocated memory with last message receive with an ERROR */
char by[NICKLEN + 1]; /**< Numnick of client who requested the link */
};
/** Describes a user on the network. */
struct User {
struct Client* server; /**< client structure of server */
struct Membership* channel; /**< chain of channel pointer blocks */
struct SLink* invited; /**< chain of invite pointer blocks */
struct SLink* watch; /**< chain of watch pointer blocks */
struct Ban* silence; /**< chain of silence pointer blocks */
char* away; /**< pointer to away message */
char* opername; /**< pointer to /OPER user name */
time_t last; /**< last time user sent a message */
unsigned int refcnt; /**< Number of times this block is referenced */
unsigned int joined; /**< number of channels joined */
unsigned int watches; /**< Number of entrances in the watch list */
unsigned int invites; /**< Number of channels we've been invited to */
/** Remote account name. Before registration is complete, this is
* either empty or contains the username from the USER command.
* After registration, that may be prefixed with ~ or it may be
* overwritten with the ident response.
*/
char username[USERLEN + 1];
char host[HOSTLEN + 1]; /**< displayed hostname */
char realhost[HOSTLEN + 1]; /**< actual hostname */
char account[ACCOUNTLEN + 1]; /**< IRC account name */
time_t acc_create; /**< IRC account timestamp */
char swhois[BUFSIZE + 1]; /**< SWHOIS message */
char cloakip[HOSTLEN + 1]; /**< Cloaked IP */
char cloakhost[HOSTLEN + 1]; /**< Cloaked host */
char fakehost[HOSTLEN + 1]; /**< Fake host */
char sethost[HOSTLEN + USERLEN + 2]; /**< Set host */
};
/** Describes a Login on connect session on the network. */
struct LOCInfo {
unsigned int cookie; /**< Cookie sent to services */
char service[NICKLEN + 1]; /**< Service that we are querying */
char account[ACCOUNTLEN + 1]; /**< Account name we are trying to auth as */
char password[ACCPASSWDLEN + 1]; /**< Password we are using */
};
#endif /* INCLUDED_struct_h */
+32
View File
@@ -0,0 +1,32 @@
/*
* IRC - Internet Relay Chat, include/supported.h
* Copyright (C) 1999 Perry Lorier.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: supported.h 1860 2007-12-28 15:52:43Z klmitch $
*
* Description: This file has the featureset that ircu announces on connecting
* a client. It's in this .h because it's likely to be appended
* to frequently and s_user.h is included by basically everyone.
*/
#ifndef INCLUDED_supported_h
#define INCLUDED_supported_h
#include "channel.h"
#include "ircd_defs.h"
#endif /* INCLUDED_supported_h */
+34
View File
@@ -0,0 +1,34 @@
/*
* IRC - Internet Relay Chat, include/sys.h
* Copyright (C) 1990 University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: sys.h 1442 2005-07-12 02:13:10Z entrope $
*/
#ifndef INCLUDED_sys_h
#define INCLUDED_sys_h
/*
* safety margin so we can always have one spare fd, for motd/authd or
* whatever else. -24 allows "safety" margin of 10 listen ports, 8 servers
* and space reserved for logfiles, DNS sockets and identd sockets etc.
*/
#define MAXCLIENTS (MAXCONNECTIONS-24)
#define IRCD_MAX(a, b) ((a) > (b) ? (a) : (b))
#define IRCD_MIN(a, b) ((a) < (b) ? (a) : (b))
#endif /* INCLUDED_sys_h */
+44
View File
@@ -0,0 +1,44 @@
/*
* IRC - Internet Relay Chat, include/umkpasswd.h
* Copyright (C) 2002 hikari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: umkpasswd.h 1077 2004-06-15 01:20:36Z entrope $
*/
#ifndef INCLUDED_umkpasswd_h
#define INCLUDED_umkpasswd_h
struct umkpasswd_conf_s {
int debuglevel; /* you really need me to comment this? */
char* mech; /* mechanism we want to use */
char* conf; /* conf file, otherwise DPATH/CPATH */
int flags; /* to add or not to add (or maybe to update) */
char* user; /* username */
int operclass; /* connection class to use */
};
typedef struct umkpasswd_conf_s umkpasswd_conf_t;
/* values for flags */
#define ACT_ADDOPER 0x1
#define ACT_UPDOPER 0x2
#define ACT_ADDSERV 0x4 /* not implemented yet */
#define ACT_UPDSRRV 0x8 /* not implemented yet */
const char* default_salts = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
#endif /* INCLUDED_umkpasswd_h */
+82
View File
@@ -0,0 +1,82 @@
/*
* IRC - Internet Relay Chat, include/uping.h
* Copyright (C) 1995 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief UDP ping implementation.
* @version $Id: uping.h 1290 2004-12-29 03:08:09Z entrope $
*/
#ifndef INCLUDED_uping_h
#define INCLUDED_uping_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_netinet_in_h
#include <netinet/in.h>
#define INCLUDED_netinet_in_h
#endif
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h"
#endif
#ifndef INCLUDED_ircd_events_h
#include "ircd_events.h"
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
struct Client;
struct ConfItem;
/** Tracks state of a UDP ping to some other server. */
struct UPing
{
struct UPing* next; /**< next ping in list */
int fd; /**< socket file descriptor */
struct irc_sockaddr addr; /**< socket name (ip addr, port, family ) */
char count; /**< number of pings requested */
char sent; /**< pings sent */
char received; /**< pings received */
char active; /**< ping active flag */
struct Client* client; /**< who requested the pings */
time_t lastsent; /**< when last ping was sent */
int ms_min; /**< minimum time in milliseconds */
int ms_ave; /**< average time in milliseconds */
int ms_max; /**< maximum time in milliseconds */
struct Socket socket; /**< socket structure */
struct Timer sender; /**< timer telling when next to send a ping */
struct Timer killer; /**< timer to kill us */
unsigned int freeable; /**< zero when structure can be free()'d */
char name[HOSTLEN + 1]; /**< server name to poing */
char buf[BUFSIZE]; /**< buffer to hold ping times */
};
#define UPING_PENDING_SOCKET 0x01 /**< pending socket destruction event */
#define UPING_PENDING_SENDER 0x02 /**< pending sender destruction event */
#define UPING_PENDING_KILLER 0x04 /**< pending killer destruction event */
extern int uping_init(void);
extern void uping_send(struct UPing* pptr);
extern void uping_read(struct UPing* pptr);
extern void uping_end(struct UPing* pptr);
extern void uping_cancel(struct Client *sptr, struct Client *acptr);
extern struct UPing* uping_begin(void);
extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count);
#endif /* INCLUDED_uping_h */
+55
View File
@@ -0,0 +1,55 @@
/*
* Userload module by Michael L. VanLoon (mlv) <michaelv@iastate.edu>
* Written 2/93. Originally grafted into irc2.7.2g 4/93.
* Rewritten 9/97 by Carlo Wood for ircu2.10.01.
*
* IRC - Internet Relay Chat, ircd/userload.h
* Copyright (C) 1990 University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Userload tracking and statistics.
* @version $Id: userload.h 1231 2004-10-05 04:21:37Z entrope $
*/
#ifndef INCLUDED_userload_h
#define INCLUDED_userload_h
struct Client;
struct StatDesc;
/*
* Structures
*/
/** Tracks load of various types of users. */
struct current_load_st {
unsigned int client_count; /**< Count of locally connected clients. */
unsigned int local_count; /**< This field is updated but apparently meaningless. */
unsigned int conn_count; /**< Locally connected clients plus servers. */
};
/*
* Proto types
*/
extern void update_load(void);
extern void calc_load(struct Client *sptr, const struct StatDesc *sd,
char *param);
extern void initload(void);
extern struct current_load_st current_load;
#endif /* INCLUDED_userload_h */
+15
View File
@@ -0,0 +1,15 @@
/*
* version.h
*
* $Id: version.h 27 2000-03-18 05:20:30Z bleep $
*/
#ifndef INCLUDED_version_h
#define INCLUDED_version_h
extern const char *version;
extern const char *cvs_version;
extern const char *creation;
extern const char *infotext[];
extern const char *generation;
#endif /* INCLUDED_version_h */
+73
View File
@@ -0,0 +1,73 @@
/*
* IRC - Internet Relay Chat, include/watch.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 2002-2007 IRC-Dev Development Team <devel@irc-dev.net>
* Copyright (C) 2002 Toni Garcia (zoltan) <zoltan@irc-dev.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Structures and functions for handling watches.
* @version $Id$
*/
#ifndef INCLUDED_watch_h
#define INCLUDED_watch_h
#ifndef INCLUDED_config_h
#include "config.h"
#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
struct Client;
/*
* Structures
*/
/** Watch list structure */
struct Watch {
struct Watch *wt_next;
struct SLink *wt_watch; /**< Pointer to watch list */
char *wt_nick; /**< Nick */
time_t wt_lasttime; /**< last time status change */
};
/*
* Macros
*/
#define wt_next(wt) ((wt)->wt_next)
#define wt_watch(wt) ((wt)->wt_watch)
#define wt_nick(wt) ((wt)->wt_nick)
#define wt_lasttime(wt) ((wt)->wt_lasttime)
/*
* Proto types
*/
extern void check_status_watch(struct Client *sptr, int raw);
extern void show_status_watch(struct Client *sptr, char *nick, int raw1, int raw2);
extern int add_nick_watch(struct Client *sptr, char *nick);
extern int del_nick_watch(struct Client *sptr, char *nick);
extern int del_list_watch(struct Client *sptr);
extern void watch_count_memory(size_t* count_out, size_t* bytes_out);
#endif /* INCLUDED_watch_h */
+93
View File
@@ -0,0 +1,93 @@
/** @file whocmds.h
* @brief Support functions for /WHO-like commands.
* @version $Id: whocmds.h 1838 2007-10-30 01:53:33Z entrope $
*/
#ifndef INCLUDED_whocmds_h
#define INCLUDED_whocmds_h
struct Client;
struct Channel;
/*
* m_who()
* m_who with support routines rewritten by Nemesi, August 1997
* - Alghoritm have been flattened (no more recursive)
* - Several bug fixes
* - Strong performance improvement
* - Added possibility to have specific fields in the output
* See readme.who for further details.
*/
/* Macros used only in here by m_who and its support functions */
#define WHOSELECT_OPER 1 /**< Flag for /WHO: Show IRC operators. */
#define WHOSELECT_EXTRA 2 /**< Flag for /WHO: Pull rank to see users. */
#define WHOSELECT_DELAY 4 /**< Flag for /WHO: Show join-delayed users. */
#define WHO_FIELD_QTY 1 /**< Display query type. */
#define WHO_FIELD_CHA 2 /**< Show common channel name. */
#define WHO_FIELD_UID 4 /**< Show username. */
#define WHO_FIELD_NIP 8 /**< Show IP address. */
#define WHO_FIELD_HOS 16 /**< Show hostname. */
#define WHO_FIELD_SER 32 /**< Show server. */
#define WHO_FIELD_NIC 64 /**< Show nickname. */
#define WHO_FIELD_FLA 128 /**< Show flags (away, oper, chanop, etc). */
#define WHO_FIELD_DIS 256 /**< Show hop count (distance). */
#define WHO_FIELD_REN 512 /**< Show realname (info). */
#define WHO_FIELD_IDL 1024 /**< Show idle time. */
#define WHO_FIELD_ACC 2048 /**< Show account name. */
#define WHO_FIELD_OPL 4096 /**< Show oplevel. */
#define WHO_FIELD_MRK 8192 /**< Match marks. */
/** Default fields for /WHO */
#define WHO_FIELD_DEF ( WHO_FIELD_NIC | WHO_FIELD_UID | WHO_FIELD_HOS | WHO_FIELD_SER )
/** Is \a ac plainly visible to \a s?
* @param[in] s Client trying to see \a ac.
* @param[in] ac Client being looked at.
*/
#define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
/** Can \a s see \a ac by using the flags in \a b?
* @param[in] s Client trying to see \a ac.
* @param[in] ac Client being looked at.
* @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
*/
#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || \
((b & WHOSELECT_EXTRA) && MyConnect(ac) && \
(HasPriv((s), PRIV_SHOW_INVIS) || \
HasPriv((s), PRIV_SHOW_ALL_INVIS))))
/** Can \a s see \a ac by using the flags in \a b?
* @param[in] s Client trying to see \a ac.
* @param[in] ac Client being looked at.
* @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
*/
#define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || \
((b & WHOSELECT_EXTRA) && \
HasPriv((s), PRIV_SHOW_ALL_INVIS)))
/** Should we show more clients to \a sptr?
* @param[in] sptr Client listing other users.
* @param[in,out] counter Default count for clients.
*/
#define SHOW_MORE(sptr, counter) (HasPriv(sptr, PRIV_UNLIMIT_QUERY) || (!(counter-- < 0)) )
/** Can \a s see \a chptr?
* @param[in] s Client trying to see \a chptr.
* @param[in] chptr Channel being looked at.
* @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
*/
#define SEE_CHANNEL(s, chptr, b) (!SecretChannel(chptr) || ((b & WHOSELECT_EXTRA) && HasPriv((s), PRIV_SEE_CHAN)))
/** Maximum number of lines to send in response to a /WHOIS. */
#define MAX_WHOIS_LINES 50
/*
* Prototypes
*/
extern void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
int fields, char* qrt);
#endif /* INCLUDED_whocmds_h */
+86
View File
@@ -0,0 +1,86 @@
/*
* IRC - Internet Relay Chat, include/whowas.h
* Copyright (C) 1990 Markku Savela
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Globally visible declarations to manipulate whowas information.
* @version $Id: whowas.h 1229 2004-10-05 04:14:44Z entrope $
*/
#ifndef INCLUDED_whowas_h
#define INCLUDED_whowas_h
#ifndef INCLUDED_sys_types_h
#include <sys/types.h> /* size_t */
#define INCLUDED_sys_types_h
#endif
#include "res.h"
struct Client;
/*
* General defines
*/
#define BITS_PER_COL 3 /**< Magic number used by whowas hash function. */
#define BITS_PER_COL_MASK 0x7 /**< Mask with #BITS_PER_COL least significant bits set. */
#define WW_MAX_INITIAL 16 /**< Magic number used by whowas hash function. */
#define MAX_SUB (1 << BITS_PER_COL) /**< Magic number used by whowas hash function. */
#define WW_MAX_INITIAL_MASK (WW_MAX_INITIAL - 1) /**< Magic number used by whowas hash function. */
#define WW_MAX (WW_MAX_INITIAL * MAX_SUB) /**< Size of whowas hash table. */
/*
* Structures
*/
/** Tracks previously used nicknames. */
struct Whowas {
unsigned int hashv; /**< Hash value for nickname. */
char *name; /**< Client's old nickname. */
char *username; /**< Client's username. */
char *hostname; /**< Client's hostname. */
char *realhost; /**< Client's real hostname. */
char *servername; /**< Name of client's server. */
char *realname; /**< Client's realname (user info). */
char *away; /**< Client's away message. */
time_t logoff; /**< When the client logged off. */
struct irc_in_addr ip; /**< Client's last IP address. */
struct Client *online; /**< Needed for get_history() (nick chasing). */
struct Whowas *hnext; /**< Next entry with the same hash value. */
struct Whowas **hprevnextp; /**< Pointer to previous next pointer. */
struct Whowas *cnext; /**< Next entry with the same 'online' pointer. */
struct Whowas **cprevnextp; /**< Pointer to previous next pointer. */
struct Whowas *wnext; /**< Next entry in whowas linked list. */
struct Whowas *wprev; /**< Pointer to previous next pointer. */
};
/*
* Proto types
*/
extern struct Whowas* whowashash[];
extern unsigned int hash_whowas_name(const char *name);
extern struct Client *get_history(const char *nick, time_t timelimit);
extern void add_history(struct Client *cptr, int still_on);
extern void off_history(const struct Client *cptr);
extern void initwhowas(void);
extern void count_whowas_memory(int *wwu, size_t *wwm, int *wwa, size_t *wwam);
extern void whowas_realloc(void);
#endif /* INCLUDED_whowas_h */
+139
View File
@@ -0,0 +1,139 @@
#ifndef INCLUDED_zline_h
#define INCLUDED_zline_h
/*
* IRC - Internet Relay Chat, include/zline.h
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
* Copyright (C) 1996 -1997 Carlo Wood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* @brief Structures and APIs for Z-line manipulation.
* @version $Id: zline.h 1913 2009-07-04 22:46:00Z entrope $
*/
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
#endif
#ifndef INCLUDED_res_h
#include "res.h"
#endif
struct Client;
struct StatDesc;
#define ZLINE_MAX_EXPIRE 604800 /**< max expire: 7 days */
/** Local state of a Z-line. */
enum ZlineLocalState {
ZLOCAL_GLOBAL, /**< Z-line state unmodified locally. */
ZLOCAL_ACTIVATED, /**< Z-line state locally activated. */
ZLOCAL_DEACTIVATED /**< Z-line state locally deactivated. */
};
/** Description of a Z-line. */
struct Zline {
struct Zline *zl_next; /**< Next Z-line in linked list. */
struct Zline**zl_prev_p; /**< Previous pointer to this Z-line. */
char *zl_mask; /**< Mask. */
char *zl_reason; /**< Reason for Z-line. */
time_t zl_expire; /**< Expiration timestamp. */
time_t zl_lastmod; /**< Last modification timestamp. */
time_t zl_lifetime; /**< Record expiration timestamp. */
struct irc_in_addr zl_addr; /**< IP address (for IP-based Z-lines). */
unsigned char zl_bits; /**< Bits in zl_addr used in the mask. */
unsigned int zl_flags; /**< Z-line status flags. */
enum ZlineLocalState zl_state;/**< Z-line local state. */
};
/** Action to perform on a Z-line. */
enum ZlineAction {
ZLINE_ACTIVATE, /**< Z-line should be activated. */
ZLINE_DEACTIVATE, /**< Z-line should be deactivated. */
ZLINE_LOCAL_ACTIVATE, /**< Z-line should be locally activated. */
ZLINE_LOCAL_DEACTIVATE, /**< Z-line should be locally deactivated. */
ZLINE_MODIFY /**< Z-line should be modified. */
};
#define ZLINE_ACTIVE 0x00001 /**< Z-line is active. */
#define ZLINE_IPMASK 0x00002 /**< zl_addr and zl_bits fields are valid. */
#define ZLINE_LOCAL 0x00008 /**< Z-line only applies to this server. */
#define ZLINE_ANY 0x00010 /**< Search flag: Find any Z-line. */
#define ZLINE_FORCE 0x00020 /**< Override normal limits on Z-lines. */
#define ZLINE_EXACT 0x00040 /**< Exact match only (no wildcards). */
#define ZLINE_LDEACT 0x00080 /**< Locally deactivated. */
#define ZLINE_GLOBAL 0x00100 /**< Find only global Z-lines. */
#define ZLINE_LASTMOD 0x00200 /**< Find only Z-lines with non-zero lastmod. */
#define ZLINE_OPERFORCE 0x00400 /**< Oper forcing Z-line to be set. */
#define ZLINE_EXPIRE 0x01000 /**< Expiration time update */
#define ZLINE_LIFETIME 0x02000 /**< Record lifetime update */
#define ZLINE_REASON 0x04000 /**< Reason update */
/** Controllable flags that can be set on an actual Z-line. */
#define ZLINE_MASK (ZLINE_ACTIVE | ZLINE_LOCAL)
/** Mask for Z-line activity flags. */
#define ZLINE_ACTMASK (ZLINE_ACTIVE | ZLINE_LDEACT)
/** Mask for Z-line update flags. */
#define ZLINE_UPDATE (ZLINE_EXPIRE | ZLINE_LIFETIME | ZLINE_REASON)
/** Test whether \a z is active. */
#define ZlineIsActive(z) ((((z)->zl_flags & ZLINE_ACTIVE) && \
(z)->zl_state != ZLOCAL_DEACTIVATED) || \
(z)->zl_state == ZLOCAL_ACTIVATED)
/** Test whether \a z is remotely (globally) active. */
#define ZlineIsRemActive(z) ((z)->zl_flags & ZLINE_ACTIVE)
/** Test whether \a z is an IP-based Z-line. */
#define ZlineIsIpMask(z) ((z)->zl_flags & ZLINE_IPMASK)
/** Test whether \a z is local to this server. */
#define ZlineIsLocal(z) ((z)->zl_flags & ZLINE_LOCAL)
/** Return mask of a Z-line. */
#define ZlineMask(z) ((z)->zl_mask)
/** Return reason/message of a Z-line. */
#define ZlineReason(z) ((z)->zl_reason)
/** Return last modification time of a Z-line. */
#define ZlineLastMod(z) ((z)->zl_lastmod)
extern int zline_add(struct Client *cptr, struct Client *sptr, char *ipmask,
char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags);
extern int zline_activate(struct Client *cptr, struct Client *sptr,
struct Zline *zline, time_t lastmod,
unsigned int flags);
extern int zline_deactivate(struct Client *cptr, struct Client *sptr,
struct Zline *zline, time_t lastmod,
unsigned int flags);
extern int zline_modify(struct Client *cptr, struct Client *sptr,
struct Zline *zline, enum ZlineAction action,
char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags);
extern int zline_destroy(struct Client *cptr, struct Client *sptr,
struct Zline *zline);
extern struct Zline *zline_find(char *ipmask, unsigned int flags);
extern struct Zline *zline_lookup(struct Client *cptr, unsigned int flags);
extern void zline_free(struct Zline *zline);
extern void zline_burst(struct Client *cptr);
extern int zline_resend(struct Client *cptr, struct Zline *zline);
extern int zline_list(struct Client *sptr, char *ipmask);
extern void zline_stats(struct Client *sptr, const struct StatDesc *sd,
char *param);
extern int zline_memory_count(size_t *zl_size);
extern int zline_remove(struct Client* sptr, char *ipmask, char *reason);
#endif /* INCLUDED_zline_h */