5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2001 - 2002 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; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
23 /* Client entry status */
25 SILC_CLIENT_STATUS_NONE = 0x0000,
26 SILC_CLIENT_STATUS_RESOLVING = 0x0001,
29 /* Client entry context. When client receives information about new client
30 (it receives its ID, for example, by IDENTIFY request) we create new
31 client entry. This entry also includes the private message keys if
33 struct SilcClientEntryStruct {
34 char *nickname; /* nickname */
35 char *username; /* username */
36 char *hostname; /* hostname */
37 char *server; /* SILC server name */
38 char *realname; /* Realname (userinfo) */
39 SilcUInt32 mode; /* User mode in SILC */
40 SilcClientID *id; /* The Client ID */
41 unsigned char *fingerprint; /* Fingerprint of client's public key */
42 SilcUInt32 fingerprint_len; /* Length of the fingerprint */
43 SilcCipher send_key; /* Private message key for sending */
44 SilcCipher receive_key; /* Private message key for receiving */
45 SilcClientKeyAgreement ke; /* Current key agreement context or NULL */
46 SilcEntryStatus status; /* Status mask */
47 SilcHashTable channels; /* All channels client has joined */
48 unsigned char *key; /* Set only if appliation provided the
49 key material. NULL if the library
51 SilcUInt32 key_len; /* Key length */
52 SilcUInt16 resolve_cmd_ident; /* Command identifier when resolving */
53 bool generated; /* TRUE if library generated `key' */
54 bool valid; /* FALSE if this entry is not valid */
57 /* Client and its mode on a channel */
58 struct SilcChannelUserStruct {
59 SilcClientEntry client;
61 SilcChannelEntry channel;
64 /* Channel entry context. This is allocate for every channel client has
65 joined to. This includes for example the channel specific keys */
66 struct SilcChannelEntryStruct {
70 SilcUInt16 resolve_cmd_ident;
72 /* All clients that has joined this channel */
73 SilcHashTable user_list;
76 SilcCipher channel_key; /* The channel key */
77 unsigned char *key; /* Raw key data */
78 SilcUInt32 key_len; /* Raw key data length */
79 unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]; /* Current IV */
80 SilcHmac hmac; /* Current HMAC */
81 SilcDList private_keys; /* List of private keys or NULL */
82 SilcChannelPrivateKey curr_key; /* Current private key */
84 /* Old channel key is saved for a short period of time when rekey occurs
85 in case if someone is sending messages after the rekey encrypted with
86 the old key, we can still decrypt them. */
87 SilcCipher old_channel_key;
92 /* Server entry context. This represents one server. When server information
93 is resolved with INFO command the server info is saved in this context.
94 Also the connected servers are saved here. */
95 struct SilcServerEntryStruct {
98 SilcServerID *server_id;
99 SilcUInt16 resolve_cmd_ident;
102 /* Prototypes. These are used only by the library. Application should not
103 call these directly. */
106 silc_client_add_client(SilcClient client, SilcClientConnection conn,
107 char *nickname, char *username,
108 char *userinfo, SilcClientID *id, SilcUInt32 mode);
109 void silc_client_update_client(SilcClient client,
110 SilcClientConnection conn,
111 SilcClientEntry client_entry,
112 const char *nickname,
113 const char *username,
114 const char *userinfo,
116 void silc_client_del_client_entry(SilcClient client,
117 SilcClientConnection conn,
118 SilcClientEntry client_entry);
119 SilcClientEntry silc_idlist_get_client(SilcClient client,
120 SilcClientConnection conn,
121 const char *nickname,
124 SilcChannelEntry silc_client_add_channel(SilcClient client,
125 SilcClientConnection conn,
126 const char *channel_name,
128 SilcChannelID *channel_id);
129 SilcServerEntry silc_client_add_server(SilcClient client,
130 SilcClientConnection conn,
131 const char *server_name,
132 const char *server_info,
133 SilcServerID *server_id);
134 void silc_client_update_server(SilcClient client,
135 SilcClientConnection conn,
136 SilcServerEntry server_entry,
137 const char *server_name,
138 const char *server_info);
139 bool silc_client_replace_channel_id(SilcClient client,
140 SilcClientConnection conn,
141 SilcChannelEntry channel,
142 SilcChannelID *new_id);
143 void silc_client_nickname_format(SilcClient client,
144 SilcClientConnection conn,
145 SilcClientEntry client_entry);