5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 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 /* Forward declarations */
24 typedef struct SilcClientInternalStruct *SilcClientInternal;
26 /* Generic rekey context for connections */
28 /* Current sending encryption key, provided for re-key. The `pfs'
29 is TRUE if the Perfect Forward Secrecy is performed in re-key. */
30 unsigned char *send_enc_key;
31 SilcUInt32 enc_key_len;
38 /* Context to hold the connection authentication request callbacks that
39 will be called when the server has replied back to our request about
40 current authentication method in the session. */
42 SilcConnectionAuthRequest callback;
45 } *SilcClientConnAuthRequest;
47 /* Connection structure used in client to associate all the important
48 connection specific data to this structure. */
49 struct SilcClientConnectionStruct {
55 /* Local client ID for this connection */
56 SilcClientID *local_id;
58 /* Decoded local ID so that the above defined ID would not have
59 to be decoded for every packet. */
60 unsigned char *local_id_data;
61 SilcUInt32 local_id_data_len;
63 /* Own client entry. */
64 SilcClientEntry local_entry;
74 /* Remote server ID for this connection */
75 SilcServerID *remote_id;
77 /* Decoded remote ID so that the above defined ID would not have
78 to be decoded for every packet. */
79 unsigned char *remote_id_data;
80 SilcUInt32 remote_id_data_len;
85 /* Keys and stuff negotiated in the SKE protocol */
87 SilcCipher receive_key;
89 SilcHmac hmac_receive;
92 SilcUInt32 psn_receive;
94 /* Client ID and Channel ID cache. Messages transmitted in SILC network
95 are done using different unique ID's. These are the cache for
96 thoses ID's used in the communication. */
97 SilcIDCache client_cache;
98 SilcIDCache channel_cache;
99 SilcIDCache server_cache;
101 /* Current channel on window. All channels are saved (allocated) into
102 the cache entries. */
103 SilcChannelEntry current_channel;
105 /* Socket connection object for this connection (window). This
106 object will have a back-pointer to this window object for fast
107 referencing (sock->user_data). */
108 SilcSocketConnection sock;
110 /* Pending command queue for this connection */
111 SilcDList pending_commands;
113 /* Current command identifier, 0 not used */
114 SilcUInt16 cmd_ident;
116 /* Requested pings. */
117 SilcClientPing *ping;
118 SilcUInt32 ping_count;
120 /* Set away message */
121 SilcClientAway *away;
124 SilcClientRekey rekey;
126 /* Authentication request context. */
127 SilcClientConnAuthRequest connauth;
129 /* File transmission sessions */
130 SilcDList ftp_sessions;
131 SilcUInt32 next_session_id;
132 SilcClientFtpSession active_session;
134 /* Pointer back to the SilcClient. This object is passed to the application
135 and the actual client object is accesible through this pointer. */
138 /* Connection parameters */
139 SilcClientConnectionParams params;
141 /* User data context. Library does not touch this. */
145 /* Main client structure. */
146 struct SilcClientStruct {
147 char *username; /* Username, must be set by application */
148 char *nickname; /* Nickname, may be set by application */
149 char *hostname; /* hostname, must be set by application */
150 char *realname; /* Real name, must be set be application */
152 SilcPublicKey public_key; /* Public key of user, set by application */
153 SilcPrivateKey private_key; /* Private key of user, set by application */
154 SilcPKCS pkcs; /* PKCS allocated by application */
156 SilcSchedule schedule; /* Scheduler, automatically allocated by
157 the client library. */
159 /* Random Number Generator. Application should use this as its primary
160 random number generator. */
163 /* Application specific user data pointer. Client library does not
164 touch this. This the context sent as argument to silc_client_alloc. */
167 /* Internal data for client library. Application cannot access this
169 SilcClientInternal internal;