1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/*
* ircd-ratbox: A slightly useful ircd.
* msg.h: A header for the message handler structure.
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2002-2004 ircd-ratbox 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
*
* $Id: msg.h 6 2005-09-10 01:02:21Z nenolod $
*/
#ifndef INCLUDED_msg_h
#define INCLUDED_msg_h
#include "config.h"
struct Client;
/* MessageHandler */
typedef enum HandlerType
{
UNREGISTERED_HANDLER,
CLIENT_HANDLER,
RCLIENT_HANDLER,
SERVER_HANDLER,
ENCAP_HANDLER,
OPER_HANDLER,
LAST_HANDLER_TYPE
}
HandlerType;
/* 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 int (*MessageHandler) (struct Client *, struct Client *, int, const char *[]);
struct MessageEntry
{
MessageHandler handler;
int min_para;
};
/* 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 long bytes; /* bytes received for this message */
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
*/
/* handlers:
* UNREGISTERED, CLIENT, RCLIENT, SERVER, OPER, LAST
*/
struct MessageEntry handlers[LAST_HANDLER_TYPE];
};
#define MFLG_SLOW 0x01 /* executed roughly once per 2s */
#define MFLG_UNREG 0x02 /* available to unregistered clients */
#define MAXPARA 15
/* generic handlers */
extern int m_ignore(struct Client *, struct Client *, int, const char **);
extern int m_not_oper(struct Client *, struct Client *, int, const char **);
extern int m_registered(struct Client *, struct Client *, int, const char **);
extern int m_unregistered(struct Client *, struct Client *, int, const char **);
#define mg_ignore { m_ignore, 0 }
#define mg_not_oper { m_not_oper, 0 }
#define mg_reg { m_registered, 0 }
#define mg_unreg { m_unregistered, 0 }
/*
* 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], unused for historical reasons (formerly
* sender name)
* parv[1]...parv[parc-1]
* pointers to additional parameters
* parv[parc] == NULL, *always*
*
* note: it is guaranteed that parv[1]..parv[parc-1] are all
* non-NULL pointers.
*/
#endif /* INCLUDED_msg_h */
|