Merged from silc_1_0_branch.
[silc.git] / lib / silcclient / silcclient.h
1 /*
2
3   silcclient.h 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2000 - 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 /****h* silcclient/Client Library Interface
21  *
22  * DESCRIPTION
23  *
24  * This interface defines the SILC Client Library API for the application.
25  * The client operations are defined first.  These are callback functions that
26  * the application MUST implement since the library may call the functions
27  * at any time.  At the end of file is the API for the application that
28  * it can use from the library.  This is the only file that the application
29  * may include from the SIlC Client Library.
30  *
31  * o SILC Client Operations
32  *
33  *   These functions must be implemented by the application calling the SILC
34  *   client library. The client library can call these functions at any time.
35  *
36  *   To use this structure: define a static SilcClientOperations variable,
37  *   fill it and pass its pointer to silc_client_alloc function.
38  *
39  * o SILC Client Library API
40  *
41  *   This is the API that is published by the SILC Client Library for the
42  *   applications.  These functions are implemented in the SILC Client Library.
43  *   Application may freely call these functions from the library.
44  *
45  * Please, refer to the README file in this directory for the directions
46  * of how to use the SILC Client Library.
47  *
48  ***/
49
50 #ifndef SILCCLIENT_H
51 #define SILCCLIENT_H
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 #include "client.h"
58
59 /* General definitions */
60
61 /****s* silcclient/SilcClientAPI/SilcClient
62  *
63  * NAME
64  *
65  *    typedef struct SilcClientStruct { ... } *SilcClient
66  *
67  * DESCRIPTION
68  *
69  *    This is the actual SILC Client structure which represents one
70  *    SILC Client.  It is allocated with the silc_client_alloc function
71  *    and given as argument to all SILC Client Library functions.  It
72  *    is initialized with silc_client_init function, and freed with
73  *    silc_client_free function.
74  *
75  * SOURCE
76  */
77 struct SilcClientStruct {
78   /*
79    * The following fields are set by application
80    */
81   char *nickname;               /* Nickname, MAY be set by application  */
82   char *username;               /* Username, MUST be set by application */
83   char *hostname;               /* hostname, MUST be set by application */
84   char *realname;               /* Real name, MUST be set be application */
85   
86   SilcPublicKey public_key;     /* Public key of user, set by application */
87   SilcPrivateKey private_key;   /* Private key of user, set by application */
88   SilcPKCS pkcs;                /* PKCS allocated by application */
89
90   /*
91    * The following fields are set by the library
92    */
93
94   /* Scheduler, set by library.  Application may use this pointer. */
95   SilcSchedule schedule;
96   
97   /* Random Number Generator. Application should use this as its primary
98      random number generator. */
99   SilcRng rng;
100   
101   /* Application specific user data pointer. Client library does not
102      touch this.  This the context sent as argument to silc_client_alloc.
103      Application can use it freely. */
104   void *application;
105      
106   /* Generic hash context for application usage */
107   SilcHash md5hash;
108   SilcHash sha1hash;
109
110   /* Internal data for client library. Application cannot access this
111      data at all. */
112   SilcClientInternal internal;
113 };  
114 /***/
115
116 /****s* silcclient/SilcClientAPI/SilcClientConnection
117  *
118  * NAME
119  *
120  *    typedef struct SilcClientConnectionStruct { ... }
121  *                      *SilcClientConnection
122  *
123  * DESCRIPTION
124  *
125  *    This structure represents a connection.  When connection is created
126  *    to server this is context is returned to the application in the
127  *    "connected" client operation.  It includes all the important
128  *    data for the session, such as nickname, local and remote IDs, and
129  *    other information.
130  *
131  * SOURCE
132  */
133 struct SilcClientConnectionStruct {
134   /*
135    * Local data
136    */
137   char *nickname;                 /* Current nickname */
138   SilcClientEntry local_entry;    /* Own Client Entry */
139   SilcClientID *local_id;         /* Current Client ID */
140   unsigned char *local_id_data;   /* Current Client ID decoded */
141   SilcUInt32 local_id_data_len;
142
143   /*
144    * Remote data
145    */
146   char *remote_host;              /* Remote host name */
147   int remote_port;                /* Remote port */
148   SilcServerID *remote_id;        /* Remote Server ID */
149   unsigned char *remote_id_data;  /* Remote Server ID decoded */
150   SilcUInt32 remote_id_data_len;
151
152   /*
153    * Common data
154    */
155
156   /* Current command identifier for a command that was sent last.
157      Application may get the value from this variable to find out the
158      command identifier for last command. */
159   SilcUInt16 cmd_ident;
160
161   /* User data context. Library does not touch this. Application may
162      freely set and use this pointer for its needs. */
163   void *context;
164
165   /* Pointer back to the SilcClient.  Application may use this. */
166   SilcClient client;
167
168   /* Current channel.  Application may use and set this pointer if needed. */
169   SilcChannelEntry current_channel;
170
171   /* Socket connection object for this connection.  Application may
172      use this if needed.  The sock->user_data is back pointer to this
173      structure. */
174   SilcSocketConnection sock;
175
176   /* Internal data for client library. Application cannot access this
177      data at all. */
178   SilcClientConnectionInternal internal;
179 };
180 /***/
181
182 /****s* silcclient/SilcClientAPI/SilcClientEntry
183  *
184  * NAME
185  *
186  *    typedef struct SilcClientEntryStruct { ... } *SilcClientEntry
187  *
188  * DESCRIPTION
189  *
190  *    This structure represents a client or a user in the SILC network.
191  *    The local user has this structure also and it can be accessed from
192  *    SilcClientConnection structure.  All other users in the SILC network
193  *    that are accessed using the Client Library routines will have their
194  *    own SilcClientEntry structure.  For example, when finding users by
195  *    their nickname the Client Library returns this structure back to
196  *    the application.
197  *
198  * SOURCE
199  */
200 struct SilcClientEntryStruct {
201   /* General information */
202   char *nickname;               /* nickname */
203   char *username;               /* username */
204   char *hostname;               /* hostname */
205   char *server;                 /* SILC server name */
206   char *realname;               /* Realname (userinfo) */
207
208   /* Mode, ID and other information */
209   SilcUInt32 mode;              /* User mode in SILC */
210   SilcClientID *id;             /* The Client ID */
211   SilcDList attrs;              /* Requested Attributes (maybe NULL) */
212   unsigned char *fingerprint;   /* Fingerprint of client's public key */
213   SilcUInt32 fingerprint_len;   /* Length of the fingerprint */
214
215   /* Private message keys */
216   SilcCipher send_key;          /* Private message key for sending */
217   SilcCipher receive_key;       /* Private message key for receiving */
218   SilcHmac hmac_send;           /* Private mesage key HMAC for sending */
219   SilcHmac hmac_receive;        /* Private mesage key HMAC for receiving */
220   unsigned char *key;           /* Set only if application provided the
221                                    key material. NULL if the library 
222                                    generated the key. */
223   SilcUInt32 key_len;           /* Key length */
224   SilcClientKeyAgreement ke;    /* Current key agreement context or NULL */
225
226   /* SilcClientEntry status information */
227   SilcEntryStatus status;       /* Status mask */
228   SilcHashTable channels;       /* All channels client has joined */
229   SilcUInt16 resolve_cmd_ident; /* Command identifier when resolving */
230   bool generated;               /* TRUE if library generated `key' */
231   bool valid;                   /* FALSE if this entry is not valid */
232 };
233 /***/
234
235 /****s* silcclient/SilcClientAPI/SilcChannelEntry
236  *
237  * NAME
238  *
239  *    typedef struct SilcChannelEntryStruct { ... } *SilcChannelEntry
240  *
241  * DESCRIPTION
242  *
243  *    This structure represents a channel in the SILC network.  All
244  *    channels that the client are aware of or have joined in will be
245  *    represented as SilcChannelEntry.  The structure includes information
246  *    about the channel.
247  *
248  * SOURCE
249  */
250 struct SilcChannelEntryStruct {
251   /* General information */
252   char *channel_name;                        /* Channel name */
253   SilcChannelID *id;                         /* Channel ID */
254   SilcUInt32 mode;                           /* Channel mode */
255
256   /* All clients that has joined this channel */
257   SilcHashTable user_list;
258
259   /* Channel keys */
260   SilcCipher channel_key;                    /* The channel key */
261   unsigned char *key;                        /* Raw key data */
262   SilcUInt32 key_len;                        /* Raw key data length */
263   unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]; /* Current IV */
264   SilcHmac hmac;                             /* Current HMAC */
265
266   /* Channel private keys */
267   SilcDList private_keys;                    /* List of private keys or NULL */
268   SilcChannelPrivateKey curr_key;            /* Current private key */
269
270   /* SilcChannelEntry status information */
271   SilcCipher old_channel_key;
272   SilcHmac old_hmac;
273   SilcTask rekey_task;
274   SilcUInt16 resolve_cmd_ident;              /* Command identifier when
275                                                 resolving this entry */
276 };
277 /***/
278
279 /****s* silcclient/SilcClientAPI/SilcServerEntry
280  *
281  * NAME
282  *
283  *    typedef struct SilcServerEntryStruct { ... } *SilcServerEntry
284  *
285  * DESCRIPTION
286  *
287  *    This structure represents a server in the SILC network.  All servers
288  *    that the client is aware of and have for example resolved with
289  *    SILC_COMMAND_INFO command have their on SilcServerEntry structure.
290  *
291  * SOURCE
292  */
293 struct SilcServerEntryStruct {
294   /* General information */
295   char *server_name;                         /* Server name */
296   char *server_info;                         /* Server info */
297   SilcServerID *server_id;                   /* Server ID */
298   SilcUInt16 resolve_cmd_ident;              /* Command identifier when
299                                                 resolving this entry */
300 };
301 /***/
302
303 /****d* silcclient/SilcClientAPI/SilcKeyAgreementStatus
304  *
305  * NAME
306  *
307  *    typedef enum { ... } SilcKeyAgreementStatus;
308  *
309  * DESCRIPTION
310  *
311  *    Key agreement status types indicating the status of the key
312  *    agreement protocol.  These types are returned to the application 
313  *    in the SilcKeyAgreementCallback callback function.
314  *
315  * SOURCE
316  */
317 typedef enum {
318   SILC_KEY_AGREEMENT_OK,               /* Everything is Ok */
319   SILC_KEY_AGREEMENT_ERROR,            /* Unknown error occurred */
320   SILC_KEY_AGREEMENT_FAILURE,          /* The protocol failed */
321   SILC_KEY_AGREEMENT_TIMEOUT,          /* The protocol timeout */
322   SILC_KEY_AGREEMENT_ABORTED,          /* The protocol aborted */
323   SILC_KEY_AGREEMENT_ALREADY_STARTED,  /* Already started */
324   SILC_KEY_AGREEMENT_SELF_DENIED,      /* Negotiationg with itself denied */
325 } SilcKeyAgreementStatus;
326 /***/
327
328 /****f* silcclient/SilcClientAPI/SilcKeyAgreementCallback
329  *
330  * SYNOPSIS
331  *
332  *    typedef void (*SilcKeyAgreementCallback)(SilcClient client,
333  *                                             SilcClientConnection conn,
334  *                                             SilcClientEntry client_entry,
335  *                                             SilcKeyAgreementStatus status,
336  *                                             SilcSKEKeyMaterial *key,
337  *                                             void *context);
338  *
339  * DESCRIPTION
340  *
341  *    Key agreement callback that is called after the key agreement protocol
342  *    has been performed. This is called also if error occurred during the
343  *    key agreement protocol. The `key' is the allocated key material and
344  *    the caller is responsible of freeing it. The `key' is NULL if error
345  *    has occurred. The application can freely use the `key' to whatever
346  *    purpose it needs. See lib/silcske/silcske.h for the definition of
347  *    the SilcSKEKeyMaterial structure.
348  *
349  ***/
350 typedef void (*SilcKeyAgreementCallback)(SilcClient client,
351                                          SilcClientConnection conn,
352                                          SilcClientEntry client_entry,
353                                          SilcKeyAgreementStatus status,
354                                          SilcSKEKeyMaterial *key,
355                                          void *context);
356
357 /****s* silcclient/SilcClientAPI/SilcPrivateMessageKeys
358  *
359  * NAME
360  *
361  *    typedef struct { ... } SilcPrivateMessageKeys;
362  *
363  * DESCRIPTION
364  *
365  *    Structure to hold the list of private message keys. The array of this
366  *    structure is returned by the silc_client_list_private_message_keys
367  *    function.
368  *
369  * SOURCE
370  */
371 typedef struct {
372   SilcClientEntry client_entry;       /* The remote client entry */
373   char *cipher;                       /* The cipher name */
374   unsigned char *key;                 /* The original key, If the appliation
375                                          provided it. This is NULL if the
376                                          library generated the key or if
377                                          the SKE key material was used. */
378   SilcUInt32 key_len;                 /* The key length */
379 } *SilcPrivateMessageKeys;
380 /***/
381
382 /****s* silcclient/SilcClientAPI/SilcChannelPrivateKey
383  *
384  * NAME
385  *
386  *    typedef struct SilcChannelPrivateKeyStruct { ... }
387  *                      *SilcChannelPrivateKey;
388  *
389  * DESCRIPTION
390  *
391  *    Structure to hold one channel private key. The array of this structure
392  *    is returned by silc_client_list_channel_private_keys function.
393  *
394  * SOURCE
395  */
396 struct SilcChannelPrivateKeyStruct {
397   char *name;                         /* Application given name */
398   SilcCipher cipher;                  /* The cipher and key */
399   SilcHmac hmac;                      /* The HMAC and hmac key */
400   unsigned char *key;                 /* The key data */
401   SilcUInt32 key_len;                 /* The key length */
402 };
403 /***/
404
405 /****f* silcclient/SilcClientAPI/SilcAskPassphrase
406  *
407  * SYNOPSIS
408  *
409  *    typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
410  *                                      SilcUInt32 passphrase_len,
411  *                                      void *context);
412  *
413  * DESCRIPTION
414  *
415  *    Ask passphrase callback. This is called by the application when the
416  *    library calls `ask_passphrase' client operation.  The callback delivers
417  *    the passphrase to the library.  The passphrases in SILC protocol
418  *    MUST be in UTF-8 encoding, therefore the `passphrase' SHOULD be UTF-8
419  *    encoded, and if it is not then library will attempt to encode it.
420  *
421  ***/
422 typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
423                                   SilcUInt32 passphrase_len,
424                                   void *context);
425
426 /****f* silcclient/SilcClientAPI/SilcVerifyPublicKey
427  *
428  * SYNOPSIS
429  *
430  *    typedef void (*SilcVerifyPublicKey)(bool success, void *context);
431  *
432  * DESCRIPTION
433  *
434  *    Public key (or certificate) verification callback. This is called
435  *    by the application to indicate that the public key verification was
436  *    either success or failure.
437  *
438  ***/
439 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
440
441 /****f* silcclient/SilcClientAPI/SilcGetAuthMeth
442  *
443  * SYNOPSIS
444  *
445  *    typedef void (*SilcGetAuthMeth)(bool success, 
446  *                                    SilcProtocolAuthMeth auth_meth,
447  *                                    const unsigned char *auth_data,
448  *                                    SilcUInt32 auth_data_len, void *context);
449  * 
450  * DESCRIPTION
451  *
452  *    Authentication method resolving callback. This is called by the
453  *    application to return the resolved authentication method. The client
454  *    library has called the get_auth_method client operation and given
455  *    this function pointer as argument. The `success' will indicate whether
456  *    the authentication method could be resolved. The `auth_meth' is the
457  *    resolved authentication method. The `auth_data' and the `auth_data_len'
458  *    are the resolved authentication data. The `context' is the libary's
459  *    context sent to the get_auth_method client operation.
460  *
461  ***/
462 typedef void (*SilcGetAuthMeth)(bool success, 
463                                 SilcProtocolAuthMeth auth_meth,
464                                 const unsigned char *auth_data,
465                                 SilcUInt32 auth_data_len, void *context);
466
467 /****d* silcclient/SilcClientAPI/SilcClientMessageType
468  *
469  * NAME
470  *
471  *    typedef enum { ... } SilcClientMessageType;
472  *
473  * DESCRIPTION
474  *
475  *    Different message types for `say' client operation.  The application
476  *    may filter the message sent by the library according this type.
477  *
478  * SOURCE
479  */
480 typedef enum {
481   SILC_CLIENT_MESSAGE_INFO,            /* Informational */
482   SILC_CLIENT_MESSAGE_WARNING,         /* Warning */
483   SILC_CLIENT_MESSAGE_ERROR,           /* Error */
484   SILC_CLIENT_MESSAGE_AUDIT,           /* Auditable */
485 } SilcClientMessageType;
486 /***/
487
488 /****d* silcclient/SilcClientAPI/SilcClientConnectionStatus
489  *
490  * NAME
491  *
492  *    typedef enum { ... } SilcClientConnectionStatus
493  *
494  * DESCRIPTION
495  *
496  *    This type is returned to the `connect' client operation to indicate
497  *    the status of the created connection.  It can indicated if it was
498  *    successful or whether an error occurred.
499  *
500  * SOURCE
501  */
502 typedef enum {
503   SILC_CLIENT_CONN_SUCCESS,            /* Successfully connected */
504   SILC_CLIENT_CONN_SUCCESS_RESUME,     /* Successfully connected and
505                                           resumed old detached session */
506   SILC_CLIENT_CONN_ERROR,              /* Error occurred during connecting */
507 } SilcClientConnectionStatus;
508 /***/
509
510 /****s* silcclient/SilcClientAPI/SilcClientOperations
511  *
512  * NAME
513  *
514  *    typedef struct { ... } SilcClientOperations;
515  *
516  * DESCRIPTION
517  *
518  *    SILC Client Operations. These must be implemented by the application.
519  *    The Client library may call any of these routines at any time.  The
520  *    routines are used to deliver certain information to the application
521  *    or from the application to the client library.
522  *
523  * SOURCE
524  */
525 typedef struct {
526   /* Message sent to the application by library. `conn' associates the
527      message to a specific connection.  `conn', however, may be NULL. 
528      The `type' indicates the type of the message sent by the library.
529      The application can for example filter the message according the
530      type. */
531   void (*say)(SilcClient client, SilcClientConnection conn, 
532               SilcClientMessageType type, char *msg, ...);
533
534   /* Message for a channel. The `sender' is the sender of the message 
535      The `channel' is the channel. The `message' is the message.  Note 
536      that `message' maybe NULL.  The `flags' indicates message flags 
537      and it is used to determine how the message can be interpreted
538      (like it may tell the message is multimedia message). */
539   void (*channel_message)(SilcClient client, SilcClientConnection conn, 
540                           SilcClientEntry sender, SilcChannelEntry channel, 
541                           SilcMessagePayload payload, SilcMessageFlags flags,
542                           const unsigned char *message,
543                           SilcUInt32 message_len);
544
545   /* Private message to the client. The `sender' is the sender of the
546      message. The message is `message'and maybe NULL.  The `flags' 
547      indicates message flags  and it is used to determine how the message 
548      can be interpreted (like it may tell the message is multimedia 
549      message). */
550   void (*private_message)(SilcClient client, SilcClientConnection conn,
551                           SilcClientEntry sender, SilcMessagePayload payload,
552                           SilcMessageFlags flags,
553                           const unsigned char *message,
554                           SilcUInt32 message_len);
555
556   /* Notify message to the client. The notify arguments are sent in the
557      same order as servers sends them. The arguments are same as received
558      from the server except for ID's.  If ID is received application receives
559      the corresponding entry to the ID. For example, if Client ID is received
560      application receives SilcClientEntry.  Also, if the notify type is
561      for channel the channel entry is sent to application (even if server
562      does not send it because client library gets the channel entry from
563      the Channel ID in the packet's header). */
564   void (*notify)(SilcClient client, SilcClientConnection conn, 
565                  SilcNotifyType type, ...);
566
567   /* Command handler. This function is called always in the command function.
568      If error occurs it will be called as well. `conn' is the associated
569      client connection. `cmd_context' is the command context that was
570      originally sent to the command. `success' is FALSE if error occurred
571      during command. `command' is the command being processed. It must be
572      noted that this is not reply from server. This is merely called just
573      after application has called the command. Just to tell application
574      that the command really was processed. */
575   void (*command)(SilcClient client, SilcClientConnection conn, 
576                   SilcClientCommandContext cmd_context, bool success,
577                   SilcCommand command, SilcStatus status);
578
579   /* Command reply handler. This function is called always in the command reply
580      function. If error occurs it will be called as well. Normal scenario
581      is that it will be called after the received command data has been parsed
582      and processed. The function is used to pass the received command data to
583      the application. 
584      
585      `conn' is the associated client connection. `cmd_payload' is the command
586      payload data received from server and it can be ignored. It is provided
587      if the application would like to re-parse the received command data,
588      however, it must be noted that the data is parsed already by the library
589      thus the payload can be ignored. `success' is FALSE if error occurred.
590      In this case arguments are not sent to the application. The `status' is
591      the command reply status server returned. The `command' is the command
592      reply being processed. The function has variable argument list and each
593      command defines the number and type of arguments it passes to the
594      application (on error they are not sent).
595
596      The arguments are sent in the same order as servers sends them.  The 
597      arguments are same as received from the server except for ID's.  If 
598      ID is received application receives the corresponding entry to the 
599      ID. For example, if Client ID is receives application receives 
600      SilcClientEntry. */
601   void (*command_reply)(SilcClient client, SilcClientConnection conn,
602                         SilcCommandPayload cmd_payload, bool success,
603                         SilcCommand command, SilcStatus status, ...);
604
605   /* Called to indicate that connection was either successfully established
606      or connecting failed.  This is also the first time application receives
607      the SilcClientConnection object which it should save somewhere.
608      The `status' indicated whether the connection were successful.  If it
609      is error value the application must always call the function
610      silc_client_close_connection. */
611   void (*connected)(SilcClient client, SilcClientConnection conn,
612                     SilcClientConnectionStatus status);
613
614   /* Called to indicate that connection was disconnected to the server.
615      The `status' may tell the reason of the disconnection, and if the
616      `message' is non-NULL it may include the disconnection message
617      received from server. */
618   void (*disconnected)(SilcClient client, SilcClientConnection conn,
619                        SilcStatus status, const char *message);
620
621   /* Find authentication method and authentication data by hostname and
622      port. The hostname may be IP address as well. When the authentication
623      method has been resolved the `completion' callback with the found
624      authentication method and authentication data is called. The `conn'
625      may be NULL. */
626   void (*get_auth_method)(SilcClient client, SilcClientConnection conn,
627                           char *hostname, SilcUInt16 port,
628                           SilcGetAuthMeth completion, void *context);
629
630   /* Verifies received public key. The `conn_type' indicates which entity
631      (server, client etc.) has sent the public key. If user decides to trust
632      the application may save the key as trusted public key for later 
633      use. The `completion' must be called after the public key has been 
634      verified. */
635   void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
636                             SilcSocketType conn_type, unsigned char *pk, 
637                             SilcUInt32 pk_len, SilcSKEPKType pk_type,
638                             SilcVerifyPublicKey completion, void *context);
639
640   /* Ask (interact, that is) a passphrase from user. The passphrase is
641      returned to the library by calling the `completion' callback with
642      the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
643      if not then the library will attempt to encode. */
644   void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
645                          SilcAskPassphrase completion, void *context);
646
647   /* Notifies application that failure packet was received.  This is called
648      if there is some protocol active in the client.  The `protocol' is the
649      protocol context.  The `failure' is opaque pointer to the failure
650      indication.  Note, that the `failure' is protocol dependant and
651      application must explicitly cast it to correct type.  Usually `failure'
652      is 32 bit failure type (see protocol specs for all protocol failure
653      types). */
654   void (*failure)(SilcClient client, SilcClientConnection conn, 
655                   SilcProtocol protocol, void *failure);
656
657   /* Asks whether the user would like to perform the key agreement protocol.
658      This is called after we have received an key agreement packet or an
659      reply to our key agreement packet. This returns TRUE if the user wants
660      the library to perform the key agreement protocol and FALSE if it is not
661      desired (application may start it later by calling the function
662      silc_client_perform_key_agreement). If TRUE is returned also the
663      `completion' and `context' arguments must be set by the application. */
664   bool (*key_agreement)(SilcClient client, SilcClientConnection conn,
665                         SilcClientEntry client_entry, const char *hostname,
666                         SilcUInt16 port, SilcKeyAgreementCallback *completion,
667                         void **context);
668
669   /* Notifies application that file transfer protocol session is being
670      requested by the remote client indicated by the `client_entry' from
671      the `hostname' and `port'. The `session_id' is the file transfer
672      session and it can be used to either accept or reject the file
673      transfer request, by calling the silc_client_file_receive or
674      silc_client_file_close, respectively. */
675   void (*ftp)(SilcClient client, SilcClientConnection conn,
676               SilcClientEntry client_entry, SilcUInt32 session_id,
677               const char *hostname, SilcUInt16 port);
678
679   /* Delivers SILC session detachment data indicated by `detach_data' to the
680      application.  If application has issued SILC_COMMAND_DETACH command     
681      the client session in the SILC network is not quit.  The client remains 
682      in the network but is detached.  The detachment data may be used later
683      to resume the session in the SILC Network.  The appliation is   
684      responsible of saving the `detach_data', to for example in a file.
685
686      The detachment data can be given as argument to the functions
687      silc_client_connect_to_server, or silc_client_add_connection when
688      creating connection to remote server, inside SilcClientConnectionParams
689      structure.  If it is provided the client library will attempt to resume
690      the session in the network.  After the connection is created
691      successfully, the application is responsible of setting the user
692      interface for user into the same state it was before detaching (showing
693      same channels, channel modes, etc).  It can do this by fetching the
694      information (like joined channels) from the client library. */
695   void (*detach)(SilcClient client, SilcClientConnection conn,
696                  const unsigned char *detach_data,
697                  SilcUInt32 detach_data_len);
698 } SilcClientOperations;
699 /***/
700
701 /****f* silcclient/SilcClientAPI/SilcNicknameFormatParse
702  *
703  * SYNOPSIS
704  *
705  *    typedef void (*SilcNicknameFormatParse)(const char *nickname,
706  *                                            char **ret_nickname);
707  *
708  * DESCRIPTION
709  *
710  *    A callback function provided by the application for the library in
711  *    SilcClientParams structure. This function parses the formatted
712  *    nickname string `nickname' and returns the true nickname to the
713  *    `ret_nickname' pointer. The library can call this function at
714  *    any time.
715  *
716  ***/
717 typedef void (*SilcNicknameFormatParse)(const char *nickname,
718                                         char **ret_nickname);
719
720 /****s* silcclient/SilcClientAPI/SilcClientParams
721  *
722  * NAME
723  *
724  *    typedef struct { ... } SilcClientParams;
725  *
726  * DESCRIPTION
727  *
728  *    Client parameters. This can be filled with proper values and
729  *    given as argument to the silc_client_alloc function. The structure
730  *    hold various parameters which affects the function of the client.
731  *
732  * SOURCE
733  */
734 typedef struct {
735   /* Number of maximum tasks the client library's scheduler can handle.
736      If set to zero, the default value will be used (200). For WIN32
737      systems this should be set to 64 as it is the hard limit dictated
738      by the WIN32. */
739   int task_max;
740
741   /* Rekey timeout in seconds. The client will perform rekey in this
742      time interval. If set to zero, the default value will be used. */
743   unsigned int rekey_secs;
744
745   /* Connection authentication method request timeout. If server does not
746      reply back the current authentication method when we've requested it
747      in this time interval we'll assume the reply will not come at all. 
748      If set to zero, the default value (2 seconds) will be used. */
749   unsigned int connauth_request_secs;
750
751   /* Nickname format string. This can be used to order the client library
752      to save the nicknames in the library in a certain format. Since 
753      nicknames are not unique in SILC it is possible to have multiple same
754      nicknames. Using this format string it is possible to order the library
755      to separate the multiple same nicknames from each other. The format
756      types are defined below and they can appear in any order in the format
757      string. If this is NULL then default format is used which is the
758      default nickname without anything else. The string MUST be NULL
759      terminated.
760      
761      Following format types are available:
762      
763      %n  nickname      - the real nickname returned by the server (mandatory)
764      %h  hostname      - the stripped hostname of the client
765      %H  full hostname - the full hostname of the client
766      %s  server name   - the server name the client is connected
767      %S  full server   - the full server name the client is connected
768      %a  number        - ascending number in case there are several
769                          same nicknames (fe. nick@host and nick@host2)
770
771      Example format strings: "%n@%h%a"   (fe. nick@host, nick@host2)
772                              "%a!%n@%s"  (fe. nick@server, 2!nick@server)
773                              "%n@%H"     (fe. nick@host.domain.com)
774
775      By default this format is employed to the nicknames by the libary
776      only when there appears multiple same nicknames. If the library has
777      only one nickname cached the nickname is saved as is and without the
778      defined format. If you want always to save the nickname in the defined
779      format set the boolean field `nickname_force_format' to value TRUE.
780   */
781   char nickname_format[32];
782
783   /* If this is set to TRUE then the `nickname_format' is employed to all
784      saved nicknames even if there are no multiple same nicknames in the 
785      cache. By default this is FALSE, which means that the `nickname_format'
786      is employed only if the library will receive a nickname that is
787      already saved in the cache. It is recommended to leave this to FALSE
788      value. */
789   bool nickname_force_format;
790
791   /* A callback function provided by the application for the library to
792      parse the nickname from the formatted nickname string. Even though
793      the libary formats the nicknames the application knows generally the
794      format better so this function should be provided for the library
795      if the application sets the `nickname_format' field. The library
796      will call this to get the true nickname from the provided formatted
797      nickname string whenever it needs the true nickname. */
798   SilcNicknameFormatParse nickname_parse;
799
800   /* If this is set to TRUE then the client will ignore all incoming
801      Requested Attributes queries and does not reply anything back.  This
802      usually leads into situation where server does not anymore send
803      the queries after seeing that client does not reply anything back.
804      If your application does not support Requested Attributes or you do
805      not want to use them set this to TRUE.  See SilcAttribute and
806      silc_client_attribute_add for more information on attributes. */
807   bool ignore_requested_attributes;
808
809 } SilcClientParams;
810 /***/
811
812
813 /* Initialization functions (client.c) */
814
815 /****f* silcclient/SilcClientAPI/silc_client_alloc
816  *
817  * SYNOPSIS
818  *
819  *    SilcClient silc_client_alloc(SilcClientOperations *ops, 
820  *                                 SilcClientParams *params,
821  *                                 void *application,
822  *                                 const char *silc_version);
823  *
824  * DESCRIPTION
825  *
826  *    Allocates new client object. This has to be done before client may
827  *    work. After calling this one must call silc_client_init to initialize
828  *    the client. The `application' is application specific user data pointer
829  *    and caller must free it. The `silc_version' is the application version
830  *    that will be used to compare against remote host's (usually a server)
831  *    version string.  The `application' context is accessible by the
832  *    application by client->application, client being SilcClient.
833  *
834  ***/
835 SilcClient silc_client_alloc(SilcClientOperations *ops, 
836                              SilcClientParams *params,
837                              void *application,
838                              const char *version_string);
839
840 /****f* silcclient/SilcClientAPI/silc_client_free
841  *
842  * SYNOPSIS
843  *
844  *    void silc_client_free(SilcClient client);
845  *
846  * DESCRIPTION
847  *
848  *    Frees client object and its internals.  The execution of the client
849  *    should be stopped with silc_client_stop function before calling
850  *    this function.
851  *
852  ***/
853 void silc_client_free(SilcClient client);
854
855 /****f* silcclient/SilcClientAPI/silc_client_init
856  *
857  * SYNOPSIS
858  *
859  *    bool silc_client_init(SilcClient client);
860  *
861  * DESCRIPTION
862  *
863  *    Initializes the client. This makes all the necessary steps to make
864  *    the client ready to be run. One must call silc_client_run to run the
865  *    client. Returns FALSE if error occurred, TRUE otherwise.
866  *
867  ***/
868 bool silc_client_init(SilcClient client);
869
870 /****f* silcclient/SilcClientAPI/silc_client_run
871  *
872  * SYNOPSIS
873  *
874  *    void silc_client_run(SilcClient client);
875  *
876  * DESCRIPTION
877  *
878  *    Runs the client. This starts the scheduler from the utility library.
879  *    When this functions returns the execution of the appliation is over.
880  *    The client must be initialized before calling this.
881  *
882  ***/
883 void silc_client_run(SilcClient client);
884
885 /****f* silcclient/SilcClientAPI/silc_client_run_one
886  *
887  * SYNOPSIS
888  *
889  *    void silc_client_run_one(SilcClient client);
890  *
891  * DESCRIPTION
892  *
893  *    Runs the client and returns immeadiately. This function is used when
894  *    the SILC Client object indicated by the `client' is run under some
895  *    other scheduler, or event loop or main loop.  On GUI applications,
896  *    for example this may be desired to used to run the client under the
897  *    GUI application's main loop.  Typically the GUI application would
898  *    register an idle task that calls this function multiple times in
899  *    a second to quickly process the SILC specific data.
900  *
901  ***/
902 void silc_client_run_one(SilcClient client);
903
904 /****f* silcclient/SilcClientAPI/silc_client_stop
905  *
906  * SYNOPSIS
907  *
908  *    void silc_client_stop(SilcClient client);
909  *
910  * DESCRIPTION
911  *
912  *    Stops the client. This is called to stop the client and thus to stop
913  *    the program.  The client context must be freed with the silc_client_free
914  *    function.
915  *
916  ***/
917 void silc_client_stop(SilcClient client);
918
919
920 /* Connecting functions (client.c) */
921
922 /****s* silcclient/SilcClientAPI/SilcClientConnectionParams
923  *
924  * NAME
925  *
926  *    typedef struct { ... } SilcClientConnectionParams;
927  *
928  * DESCRIPTION
929  *
930  *    Client connection parameters.  This can be filled by the application
931  *    and given as argument to silc_client_connect_to_server or to
932  *    silc_client_add_connection.
933  *
934  * SOURCE
935  */
936 typedef struct {
937   /* The SILC session detachment data that was returned by `detach' client
938      operation when the application detached from the network.  Application
939      is responsible of saving the data and giving it as argument here
940      for resuming the session in the SILC network.
941
942      If this is provided here the client library will attempt to resume
943      the session in the network.  After the connection is created
944      successfully, the application is responsible of setting the user
945      interface for user into the same state it was before detaching (showing
946      same channels, channel modes, etc).  It can do this by fetching the
947      information (like joined channels) from the client library. */
948   unsigned char *detach_data;
949   SilcUInt32 detach_data_len;
950
951 } SilcClientConnectionParams;
952 /***/
953
954 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
955  *
956  * SYNOPSIS
957  *
958  *    bool silc_client_connect_to_server(SilcClient client, 
959  *                                      SilcClientConnectionParams *params,
960  *                                      int port, char *host, void *context);
961  *
962  * DESCRIPTION
963  *
964  *    Connects to remote server. This is the main routine used to connect
965  *    to SILC server. Returns -1 on error and the created socket otherwise. 
966  *    The `context' is user context that is saved into the SilcClientConnection
967  *    that is created after the connection is created. Note that application
968  *    may handle the connecting process outside the library. If this is the
969  *    case then this function is not used at all. When the connecting is
970  *    done the `connect' client operation is called, and the `context' is
971  *    accessible with conn->context, conn being SilcClientConnection.
972  *    If the `params' is provided they are used by the routine.
973  *
974  ***/
975 bool silc_client_connect_to_server(SilcClient client, 
976                                    SilcClientConnectionParams *params,
977                                    int port, char *host, void *context);
978
979 /****f* silcclient/SilcClientAPI/silc_client_add_connection
980  *
981  * SYNOPSIS
982  *
983  *
984  *    SilcClientConnection
985  *    silc_client_add_connection(SilcClient client,
986  *                               SilcClientConnectionParams *params,
987  *                               char *hostname, int port, void *context);
988  *
989  * DESCRIPTION
990  *
991  *    Allocates and adds new connection to the client. This adds the allocated
992  *    connection to the connection table and returns a pointer to it. A client
993  *    can have multiple connections to multiple servers. Every connection must
994  *    be added to the client using this function. User data `context' may
995  *    be sent as argument.  If the `params' is provided they are used by 
996  *    the routine.
997  *
998  * NOTES
999  *
1000  *    This function is normally used only if the application performed 
1001  *    the connecting outside the library, and did not called the
1002  *    silc_client_connect_to_server function at all. The library
1003  *    however may use this internally.
1004  *
1005  ***/
1006 SilcClientConnection
1007 silc_client_add_connection(SilcClient client,
1008                            SilcClientConnectionParams *params,
1009                            char *hostname, int port, void *context);
1010
1011 /****f* silcclient/SilcClientAPI/silc_client_del_connection
1012  *
1013  * SYNOPSIS
1014  *
1015  *    void silc_client_del_connection(SilcClient client, 
1016  *                                    SilcClientConnection conn);
1017  *
1018  * DESCRIPTION
1019  *
1020  *    Removes connection from client. Frees all memory. The library
1021  *    call this function automatically for all connection contexts.
1022  *    The application however may free the connection contexts it has
1023  *    allocated.
1024  *
1025  ***/
1026 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
1027
1028 /****f* silcclient/SilcClientAPI/silc_client_add_socket
1029  *
1030  * SYNOPSIS
1031  *
1032  *    void silc_client_add_socket(SilcClient client, 
1033  *                                SilcSocketConnection sock);
1034  *
1035  * DESCRIPTION
1036  *
1037  *    Adds listener socket to the listener sockets table. This function is
1038  *    used to add socket objects that are listeners to the client.  This should
1039  *    not be used to add other connection objects.
1040  *
1041  ***/
1042 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
1043
1044 /****f* silcclient/SilcClientAPI/silc_client_del_socket
1045  *
1046  * SYNOPSIS
1047  *
1048  *    void silc_client_del_socket(SilcClient client, 
1049  *                                SilcSocketConnection sock);
1050  *
1051  * DESCRIPTION
1052  *
1053  *    Deletes listener socket from the listener sockets table.  If the
1054  *    application has added a socket with silc_client_add_socket it must
1055  *    also free it using this function.
1056  *
1057  ***/
1058 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
1059
1060 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
1061  *
1062  * SYNOPSIS
1063  *
1064  *    void silc_client_start_key_exchange(SilcClient client,
1065  *                                        SilcClientConnection conn,
1066  *                                        int fd);
1067  *
1068  * DESCRIPTION
1069  *
1070  *    Start SILC Key Exchange (SKE) protocol to negotiate shared secret
1071  *    key material between client and server.  This function can be called
1072  *    directly if application is performing its own connecting and does not
1073  *    use the connecting provided by this library. This function is normally
1074  *    used only if the application performed the connecting outside the
1075  *    library. The library however may use this internally.  After the
1076  *    key exchange is performed the `connect' client operation is called.
1077  *
1078  ***/
1079 void silc_client_start_key_exchange(SilcClient client,
1080                                     SilcClientConnection conn,
1081                                     int fd);
1082
1083 /****f* silcclient/SilcClientAPI/silc_client_close_connection
1084  *
1085  * SYNOPSIS
1086  *
1087  *    void silc_client_close_connection(SilcClient client,
1088  *                                      SilcClientConnection conn);
1089  *
1090  * DESCRIPTION
1091  *
1092  *    Closes connection to remote end. Free's all allocated data except
1093  *    for some information such as nickname etc. that are valid at all time. 
1094  *
1095  ***/
1096 void silc_client_close_connection(SilcClient client,
1097                                   SilcClientConnection conn);
1098
1099
1100 /* Message sending functions (client_channel.c and client_prvmsg.c) */
1101
1102 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
1103  *
1104  * SYNOPSIS
1105  *
1106  *    void silc_client_send_channel_message(SilcClient client, 
1107  *                                          SilcClientConnection conn,
1108  *                                          SilcChannelEntry channel,
1109  *                                          SilcChannelPrivateKey key,
1110  *                                          SilcMessageFlags flags,
1111  *                                          unsigned char *data, 
1112  *                                          SilcUInt32 data_len, 
1113  *                                          bool_force_send);
1114  *
1115  * DESCRIPTION
1116  *
1117  *    Sends packet to the `channel'. Packet to channel is always encrypted
1118  *    differently from "normal" packets. SILC header of the packet is 
1119  *    encrypted with the next receiver's key and the rest of the packet is
1120  *    encrypted with the channel specific key. Padding and HMAC is computed
1121  *    with the next receiver's key. The `data' is the channel message. If
1122  *    the `force_send' is TRUE then the packet is sent immediately. 
1123  *
1124  *    If `key' is provided then that private key is used to encrypt the
1125  *    channel message.  If it is not provided, private keys has not been
1126  *    set at all, the normal channel key is used automatically.  If private
1127  *    keys are set then the first key (the key that was added first as
1128  *    private key) is used. 
1129  *
1130  *    If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
1131  *    digitally signed with the SILC key pair.
1132  *
1133  ***/
1134 void silc_client_send_channel_message(SilcClient client, 
1135                                       SilcClientConnection conn,
1136                                       SilcChannelEntry channel,
1137                                       SilcChannelPrivateKey key,
1138                                       SilcMessageFlags flags,
1139                                       unsigned char *data, 
1140                                       SilcUInt32 data_len, 
1141                                       bool force_send);
1142
1143 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
1144  *
1145  * SYNOPSIS
1146  *
1147  *    void silc_client_send_private_message(SilcClient client,
1148  *                                          SilcClientConnection conn,
1149  *                                          SilcClientEntry client_entry,
1150  *                                          SilcMessageFlags flags,
1151  *                                          unsigned char *data, 
1152  *                                          SilcUInt32 data_len, 
1153  *                                          bool force_send);
1154  *
1155  * DESCRIPTION
1156  *
1157  *    Sends private message to remote client. If private message key has
1158  *    not been set with this client then the message will be encrypted using
1159  *    normal session keys. Private messages are special packets in SILC
1160  *    network hence we need this own function for them. This is similar
1161  *    to silc_client_packet_send_to_channel except that we send private
1162  *    message. The `data' is the private message. If the `force_send' is
1163  *    TRUE the packet is sent immediately. 
1164  *
1165  *    If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
1166  *    digitally signed with the SILC key pair.
1167  *
1168  ***/
1169 void silc_client_send_private_message(SilcClient client,
1170                                       SilcClientConnection conn,
1171                                       SilcClientEntry client_entry,
1172                                       SilcMessageFlags flags,
1173                                       unsigned char *data, 
1174                                       SilcUInt32 data_len, 
1175                                       bool force_send);
1176
1177
1178 /* Client and Channel entry retrieval (idlist.c) */
1179
1180 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
1181  *
1182  * SYNOPSIS
1183  *
1184  *    typedef void (*SilcGetClientCallback)(SilcClient client,
1185  *                                          SilcClientConnection conn,
1186  *                                          SilcClientEntry *clients,
1187  *                                          SilcUInt32 clients_count,
1188  *                                          void *context);
1189  *
1190  * DESCRIPTION
1191  *
1192  *    Callback function given to the silc_client_get_client function. The
1193  *    found entries are allocated into the `clients' array. The array must
1194  *    not be freed by the receiver, the library will free it later. If the
1195  *    `clients' is NULL, no such clients exist in the SILC Network.
1196  *
1197  ***/
1198 typedef void (*SilcGetClientCallback)(SilcClient client,
1199                                       SilcClientConnection conn,
1200                                       SilcClientEntry *clients,
1201                                       SilcUInt32 clients_count,
1202                                       void *context);
1203
1204 /****f* silcclient/SilcClientAPI/silc_client_get_clients
1205  *
1206  * SYNOPSIS
1207  *
1208  *    void silc_client_get_clients(SilcClient client,
1209  *                                 SilcClientConnection conn,
1210  *                                 const char *nickname,
1211  *                                 const char *server,
1212  *                                 SilcGetClientCallback completion,
1213  *                                 void *context);
1214  *
1215  * DESCRIPTION
1216  *
1217  *    Finds client entry or entries by the `nickname' and `server'. The 
1218  *    completion callback will be called when the client entries has been
1219  *    found.  After the server returns the client information it is cached
1220  *    and can be accesses locally at a later time.
1221  *
1222  * NOTES
1223  *
1224  *    NOTE: This function is always asynchronous and resolves the client
1225  *    information from the server. Thus, if you already know the client
1226  *    information then use the silc_client_get_client_by_id function to
1227  *    get the client entry since this function may be very slow and should
1228  *    be used only to initially get the client entries. 
1229  *
1230  ***/
1231 void silc_client_get_clients(SilcClient client,
1232                              SilcClientConnection conn,
1233                              const char *nickname,
1234                              const char *server,
1235                              SilcGetClientCallback completion,
1236                              void *context);
1237
1238 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
1239  *
1240  * SYNOPSIS
1241  *
1242  *    SilcClientEntry *silc_client_get_clients_local(SilcClient client,
1243  *                                                   SilcClientConnection conn,
1244  *                                                   const char *nickname,
1245  *                                                   const char *format,
1246  *                                                   SilcUInt32 *clients_count);
1247  *
1248  * DESCRIPTION
1249  *
1250  *    Same as silc_client_get_clients function but does not resolve anything
1251  *    from the server. This checks local cache and returns all matching
1252  *    clients from the local cache. If none was found this returns NULL.
1253  *    The `nickname' is the real nickname of the client, and the `format'
1254  *    is the formatted nickname to find exact match from multiple found
1255  *    entries. The format must be same as given in the SilcClientParams
1256  *    structure to the client library. If the `format' is NULL all found
1257  *    clients by `nickname' are returned. The caller must return the
1258  *    returned array.
1259  *
1260  ***/
1261 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
1262                                                SilcClientConnection conn,
1263                                                const char *nickname,
1264                                                const char *format,
1265                                                SilcUInt32 *clients_count);
1266
1267 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
1268  *
1269  * SYNOPSIS
1270  *
1271  *    void silc_client_get_clients_by_list(SilcClient client,
1272  *                                         SilcClientConnection conn,
1273  *                                         SilcUInt32 list_count,
1274  *                                         SilcBuffer client_id_list,
1275  *                                         SilcGetClientCallback completion,
1276  *                                         void *context);
1277  *
1278  * DESCRIPTION
1279  *
1280  *    Gets client entries by the list of client ID's `client_id_list'. This
1281  *    always resolves those client ID's it does not know yet from the server
1282  *    so this function might take a while. The `client_id_list' is a list
1283  *    of ID Payloads added one after other.  JOIN command reply and USERS
1284  *    command reply for example returns this sort of list. The `completion'
1285  *    will be called after the entries are available. When server returns
1286  *    the client information it will be cached and can be accessed locally
1287  *    at a later time.
1288  *
1289  ***/
1290 void silc_client_get_clients_by_list(SilcClient client,
1291                                      SilcClientConnection conn,
1292                                      SilcUInt32 list_count,
1293                                      SilcBuffer client_id_list,
1294                                      SilcGetClientCallback completion,
1295                                      void *context);
1296
1297 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
1298  *
1299  * SYNOPSIS
1300  *
1301  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
1302  *                                                 SilcClientConnection conn,
1303  *                                                 SilcClientID *client_id);
1304  *
1305  * DESCRIPTION
1306  *
1307  *    Find entry for client by the client's ID. Returns the entry or NULL
1308  *    if the entry was not found.  This checks the local cache and does
1309  *    not resolve anything from server.
1310  *
1311  ***/
1312 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
1313                                              SilcClientConnection conn,
1314                                              SilcClientID *client_id);
1315
1316 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
1317  *
1318  * SYNOPSIS
1319  *
1320  *    void 
1321  *    silc_client_get_client_by_id_resolve(SilcClient client,
1322  *                                         SilcClientConnection conn,
1323  *                                         SilcClientID *client_id,
1324  *                                         SilcBuffer attributes,
1325  *                                         SilcGetClientCallback completion,
1326  *                                         void *context);
1327  *
1328  * DESCRIPTION
1329  *
1330  *    Same as silc_client_get_client_by_id but will always resolve the
1331  *    information from the server. Use this only if you know that you
1332  *    do not have the entry and the only thing you know about the client
1333  *    is its ID. When server returns the client information it will be
1334  *    cache and can be accessed locally at a later time.
1335  *
1336  *    If the `attributes' is non-NULL then the buffer includes Requested
1337  *    Attributes which can be used to fetch very detailed information
1338  *    about the user. If it is NULL then only normal WHOIS query is
1339  *    made (for more information about attributes see SilcAttribute).
1340  *    Caller may create the `attributes' with silc_client_attributes_request
1341  *    function.
1342  *
1343  ***/
1344 void silc_client_get_client_by_id_resolve(SilcClient client,
1345                                           SilcClientConnection conn,
1346                                           SilcClientID *client_id,
1347                                           SilcBuffer attributes,
1348                                           SilcGetClientCallback completion,
1349                                           void *context);
1350
1351 /****f* silcclient/SilcClientAPI/silc_client_del_client
1352  *
1353  * SYNOPSIS
1354  *
1355  *    bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
1356  *                                SilcClientEntry client_entry)
1357  *
1358  * DESCRIPTION
1359  *
1360  *    Removes client from local cache by the client entry indicated by
1361  *    the `client_entry'.  Returns TRUE if the deletion were successful.
1362  *
1363  ***/
1364 bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
1365                             SilcClientEntry client_entry);
1366
1367 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
1368  *
1369  * SYNOPSIS
1370  *
1371  *    typedef void (*SilcGetChannelCallback)(SilcClient client,
1372  *                                           SilcClientConnection conn,
1373  *                                           SilcChannelEntry *channels,
1374  *                                           SilcUInt32 channels_count,
1375  *                                           void *context);
1376  *
1377  * DESCRIPTION
1378  *
1379  *    Callback function given to the silc_client_get_channel_* functions.
1380  *    The found entries are allocated into the `channels' array. The array
1381  *    must not be freed by the receiver, the library will free it later.
1382  *    If the `channel' is NULL, no such channel exist in the SILC Network.
1383  *
1384  ***/
1385 typedef void (*SilcGetChannelCallback)(SilcClient client,
1386                                        SilcClientConnection conn,
1387                                        SilcChannelEntry *channels,
1388                                        SilcUInt32 channels_count,
1389                                        void *context);
1390
1391 /****f* silcclient/SilcClientAPI/silc_client_get_channel
1392  *
1393  * SYNOPSIS
1394  *
1395  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
1396  *                                             SilcClientConnection conn,
1397  *                                             char *channel);
1398  *
1399  * DESCRIPTION
1400  *
1401  *    Finds entry for channel by the channel name. Returns the entry or NULL
1402  *    if the entry was not found. It is found only if the client is joined
1403  *    to the channel. 
1404  *
1405  ***/
1406 SilcChannelEntry silc_client_get_channel(SilcClient client,
1407                                          SilcClientConnection conn,
1408                                          char *channel);
1409
1410 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id
1411  *
1412  * SYNOPSIS
1413  *
1414  *    SilcChannelEntry
1415  *    silc_client_get_channel_by_id(SilcClient client,
1416  *                                  SilcClientConnection conn,
1417  *                                  SilcChannelID *channel_id);
1418  *
1419  * DESCRIPTION
1420  *
1421  *    Finds channel entry by the channel name. Returns the entry or NULL
1422  *    if it was not found.
1423  *
1424  ***/
1425 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
1426                                                SilcClientConnection conn,
1427                                                SilcChannelID *channel_id);
1428
1429 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
1430  *
1431  * SYNOPSIS
1432  *
1433  *    void 
1434  *    silc_client_get_channel_by_id_resolve(SilcClient client,
1435  *                                          SilcClientConnection conn,
1436  *                                          SilcChannelID *channel_id,
1437  *                                          SilcGetClientCallback completion,
1438  *                                          void *context);
1439  *
1440  * DESCRIPTION
1441  *
1442  *    Resolves the channel information (its name mainly) from the server
1443  *    by the `channel_id'. Use this only if you know that you do not have
1444  *    the entry cached locally.
1445  *
1446  ***/
1447 void silc_client_get_channel_by_id_resolve(SilcClient client,
1448                                            SilcClientConnection conn,
1449                                            SilcChannelID *channel_id,
1450                                            SilcGetChannelCallback completion,
1451                                            void *context);
1452
1453 /****f* silcclient/SilcClientAPI/silc_client_del_channel
1454  *
1455  * SYNOPSIS
1456  *
1457  *    bool silc_client_del_channel(SilcClient client, 
1458  *                                 SilcClientConnection conn,
1459  *                                 SilcChannelEntry channel)
1460  *
1461  * DESCRIPTION
1462  *
1463  *    Removes channel from local cache by the channel entry indicated by
1464  *    the `channel'.  Returns TRUE if the deletion were successful.
1465  *
1466  ***/
1467 bool silc_client_del_channel(SilcClient client, SilcClientConnection conn,
1468                              SilcChannelEntry channel);
1469
1470 /****f* silcclient/SilcClientAPI/silc_client_get_server
1471  *
1472  * SYNOPSIS
1473  *
1474  *    SilcServerEntry silc_client_get_server(SilcClient client,
1475  *                                           SilcClientConnection conn,
1476  *                                           char *server_name)
1477  *
1478  * DESCRIPTION
1479  *
1480  *    Finds entry for server by the server name. Returns the entry or NULL
1481  *    if the entry was not found.
1482  *
1483  ***/
1484 SilcServerEntry silc_client_get_server(SilcClient client,
1485                                        SilcClientConnection conn,
1486                                        char *server_name);
1487
1488 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
1489  *
1490  * SYNOPSIS
1491  *
1492  *    SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1493  *                                                 SilcClientConnection conn,
1494  *                                                 SilcServerID *server_id);
1495  *
1496  * DESCRIPTION
1497  *
1498  *    Finds entry for server by the server ID. Returns the entry or NULL
1499  *    if the entry was not found.
1500  *
1501  ***/
1502 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1503                                              SilcClientConnection conn,
1504                                              SilcServerID *server_id);
1505
1506 /****f* silcclient/SilcClientAPI/silc_client_del_server
1507  *
1508  * SYNOPSIS
1509  *
1510  *    bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1511  *                                SilcServerEntry server);
1512  *
1513  * DESCRIPTION
1514  *
1515  *    Removes server from local cache by the server entry indicated by
1516  *    the `server'.  Returns TRUE if the deletion were successful.
1517  *
1518  ***/
1519 bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1520                             SilcServerEntry server);
1521
1522 /****f* silcclient/SilcClientAPI/silc_client_on_channel
1523  *
1524  * SYNOPSIS
1525  *
1526  *    SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1527  *                                           SilcClientEntry client_entry);
1528  *
1529  * DESCRIPTION
1530  *
1531  *    Returns the ChannelUser entry if the `client_entry' is joined on the 
1532  *    channel indicated by the `channel'. NULL if client is not joined on
1533  *    the channel. 
1534  *
1535  ***/
1536 SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1537                                        SilcClientEntry client_entry);
1538
1539 /* Command management (command.c) */
1540
1541 /****f* silcclient/SilcClientAPI/silc_client_command_call
1542  *
1543  * SYNOPSIS
1544  *
1545  *    bool silc_client_command_call(SilcClient client,
1546  *                                  SilcClientConnection conn,
1547  *                                  const char *command_line, ...);
1548  *
1549  * DESCRIPTION
1550  *
1551  *    Calls and executes the command indicated by the `command_name'.
1552  *    The `command_line' is a string which includes the command's name and
1553  *    its arguments separated with whitespaces (' ').  If `command_line'
1554  *    is non-NULL then all variable arguments are ignored by default.
1555  *
1556  *    If `command_line' is NULL, then the variable arguments define the
1557  *    command's name and its arguments.  The first variable argument must
1558  *    be the command name.  The variable argument list must be terminated
1559  *    with NULL.
1560  *
1561  *    Returns FALSE if the command is not known and TRUE after command.
1562  *    execution.  The "command" client operation is called when the
1563  *    command is executed to indicate whether the command executed
1564  *    successfully or not.
1565  *
1566  *    The "command_reply" client operation will be called when reply is
1567  *    received from the server to the command.  Application may also use
1568  *    the silc_client_command_pending to attach to the command reply.
1569  *    The command identifier for silc_client_command_pending function after
1570  *    this function call is conn->cmd_ident, which application may use.
1571  *
1572  * EXAMPLE
1573  *
1574  *    silc_client_command_call(client, conn, NULL, "PING", "silc.silcnet.org",
1575  *                             NULL);
1576  *    silc_client_command_call(client, conn, "PING silc.silcnet.org");
1577  *
1578  ***/
1579 bool silc_client_command_call(SilcClient client,
1580                               SilcClientConnection conn,
1581                               const char *command_line, ...);
1582
1583 /****f* silcclient/SilcClientAPI/silc_client_command_send
1584  *
1585  * SYNOPSIS
1586  *
1587  *    void silc_client_command_send(SilcClient client, 
1588  *                                  SilcClientConnection conn,
1589  *                                  SilcCommand command, SilcUInt16 ident,
1590  *                                  SilcUInt32 argc, ...);
1591  *
1592  * DESCRIPTION
1593  *
1594  *    Generic function to send any command. The arguments must be sent already
1595  *    encoded into correct form and in correct order. If application wants
1596  *    to perform the commands by itself, it can do so and send the data
1597  *    directly to the server using this function.  If application is using
1598  *    the silc_client_command_call, this function is usually not used.
1599  *    Note that this overriders the Client Librarys commands and sends
1600  *    the command packet directly to server.
1601  *
1602  *    The variable arguments are a pair of { type, data, data_length },
1603  *    and the `argc' is the number of these pairs.
1604  *
1605  * EXAMPLE
1606  *
1607  *    silc_client_command_send(client, conn, SILC_COMMAND_WHOIS, 0, 1,
1608  *                             1, nickname, strlen(nickname));
1609  *
1610  ***/
1611 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1612                               SilcCommand command, SilcUInt16 ident,
1613                               SilcUInt32 argc, ...);
1614
1615 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1616  *
1617  * SYNOPSIS
1618  *
1619  *    void silc_client_command_pending(SilcClientConnection conn,
1620  *                                     SilcCommand reply_cmd,
1621  *                                     SilcUInt16 ident,
1622  *                                     SilcCommandCb callback,
1623  *                                     void *context);
1624  *
1625  * DESCRIPTION
1626  *
1627  *    This function can be used to add pending command callback to be
1628  *    called when an command reply is received to an earlier sent command.
1629  *    The `reply_cmd' is the command that must be received in order for
1630  *    the pending command callback indicated by `callback' to be called.
1631  *    The `callback' will deliver the `context' and 
1632  *    SilcClientCommandReplyContext which includes the internals of the 
1633  *    command reply.
1634  *
1635  *    The `ident' is a command identifier which was set for the earlier
1636  *    sent command.  The command reply will include the same identifier
1637  *    and pending command callback will be called when the reply is 
1638  *    received with the same command identifier.  It is possible to
1639  *    add multiple pending command callbacks for same command and for
1640  *    same identifier.
1641  *
1642  *    Application may use this function to add its own command reply
1643  *    handlers if it wishes not to use the standard `command_reply'
1644  *    client operation.  However, note that the pending command callback
1645  *    does not deliver parsed command reply, but application must parse
1646  *    it itself.
1647  *
1648  *    Note also that the application is notified about the received command
1649  *    reply through the `command_reply' client operation before calling
1650  *    the `callback` pending command callback.  That is the normal 
1651  *    command reply handling, and is called regardless whether pending
1652  *    command callbacks are used or not.
1653  *
1654  *    Commands that application calls with silc_client_command_call
1655  *    will use a command identifier from conn->cmd_ident variable.  After
1656  *    calling the silc_client_command_call, the conn->cmd_ident includes
1657  *    the command identifier that was used for the command sending.
1658  *
1659  * EXAMPLE
1660  *
1661  *    silc_client_command_call(client, conn, "PING silc.silcnet.org");
1662  *    silc_client_command_pending(conn, SILC_COMMAND_PING, conn->cmd_ident,
1663  *                                my_ping_handler, my_ping_context);
1664  *
1665  ***/
1666 void silc_client_command_pending(SilcClientConnection conn,
1667                                  SilcCommand reply_cmd,
1668                                  SilcUInt16 ident,
1669                                  SilcCommandCb callback,
1670                                  void *context);
1671
1672
1673 /* Private Message key management (client_prvmsg.c) */
1674
1675 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1676  *
1677  * SYNOPSIS
1678  *
1679  *    bool silc_client_add_private_message_key(SilcClient client,
1680  *                                             SilcClientConnection conn,
1681  *                                             SilcClientEntry client_entry,
1682  *                                             const char *cipher,
1683  *                                             const char *hmac,
1684  *                                             unsigned char *key,
1685  *                                             SilcUInt32 key_len,
1686  *                                             bool generate_key,
1687  *                                             bool responder);
1688  *
1689  * DESCRIPTION
1690  *
1691  *    Adds private message key to the client library. The key will be used to
1692  *    encrypt all private message between the client and the remote client
1693  *    indicated by the `client_entry'. If the `key' is NULL and the boolean
1694  *    value `generate_key' is TRUE the library will generate random key.
1695  *    The `key' maybe for example pre-shared-key, passphrase or similar.
1696  *    The `cipher' and `hmac' MAY be provided but SHOULD be NULL to assure
1697  *    that the requirements of the SILC protocol are met. The API, however,
1698  *    allows to allocate any cipher and HMAC.
1699  *
1700  *    If `responder' is TRUE then the sending and receiving keys will be
1701  *    set according the client being the receiver of the private key.  If
1702  *    FALSE the client is being the sender (or negotiator) of the private
1703  *    key.
1704  *
1705  *    It is not necessary to set key for normal private message usage. If the
1706  *    key is not set then the private messages are encrypted using normal
1707  *    session keys. Setting the private key, however, increases the security. 
1708  *
1709  *    Returns FALSE if the key is already set for the `client_entry', TRUE
1710  *    otherwise. 
1711  *
1712  ***/
1713 bool silc_client_add_private_message_key(SilcClient client,
1714                                          SilcClientConnection conn,
1715                                          SilcClientEntry client_entry,
1716                                          const char *cipher,
1717                                          const char *hmac,
1718                                          unsigned char *key,
1719                                          SilcUInt32 key_len,
1720                                          bool generate_key,
1721                                          bool responder);
1722
1723 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1724  *
1725  * SYNOPSIS
1726  *
1727  *    bool
1728  *    silc_client_add_private_message_key_ske(SilcClient client,
1729  *                                            SilcClientConnection conn,
1730  *                                            SilcClientEntry client_entry,
1731  *                                            const char *cipher,
1732  *                                            const char *hmac,
1733  *                                            SilcSKEKeyMaterial *key);
1734  *
1735  * DESCRIPTION
1736  *
1737  *    Same as silc_client_add_private_message_key but takes the key material
1738  *    from the SKE key material structure. This structure is received if
1739  *    the application uses the silc_client_send_key_agreement to negotiate
1740  *    the key material. The `cipher' and `hmac' SHOULD be provided as it is
1741  *    negotiated also in the SKE protocol. 
1742  *
1743  ***/
1744 bool silc_client_add_private_message_key_ske(SilcClient client,
1745                                              SilcClientConnection conn,
1746                                              SilcClientEntry client_entry,
1747                                              const char *cipher,
1748                                              const char *hmac,
1749                                              SilcSKEKeyMaterial *key,
1750                                              bool responder);
1751
1752 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1753  *
1754  * SYNOPSIS
1755  *
1756  *    bool silc_client_del_private_message_key(SilcClient client,
1757  *                                             SilcClientConnection conn,
1758  *                                             SilcClientEntry client_entry);
1759  *
1760  * DESCRIPTION
1761  *
1762  *    Removes the private message from the library. The key won't be used
1763  *    after this to protect the private messages with the remote `client_entry'
1764  *    client. Returns FALSE on error, TRUE otherwise. 
1765  *
1766  ***/
1767 bool silc_client_del_private_message_key(SilcClient client,
1768                                          SilcClientConnection conn,
1769                                          SilcClientEntry client_entry);
1770
1771 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1772  *
1773  * SYNOPSIS
1774  *
1775  *    SilcPrivateMessageKeys
1776  *    silc_client_list_private_message_keys(SilcClient client,
1777  *                                          SilcClientConnection conn,
1778  *                                          SilcUInt32 *key_count);
1779  * 
1780  * DESCRIPTION
1781  *
1782  *    Returns array of set private message keys associated to the connection
1783  *    `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1784  *    count to the `key_count' argument. The array must be freed by the caller
1785  *    by calling the silc_client_free_private_message_keys function. Note: 
1786  *    the keys returned in the array is in raw format. It might not be desired
1787  *    to show the keys as is. The application might choose not to show the keys
1788  *    at all or to show the fingerprints of the keys. 
1789  *
1790  ***/
1791 SilcPrivateMessageKeys
1792 silc_client_list_private_message_keys(SilcClient client,
1793                                       SilcClientConnection conn,
1794                                       SilcUInt32 *key_count);
1795
1796 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1797  *
1798  * SYNOPSIS
1799  *
1800  *    void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1801  *                                               SilcUInt32 key_count);
1802  * 
1803  * DESCRIPTION
1804  *
1805  *    Frees the SilcPrivateMessageKeys array returned by the function
1806  *    silc_client_list_private_message_keys. 
1807  *
1808  ***/
1809 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1810                                            SilcUInt32 key_count);
1811
1812
1813 /* Channel private key management (client_channel.c, 
1814    SilcChannelPrivateKey is defined in idlist.h) */
1815
1816 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1817  *
1818  * SYNOPSIS
1819  *
1820  *    bool silc_client_add_channel_private_key(SilcClient client,
1821  *                                             SilcClientConnection conn,
1822  *                                             SilcChannelEntry channel,
1823  *                                             const char *name,
1824  *                                             char *cipher,
1825  *                                             char *hmac,
1826  *                                             unsigned char *key,
1827  *                                             SilcUInt32 key_len);
1828  * 
1829  * DESCRIPTION
1830  *
1831  *    Adds private key for channel. This may be set only if the channel's mode
1832  *    mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1833  *    mode is not set. When channel has private key then the messages are
1834  *    encrypted using that key. All clients on the channel must also know the
1835  *    key in order to decrypt the messages. However, it is possible to have
1836  *    several private keys per one channel. In this case only some of the
1837  *    clients on the channel may know the one key and only some the other key.
1838  *    The `name' can be application given name for the key.
1839  *
1840  *    The private key for channel is optional. If it is not set then the
1841  *    channel messages are encrypted using the channel key generated by the
1842  *    server. However, setting the private key (or keys) for the channel 
1843  *    significantly adds security. If more than one key is set the library
1844  *    will automatically try all keys at the message decryption phase. Note:
1845  *    setting many keys slows down the decryption phase as all keys has to
1846  *    be tried in order to find the correct decryption key. However, setting
1847  *    a few keys does not have big impact to the decryption performace. 
1848  *
1849  * NOTES
1850  *
1851  *    NOTE: This is entirely local setting. The key set using this function
1852  *    is not sent to the network at any phase.
1853  *
1854  *    NOTE: If the key material was originated by the SKE protocol (using
1855  *    silc_client_send_key_agreement) then the `key' MUST be the
1856  *    key->send_enc_key as this is dictated by the SILC protocol. However,
1857  *    currently it is not expected that the SKE key material would be used
1858  *    as channel private key. However, this API allows it. 
1859  *
1860  ***/
1861 bool silc_client_add_channel_private_key(SilcClient client,
1862                                          SilcClientConnection conn,
1863                                          SilcChannelEntry channel,
1864                                          const char *name,
1865                                          char *cipher,
1866                                          char *hmac,
1867                                          unsigned char *key,
1868                                          SilcUInt32 key_len);
1869
1870 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1871  *
1872  * SYNOPSIS
1873  *
1874  *    bool silc_client_del_channel_private_keys(SilcClient client,
1875  *                                              SilcClientConnection conn,
1876  *                                              SilcChannelEntry channel);
1877  * 
1878  * DESCRIPTION
1879  *
1880  *    Removes all private keys from the `channel'. The old channel key is used
1881  *    after calling this to protect the channel messages. Returns FALSE on
1882  *    on error, TRUE otherwise. 
1883  *
1884  ***/
1885 bool silc_client_del_channel_private_keys(SilcClient client,
1886                                           SilcClientConnection conn,
1887                                           SilcChannelEntry channel);
1888
1889 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1890  *
1891  * SYNOPSIS
1892  *
1893  *    bool silc_client_del_channel_private_key(SilcClient client,
1894  *                                            SilcClientConnection conn,
1895  *                                            SilcChannelEntry channel,
1896  *                                            SilcChannelPrivateKey key);
1897  * 
1898  * DESCRIPTION
1899  *
1900  *    Removes and frees private key `key' from the channel `channel'. 
1901  *    The `key' is retrieved by calling the function 
1902  *    silc_client_list_channel_private_keys. The key is not used after
1903  *    this. If the key was last private key then the old channel key is
1904  *    used hereafter to protect the channel messages. This returns FALSE
1905  *    on error, TRUE otherwise. 
1906  *
1907  ***/
1908 bool silc_client_del_channel_private_key(SilcClient client,
1909                                          SilcClientConnection conn,
1910                                          SilcChannelEntry channel,
1911                                          SilcChannelPrivateKey key);
1912
1913 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1914  *
1915  * SYNOPSIS
1916  *
1917  *    SilcChannelPrivateKey *
1918  *    silc_client_list_channel_private_keys(SilcClient client,
1919  *                                          SilcClientConnection conn,
1920  *                                          SilcChannelEntry channel,
1921  *                                          SilcUInt32 *key_count);
1922  *
1923  * DESCRIPTION
1924  *
1925  *    Returns array (pointers) of private keys associated to the `channel'.
1926  *    The caller must free the array by calling the function
1927  *    silc_client_free_channel_private_keys. The pointers in the array may be
1928  *    used to delete the specific key by giving the pointer as argument to the
1929  *    function silc_client_del_channel_private_key. 
1930  *
1931  ***/
1932 SilcChannelPrivateKey *
1933 silc_client_list_channel_private_keys(SilcClient client,
1934                                       SilcClientConnection conn,
1935                                       SilcChannelEntry channel,
1936                                       SilcUInt32 *key_count);
1937
1938 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1939  *
1940  * SYNOPSIS
1941  *
1942  *    void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1943  *                                               SilcUInt32 key_count);
1944  *
1945  * DESCRIPTION
1946  *
1947  *    Frees the SilcChannelPrivateKey array.
1948  *
1949  ***/
1950 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1951                                            SilcUInt32 key_count);
1952
1953 /****f* silcclient/SilcClientAPI/silc_client_current_channel_private_key
1954  *
1955  * SYNOPSIS
1956  *
1957  *    void silc_client_current_channel_private_key(SilcClient client,
1958  *                                                 SilcClientConnection conn,
1959  *                                                 SilcChannelEntry channel,
1960  *                                                 SilcChannelPrivateKey key);
1961  *
1962  * DESCRIPTION
1963  *
1964  *    Sets the `key' to be used as current channel private key on the
1965  *    `channel'.  Packet sent after calling this function will be secured
1966  *    with `key'.
1967  *
1968  ***/
1969 void silc_client_current_channel_private_key(SilcClient client,
1970                                              SilcClientConnection conn,
1971                                              SilcChannelEntry channel,
1972                                              SilcChannelPrivateKey key);
1973
1974
1975 /* Key Agreement routines (client_keyagr.c) */
1976
1977 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1978  *
1979  * SYNOPSIS
1980  *
1981  *    void silc_client_send_key_agreement(SilcClient client,
1982  *                                        SilcClientConnection conn,
1983  *                                        SilcClientEntry client_entry,
1984  *                                        char *hostname,
1985  *                                        int port,
1986  *                                        SilcUInt32 timeout_secs,
1987  *                                        SilcKeyAgreementCallback completion,
1988  *                                        void *context);
1989  *
1990  * DESCRIPTION
1991  *
1992  *    Sends key agreement request to the remote client indicated by the
1993  *    `client_entry'. If the caller provides the `hostname' and the `port'
1994  *    arguments then the library will bind the client to that hostname and
1995  *    that port for the key agreement protocol. It also sends the `hostname'
1996  *    and the `port' in the key agreement packet to the remote client. This
1997  *    would indicate that the remote client may initiate the key agreement
1998  *    protocol to the `hostname' on the `port'.  If port is zero then the
1999  *    bound port is undefined (the operating system defines it).
2000  *
2001  *    If the `hostname' and `port' is not provided then empty key agreement
2002  *    packet is sent to the remote client. The remote client may reply with
2003  *    the same packet including its hostname and port. If the library receives
2004  *    the reply from the remote client the `key_agreement' client operation
2005  *    callback will be called to verify whether the user wants to perform the
2006  *    key agreement or not. 
2007  *
2008  * NOTES
2009  *
2010  *    NOTE: If the application provided the `hostname' and the `port' and the 
2011  *    remote side initiates the key agreement protocol it is not verified
2012  *    from the user anymore whether the protocol should be executed or not.
2013  *    By setting the `hostname' and `port' the user gives permission to
2014  *    perform the protocol (we are responder in this case).
2015  *
2016  *    NOTE: If the remote side decides not to initiate the key agreement
2017  *    or decides not to reply with the key agreement packet then we cannot
2018  *    perform the key agreement at all. If the key agreement protocol is
2019  *    performed the `completion' callback with the `context' will be called.
2020  *    If remote side decides to ignore the request the `completion' will be
2021  *    called after the specified timeout, `timeout_secs'. 
2022  *
2023  *    NOTE: If the `hostname' and the `port' was not provided the `completion'
2024  *    will not be called at all since this does nothing more than sending
2025  *    a packet to the remote host.
2026  *
2027  *    NOTE: There can be only one active key agreement for one client entry.
2028  *    Before setting new one, the old one must be finished (it is finished
2029  *    after calling the completion callback) or the function 
2030  *    silc_client_abort_key_agreement must be called. 
2031  *
2032  ***/
2033 void silc_client_send_key_agreement(SilcClient client,
2034                                     SilcClientConnection conn,
2035                                     SilcClientEntry client_entry,
2036                                     const char *hostname,
2037                                     const char *bindhost,
2038                                     int port,
2039                                     SilcUInt32 timeout_secs,
2040                                     SilcKeyAgreementCallback completion,
2041                                     void *context);
2042
2043 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
2044  *
2045  * SYNOPSIS
2046  *
2047  *    void 
2048  *    silc_client_perform_key_agreement(SilcClient client,
2049  *                                      SilcClientConnection conn,
2050  *                                      SilcClientEntry client_entry,
2051  *                                      char *hostname,
2052  *                                      int port,
2053  *                                      SilcKeyAgreementCallback completion,
2054  *                                      void *context);
2055  *
2056  * DESCRIPTION
2057  *
2058  *    Performs the actual key agreement protocol. Application may use this
2059  *    to initiate the key agreement protocol. This can be called for example
2060  *    after the application has received the `key_agreement' client operation,
2061  *    and did not return TRUE from it.
2062  *
2063  *    The `hostname' is the remote hostname (or IP address) and the `port'
2064  *    is the remote port. The `completion' callback with the `context' will
2065  *    be called after the key agreement protocol.
2066  *
2067  * NOTES
2068  * 
2069  *    NOTE: If the application returns TRUE in the `key_agreement' client
2070  *    operation the library will automatically start the key agreement. In this
2071  *    case the application must not call this function. However, application
2072  *    may choose to just ignore the `key_agreement' client operation (and
2073  *    merely just print information about it on the screen) and call this
2074  *    function when the user whishes to do so (by, for example, giving some
2075  *    specific command). Thus, the API provides both, automatic and manual
2076  *    initiation of the key agreement. Calling this function is the manual
2077  *    initiation and returning TRUE in the `key_agreement' client operation
2078  *    is the automatic initiation. 
2079  *
2080  ***/
2081 void silc_client_perform_key_agreement(SilcClient client,
2082                                        SilcClientConnection conn,
2083                                        SilcClientEntry client_entry,
2084                                        char *hostname,
2085                                        int port,
2086                                        SilcKeyAgreementCallback completion,
2087                                        void *context);
2088
2089 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
2090  *
2091  * SYNOPSIS
2092  *
2093  *    void
2094  *    silc_client_perform_key_agreement_fd(SilcClient client,
2095  *                                         SilcClientConnection conn,
2096  *                                         SilcClientEntry client_entry,
2097  *                                         int sock,
2098  *                                         char *hostname,
2099  *                                         SilcKeyAgreementCallback completion,
2100  *                                         void *context);
2101  *
2102  * DESCRIPTION
2103  *
2104  *    Same as above but application has created already the connection to 
2105  *    the remote host. The `sock' is the socket to the remote connection. 
2106  *    Application can use this function if it does not want the client library
2107  *    to create the connection. 
2108  *
2109  ***/
2110 void silc_client_perform_key_agreement_fd(SilcClient client,
2111                                           SilcClientConnection conn,
2112                                           SilcClientEntry client_entry,
2113                                           int sock,
2114                                           char *hostname,
2115                                           SilcKeyAgreementCallback completion,
2116                                           void *context);
2117
2118 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
2119  *
2120  * SYNOPSIS
2121  *
2122  *    void silc_client_abort_key_agreement(SilcClient client,
2123  *                                         SilcClientConnection conn,
2124  *                                         SilcClientEntry client_entry);
2125  *
2126  * DESCRIPTION
2127  *
2128  *    This function can be called to unbind the hostname and the port for
2129  *    the key agreement protocol. However, this function has effect only 
2130  *    before the key agreement protocol has been performed. After it has
2131  *    been performed the library will automatically unbind the port. The 
2132  *    `client_entry' is the client to which we sent the key agreement 
2133  *    request.  The key agreement completion callback will be called
2134  *    with SILC_KEY_AGREEMENT_ABORTED status.
2135  *
2136  ***/
2137 void silc_client_abort_key_agreement(SilcClient client,
2138                                      SilcClientConnection conn,
2139                                      SilcClientEntry client_entry);
2140
2141
2142 /* Misc functions */
2143
2144 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
2145  *
2146  * SYNOPSIS
2147  *
2148  *    void silc_client_set_away_message(SilcClient client,
2149  *                                      SilcClientConnection conn,
2150  *                                      char *message);
2151  *
2152  * DESCRIPTION
2153  *
2154  *    Sets away `message'.  The away message may be set when the client's
2155  *    mode is changed to SILC_UMODE_GONE and the client whishes to reply
2156  *    to anyone who sends private message.  The `message' will be sent
2157  *    automatically back to the the client who send private message.  If
2158  *    away message is already set this replaces the old message with the
2159  *    new one.  If `message' is NULL the old away message is removed. 
2160  *    The sender may freely free the memory of the `message'. 
2161  *
2162  ***/
2163 void silc_client_set_away_message(SilcClient client,
2164                                   SilcClientConnection conn,
2165                                   char *message);
2166
2167 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
2168  *
2169  * SYNOPSIS
2170  *
2171  *    typedef void (*SilcConnectionAuthRequest)(SilcClient client,
2172  *                                              SilcClientConnection conn,
2173  *                                              SilcAuthMethod auth_meth,
2174  *                                              void *context);
2175  *
2176  * DESCRIPTION
2177  *
2178  *    Connection authentication method request callback. This is called
2179  *    by the client library after it has received the authentication method
2180  *    that the application requested by calling the function
2181  *    silc_client_request_authentication_method.
2182  *
2183  ***/
2184 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
2185                                           SilcClientConnection conn,
2186                                           SilcAuthMethod auth_meth,
2187                                           void *context);
2188
2189 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
2190  *
2191  * SYNOPSIS
2192  *
2193  *    void 
2194  *    silc_client_request_authentication_method(SilcClient client,
2195  *                                              SilcClientConnection conn,
2196  *                                              SilcConnectionAuthRequest 
2197  *                                                callback,
2198  *                                              void *context);
2199  *
2200  * DESCRIPTION
2201  *
2202  *    This function can be used to request the current authentication method
2203  *    from the server. This may be called when connecting to the server
2204  *    and the client library requests the authentication data from the
2205  *    application. If the application does not know the current authentication
2206  *    method it can request it from the server using this function.
2207  *    The `callback' with `context' will be called after the server has
2208  *    replied back with the current authentication method.
2209  *
2210  ***/
2211 void 
2212 silc_client_request_authentication_method(SilcClient client,
2213                                           SilcClientConnection conn,
2214                                           SilcConnectionAuthRequest callback,
2215                                           void *context);
2216
2217 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
2218  *
2219  * NAME
2220  *
2221  *    typedef enum { ... } SilcClientMonitorStatus;
2222  *
2223  * DESCRIPTION
2224  *
2225  *    File transmission session status types.  These will indicate
2226  *    the status of the file transmission session.
2227  *
2228  * SOURCE
2229  */
2230 typedef enum {
2231   SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT,    /* In key agreemenet phase */
2232   SILC_CLIENT_FILE_MONITOR_SEND,             /* Sending file */
2233   SILC_CLIENT_FILE_MONITOR_RECEIVE,          /* Receiving file */
2234   SILC_CLIENT_FILE_MONITOR_GET,
2235   SILC_CLIENT_FILE_MONITOR_PUT,
2236   SILC_CLIENT_FILE_MONITOR_CLOSED,           /* Session closed */
2237   SILC_CLIENT_FILE_MONITOR_ERROR,            /* Error during session */
2238 } SilcClientMonitorStatus;
2239 /***/
2240
2241 /****d* silcclient/SilcClientAPI/SilcClientFileError
2242  *
2243  * NAME
2244  *
2245  *    typedef enum { ... } SilcClientFileError;
2246  *
2247  * DESCRIPTION
2248  *
2249  *    File transmission error types.  These types are returned by
2250  *    some of the file transmission functions, and by the monitor
2251  *    callback to indicate error.
2252  *
2253  * SOURCE
2254  */
2255 typedef enum {
2256   SILC_CLIENT_FILE_OK,
2257   SILC_CLIENT_FILE_ERROR,
2258   SILC_CLIENT_FILE_UNKNOWN_SESSION,
2259   SILC_CLIENT_FILE_ALREADY_STARTED,
2260   SILC_CLIENT_FILE_NO_SUCH_FILE,
2261   SILC_CLIENT_FILE_PERMISSION_DENIED,
2262   SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED,
2263 } SilcClientFileError;
2264 /***/
2265
2266 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
2267  *
2268  * SYNOPSIS
2269  *
2270  *    typedef void (*SilcClientFileMonitor)(SilcClient client,
2271  *                                          SilcClientConnection conn,
2272  *                                          SilcClientMonitorStatus status,
2273  *                                          SilcClientFileError error,
2274  *                                          SilcUInt64 offset,
2275  *                                          SilcUInt64 filesize,
2276  *                                          SilcClientEntry client_entry,
2277  *                                          SilcUInt32 session_id,
2278  *                                          const char *filepath,
2279  *                                          void *context);
2280  *
2281  * DESCRIPTION
2282  *
2283  *    Monitor callback that is called during the file transmission to
2284  *    monitor the transmission process.  The `status' indicates the current
2285  *    monitoring process.  The `error' will indicate the error type
2286  *    if `status' is SILC_CLIENT_FILE_MONITOR_ERROR.  The `offset' is the
2287  *    currently transmitted amount of total `filesize'.  The `client_entry'
2288  *    indicates the remote client, and the transmission session ID is the 
2289  *    `session_id'.  The filename being transmitted is indicated by the 
2290  *    `filepath'.
2291  *
2292  ***/
2293 typedef void (*SilcClientFileMonitor)(SilcClient client,
2294                                       SilcClientConnection conn,
2295                                       SilcClientMonitorStatus status,
2296                                       SilcClientFileError error,
2297                                       SilcUInt64 offset,
2298                                       SilcUInt64 filesize,
2299                                       SilcClientEntry client_entry,
2300                                       SilcUInt32 session_id,
2301                                       const char *filepath,
2302                                       void *context);
2303
2304 /****f* silcclient/SilcClientAPI/silc_client_file_send
2305  *
2306  * SYNOPSIS
2307  *
2308  *    SilcClientFileError 
2309  *    silc_client_file_send(SilcClient client,
2310  *                          SilcClientConnection conn,
2311  *                          SilcClientFileMonitor monitor,
2312  *                          void *monitor_context,
2313  *                          const char *local_ip,
2314  *                          SilcUInt32 local_port,
2315  *                          bool do_not_bind,
2316  *                          SilcClientEntry client_entry,
2317  *                          const char *filepath);
2318  *                          SilcUInt32 *session_id);
2319  *
2320  * DESCRIPTION
2321  *
2322  *    Sends a file indicated by the `filepath' to the remote client 
2323  *    indicated by the `client_entry'.  This will negotiate a secret key
2324  *    with the remote client before actually starting the transmission of
2325  *    the file.  The `monitor' callback will be called to monitor the
2326  *    transmission of the file.
2327  *
2328  *    This returns a file session ID for the file transmission to the
2329  *    `session_id' pointer.  It can be used to close the session (and
2330  *    abort the file transmission) by calling the silc_client_file_close
2331  *    function.  The session ID is also returned in the `monitor' callback. 
2332  *
2333  *    If the `local_ip' is provided then this will try to bind the 
2334  *    listener for key exchange protocol to that IP.  If `local_port' is
2335  *    non-zero that port is used.  If `local_ip' is NULL then this will
2336  *    automatically attempt to bind it to local IP address of the machine.
2337  *    If `do_not_bind' is TRUE then the `local_ip' and `local_port' are
2338  *    ignored and it is expected that the receiver will provide the
2339  *    point of contact.  This is usefull if the sender is behind NAT.
2340  *
2341  *    If error will occur during the file transfer process the error
2342  *    status will be returned in the monitor callback.  In this case
2343  *    the application must call silc_client_file_close to close the
2344  *    session.
2345  *
2346  ***/
2347 SilcClientFileError 
2348 silc_client_file_send(SilcClient client,
2349                       SilcClientConnection conn,
2350                       SilcClientFileMonitor monitor,
2351                       void *monitor_context,
2352                       const char *local_ip,
2353                       SilcUInt32 local_port,
2354                       bool do_not_bind,
2355                       SilcClientEntry client_entry,
2356                       const char *filepath,
2357                       SilcUInt32 *session_id);
2358
2359 /****f* silcclient/SilcClientAPI/silc_client_file_receive
2360  *
2361  * SYNOPSIS
2362  *
2363  *    SilcClientFileError 
2364  *    silc_client_file_receive(SilcClient client,
2365  *                             SilcClientConnection conn,
2366  *                             SilcClientFileMonitor monitor,
2367  *                             void *monitor_context,
2368  *                             const char *path,
2369  *                             SilcUInt32 session_id);
2370  *
2371  * DESCRIPTION
2372  *
2373  *    Receives a file from a client indicated by the `client_entry'.  The
2374  *    `session_id' indicates the file transmission session and it has been
2375  *    received in the `ftp' client operation function.  This will actually
2376  *    perform the key agreement protocol with the remote client before
2377  *    actually starting the file transmission.  The `monitor' callback
2378  *    will be called to monitor the transmission.  If `path' is non NULL
2379  *    the file will be saved into that directory.  If NULL the file is
2380  *    saved in the current working directory.
2381  *
2382  *    If error will occur during the file transfer process the error
2383  *    status will be returned in the monitor callback.  In this case
2384  *    the application must call silc_client_file_close to close the
2385  *    session.
2386  *
2387  ***/
2388 SilcClientFileError 
2389 silc_client_file_receive(SilcClient client,
2390                          SilcClientConnection conn,
2391                          SilcClientFileMonitor monitor,
2392                          void *monitor_context,
2393                          const char *path,
2394                          SilcUInt32 session_id);
2395
2396 /****f* silcclient/SilcClientAPI/silc_client_file_close
2397  *
2398  * SYNOPSIS
2399  *
2400  *    SilcClientFileError silc_client_file_close(SilcClient client,
2401  *                                               SilcClientConnection conn,
2402  *                                               SilcUInt32 session_id);
2403  *
2404  * DESCRIPTION
2405  *
2406  *    Closes file transmission session indicated by the `session_id'.
2407  *    If file transmission is being conducted it will be aborted
2408  *    automatically. This function is also used to close the session
2409  *    after successful file transmission. This function can be used
2410  *    also to reject incoming file transmission request.
2411  *
2412  ***/
2413 SilcClientFileError silc_client_file_close(SilcClient client,
2414                                            SilcClientConnection conn,
2415                                            SilcUInt32 session_id);
2416
2417 /****f* silcclient/SilcClientAPI/silc_client_attribute_add
2418  *
2419  * SYNOPSIS
2420  *
2421  *    SilcAttributePayload
2422  *    silc_client_attribute_add(SilcClient client,
2423  *                              SilcClientConnection conn,
2424  *                              SilcAttribute attribute,
2425  *                              void *object,
2426  *                              SilcUInt32 object_size);
2427  *
2428  * DESCRIPTION
2429  *
2430  *    Add new Requsted Attribute for WHOIS command to the client library.
2431  *    The `attribute' object indicated by `object' is added and allocated
2432  *    SilcAttributePayload is returned.  The `object' must be of correct
2433  *    type and of correct size.  See the SilcAttribute for object types
2434  *    for different attributes.  You may also get all added attributes
2435  *    from the client with silc_client_attributes_get function.
2436  *
2437  *    Requested Attributes are different personal information about the
2438  *    user, status information and other information which other users
2439  *    may query with WHOIS command.  Application may set these so that
2440  *    if someone sends WHOIS query these attributes will be replied back
2441  *    to the sender.  The library always puts the public key to the
2442  *    Requested Attributes, but if application wishes to add additional
2443  *    public keys (or certificates) it can be done with this interface.
2444  *    Library also always computes digital signature of the attributes
2445  *    automatically, so application does not need to do that.
2446  *
2447  ***/
2448 SilcAttributePayload silc_client_attribute_add(SilcClient client,
2449                                                SilcClientConnection conn,
2450                                                SilcAttribute attribute,
2451                                                void *object,
2452                                                SilcUInt32 object_size);
2453
2454 /****f* silcclient/SilcClientAPI/silc_client_attribute_del
2455  *
2456  * SYNOPSIS
2457  *
2458  *    bool silc_client_attribute_del(SilcClient client,
2459  *                                   SilcClientConnection conn,
2460  *                                   SilcAttribute attribute,
2461  *                                   SilcAttributePayload attr);
2462  *
2463  * DESCRIPTION
2464  *
2465  *    Delete a Requested Attribute from the client.  If the `attribute'
2466  *    is non-zero then all attributes of that type are deleted and the
2467  *    `attr' is ignored.  If `attr' is non-NULL then that specific
2468  *    attribute is deleted and `attribute' is ignored.
2469  *    
2470  *    You may get all added attributes with the function
2471  *    silc_client_attributes_get and to get the SilcAttributePayload.
2472  *    This function Returns TRUE if the attribute was found and deleted.
2473  *
2474  ***/
2475 bool silc_client_attribute_del(SilcClient client,
2476                                SilcClientConnection conn,
2477                                SilcAttribute attribute,
2478                                SilcAttributePayload attr);
2479
2480 /****f* silcclient/SilcClientAPI/silc_client_attributes_get
2481  *
2482  * SYNOPSIS
2483  *
2484  *    const SilcHashTable
2485  *    silc_client_attributes_get(SilcClient client,
2486  *                               SilcClientConnection conn);
2487  *
2488  * DESCRIPTION
2489  *
2490  *    Returns pointer to the SilcHashTable which includes all the added
2491  *    Requested Attributes.  The caller must not free the hash table.
2492  *    The caller may use SilcHashTableList and silc_hash_table_list to
2493  *    traverse the table.  Each entry in the hash table is one added
2494  *    SilcAttributePayload.  It is possible to delete a attribute
2495  *    payload while traversing the table.
2496  *
2497  ***/
2498 const SilcHashTable silc_client_attributes_get(SilcClient client,
2499                                                SilcClientConnection conn);
2500
2501 /****f* silcclient/SilcClientAPI/silc_client_attributes_request
2502  *
2503  * SYNOPSIS
2504  *
2505  *    SilcBuffer silc_client_attributes_request(SilcAttribute attribute, ...);
2506  *
2507  * DESCRIPTION
2508  *
2509  *    Constructs a Requested Attributes buffer. If the `attribute' is zero (0)
2510  *    then all attributes are requested.  Alternatively, `attribute' and
2511  *    all variable arguments can each be requested attribute.  In this case
2512  *    the last must be set to zero (0) to complete the variable list of
2513  *    requested attributes.  See SilcAttribute for all attributes.
2514  *    You can give the returned buffer as argument to for example
2515  *    silc_client_get_client_by_id_resolve function.
2516  *
2517  ***/
2518 SilcBuffer silc_client_attributes_request(SilcAttribute attribute, ...);
2519
2520 /* Low level packet sending functions */
2521
2522 /****f* silcclient/SilcClientAPI/silc_client_send_packet
2523  *
2524  * SYNOPSIS
2525  *
2526  *     bool silc_client_send_packet(SilcClient client, 
2527  *                                  SilcClientConnection conn,
2528  *                                  SilcPacketType type, 
2529  *                                  const unsigned char *data, 
2530  *                                  SilcUInt32 data_len);
2531  *
2532  * DESCRIPTION
2533  *
2534  *    This routine can be used by application to send packets directly
2535  *    to a connection indicated by `conn'.  Usually application does not
2536  *    need this routine since the Client Library handles the packet
2537  *    sending.  The `type' indicates the packet type.  If `data' is
2538  *    NULL then empty packet is sent.  This returns FALSE if packet cannot 
2539  *    be sent.
2540  *
2541  ***/
2542 bool silc_client_send_packet(SilcClient client, 
2543                              SilcClientConnection conn,
2544                              SilcPacketType type, 
2545                              const unsigned char *data, 
2546                              SilcUInt32 data_len);
2547
2548 #include "command.h"
2549 #include "command_reply.h"
2550 #include "idlist.h"
2551 #include "protocol.h"
2552
2553 #ifdef __cplusplus
2554 }
2555 #endif
2556
2557 #endif /* SILCCLIENT_H */