updates.
[silc.git] / lib / silcclient / silcapi.h
1 /****h* silcclient/silcapi.h
2  *
3  * NAME
4  *
5  * silcapi.h
6  *
7  * COPYRIGHT
8  *
9  * Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
10  *
11  * Copyright (C) 2000 - 2001 Pekka Riikonen
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * DESCRIPTION
24  *
25  * This file defines the SILC Client Library API for the application.  The
26  * client operations are defined first.  These are callback functions that
27  * the application MUST implement since the library may call the functions
28  * at any time.  At the end of file is the API for the application that
29  * it can use from the library.  This is the only file that the application
30  * may include from the SIlC Client Library.
31  *
32  * o SILC Client Operations
33  *
34  *   These functions must be implemented by the application calling the SILC
35  *   client library. The client library can call these functions at any time.
36  *
37  *   To use this structure: define a static SilcClientOperations variable,
38  *   fill it and pass its pointer to silc_client_alloc function.
39  *
40  * o SILC Client Library API
41  *
42  *   This is the API that is published by the SILC Client Library for the
43  *   applications.  These functions are implemented in the SILC Client Library.
44  *   Application may freely call these functions from the library.
45  *
46  * Please, refer to the README file in this directory for the directions
47  * of how to use the SILC Client Library.
48  *
49  ***/
50
51 #ifndef SILCAPI_H
52 #define SILCAPI_H
53
54 #include "clientlibincludes.h"
55
56 /* General definitions */
57
58 /****d* silcclient/SilcClientAPI/SilcKeyAgreementStatus
59  *
60  * NAME
61  *
62  *    typedef enum { ... } SilcKeyAgreementStatus;
63  *
64  * DESCRIPTION
65  *
66  *    Key agreement status types indicating the status of the key
67  *    agreement protocol.  These types are returned to the application 
68  *    in the SilcKeyAgreementCallback callback function.
69  *
70  * SOURCE
71  */
72 typedef enum {
73   SILC_KEY_AGREEMENT_OK,               /* Everything is Ok */
74   SILC_KEY_AGREEMENT_ERROR,            /* Unknown error occurred */
75   SILC_KEY_AGREEMENT_FAILURE,          /* The protocol failed */
76   SILC_KEY_AGREEMENT_TIMEOUT,          /* The protocol timeout */
77 } SilcKeyAgreementStatus;
78 /***/
79
80 /****f* silcclient/SilcClientAPI/SilcKeyAgreementCallback
81  *
82  * SYNOPSIS
83  *
84  *    typedef void (*SilcKeyAgreementCallback)(SilcClient client,
85  *                                             SilcClientConnection conn,
86  *                                             SilcClientEntry client_entry,
87  *                                             SilcKeyAgreementStatus status,
88  *                                             SilcSKEKeyMaterial *key,
89  *                                             void *context);
90  *
91  * DESCRIPTION
92  *
93  *    Key agreement callback that is called after the key agreement protocol
94  *    has been performed. This is called also if error occurred during the
95  *    key agreement protocol. The `key' is the allocated key material and
96  *    the caller is responsible of freeing it. The `key' is NULL if error
97  *    has occurred. The application can freely use the `key' to whatever
98  *    purpose it needs. See lib/silcske/silcske.h for the definition of
99  *    the SilcSKEKeyMaterial structure.
100  *
101  ***/
102 typedef void (*SilcKeyAgreementCallback)(SilcClient client,
103                                          SilcClientConnection conn,
104                                          SilcClientEntry client_entry,
105                                          SilcKeyAgreementStatus status,
106                                          SilcSKEKeyMaterial *key,
107                                          void *context);
108
109 /****s* silcclient/SilcClientAPI/SilcPrivateMessageKeys
110  *
111  * NAME
112  *
113  *    typedef struct { ... } SilcPrivateMessageKeys;
114  *
115  * DESCRIPTION
116  *
117  *    Structure to hold the list of private message keys. The array of this
118  *    structure is returned by the silc_client_list_private_message_keys
119  *    function.
120  *
121  * SOURCE
122  */
123 typedef struct {
124   SilcClientEntry client_entry;       /* The remote client entry */
125   char *cipher;                       /* The cipher name */
126   unsigned char *key;                 /* The original key, If the appliation
127                                          provided it. This is NULL if the
128                                          library generated the key or if
129                                          the SKE key material was used. */
130   uint32 key_len;                     /* The key length */
131 } *SilcPrivateMessageKeys;
132 /***/
133
134
135 /****f* silcclient/SilcClientAPI/SilcAskPassphrase
136  *
137  * SYNOPSIS
138  *
139  *    typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
140  *                                      uint32 passphrase_len,
141  *                                      void *context);
142  *
143  * DESCRIPTION
144  *
145  *    Ask passphrase callback. This is called by the application when the
146  *    library calls `ask_passphrase' client operation.  The callback delivers
147  *    the passphrase to the library.
148  *
149  ***/
150 typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
151                                   uint32 passphrase_len,
152                                   void *context);
153
154 /****f* silcclient/SilcClientAPI/SilcVerifyPublicKey
155  *
156  * SYNOPSIS
157  *
158  *    typedef void (*SilcVerifyPublicKey)(bool success, void *context);
159  *
160  * DESCRIPTION
161  *
162  *    Public key (or certificate) verification callback. This is called
163  *    by the application to indicate that the public key verification was
164  *    either success or failure.
165  *
166  ***/
167 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
168
169 /****s* silcclient/SilcClientAPI/SilcClientOperations
170  *
171  * NAME
172  *
173  *    typedef struct { ... } SilcClientOperations;
174  *
175  * DESCRIPTION
176  *
177  *    SILC Client Operations. These must be implemented by the application.
178  *    The Client library may call any of these routines at any time.  The
179  *    routines are used to deliver certain information to the application
180  *    or from the application to the client library.
181  *
182  * SOURCE
183  */
184 typedef struct {
185   /* Message sent to the application by library. `conn' associates the
186      message to a specific connection.  `conn', however, may be NULL. */
187   void (*say)(SilcClient client, SilcClientConnection conn, char *msg, ...);
188
189   /* Message for a channel. The `sender' is the sender of the message 
190      The `channel' is the channel. */
191   void (*channel_message)(SilcClient client, SilcClientConnection conn, 
192                           SilcClientEntry sender, SilcChannelEntry channel, 
193                           SilcMessageFlags flags, char *msg);
194
195   /* Private message to the client. The `sender' is the sender of the
196      message. */
197   void (*private_message)(SilcClient client, SilcClientConnection conn,
198                           SilcClientEntry sender, SilcMessageFlags flags,
199                           char *msg);
200
201   /* Notify message to the client. The notify arguments are sent in the
202      same order as servers sends them. The arguments are same as received
203      from the server except for ID's.  If ID is received application receives
204      the corresponding entry to the ID. For example, if Client ID is received
205      application receives SilcClientEntry.  Also, if the notify type is
206      for channel the channel entry is sent to application (even if server
207      does not send it because client library gets the channel entry from
208      the Channel ID in the packet's header). */
209   void (*notify)(SilcClient client, SilcClientConnection conn, 
210                  SilcNotifyType type, ...);
211
212   /* Command handler. This function is called always in the command function.
213      If error occurs it will be called as well. `conn' is the associated
214      client connection. `cmd_context' is the command context that was
215      originally sent to the command. `success' is FALSE if error occurred
216      during command. `command' is the command being processed. It must be
217      noted that this is not reply from server. This is merely called just
218      after application has called the command. Just to tell application
219      that the command really was processed. */
220   void (*command)(SilcClient client, SilcClientConnection conn, 
221                   SilcClientCommandContext cmd_context, int success,
222                   SilcCommand command);
223
224   /* Command reply handler. This function is called always in the command reply
225      function. If error occurs it will be called as well. Normal scenario
226      is that it will be called after the received command data has been parsed
227      and processed. The function is used to pass the received command data to
228      the application. 
229      
230      `conn' is the associated client connection. `cmd_payload' is the command
231      payload data received from server and it can be ignored. It is provided
232      if the application would like to re-parse the received command data,
233      however, it must be noted that the data is parsed already by the library
234      thus the payload can be ignored. `success' is FALSE if error occurred.
235      In this case arguments are not sent to the application. The `status' is
236      the command reply status server returned. The `command' is the command
237      reply being processed. The function has variable argument list and each
238      command defines the number and type of arguments it passes to the
239      application (on error they are not sent). */
240   void (*command_reply)(SilcClient client, SilcClientConnection conn,
241                         SilcCommandPayload cmd_payload, int success,
242                         SilcCommand command, SilcCommandStatus status, ...);
243
244   /* Called to indicate that connection was either successfully established
245      or connecting failed.  This is also the first time application receives
246      the SilcClientConnection objecet which it should save somewhere. */
247   void (*connect)(SilcClient client, SilcClientConnection conn, int success);
248
249   /* Called to indicate that connection was disconnected to the server. */
250   void (*disconnect)(SilcClient client, SilcClientConnection conn);
251
252   /* Find authentication method and authentication data by hostname and
253      port. The hostname may be IP address as well. The found authentication
254      method and authentication data is returned to `auth_meth', `auth_data'
255      and `auth_data_len'. The function returns TRUE if authentication method
256      is found and FALSE if not. `conn' may be NULL. */
257   int (*get_auth_method)(SilcClient client, SilcClientConnection conn,
258                          char *hostname, uint16 port,
259                          SilcProtocolAuthMeth *auth_meth,
260                          unsigned char **auth_data,
261                          uint32 *auth_data_len);
262
263   /* Verifies received public key. The `conn_type' indicates which entity
264      (server, client etc.) has sent the public key. If user decides to trust
265      the key may be saved as trusted public key for later use. The 
266      `completion' must be called after the public key has been verified. */
267   void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
268                             SilcSocketType conn_type, unsigned char *pk, 
269                             uint32 pk_len, SilcSKEPKType pk_type,
270                             SilcVerifyPublicKey completion, void *context);
271
272   /* Ask (interact, that is) a passphrase from user. The passphrase is
273      returned to the library by calling the `completion' callback with
274      the `context'. */
275   void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
276                          SilcAskPassphrase completion, void *context);
277
278   /* Notifies application that failure packet was received.  This is called
279      if there is some protocol active in the client.  The `protocol' is the
280      protocol context.  The `failure' is opaque pointer to the failure
281      indication.  Note, that the `failure' is protocol dependant and
282      application must explicitly cast it to correct type.  Usually `failure'
283      is 32 bit failure type (see protocol specs for all protocol failure
284      types). */
285   void (*failure)(SilcClient client, SilcClientConnection conn, 
286                   SilcProtocol protocol, void *failure);
287
288   /* Asks whether the user would like to perform the key agreement protocol.
289      This is called after we have received an key agreement packet or an
290      reply to our key agreement packet. This returns TRUE if the user wants
291      the library to perform the key agreement protocol and FALSE if it is not
292      desired (application may start it later by calling the function
293      silc_client_perform_key_agreement). If TRUE is returned also the
294      `completion' and `context' arguments must be set by the application. */
295   int (*key_agreement)(SilcClient client, SilcClientConnection conn,
296                        SilcClientEntry client_entry, char *hostname,
297                        int port,
298                        SilcKeyAgreementCallback *completion,
299                        void **context);
300 } SilcClientOperations;
301 /***/
302
303 /* Initialization functions (client.c) */
304
305 /****f* silcclient/SilcClientAPI/silc_client_alloc
306  *
307  * SYNOPSIS
308  *
309  *    SilcClient silc_client_alloc(SilcClientOperations *ops, 
310  *                                 void *application);
311  *
312  * DESCRIPTION
313  *
314  *    Allocates new client object. This has to be done before client may
315  *    work. After calling this one must call silc_client_init to initialize
316  *    the client. The `application' is application specific user data pointer
317  *    and caller must free it. The `silc_version' is the application version
318  *    that will be used to compare against remote host's (usually a server)
319  *    version string.
320  *
321  ***/
322 SilcClient silc_client_alloc(SilcClientOperations *ops, void *application,
323                              const char *silc_version);
324
325 /****f* silcclient/SilcClientAPI/silc_client_free
326  *
327  * SYNOPSIS
328  *
329  *    void silc_client_free(SilcClient client);
330  *
331  * DESCRIPTION
332  *
333  *    Frees client object and its internals.  The execution of the client
334  *    should be stopped with silc_client_stop function before calling
335  *    this function.
336  *
337  ***/
338 void silc_client_free(SilcClient client);
339
340 /****f* silcclient/SilcClientAPI/silc_client_init
341  *
342  * SYNOPSIS
343  *
344  *    int silc_client_init(SilcClient client);
345  *
346  * DESCRIPTION
347  *
348  *    Initializes the client. This makes all the necessary steps to make
349  *    the client ready to be run. One must call silc_client_run to run the
350  *    client. Returns FALSE if error occurred, TRUE otherwise.
351  *
352  ***/
353 int silc_client_init(SilcClient client);
354
355 /****f* silcclient/SilcClientAPI/silc_client_run
356  *
357  * SYNOPSIS
358  *
359  *    void silc_client_run(SilcClient client);
360  *
361  * DESCRIPTION
362  *
363  *    Runs the client. This starts the scheduler from the utility library.
364  *    When this functions returns the execution of the appliation is over.
365  *
366  ***/
367 void silc_client_run(SilcClient client);
368
369 /****f* silcclient/SilcClientAPI/silc_client_stop
370  *
371  * SYNOPSIS
372  *
373  *    void silc_client_stop(SilcClient client);
374  *
375  * DESCRIPTION
376  *
377  *    Stops the client. This is called to stop the client and thus to stop
378  *    the program.  The client context must be freed with the silc_client_free
379  *    function.
380  *
381  ***/
382 void silc_client_stop(SilcClient client);
383
384
385 /* Connecting functions (client.c) */
386
387 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
388  *
389  * SYNOPSIS
390  *
391  *    int silc_client_connect_to_server(SilcClient client, int port,
392  *                                      char *host, void *context);
393  *
394  * DESCRIPTION
395  *
396  *    Connects to remote server. This is the main routine used to connect
397  *    to SILC server. Returns -1 on error and the created socket otherwise. 
398  *    The `context' is user context that is saved into the SilcClientConnection
399  *    that is created after the connection is created. Note that application
400  *    may handle the connecting process outside the library. If this is the
401  *    case then this function is not used at all. When the connecting is
402  *    done the `connect' client operation is called.
403  *
404  ***/
405 int silc_client_connect_to_server(SilcClient client, int port,
406                                   char *host, void *context);
407
408 /****f* silcclient/SilcClientAPI/silc_client_add_connection
409  *
410  * SYNOPSIS
411  *
412  *    SilcClientConnection silc_client_add_connection(SilcClient client,
413  *                                                    char *hostname,
414  *                                                    int port,
415  *                                                    void *context);
416  *
417  * DESCRIPTION
418  *
419  *    Allocates and adds new connection to the client. This adds the allocated
420  *    connection to the connection table and returns a pointer to it. A client
421  *    can have multiple connections to multiple servers. Every connection must
422  *    be added to the client using this function. User data `context' may
423  *    be sent as argument. This function is normally used only if the 
424  *    application performed the connecting outside the library. The library
425  *    however may use this internally.
426  *
427  ***/
428 SilcClientConnection silc_client_add_connection(SilcClient client,
429                                                 char *hostname,
430                                                 int port,
431                                                 void *context);
432
433 /****f* silcclient/SilcClientAPI/silc_client_del_connection
434  *
435  * SYNOPSIS
436  *
437  *    void silc_client_del_connection(SilcClient client, 
438  *                                    SilcClientConnection conn);
439  *
440  * DESCRIPTION
441  *
442  *    Removes connection from client. Frees all memory. The library
443  *    call this function automatically for all connection contexts.
444  *    The application however may free the connection contexts it has
445  *    allocated.
446  *
447  ***/
448 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
449
450 /****f* silcclient/SilcClientAPI/silc_client_add_socket
451  *
452  * SYNOPSIS
453  *
454  *    void silc_client_add_socket(SilcClient client, 
455  *                                SilcSocketConnection sock);
456  *
457  * DESCRIPTION
458  *
459  *    Adds listener socket to the listener sockets table. This function is
460  *    used to add socket objects that are listeners to the client.  This should
461  *    not be used to add other connection objects.
462  *
463  ***/
464 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
465
466 /****f* silcclient/SilcClientAPI/silc_client_del_socket
467  *
468  * SYNOPSIS
469  *
470  *    void silc_client_del_socket(SilcClient client, 
471  *                                SilcSocketConnection sock);
472  *
473  * DESCRIPTION
474  *
475  *    Deletes listener socket from the listener sockets table.  If the
476  *    application has added a socket with silc_client_add_socket it must
477  *    also free it using this function.
478  *
479  ***/
480 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
481
482 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
483  *
484  * SYNOPSIS
485  *
486  *    int silc_client_start_key_exchange(SilcClient client,
487  *                                       SilcClientConnection conn,
488  *                                       int fd);
489  *
490  * DESCRIPTION
491  *
492  *    Start SILC Key Exchange (SKE) protocol to negotiate shared secret
493  *    key material between client and server.  This function can be called
494  *    directly if application is performing its own connecting and does not
495  *    use the connecting provided by this library. This function is normally
496  *    used only if the application performed the connecting outside the
497  *    library. The library however may use this internally.
498  *
499  ***/
500 int silc_client_start_key_exchange(SilcClient client,
501                                    SilcClientConnection conn,
502                                    int fd);
503
504 /****f* silcclient/SilcClientAPI/silc_client_close_connection
505  *
506  * SYNOPSIS
507  *
508  *    void silc_client_close_connection(SilcClient client,
509  *                                      SilcSocketConnection sock,
510  *                                      SilcClientConnection conn);
511  *
512  * DESCRIPTION
513  *
514  *    Closes connection to remote end. Free's all allocated data except
515  *    for some information such as nickname etc. that are valid at all time. 
516  *    If the `sock' is NULL then the conn->sock will be used.  If `sock' is
517  *    provided it will be checked whether the sock and `conn->sock' are the
518  *    same (they can be different, ie. a socket can use `conn' as its
519  *    connection but `conn->sock' might be actually a different connection
520  *    than the `sock'). 
521  *
522  ***/
523 void silc_client_close_connection(SilcClient client,
524                                   SilcSocketConnection sock,
525                                   SilcClientConnection conn);
526
527
528 /* Message sending functions (client_channel.c and client_prvmsg.c) */
529
530 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
531  *
532  * SYNOPSIS
533  *
534  *    void silc_client_send_channel_message(SilcClient client, 
535  *                                          SilcClientConnection conn,
536  *                                          SilcChannelEntry channel,
537  *                                          SilcChannelPrivateKey key,
538  *                                          SilcMessageFlags flags,
539  *                                          unsigned char *data, 
540  *                                          uint32 data_len, 
541  *                                          int force_send);
542  *
543  * DESCRIPTION
544  *
545  *    Sends packet to the `channel'. Packet to channel is always encrypted
546  *    differently from "normal" packets. SILC header of the packet is 
547  *    encrypted with the next receiver's key and the rest of the packet is
548  *    encrypted with the channel specific key. Padding and HMAC is computed
549  *    with the next receiver's key. The `data' is the channel message. If
550  *    the `force_send' is TRUE then the packet is sent immediately. 
551  *
552  *    If `key' is provided then that private key is used to encrypt the
553  *    channel message.  If it is not provided, private keys has not been
554  *    set at all, the normal channel key is used automatically.  If private
555  *    keys are set then the first key (the key that was added first as
556  *    private key) is used. 
557  *
558  ***/
559 void silc_client_send_channel_message(SilcClient client, 
560                                       SilcClientConnection conn,
561                                       SilcChannelEntry channel,
562                                       SilcChannelPrivateKey key,
563                                       SilcMessageFlags flags,
564                                       unsigned char *data, 
565                                       uint32 data_len, 
566                                       int force_send);
567
568 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
569  *
570  * SYNOPSIS
571  *
572  *    void silc_client_send_private_message(SilcClient client,
573  *                                          SilcClientConnection conn,
574  *                                          SilcClientEntry client_entry,
575  *                                          SilcMessageFlags flags,
576  *                                          unsigned char *data, 
577  *                                          uint32 data_len, 
578  *                                          int force_send);
579  *
580  * DESCRIPTION
581  *
582  *    Sends private message to remote client. If private message key has
583  *    not been set with this client then the message will be encrypted using
584  *    normal session keys. Private messages are special packets in SILC
585  *    network hence we need this own function for them. This is similar
586  *    to silc_client_packet_send_to_channel except that we send private
587  *    message. The `data' is the private message. If the `force_send' is
588  *    TRUE the packet is sent immediately. 
589  *
590  ***/
591 void silc_client_send_private_message(SilcClient client,
592                                       SilcClientConnection conn,
593                                       SilcClientEntry client_entry,
594                                       SilcMessageFlags flags,
595                                       unsigned char *data, 
596                                       uint32 data_len, 
597                                       int force_send);
598
599
600 /* Client and Channel entry retrieval (idlist.c) */
601
602 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
603  *
604  * SYNOPSIS
605  *
606  *    typedef void (*SilcGetClientCallback)(SilcClient client,
607  *                                          SilcClientConnection conn,
608  *                                          SilcClientEntry *clients,
609  *                                          uint32 clients_count,
610  *                                          void *context);
611  *
612  * DESCRIPTION
613  *
614  *    Callback function given to the silc_client_get_client function. The
615  *    found entries are allocated into the `clients' array. The array must
616  *    not be freed by the caller, the library will free it later. If the
617  *    `clients' is NULL, no such clients exist in the SILC Network.
618  *
619  ***/
620 typedef void (*SilcGetClientCallback)(SilcClient client,
621                                       SilcClientConnection conn,
622                                       SilcClientEntry *clients,
623                                       uint32 clients_count,
624                                       void *context);
625
626 /****f* silcclient/SilcClientAPI/silc_client_get_clients
627  *
628  * SYNOPSIS
629  *
630  *    void silc_client_get_clients(SilcClient client,
631  *                                 SilcClientConnection conn,
632  *                                 char *nickname,
633  *                                 char *server,
634  *                                 SilcGetClientCallback completion,
635  *                                 void *context);
636  *
637  * DESCRIPTION
638  *
639  *    Finds client entry or entries by the `nickname' and `server'. The 
640  *    completion callback will be called when the client entries has been
641  *    found.
642  *
643  * NOTES
644  *
645  *    NOTE: This function is always asynchronous and resolves the client
646  *    information from the server. Thus, if you already know the client
647  *    information then use the silc_client_get_client_by_id function to
648  *    get the client entry since this function may be very slow and should
649  *    be used only to initially get the client entries. 
650  *
651  ***/
652 void silc_client_get_clients(SilcClient client,
653                              SilcClientConnection conn,
654                              char *nickname,
655                              char *server,
656                              SilcGetClientCallback completion,
657                              void *context);
658
659 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
660  *
661  * SYNOPSIS
662  *
663  *    SilcClientEntry *silc_client_get_clients_local(SilcClient client,
664  *                                                   SilcClientConnection conn,
665  *                                                   char *nickname,
666  *                                                   char *server,
667  *                                                   uint32 *clients_count);
668  *
669  * DESCRIPTION
670  *
671  *    Same as silc_client_get_clients function but does not resolve anything
672  *    from the server.  This checks local cache and returns all clients from
673  *    the local cache. 
674  *
675  ***/
676 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
677                                                SilcClientConnection conn,
678                                                char *nickname,
679                                                char *server,
680                                                uint32 *clients_count);
681
682 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
683  *
684  * SYNOPSIS
685  *
686  *    void silc_client_get_clients_by_list(SilcClient client,
687  *                                         SilcClientConnection conn,
688  *                                         uint32 list_count,
689  *                                         SilcBuffer client_id_list,
690  *                                         SilcGetClientCallback completion,
691  *                                         void *context);
692  *
693  * DESCRIPTION
694  *
695  *    Gets client entries by the list of client ID's `client_id_list'. This
696  *    always resolves those client ID's it does not know yet from the server
697  *    so this function might take a while. The `client_id_list' is a list
698  *    of ID Payloads added one after other.  JOIN command reply and USERS
699  *    command reply for example returns this sort of list. The `completion'
700  *    will be called after the entries are available. 
701  *
702  ***/
703 void silc_client_get_clients_by_list(SilcClient client,
704                                      SilcClientConnection conn,
705                                      uint32 list_count,
706                                      SilcBuffer client_id_list,
707                                      SilcGetClientCallback completion,
708                                      void *context);
709
710 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
711  *
712  * SYNOPSIS
713  *
714  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
715  *                                                 SilcClientConnection conn,
716  *                                                 SilcClientID *client_id);
717  *
718  * DESCRIPTION
719  *
720  *    Find entry for client by the client's ID. Returns the entry or NULL
721  *    if the entry was not found. 
722  *
723  ***/
724 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
725                                              SilcClientConnection conn,
726                                              SilcClientID *client_id);
727
728 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
729  *
730  * SYNOPSIS
731  *
732  *    void 
733  *    silc_client_get_client_by_id_resolve(SilcClient client,
734  *                                         SilcClientConnection conn,
735  *                                         SilcClientID *client_id,
736  *                                         SilcGetClientCallback completion,
737  *                                         void *context);
738  *
739  * DESCRIPTION
740  *
741  *    Same as silc_client_get_client_by_id but will always resolve the
742  *    information from the server. Use this only if you know that you
743  *    do not have the entry and the only thing you know about the client
744  *    is its ID. 
745  *
746  ***/
747 void silc_client_get_client_by_id_resolve(SilcClient client,
748                                           SilcClientConnection conn,
749                                           SilcClientID *client_id,
750                                           SilcGetClientCallback completion,
751                                           void *context);
752
753 /****f* silcclient/SilcClientAPI/silc_client_get_channel
754  *
755  * SYNOPSIS
756  *
757  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
758  *                                             SilcClientConnection conn,
759  *                                             char *channel);
760  *
761  * DESCRIPTION
762  *
763  *    Finds entry for channel by the channel name. Returns the entry or NULL
764  *    if the entry was not found. It is found only if the client is joined
765  *    to the channel. 
766  *
767  ***/
768 SilcChannelEntry silc_client_get_channel(SilcClient client,
769                                          SilcClientConnection conn,
770                                          char *channel);
771
772
773 /* Command management (command.c) */
774
775 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
776  *
777  * SYNOPSIS
778  *
779  *    SilcClientCommandContext silc_client_command_alloc();
780  *
781  * DESCRIPTION
782  *
783  *    Allocate Command Context. The context is defined in `command.h' file.
784  *    The context is used by the library commands and applications should use
785  *    it as well. However, application may choose to use some own context
786  *    for its local commands. All library commands, however, must use this
787  *    context. 
788  *
789  ***/
790 SilcClientCommandContext silc_client_command_alloc();
791
792 /****f* silcclient/SilcClientAPI/silc_client_command_free
793  *
794  * SYNOPSIS
795  *
796  *    void silc_client_command_free(SilcClientCommandContext ctx);
797  *
798  * DESCRIPTION
799  *
800  *    Free command context and its internals.  If the contex was duplicated
801  *    with silc_client_command_dup this may not actually free the data, 
802  *    instead it will decrease the reference counter of the context.  The
803  *    context will be freed when the reference counter hits zero.
804  *
805  ***/
806 void silc_client_command_free(SilcClientCommandContext ctx);
807
808 /****f* silcclient/SilcClientAPI/silc_client_command_dup
809  *
810  * SYNOPSIS
811  *
812  *    SilcClientCommandContext 
813  *    silc_client_command_dup(SilcClientCommandContext ctx);
814  *
815  * DESCRIPTION
816  *
817  *    Duplicate Command Context by adding reference counter. The context won't
818  *    be free'd untill it hits zero. 
819  *
820  ***/
821 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
822
823 /****f* silcclient/SilcClientAPI/silc_client_command_find
824  *
825  * SYNOPSIS
826  *
827  *    SilcClientCommand *silc_client_command_find(const char *name);
828  *
829  * DESCRIPTION
830  *
831  *    Finds and returns a pointer to the command list. Return NULL if the
832  *    command is not found. See the `command.[ch]' for the command list. 
833  *
834  ***/
835 SilcClientCommand *silc_client_command_find(const char *name);
836
837 /****f* silcclient/SilcClientAPI/silc_client_send_command
838  *
839  * SYNOPSIS
840  *
841  *    void silc_client_send_command(SilcClient client, 
842  *                                  SilcClientConnection conn,
843  *                                  SilcCommand command, uint16 ident,
844  *                                  uint32 argc, ...);
845  *
846  * DESCRIPTION
847  *
848  *    Generic function to send any command. The arguments must be sent already
849  *    encoded into correct form and in correct order. 
850  *
851  ***/
852 void silc_client_send_command(SilcClient client, SilcClientConnection conn,
853                               SilcCommand command, uint16 ident,
854                               uint32 argc, ...);
855
856 /****f* silcclient/SilcClientAPI/SilcClientPendingDestructor
857  *
858  * SYNOPSIS
859  *
860  *    typedef void (*SilcClientPendingDestructor)(void *context);
861  *
862  * DESCRIPTION
863  *
864  *    Pending Command callback destructor. This is called after calling the
865  *    pending callback or if error occurs while processing the pending command.
866  *    If error occurs then the callback won't be called at all, and only this
867  *    destructor is called. The `context' is the context given for the function
868  *    silc_client_command_pending. 
869  *
870  ***/
871 typedef void (*SilcClientPendingDestructor)(void *context);
872
873 /****f* silcclient/SilcClientAPI/silc_client_command_pending
874  *
875  * SYNOPSIS
876  *
877  *    void silc_client_command_pending(SilcClientConnection conn,
878  *                                     SilcCommand reply_cmd,
879  *                                     uint16 ident,
880  *                                     SilcClientPendingDestructor destructor,
881  *                                     SilcCommandCb callback,
882  *                                     void *context);
883  *
884  * DESCRIPTION
885  *
886  *    Add new pending command to be executed when reply to a command has been
887  *    received.  The `reply_cmd' is the command that will call the `callback'
888  *    with `context' when reply has been received.  If `ident is non-zero
889  *    the `callback' will be executed when received reply with command 
890  *    identifier `ident'. 
891  *
892  ***/
893 void silc_client_command_pending(SilcClientConnection conn,
894                                  SilcCommand reply_cmd,
895                                  uint16 ident,
896                                  SilcClientPendingDestructor destructor,
897                                  SilcCommandCb callback,
898                                  void *context);
899
900
901 /* Private Message key management (client_prvmsg.c) */
902
903 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
904  *
905  * SYNOPSIS
906  *
907  *    int silc_client_add_private_message_key(SilcClient client,
908  *                                            SilcClientConnection conn,
909  *                                            SilcClientEntry client_entry,
910  *                                            char *cipher,
911  *                                            unsigned char *key,
912  *                                            uint32 key_len,
913  *                                            bool generate_key,
914  *                                            bool responder);
915  *
916  * DESCRIPTION
917  *
918  *    Adds private message key to the client library. The key will be used to
919  *    encrypt all private message between the client and the remote client
920  *    indicated by the `client_entry'. If the `key' is NULL and the boolean
921  *    value `generate_key' is TRUE the library will generate random key.
922  *    The `key' maybe for example pre-shared-key, passphrase or similar.
923  *    The `cipher' MAY be provided but SHOULD be NULL to assure that the
924  *    requirements of the SILC protocol are met. The API, however, allows
925  *    to allocate any cipher.
926  *
927  *    If `responder' is TRUE then the sending and receiving keys will be
928  *    set according the client being the receiver of the private key.  If
929  *    FALSE the client is being the sender (or negotiator) of the private
930  *    key.
931  *
932  *    It is not necessary to set key for normal private message usage. If the
933  *    key is not set then the private messages are encrypted using normal
934  *    session keys. Setting the private key, however, increases the security. 
935  *
936  *    Returns FALSE if the key is already set for the `client_entry', TRUE
937  *    otherwise. 
938  *
939  ***/
940 int silc_client_add_private_message_key(SilcClient client,
941                                         SilcClientConnection conn,
942                                         SilcClientEntry client_entry,
943                                         char *cipher,
944                                         unsigned char *key,
945                                         uint32 key_len,
946                                         bool generate_key,
947                                         bool responder);
948
949 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
950  *
951  * SYNOPSIS
952  *
953  *    int silc_client_add_private_message_key_ske(SilcClient client,
954  *                                                SilcClientConnection conn,
955  *                                                SilcClientEntry client_entry,
956  *                                                char *cipher,
957  *                                                SilcSKEKeyMaterial *key);
958  *
959  * DESCRIPTION
960  *
961  *    Same as silc_client_add_private_message_key but takes the key material
962  *    from the SKE key material structure. This structure is received if
963  *    the application uses the silc_client_send_key_agreement to negotiate
964  *    the key material. The `cipher' SHOULD be provided as it is negotiated
965  *    also in the SKE protocol. 
966  *
967  ***/
968 int silc_client_add_private_message_key_ske(SilcClient client,
969                                             SilcClientConnection conn,
970                                             SilcClientEntry client_entry,
971                                             char *cipher,
972                                             SilcSKEKeyMaterial *key,
973                                             bool responder);
974
975 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
976  *
977  * SYNOPSIS
978  *
979  *    int silc_client_send_private_message_key(SilcClient client,
980  *                                             SilcClientConnection conn,
981  *                                             SilcClientEntry client_entry,
982  *                                             int force_send);
983  *
984  * DESCRIPTION
985  *
986  *    Sends private message key payload to the remote client indicated by
987  *    the `client_entry'. If the `force_send' is TRUE the packet is sent
988  *    immediately. Returns FALSE if error occurs, TRUE otherwise. The
989  *    application should call this function after setting the key to the
990  *    client.
991  *
992  *    Note that the key sent using this function is sent to the remote client
993  *    through the SILC network. The packet is protected using normal session
994  *    keys. 
995  *
996  ***/
997 int silc_client_send_private_message_key(SilcClient client,
998                                          SilcClientConnection conn,
999                                          SilcClientEntry client_entry,
1000                                          int force_send);
1001
1002 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1003  *
1004  * SYNOPSIS
1005  *
1006  *    int silc_client_del_private_message_key(SilcClient client,
1007  *                                            SilcClientConnection conn,
1008  *                                            SilcClientEntry client_entry);
1009  *
1010  * DESCRIPTION
1011  *
1012  *    Removes the private message from the library. The key won't be used
1013  *    after this to protect the private messages with the remote `client_entry'
1014  *    client. Returns FALSE on error, TRUE otherwise. 
1015  *
1016  ***/
1017 int silc_client_del_private_message_key(SilcClient client,
1018                                         SilcClientConnection conn,
1019                                         SilcClientEntry client_entry);
1020
1021 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1022  *
1023  * SYNOPSIS
1024  *
1025  *    SilcPrivateMessageKeys
1026  *    silc_client_list_private_message_keys(SilcClient client,
1027  *                                          SilcClientConnection conn,
1028  *                                          uint32 *key_count);
1029  * 
1030  * DESCRIPTION
1031  *
1032  *    Returns array of set private message keys associated to the connection
1033  *    `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1034  *    count to the `key_count' argument. The array must be freed by the caller
1035  *    by calling the silc_client_free_private_message_keys function. Note: 
1036  *    the keys returned in the array is in raw format. It might not be desired
1037  *    to show the keys as is. The application might choose not to show the keys
1038  *    at all or to show the fingerprints of the keys. 
1039  *
1040  ***/
1041 SilcPrivateMessageKeys
1042 silc_client_list_private_message_keys(SilcClient client,
1043                                       SilcClientConnection conn,
1044                                       uint32 *key_count);
1045
1046 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1047  *
1048  * SYNOPSIS
1049  *
1050  *    void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1051  *                                               uint32 key_count);
1052  * 
1053  * DESCRIPTION
1054  *
1055  *    Frees the SilcPrivateMessageKeys array returned by the function
1056  *    silc_client_list_private_message_keys. 
1057  *
1058  ***/
1059 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1060                                            uint32 key_count);
1061
1062
1063 /* Channel private key management (client_channel.c, 
1064    SilcChannelPrivateKey is defined in idlist.h) */
1065
1066 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1067  *
1068  * SYNOPSIS
1069  *
1070  *    int silc_client_add_channel_private_key(SilcClient client,
1071  *                                            SilcClientConnection conn,
1072  *                                            SilcChannelEntry channel,
1073  *                                            char *cipher,
1074  *                                            char *hmac,
1075  *                                            unsigned char *key,
1076  *                                            uint32 key_len);
1077  * 
1078  * DESCRIPTION
1079  *
1080  *    Adds private key for channel. This may be set only if the channel's mode
1081  *    mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1082  *    mode is not set. When channel has private key then the messages are
1083  *    encrypted using that key. All clients on the channel must also know the
1084  *    key in order to decrypt the messages. However, it is possible to have
1085  *    several private keys per one channel. In this case only some of the
1086  *    clients on the channel may know the one key and only some the other key.
1087  *
1088  *    The private key for channel is optional. If it is not set then the
1089  *    channel messages are encrypted using the channel key generated by the
1090  *    server. However, setting the private key (or keys) for the channel 
1091  *    significantly adds security. If more than one key is set the library
1092  *    will automatically try all keys at the message decryption phase. Note:
1093  *    setting many keys slows down the decryption phase as all keys has to
1094  *    be tried in order to find the correct decryption key. However, setting
1095  *    a few keys does not have big impact to the decryption performace. 
1096  *
1097  * NOTES
1098  *
1099  *    NOTE: This is entirely local setting. The key set using this function
1100  *    is not sent to the network at any phase.
1101  *
1102  *    NOTE: If the key material was originated by the SKE protocol (using
1103  *    silc_client_send_key_agreement) then the `key' MUST be the
1104  *    key->send_enc_key as this is dictated by the SILC protocol. However,
1105  *    currently it is not expected that the SKE key material would be used
1106  *    as channel private key. However, this API allows it. 
1107  *
1108  ***/
1109 int silc_client_add_channel_private_key(SilcClient client,
1110                                         SilcClientConnection conn,
1111                                         SilcChannelEntry channel,
1112                                         char *cipher,
1113                                         char *hmac,
1114                                         unsigned char *key,
1115                                         uint32 key_len);
1116
1117 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1118  *
1119  * SYNOPSIS
1120  *
1121  *    int silc_client_del_channel_private_keys(SilcClient client,
1122  *                                             SilcClientConnection conn,
1123  *                                             SilcChannelEntry channel);
1124  * 
1125  * DESCRIPTION
1126  *
1127  *    Removes all private keys from the `channel'. The old channel key is used
1128  *    after calling this to protect the channel messages. Returns FALSE on
1129  *    on error, TRUE otherwise. 
1130  *
1131  ***/
1132 int silc_client_del_channel_private_keys(SilcClient client,
1133                                          SilcClientConnection conn,
1134                                          SilcChannelEntry channel);
1135
1136 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1137  *
1138  * SYNOPSIS
1139  *
1140  *    int silc_client_del_channel_private_key(SilcClient client,
1141  *                                            SilcClientConnection conn,
1142  *                                            SilcChannelEntry channel,
1143  *                                            SilcChannelPrivateKey key);
1144  * 
1145  * DESCRIPTION
1146  *
1147  *    Removes and frees private key `key' from the channel `channel'. 
1148  *    The `key' is retrieved by calling the function 
1149  *    silc_client_list_channel_private_keys. The key is not used after
1150  *    this. If the key was last private key then the old channel key is
1151  *    used hereafter to protect the channel messages. This returns FALSE
1152  *    on error, TRUE otherwise. 
1153  *
1154  ***/
1155 int silc_client_del_channel_private_key(SilcClient client,
1156                                         SilcClientConnection conn,
1157                                         SilcChannelEntry channel,
1158                                         SilcChannelPrivateKey key);
1159
1160 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1161  *
1162  * SYNOPSIS
1163  *
1164  *    SilcChannelPrivateKey *
1165  *    silc_client_list_channel_private_keys(SilcClient client,
1166  *                                          SilcClientConnection conn,
1167  *                                          SilcChannelEntry channel,
1168  *                                          uint32 *key_count);
1169  *
1170  * DESCRIPTION
1171  *
1172  *    Returns array (pointers) of private keys associated to the `channel'.
1173  *    The caller must free the array by calling the function
1174  *    silc_client_free_channel_private_keys. The pointers in the array may be
1175  *    used to delete the specific key by giving the pointer as argument to the
1176  *    function silc_client_del_channel_private_key. 
1177  *
1178  ***/
1179 SilcChannelPrivateKey *
1180 silc_client_list_channel_private_keys(SilcClient client,
1181                                       SilcClientConnection conn,
1182                                       SilcChannelEntry channel,
1183                                       uint32 *key_count);
1184
1185 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1186  *
1187  * SYNOPSIS
1188  *
1189  *    void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1190  *                                               uint32 key_count);
1191  *
1192  * DESCRIPTION
1193  *
1194  *    Frees the SilcChannelPrivateKey array.
1195  *
1196  ***/
1197 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1198                                            uint32 key_count);
1199
1200
1201 /* Key Agreement routines (client_keyagr.c) */
1202
1203 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1204  *
1205  * SYNOPSIS
1206  *
1207  *    void silc_client_send_key_agreement(SilcClient client,
1208  *                                        SilcClientConnection conn,
1209  *                                        SilcClientEntry client_entry,
1210  *                                        char *hostname,
1211  *                                        int port,
1212  *                                        uint32 timeout_secs,
1213  *                                        SilcKeyAgreementCallback completion,
1214  *                                        void *context);
1215  *
1216  * DESCRIPTION
1217  *
1218  *    Sends key agreement request to the remote client indicated by the
1219  *    `client_entry'. If the caller provides the `hostname' and the `port'
1220  *    arguments then the library will bind the client to that hostname and
1221  *    that port for the key agreement protocol. It also sends the `hostname'
1222  *    and the `port' in the key agreement packet to the remote client. This
1223  *    would indicate that the remote client may initiate the key agreement
1224  *    protocol to the `hostname' on the `port'.  If port is zero then the
1225  *    bound port is undefined (the operating system defines it).
1226  *
1227  *    If the `hostname' and `port' is not provided then empty key agreement
1228  *    packet is sent to the remote client. The remote client may reply with
1229  *    the same packet including its hostname and port. If the library receives
1230  *    the reply from the remote client the `key_agreement' client operation
1231  *    callback will be called to verify whether the user wants to perform the
1232  *    key agreement or not. 
1233  *
1234  * NOTES
1235  *
1236  *    NOTE: If the application provided the `hostname' and the `port' and the 
1237  *    remote side initiates the key agreement protocol it is not verified
1238  *    from the user anymore whether the protocol should be executed or not.
1239  *    By setting the `hostname' and `port' the user gives permission to
1240  *    perform the protocol (we are responder in this case).
1241  *
1242  *    NOTE: If the remote side decides not to initiate the key agreement
1243  *    or decides not to reply with the key agreement packet then we cannot
1244  *    perform the key agreement at all. If the key agreement protocol is
1245  *    performed the `completion' callback with the `context' will be called.
1246  *    If remote side decides to ignore the request the `completion' will be
1247  *    called after the specified timeout, `timeout_secs'. 
1248  *
1249  *    NOTE: If the `hostname' and the `port' was not provided the `completion'
1250  *    will not be called at all since this does nothing more than sending
1251  *    a packet to the remote host.
1252  *
1253  *    NOTE: There can be only one active key agreement for one client entry.
1254  *    Before setting new one, the old one must be finished (it is finished
1255  *    after calling the completion callback) or the function 
1256  *    silc_client_abort_key_agreement must be called. 
1257  *
1258  ***/
1259 void silc_client_send_key_agreement(SilcClient client,
1260                                     SilcClientConnection conn,
1261                                     SilcClientEntry client_entry,
1262                                     char *hostname,
1263                                     int port,
1264                                     uint32 timeout_secs,
1265                                     SilcKeyAgreementCallback completion,
1266                                     void *context);
1267
1268 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1269  *
1270  * SYNOPSIS
1271  *
1272  *    void 
1273  *    silc_client_perform_key_agreement(SilcClient client,
1274  *                                      SilcClientConnection conn,
1275  *                                      SilcClientEntry client_entry,
1276  *                                      char *hostname,
1277  *                                      int port,
1278  *                                      SilcKeyAgreementCallback completion,
1279  *                                      void *context);
1280  *
1281  * DESCRIPTION
1282  *
1283  *    Performs the actual key agreement protocol. Application may use this
1284  *    to initiate the key agreement protocol. This can be called for example
1285  *    after the application has received the `key_agreement' client operation,
1286  *    and did not return TRUE from it.
1287  *
1288  *    The `hostname' is the remote hostname (or IP address) and the `port'
1289  *    is the remote port. The `completion' callback with the `context' will
1290  *    be called after the key agreement protocol.
1291  *
1292  * NOTES
1293  * 
1294  *    NOTE: If the application returns TRUE in the `key_agreement' client
1295  *    operation the library will automatically start the key agreement. In this
1296  *    case the application must not call this function. However, application
1297  *    may choose to just ignore the `key_agreement' client operation (and
1298  *    merely just print information about it on the screen) and call this
1299  *    function when the user whishes to do so (by, for example, giving some
1300  *    specific command). Thus, the API provides both, automatic and manual
1301  *    initiation of the key agreement. Calling this function is the manual
1302  *    initiation and returning TRUE in the `key_agreement' client operation
1303  *    is the automatic initiation. 
1304  *
1305  ***/
1306 void silc_client_perform_key_agreement(SilcClient client,
1307                                        SilcClientConnection conn,
1308                                        SilcClientEntry client_entry,
1309                                        char *hostname,
1310                                        int port,
1311                                        SilcKeyAgreementCallback completion,
1312                                        void *context);
1313
1314 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1315  *
1316  * SYNOPSIS
1317  *
1318  *    void
1319  *    silc_client_perform_key_agreement_fd(SilcClient client,
1320  *                                         SilcClientConnection conn,
1321  *                                         SilcClientEntry client_entry,
1322  *                                         int sock,
1323  *                                         char *hostname,
1324  *                                         SilcKeyAgreementCallback completion,
1325  *                                         void *context);
1326  *
1327  * DESCRIPTION
1328  *
1329  *    Same as above but application has created already the connection to 
1330  *    the remote host. The `sock' is the socket to the remote connection. 
1331  *    Application can use this function if it does not want the client library
1332  *    to create the connection. 
1333  *
1334  ***/
1335 void silc_client_perform_key_agreement_fd(SilcClient client,
1336                                           SilcClientConnection conn,
1337                                           SilcClientEntry client_entry,
1338                                           int sock,
1339                                           char *hostname,
1340                                           SilcKeyAgreementCallback completion,
1341                                           void *context);
1342
1343 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1344  *
1345  * SYNOPSIS
1346  *
1347  *    void silc_client_abort_key_agreement(SilcClient client,
1348  *                                         SilcClientConnection conn,
1349  *                                         SilcClientEntry client_entry);
1350  *
1351  * DESCRIPTION
1352  *
1353  *    This function can be called to unbind the hostname and the port for
1354  *    the key agreement protocol. However, this function has effect only 
1355  *    before the key agreement protocol has been performed. After it has
1356  *    been performed the library will automatically unbind the port. The 
1357  *    `client_entry' is the client to which we sent the key agreement 
1358  *    request. 
1359  *
1360  ***/
1361 void silc_client_abort_key_agreement(SilcClient client,
1362                                      SilcClientConnection conn,
1363                                      SilcClientEntry client_entry);
1364
1365
1366 /* Misc functions */
1367
1368 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1369  *
1370  * SYNOPSIS
1371  *
1372  *    void silc_client_set_away_message(SilcClient client,
1373  *                                      SilcClientConnection conn,
1374  *                                      char *message);
1375  *
1376  * DESCRIPTION
1377  *
1378  *    Sets away `message'.  The away message may be set when the client's
1379  *    mode is changed to SILC_UMODE_GONE and the client whishes to reply
1380  *    to anyone who sends private message.  The `message' will be sent
1381  *    automatically back to the the client who send private message.  If
1382  *    away message is already set this replaces the old message with the
1383  *    new one.  If `message' is NULL the old away message is removed. 
1384  *    The sender may freely free the memory of the `message'. 
1385  *
1386  ***/
1387 void silc_client_set_away_message(SilcClient client,
1388                                   SilcClientConnection conn,
1389                                   char *message);
1390
1391 #endif