5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2001 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 SilcClientStruct *SilcClient;
25 typedef struct SilcClientInternalStruct *SilcClientInternal;
26 typedef struct SilcClientConnectionStruct *SilcClientConnection;
27 typedef struct SilcClientPingStruct SilcClientPing;
28 typedef struct SilcClientAwayStruct SilcClientAway;
29 typedef struct SilcClientKeyAgreementStruct *SilcClientKeyAgreement;
30 typedef struct SilcClientFtpSessionStruct *SilcClientFtpSession;
36 /* Generic rekey context for connections */
38 /* Current sending encryption key, provided for re-key. The `pfs'
39 is TRUE if the Perfect Forward Secrecy is performed in re-key. */
40 unsigned char *send_enc_key;
48 /* Context to hold the connection authentication request callbacks that
49 will be called when the server has replied back to our request about
50 current authentication method in the session. */
52 SilcConnectionAuthRequest callback;
55 } *SilcClientConnAuthRequest;
57 /* Connection structure used in client to associate all the important
58 connection specific data to this structure. */
59 struct SilcClientConnectionStruct {
65 /* Local client ID for this connection */
66 SilcClientID *local_id;
68 /* Decoded local ID so that the above defined ID would not have
69 to be decoded for every packet. */
70 unsigned char *local_id_data;
71 uint32 local_id_data_len;
73 /* Own client entry. */
74 SilcClientEntry local_entry;
84 /* Remote server ID for this connection */
85 SilcServerID *remote_id;
87 /* Decoded remote ID so that the above defined ID would not have
88 to be decoded for every packet. */
89 unsigned char *remote_id_data;
90 uint32 remote_id_data_len;
95 /* Keys and stuff negotiated in the SKE protocol */
97 SilcCipher receive_key;
99 SilcHmac hmac_receive;
104 /* Client ID and Channel ID cache. Messages transmitted in SILC network
105 are done using different unique ID's. These are the cache for
106 thoses ID's used in the communication. */
107 SilcIDCache client_cache;
108 SilcIDCache channel_cache;
109 SilcIDCache server_cache;
111 /* Current channel on window. All channels are saved (allocated) into
112 the cache entries. */
113 SilcChannelEntry current_channel;
115 /* Socket connection object for this connection (window). This
116 object will have a back-pointer to this window object for fast
117 referencing (sock->user_data). */
118 SilcSocketConnection sock;
120 /* Pending command queue for this connection */
121 SilcDList pending_commands;
123 /* Current command identifier, 0 not used */
126 /* Requested pings. */
127 SilcClientPing *ping;
130 /* Set away message */
131 SilcClientAway *away;
134 SilcClientRekey rekey;
136 /* Authentication request context. */
137 SilcClientConnAuthRequest connauth;
139 /* File transmission sessions */
140 SilcDList ftp_sessions;
141 uint32 next_session_id;
142 SilcClientFtpSession active_session;
144 /* Pointer back to the SilcClient. This object is passed to the application
145 and the actual client object is accesible through this pointer. */
148 /* User data context. Library does not touch this. */
152 /* Main client structure. */
153 struct SilcClientStruct {
154 char *username; /* Username, must be set by application */
155 char *hostname; /* hostname, must be set by application */
156 char *realname; /* Real name, must be set be application */
158 SilcPublicKey public_key; /* Public key of user, set by application */
159 SilcPrivateKey private_key; /* Private key of user, set by application */
160 SilcPKCS pkcs; /* PKCS allocated by application */
162 SilcSchedule schedule; /* Scheduler, automatically allocated by
163 the client library. */
165 /* Random Number Generator. Application should use this as its primary
166 random number generator. */
169 /* Application specific user data pointer. Client library does not
170 touch this. This the context sent as argument to silc_client_alloc. */
173 /* Internal data for client library. Application cannot access this
175 SilcClientInternal internal;