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