| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
* |
| 4 |
* Copyright (c) 1997-2022 ircd-hybrid development team |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
* USA |
| 20 |
*/ |
| 21 |
|
| 22 |
/*! \file channel_mode.h |
| 23 |
* \brief Includes channel mode related definitions and structures. |
| 24 |
* \version $Id$ |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef INCLUDED_channel_mode_h |
| 28 |
#define INCLUDED_channel_mode_h |
| 29 |
|
| 30 |
|
| 31 |
#define CMEMBER_STATUS_FLAGS "@%+" |
| 32 |
enum { CMEMBER_STATUS_FLAGS_LEN = sizeof(CMEMBER_STATUS_FLAGS) - 1 }; |
| 33 |
|
| 34 |
enum { MODEBUFLEN = 200 }; |
| 35 |
|
| 36 |
/* Maximum mode changes allowed per client, per server is different */ |
| 37 |
enum { MAXMODEPARAMS = 6 }; |
| 38 |
|
| 39 |
enum |
| 40 |
{ |
| 41 |
MODE_QUERY, |
| 42 |
MODE_DEL, |
| 43 |
MODE_ADD |
| 44 |
}; |
| 45 |
|
| 46 |
enum |
| 47 |
{ |
| 48 |
CHACCESS_NOTONCHAN = -1, |
| 49 |
CHACCESS_PEON, |
| 50 |
CHACCESS_HALFOP, |
| 51 |
CHACCESS_CHANOP, |
| 52 |
CHACCESS_REMOTE |
| 53 |
}; |
| 54 |
|
| 55 |
enum mode_class |
| 56 |
{ |
| 57 |
/* A = modes that take a parameter, and add or remove nicks |
| 58 |
* or addresses to a list, such as +bIe for the ban, |
| 59 |
* invite, and exception lists. |
| 60 |
*/ |
| 61 |
MODE_CLASS_A, |
| 62 |
|
| 63 |
/* B = modes that change channel settings, but which take |
| 64 |
* a parameter when they are set and unset, such as |
| 65 |
* +k key, and -k key. |
| 66 |
*/ |
| 67 |
MODE_CLASS_B, |
| 68 |
|
| 69 |
/* C = modes that change channel settings, but which take |
| 70 |
* a parameter only when they are set, such as +l N, |
| 71 |
* and -l. |
| 72 |
*/ |
| 73 |
MODE_CLASS_C, |
| 74 |
|
| 75 |
/* D = modes that change channel settings, such as +imnpst |
| 76 |
* and take no parameters. |
| 77 |
*/ |
| 78 |
MODE_CLASS_D |
| 79 |
}; |
| 80 |
|
| 81 |
/* Channel related flags */ |
| 82 |
enum |
| 83 |
{ |
| 84 |
CHFL_CHANOP = 1 << 0, /* Channel operator */ |
| 85 |
CHFL_HALFOP = 1 << 1, /* Channel half op */ |
| 86 |
CHFL_VOICE = 1 << 2, /* the power to speak */ |
| 87 |
CHFL_BAN = 1 << 3, /* ban channel flag */ |
| 88 |
CHFL_EXCEPTION = 1 << 4, /* exception to ban channel flag */ |
| 89 |
CHFL_INVEX = 1 << 5, |
| 90 |
/* Cache flags for silence on ban */ |
| 91 |
CHFL_BAN_CHECKED = 1 << 6, |
| 92 |
CHFL_BAN_SILENCED = 1 << 7, |
| 93 |
CHFL_MUTE_CHECKED = 1 << 8 |
| 94 |
}; |
| 95 |
|
| 96 |
/* channel modes ONLY */ |
| 97 |
enum |
| 98 |
{ |
| 99 |
MODE_PRIVATE = 1 << 0, /**< */ |
| 100 |
MODE_SECRET = 1 << 1, /**< Channel does not show up on NAMES or LIST */ |
| 101 |
MODE_MODERATED = 1 << 2, /**< Users without +v/+h/+o cannot send text to the channel */ |
| 102 |
MODE_TOPICLIMIT = 1 << 3, /**< Only chanops can change the topic */ |
| 103 |
MODE_INVITEONLY = 1 << 4, /**< Only invited users may join this channel */ |
| 104 |
MODE_NOPRIVMSGS = 1 << 5, /**< Users must be in the channel to send text to it */ |
| 105 |
MODE_SECUREONLY = 1 << 6, /**< Prevents anyone who isn't connected via TLS from joining the channel */ |
| 106 |
MODE_OPERONLY = 1 << 7, /**< Prevents anyone who hasn't obtained IRC operator status from joining the channel */ |
| 107 |
MODE_REGISTERED = 1 << 8, /**< Channel has been registered with ChanServ */ |
| 108 |
MODE_REGONLY = 1 << 9, /**< Only registered clients may join a channel with that mode set */ |
| 109 |
MODE_NOCTRL = 1 << 10, /**< Prevents users from sending messages containing control codes to the channel */ |
| 110 |
MODE_MODREG = 1 << 11, /**< Unregistered/unidentified clients cannot send text to the channel */ |
| 111 |
MODE_NOCTCP = 1 << 12, /**< Clients cannot send CTCP messages to the channel */ |
| 112 |
MODE_NONOTICE = 1 << 13, /**< Clients cannot send NOTICE to the channel */ |
| 113 |
MODE_EXTLIMIT = 1 << 14, /**< Channel can make use of the extended ban list limit */ |
| 114 |
MODE_NONICKCHANGE = 1 << 15, /**< User is prevented from changing their nick while in this channel */ |
| 115 |
MODE_NOKNOCK = 1 << 16, /**< Clients may not use KNOCK on this channel */ |
| 116 |
}; |
| 117 |
|
| 118 |
#define HasCMode(x, y) ((x)->mode.mode & (y)) |
| 119 |
#define AddCMode(x, y) ((x)->mode.mode |= (y)) |
| 120 |
#define DelCMode(x, y) ((x)->mode.mode &= ~(y)) |
| 121 |
|
| 122 |
/* name invisible */ |
| 123 |
#define SecretChannel(x) (((x)->mode.mode & MODE_SECRET)) |
| 124 |
#define PubChannel(x) (((x)->mode.mode & (MODE_PRIVATE | MODE_SECRET)) == 0) |
| 125 |
/* knock is forbidden, halfops can't kick/deop other halfops. */ |
| 126 |
#define PrivateChannel(x) (((x)->mode.mode & MODE_PRIVATE)) |
| 127 |
|
| 128 |
struct ChModeChange |
| 129 |
{ |
| 130 |
char letter; |
| 131 |
const char *arg; |
| 132 |
const char *id; |
| 133 |
unsigned int dir; |
| 134 |
}; |
| 135 |
|
| 136 |
struct chan_mode |
| 137 |
{ |
| 138 |
unsigned char letter; |
| 139 |
unsigned int mode; |
| 140 |
unsigned int flag; |
| 141 |
enum mode_class class; |
| 142 |
bool only_opers; |
| 143 |
bool only_servers; |
| 144 |
int required_oplevel; |
| 145 |
void (*func)(struct Client *, |
| 146 |
struct Channel *, int, int *, char **, int *, |
| 147 |
int, int, const char, const struct chan_mode *); |
| 148 |
}; |
| 149 |
|
| 150 |
extern const struct chan_mode *cmode_map[]; |
| 151 |
extern const struct chan_mode cmode_tab[]; |
| 152 |
extern char cmode_rpl04[][256]; |
| 153 |
extern char cmode_class[][256]; |
| 154 |
|
| 155 |
extern void channel_mode_init(void); |
| 156 |
extern const char *add_id(struct Client *, struct Channel *, const char *, dlink_list *, unsigned int); |
| 157 |
extern void channel_mode_set(struct Client *, struct Channel *, struct ChannelMember *, int, char **); |
| 158 |
extern void clear_ban_cache_list(dlink_list *); |
| 159 |
#endif /* INCLUDED_channel_mode_h */ |