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