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