Integer type name change.
[silc.git] / lib / silcclient / client.h
1 /*
2
3   client.h 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2002 Pekka Riikonen
8
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.
12
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.
17
18 */
19
20 #ifndef CLIENT_H
21 #define CLIENT_H
22
23 /* Forward declarations */
24 typedef struct SilcClientInternalStruct *SilcClientInternal;
25
26 /* Generic rekey context for connections */
27 typedef struct {
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;
32   int ske_group;
33   bool pfs;
34   SilcUInt32 timeout;
35   void *context;
36 } *SilcClientRekey;
37
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. */
41 typedef struct {
42   SilcConnectionAuthRequest callback;
43   void *context;
44   SilcTask timeout;
45 } *SilcClientConnAuthRequest;
46
47 /* Connection structure used in client to associate all the important
48    connection specific data to this structure. */
49 struct SilcClientConnectionStruct {
50   /*
51    * Local data 
52    */
53   char *nickname;
54
55   /* Local client ID for this connection */
56   SilcClientID *local_id;
57
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;
62
63   /* Own client entry. */
64   SilcClientEntry local_entry;
65
66   /*
67    * Remote data 
68    */
69   char *remote_host;
70   int remote_port;
71   int remote_type;
72   char *remote_info;
73
74   /* Remote server ID for this connection */
75   SilcServerID *remote_id;
76
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;
81
82   /*
83    * Common data 
84    */
85   /* Keys and stuff negotiated in the SKE protocol */
86   SilcCipher send_key;
87   SilcCipher receive_key;
88   SilcHmac hmac_send;
89   SilcHmac hmac_receive;
90   SilcHash hash;
91   SilcUInt32 psn_send;
92   SilcUInt32 psn_receive;
93
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;
100
101   /* Current channel on window. All channels are saved (allocated) into
102      the cache entries. */
103   SilcChannelEntry current_channel;
104
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;
109
110   /* Pending command queue for this connection */
111   SilcDList pending_commands;
112
113   /* Current command identifier, 0 not used */
114   SilcUInt16 cmd_ident;
115
116   /* Requested pings. */
117   SilcClientPing *ping;
118   SilcUInt32 ping_count;
119
120   /* Set away message */
121   SilcClientAway *away;
122
123   /* Re-key context */
124   SilcClientRekey rekey;
125
126   /* Authentication request context. */
127   SilcClientConnAuthRequest connauth;
128
129   /* File transmission sessions */
130   SilcDList ftp_sessions;
131   SilcUInt32 next_session_id;
132   SilcClientFtpSession active_session;
133
134   /* Pointer back to the SilcClient. This object is passed to the application
135      and the actual client object is accesible through this pointer. */
136   SilcClient client;
137
138   /* User data context. Library does not touch this. */
139   void *context;
140 };
141
142 /* Main client structure. */
143 struct SilcClientStruct {
144   char *username;               /* Username, must be set by application */
145   char *nickname;               /* Nickname, may be set by application  */
146   char *hostname;               /* hostname, must be set by application */
147   char *realname;               /* Real name, must be set be application */
148
149   SilcPublicKey public_key;     /* Public key of user, set by application */
150   SilcPrivateKey private_key;   /* Private key of user, set by application */
151   SilcPKCS pkcs;                /* PKCS allocated by application */
152
153   SilcSchedule schedule;        /* Scheduler, automatically allocated by
154                                    the client library. */
155
156   /* Random Number Generator. Application should use this as its primary
157      random number generator. */
158   SilcRng rng;
159
160   /* Application specific user data pointer. Client library does not
161      touch this. This the context sent as argument to silc_client_alloc. */
162   void *application;
163
164   /* Internal data for client library. Application cannot access this
165      data at all. */
166   SilcClientInternal internal;
167 };
168
169 #endif