ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/include/s_serv.h
Revision: 126
Committed: Fri Oct 14 02:41:46 2005 UTC (20 years, 10 months ago) by db
Content type: text/x-chdr
File size: 10065 byte(s)
Log Message:
- attach/conf cleanup take 2
- Each client has now one AccessItem for its connect
  stored in localClient->iline
- The corresponding class is now stored in localClient->class

The ramifications of this move are, there is no conf list to traverse
to find the AccessItem, the class is instantly available from the localClient
struct without having to traverse the confs list and indirectly through the
aconf. This speeds up get_sendq etc. functions. As a bonus, at least
4 fewer bytes are used in the Client struct, since a dlink list is 4 words.
It does mean there is no longer a separate conf oper, which leads to the
kludge of patching the clients iline into an oper conf when
a client opers up. I don't think the oper flags are used after the client
is opered, so the patching operation may not be necessary.

- Server confs are stored in ->serv->sconf as before but attaching
  happens much earlier.
- server hub/leaf masks continues to be a dlink list but linked from
  the ->serv which is only allocated for servers.

- cleaned up some comments, added a comment, notably to check_server()
  which badly needed it.
- Pass ClassItem or AccessItem etc. in when it makes more sense than passing
  in struct ConfItem. This simplified and clarified rebuild_cidr_class()

And lo, there was a great rejoicing.


File Contents

# User Rev Content
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     #include "setup.h"
28    
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     #define CAP_LL 0x00000010 /* Can do lazy links */
58     #define CAP_IE 0x00000020 /* Can do invite exceptions */
59     #define CAP_EOB 0x00000040 /* Can do EOB message */
60     #define CAP_KLN 0x00000080 /* Can do KLINE message */
61     #define CAP_GLN 0x00000100 /* Can do GLINE message */
62     #define CAP_HUB 0x00000200 /* This server is a HUB */
63     #define CAP_TS6 0x00000400 /* Can do TS6 */
64     #define CAP_ZIP 0x00000800 /* Can do ZIPlinks */
65     #define CAP_ENC 0x00001000 /* Can do ENCrypted links */
66     #define CAP_KNOCK 0x00002000 /* supports KNOCK */
67     #define CAP_TB 0x00004000 /* supports TB */
68     #define CAP_UNKLN 0x00008000 /* Can do UNKLINE message */
69     #define CAP_CLUSTER 0x00010000 /* supports server clustering */
70     #define CAP_ENCAP 0x00020000 /* supports ENCAP message */
71     #define CAP_HOPS 0x00040000 /* supports HALFOPS */
72 michael 120 #define CAP_TBURST 0x00080000 /* supports TBURST (Topic burst) */
73 adx 30
74     #ifdef HAVE_LIBZ
75     #define CAP_ZIP_SUPPORTED CAP_ZIP
76     #else
77     #define CAP_ZIP_SUPPORTED 0
78     #endif
79    
80     #ifdef HAVE_LIBCRYPTO
81     struct EncCapability
82     {
83     const char *name; /* name of capability (cipher name) */
84     unsigned int cap; /* mask value */
85     int keylen; /* keylength (bytes) */
86     int cipherid; /* ID number of cipher type (BF, IDEA, etc.) */
87     };
88    
89     /*
90     * Cipher ID numbers
91     * - DO NOT CHANGE THESE! Otherwise you break backwards compatibility
92     * If you wish to add a new cipher, append it to the list. Do not
93     * have it's value replace another.
94     */
95     #define CIPHER_BF 1
96     #define CIPHER_CAST 2
97     #define CIPHER_DES 3
98     #define CIPHER_3DES 4
99     #define CIPHER_IDEA 5
100     #define CIPHER_RC5_8 6
101     #define CIPHER_RC5_12 7
102     #define CIPHER_RC5_16 8
103    
104     /* Cipher Capabilities */
105     #define CAP_ENC_BF_128 0x00000001
106     #define CAP_ENC_BF_168 0x00000002
107     #define CAP_ENC_CAST_128 0x00000004
108     #define CAP_ENC_DES_56 0x00000008
109     #define CAP_ENC_3DES_168 0x00000010
110     #define CAP_ENC_IDEA_128 0x00000020
111     #define CAP_ENC_RC5_8_128 0x00000040
112     #define CAP_ENC_RC5_12_128 0x00000080
113     #define CAP_ENC_RC5_16_128 0x00000100
114     #define CAP_ENC_ALL 0xFFFFFFFF
115    
116    
117     /* */
118     #ifdef HAVE_EVP_BF_CFB
119     #define USE_CIPHER_BF 1
120     /* Check for bug handling variable length blowfish keys */
121     #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x00000000L
122     #define USE_CIPHER_BF_V 1
123     #else
124     #define USE_CIPHER_BF_V 0
125     #endif
126     #else
127     #define USE_CIPHER_BF_V 0
128     #define USE_CIPHER_BF 0
129     #endif
130     /* Cast */
131     #ifdef HAVE_EVP_CAST5_CFB
132     #define USE_CIPHER_CAST 1
133     #else
134     #define USE_CIPHER_CAST 0
135     #endif
136     /* DES */
137     #ifdef HAVE_EVP_DES_CFB
138     #define USE_CIPHER_DES 1
139     #else
140     #define USE_CIPHER_DES 0
141     #endif
142     /* 3DES */
143     #ifdef HAVE_EVP_DES_EDE3_CFB
144     #define USE_CIPHER_3DES 1
145     #else
146     #define USE_CIPHER_3DES 0
147     #endif
148     /* IDEA */
149     #ifdef HAVE_EVP_IDEA_CFB
150     #define USE_CIPHER_IDEA 1
151     #else
152     #define USE_CIPHER_IDEA 0
153     #endif
154     /* RC5 */
155     #ifdef HAVE_EVP_RC5_32_12_16_CFB
156     #define USE_CIPHER_RC5 1
157     #else
158     #define USE_CIPHER_RC5 0
159     #endif
160    
161     /* Only enable ciphers supported by available version of OpenSSL */
162     #define CAP_ENC_MASK \
163     (((USE_CIPHER_BF * CAP_ENC_ALL) & CAP_ENC_BF_128) | \
164     ((USE_CIPHER_BF_V * CAP_ENC_ALL) & CAP_ENC_BF_168) | \
165     ((USE_CIPHER_CAST * CAP_ENC_ALL) & CAP_ENC_CAST_128) | \
166     ((USE_CIPHER_DES * CAP_ENC_ALL) & CAP_ENC_DES_56) | \
167     ((USE_CIPHER_3DES * CAP_ENC_ALL) & CAP_ENC_3DES_168) | \
168     ((USE_CIPHER_IDEA * CAP_ENC_ALL) & CAP_ENC_IDEA_128) | \
169     ((USE_CIPHER_RC5 * CAP_ENC_ALL) & CAP_ENC_RC5_8_128) | \
170     ((USE_CIPHER_RC5 * CAP_ENC_ALL) & CAP_ENC_RC5_12_128) | \
171     ((USE_CIPHER_RC5 * CAP_ENC_ALL) & CAP_ENC_RC5_16_128))
172    
173     #define IsCapableEnc(x, cap) ((x)->localClient->enc_caps & (cap))
174     #define SetCapableEnc(x, cap) ((x)->localClient->enc_caps |= (cap))
175     #define ClearCapEnc(x, cap) ((x)->localClient->enc_caps &= ~(cap))
176     #endif /* HAVE_LIBCRYPTO */
177    
178     #define CHECK_SERVER_CRYPTLINK 1
179     #define CHECK_SERVER_NOCRYPTLINK 0
180    
181     /*
182     * Capability macros.
183     */
184     #define IsCapable(x, cap) ((x)->localClient->caps & (cap))
185     #define SetCapable(x, cap) ((x)->localClient->caps |= (cap))
186     #define ClearCap(x, cap) ((x)->localClient->caps &= ~(cap))
187    
188     #define SLINKCMD_SET_ZIP_OUT_LEVEL 1 /* data */
189     #define SLINKCMD_START_ZIP_OUT 2
190     #define SLINKCMD_START_ZIP_IN 3
191     #define SLINKCMD_SET_CRYPT_IN_CIPHER 4 /* data */
192     #define SLINKCMD_SET_CRYPT_IN_KEY 5 /* data */
193     #define SLINKCMD_START_CRYPT_IN 6
194     #define SLINKCMD_SET_CRYPT_OUT_CIPHER 7 /* data */
195     #define SLINKCMD_SET_CRYPT_OUT_KEY 8 /* data */
196     #define SLINKCMD_START_CRYPT_OUT 9
197     #define SLINKCMD_INJECT_RECVQ 10 /* data */
198     #define SLINKCMD_INJECT_SENDQ 11 /* data */
199     #define SLINKCMD_INIT 12
200     #define SLINKCMD_ZIPSTATS 13
201    
202     #define SLINKRPL_FLAG_DATA 0x0001 /* reply has data following */
203     #define SLINKRPL_ERROR 1
204     #define SLINKRPL_ZIPSTATS 2
205    
206     typedef void SlinkRplHnd(unsigned int replyid, unsigned int datalen,
207     unsigned char *data, struct Client *client_p);
208     struct SlinkRplDef
209     {
210     unsigned int replyid;
211     SlinkRplHnd *handler;
212     unsigned int flags;
213     };
214    
215     extern struct SlinkRplDef slinkrpltab[];
216    
217     /*
218     * Globals
219     *
220     *
221     * list of recognized server capabilities. "TS" is not on the list
222     * because all servers that we talk to already do TS, and the kludged
223     * extra argument to "PASS" takes care of checking that. -orabidoo
224     */
225     extern struct Capability captab[];
226     #ifdef HAVE_LIBCRYPTO
227     extern struct EncCapability CipherTable[];
228     #endif
229    
230     extern struct Client *uplink; /* NON NULL if leaf and is this servers uplink */
231    
232     /*
233     * return values for hunt_server()
234     */
235     #define HUNTED_NOSUCH (-1) /* if the hunted server is not found */
236     #define HUNTED_ISME 0 /* if this server should execute the command */
237     #define HUNTED_PASS 1 /* if message passed onwards successfully */
238    
239     extern int check_server(const char *, struct Client *, int);
240     extern int hunt_server(struct Client *, struct Client *,
241     const char *, int, int, char **);
242 db 126 extern const char *my_name_for_link(struct AccessItem *);
243 adx 30 extern void add_capability(const char *, int, int);
244     extern int delete_capability(const char *);
245     extern int find_capability(const char *);
246     extern void send_capabilities(struct Client *, struct AccessItem *, int, int);
247     extern void write_links_file(void *);
248     extern void server_estab(struct Client *);
249     extern void set_autoconn(struct Client *, const char *, int);
250     extern const char *show_capabilities(struct Client *);
251     extern void try_connections(void *);
252     extern void collect_zipstats(void *);
253     extern void initServerMask(void);
254     extern void burst_channel(struct Client *client_p, struct Channel *);
255     extern void sendnick_TS(struct Client *, struct Client *);
256     extern int serv_connect(struct AccessItem *, struct Client *);
257     extern struct Client *find_servconn_in_progress(const char *);
258     extern unsigned long nextFreeMask(void);
259 db 126 extern void cryptlink_init(struct Client *, struct AccessItem *, fde_t *);
260 adx 30 extern void cryptlink_regen_key(void *);
261     extern void cryptlink_error(struct Client *, const char *,
262     const char *, const char *);
263     extern void remove_lazylink_flags(unsigned long);
264     extern void client_burst_if_needed(struct Client *, struct Client *);
265     extern struct EncCapability *check_cipher(struct Client *, struct AccessItem *);
266     extern void add_lazylinkclient(struct Client *, struct Client *);
267    
268     extern struct Server *make_server(struct Client *);
269    
270     /* XXX don't belong in the now gone md5, but do these belong in s_serv.c ? */
271     extern int base64_block(unsigned char **, char *, int);
272     extern int unbase64_block(unsigned char **, char *, int);
273     #endif /* INCLUDED_s_serv_h */
274    

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision