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 SilcServerEntryStruct *SilcServerEntry;
26 typedef struct SilcClientEntryStruct *SilcClientEntry;
27 typedef struct SilcChannelEntryStruct *SilcChannelEntry;
30 SILC Server entry object.
32 This entry holds information about servers in SILC network. However,
33 contents of this entry is highly dependent of what kind of server we are
34 (normal server or router server) and whether the entry is used as a local
35 list or a global list. These factors dictates the contents of this entry.
37 This entry 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.
66 Time when data was received from the server last time.
68 SilcServerEntry router
70 This is a pointer back to the server list. This is the router server
71 where this server is connected to. If this is the router itself and
72 it doesn't have a route this is NULL.
75 SilcCipher receive_key
77 Data sending and receiving keys.
81 A pointer, usually, to the socket list for fast referencing to
82 the data used in connection with this server. This may be anything
83 but as just said, this is usually pointer to the socket connection
87 struct SilcServerEntryStruct {
93 /* TRUE when server is registered to server */
96 /* Pointer to the router */
97 SilcServerEntry router;
101 SilcCipher receive_key;
103 SilcPublicKey public_key;
105 unsigned char *hmac_key;
106 unsigned int hmac_key_len;
108 /* Connection data */
113 SILC Client entry object.
115 This entry holds information about connected clients ie. users in the SILC
116 network. The contents of this entrt is depended on whether we are normal
117 server or router server and whether the list is a local or global list.
119 This entry is defined as follows:
121 Server type List type Contents
122 =======================================================================
123 server local list All clients in server
124 server global list NULL
125 router local list All clients in cell
126 router global list All clients in SILC
128 Following short description of the fields:
132 Client's (meaning user's) real name. This is defined in following
135 Server type List type Contents
136 ====================================================
137 server local list User's name
138 router local list NULL
139 router global list NULL
141 Router doesn't hold this information since it is not vital data
142 for the router. If this information is needed by the client it is
143 fetched when it is needed.
147 Information about user. This is free information and can be virtually
148 anything. This is defined in following manner:
150 Server type List type Contents
151 ====================================================
152 server local list User's information
153 router local list NULL
154 router global list NULL
156 Router doesn't hold this information since it is not vital data
157 for the router. If this information is needed by the client it is
158 fetched when it is needed.
162 ID of the client. This includes all the information SILC will ever
163 need. Notice that no nickname of the user is saved anywhere. This is
164 beacuse of SilcClientID includes 88 bit hash value of the user's
165 nickname which can be used to track down specific user by their
166 nickname. Nickname is not relevant information that would need to be
171 Client's mode. Client maybe for example server operator or
172 router operator (SILC operator).
176 Time of last time data was received from the client. This is
177 result of normal time().
181 Time of last time client executed command. We are strict and will
182 not allow any command to be exeucted more than once in about
183 2 seconds. This is result of normal time().
187 Boolean value to indicate whether this client has registered itself
188 to the server. After KE and authentication protocols has been
189 successfully completed will client become registered.
191 SilcServerEntry router
193 This is a pointer to the server list. This is the router server whose
194 cell this client is coming from. This is used to route messages to
197 SilcCipher session_key
199 The actual session key established by key exchange protcol between
200 connecting parties. This is used for both encryption and decryption.
204 PKCS of the client. This maybe NULL.
208 MAC key used to compute MAC's for packets.
212 A pointer, usually, to the socket list for fast referencing to
213 the data used in connection with this client. This may be anything
214 but as just said, this is usually pointer to the socket connection
218 struct SilcClientEntryStruct {
225 /* Time of last accesses of the client */
229 /* TRUE when client is registered to server */
232 /* Pointer to the router */
233 SilcServerEntry router;
235 /* Pointers to channels this client has joined */
236 SilcChannelEntry *channel;
237 unsigned int channel_count;
241 SilcCipher receive_key;
244 SilcPublicKey public_key;
246 /* Connection data */
251 SILC Channel Client entry structure.
253 This entry used only by the SilcChannelEntry object and it holds
254 information about current clients (ie. users) on channel. Following
255 short description of the fields:
257 SilcClientEntry client
259 Pointer to the client list. This is the client currently on channel.
263 Client's current mode on the channel.
266 typedef struct SilcChannelClientEntryStruct {
267 SilcClientEntry client;
269 } *SilcChannelClientEntry;
272 SILC Channel entry object.
274 This entry holds information about channels in SILC network. The contents
275 of this entry is depended on whether we are normal server or router server
276 and whether the list is a local or global list.
278 This entry is defined as follows:
280 Server type List type Contents
281 =======================================================================
282 server local list All channels in server
283 server global list NULL
284 router local list All channels in cell
285 router global list All channels in SILC
287 Following short description of the fields:
291 Logical name of the channel.
295 Current mode of the channel.
299 ID of the channel. This includes all the information SILC will ever
304 Boolean value to tell whether there are users outside this server
305 on this channel. This is set to TRUE if router sends message to
306 the server that there are users outside your server on your
307 channel as well. This way server knows that messages needs to be
308 sent to the router for further routing. If this is a normal
309 server and this channel is not created on this server this field
310 is always TRUE. If this server is a router this field is ignored.
314 Current topic of the channel.
316 SilcServerEntry router
318 This is a pointer to the server list. This is the router server
319 whose cell this channel belongs to. This is used to route messages
322 SilcCipher channel_key
324 The key of the channel (the cipher actually).
329 Raw key data of the channel key.
331 unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]
333 Current initial vector. Initial vector is received always along
334 with the channel packet. By default this is filled with NULL.
337 struct SilcChannelEntryStruct {
344 /* List of users on channel */
345 SilcChannelClientEntry user_list;
346 unsigned int user_list_count;
348 /* Pointer to the router */
349 SilcServerEntry router;
352 SilcCipher channel_key;
354 unsigned int key_len;
355 unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
361 As for remainder these lists are defined as follows:
363 Entry list (cache) Server type List type Contents
364 =======================================================================
365 servers server local list Server itself
366 servers server global list NULL
367 servers router local list All servers in cell
368 servers router global list All servers in SILC
370 clients server local list All clients in server
371 clients server global list NULL
372 clients router local list All clients in cell
373 clients router global list All clients in SILC
375 channels server local list All channels in server
376 channels server global list NULL
377 channels router local list All channels in cell
378 channels router global list All channels in SILC
380 As seen on the list normal server never defines a global list. This is
381 because of normal server don't know anything about anything global data,
382 they get it from the router if and when they need it. Routers, on the
383 other hand, always define local and global lists because routers really
384 know all the relevant data in the SILC network.
386 This object is used as local and global list by the server/router.
387 Above table shows how this is defined on different conditions.
389 This object holds pointers to the ID cache system. Every ID cache entry
390 has a specific context pointer to allocated entry (server, client or
394 typedef struct SilcIDListStruct {
397 SilcIDCache channels;
401 Temporary ID Entry object.
403 This is used during authentication phases where we still don't know
404 what kind of connection remote connection is, hence, we will use this
405 structure instead until we know what type of connection remote end is.
407 This is not in any list. This is always individually allocated and
413 SilcCipher receive_key;
415 SilcPublicKey public_key;
418 unsigned char *hmac_key;
419 unsigned int hmac_key_len;
426 silc_idlist_add_server(SilcIDList id_list,
427 char *server_name, int server_type,
428 SilcServerID *id, SilcServerEntry router,
429 SilcCipher send_key, SilcCipher receive_key,
430 SilcPKCS pkcs, SilcHmac hmac,
431 SilcPublicKey public_key, void *connection);
433 silc_idlist_add_client(SilcIDList id_list, char *nickname, char *username,
434 char *userinfo, SilcClientID *id,
435 SilcServerEntry router,
436 SilcCipher send_key, SilcCipher receive_key,
437 SilcPKCS pkcs, SilcHmac hmac,
438 SilcPublicKey public_key, void *connection);
439 void silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry);
441 silc_idlist_find_client_by_nickname(SilcIDList id_list, char *nickname,
444 silc_idlist_find_client_by_hash(SilcIDList id_list, unsigned char *hash,
447 silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id);
449 silc_idlist_add_channel(SilcIDList id_list, char *channel_name, int mode,
450 SilcChannelID *id, SilcServerEntry router,
451 SilcCipher channel_key);
452 void silc_idlist_del_channel(SilcIDList id_list, SilcChannelEntry entry);
454 silc_idlist_find_channel_by_name(SilcIDList id_list, char *name);
456 silc_idlist_find_channel_by_id(SilcIDList id_list, SilcChannelID *id);