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