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