| 1 |
adx |
30 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
|
|
* s_serv.h: A header for the server functions. |
| 4 |
|
|
* |
| 5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 6 |
|
|
* |
| 7 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU General Public License as published by |
| 9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
|
* (at your option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* This program is distributed in the hope that it will be useful, |
| 13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
|
* GNU General Public License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU General Public License |
| 18 |
|
|
* along with this program; if not, write to the Free Software |
| 19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
|
|
* USA |
| 21 |
|
|
* |
| 22 |
knight |
31 |
* $Id$ |
| 23 |
adx |
30 |
*/ |
| 24 |
|
|
|
| 25 |
|
|
#ifndef INCLUDED_serv_h |
| 26 |
|
|
#define INCLUDED_serv_h |
| 27 |
michael |
912 |
#include "config.h" |
| 28 |
adx |
30 |
|
| 29 |
|
|
/* collect ziplinks compression ratios/etc every minute */ |
| 30 |
|
|
#define ZIPSTATS_TIME 60 |
| 31 |
|
|
|
| 32 |
|
|
struct ConfItem; |
| 33 |
|
|
|
| 34 |
|
|
/* |
| 35 |
|
|
* number of seconds to wait after server starts up, before |
| 36 |
|
|
* starting try_connections() |
| 37 |
|
|
* TOO SOON and you can nick collide like crazy. |
| 38 |
|
|
*/ |
| 39 |
|
|
#define STARTUP_CONNECTIONS_TIME 60 |
| 40 |
|
|
|
| 41 |
|
|
struct Client; |
| 42 |
|
|
struct AccessItem; |
| 43 |
|
|
struct Channel; |
| 44 |
|
|
|
| 45 |
|
|
/* Capabilities */ |
| 46 |
|
|
struct Capability |
| 47 |
|
|
{ |
| 48 |
|
|
dlink_node node; |
| 49 |
|
|
char *name; /* name of capability */ |
| 50 |
|
|
unsigned int cap; /* mask value */ |
| 51 |
|
|
}; |
| 52 |
|
|
|
| 53 |
|
|
#define CAP_CAP 0x00000001 /* received a CAP to begin with */ |
| 54 |
|
|
#define CAP_QS 0x00000002 /* Can handle quit storm removal */ |
| 55 |
|
|
#define CAP_EX 0x00000004 /* Can do channel +e exemptions */ |
| 56 |
|
|
#define CAP_CHW 0x00000008 /* Can do channel wall @# */ |
| 57 |
michael |
885 |
#define CAP_IE 0x00000010 /* Can do invite exceptions */ |
| 58 |
|
|
#define CAP_EOB 0x00000020 /* Can do EOB message */ |
| 59 |
|
|
#define CAP_KLN 0x00000040 /* Can do KLINE message */ |
| 60 |
|
|
#define CAP_GLN 0x00000080 /* Can do GLINE message */ |
| 61 |
|
|
#define CAP_HUB 0x00000100 /* This server is a HUB */ |
| 62 |
|
|
#define CAP_TS6 0x00000200 /* Can do TS6 */ |
| 63 |
|
|
#define CAP_ZIP 0x00000400 /* Can do ZIPlinks */ |
| 64 |
|
|
#define CAP_ENC 0x00000800 /* Can do ENCrypted links */ |
| 65 |
|
|
#define CAP_KNOCK 0x00001000 /* supports KNOCK */ |
| 66 |
|
|
#define CAP_TB 0x00002000 /* supports TB */ |
| 67 |
|
|
#define CAP_UNKLN 0x00004000 /* Can do UNKLINE message */ |
| 68 |
|
|
#define CAP_CLUSTER 0x00008000 /* supports server clustering */ |
| 69 |
|
|
#define CAP_ENCAP 0x00010000 /* supports ENCAP message */ |
| 70 |
|
|
#define CAP_HOPS 0x00020000 /* supports HALFOPS */ |
| 71 |
|
|
#define CAP_TBURST 0x00040000 /* supports TBURST */ |
| 72 |
adx |
30 |
|
| 73 |
|
|
#ifdef HAVE_LIBZ |
| 74 |
|
|
#define CAP_ZIP_SUPPORTED CAP_ZIP |
| 75 |
|
|
#else |
| 76 |
|
|
#define CAP_ZIP_SUPPORTED 0 |
| 77 |
|
|
#endif |
| 78 |
|
|
|
| 79 |
|
|
#ifdef HAVE_LIBCRYPTO |
| 80 |
|
|
struct EncCapability |
| 81 |
|
|
{ |
| 82 |
|
|
const char *name; /* name of capability (cipher name) */ |
| 83 |
|
|
unsigned int cap; /* mask value */ |
| 84 |
|
|
int keylen; /* keylength (bytes) */ |
| 85 |
|
|
int cipherid; /* ID number of cipher type (BF, IDEA, etc.) */ |
| 86 |
|
|
}; |
| 87 |
|
|
|
| 88 |
|
|
/* |
| 89 |
|
|
* Cipher ID numbers |
| 90 |
|
|
* - DO NOT CHANGE THESE! Otherwise you break backwards compatibility |
| 91 |
|
|
* If you wish to add a new cipher, append it to the list. Do not |
| 92 |
|
|
* have it's value replace another. |
| 93 |
|
|
*/ |
| 94 |
|
|
#define CIPHER_BF 1 |
| 95 |
|
|
#define CIPHER_CAST 2 |
| 96 |
|
|
#define CIPHER_DES 3 |
| 97 |
|
|
#define CIPHER_3DES 4 |
| 98 |
|
|
#define CIPHER_IDEA 5 |
| 99 |
|
|
#define CIPHER_RC5_8 6 |
| 100 |
|
|
#define CIPHER_RC5_12 7 |
| 101 |
|
|
#define CIPHER_RC5_16 8 |
| 102 |
|
|
|
| 103 |
|
|
/* Cipher Capabilities */ |
| 104 |
|
|
#define CAP_ENC_BF_128 0x00000001 |
| 105 |
|
|
#define CAP_ENC_BF_168 0x00000002 |
| 106 |
|
|
#define CAP_ENC_CAST_128 0x00000004 |
| 107 |
|
|
#define CAP_ENC_DES_56 0x00000008 |
| 108 |
|
|
#define CAP_ENC_3DES_168 0x00000010 |
| 109 |
|
|
#define CAP_ENC_IDEA_128 0x00000020 |
| 110 |
|
|
#define CAP_ENC_RC5_8_128 0x00000040 |
| 111 |
|
|
#define CAP_ENC_RC5_12_128 0x00000080 |
| 112 |
|
|
#define CAP_ENC_RC5_16_128 0x00000100 |
| 113 |
|
|
#define CAP_ENC_ALL 0xFFFFFFFF |
| 114 |
|
|
|
| 115 |
|
|
|
| 116 |
|
|
/* */ |
| 117 |
|
|
#ifdef HAVE_EVP_BF_CFB |
| 118 |
|
|
#define USE_CIPHER_BF 1 |
| 119 |
|
|
/* Check for bug handling variable length blowfish keys */ |
| 120 |
|
|
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x00000000L |
| 121 |
|
|
#define USE_CIPHER_BF_V 1 |
| 122 |
|
|
#else |
| 123 |
|
|
#define USE_CIPHER_BF_V 0 |
| 124 |
|
|
#endif |
| 125 |
|
|
#else |
| 126 |
|
|
#define USE_CIPHER_BF_V 0 |
| 127 |
|
|
#define USE_CIPHER_BF 0 |
| 128 |
|
|
#endif |
| 129 |
|
|
/* Cast */ |
| 130 |
|
|
#ifdef HAVE_EVP_CAST5_CFB |
| 131 |
|
|
#define USE_CIPHER_CAST 1 |
| 132 |
|
|
#else |
| 133 |
|
|
#define USE_CIPHER_CAST 0 |
| 134 |
|
|
#endif |
| 135 |
|
|
/* DES */ |
| 136 |
|
|
#ifdef HAVE_EVP_DES_CFB |
| 137 |
|
|
#define USE_CIPHER_DES 1 |
| 138 |
|
|
#else |
| 139 |
|
|
#define USE_CIPHER_DES 0 |
| 140 |
|
|
#endif |
| 141 |
|
|
/* 3DES */ |
| 142 |
|
|
#ifdef HAVE_EVP_DES_EDE3_CFB |
| 143 |
|
|
#define USE_CIPHER_3DES 1 |
| 144 |
|
|
#else |
| 145 |
|
|
#define USE_CIPHER_3DES 0 |
| 146 |
|
|
#endif |
| 147 |
|
|
/* IDEA */ |
| 148 |
|
|
#ifdef HAVE_EVP_IDEA_CFB |
| 149 |
|
|
#define USE_CIPHER_IDEA 1 |
| 150 |
|
|
#else |
| 151 |
|
|
#define USE_CIPHER_IDEA 0 |
| 152 |
|
|
#endif |
| 153 |
|
|
/* RC5 */ |
| 154 |
|
|
#ifdef HAVE_EVP_RC5_32_12_16_CFB |
| 155 |
|
|
#define USE_CIPHER_RC5 1 |
| 156 |
|
|
#else |
| 157 |
|
|
#define USE_CIPHER_RC5 0 |
| 158 |
|
|
#endif |
| 159 |
|
|
|
| 160 |
|
|
/* Only enable ciphers supported by available version of OpenSSL */ |
| 161 |
|
|
#define CAP_ENC_MASK \ |
| 162 |
|
|
(((USE_CIPHER_BF * CAP_ENC_ALL) & CAP_ENC_BF_128) | \ |
| 163 |
|
|
((USE_CIPHER_BF_V * CAP_ENC_ALL) & CAP_ENC_BF_168) | \ |
| 164 |
|
|
((USE_CIPHER_CAST * CAP_ENC_ALL) & CAP_ENC_CAST_128) | \ |
| 165 |
|
|
((USE_CIPHER_DES * CAP_ENC_ALL) & CAP_ENC_DES_56) | \ |
| 166 |
|
|
((USE_CIPHER_3DES * CAP_ENC_ALL) & CAP_ENC_3DES_168) | \ |
| 167 |
|
|
((USE_CIPHER_IDEA * CAP_ENC_ALL) & CAP_ENC_IDEA_128) | \ |
| 168 |
|
|
((USE_CIPHER_RC5 * CAP_ENC_ALL) & CAP_ENC_RC5_8_128) | \ |
| 169 |
|
|
((USE_CIPHER_RC5 * CAP_ENC_ALL) & CAP_ENC_RC5_12_128) | \ |
| 170 |
|
|
((USE_CIPHER_RC5 * CAP_ENC_ALL) & CAP_ENC_RC5_16_128)) |
| 171 |
|
|
|
| 172 |
|
|
#define IsCapableEnc(x, cap) ((x)->localClient->enc_caps & (cap)) |
| 173 |
|
|
#define SetCapableEnc(x, cap) ((x)->localClient->enc_caps |= (cap)) |
| 174 |
|
|
#define ClearCapEnc(x, cap) ((x)->localClient->enc_caps &= ~(cap)) |
| 175 |
|
|
#endif /* HAVE_LIBCRYPTO */ |
| 176 |
|
|
|
| 177 |
|
|
#define CHECK_SERVER_CRYPTLINK 1 |
| 178 |
|
|
#define CHECK_SERVER_NOCRYPTLINK 0 |
| 179 |
|
|
|
| 180 |
|
|
/* |
| 181 |
|
|
* Capability macros. |
| 182 |
|
|
*/ |
| 183 |
|
|
#define IsCapable(x, cap) ((x)->localClient->caps & (cap)) |
| 184 |
|
|
#define SetCapable(x, cap) ((x)->localClient->caps |= (cap)) |
| 185 |
|
|
#define ClearCap(x, cap) ((x)->localClient->caps &= ~(cap)) |
| 186 |
|
|
|
| 187 |
|
|
#define SLINKCMD_SET_ZIP_OUT_LEVEL 1 /* data */ |
| 188 |
|
|
#define SLINKCMD_START_ZIP_OUT 2 |
| 189 |
|
|
#define SLINKCMD_START_ZIP_IN 3 |
| 190 |
|
|
#define SLINKCMD_SET_CRYPT_IN_CIPHER 4 /* data */ |
| 191 |
|
|
#define SLINKCMD_SET_CRYPT_IN_KEY 5 /* data */ |
| 192 |
|
|
#define SLINKCMD_START_CRYPT_IN 6 |
| 193 |
|
|
#define SLINKCMD_SET_CRYPT_OUT_CIPHER 7 /* data */ |
| 194 |
|
|
#define SLINKCMD_SET_CRYPT_OUT_KEY 8 /* data */ |
| 195 |
|
|
#define SLINKCMD_START_CRYPT_OUT 9 |
| 196 |
|
|
#define SLINKCMD_INJECT_RECVQ 10 /* data */ |
| 197 |
|
|
#define SLINKCMD_INJECT_SENDQ 11 /* data */ |
| 198 |
|
|
#define SLINKCMD_INIT 12 |
| 199 |
|
|
#define SLINKCMD_ZIPSTATS 13 |
| 200 |
|
|
|
| 201 |
|
|
#define SLINKRPL_FLAG_DATA 0x0001 /* reply has data following */ |
| 202 |
|
|
#define SLINKRPL_ERROR 1 |
| 203 |
|
|
#define SLINKRPL_ZIPSTATS 2 |
| 204 |
|
|
|
| 205 |
|
|
typedef void SlinkRplHnd(unsigned int replyid, unsigned int datalen, |
| 206 |
|
|
unsigned char *data, struct Client *client_p); |
| 207 |
|
|
struct SlinkRplDef |
| 208 |
|
|
{ |
| 209 |
|
|
unsigned int replyid; |
| 210 |
|
|
SlinkRplHnd *handler; |
| 211 |
|
|
unsigned int flags; |
| 212 |
|
|
}; |
| 213 |
|
|
|
| 214 |
|
|
extern struct SlinkRplDef slinkrpltab[]; |
| 215 |
|
|
|
| 216 |
|
|
/* |
| 217 |
|
|
* Globals |
| 218 |
|
|
* |
| 219 |
|
|
* |
| 220 |
|
|
* list of recognized server capabilities. "TS" is not on the list |
| 221 |
|
|
* because all servers that we talk to already do TS, and the kludged |
| 222 |
|
|
* extra argument to "PASS" takes care of checking that. -orabidoo |
| 223 |
|
|
*/ |
| 224 |
|
|
extern struct Capability captab[]; |
| 225 |
|
|
#ifdef HAVE_LIBCRYPTO |
| 226 |
|
|
extern struct EncCapability CipherTable[]; |
| 227 |
|
|
#endif |
| 228 |
|
|
|
| 229 |
|
|
/* |
| 230 |
|
|
* return values for hunt_server() |
| 231 |
|
|
*/ |
| 232 |
|
|
#define HUNTED_NOSUCH (-1) /* if the hunted server is not found */ |
| 233 |
|
|
#define HUNTED_ISME 0 /* if this server should execute the command */ |
| 234 |
|
|
#define HUNTED_PASS 1 /* if message passed onwards successfully */ |
| 235 |
|
|
|
| 236 |
michael |
1115 |
extern int valid_servname(const char *); |
| 237 |
adx |
30 |
extern int check_server(const char *, struct Client *, int); |
| 238 |
|
|
extern int hunt_server(struct Client *, struct Client *, |
| 239 |
|
|
const char *, int, int, char **); |
| 240 |
|
|
extern const char *my_name_for_link(struct ConfItem *); |
| 241 |
|
|
extern void add_capability(const char *, int, int); |
| 242 |
|
|
extern int delete_capability(const char *); |
| 243 |
|
|
extern int find_capability(const char *); |
| 244 |
|
|
extern void send_capabilities(struct Client *, struct AccessItem *, int, int); |
| 245 |
|
|
extern void write_links_file(void *); |
| 246 |
|
|
extern void server_estab(struct Client *); |
| 247 |
|
|
extern const char *show_capabilities(struct Client *); |
| 248 |
|
|
extern void try_connections(void *); |
| 249 |
|
|
extern void collect_zipstats(void *); |
| 250 |
|
|
extern void burst_channel(struct Client *client_p, struct Channel *); |
| 251 |
|
|
extern void sendnick_TS(struct Client *, struct Client *); |
| 252 |
|
|
extern int serv_connect(struct AccessItem *, struct Client *); |
| 253 |
|
|
extern struct Client *find_servconn_in_progress(const char *); |
| 254 |
|
|
extern void cryptlink_init(struct Client *, struct ConfItem *, fde_t *); |
| 255 |
|
|
extern void cryptlink_regen_key(void *); |
| 256 |
|
|
extern void cryptlink_error(struct Client *, const char *, |
| 257 |
|
|
const char *, const char *); |
| 258 |
|
|
extern struct EncCapability *check_cipher(struct Client *, struct AccessItem *); |
| 259 |
|
|
extern struct Server *make_server(struct Client *); |
| 260 |
|
|
|
| 261 |
|
|
/* XXX don't belong in the now gone md5, but do these belong in s_serv.c ? */ |
| 262 |
|
|
extern int base64_block(unsigned char **, char *, int); |
| 263 |
|
|
extern int unbase64_block(unsigned char **, char *, int); |
| 264 |
|
|
#endif /* INCLUDED_s_serv_h */ |
| 265 |
|
|
|