diff options
Diffstat (limited to 'include')
47 files changed, 4577 insertions, 0 deletions
diff --git a/include/balloc.h b/include/balloc.h new file mode 100644 index 0000000..7e99788 --- /dev/null +++ b/include/balloc.h @@ -0,0 +1,82 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +/*! \file balloc.h + * \brief A block allocator + * \version $Id$ + * \todo Get rid of all typedefs in this file + */ + +#ifndef INCLUDED_balloc_h +#define INCLUDED_balloc_h + +#include "config.h" +#include "client.h" +#include "ircd_defs.h" + + +/*! \brief Block contains status information for + * an allocated block in our heap. + */ +struct Block +{ + int freeElems; /*!< Number of available elems */ + size_t alloc_size; /*!< Size of data space for each block */ + struct Block* next; /*!< Next in our chain of blocks */ + void* elems; /*!< Points to allocated memory */ + dlink_list free_list; /*!< Chain of free memory blocks */ +}; + +typedef struct Block Block; + +struct MemBlock +{ + dlink_node self; /*!< Node for linking into free_list */ + Block *block; /*!< Which block we belong to */ +}; + +typedef struct MemBlock MemBlock; + +/*! \brief BlockHeap contains the information for the root node of the + * memory heap. + */ +struct BlockHeap +{ + size_t elemSize; /*!< Size of each element to be stored */ + int elemsPerBlock; /*!< Number of elements per block */ + int blocksAllocated; /*!< Number of blocks allocated */ + int freeElems; /*!< Number of free elements */ + Block* base; /*!< Pointer to first block */ + const char *name; /*!< Name of the heap */ + struct BlockHeap *next; /*!< Pointer to next heap */ +}; + +typedef struct BlockHeap BlockHeap; + + +extern int BlockHeapFree(BlockHeap *, void *); +extern void * BlockHeapAlloc(BlockHeap *); + +extern BlockHeap* BlockHeapCreate(const char *const, size_t, int); +extern int BlockHeapDestroy(BlockHeap *); +extern void initBlockHeap(void); +extern void block_heap_report_stats(struct Client *); +#endif /* INCLUDED_balloc_h */ diff --git a/include/channel.h b/include/channel.h new file mode 100644 index 0000000..dca2ff5 --- /dev/null +++ b/include/channel.h @@ -0,0 +1,144 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +/*! \file channel.h + * \brief Responsible for managing channels, members, bans and topics + * \version $Id$ + */ + +#ifndef INCLUDED_channel_h +#define INCLUDED_channel_h + +#include "ircd_defs.h" /* KEYLEN, CHANNELLEN */ + +struct Client; + +/*! \brief Mode structure for channels */ +struct Mode +{ + unsigned int mode; /*!< simple modes */ + unsigned int limit; /*!< +l userlimit */ + char key[KEYLEN + 1]; /*!< +k key */ +}; + +/*! \brief Channel structure */ +struct Channel +{ + dlink_node node; + + struct Channel *hnextch; + struct Mode mode; + + char topic[TOPICLEN + 1]; + char topic_info[USERHOST_REPLYLEN]; + + time_t channelts; + time_t topic_time; + time_t last_knock; /*!< don't allow knock to flood */ + time_t last_join_time; + time_t first_received_message_time; /*!< channel flood control */ + unsigned int flags; + int received_number_of_privmsgs; + + dlink_list members; + dlink_list invites; + dlink_list banlist; + dlink_list exceptlist; + dlink_list invexlist; + + float number_joined; + + char chname[CHANNELLEN + 1]; +}; + +/*! \brief Membership structure */ +struct Membership +{ + dlink_node channode; /*!< link to chptr->members */ + dlink_node usernode; /*!< link to source_p->channel */ + struct Channel *chptr; /*!< Channel pointer */ + struct Client *client_p; /*!< Client pointer */ + unsigned int flags; /*!< user/channel flags, e.g. CHFL_CHANOP */ +}; + +/*! \brief Ban structure. Used for b/e/I n!u\@h masks */ +struct Ban +{ + dlink_node node; + char *name; + char *username; + char *host; + char *who; + size_t len; + time_t when; + struct irc_ssaddr addr; + int bits; + char type; +}; + +extern dlink_list global_channel_list; + +extern int check_channel_name(const char *, int); +extern int can_send(struct Channel *, struct Client *, struct Membership *); +extern int is_banned(const struct Channel *, const struct Client *); +extern int can_join(struct Client *, struct Channel *, const char *); +extern int has_member_flags(struct Membership *, unsigned int); + +extern void remove_ban(struct Ban *, dlink_list *); +extern void init_channels(void); +extern void add_user_to_channel(struct Channel *, struct Client *, + unsigned int, int); +extern void remove_user_from_channel(struct Membership *); +extern void channel_member_names(struct Client *, struct Channel *, int); +extern void add_invite(struct Channel *, struct Client *); +extern void del_invite(struct Channel *, struct Client *); +extern void send_channel_modes(struct Client *, struct Channel *); +extern void channel_modes(struct Channel *, struct Client *, char *, char *); +extern void check_spambot_warning(struct Client *, const char *); +extern void check_splitmode(void *); +extern void free_channel_list(dlink_list *); +extern void destroy_channel(struct Channel *); +extern void set_channel_topic(struct Channel *, const char *, const char *, time_t); + +extern const char *get_member_status(const struct Membership *, int); + +extern struct Channel *make_channel(const char *); +extern struct Membership *find_channel_link(struct Client *, struct Channel *); + +/* channel visible */ +#define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) + +#define IsMember(who, chan) ((find_channel_link(who, chan)) ? 1 : 0) +#define AddMemberFlag(x, y) ((x)->flags |= (y)) +#define DelMemberFlag(x, y) ((x)->flags &= ~(y)) + +#define FLOOD_NOTICED 1 +#define JOIN_FLOOD_NOTICED 2 + +#define SetFloodNoticed(x) ((x)->flags |= FLOOD_NOTICED) +#define IsSetFloodNoticed(x) ((x)->flags & FLOOD_NOTICED) +#define ClearFloodNoticed(x) ((x)->flags &= ~FLOOD_NOTICED) + +#define SetJoinFloodNoticed(x) ((x)->flags |= JOIN_FLOOD_NOTICED) +#define IsSetJoinFloodNoticed(x) ((x)->flags & JOIN_FLOOD_NOTICED) +#define ClearJoinFloodNoticed(x) ((x)->flags &= ~JOIN_FLOOD_NOTICED) + +#endif /* INCLUDED_channel_h */ diff --git a/include/channel_mode.h b/include/channel_mode.h new file mode 100644 index 0000000..2bd8ce6 --- /dev/null +++ b/include/channel_mode.h @@ -0,0 +1,117 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * channel_mode.h: The ircd channel mode header. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + + +#ifndef INCLUDED_channel_mode_h +#define INCLUDED_channel_mode_h + +#include "ircd_defs.h" /* buffer sizes */ + +#define MODEBUFLEN 200 + +/* Maximum mode changes allowed per client, per server is different */ +#define MAXMODEPARAMS 4 + +/* can_send results */ +#define CAN_SEND_NO 0 +#define CAN_SEND_NONOP -1 +#define CAN_SEND_OPV -2 + + +/* Channel related flags */ +#define CHFL_CHANOP 0x0001 /* Channel operator */ +#define CHFL_HALFOP 0x0002 /* Channel half op */ +#define CHFL_VOICE 0x0004 /* the power to speak */ +#define CHFL_DEOPPED 0x0008 /* deopped by us, modes need to be bounced */ +#define CHFL_BAN 0x0010 /* ban channel flag */ +#define CHFL_EXCEPTION 0x0020 /* exception to ban channel flag */ +#define CHFL_INVEX 0x0040 + +/* channel modes ONLY */ +#define MODE_PRIVATE 0x0001 +#define MODE_SECRET 0x0002 +#define MODE_MODERATED 0x0004 +#define MODE_TOPICLIMIT 0x0008 +#define MODE_INVITEONLY 0x0010 +#define MODE_NOPRIVMSGS 0x0020 +#define MODE_SSLONLY 0x0040 +#define MODE_OPERONLY 0x0080 +#define MODE_REGISTERED 0x0100 /* Channel has been registered with ChanServ */ +#define MODE_REGONLY 0x0200 + +/* cache flags for silence on ban */ +#define CHFL_BAN_CHECKED 0x0080 +#define CHFL_BAN_SILENCED 0x0100 + +#define MODE_QUERY 0 +#define MODE_ADD 1 +#define MODE_DEL -1 + +#define CHACCESS_NOTONCHAN -1 +#define CHACCESS_PEON 0 +#define CHACCESS_HALFOP 1 +#define CHACCESS_CHANOP 2 + +/* name invisible */ +#define SecretChannel(x) (((x)->mode.mode & MODE_SECRET)) +#define PubChannel(x) (!SecretChannel(x)) +/* knock is forbidden, halfops can't kick/deop other halfops. + * +pi means paranoid and will generate notices on each invite */ +#define PrivateChannel(x) (((x)->mode.mode & MODE_PRIVATE)) + +struct ChModeChange +{ + char letter; + const char *arg; + const char *id; + int dir; + unsigned int caps; + unsigned int nocaps; + int mems; + struct Client *client; +}; + +struct ChCapCombo +{ + int count; + unsigned int cap_yes; + unsigned int cap_no; +}; + +struct mode_letter +{ + const unsigned int mode; + const unsigned char letter; +}; + +extern const struct mode_letter chan_modes[]; +extern int add_id(struct Client *, struct Channel *, char *, int); +extern void set_channel_mode(struct Client *, struct Client *, struct Channel *, + struct Membership *, int, char **, char *); +extern void clear_ban_cache(struct Channel *); +extern void clear_ban_cache_client(struct Client *); +extern void init_chcap_usage_counts(void); +extern void set_chcap_usage_counts(struct Client *); +extern void unset_chcap_usage_counts(struct Client *); +#endif /* INCLUDED_channel_mode_h */ diff --git a/include/client.h b/include/client.h new file mode 100644 index 0000000..7ac400b --- /dev/null +++ b/include/client.h @@ -0,0 +1,462 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +/*! \file client.h + * \brief Header including structures, macros and prototypes for client handling + * \version $Id$ + */ + + +#ifndef INCLUDED_client_h +#define INCLUDED_client_h + +#include "list.h" +#include "fdlist.h" +#include "config.h" +#include "ircd_defs.h" +#include "dbuf.h" +#include "channel.h" + + +/*! \brief addr_mask_type enumeration */ +enum addr_mask_type +{ + HIDE_IP, /**< IP is hidden. Resolved hostname is shown instead */ + SHOW_IP, /**< IP is shown. No parts of it are hidden or masked */ + MASK_IP /**< IP is masked. 255.255.255.255 is shown instead */ +}; + +/*! \brief Server structure */ +struct Server +{ + dlink_list server_list; /**< Servers on this server */ + dlink_list client_list; /**< Clients on this server */ + char by[NICKLEN + 1]; /**< who activated this connection */ +}; + +/*! \brief ListTask structure */ +struct ListTask +{ + dlink_list show_mask; /**< show these channels.. */ + dlink_list hide_mask; /**< ..and hide these ones */ + + unsigned int hash_index; /**< the bucket we are currently in */ + unsigned int users_min; + unsigned int users_max; + unsigned int created_min; + unsigned int created_max; + unsigned int topicts_min; + unsigned int topicts_max; +}; + +/*! \brief LocalUser structure + * + * Allocated only for local clients, that are directly connected + * to \b this server with a socket. + */ +struct LocalUser +{ + dlink_node lclient_node; + + char client_host[HOSTLEN + 1]; + char client_server[HOSTLEN + 1]; + + unsigned int registration; + unsigned int cap_client; /**< Client capabilities (from us) */ + unsigned int cap_active; /**< Active capabilities (to us) */ + unsigned int caps; /**< capabilities bit-field */ + + unsigned int operflags; /**< IRC Operator privilege flags */ + unsigned int random_ping; /**< Holding a 32bit value used for PING cookies */ + + unsigned int serial; /**< used to enforce 1 send per nick */ + + time_t lasttime; /**< ...should be only LOCAL clients? --msa */ + time_t firsttime; /**< time client was created */ + time_t since; /**< last time we parsed something */ + time_t last_knock; /**< time of last knock */ + time_t last_join_time; /**< when this client last + joined a channel */ + time_t last_leave_time; /**< when this client last + * left a channel */ + int join_leave_count; /**< count of JOIN/LEAVE in less than + MIN_JOIN_LEAVE_TIME seconds */ + int oper_warn_count_down; /**< warn opers of this possible + spambot every time this gets to 0 */ + time_t last_caller_id_time; + time_t first_received_message_time; + time_t last_nick_change; + time_t last_privmsg; /**< Last time we got a PRIVMSG */ + time_t last_away; /**< Away since... */ + + int received_number_of_privmsgs; + unsigned int number_of_nick_changes; + + struct ListTask *list_task; + + struct dbuf_queue buf_sendq; + struct dbuf_queue buf_recvq; + + struct { + unsigned int messages; /**< Statistics: protocol messages sent/received */ + uint64_t bytes; /**< Statistics: total bytes sent/received */ + } recv, send; + + struct AuthRequest *auth; + struct Listener *listener; /**< listener accepted from */ + dlink_list acceptlist; /**< clients I'll allow to talk to me */ + dlink_list watches; /**< chain of Watch pointer blocks */ + dlink_list confs; /**< Configuration record associated */ + dlink_list invited; /**< chain of invite pointer blocks */ + struct irc_ssaddr ip; + int aftype; /**< Makes life easier for DNS res in IPV6 */ + + char *passwd; + fde_t fd; + + /* Anti-flood stuff. We track how many messages were parsed and how + * many we were allowed in the current second, and apply a simple + * decay to avoid flooding. + * -- adrian + */ + int allow_read; /**< how many we're allowed to read in this second */ + int sent_parsed; /**< how many messages we've parsed in this second */ + + char* response; /**< expected response from client */ + char* auth_oper; /**< Operator to become if they supply the response.*/ +}; + +/*! \brief Client structure */ +struct Client +{ + dlink_node node; + dlink_node lnode; /**< Used for Server->servers/users */ + + struct LocalUser *localClient; + struct Client *hnext; /**< For client hash table lookups by name */ + struct Client *idhnext; /**< For SID hash table lookups by sid */ + struct Server *serv; /**< ...defined, if this is a server */ + struct Client *servptr; /**< Points to server this Client is on */ + struct Client *from; /**< == self, if Local Client, *NEVER* NULL! */ + + time_t tsinfo; /**< TS on the nick, SVINFO on server */ + + unsigned int flags; /**< client flags */ + unsigned int umodes; /**< opers, normal users subset */ + unsigned int hopcount; /**< number of servers to this 0 = local */ + unsigned int status; /**< Client type */ + unsigned int handler; /**< Handler index */ + + dlink_list whowas; + dlink_list channel; /**< chain of channel pointer blocks */ + + char away[AWAYLEN + 1]; /**< Client's AWAY message. Can be set/unset via AWAY command */ + char name[HOSTLEN + 1]; /**< unique name for a client nick or host */ + char svid[HOSTLEN + 1]; /**< Services ID. XXX: Going with HOSTLEN for now. NICKLEN might be too small + if dealing with timestamps */ + char id[IDLEN + 1]; /**< client ID, unique ID per client */ + /* + * client->username is the username from ident or the USER message, + * If the client is idented the USER message is ignored, otherwise + * the username part of the USER message is put here prefixed with a + * tilde depending on the auth{} block. Once a client has registered, + * this field should be considered read-only. + */ + char username[USERLEN + 1]; /* client's username */ + + /* + * client->host contains the resolved name or ip address + * as a string for the user, it may be fiddled with for oper spoofing etc. + * once it's changed the *real* address goes away. This should be + * considered a read-only field after the client has registered. + */ + char host[HOSTLEN + 1]; /* client's hostname */ + + /* + * client->info for unix clients will normally contain the info from the + * gcos field in /etc/passwd but anything can go here. + */ + char info[REALLEN + 1]; /* Free form additional client info */ + + /* + * client->sockhost contains the ip address gotten from the socket as a + * string, this field should be considered read-only once the connection + * has been made. (set in s_bsd.c only) + */ + char sockhost[HOSTIPLEN + 1]; /* This is the host name from the + socket ip address as string */ +}; + +/* + * status macros. + */ +#define STAT_CONNECTING 0x01 +#define STAT_HANDSHAKE 0x02 +#define STAT_ME 0x04 +#define STAT_UNKNOWN 0x08 +#define STAT_SERVER 0x10 +#define STAT_CLIENT 0x20 + +#define REG_NEED_USER 0x1 +#define REG_NEED_NICK 0x2 +#define REG_NEED_CAP 0x4 +#define REG_INIT (REG_NEED_USER|REG_NEED_NICK) + +#define HasID(x) ((x)->id[0] != '\0') +#define ID(x) (HasID(x) ? (x)->id : (x)->name) +#define ID_or_name(x,client_p) ((IsCapable(client_p, CAP_TS6) && HasID(x)) ? (x)->id : (x)->name) + +#define IsRegistered(x) ((x)->status > STAT_UNKNOWN) +#define IsConnecting(x) ((x)->status == STAT_CONNECTING) +#define IsHandshake(x) ((x)->status == STAT_HANDSHAKE) +#define IsMe(x) ((x)->status == STAT_ME) +#define IsUnknown(x) ((x)->status == STAT_UNKNOWN) +#define IsServer(x) ((x)->status == STAT_SERVER) +#define IsClient(x) ((x)->status == STAT_CLIENT) + +#define SetConnecting(x) {(x)->status = STAT_CONNECTING; \ + (x)->handler = UNREGISTERED_HANDLER; } + +#define SetHandshake(x) {(x)->status = STAT_HANDSHAKE; \ + (x)->handler = UNREGISTERED_HANDLER; } + +#define SetMe(x) {(x)->status = STAT_ME; \ + (x)->handler = UNREGISTERED_HANDLER; } + +#define SetUnknown(x) {(x)->status = STAT_UNKNOWN; \ + (x)->handler = UNREGISTERED_HANDLER; } + +#define SetServer(x) {(x)->status = STAT_SERVER; \ + (x)->handler = SERVER_HANDLER; } + +#define SetClient(x) {(x)->status = STAT_CLIENT; \ + (x)->handler = HasUMode(x, UMODE_OPER) ? \ + OPER_HANDLER : CLIENT_HANDLER; } + +#define MyConnect(x) ((x)->localClient != NULL) +#define MyClient(x) (MyConnect(x) && IsClient(x)) + +/* + * ts stuff + */ +#define TS_CURRENT 6 /**< current TS protocol version */ +#define TS_MIN 5 /**< minimum supported TS protocol version */ +#define TS_DOESTS 0x20000000 +#define DoesTS(x) ((x)->tsinfo == TS_DOESTS) + + + +#define CAP_MULTI_PREFIX 0x00000001 + +#define HasCap(x, y) ((x)->localClient->cap_active & (y)) + +/* housekeeping flags */ +#define FLAGS_PINGSENT 0x00000001 /**< Unreplied ping sent */ +#define FLAGS_DEADSOCKET 0x00000002 /**< Local socket is dead--Exiting soon */ +#define FLAGS_KILLED 0x00000004 /**< Prevents "QUIT" from being sent for this */ +#define FLAGS_CLOSING 0x00000008 /**< set when closing to suppress errors */ +#define FLAGS_GOTID 0x00000010 /**< successful ident lookup achieved */ +#define FLAGS_NEEDID 0x00000020 /**< auth{} block say must use ident return */ +#define FLAGS_SENDQEX 0x00000040 /**< Sendq exceeded */ +#define FLAGS_IPHASH 0x00000080 /**< iphashed this client */ +#define FLAGS_MARK 0x00000100 /**< marked client */ +#define FLAGS_CANFLOOD 0x00000200 /**< client has the ability to flood */ +#define FLAGS_EXEMPTGLINE 0x00000400 /**< client can't be G-lined */ +#define FLAGS_EXEMPTKLINE 0x00000800 /**< client is exempt from kline */ +#define FLAGS_NOLIMIT 0x00001000 /**< client is exempt from limits */ +#define FLAGS_PING_COOKIE 0x00002000 /**< PING Cookie */ +#define FLAGS_IP_SPOOFING 0x00004000 /**< client IP is spoofed */ +#define FLAGS_FLOODDONE 0x00008000 /**< Flood grace period has been ended. */ +#define FLAGS_EOB 0x00010000 /**< server has sent us an EOB */ +#define FLAGS_HIDDEN 0x00020000 /**< a hidden server. not shown in /links */ +#define FLAGS_BLOCKED 0x00040000 /**< must wait for COMM_SELECT_WRITE */ +#define FLAGS_USERHOST 0x00080000 /**< client is in userhost hash */ +#define FLAGS_BURSTED 0x00100000 /**< user was already bursted */ +#define FLAGS_EXEMPTRESV 0x00200000 /**< client is exempt from RESV */ +#define FLAGS_GOTUSER 0x00400000 /**< if we received a USER command */ +#define FLAGS_PINGWARNING 0x00800000 /**< unreplied ping warning already sent */ +#define FLAGS_FINISHED_AUTH 0x01000000 /**< Client has been released from auth */ +#define FLAGS_FLOOD_NOTICED 0x02000000 /**< Notice to opers about this flooder has been sent */ +#define FLAGS_SERVICE 0x04000000 /**< Client/server is a network service */ + +#define HasFlag(x, y) ((x)->flags & (y)) +#define AddFlag(x, y) ((x)->flags |= (y)) +#define DelFlag(x, y) ((x)->flags &= ~(y)) + + + +/* umodes, settable flags */ +#define UMODE_SERVNOTICE 0x00000001 /**< server notices such as kill */ +#define UMODE_CCONN 0x00000002 /**< Client Connections */ +#define UMODE_REJ 0x00000004 /**< Bot Rejections */ +#define UMODE_SKILL 0x00000008 /**< Server Killed */ +#define UMODE_FULL 0x00000010 /**< Full messages */ +#define UMODE_SPY 0x00000020 /**< see STATS / LINKS */ +#define UMODE_DEBUG 0x00000040 /**< 'debugging' info */ +#define UMODE_NCHANGE 0x00000080 /**< Nick change notice */ +#define UMODE_WALLOP 0x00000100 /**< send wallops to them */ +#define UMODE_OPERWALL 0x00000200 /**< Operwalls */ +#define UMODE_INVISIBLE 0x00000400 /**< makes user invisible */ +#define UMODE_BOTS 0x00000800 /**< shows bots */ +#define UMODE_EXTERNAL 0x00001000 /**< show servers introduced and splitting */ +#define UMODE_CALLERID 0x00002000 /**< block unless caller id's */ +#define UMODE_SOFTCALLERID 0x00004000 /**< block unless on common channel */ +#define UMODE_UNAUTH 0x00008000 /**< show unauth connects here */ +#define UMODE_LOCOPS 0x00010000 /**< show locops */ +#define UMODE_DEAF 0x00020000 /**< don't receive channel messages */ +#define UMODE_CCONN_FULL 0x00040000 /**< add unused fields to connection monitoring */ +#define UMODE_REGISTERED 0x00080000 /**< User has identified for that nick. */ +#define UMODE_REGONLY 0x00100000 /**< Only registered nicks may PM */ +#define UMODE_HIDDEN 0x00200000 /**< Operator status is hidden */ +#define UMODE_OPER 0x00400000 /**< Operator */ +#define UMODE_ADMIN 0x00800000 /**< Admin on server */ + +#define UMODE_ALL UMODE_SERVNOTICE + +#define HasUMode(x, y) ((x)->umodes & (y)) +#define AddUMode(x, y) ((x)->umodes |= (y)) +#define DelUMode(x, y) ((x)->umodes &= ~(y)) + +#define SEND_UMODES (UMODE_INVISIBLE | UMODE_OPER | UMODE_WALLOP |\ + UMODE_REGONLY | UMODE_REGISTERED | UMODE_ADMIN |\ + UMODE_HIDDEN) + + + +/* oper priv flags */ +#define OPER_FLAG_GLOBAL_KILL 0x00000001 /**< Oper can global kill */ +#define OPER_FLAG_REMOTE 0x00000002 /**> Oper can do squits/connects */ +#define OPER_FLAG_UNKLINE 0x00000004 /**< Oper can use unkline */ +#define OPER_FLAG_GLINE 0x00000008 /**< Oper can use gline */ +#define OPER_FLAG_N 0x00000010 /**< Oper can umode n */ +#define OPER_FLAG_K 0x00000020 /**< Oper can kill/kline */ +#define OPER_FLAG_X 0x00000040 /**< Oper can xline */ +#define OPER_FLAG_DIE 0x00000080 /**< Oper can die */ +#define OPER_FLAG_REHASH 0x00000100 /**< Oper can rehash */ +#define OPER_FLAG_ADMIN 0x00000200 /**< Oper can set umode +a */ +#define OPER_FLAG_OPERWALL 0x00000400 /**< Oper can use OPERWALL command */ +#define OPER_FLAG_OPER_SPY 0x00000800 /* */ +#define OPER_FLAG_REMOTEBAN 0x00001000 /**< Oper can set remote bans */ +#define OPER_FLAG_GLOBOPS 0x00002000 /**< Oper can use GLOBOPS command */ +#define OPER_FLAG_MODULE 0x00004000 /**< Oper can use MODULE commands */ +#define OPER_FLAG_RESTART 0x00008000 /**< Oper can use RESTART command */ +#define OPER_FLAG_DLINE 0x00010000 /**< Oper can use DLINE command */ +#define OPER_FLAG_UNDLINE 0x00020000 /**< Oper can use UNDLINE command */ +#define OPER_FLAG_SET 0x00040000 /**< Oper can use SET command */ + +#define HasOFlag(x, y) (MyConnect(x) ? (x)->localClient->operflags & (y) : 0) +#define AddOFlag(x, y) ((x)->localClient->operflags |= (y)) +#define DelOFlag(x, y) ((x)->localClient->operflags &= ~(y)) +#define ClrOFlag(x) ((x)->localClient->operflags = 0) + + + +/* flags macros. */ +#define IsAuthFinished(x) ((x)->flags & FLAGS_FINISHED_AUTH) +#define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET) +#define SetDead(x) ((x)->flags |= FLAGS_DEADSOCKET) +#define IsClosing(x) ((x)->flags & FLAGS_CLOSING) +#define SetClosing(x) ((x)->flags |= FLAGS_CLOSING) +#define SetCanFlood(x) ((x)->flags |= FLAGS_CANFLOOD) +#define IsCanFlood(x) ((x)->flags & FLAGS_CANFLOOD) +#define IsDefunct(x) ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING| \ + FLAGS_KILLED)) + +/* oper flags */ +#define MyOper(x) (MyConnect(x) && HasUMode(x, UMODE_OPER)) + +#define SetOper(x) {(x)->umodes |= UMODE_OPER; \ + if (!IsServer((x))) (x)->handler = OPER_HANDLER;} + +#define ClearOper(x) {(x)->umodes &= ~(UMODE_OPER|UMODE_ADMIN); \ + if (!HasUMode(x, UMODE_OPER) && !IsServer((x))) \ + (x)->handler = CLIENT_HANDLER; } + +#define SetSendQExceeded(x) ((x)->flags |= FLAGS_SENDQEX) +#define IsSendQExceeded(x) ((x)->flags & FLAGS_SENDQEX) + +#define SetIpHash(x) ((x)->flags |= FLAGS_IPHASH) +#define ClearIpHash(x) ((x)->flags &= ~FLAGS_IPHASH) +#define IsIpHash(x) ((x)->flags & FLAGS_IPHASH) + +#define SetUserHost(x) ((x)->flags |= FLAGS_USERHOST) +#define ClearUserHost(x) ((x)->flags &= ~FLAGS_USERHOST) +#define IsUserHostIp(x) ((x)->flags & FLAGS_USERHOST) + +#define SetPingSent(x) ((x)->flags |= FLAGS_PINGSENT) +#define IsPingSent(x) ((x)->flags & FLAGS_PINGSENT) +#define ClearPingSent(x) ((x)->flags &= ~FLAGS_PINGSENT) + +#define SetPingWarning(x) ((x)->flags |= FLAGS_PINGWARNING) +#define IsPingWarning(x) ((x)->flags & FLAGS_PINGWARNING) +#define ClearPingWarning(x) ((x)->flags &= ~FLAGS_PINGWARNING) + +#define SetNeedId(x) ((x)->flags |= FLAGS_NEEDID) +#define IsNeedId(x) ((x)->flags & FLAGS_NEEDID) + +#define SetGotId(x) ((x)->flags |= FLAGS_GOTID) +#define IsGotId(x) ((x)->flags & FLAGS_GOTID) + +#define IsExemptKline(x) ((x)->flags & FLAGS_EXEMPTKLINE) +#define SetExemptKline(x) ((x)->flags |= FLAGS_EXEMPTKLINE) +#define IsExemptLimits(x) ((x)->flags & FLAGS_NOLIMIT) +#define SetExemptLimits(x) ((x)->flags |= FLAGS_NOLIMIT) +#define IsExemptGline(x) ((x)->flags & FLAGS_EXEMPTGLINE) +#define SetExemptGline(x) ((x)->flags |= FLAGS_EXEMPTGLINE) +#define IsExemptResv(x) ((x)->flags & FLAGS_EXEMPTRESV) +#define SetExemptResv(x) ((x)->flags |= FLAGS_EXEMPTRESV) +#define SetIPSpoof(x) ((x)->flags |= FLAGS_IP_SPOOFING) +#define IsIPSpoof(x) ((x)->flags & FLAGS_IP_SPOOFING) + +#define IsFloodDone(x) ((x)->flags & FLAGS_FLOODDONE) +#define SetFloodDone(x) ((x)->flags |= FLAGS_FLOODDONE) +#define HasPingCookie(x) ((x)->flags & FLAGS_PING_COOKIE) +#define SetPingCookie(x) ((x)->flags |= FLAGS_PING_COOKIE) +#define IsHidden(x) ((x)->flags & FLAGS_HIDDEN) +#define SetHidden(x) ((x)->flags |= FLAGS_HIDDEN) + +#define IsSendqBlocked(x) ((x)->flags & FLAGS_BLOCKED) +#define SetSendqBlocked(x) ((x)->flags |= FLAGS_BLOCKED) +#define ClearSendqBlocked(x) ((x)->flags &= ~FLAGS_BLOCKED) + + +extern struct Client me; +extern dlink_list listing_client_list; +extern dlink_list global_client_list; + +extern int accept_message(struct Client *, struct Client *); +extern struct split_nuh_item *find_accept(const char *, const char *, + const char *, struct Client *, int); +extern void del_accept(struct split_nuh_item *, struct Client *); +extern void del_all_accepts(struct Client *); +extern void exit_client(struct Client *, struct Client *, const char *); +extern void check_conf_klines(void); +extern void init_client(void); +extern void dead_link_on_write(struct Client *, int); +extern void dead_link_on_read(struct Client *, int); +extern void exit_aborted_clients(void); +extern void free_exited_clients(void); +extern struct Client *make_client(struct Client *); +extern struct Client *find_chasing(struct Client *, struct Client *, const char *, int *); +extern struct Client *find_person(const struct Client *const, const char *); +extern const char *get_client_name(const struct Client *, enum addr_mask_type); + +#endif /* INCLUDED_client_h */ diff --git a/include/conf.h b/include/conf.h new file mode 100644 index 0000000..4cb80e7 --- /dev/null +++ b/include/conf.h @@ -0,0 +1,494 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * conf.h: A header for the configuration functions. + * + * Copyright (C) 2005 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_conf_h +#define INCLUDED_s_conf_h +#include "config.h" +#ifdef HAVE_LIBCRYPTO +#include <openssl/rsa.h> +#endif +#include "ircd_defs.h" +#include "motd.h" /* MessageFile */ +#include "client.h" +#include "hook.h" + + +struct Client; + +extern struct Callback *client_check_cb; + +struct conf_parser_context +{ + unsigned int boot; + unsigned int pass; + FILE *conf_file; +}; + +extern struct conf_parser_context conf_parser_ctx; + +typedef enum +{ + CONF_TYPE, + CLASS_TYPE, + OPER_TYPE, + CLIENT_TYPE, + SERVER_TYPE, + HUB_TYPE, + LEAF_TYPE, + KLINE_TYPE, + DLINE_TYPE, + EXEMPTDLINE_TYPE, + CLUSTER_TYPE, + RKLINE_TYPE, + RXLINE_TYPE, + XLINE_TYPE, + ULINE_TYPE, + GLINE_TYPE, + CRESV_TYPE, + NRESV_TYPE, + SERVICE_TYPE +} ConfType; + +struct split_nuh_item +{ + dlink_node node; + + char *nuhmask; + char *nickptr; + char *userptr; + char *hostptr; + + size_t nicksize; + size_t usersize; + size_t hostsize; +}; + +struct ConfItem +{ + dlink_node node; /* link into known ConfItems of this type */ + + char *name; /* Primary key */ + void *regexpname; + unsigned int flags; + ConfType type; +}; + +/* + * MatchItem - used for XLINE and ULINE types + */ +struct MatchItem +{ + char *user; /* Used for ULINE only */ + char *host; /* Used for ULINE only */ + char *reason; + char *oper_reason; + int action; /* used for uline */ + int count; /* How many times this matchitem has been matched */ + int ref_count; /* How many times is this matchitem in use */ + int illegal; /* Should it be deleted when possible? */ + time_t hold; /* Hold action until this time (calendar time) */ +}; + +struct AccessItem +{ + dlink_node node; + unsigned int dns_failed; + unsigned int dns_pending; + unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ + unsigned int flags; + unsigned int modes; + unsigned int port; + int clients; /* Number of *LOCAL* clients using this */ + int bits; + int type; + struct irc_ssaddr bind; /* ip to bind to for outgoing connect */ + struct irc_ssaddr addr; /* ip to connect to */ + char * host; /* host part of user@host */ + char * passwd; + char * spasswd; /* Password to send. */ + char * reason; + char * oper_reason; + char * user; /* user part of user@host */ + time_t hold; /* Hold action until this time (calendar time) */ + struct ConfItem *class_ptr; /* Class of connection */ + int aftype; +#ifdef HAVE_LIBCRYPTO + /* certs */ + char *cipher_list; + char * rsa_public_key_file; + RSA * rsa_public_key; +#endif + void *regexuser; + void *regexhost; + dlink_list leaf_list; + dlink_list hub_list; +}; + +struct ClassItem +{ + dlink_list list_ipv4; /* base of per cidr ipv4 client link list */ + dlink_list list_ipv6; /* base of per cidr ipv6 client link list */ + unsigned int max_sendq; + unsigned int max_recvq; + int con_freq; + int ping_freq; + int ping_warning; + int max_total; + int max_local; + int max_global; + int max_ident; + int max_perip; + int curr_user_count; + int cidr_bitlen_ipv4; + int cidr_bitlen_ipv6; + int number_per_cidr; + int active; +}; + +struct CidrItem +{ + dlink_node node; + struct irc_ssaddr mask; + int number_on_this_cidr; +}; + + +#define CONF_ILLEGAL 0x80000000 +#define CONF_RESERVED 0x00000001 +#define CONF_CLIENT 0x00000002 +#define CONF_SERVER 0x00000004 +#define CONF_OPERATOR 0x00000008 +#define CONF_KLINE 0x00000010 +#define CONF_CLASS 0x00000020 +#define CONF_DLINE 0x00000040 +#define CONF_XLINE 0x00000080 +#define CONF_ULINE 0x00000100 +#define CONF_EXEMPTDLINE 0x00000200 +#define CONF_GLINE 0x00000400 +#define CONF_SERVICE 0x00000800 + +#define CONF_SERVER_MASK CONF_SERVER +#define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER_MASK) + +/* XXX temporary hack */ +#define CONF_CRESV 0x80000001 +#define CONF_NRESV 0x80000002 + +#define IsConfIllegal(x) ((x)->status & CONF_ILLEGAL) +#define SetConfIllegal(x) ((x)->status |= CONF_ILLEGAL) +#define IsConfServer(x) ((x)->status == CONF_SERVER) +#define SetConfServer(x) ((x)->status = CONF_SERVER) +#define IsConfOperator(x) ((x)->status & CONF_OPERATOR) +#define IsConfKill(x) ((x)->status == CONF_KLINE) +#define IsConfClient(x) ((x)->status & CONF_CLIENT) +#define IsConfUline(x) ((x)->status & CONF_ULINE) +#define IsConfXline(x) ((x)->status & CONF_XLINE) +#define IsConfGline(x) ((x)->status == CONF_GLINE) + +/* AccessItem->flags */ + +/* Generic flags... */ +/* access flags... */ +#define CONF_FLAGS_DO_IDENTD 0x00000001 +#define CONF_FLAGS_LIMIT_IP 0x00000002 +#define CONF_FLAGS_NO_TILDE 0x00000004 +#define CONF_FLAGS_NEED_IDENTD 0x00000008 +#define CONF_FLAGS_NOMATCH_IP 0x00000010 +#define CONF_FLAGS_EXEMPTKLINE 0x00000020 +#define CONF_FLAGS_NOLIMIT 0x00000040 +#define CONF_FLAGS_SPOOF_IP 0x00000080 +#define CONF_FLAGS_SPOOF_NOTICE 0x00000100 +#define CONF_FLAGS_REDIR 0x00000200 +#define CONF_FLAGS_EXEMPTGLINE 0x00000400 +#define CONF_FLAGS_CAN_FLOOD 0x00000800 +#define CONF_FLAGS_NEED_PASSWORD 0x00001000 +/* server flags */ +#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00002000 +#define CONF_FLAGS_ENCRYPTED 0x00004000 +#define CONF_FLAGS_TEMPORARY 0x00008000 +#define CONF_FLAGS_EXEMPTRESV 0x00010000 +#define CONF_FLAGS_SSL 0x00020000 + +/* Macros for struct AccessItem */ +#define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP) +#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) +#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) +#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) +#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) +#define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP) +#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) +#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) +#define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE) +#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) +#define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD) +#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) +#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) +#define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED) +#define SetConfEncrypted(x) ((x)->flags |= CONF_FLAGS_ENCRYPTED) +#define ClearConfEncrypted(x) ((x)->flags &= ~CONF_FLAGS_ENCRYPTED) +#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) +#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) +#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) +#define IsConfTemporary(x) ((x)->flags & CONF_FLAGS_TEMPORARY) +#define SetConfTemporary(x) ((x)->flags |= CONF_FLAGS_TEMPORARY) +#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) +#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) +#define SetConfSSL(x) ((x)->flags |= CONF_FLAGS_SSL) +#define ClearConfSSL(x) ((x)->flags &= ~CONF_FLAGS_SSL) + +/* shared/cluster server entry types + * These defines are used for both shared and cluster. + */ +#define SHARED_KLINE 0x0001 +#define SHARED_UNKLINE 0x0002 +#define SHARED_XLINE 0x0004 +#define SHARED_UNXLINE 0x0008 +#define SHARED_RESV 0x0010 +#define SHARED_UNRESV 0x0020 +#define SHARED_LOCOPS 0x0040 +#define SHARED_DLINE 0x0080 +#define SHARED_UNDLINE 0x0100 +#define SHARED_ALL (SHARED_KLINE | SHARED_UNKLINE |\ + SHARED_XLINE | SHARED_UNXLINE |\ + SHARED_RESV | SHARED_UNRESV |\ + SHARED_LOCOPS | SHARED_DLINE | SHARED_UNDLINE) + +struct config_file_entry +{ + const char *dpath; /* DPATH if set from command line */ + const char *configfile; + const char *klinefile; + const char *xlinefile; + const char *dlinefile; + const char *cresvfile; + const char *nresvfile; + + char *egdpool_path; + char *service_name; + + MessageFile motd; + MessageFile linksfile; + + int gline_min_cidr; + int gline_min_cidr6; + int dots_in_ident; + int failed_oper_notice; + int anti_spam_exit_message_time; + unsigned int max_accept; + unsigned int max_watch; + int max_nick_time; + unsigned int max_nick_changes; + int ts_max_delta; + int ts_warn_delta; + int anti_nick_flood; + int warn_no_nline; + int invisible_on_connect; + int stats_e_disabled; + int stats_o_oper_only; + int stats_k_oper_only; + int stats_i_oper_only; + int stats_P_oper_only; + int short_motd; + int no_oper_flood; + int true_no_oper_flood; + int oper_pass_resv; + int glines; + int hide_spoof_ips; + int tkline_expire_notices; + int opers_bypass_callerid; + int ignore_bogus_ts; + int pace_wait; + int pace_wait_simple; + int gline_time; + int gline_request_time; + int oper_only_umodes; + int oper_umodes; + int max_targets; + int caller_id_wait; + int min_nonwildcard; + int min_nonwildcard_simple; + int kill_chase_time_limit; + int default_floodcount; + /* 0 == don't use throttle... */ + int throttle_time; + int use_egd; + int ping_cookie; + int disable_auth; + int disable_remote; +}; + +struct config_channel_entry +{ + int disable_fake_channels; + int restrict_channels; + int knock_delay; + int knock_delay_channel; + unsigned int max_bans; + unsigned int max_chans_per_user; + unsigned int max_chans_per_oper; + int no_create_on_split; + int no_join_on_split; + int quiet_on_ban; + int default_split_server_count; + int default_split_user_count; +}; + +struct config_server_hide +{ + char *hidden_name; + int flatten_links; + int hide_servers; + int links_delay; + int links_disabled; + int hidden; + int hide_server_ips; +}; + +struct server_info +{ + char *sid; + char *name; + char *description; + char *network_name; + char *network_desc; +#ifdef HAVE_LIBCRYPTO + char *rsa_private_key_file; + RSA *rsa_private_key; + SSL_CTX *server_ctx; + SSL_CTX *client_ctx; +#endif + int hub; + struct irc_ssaddr ip; + struct irc_ssaddr ip6; + unsigned int max_clients; + int specific_ipv4_vhost; + int specific_ipv6_vhost; + struct sockaddr_in dns_host; + int can_use_v6; +}; + +struct admin_info +{ + char *name; + char *description; + char *email; +}; + +struct logging_entry +{ + unsigned int use_logging; +}; + +extern dlink_list class_items; +extern dlink_list server_items; +extern dlink_list cluster_items; +extern dlink_list hub_items; +extern dlink_list rxconf_items; +extern dlink_list rkconf_items; +extern dlink_list leaf_items; +extern dlink_list service_items; +extern dlink_list temporary_xlines; +extern struct logging_entry ConfigLoggingEntry; +extern struct config_file_entry ConfigFileEntry;/* defined in ircd.c*/ +extern struct config_channel_entry ConfigChannel;/* defined in channel.c*/ +extern struct config_server_hide ConfigServerHide; /* defined in s_conf.c */ +extern struct server_info ServerInfo; /* defined in ircd.c */ +extern struct admin_info AdminInfo; /* defined in ircd.c */ +extern int valid_wild_card(struct Client *, int, int, ...); +/* End GLOBAL section */ + +extern unsigned int get_sendq(struct Client *); +extern unsigned int get_recvq(struct Client *); +extern const char *get_client_class(struct Client *); +extern int get_client_ping(struct Client *, int *); +extern void check_class(void); +extern void init_class(void); +extern struct ConfItem *find_class(const char *); +extern void init_ip_hash_table(void); +extern void count_ip_hash(unsigned int *, uint64_t *); +extern void remove_one_ip(struct irc_ssaddr *); +extern struct ConfItem *make_conf_item(ConfType type); +extern void free_access_item(struct AccessItem *); +extern void read_conf_files(int); +extern int attach_conf(struct Client *, struct ConfItem *); +extern int attach_connect_block(struct Client *, const char *, const char *); + +extern int detach_conf(struct Client *, ConfType); + +extern struct ConfItem *find_conf_name(dlink_list *, const char *, ConfType); +extern struct ConfItem *find_conf_exact(ConfType, const char *, const char *, const char *); +extern struct AccessItem *find_kill(struct Client *); +extern struct AccessItem *find_gline(struct Client *); +extern int conf_connect_allowed(struct irc_ssaddr *, int); +extern char *oper_privs_as_string(const unsigned int); +extern void split_nuh(struct split_nuh_item *); +extern struct ConfItem *find_matching_name_conf(ConfType, const char *, + const char *, const char *, int); +extern struct ConfItem *find_exact_name_conf(ConfType, const struct Client *, const char *, + const char *, const char *); +extern void delete_conf_item(struct ConfItem *); +extern void report_confitem_types(struct Client *, ConfType); +extern void yyerror(const char *); +extern void write_conf_line(struct Client *, struct ConfItem *, + const char *, time_t); +extern int remove_conf_line(ConfType, struct Client *, const char *, + const char *); +extern void add_temp_line(struct ConfItem *); +extern void cleanup_tklines(void *); +extern const char *get_conf_name(ConfType); +extern int rehash(int); +extern int conf_add_server(struct ConfItem *, const char *); +extern void conf_add_class_to_conf(struct ConfItem *, const char *); + +/* XXX consider moving these into csvlib.h */ +extern void parse_csv_file(FILE *, ConfType); +extern int find_and_delete_temporary(const char *, const char *, int); +extern const char *get_oper_name(const struct Client *); + +extern void *map_to_conf(struct ConfItem *); +extern struct ConfItem *unmap_conf_item(void *); +/* XXX should the parse_aline stuff go into another file ?? */ +#define AWILD 0x1 /* check wild cards */ +extern int parse_aline(const char *, struct Client *, int, char **, + int, char **, char **, time_t *, char **, char **); +extern int valid_comment(struct Client *, char *, int); + + +#define TK_SECONDS 0 +#define TK_MINUTES 1 +extern time_t valid_tkline(const char *, int); +extern int match_conf_password(const char *, const struct AccessItem *); + +#define NOT_AUTHORIZED (-1) +#define I_LINE_FULL (-2) +#define TOO_MANY (-3) +#define BANNED_CLIENT (-4) +#define TOO_FAST (-5) + +#define CLEANUP_TKLINES_TIME 60 + +extern void cluster_a_line(struct Client *, + const char *, int, int, const char *,...); +extern void rebuild_cidr_class(struct ConfItem *, struct ClassItem *); +#endif /* INCLUDED_s_conf_h */ diff --git a/include/dbuf.h b/include/dbuf.h new file mode 100644 index 0000000..6c580b9 --- /dev/null +++ b/include/dbuf.h @@ -0,0 +1,48 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * dbuf.h: A header for the dynamic buffers functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef __DBUF_H_INCLUDED +#define __DBUF_H_INCLUDED + +#define DBUF_BLOCK_SIZE 1024 /* this is also our MTU used for sending */ + +#define dbuf_length(x) ((x)->total_size) +#define dbuf_clear(x) dbuf_delete(x, dbuf_length(x)) + +struct dbuf_block +{ + size_t size; + char data[DBUF_BLOCK_SIZE]; +}; + +struct dbuf_queue +{ + dlink_list blocks; + size_t total_size; +}; + +extern void dbuf_init(void); +extern void dbuf_put(struct dbuf_queue *, char *, size_t); +extern void dbuf_delete(struct dbuf_queue *, size_t); +#endif diff --git a/include/defaults.h b/include/defaults.h new file mode 100644 index 0000000..038bc87 --- /dev/null +++ b/include/defaults.h @@ -0,0 +1,136 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * defaults.h: The ircd defaults header for values and paths. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_defaults_h +#define INCLUDED_defaults_h + +/* Here are some default paths. Most except DPATH are + * configurable at runtime. */ + +/* + * Directory paths and filenames for UNIX systems. + * PREFIX is set using ./configure --prefix, see INSTALL. + * The other defaults should be fine. + * + * NOTE: CHANGING THESE WILL NOT ALTER THE DIRECTORY THAT FILES WILL + * BE INSTALLED TO. IF YOU CHANGE THESE, DO NOT USE MAKE INSTALL, + * BUT COPY THE FILES MANUALLY TO WHERE YOU WANT THEM. + * + * PREFIX = prefix for all directories + * DPATH = root directory of installation + * BINPATH = directory for binary files + * MSGPATH = directory for language files + * ETCPATH = directory for configuration files + * LOGPATH = directory for logfiles + * MODPATH = directory for modules + * AUTOMODPATH = directory for autoloaded modules + */ + +/* dirs */ +#define DPATH PREFIX +#define SBINPATH PREFIX "/sbin/" +#define BINPATH PREFIX "/bin/" +#define MSGPATH DATADIR "/" PACKAGE "/messages" +#define MODPATH LIBDIR "/" PACKAGE "/modules/" +#define HPATH DATADIR "/" PACKAGE "/help/opers" +#define UHPATH DATADIR "/" PACKAGE "/help/users" +#define AUTOMODPATH MODPATH "/autoload/" +#define ETCPATH SYSCONFDIR +#define LOGPATH LOCALSTATEDIR "/log" + +/* files */ +#define SPATH SBINPATH "/ircd" /* ircd executable */ +#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ +#define KPATH ETCPATH "/kline.conf" /* kline file */ +#define CRESVPATH ETCPATH "/cresv.conf" /* channel resvs file */ +#define NRESVPATH ETCPATH "/nresv.conf" /* nick resvs file */ +#define DLPATH ETCPATH "/dline.conf" /* dline file */ +#define XPATH ETCPATH "/xline.conf" /* xline file */ +#define MPATH ETCPATH "/ircd.motd" /* MOTD file */ +#define LPATH LOGPATH "/ircd.log" /* ircd logfile */ +#define PPATH LOCALSTATEDIR "/ircd.pid" /* pid file */ +#define LIPATH ETCPATH "/links.txt" /* cached links file */ + +/* + * This file is included to supply default values for things which + * are now configurable at runtime. + */ + +#define HYBRID_SOMAXCONN 25 +#define MAX_TDKLINE_TIME (24*60*360) + +/* tests show that about 7 fds are not registered by fdlist.c, these + * include std* descriptors + some others (by OpenSSL etc.). Note this is + * intentionally too high, we don't want to eat fds up to the last one */ +#define LEAKED_FDS 10 +/* how many (privileged) clients can exceed max_clients */ +#define MAX_BUFFER 60 + +#define MAXCLIENTS_MAX (hard_fdlimit - LEAKED_FDS - MAX_BUFFER) +#define MAXCLIENTS_MIN 32 + +/* class {} default values */ +#define DEFAULT_SENDQ 9000000 /* default max SendQ */ +#define DEFAULT_RECVQ 2560 /* default max RecvQ */ +#define PORTNUM 6667 /* default outgoing portnum */ +#define DEFAULT_PINGFREQUENCY 120 /* Default ping frequency */ +#define DEFAULT_CONNECTFREQUENCY 600 /* Default connect frequency */ +#define CLIENT_FLOOD_MAX 8000 +#define CLIENT_FLOOD_MIN 512 + +#define WATCHSIZE_MIN 1 +#define WATCHSIZE_DEFAULT 32 +#define TS_MAX_DELTA_MIN 10 /* min value for ts_max_delta */ +#define TS_MAX_DELTA_DEFAULT 600 /* default for ts_max_delta */ +#define TS_WARN_DELTA_MIN 10 /* min value for ts_warn_delta */ +#define TS_WARN_DELTA_DEFAULT 30 /* default for ts_warn_delta */ + +/* ServerInfo default values */ +#define NETWORK_NAME_DEFAULT "EFnet" /* default for network_name */ +#define NETWORK_DESC_DEFAULT "Eris Free Network" /* default for network_desc */ +#define SERVICE_NAME_DEFAULT "service.someserver" + +#define GLINE_REQUEST_EXPIRE_DEFAULT 600 + +/* General defaults */ +#define MAXIMUM_LINKS_DEFAULT 0 /* default for maximum_links */ + +#define LINKS_DELAY_DEFAULT 300 + +#define MAX_TARGETS_DEFAULT 4 /* default for max_targets */ + +#define INIT_LOG_LEVEL L_NOTICE /* default for log_level */ + +#define CONNECTTIMEOUT 30 /* Recommended value: 30 */ +#define IDENT_TIMEOUT 10 + +#define MIN_JOIN_LEAVE_TIME 60 +#define MAX_JOIN_LEAVE_COUNT 25 +#define OPER_SPAM_COUNTDOWN 5 +#define JOIN_LEAVE_COUNT_EXPIRE_TIME 120 + +#define MIN_SPAM_NUM 5 +#define MIN_SPAM_TIME 60 + +#endif /* INCLUDED_defaults_h */ diff --git a/include/event.h b/include/event.h new file mode 100644 index 0000000..f9b6ab0 --- /dev/null +++ b/include/event.h @@ -0,0 +1,57 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * event.h: The ircd event header. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_event_h +#define INCLUDED_event_h + +/* + * How many event entries we need to allocate at a time in the block + * allocator. 16 should be plenty at a time. + */ +#define MAX_EVENTS 50 + + +typedef void EVH(void *); + +/* The list of event processes */ +struct ev_entry +{ + EVH *func; + void *arg; + const char *name; + time_t frequency; + time_t when; + int active; +}; + +extern void eventAdd(const char *, EVH *, void *, time_t); +extern void eventAddIsh(const char *, EVH *, void *, time_t); +extern void eventRun(void); +extern time_t eventNextTime(void); +extern void eventInit(void); +extern void eventDelete(EVH *, void *); +extern void set_back_events(time_t); +extern void show_events(struct Client *); + +#endif /* INCLUDED_event_h */ diff --git a/include/fdlist.h b/include/fdlist.h new file mode 100644 index 0000000..06313ec --- /dev/null +++ b/include/fdlist.h @@ -0,0 +1,113 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * fdlist.h: The file descriptor list header. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_fdlist_h +#define INCLUDED_fdlist_h +#define FILEIO_V2 + +#include "ircd_defs.h" +#define FD_DESC_SZ 128 /* hostlen + comment */ + +enum { + COMM_OK, + COMM_ERR_BIND, + COMM_ERR_DNS, + COMM_ERR_TIMEOUT, + COMM_ERR_CONNECT, + COMM_ERROR, + COMM_ERR_MAX +}; + +struct _fde; +struct Client; + +/* Callback for completed IO events */ +typedef void PF(struct _fde *, void *); + +/* Callback for completed connections */ +/* int fd, int status, void * */ +typedef void CNCB(struct _fde *, int, void *); + +typedef struct _fde { + /* New-school stuff, again pretty much ripped from squid */ + /* + * Yes, this gives us only one pending read and one pending write per + * filedescriptor. Think though: when do you think we'll need more? + */ + int fd; /* So we can use the fde_t as a callback ptr */ + int comm_index; /* where in the poll list we live */ + int evcache; /* current fd events as set up by the underlying I/O */ + char desc[FD_DESC_SZ]; + PF *read_handler; + void *read_data; + PF *write_handler; + void *write_data; + PF *timeout_handler; + void *timeout_data; + time_t timeout; + PF *flush_handler; + void *flush_data; + time_t flush_timeout; + + struct { + unsigned int open:1; + unsigned int is_socket:1; +#ifdef HAVE_LIBCRYPTO + unsigned int pending_read:1; +#endif + } flags; + + struct { + /* We don't need the host here ? */ + struct irc_ssaddr S; + struct irc_ssaddr hostaddr; + CNCB *callback; + void *data; + /* We'd also add the retry count here when we get to that -- adrian */ + } connect; +#ifdef HAVE_LIBCRYPTO + SSL *ssl; +#endif + struct _fde *hnext; +} fde_t; + +#define FD_HASH_SIZE CLIENT_HEAP_SIZE + +extern int number_fd; +extern int hard_fdlimit; +extern fde_t *fd_hash[]; +extern fde_t *fd_next_in_loop; +extern struct Callback *fdlimit_cb; + +extern void fdlist_init(void); +extern fde_t *lookup_fd(int); +extern void fd_open(fde_t *, int, int, const char *); +extern void fd_close(fde_t *); +extern void fd_dump(struct Client *); +extern void fd_note(fde_t *, const char *, ...); +extern void close_standard_fds(void); +extern void close_fds(fde_t *); +extern void recalc_fdlimit(void *); + +#endif /* INCLUDED_fdlist_h */ diff --git a/include/hash.h b/include/hash.h new file mode 100644 index 0000000..a75815f --- /dev/null +++ b/include/hash.h @@ -0,0 +1,70 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * hash.h: A header for the ircd hashtable code. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_hash_h +#define INCLUDED_hash_h + +#define FNV1_32_INIT 0x811c9dc5 +#define FNV1_32_BITS 16 +#define FNV1_32_SIZE (1 << FNV1_32_BITS) /* 2^16 = 65536 */ +#define HASHSIZE FNV1_32_SIZE + +struct Client; +struct Channel; +struct ResvChannel; +struct UserHost; + +enum { + HASH_TYPE_ID, + HASH_TYPE_CLIENT, + HASH_TYPE_CHANNEL, + HASH_TYPE_USERHOST, + HASH_TYPE_RESERVED +}; + +extern void init_hash(void); +extern void hash_add_client(struct Client *); +extern void hash_del_client(struct Client *); +extern void hash_add_channel(struct Channel *); +extern void hash_del_channel(struct Channel *); +extern void hash_add_resv(struct ResvChannel *); +extern void hash_del_resv(struct ResvChannel *); +extern void hash_add_id(struct Client *); +extern void hash_del_id(struct Client *); +extern void hash_add_userhost(struct UserHost *); +extern void hash_del_userhost(struct UserHost *); + +extern struct UserHost *hash_find_userhost(const char *); +extern struct Client *hash_find_id(const char *); +extern struct Client *hash_find_client(const char *); +extern struct Client *hash_find_server(const char *); +extern struct Channel *hash_find_channel(const char *); +extern void *hash_get_bucket(int, unsigned int); +extern struct ResvChannel *hash_find_resv(const char *); + +extern void free_list_task(struct ListTask *, struct Client *); +extern void safe_list_channels(struct Client *, struct ListTask *, int); + +extern unsigned int strhash(const char *); +#endif /* INCLUDED_hash_h */ diff --git a/include/hook.h b/include/hook.h new file mode 100644 index 0000000..93ecfb6 --- /dev/null +++ b/include/hook.h @@ -0,0 +1,53 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * hook.h: A header for the hooks into parts of ircd. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef __HOOK_H_INCLUDED +#define __HOOK_H_INCLUDED + +#define HOOK_V2 + +typedef void *CBFUNC(va_list); + +struct Callback +{ + char *name; + dlink_list chain; + dlink_node node; + unsigned int called; + time_t last; +}; + +struct Client; + +extern struct Callback *register_callback(const char *, CBFUNC *); +extern void *execute_callback(struct Callback *, ...); +extern struct Callback *find_callback(const char *); +extern dlink_node *install_hook(struct Callback *, CBFUNC *); +extern void uninstall_hook(struct Callback *, CBFUNC *); +extern void *pass_callback(dlink_node *, ...); +extern void stats_hooks(struct Client *); + +#define is_callback_present(c) (!!dlink_list_length(&c->chain)) + +#endif diff --git a/include/hostmask.h b/include/hostmask.h new file mode 100644 index 0000000..63abb88 --- /dev/null +++ b/include/hostmask.h @@ -0,0 +1,86 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * hostmask.h: A header for the hostmask code. + * + * Copyright (C) 2005 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDE_hostmask_h +#define INCLUDE_hostmask_h 1 + +#define ATABLE_SIZE 0x1000 + + +enum hostmask_type +{ + HM_HOST, + HM_IPV4, + HM_IPV6 +}; + +struct AddressRec +{ + /* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */ + enum hostmask_type masktype; + + union + { + struct + { + /* Pointer into AccessItem... -A1kmm */ + struct irc_ssaddr addr; + int bits; + } ipa; + + /* Pointer into AccessItem... -A1kmm */ + const char *hostname; + } Mask; + + /* type: CONF_CLIENT, CONF_DLINE, CONF_KLINE etc... -A1kmm */ + unsigned int type; + + /* Higher precedences overrule lower ones... */ + unsigned int precedence; + + /* Only checked if !(type & 1)... */ + const char *username; + struct AccessItem *aconf; + + dlink_node node; +}; + +extern dlink_list atable[ATABLE_SIZE]; +extern int parse_netmask(const char *, struct irc_ssaddr *, int *); +extern int match_ipv6(const struct irc_ssaddr *, const struct irc_ssaddr *, int); +extern int match_ipv4(const struct irc_ssaddr *, const struct irc_ssaddr *, int); + +extern void mask_addr(struct irc_ssaddr *, int); +extern void init_host_hash(void); +extern void add_conf_by_address(const unsigned int, struct AccessItem *); +extern void delete_one_address_conf(const char *, struct AccessItem *); +extern void clear_out_address_conf(void); +extern void hostmask_expire_temporary(void); + +extern struct AccessItem *find_address_conf(const char *, const char *, + struct irc_ssaddr *, int, char *); +extern struct AccessItem *find_dline_conf(struct irc_ssaddr *, int); +extern struct AccessItem *find_conf_by_address(const char *, struct irc_ssaddr *, + unsigned int, int, const char *, const char *, int); +#endif /* INCLUDE_hostmask_h */ diff --git a/include/irc_res.h b/include/irc_res.h new file mode 100644 index 0000000..cddd955 --- /dev/null +++ b/include/irc_res.h @@ -0,0 +1,85 @@ +/* + * include/irc_res.h for referencing functions in src/irc_res.c + * + * $Id$ + */ + +#ifndef INCLUDED_irc_res_h +#define INCLUDED_irc_res_h + +#include "config.h" + +struct Client; /* XXX */ + +/* Here we define some values lifted from nameser.h */ +#define NS_NOTIFY_OP 4 +#define NS_INT16SZ 2 +#define NS_IN6ADDRSZ 16 +#define NS_INADDRSZ 4 +#define NS_INT32SZ 4 +#define NS_CMPRSFLGS 0xc0 +#define NS_MAXCDNAME 255 +#define QUERY 0 +#define IQUERY 1 +#define NO_ERRORS 0 +#define SERVFAIL 2 +#define NXDOMAIN 3 +#define T_A 1 +#define T_AAAA 28 +#define T_PTR 12 +#define T_CNAME 5 +#define T_NULL 10 +#define C_IN 1 +#define QFIXEDSZ 4 +#define RRFIXEDSZ 10 +#define HFIXEDSZ 12 + + + +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; + +typedef void (*dns_callback_fnc)(void *, const struct irc_ssaddr *, const char *); + +extern void init_resolver(void); +extern void restart_resolver(void); +extern void delete_resolver_queries(const void *); +extern void report_dns_servers(struct Client *); +extern void gethost_byname_type(dns_callback_fnc , void *, const char *, int); +extern void gethost_byname(dns_callback_fnc, void *, const char *); +extern void gethost_byaddr(dns_callback_fnc, void *, const struct irc_ssaddr *); +#endif diff --git a/include/irc_reslib.h b/include/irc_reslib.h new file mode 100644 index 0000000..cd3e923 --- /dev/null +++ b/include/irc_reslib.h @@ -0,0 +1,59 @@ +/* + * include/irc_reslib.h (C)opyright 1992 Darren Reed. + * + * $Id$ + */ +#ifndef INCLUDED_ircdreslib_h +#define INCLUDED_ircdreslib_h + +/* + * Inline versions of get/put short/long. Pointer is advanced. + */ +#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; \ +} + +#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; \ +} + +#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; \ +} + +#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; \ +} + +extern struct irc_ssaddr irc_nsaddr_list[]; +extern int irc_nscount; +extern void irc_res_init(void); +extern int irc_dn_expand(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, int dstsiz); +extern int irc_dn_skipname(const unsigned char *ptr, const unsigned char *eom); +extern unsigned int irc_ns_get16(const unsigned char *src); +extern unsigned long irc_ns_get32(const unsigned char *src); +extern void irc_ns_put16(unsigned int src, unsigned char *dst); +extern void irc_ns_put32(unsigned long src, unsigned char *dst); +extern int irc_res_mkquery(const char *dname, int class, int type, unsigned char *buf, int buflen); +#endif /* INCLUDED_res_h */ + diff --git a/include/irc_string.h b/include/irc_string.h new file mode 100644 index 0000000..13a57c9 --- /dev/null +++ b/include/irc_string.h @@ -0,0 +1,150 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * irc_string.h: A header for the ircd string functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_irc_string_h +#define INCLUDED_irc_string_h + +#include "config.h" + + +extern int has_wildcards(const char *); +extern int ircd_pcre_exec(const void *, const char *); +extern void *ircd_pcre_compile(const char *, const char **); + +/* + * match - compare name with mask, mask may contain * and ? as wildcards + * match - returns 1 on successful match, 0 otherwise + * + * match_esc - compare with support for escaping chars + * match_chan - like match_esc with first character auto-escaped + */ +extern int match(const char *, const char *); +extern int match_esc(const char *, const char *); +extern int match_chan(const char *, const char *); + +/* + * collapse - collapse a string in place, converts multiple adjacent *'s + * into a single *. + * collapse - modifies the contents of pattern + * + * collapse_esc() - collapse with support for escaping chars + */ +extern char *collapse(char *); +extern char *collapse_esc(char *); + +/* + * NOTE: The following functions are NOT the same as strcasecmp + * and strncasecmp! These functions use the Finnish (RFC1459) + * character set. Do not replace! + * + * irccmp - case insensitive comparison of s1 and s2 + */ +extern int irccmp(const char *, const char *); + +/* + * ircncmp - counted case insensitive comparison of s1 and s2 + */ +extern int ircncmp(const char *, const char *, size_t); + +#ifndef HAVE_STRLCPY +extern size_t strlcpy(char *, const char *, size_t); +#endif + +#ifndef HAVE_STRLCAT +extern size_t strlcat(char *, const char *, size_t); +#endif + +extern const char *libio_basename(const char *); + +/* + * strip_tabs - convert tabs to spaces + * - jdc + */ +extern void strip_tabs(char *, const char *, size_t); + +const char *myctime(time_t); + +#define EmptyString(x) (!(x) || (*(x) == '\0')) + +#ifndef HAVE_STRTOK_R +extern char *strtoken(char **, char *, const char *); +#endif + +/* + * character macros + */ +extern const unsigned char ToLowerTab[]; +#define ToLower(c) (ToLowerTab[(unsigned char)(c)]) + +extern const unsigned char ToUpperTab[]; +#define ToUpper(c) (ToUpperTab[(unsigned char)(c)]) + +extern const unsigned int CharAttrs[]; + +#define PRINT_C 0x00001 +#define CNTRL_C 0x00002 +#define ALPHA_C 0x00004 +#define PUNCT_C 0x00008 +#define DIGIT_C 0x00010 +#define SPACE_C 0x00020 +#define NICK_C 0x00040 +#define CHAN_C 0x00080 +#define KWILD_C 0x00100 +#define CHANPFX_C 0x00200 +#define USER_C 0x00400 +#define HOST_C 0x00800 +#define NONEOS_C 0x01000 +#define SERV_C 0x02000 +#define EOL_C 0x04000 +#define MWILD_C 0x08000 +#define VCHAN_C 0x10000 + +#define IsVisibleChanChar(c) (CharAttrs[(unsigned char)(c)] & VCHAN_C) +#define IsHostChar(c) (CharAttrs[(unsigned char)(c)] & HOST_C) +#define IsUserChar(c) (CharAttrs[(unsigned char)(c)] & USER_C) +#define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C) +#define IsChanChar(c) (CharAttrs[(unsigned char)(c)] & CHAN_C) +#define IsKWildChar(c) (CharAttrs[(unsigned char)(c)] & KWILD_C) +#define IsMWildChar(c) (CharAttrs[(unsigned char)(c)] & MWILD_C) +#define IsNickChar(c) (CharAttrs[(unsigned char)(c)] & NICK_C) +#define IsServChar(c) (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C)) +#define IsCntrl(c) (CharAttrs[(unsigned char)(c)] & CNTRL_C) +#define IsAlpha(c) (CharAttrs[(unsigned char)(c)] & ALPHA_C) +#define IsSpace(c) (CharAttrs[(unsigned char)(c)] & SPACE_C) +#define IsLower(c) (IsAlpha((c)) && ((unsigned char)(c) > 0x5f)) +#define IsUpper(c) (IsAlpha((c)) && ((unsigned char)(c) < 0x60)) +#define IsDigit(c) (CharAttrs[(unsigned char)(c)] & DIGIT_C) +#define IsXDigit(c) (IsDigit(c) || ('a' <= (c) && (c) <= 'f') || \ + ('A' <= (c) && (c) <= 'F')) +#define IsAlNum(c) (CharAttrs[(unsigned char)(c)] & (DIGIT_C | ALPHA_C)) +#define IsPrint(c) (CharAttrs[(unsigned char)(c)] & PRINT_C) +#define IsAscii(c) ((unsigned char)(c) < 0x80) +#define IsGraph(c) (IsPrint((c)) && ((unsigned char)(c) != 0x32)) +#define IsPunct(c) (!(CharAttrs[(unsigned char)(c)] & \ + (CNTRL_C | ALPHA_C | DIGIT_C))) + +#define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C) +#define IsEol(c) (CharAttrs[(unsigned char)(c)] & EOL_C) + +#endif /* INCLUDED_irc_string_h */ diff --git a/include/ircd.h b/include/ircd.h new file mode 100644 index 0000000..e55db3f --- /dev/null +++ b/include/ircd.h @@ -0,0 +1,124 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * ircd.h: A header for the ircd startup routines. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_ircd_h +#define INCLUDED_ircd_h + +#include "ircd_defs.h" +#include "config.h" +#include "memory.h" +#include "list.h" + +struct Client; + +struct SetOptions +{ + int autoconn; /* autoconn enabled for all servers? */ + int floodcount; /* Number of messages in 1 second */ + int joinfloodtime; + int joinfloodcount; + int ident_timeout; /* timeout for identd lookups */ + int spam_num; + int spam_time; +}; + +/* + * statistics structures + */ +struct ServerStatistics +{ + uint64_t is_cbs; /* bytes sent to clients */ + uint64_t is_cbr; /* bytes received from clients */ + uint64_t is_sbs; /* bytes sent to servers */ + uint64_t is_sbr; /* bytes received from servers */ + + time_t is_cti; /* time spent connected by clients */ + time_t is_sti; /* time spent connected by servers */ + + 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 */ + 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_asuc; /* successful auth requests */ + unsigned int is_abad; /* bad auth requests */ +}; + +extern struct ServerStatistics ServerStats; + + +struct Counter +{ + uint64_t totalrestartcount; /* Total client count ever */ + unsigned int myserver; /* my servers */ + unsigned int oper; /* Opers */ + unsigned int local; /* Local Clients */ + unsigned int total; /* total clients */ + unsigned int invisi; /* invisible clients */ + unsigned int max_loc; /* MAX local clients */ + unsigned int max_tot; /* MAX global clients */ + unsigned int max_loc_con; /* MAX local connection count (clients + server) */ + unsigned int max_loc_cli; /* XXX This is redundant - Max local client count */ +}; + +extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */ + +struct ServerState_t +{ + int foreground; +}; + +extern struct ServerState_t server_state; + +extern char **myargv; +extern const char *infotext[]; +extern const char *serno; +extern const char *ircd_version; +extern const char *logFileName; +extern const char *pidFileName; +extern int dorehash; +extern int doremotd; +extern struct Counter Count; +extern struct timeval SystemTime; +#define CurrentTime SystemTime.tv_sec +extern int default_server_capabs; +extern unsigned int splitmode; +extern unsigned int splitchecking; +extern unsigned int split_users; +extern unsigned int split_servers; + +extern dlink_list unknown_list; /* unknown clients ON this server only */ +extern dlink_list local_client_list; /* local clients only ON this server */ +extern dlink_list serv_list; /* local servers to this server ONLY */ +extern dlink_list global_serv_list; /* global servers on the network */ +extern dlink_list oper_list; /* our opers, duplicated in local_client_list */ +extern int rehashed_klines; +extern void set_time(void); +#endif diff --git a/include/ircd_defs.h b/include/ircd_defs.h new file mode 100644 index 0000000..55215eb --- /dev/null +++ b/include/ircd_defs.h @@ -0,0 +1,73 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * ircd_defs.h: A header for ircd global definitions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +/* + * NOTE: NICKLEN and TOPICLEN do not live here anymore. Set it with configure + * Otherwise there are no user servicable part here. + * + */ + /* ircd_defs.h - Global size definitions for record entries used + * througout ircd. Please think 3 times before adding anything to this + * file. + */ +#ifndef INCLUDED_ircd_defs_h +#define INCLUDED_ircd_defs_h +#include "stdinc.h" +/* Right out of the RFC */ +#define IRCD_BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ +#define HOSTLEN 63 /* Length of hostname. Updated to comply + with RFC 1123 */ +#define USERLEN 10 +#define PORTNAMELEN 6 /* ":31337" */ + +#define HOSTIPLEN 45 /* sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") */ +#define PASSWDLEN 20 +#define IDLEN 12 /* this is the maximum length, not the actual + generated length; DO NOT CHANGE! */ +#define REALLEN 50 +#define KILLLEN 90 +#define LOCAL_CHANNELLEN 50 +#define CHANNELLEN 200 +#define REASONLEN 120 +#define KICKLEN 160 +#define AWAYLEN 160 +#define KEYLEN 23 + +#define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) +#define MAX_DATE_STRING 32 /* maximum string length for a date string */ +#define IRCD_MAXNS 3 /* Maximum number of nameservers in + /etc/resolv.conf we care about */ + +#define LOWEST_SAFE_FD 4 /* skip stdin, stdout, stderr, and profiler */ + +/* This is to get around the fact that some implementations have ss_len and + * others do not + */ +struct irc_ssaddr +{ + struct sockaddr_storage ss; + unsigned char ss_len; + in_port_t ss_port; +}; +#endif /* INCLUDED_ircd_defs_h */ diff --git a/include/ircd_getopt.h b/include/ircd_getopt.h new file mode 100644 index 0000000..3a680ba --- /dev/null +++ b/include/ircd_getopt.h @@ -0,0 +1,36 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * ircd_getopt.h: A header for the getopt() command line option calls. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef __GETOPT_H_INCLUDED__ +#define __GETOPT_H_INCLUDED__ + +struct lgetopt { + const char *opt; /* name of the argument */ + void *argloc; /* where we store the argument to it (-option argument) */ + enum { INTEGER, YESNO, STRING, USAGE, ENDEBUG } argtype; + const char *desc; /* description of the argument, usage for printing help */ +}; + +extern void parseargs(int *, char ***, struct lgetopt *); +#endif /* __GETOPT_H_INCLUDED__ */ diff --git a/include/ircd_signal.h b/include/ircd_signal.h new file mode 100644 index 0000000..3871e98 --- /dev/null +++ b/include/ircd_signal.h @@ -0,0 +1,31 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * ircd_signal.h: A header for ircd signals. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_ircd_signal_h +#define INCLUDED_ircd_signal_h + +extern void setup_signals(void); + +#endif /* INCLUDED_ircd_signal_h */ + diff --git a/include/list.h b/include/list.h new file mode 100644 index 0000000..9101f32 --- /dev/null +++ b/include/list.h @@ -0,0 +1,83 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * list.h: A header for the code in list.c. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_list_h +#define INCLUDED_list_h + +/* These macros are basically swiped from the linux kernel + * they are simple yet effective + */ + +/* + * Walks forward of a list. + * pos is your node + * head is your list head + */ +#define DLINK_FOREACH(pos, head) for (pos = (head); pos != NULL; pos = pos->next) + +/* + * Walks forward of a list safely while removing nodes + * pos is your node + * n is another list head for temporary storage + * head is your list head + */ +#define DLINK_FOREACH_SAFE(pos, n, head) for (pos = (head), n = pos ? pos->next : NULL; pos != NULL; pos = n, n = pos ? pos->next : NULL) +#define DLINK_FOREACH_PREV(pos, head) for (pos = (head); pos != NULL; pos = pos->prev) + +/* Returns the list length */ +#define dlink_list_length(list) (list)->length + +/* + * double-linked-list stuff + */ +typedef struct _dlink_node dlink_node; +typedef struct _dlink_list dlink_list; + +struct _dlink_node +{ + void *data; + dlink_node *prev; + dlink_node *next; +}; + +struct _dlink_list +{ + dlink_node *head; + dlink_node *tail; + unsigned int length; +}; + +extern void dlinkAdd(void *, dlink_node *, dlink_list *); +extern void dlinkAddBefore(dlink_node *, void *, dlink_node *, dlink_list *); +extern void dlinkAddTail(void *, dlink_node *, dlink_list *); +extern void dlinkDelete(dlink_node *, dlink_list *); +extern void dlinkMoveList(dlink_list *, dlink_list *); +extern void dlink_move_node(dlink_node *, dlink_list *, dlink_list *); +extern dlink_node *dlinkFind(dlink_list *, void *); +extern dlink_node *dlinkFindDelete(dlink_list *, void *); + +extern void init_dlink_nodes(void); +extern void free_dlink_node(dlink_node *); +extern dlink_node *make_dlink_node(void); +#endif diff --git a/include/listener.h b/include/listener.h new file mode 100644 index 0000000..6e402f6 --- /dev/null +++ b/include/listener.h @@ -0,0 +1,54 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * listener.h: A header for the listener code. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_listener_h +#define INCLUDED_listener_h + +#define LISTENER_SSL 0x1 +#define LISTENER_HIDDEN 0x2 +#define LISTENER_SERVER 0x4 + +#include "ircd_defs.h" +#include "fdlist.h" + +struct Client; + +struct Listener +{ + dlink_node listener_node; /* list node pointer */ + fde_t fd; /* file descriptor */ + int port; /* listener IP port */ + int ref_count; /* number of connection references */ + int active; /* current state of listener */ + struct irc_ssaddr addr; /* virtual address or INADDR_ANY */ + char name[HOSTLEN + 1]; /* virtual name of listener */ + unsigned int flags; +}; + +extern void add_listener(int, const char *, unsigned int); +extern void close_listeners(void); +extern const char *get_listener_name(const struct Listener *const); +extern void show_ports(struct Client *); +extern void free_listener(struct Listener *); +#endif /* INCLUDED_listener_h */ diff --git a/include/log.h b/include/log.h new file mode 100644 index 0000000..3467e51 --- /dev/null +++ b/include/log.h @@ -0,0 +1,46 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * log.h: A header for the logger functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_log_h +#define INCLUDED_s_log_h + +#define LOG_BUFSIZE 1024 + +enum log_type { + LOG_TYPE_IRCD, + LOG_TYPE_KILL, + LOG_TYPE_KLINE, + LOG_TYPE_DLINE, + LOG_TYPE_GLINE, + LOG_TYPE_OPER, + LOG_TYPE_USER, + LOG_TYPE_DEBUG, + LOG_TYPE_LAST +}; + +extern int log_add_file(enum log_type, size_t, const char *); +extern void log_close_all(void); +extern void ilog(enum log_type, const char *, ...); + +#endif /* INCLUDED_s_log_h */ diff --git a/include/memory.h b/include/memory.h new file mode 100644 index 0000000..8ed1bb1 --- /dev/null +++ b/include/memory.h @@ -0,0 +1,45 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * memory.h: A header for the memory functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef _I_MEMORY_H +#define _I_MEMORY_H + +#include "ircd_defs.h" +#include "config.h" + +extern void outofmemory(void); + +extern void *MyMalloc(size_t); +extern void *MyRealloc(void *, size_t); +extern void MyFree(void *); +extern void _DupString(char **, const char *); + +#define DupString(x,y) _DupString(&x, y) + +#ifndef NDEBUG +extern void mem_frob(void *, int); +#else +#define mem_frob(x, y) +#endif +#endif /* _I_MEMORY_H */ diff --git a/include/modules.h b/include/modules.h new file mode 100644 index 0000000..f96d544 --- /dev/null +++ b/include/modules.h @@ -0,0 +1,74 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * modules.h: A header for the modules functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_modules_h +#define INCLUDED_modules_h + +#include "config.h" + + +#define MODULE_FLAG_CORE 0x1 +#define MODULE_FLAG_NOUNLOAD 0x2 + +struct module +{ + dlink_node node; + char *name; + const char *version; + void *handle; + void (*modinit)(void); + void (*modexit)(void); + unsigned int flags; +}; + +struct module_path +{ + dlink_node node; + char path[PATH_MAX + 1]; +}; + +extern dlink_list modules_list; + +/* add a path */ +extern void mod_add_path(const char *); +extern void mod_clear_paths(void); + +/* load all modules */ +extern void load_all_modules(int); + +/* load core modules */ +extern void load_core_modules(int); + +/* Add this module to list of modules to be loaded from conf */ +extern void add_conf_module(const char *); +/* load all modules listed in conf */ +extern void load_conf_modules(void); +extern void modules_init(void); + +extern int unload_one_module(const char *, int); +extern int modules_valid_suffix(const char *); +extern int load_one_module(const char *); +extern int load_a_module(const char *, int); +extern struct module *findmodule_byname(const char *); +#endif /* INCLUDED_modules_h */ diff --git a/include/motd.h b/include/motd.h new file mode 100644 index 0000000..24e15e6 --- /dev/null +++ b/include/motd.h @@ -0,0 +1,65 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * motd.h: A header for the MOTD functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_motd_h +#define INCLUDED_motd_h +#include "ircd_defs.h" + + +#define MESSAGELINELEN 256 + +struct MessageFileLine +{ + struct MessageFileLine *next; + char line[MESSAGELINELEN + 1]; +}; + +typedef struct MessageFileLine MessageFileLine; + +typedef enum { + USER_MOTD, + USER_LINKS, + ISSUPPORT +} MotdType; + +struct MessageFile +{ + MessageFileLine *contentsOfFile; + MotdType motdType; + char fileName[PATH_MAX + 1]; + char lastChangedDate[MAX_DATE_STRING + 1]; +}; + +typedef struct MessageFile MessageFile; + +struct Client; + +extern void init_message_file(MotdType, const char *, struct MessageFile *); +extern int send_message_file(struct Client *, struct MessageFile *); +extern int read_message_file(MessageFile *); +extern MessageFile *init_MessageLine(void); +extern void addto_MessageLine(MessageFile *, const char *); +extern void destroy_MessageLine(MessageFile *); + +#endif /* INCLUDED_motd_h */ diff --git a/include/numeric.h b/include/numeric.h new file mode 100644 index 0000000..558b7e5 --- /dev/null +++ b/include/numeric.h @@ -0,0 +1,483 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * numeric.h: A header for the numeric functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_numeric_h +#define INCLUDED_numeric_h + +#define LOCALE_LENGTH 64 /* maximum length of locale name + 1 */ + +struct NumericInfo +{ + const char *name; /* common name of the numeric */ + const char *standard; /* standard numeric text */ + char *translated; /* translated numeric text */ +}; + +/* form_str - return a format string for a message number + * messages are defined below + */ +extern const char *form_str(int); +extern void set_locale(const char *); +extern const char *get_locale(void); + +/* + * 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 001 +#define RPL_YOURHOST 002 +#define RPL_CREATED 003 +#define RPL_MYINFO 004 +#define RPL_ISUPPORT 005 + /* RPL_BOUNCE IRCnet extension */ +/* RPL_MAP 6 unreal */ +/* RPL_MAPEND 7 unreal */ +/* RPL_SNOMASK 8 Undernet extension */ +/* RPL_STATMEMTOT 9 Undernet extension */ +/* RPL_STATMEM 10 Undernet extension */ + +#define RPL_REDIR 10 +#define RPL_MAP 15 /* Undernet extension */ +#define RPL_MAPMORE 16 /* Undernet extension */ +#define RPL_MAPEND 17 /* Undernet extension */ + +#define RPL_YOURID 42 /* IRCnet extension */ +/* RPL_ATTEMPTINGJUNC 50 aircd extension */ +/* RPL_ATTEMPTINGREROUTE 51 aircd extension */ + +/* + * Numeric 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 +#define RPL_STATSNLINE 214 +/* RPL_STATSOLDNLINE 214 unreal */ +#define RPL_STATSILINE 215 +#define RPL_STATSKLINE 216 +#define RPL_STATSQLINE 217 +#define RPL_STATSYLINE 218 +#define RPL_ENDOFSTATS 219 +/* note ircu uses 217 for STATSPLINE frip. conflict + * as RPL_STATSQLINE was used in old 2.8 for Q line + * I'm going to steal 220 for now *sigh* + * -Dianora + */ + +#define RPL_STATSPLINE 220 +#define RPL_UMODEIS 221 + +/* RPL_SQLINE_NICK 222 Numerics List: Dalnet */ +/* 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_STATSFLINE 224 +#define RPL_STATSDLINE 225 +#define RPL_STATSALINE 226 + +/* RPL_RULES 232 unreal */ + +/* RPL_STATSIAUTH 239 IRCnet extension */ +/* RPL_STATSVLINE 240 IRCnet extension */ +/* RPL_STATSXLINE 240 austnet */ + +#define RPL_STATSLLINE 241 +#define RPL_STATSUPTIME 242 +#define RPL_STATSOLINE 243 +#define RPL_STATSHLINE 244 +/* 245 No longer used in ircd-hybrid */ +#define RPL_STATSSLINE 245 +#define RPL_STATSSERVICE 246 +#define RPL_STATSXLINE 247 +#define RPL_STATSULINE 248 +#define RPL_STATSDEBUG 249 +#define RPL_STATSCONN 250 +/* 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 + +#define RPL_ENDOFTRACE 262 +#define RPL_LOAD2HI 263 + +/* RPL_TRYAGAIN 263 Numerics List: IRCnet */ +/* RPL_LOAD2HI 263 Dalnet */ +/* RPL_CURRENT_LOCAL 265 aircd/efnet/hybrid/dalnet*/ +/* RPL_CURRENT_GLOBAL 266 aircd/efnet/hybrid/dalnet */ +/* RPL_START_NETSTAT 267 aircd */ +/* RPL_NETSTAT 268 aircd */ +/* RPL_END_NETSTAT 269 aircd */ + +#define RPL_LOCALUSERS 265 +#define RPL_GLOBALUSERS 266 + +#define RPL_ACCEPTLIST 281 +#define RPL_ENDOFACCEPT 282 + +/* RPL_GLIST 280 Undernet extension */ +/* RPL_ENDOFGLIST 281 Undernet extension */ +/* RPL_JUPELIST 282 Undernet extension - jupe -Kev */ +/* RPL_ENDOFJUPELIST 283 Undernet extension - jupe -Kev */ +/* RPL_FEATURE 284 Undernet extension - features */ +/* RPL_CHANINFO_HANDLE 285 aircd */ +/* RPL_CHANINFO_USERS 286 aircd */ +/* RPL_CHANINFO_CHOPS 287 aircd */ +/* RPL_CHANINFO_VOICES 288 aircd */ +/* RPL_CHANINFO_AWAY 289 aircd */ +/* RPL_CHANINFO_OPERS 290 aircd */ +/* RPL_HELPHDR 290 Numeric List: Dalnet */ +/* RPL_CHANINFO_BANNED 291 aircd */ +/* RPL_HELPOP 291 Numeric List: Dalnet */ +/* RPL_CHANINFO_BANS 292 aircd */ +/* RPL_HELPTLR 292 Numeric List: Dalnet */ +/* 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 */ + +/* numeric_replies */ +#define RPL_AWAY 301 +#define RPL_USERHOST 302 +#define RPL_ISON 303 +#define RPL_TEXT 304 +#define RPL_UNAWAY 305 +#define RPL_NOWAWAY 306 +/* RPL_USERIP 307 Undernet extension */ +#define RPL_WHOISREGNICK 307 +/* RPL_SUSERHOST 307 austnet */ +/* RPL_NOTIFYACTION 308 aircd */ +#define RPL_WHOISADMIN 308 /* Numeric List: Dalnet */ +/* RPL_RULESSTART 308 unreal */ +/* RPL_NICKTRACE 309 aircd */ +/* RPL_WHOISSADMIN 309 Numeric List: Dalnet */ +/* RPL_ENDOFRULES 309 unreal */ +/* RPL_WHOISHELPER 309 austnet */ +/* RPL_WHOISSVCMSG 310 Dalnet */ +/* RPL_WHOISHELPOP 310 unreal */ +/* RPL_WHOISSERVICE 310 austnet */ + +#define RPL_WHOISUSER 311 +#define RPL_WHOISSERVER 312 +#define RPL_WHOISOPERATOR 313 + +#define RPL_WHOWASUSER 314 +/* rpl_endofwho below (315) */ +#define RPL_ENDOFWHOWAS 369 + +#define RPL_WHOISCHANOP 316 /* redundant and not needed but reserved */ +#define RPL_WHOISIDLE 317 + +#define RPL_ENDOFWHOIS 318 +#define RPL_WHOISCHANNELS 319 +/* RPL_WHOIS_HIDDEN 320 Anothernet +h, ick! */ +/* RPL_WHOISSPECIAL 320 unreal */ +#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 */ +/* 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_NOTOPIC 331 +#define RPL_TOPIC 332 +#define RPL_TOPICWHOTIME 333 +/* RPL_COMMANDSYNTAX 334 Dalnet */ +/* RPL_LISTSYNTAX 334 unreal */ +/* RPL_CHANPASSOK 338 IRCnet extension (?)*/ +#define RPL_WHOISACTUALLY 338 /* dalnet */ +/* RPL_WHOISACTUALLY 338 Undernet extension, dalnet */ +/* RPL_BADCHANPASS 339 IRCnet extension (?)*/ +/* RPL_USERIP 340 (old) Undernet extension */ +#define RPL_INVITING 341 +/* RPL_SUMMONING 342 removed from RFC1459 */ + +#define RPL_INVITELIST 346 +#define RPL_ENDOFINVITELIST 347 /* IRCnet, Undernet extension */ +#define RPL_EXCEPTLIST 348 +#define RPL_ENDOFEXCEPTLIST 349 + +#define RPL_VERSION 351 + +#define RPL_WHOREPLY 352 +#define RPL_ENDOFWHO 315 +#define RPL_NAMREPLY 353 +#define RPL_ENDOFNAMES 366 + +#define RPL_CLOSING 362 +#define RPL_CLOSEEND 363 +#define RPL_LINKS 364 +#define RPL_ENDOFLINKS 365 +/* rpl_endofnames above (366) */ +#define RPL_BANLIST 367 +#define RPL_ENDOFBANLIST 368 +/* rpl_endofwhowas above (369) */ + +#define RPL_INFO 371 +#define RPL_MOTD 372 +#define RPL_INFOSTART 373 +#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 */ +#define RPL_RSACHALLENGE 386 + +/* RPL_QLIST 386 unreal */ +/* RPL_ENDOFQLIST 387 unreal */ +/* RPL_ALIST 388 unreal */ +/* RPL_ENDOFALIST 389 unreal */ + +#define RPL_TIME 391 +#define RPL_USERSSTART 392 +#define RPL_USERS 393 +#define RPL_ENDOFUSERS 394 +#define RPL_NOUSERS 395 +#define RPL_HOSTHIDDEN 396 + +/* + * Errors are in the range from 400-599 currently and are grouped by what + * commands they come from. + */ +#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 +#define ERR_NOORIGIN 409 +#define ERR_INVALIDCAPCMD 410 + +#define ERR_NORECIPIENT 411 +#define ERR_NOTEXTTOSEND 412 +#define ERR_NOTOPLEVEL 413 +#define ERR_WILDTOPLEVEL 414 +/* ERR_BADMASK 415 IRCnet extension */ +#define ERR_UNKNOWNCOMMAND 421 +#define ERR_NOMOTD 422 +#define ERR_NOADMININFO 423 + +/* ERR_TOOMANYAWAY 429 Dalnet */ + +#define ERR_NONICKNAMEGIVEN 431 +#define ERR_ERRONEUSNICKNAME 432 +#define ERR_NICKNAMEINUSE 433 + +/* ERR_SERVICENAMEINUSE 434 ? */ +/* ERR_NORULES 434 unreal */ +/* ERR_SERVICECONFUSED 435 ? */ +/* ERR_BANONCHAN 435 dalnet */ + +#define ERR_NICKCOLLISION 436 +#define ERR_UNAVAILRESOURCE 437 +#define ERR_NICKTOOFAST 438 /* We did it first Undernet! ;) db */ + +#define ERR_SERVICESDOWN 440 + +#define ERR_USERNOTINCHANNEL 441 +#define ERR_NOTONCHANNEL 442 +#define ERR_USERONCHANNEL 443 + +#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_ACCEPTFULL 456 +#define ERR_ACCEPTEXIST 457 +#define ERR_ACCEPTNOT 458 + +#define ERR_NEEDMOREPARAMS 461 +#define ERR_ALREADYREGISTRED 462 +#define ERR_PASSWDMISMATCH 464 +#define ERR_YOUREBANNEDCREEP 465 +#define ERR_ONLYSERVERSCANCHANGE 468 +/* ERR_LINKSET 469 unreal */ +/* ERR_LINKCHANNEL 470 unreal */ +/* ERR_KICKEDFROMCHAN 470 aircd */ +#define ERR_OPERONLYCHAN 470 +#define ERR_CHANNELISFULL 471 +#define ERR_UNKNOWNMODE 472 +#define ERR_INVITEONLYCHAN 473 +#define ERR_BANNEDFROMCHAN 474 +#define ERR_BADCHANNELKEY 475 +#define ERR_NEEDREGGEDNICK 477 +#define ERR_BANLISTFULL 478 /* I stole the numeric from ircu -db */ +#define ERR_BADCHANNAME 479 +/* ERR_LINKFAIL 479 unreal */ +#define ERR_SSLONLYCHAN 480 +#define ERR_NOPRIVILEGES 481 +#define ERR_CHANOPRIVSNEEDED 482 +#define ERR_CANTKILLSERVER 483 +#define ERR_RESTRICTED 484 +/* 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_NONONREG 486 +/* ERR_CHANTOORECENT 487 IRCnet extension (?) */ +/* ERR_TSLESSCHAN 488 IRCnet extension (?) */ +/* ERR_VOICENEEDED 489 Undernet extension */ +#define ERR_NOOPERHOST 491 +/* ERR_NOSERVICEHOST 492 IRCnet extension */ + +#define ERR_UMODEUNKNOWNFLAG 501 +#define ERR_USERSDONTMATCH 502 + +#define ERR_GHOSTEDCLIENT 503 +/* ERR_VWORLDWARN 503 austnet */ + +#define ERR_USERNOTONSERV 504 + +/* #define ERR_LAST_ERR_MSG 505 + * moved to 999 + */ + + +#define ERR_TOOMANYWATCH 512 +#define ERR_WRONGPONG 513 +/* ERR_TOOMANYDCC 514 dalnet */ +/* ERR_NOINVITE 518 unreal */ +#define ERR_LONGMASK 518 /* Undernet extension -Kev */ +/* ERR_ADMONLY 519 unreal */ +/* ERR_TOOMANYUSERS 519 Undernet extension -Kev */ +/* ERR_OPERONLY 520 unreal */ +/* ERR_MASKTOOWIDE 520 Undernet extension -Kev */ +/* ERR_WHOTRUNC 520 austnet */ +/* ERR_LASTERROR 521 Undernet extension -Kev */ +#define ERR_LISTSYNTAX 521 +/* ERR_WHOSYNTAX 522 dalnet */ +/* ERR_WHOLIMEXCEED 523 dalnet */ + +#define ERR_HELPNOTFOUND 524 + +#define RPL_LOGON 600 +#define RPL_LOGOFF 601 +#define RPL_WATCHOFF 602 +#define RPL_WATCHSTAT 603 +#define RPL_NOWON 604 +#define RPL_NOWOFF 605 +#define RPL_WATCHLIST 606 +#define RPL_ENDOFWATCHLIST 607 + +/* 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_WHOISSECURE 671 +#define RPL_MODLIST 702 +#define RPL_ENDOFMODLIST 703 + +#define RPL_HELPSTART 704 +#define RPL_HELPTXT 705 +#define RPL_ENDOFHELP 706 + +#define RPL_ETRACE_FULL 708 +#define RPL_ETRACE 709 + +#define RPL_KNOCK 710 +#define RPL_KNOCKDLVR 711 + +#define ERR_TOOMANYKNOCK 712 +#define ERR_CHANOPEN 713 +#define ERR_KNOCKONCHAN 714 + +#define RPL_TARGUMODEG 716 +#define RPL_TARGNOTIFY 717 +#define RPL_UMODEGMSG 718 + +#define ERR_NOPRIVS 723 + +#define RPL_TESTMASK 724 +#define RPL_TESTLINE 725 +#define RPL_NOTESTLINE 726 + +#define ERR_LAST_ERR_MSG 999 + +#endif /* INCLUDED_numeric_h */ diff --git a/include/packet.h b/include/packet.h new file mode 100644 index 0000000..1f2b272 --- /dev/null +++ b/include/packet.h @@ -0,0 +1,58 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * packet.h: A header for the packet functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_packet_h +#define INCLUDED_packet_h + +#include "fdlist.h" + +/* + * this hides in here rather than in defaults.h because it really shouldn't + * be tweaked unless you *REALLY REALLY* know what you're doing! + * Remember, messages are only anti-flooded on incoming from the client, not on + * incoming from a server for a given client, so if you tweak this you risk + * allowing a client to flood differently depending upon where they are on + * the network.. + * -- adrian + */ +/* MAX_FLOOD is the amount of lines in a 'burst' we allow from a client, + * anything beyond MAX_FLOOD is limited to about one line per second. + * + * MAX_FLOOD_CONN is the amount of lines we allow from a client who has + * just connected. this allows clients to rejoin multiple channels + * without being so heavily penalised they excess flood. + */ +#define MAX_FLOOD 5 +#define MAX_FLOOD_BURST MAX_FLOOD * 8 + +struct Callback; + +void *iorecv_default(va_list); +extern struct Callback *iorecv_cb; + +PF read_packet; +PF flood_recalc; +void flood_endgrace(struct Client *); + +#endif /* INCLUDED_packet_h */ diff --git a/include/parse.h b/include/parse.h new file mode 100644 index 0000000..1a58e66 --- /dev/null +++ b/include/parse.h @@ -0,0 +1,165 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * parse.h: A header for the message parser. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_parse_h +#define INCLUDED_parse_h + +struct Client; + + +/* + * m_functions execute protocol messages on this server: + * int m_func(struct Client* client_p, struct Client* source_p, int parc, char* parv[]); + * + * client_p 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...). + * + * source_p is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then source_p==client_p. + * + * (!IsServer(client_p)) => (client_p == source_p), because + * prefixes are taken *only* from servers... + * + * (IsServer(client_p)) + * (source_p == client_p) => the message didn't + * have the prefix. + * + * (source_p != client_p && IsServer(source_p) means + * the prefix specified servername. (?) + * + * (source_p != client_p && !IsServer(source_p) means + * that message originated from a remote + * user (not local). + * + * + * combining + * + * (!IsServer(source_p)) means that, source_p can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) source_p->from == client_p (note: client_p->from == client_p) + * + * 2) MyConnect(source_p) <=> source_p == client_p (e.g. source_p + * *cannot* be a local connection, unless it's + * actually client_p!). [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. + */ + +/* + * MessageHandler + */ +typedef enum HandlerType { + UNREGISTERED_HANDLER, + CLIENT_HANDLER, + SERVER_HANDLER, + ENCAP_HANDLER, + OPER_HANDLER, + DUMMY_HANDLER, + LAST_HANDLER_TYPE +} HandlerType; + +/* + * MessageHandler function + * Params: + * struct Client* client_p - connection message originated from + * struct Client* source_p - source of message, may be different from client_p + * int parc - parameter count + * char* parv[] - parameter vector + */ +typedef void (*MessageHandler)(struct Client *, struct Client *, int, char *[]); + +/* + * Message table structure + */ +struct Message +{ + const char *cmd; + unsigned int count; /* number of times command used */ + unsigned int rcount; /* number of times command used by server */ + unsigned int args_min; /* at least this many args must be passed + * or an error will be sent to the user + * before the m_func is even called + */ + unsigned int args_max; /* maximum permitted parameters */ + unsigned int flags; /* bit 0 set means that this command is allowed + * to be used only on the average of once per 2 + * seconds -SRB + */ + uint64_t bytes; /* bytes received for this message */ + + /* + * client_p = Connected client ptr + * source_p = Source client ptr + * parc = parameter count + * parv = parameter variable array + */ + /* handlers: + * UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, DUMMY, LAST + */ + MessageHandler handlers[LAST_HANDLER_TYPE]; +}; + +/* + * Constants + */ +#define MFLG_SLOW 0x001 /* Command can be executed roughly + * once per 2 seconds. + */ +#define MAXPARA 15 + +extern void parse(struct Client *, char *, char *); +extern void mod_add_cmd(struct Message *); +extern void mod_del_cmd(struct Message *); +extern struct Message *find_command(const char *); +extern void report_messages(struct Client *); + +/* generic handlers */ +extern void rfc1459_command_send_error(struct Client *, struct Client *,int, char *[]); +extern void m_ignore(struct Client *, struct Client *, int, char *[]); +extern void m_not_oper(struct Client *, struct Client *, int, char *[]); +extern void m_registered(struct Client *, struct Client *, int, char *[]); +extern void m_unregistered(struct Client *, struct Client *, int, char *[]); + +#endif /* INCLUDED_parse_h */ diff --git a/include/patchlevel.h b/include/patchlevel.h new file mode 100644 index 0000000..7365468 --- /dev/null +++ b/include/patchlevel.h @@ -0,0 +1,27 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * patchlevel.h: A header defining the patchlevel. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef PATCHLEVEL +#define PATCHLEVEL "hybrid-8.0.0" +#endif diff --git a/include/restart.h b/include/restart.h new file mode 100644 index 0000000..9b79800 --- /dev/null +++ b/include/restart.h @@ -0,0 +1,31 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * restart.h: A header with restart functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_restart_h +#define INCLUDED_restart_h + +extern void restart(const char *); +extern void server_die(const char *, int); + +#endif diff --git a/include/resv.h b/include/resv.h new file mode 100644 index 0000000..87bbe85 --- /dev/null +++ b/include/resv.h @@ -0,0 +1,52 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * resv.h: A header for the RESV functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_resv_h +#define INCLUDED_resv_h + +struct ResvChannel +{ + dlink_node node; + struct ResvChannel *hnext; + time_t hold; /* Hold action until this time (calendar time) */ + /* +1 for \0 */ + char name[CHANNELLEN + 1]; + char *reason; + int conf; /* 1 if set from ircd.conf, 0 if from elsewhere */ +}; + +extern dlink_list nresv_items; +extern dlink_list resv_channel_list; + +extern struct ConfItem *create_channel_resv(char *, char *, int); +extern struct ConfItem *create_nick_resv(char *, char *, int); + +extern int delete_channel_resv(struct ResvChannel *); + +extern void clear_conf_resv(void); +extern void report_resv(struct Client *); + +extern int valid_wild_card_simple(const char *); +extern struct ResvChannel *match_find_resv(const char *); +#endif /* INCLUDED_resv_h */ diff --git a/include/rng_mt.h b/include/rng_mt.h new file mode 100644 index 0000000..1f32ef1 --- /dev/null +++ b/include/rng_mt.h @@ -0,0 +1,53 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) + + $Id$ +*/ + + +#ifndef __include_rng_mt_header__ +#define __include_rng_mt_header__ + +extern void init_genrand(uint32_t); +extern void init_by_array(uint32_t[], int); +extern uint32_t genrand_int32(void); +#endif diff --git a/include/rsa.h b/include/rsa.h new file mode 100644 index 0000000..06f7f6e --- /dev/null +++ b/include/rsa.h @@ -0,0 +1,35 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * rsa.h: A header for the RSA functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ +#ifndef INCLUDED_rsa_h +#define INCLUDED_rsa_h + +#include "config.h" + +#ifdef HAVE_LIBCRYPTO +extern void report_crypto_errors(void); +extern int generate_challenge(char **, char **, RSA *); +extern int get_randomness(unsigned char *, int); +#endif +#endif /* INCLUDED_rsa_h */ + diff --git a/include/s_auth.h b/include/s_auth.h new file mode 100644 index 0000000..b9ffc35 --- /dev/null +++ b/include/s_auth.h @@ -0,0 +1,66 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * s_auth.h: A header for the ident functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_auth_h +#define INCLUDED_s_auth_h + +#include "irc_res.h" +#include "hook.h" + + +struct Client; + +struct AuthRequest +{ + dlink_node node; /* auth_doing_list */ + int flags; + struct Client* client; /* pointer to client struct for request */ + fde_t fd; /* file descriptor for auth queries */ + time_t timeout; /* time when query expires */ +}; + +/* + * flag values for AuthRequest + * NAMESPACE: AM_xxx - Authentication Module + */ +#define AM_DOING_AUTH 0x1 +#define AM_DNS_PENDING 0x2 + +#define SetDNSPending(x) ((x)->flags |= AM_DNS_PENDING) +#define ClearDNSPending(x) ((x)->flags &= ~AM_DNS_PENDING) +#define IsDNSPending(x) ((x)->flags & AM_DNS_PENDING) + +#define SetDoingAuth(x) ((x)->flags |= AM_DOING_AUTH) +#define ClearAuth(x) ((x)->flags &= ~AM_DOING_AUTH) +#define IsDoingAuth(x) ((x)->flags & AM_DOING_AUTH) + +extern struct Callback *auth_cb; + +extern void init_auth(void); +extern void send_auth_query(struct AuthRequest *); +extern void remove_auth_request(struct AuthRequest *); +extern void delete_auth(struct AuthRequest *); +extern void release_auth_client(struct AuthRequest *); + +#endif /* INCLUDED_s_auth_h */ diff --git a/include/s_bsd.h b/include/s_bsd.h new file mode 100644 index 0000000..a76ce6d --- /dev/null +++ b/include/s_bsd.h @@ -0,0 +1,73 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * s_bsd.h: A header for the network subsystem. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_bsd_h +#define INCLUDED_s_bsd_h + +#include "config.h" +#include "fdlist.h" +#include "hook.h" + +/* Type of IO */ +#define COMM_SELECT_READ 1 +#define COMM_SELECT_WRITE 2 + +/* How long can comm_select() wait for network events [milliseconds] */ +#define SELECT_DELAY 500 + +struct Client; +struct AccessItem; +struct Listener; + +extern struct Callback *setup_socket_cb; + +extern void add_connection(struct Listener *, struct irc_ssaddr *, int); +extern void close_connection(struct Client *); +extern void report_error(int, const char *, const char *, int); + +extern int get_sockerr(int); +extern int ignoreErrno(int); + +extern void comm_settimeout(fde_t *, time_t, PF *, void *); +extern void comm_setflush(fde_t *, time_t, PF *, void *); +extern void comm_checktimeouts(void *); +extern void comm_connect_tcp(fde_t *, const char *, u_short, + struct sockaddr *, int, CNCB *, void *, int, int); +extern const char * comm_errstr(int status); +extern int comm_open(fde_t *F, int family, int sock_type, int proto, + const char *note); +extern int comm_accept(struct Listener *, struct irc_ssaddr *pn); + +/* These must be defined in the network IO loop code of your choice */ +extern void init_netio(void); +extern void comm_setselect(fde_t *, unsigned int, PF *, void *, time_t); +extern void init_comm(void); +extern int read_message (time_t, unsigned char); +extern void comm_select(void); +extern void check_can_use_v6(void); +#ifdef IPV6 +extern void remove_ipv6_mapping(struct irc_ssaddr *); +#endif + +#endif /* INCLUDED_s_bsd_h */ diff --git a/include/s_gline.h b/include/s_gline.h new file mode 100644 index 0000000..1ecc9b2 --- /dev/null +++ b/include/s_gline.h @@ -0,0 +1,60 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * s_gline.h: A header for the gline functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_gline_h +#define INCLUDED_s_gline_h + +#include "ircd_defs.h" + +#define GLINE_PENDING_DEL_TYPE 0 +#define GLINE_PENDING_ADD_TYPE 1 + +struct AccessItem; + +extern void cleanup_glines(void *); +extern struct AccessItem *find_is_glined(const char *, const char *); + +struct gline_pending +{ + dlink_node node; + + struct { + char oper_nick[NICKLEN + 1]; + char oper_user[USERLEN + 1]; + char oper_host[HOSTLEN + 1]; + char oper_server[HOSTLEN + 1]; + char reason[REASONLEN + 1]; + time_t time_request; + } vote_1, vote_2; + + time_t last_gline_time; /* for expiring entry */ + char user[USERLEN * 2 + 2]; + char host[HOSTLEN * 2 + 2]; +}; + + +#define CLEANUP_GLINES_TIME 300 + +extern dlink_list pending_glines[]; +#endif /* INCLUDED_s_gline_h */ diff --git a/include/s_misc.h b/include/s_misc.h new file mode 100644 index 0000000..88dd5bf --- /dev/null +++ b/include/s_misc.h @@ -0,0 +1,47 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * s_misc.h: A header for the miscellaneous functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_misc_h +#define INCLUDED_s_misc_h + +extern char *date(time_t); +extern const char *smalldate(time_t); +#ifdef HAVE_LIBCRYPTO +extern char *ssl_get_cipher(const SSL *); +#endif + +/* Just blindly define our own MIN/MAX macro */ + +#define IRCD_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define IRCD_MIN(a, b) ((a) < (b) ? (a) : (b)) + +#define _1MEG (1024.0) +#define _1GIG (1024.0*1024.0) +#define _1TER (1024.0*1024.0*1024.0) +#define _GMKs(x) (((x) > _1TER) ? "Terabytes" : (((x) > _1GIG) ? "Gigabytes" :\ + (((x) > _1MEG) ? "Megabytes" : "Kilobytes"))) +#define _GMKv(x) (((x) > _1TER) ? (float)((x)/_1TER) : (((x) > _1GIG) ? \ + (float)((x)/_1GIG) : (((x) > _1MEG) ? (float)((x)/_1MEG) : \ + (float)(x)))) +#endif diff --git a/include/s_serv.h b/include/s_serv.h new file mode 100644 index 0000000..31582ea --- /dev/null +++ b/include/s_serv.h @@ -0,0 +1,101 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * s_serv.h: A header for the server functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_serv_h +#define INCLUDED_serv_h +#include "config.h" + +struct ConfItem; + +/* + * number of seconds to wait after server starts up, before + * starting try_connections() + * TOO SOON and you can nick collide like crazy. + */ +#define STARTUP_CONNECTIONS_TIME 60 + +struct Client; +struct AccessItem; +struct Channel; + +/* Capabilities */ +struct Capability +{ + dlink_node node; + char *name; /* name of capability */ + unsigned int cap; /* mask value */ +}; + +#define CAP_CAP 0x00000001 /* received a CAP to begin with */ +#define CAP_QS 0x00000002 /* Can handle quit storm removal */ +#define CAP_EX 0x00000004 /* Can do channel +e exemptions */ +#define CAP_CHW 0x00000008 /* Can do channel wall @# */ +#define CAP_IE 0x00000010 /* Can do invite exceptions */ +#define CAP_EOB 0x00000020 /* Can do EOB message */ +#define CAP_KLN 0x00000040 /* Can do KLINE message */ +#define CAP_GLN 0x00000080 /* Can do GLINE message */ +#define CAP_TS6 0x00000100 /* Can do TS6 */ +#define CAP_KNOCK 0x00000200 /* supports KNOCK */ +#define CAP_UNKLN 0x00000400 /* Can do UNKLINE message */ +#define CAP_CLUSTER 0x00000800 /* supports server clustering */ +#define CAP_ENCAP 0x00001000 /* supports ENCAP message */ +#define CAP_HOPS 0x00002000 /* supports HALFOPS */ +#define CAP_TBURST 0x00004000 /* supports TBURST */ +#define CAP_SVS 0x00008000 /* supports services */ +#define CAP_DLN 0x00010000 /* Can do DLINE message */ +#define CAP_UNDLN 0x00020000 /* Can do UNDLINE message */ + +/* + * Capability macros. + */ +#define IsCapable(x, cap) ((x)->localClient->caps & (cap)) +#define SetCapable(x, cap) ((x)->localClient->caps |= (cap)) +#define ClearCap(x, cap) ((x)->localClient->caps &= ~(cap)) + + +/* + * 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 */ + +extern int valid_servname(const char *); +extern int check_server(const char *, struct Client *); +extern int hunt_server(struct Client *, struct Client *, + const char *, int, int, char **); +extern void add_capability(const char *, int, int); +extern int delete_capability(const char *); +extern int find_capability(const char *); +extern void send_capabilities(struct Client *, struct AccessItem *, int); +extern void write_links_file(void *); +extern void server_estab(struct Client *); +extern const char *show_capabilities(struct Client *); +extern void try_connections(void *); +extern void burst_channel(struct Client *client_p, struct Channel *); +extern void sendnick_TS(struct Client *, struct Client *); +extern int serv_connect(struct AccessItem *, struct Client *); +extern struct Client *find_servconn_in_progress(const char *); +extern struct Server *make_server(struct Client *); +#endif /* INCLUDED_s_serv_h */ diff --git a/include/s_user.h b/include/s_user.h new file mode 100644 index 0000000..e90a31d --- /dev/null +++ b/include/s_user.h @@ -0,0 +1,61 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * s_user.h: A header for the user functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_s_user_h +#define INCLUDED_s_user_h + +#define IRC_MAXSID 3 +#define IRC_MAXUID 6 +#define TOTALSIDUID (IRC_MAXSID + IRC_MAXUID) + +struct Client; + +extern struct Callback *entering_umode_cb; +extern struct Callback *umode_cb; +extern unsigned int user_modes[]; + +extern void assemble_umode_buffer(void); +extern void set_user_mode(struct Client *, struct Client *, int, char **); +extern void send_umode(struct Client *, struct Client *, + unsigned int, unsigned int, char *); +extern void send_umode_out(struct Client *, struct Client *, unsigned int); +extern void show_lusers(struct Client *); +extern void show_isupport(struct Client *); +extern void oper_up(struct Client *); + +extern void register_local_user(struct Client *); +extern void register_remote_user(struct Client *, + const char *, const char *, + const char *, const char *); +extern void init_uid(void); +extern int valid_sid(const char *); +extern int valid_hostname(const char *); +extern int valid_username(const char *); +extern int valid_nickname(const char *, const int); +extern void add_isupport(const char *, const char *, int); +extern void delete_isupport(const char *); +extern void init_isupport(void); +extern void rebuild_isupport_message_line(void); + +#endif diff --git a/include/send.h b/include/send.h new file mode 100644 index 0000000..1039618 --- /dev/null +++ b/include/send.h @@ -0,0 +1,98 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * send.h: A header for the message sending functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_send_h +#define INCLUDED_send_h + +#include "fdlist.h" + +/* + * struct decls + */ +struct Callback; +struct Channel; +struct Client; +struct dlink_list; + +extern void *iosend_default(va_list); +extern struct Callback *iosend_cb; + +/* send.c prototypes */ + +extern void sendq_unblocked(fde_t *, struct Client *); +extern void send_queued_write(struct Client *); +extern void send_queued_all(void); +extern void sendto_one(struct Client *, const char *, ...); +extern void sendto_channel_butone(struct Client *, struct Client *, + struct Channel *, unsigned int, + const char *, ...); +extern void sendto_common_channels_local(struct Client *, int, + const char *, ...); +extern void sendto_channel_local(int, int, struct Channel *, + const char *, ...); +extern void sendto_channel_local_butone(struct Client *, int, struct Channel *, + const char *, ...); +extern void sendto_channel_remote(struct Client *, struct Client *, int, + const unsigned int, const unsigned int, + struct Channel *, const char *, ...); +extern void sendto_server(struct Client *, + const unsigned int, + const unsigned int, const char *, ...); +extern void sendto_match_butone(struct Client *, struct Client *, + char *, int, const char *, ...); +extern void sendto_match_servs(struct Client *, const char *, int, + const char *, ...); +extern void sendto_realops_flags(unsigned int, int, + const char *, ...); +extern void sendto_globops_flags(unsigned int, int, const char *, ...); +extern void sendto_wallops_flags(unsigned int, struct Client *, + const char *, ...); +extern void ts_warn(const char *, ...); + +extern void sendto_anywhere(struct Client *, struct Client *, + const char *, ...); +extern void kill_client(struct Client *, struct Client *, + const char *, ... ); +extern void kill_client_ll_serv_butone(struct Client *, struct Client *, + const char *, ...); + + +#define ALL_MEMBERS 0 +#define NON_CHANOPS 1 +#define ONLY_CHANOPS_VOICED 2 +#define ONLY_CHANOPS 3 +#define ONLY_SERVERS 4 /* for channel_mode.c */ + +#define L_ALL 0 +#define L_OPER 1 +#define L_ADMIN 2 + +#define NOCAPS 0 /* no caps */ +#define NOFLAGS 0 /* no flags */ + +/* used when sending to #mask or $mask */ +#define MATCH_SERVER 1 +#define MATCH_HOST 2 + +#endif /* INCLUDED_send_h */ diff --git a/include/serno.h b/include/serno.h new file mode 100644 index 0000000..bdad155 --- /dev/null +++ b/include/serno.h @@ -0,0 +1 @@ +#define SERIALNUM "SVN" diff --git a/include/sprintf_irc.h b/include/sprintf_irc.h new file mode 100644 index 0000000..641c636 --- /dev/null +++ b/include/sprintf_irc.h @@ -0,0 +1,39 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * sprintf_irc.h: The irc sprintf header. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef SPRINTF_IRC +#define SPRINTF_IRC + + +/*============================================================================= + * Proto types + */ + +extern int vsprintf_irc(char *, const char *, va_list); + +/* + * ircsprintf - optimized sprintf + */ +extern int ircsprintf(char *, const char *, ...); +#endif /* SPRINTF_IRC */ diff --git a/include/stdinc.h b/include/stdinc.h new file mode 100644 index 0000000..09c0939 --- /dev/null +++ b/include/stdinc.h @@ -0,0 +1,90 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * stdinc.h: Pull in all of the necessary system headers + * + * Copyright (C) 2002 Aaron Sethman <androsyn@ratbox.org> + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + * + */ + +#ifndef STDINC_H /* prevent multiple #includes */ +#define STDINC_H + +#include "config.h" + +#include "defaults.h" + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include <errno.h> + +#ifdef HAVE_STRTOK_R +# define strtoken(x, y, z) strtok_r(y, z, x) +#endif + +#include <sys/types.h> + +#ifdef HAVE_CRYPT_H +#include <crypt.h> +#endif + +#ifdef HAVE_LIBCRYPTO +#include <openssl/ssl.h> +#include <openssl/err.h> +#endif + +#include <stdio.h> +#include <assert.h> +#include <time.h> +#include <fcntl.h> + +#include <stdarg.h> +#include <signal.h> +#include <ctype.h> + +#include <dirent.h> +#include <netdb.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <sys/time.h> +#include <sys/file.h> + +#include <limits.h> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#include <sys/stat.h> +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif + +#endif diff --git a/include/supported.h b/include/supported.h new file mode 100644 index 0000000..0e59fd5 --- /dev/null +++ b/include/supported.h @@ -0,0 +1,73 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * supported.h: Header for 005 numeric etc... + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_supported_h +#define INCLUDED_supported_h + +#include "channel.h" +#include "ircd_defs.h" +#include "s_serv.h" + +#define CASEMAP "rfc1459" + +/* ConfigChannel.use_knock ? " KNOCK" */ + +/* + * - from mirc's versions.txt + * + * mIRC now supports the numeric 005 tokens: CHANTYPES=# and + * PREFIX=(ohv)@%+ and can handle a dynamic set of channel and + * nick prefixes. + * + * mIRC assumes that @ is supported on all networks, any mode + * left of @ is assumed to have at least equal power to @, and + * any mode right of @ has less power. + * + * mIRC has internal support for @%+ modes. + * + * $nick() can now handle all mode letters listed in PREFIX. + * + * Also added support for CHANMODES=A,B,C,D token (not currently + * supported by any servers), which lists all modes supported + * by a channel, where: + * + * A = modes that take a parameter, and add or remove nicks + * or addresses to a list, such as +bIe for the ban, + * invite, and exception lists. + * + * B = modes that change channel settings, but which take + * a parameter when they are set and unset, such as + * +k key, and -k key. + * + * C = modes that change channel settings, but which take + * a parameter only when they are set, such as +l N, + * and -l. + * + * D = modes that change channel settings, such as +imnpst + * and take no parameters. + * + * All unknown/unlisted modes are treated as type D. + */ + +#endif /* INCLUDED_supported_h */ diff --git a/include/userhost.h b/include/userhost.h new file mode 100644 index 0000000..2608507 --- /dev/null +++ b/include/userhost.h @@ -0,0 +1,47 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * userhost.h: A header for global user limits. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_userhost_h +#define INCLUDED_userhost_h + +struct NameHost +{ + dlink_node node; /* point to other names on this hostname */ + char name[USERLEN + 1]; + int icount; /* number of =local= identd on this name*/ + int gcount; /* global user count on this name */ + int lcount; /* local user count on this name */ +}; + +struct UserHost +{ + dlink_list list; /* list of names on this hostname */ + struct UserHost *next; + char host[HOSTLEN + 1]; +}; + +extern void count_user_host(const char *, const char *, int *, int *, int *); +extern void add_user_host(const char *, const char *, int); +extern void delete_user_host(const char *, const char *, int global); +#endif /* INCLUDED_userhost_h */ diff --git a/include/watch.h b/include/watch.h new file mode 100644 index 0000000..2d14818 --- /dev/null +++ b/include/watch.h @@ -0,0 +1,48 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * + * Copyright (C) 1997 Jukka Santala (Donwulff) + * Copyright (C) 2005 by the Hybrid Development Team. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +/*! \file watch.h + * \brief Header including structures and prototypes for WATCH support + * \version $Id$ + */ + +#ifndef INCLUDED_watch_h +#define INCLUDED_watch_h + +/*! \brief Watch structure */ +struct Watch +{ + dlink_node node; /**< Embedded dlink_node used to link into watchTable */ + dlink_list watched_by; /**< list of clients that have this + entry on their watch list */ + time_t lasttime; /**< last time the client was seen */ + char nick[NICKLEN + 1]; /**< nick name of the client to watch */ +}; + +extern void watch_init(void); +extern void watch_add_to_hash_table(const char *, struct Client *); +extern void watch_del_from_hash_table(const char *, struct Client *); +extern void watch_check_hash(struct Client *, int); +extern void watch_del_watch_list(struct Client *); +extern void watch_count_memory(unsigned int *const, uint64_t *const); +extern struct Watch *watch_find_hash(const char *); +#endif diff --git a/include/whowas.h b/include/whowas.h new file mode 100644 index 0000000..3f23ec5 --- /dev/null +++ b/include/whowas.h @@ -0,0 +1,82 @@ +/* + * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). + * whowas.h: Header for the whowas functions. + * + * Copyright (C) 2002 by the past and present ircd coders, and others. + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * $Id$ + */ + +#ifndef INCLUDED_whowas_h +#define INCLUDED_whowas_h + +#include "ircd_defs.h" +#include "client.h" +#include "config.h" + + +struct Whowas +{ + int hashv; + time_t logoff; + char name[NICKLEN + 1]; + char username[USERLEN + 1]; + char hostname[HOSTLEN + 1]; + char realname[REALLEN + 1]; + char servername[HOSTLEN + 1]; + struct Client *online; /* Pointer to new nickname for chasing or NULL */ + dlink_node tnode; /* for hash table... */ + dlink_node cnode; /* for client struct linked list */ +}; + +/* +** initwhowas +*/ +extern void whowas_init(void); + +/* +** add_history +** Add the currently defined name of the client to history. +** usually called before changing to a new name (nick). +** Client must be a fully registered user. +*/ +extern void add_history(struct Client *, int); + +/* +** off_history +** This must be called when the client structure is about to +** be released. History mechanism keeps pointers to client +** structures and it must know when they cease to exist. This +** also implicitly calls AddHistory. +*/ +extern void off_history(struct Client *); + +/* +** get_history +** Return the current client that was using the given +** nickname within the timelimit. Returns NULL, if no +** one found... +*/ +extern struct Client *get_history(const char *, time_t); + +/* +** for debugging...counts related structures stored in whowas array. +*/ +extern void count_whowas_memory(unsigned int *, uint64_t *); +extern dlink_list WHOWASHASH[]; +#endif /* INCLUDED_whowas_h */ |