5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
24 /* Forward declarations */
25 typedef struct SilcServerListStruct SilcServerList;
26 typedef struct SilcClientListStruct SilcClientList;
27 typedef struct SilcChannelListStruct SilcChannelList;
30 SILC Server list object.
32 This list holds information about servers in SILC network. However,
33 contents of this list is highly dependent of what kind of server we are
34 (normal server or router server) and whether the list is used as a local
35 list or a global list. These factors dictates the contents of this list.
37 This list is defined as follows:
39 Server type List type Contents
40 =======================================================================
41 server local list Server itself
42 server global list NULL
43 router local list All servers is the cell
44 router global list All servers in the SILC network
46 Following short description of the fields:
50 Logical name of the server. There is no limit of the length of the
51 server name. This is usually the same name as defined in DNS.
55 Type of the server. SILC_SERVER or SILC_ROUTER are the possible
60 ID of the server. This includes all the relevant information about
61 the server SILC will ever need. These are also the informations
62 that is broadcasted between servers and routers in the SILC network.
64 struct SilcServerListStruct *router
66 This is a pointer back to the server list. This is the router server
67 where this server is connected to. If this is the router itself and
68 it doesn't have a route this is NULL.
72 SilcCipher receive_key
76 A pointer, usually, to the socket list for fast referencing to
77 the data used in connection with this server. This may be anything
78 but as just said, this is usually pointer to the socket connection
82 struct SilcServerListStruct {
87 /* TRUE when server is registered to server */
90 /* Pointer to the router */
91 struct SilcServerListStruct *router;
95 SilcCipher receive_key;
97 SilcPublicKey public_key;
99 unsigned char *hmac_key;
100 unsigned int hmac_key_len;
102 /* Connection data */
105 struct SilcServerListStruct *next;
106 struct SilcServerListStruct *prev;
110 SILC Client list object.
112 This list holds information about connected clients ie. users in the SILC
113 network. The contents of this list is depended on whether we are normal
114 server or router server and whether the list is a local or global list.
116 This list is defined as follows:
118 Server type List type Contents
119 =======================================================================
120 server local list All clients in server
121 server global list NULL
122 router local list All clients in cell
123 router global list All clients in SILC
125 Following short description of the fields:
129 Client's (meaning user's) real name. This is defined in following
132 Server type List type Contents
133 ====================================================
134 server local list User's name
135 router local list NULL
136 router global list NULL
138 Router doesn't hold this information since it is not vital data
139 for the router. If this information is needed by the client it is
140 fetched when it is needed.
144 Information about user. This is free information and can be virtually
145 anything. This is defined in following manner:
147 Server type List type Contents
148 ====================================================
149 server local list User's information
150 router local list NULL
151 router global list NULL
153 Router doesn't hold this information since it is not vital data
154 for the router. If this information is needed by the client it is
155 fetched when it is needed.
159 ID of the client. This includes all the information SILC will ever
160 need. Notice that no nickname of the user is saved anywhere. This is
161 beacuse of SilcClientID includes 88 bit hash value of the user's
162 nickname which can be used to track down specific user by their
163 nickname. Nickname is not relevant information that would need to be
168 Client's mode. Client maybe for example server operator or
169 router operator (SILC operator).
171 SilcServerList *router
173 This is a pointer to the server list. This is the router server whose
174 cell this client is coming from. This is used to route messages to
177 SilcCipher session_key
179 The actual session key established by key exchange protcol between
180 connecting parties. This is used for both encryption and decryption.
184 PKCS of the client. This maybe NULL.
187 unsigned char *hmac_key
188 unsigned int hmac_key_len
190 MAC key used to compute MAC's for packets.
194 A pointer, usually, to the socket list for fast referencing to
195 the data used in connection with this client. This may be anything
196 but as just said, this is usually pointer to the socket connection
200 struct SilcClientListStruct {
207 /* TRUE when client is registered to server */
210 /* Pointer to the router */
211 SilcServerList *router;
213 /* Pointers to channels this client has joined */
214 SilcChannelList **channel;
215 unsigned int channel_count;
219 SilcCipher receive_key;
222 unsigned char *hmac_key;
223 unsigned int hmac_key_len;
225 /* Connection data */
228 struct SilcClientListStruct *next;
229 struct SilcClientListStruct *prev;
233 SILC Channel Client list structure.
235 This list used only by the SilcChannelList object and it holds information
236 about current clients (ie. users) on channel. Following short description
239 SilcClientList client
241 Pointer to the client list. This is the client currently on channel.
245 Client's current mode on the channel.
248 typedef struct SilcChannelClientListStruct {
249 SilcClientList *client;
251 } SilcChannelClientList;
254 SILC Channel list object.
256 This list holds information about channels in SILC network. The contents
257 of this list is depended on whether we are normal server or router server
258 and whether the list is a local or global list.
260 This list is defined as follows:
262 Server type List type Contents
263 =======================================================================
264 server local list All channels in server
265 server global list NULL
266 router local list All channels in cell
267 router global list All channels in SILC
269 Following short description of the fields:
273 Logical name of the channel.
277 Current mode of the channel.
281 ID of the channel. This includes all the information SILC will ever
286 Boolean value to tell whether there are users outside this server
287 on this channel. This is set to TRUE if router sends message to
288 the server that there are users outside your server on your
289 channel as well. This way server knows that messages needs to be
290 sent to the router for further routing. If this is a normal
291 server and this channel is not created on this server this field
292 is always TRUE. If this server is a router this field is ignored.
296 Current topic of the channel.
298 SilcServerList *router
300 This is a pointer to the server list. This is the router server
301 whose cell this channel belongs to. This is used to route messages
307 SilcCipher receive_key
310 struct SilcChannelListStruct {
317 /* List of users on channel */
318 SilcChannelClientList *user_list;
319 unsigned int user_list_count;
321 /* Pointer to the router */
322 SilcServerList *router;
325 SilcCipher channel_key;
327 unsigned int key_len;
328 unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
330 struct SilcChannelListStruct *next;
331 struct SilcChannelListStruct *prev;
337 As for remainder these lists are defined as follows:
339 List Server type List type Contents
340 =======================================================================
341 servers server local list Server itself
342 servers server global list NULL
343 servers router local list All servers in cell
344 servers router global list All servers in SILC
346 clients server local list All clients in server
347 clients server global list NULL
348 clients router local list All clients in cell
349 clients router global list All clients in SILC
351 channels server local list All channels in server
352 channels server global list NULL
353 channels router local list All channels in cell
354 channels router global list All channels in SILC
356 As seen on the list normal server never defines a global list. This is
357 because of normal server don't know anything about anything global data,
358 they get it from the router if and when they need it. Routers, on the
359 other hand, always define local and global lists because routers really
360 know all the relevant data in the SILC network.
363 typedef struct SilcIDListStruct {
364 SilcServerList *servers;
365 SilcClientList *clients;
366 SilcChannelList *channels;
368 /* ID Caches. Caches are used to perform fast search on the ID's. */
369 SilcIDCache *server_cache[96];
370 unsigned int server_cache_count[96];
371 SilcIDCache *client_cache[96];
372 unsigned int client_cache_count[96];
373 SilcIDCache *channel_cache[96];
374 unsigned int channel_cache_count[96];
377 typedef SilcIDListObject *SilcIDList;
380 Temporary ID List object.
382 This is used during authentication phases where we still don't
383 know what kind of connection remote connection is, hence, we
384 will use this structure instead until we know what type of
385 connection remote end is.
387 This is not in any list. This is always individually allocated
393 SilcCipher receive_key;
395 SilcPublicKey public_key;
398 unsigned char *hmac_key;
399 unsigned int hmac_key_len;
405 void silc_idlist_add_server(SilcServerList **list,
406 char *server_name, int server_type,
407 SilcServerID *id, SilcServerList *router,
408 SilcCipher send_key, SilcCipher receive_key,
409 SilcPKCS public_key, SilcHmac hmac,
410 SilcServerList **new_idlist);
411 void silc_idlist_add_client(SilcClientList **list, char *nickname,
412 char *username, char *userinfo,
413 SilcClientID *id, SilcServerList *router,
414 SilcCipher send_key, SilcCipher receive_key,
415 SilcPKCS public_key, SilcHmac hmac,
416 SilcClientList **new_idlist);
417 void silc_idlist_del_client(SilcClientList **list, SilcClientList *entry);
419 silc_idlist_find_client_by_nickname(SilcClientList *list,
423 silc_idlist_find_client_by_hash(SilcClientList *list,
424 char *nickname, SilcHash hash);
426 silc_idlist_find_client_by_id(SilcClientList *list, SilcClientID *id);
427 void silc_idlist_add_channel(SilcChannelList **list,
428 char *channel_name, int mode,
429 SilcChannelID *id, SilcServerList *router,
430 SilcCipher channel_key,
431 SilcChannelList **new_idlist);
433 silc_idlist_find_channel_by_id(SilcChannelList *list, SilcChannelID *id);
434 void silc_idlist_del_channel(SilcChannelList **list, SilcChannelList *entry);