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  *                                            int generate_key);
914  *
915  * DESCRIPTION
916  *
917  *    Adds private message key to the client library. The key will be used to
918  *    encrypt all private message between the client and the remote client
919  *    indicated by the `client_entry'. If the `key' is NULL and the boolean
920  *    value `generate_key' is TRUE the library will generate random key.
921  *    The `key' maybe for example pre-shared-key, passphrase or similar.
922  *    The `cipher' MAY be provided but SHOULD be NULL to assure that the
923  *    requirements of the SILC protocol are met. The API, however, allows
924  *    to allocate any cipher.
925  *
926  *    It is not necessary to set key for normal private message usage. If the
927  *    key is not set then the private messages are encrypted using normal
928  *    session keys. Setting the private key, however, increases the security. 
929  *
930  *    Returns FALSE if the key is already set for the `client_entry', TRUE
931  *    otherwise. 
932  *
933  ***/
934 int silc_client_add_private_message_key(SilcClient client,
935                                         SilcClientConnection conn,
936                                         SilcClientEntry client_entry,
937                                         char *cipher,
938                                         unsigned char *key,
939                                         uint32 key_len,
940                                         int generate_key);
941
942 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
943  *
944  * SYNOPSIS
945  *
946  *    int silc_client_add_private_message_key_ske(SilcClient client,
947  *                                                SilcClientConnection conn,
948  *                                                SilcClientEntry client_entry,
949  *                                                char *cipher,
950  *                                                SilcSKEKeyMaterial *key);
951  *
952  * DESCRIPTION
953  *
954  *    Same as above but takes the key material from the SKE key material
955  *    structure. This structure is received if the application uses the
956  *    silc_client_send_key_agreement to negotiate the key material. The
957  *    `cipher' SHOULD be provided as it is negotiated also in the SKE
958  *    protocol. 
959  *
960  ***/
961 int silc_client_add_private_message_key_ske(SilcClient client,
962                                             SilcClientConnection conn,
963                                             SilcClientEntry client_entry,
964                                             char *cipher,
965                                             SilcSKEKeyMaterial *key);
966
967 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
968  *
969  * SYNOPSIS
970  *
971  *    int silc_client_send_private_message_key(SilcClient client,
972  *                                             SilcClientConnection conn,
973  *                                             SilcClientEntry client_entry,
974  *                                             int force_send);
975  *
976  * DESCRIPTION
977  *
978  *    Sends private message key payload to the remote client indicated by
979  *    the `client_entry'. If the `force_send' is TRUE the packet is sent
980  *    immediately. Returns FALSE if error occurs, TRUE otherwise. The
981  *    application should call this function after setting the key to the
982  *    client.
983  *
984  *    Note that the key sent using this function is sent to the remote client
985  *    through the SILC network. The packet is protected using normal session
986  *    keys. 
987  *
988  ***/
989 int silc_client_send_private_message_key(SilcClient client,
990                                          SilcClientConnection conn,
991                                          SilcClientEntry client_entry,
992                                          int force_send);
993
994 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
995  *
996  * SYNOPSIS
997  *
998  *    int silc_client_del_private_message_key(SilcClient client,
999  *                                            SilcClientConnection conn,
1000  *                                            SilcClientEntry client_entry);
1001  *
1002  * DESCRIPTION
1003  *
1004  *    Removes the private message from the library. The key won't be used
1005  *    after this to protect the private messages with the remote `client_entry'
1006  *    client. Returns FALSE on error, TRUE otherwise. 
1007  *
1008  ***/
1009 int silc_client_del_private_message_key(SilcClient client,
1010                                         SilcClientConnection conn,
1011                                         SilcClientEntry client_entry);
1012
1013 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1014  *
1015  * SYNOPSIS
1016  *
1017  *    SilcPrivateMessageKeys
1018  *    silc_client_list_private_message_keys(SilcClient client,
1019  *                                          SilcClientConnection conn,
1020  *                                          uint32 *key_count);
1021  * 
1022  * DESCRIPTION
1023  *
1024  *    Returns array of set private message keys associated to the connection
1025  *    `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1026  *    count to the `key_count' argument. The array must be freed by the caller
1027  *    by calling the silc_client_free_private_message_keys function. Note: 
1028  *    the keys returned in the array is in raw format. It might not be desired
1029  *    to show the keys as is. The application might choose not to show the keys
1030  *    at all or to show the fingerprints of the keys. 
1031  *
1032  ***/
1033 SilcPrivateMessageKeys
1034 silc_client_list_private_message_keys(SilcClient client,
1035                                       SilcClientConnection conn,
1036                                       uint32 *key_count);
1037
1038 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1039  *
1040  * SYNOPSIS
1041  *
1042  *    void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1043  *                                               uint32 key_count);
1044  * 
1045  * DESCRIPTION
1046  *
1047  *    Frees the SilcPrivateMessageKeys array returned by the function
1048  *    silc_client_list_private_message_keys. 
1049  *
1050  ***/
1051 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1052                                            uint32 key_count);
1053
1054
1055 /* Channel private key management (client_channel.c, 
1056    SilcChannelPrivateKey is defined in idlist.h) */
1057
1058 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1059  *
1060  * SYNOPSIS
1061  *
1062  *    int silc_client_add_channel_private_key(SilcClient client,
1063  *                                            SilcClientConnection conn,
1064  *                                            SilcChannelEntry channel,
1065  *                                            char *cipher,
1066  *                                            char *hmac,
1067  *                                            unsigned char *key,
1068  *                                            uint32 key_len);
1069  * 
1070  * DESCRIPTION
1071  *
1072  *    Adds private key for channel. This may be set only if the channel's mode
1073  *    mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1074  *    mode is not set. When channel has private key then the messages are
1075  *    encrypted using that key. All clients on the channel must also know the
1076  *    key in order to decrypt the messages. However, it is possible to have
1077  *    several private keys per one channel. In this case only some of the
1078  *    clients on the channel may know the one key and only some the other key.
1079  *
1080  *    The private key for channel is optional. If it is not set then the
1081  *    channel messages are encrypted using the channel key generated by the
1082  *    server. However, setting the private key (or keys) for the channel 
1083  *    significantly adds security. If more than one key is set the library
1084  *    will automatically try all keys at the message decryption phase. Note:
1085  *    setting many keys slows down the decryption phase as all keys has to
1086  *    be tried in order to find the correct decryption key. However, setting
1087  *    a few keys does not have big impact to the decryption performace. 
1088  *
1089  * NOTES
1090  *
1091  *    NOTE: This is entirely local setting. The key set using this function
1092  *    is not sent to the network at any phase.
1093  *
1094  *    NOTE: If the key material was originated by the SKE protocol (using
1095  *    silc_client_send_key_agreement) then the `key' MUST be the
1096  *    key->send_enc_key as this is dictated by the SILC protocol. However,
1097  *    currently it is not expected that the SKE key material would be used
1098  *    as channel private key. However, this API allows it. 
1099  *
1100  ***/
1101 int silc_client_add_channel_private_key(SilcClient client,
1102                                         SilcClientConnection conn,
1103                                         SilcChannelEntry channel,
1104                                         char *cipher,
1105                                         char *hmac,
1106                                         unsigned char *key,
1107                                         uint32 key_len);
1108
1109 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1110  *
1111  * SYNOPSIS
1112  *
1113  *    int silc_client_del_channel_private_keys(SilcClient client,
1114  *                                             SilcClientConnection conn,
1115  *                                             SilcChannelEntry channel);
1116  * 
1117  * DESCRIPTION
1118  *
1119  *    Removes all private keys from the `channel'. The old channel key is used
1120  *    after calling this to protect the channel messages. Returns FALSE on
1121  *    on error, TRUE otherwise. 
1122  *
1123  ***/
1124 int silc_client_del_channel_private_keys(SilcClient client,
1125                                          SilcClientConnection conn,
1126                                          SilcChannelEntry channel);
1127
1128 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1129  *
1130  * SYNOPSIS
1131  *
1132  *    int silc_client_del_channel_private_key(SilcClient client,
1133  *                                            SilcClientConnection conn,
1134  *                                            SilcChannelEntry channel,
1135  *                                            SilcChannelPrivateKey key);
1136  * 
1137  * DESCRIPTION
1138  *
1139  *    Removes and frees private key `key' from the channel `channel'. 
1140  *    The `key' is retrieved by calling the function 
1141  *    silc_client_list_channel_private_keys. The key is not used after
1142  *    this. If the key was last private key then the old channel key is
1143  *    used hereafter to protect the channel messages. This returns FALSE
1144  *    on error, TRUE otherwise. 
1145  *
1146  ***/
1147 int silc_client_del_channel_private_key(SilcClient client,
1148                                         SilcClientConnection conn,
1149                                         SilcChannelEntry channel,
1150                                         SilcChannelPrivateKey key);
1151
1152 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1153  *
1154  * SYNOPSIS
1155  *
1156  *    SilcChannelPrivateKey *
1157  *    silc_client_list_channel_private_keys(SilcClient client,
1158  *                                          SilcClientConnection conn,
1159  *                                          SilcChannelEntry channel,
1160  *                                          uint32 *key_count);
1161  *
1162  * DESCRIPTION
1163  *
1164  *    Returns array (pointers) of private keys associated to the `channel'.
1165  *    The caller must free the array by calling the function
1166  *    silc_client_free_channel_private_keys. The pointers in the array may be
1167  *    used to delete the specific key by giving the pointer as argument to the
1168  *    function silc_client_del_channel_private_key. 
1169  *
1170  ***/
1171 SilcChannelPrivateKey *
1172 silc_client_list_channel_private_keys(SilcClient client,
1173                                       SilcClientConnection conn,
1174                                       SilcChannelEntry channel,
1175                                       uint32 *key_count);
1176
1177 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1178  *
1179  * SYNOPSIS
1180  *
1181  *    void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1182  *                                               uint32 key_count);
1183  *
1184  * DESCRIPTION
1185  *
1186  *    Frees the SilcChannelPrivateKey array.
1187  *
1188  ***/
1189 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1190                                            uint32 key_count);
1191
1192
1193 /* Key Agreement routines (client_keyagr.c) */
1194
1195 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1196  *
1197  * SYNOPSIS
1198  *
1199  *    void silc_client_send_key_agreement(SilcClient client,
1200  *                                        SilcClientConnection conn,
1201  *                                        SilcClientEntry client_entry,
1202  *                                        char *hostname,
1203  *                                        int port,
1204  *                                        uint32 timeout_secs,
1205  *                                        SilcKeyAgreementCallback completion,
1206  *                                        void *context);
1207  *
1208  * DESCRIPTION
1209  *
1210  *    Sends key agreement request to the remote client indicated by the
1211  *    `client_entry'. If the caller provides the `hostname' and the `port'
1212  *    arguments then the library will bind the client to that hostname and
1213  *    that port for the key agreement protocol. It also sends the `hostname'
1214  *    and the `port' in the key agreement packet to the remote client. This
1215  *    would indicate that the remote client may initiate the key agreement
1216  *    protocol to the `hostname' on the `port'.  If port is zero then the
1217  *    bound port is undefined (the operating system defines it).
1218  *
1219  *    If the `hostname' and `port' is not provided then empty key agreement
1220  *    packet is sent to the remote client. The remote client may reply with
1221  *    the same packet including its hostname and port. If the library receives
1222  *    the reply from the remote client the `key_agreement' client operation
1223  *    callback will be called to verify whether the user wants to perform the
1224  *    key agreement or not. 
1225  *
1226  * NOTES
1227  *
1228  *    NOTE: If the application provided the `hostname' and the `port' and the 
1229  *    remote side initiates the key agreement protocol it is not verified
1230  *    from the user anymore whether the protocol should be executed or not.
1231  *    By setting the `hostname' and `port' the user gives permission to
1232  *    perform the protocol (we are responder in this case).
1233  *
1234  *    NOTE: If the remote side decides not to initiate the key agreement
1235  *    or decides not to reply with the key agreement packet then we cannot
1236  *    perform the key agreement at all. If the key agreement protocol is
1237  *    performed the `completion' callback with the `context' will be called.
1238  *    If remote side decides to ignore the request the `completion' will be
1239  *    called after the specified timeout, `timeout_secs'. 
1240  *
1241  *    NOTE: There can be only one active key agreement for one client entry.
1242  *    Before setting new one, the old one must be finished (it is finished
1243  *    after calling the completion callback) or the function 
1244  *    silc_client_abort_key_agreement must be called. 
1245  *
1246  ***/
1247 void silc_client_send_key_agreement(SilcClient client,
1248                                     SilcClientConnection conn,
1249                                     SilcClientEntry client_entry,
1250                                     char *hostname,
1251                                     int port,
1252                                     uint32 timeout_secs,
1253                                     SilcKeyAgreementCallback completion,
1254                                     void *context);
1255
1256 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1257  *
1258  * SYNOPSIS
1259  *
1260  *    void 
1261  *    silc_client_perform_key_agreement(SilcClient client,
1262  *                                      SilcClientConnection conn,
1263  *                                      SilcClientEntry client_entry,
1264  *                                      char *hostname,
1265  *                                      int port,
1266  *                                      SilcKeyAgreementCallback completion,
1267  *                                      void *context);
1268  *
1269  * DESCRIPTION
1270  *
1271  *    Performs the actual key agreement protocol. Application may use this
1272  *    to initiate the key agreement protocol. This can be called for example
1273  *    after the application has received the `key_agreement' client operation,
1274  *    and did not return TRUE from it.
1275  *
1276  *    The `hostname' is the remote hostname (or IP address) and the `port'
1277  *    is the remote port. The `completion' callback with the `context' will
1278  *    be called after the key agreement protocol.
1279  *
1280  * NOTES
1281  * 
1282  *    NOTE: If the application returns TRUE in the `key_agreement' client
1283  *    operation the library will automatically start the key agreement. In this
1284  *    case the application must not call this function. However, application
1285  *    may choose to just ignore the `key_agreement' client operation (and
1286  *    merely just print information about it on the screen) and call this
1287  *    function when the user whishes to do so (by, for example, giving some
1288  *    specific command). Thus, the API provides both, automatic and manual
1289  *    initiation of the key agreement. Calling this function is the manual
1290  *    initiation and returning TRUE in the `key_agreement' client operation
1291  *    is the automatic initiation. 
1292  *
1293  ***/
1294 void silc_client_perform_key_agreement(SilcClient client,
1295                                        SilcClientConnection conn,
1296                                        SilcClientEntry client_entry,
1297                                        char *hostname,
1298                                        int port,
1299                                        SilcKeyAgreementCallback completion,
1300                                        void *context);
1301
1302 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1303  *
1304  * SYNOPSIS
1305  *
1306  *    void
1307  *    silc_client_perform_key_agreement_fd(SilcClient client,
1308  *                                         SilcClientConnection conn,
1309  *                                         SilcClientEntry client_entry,
1310  *                                         int sock,
1311  *                                         char *hostname,
1312  *                                         SilcKeyAgreementCallback completion,
1313  *                                         void *context);
1314  *
1315  * DESCRIPTION
1316  *
1317  *    Same as above but application has created already the connection to 
1318  *    the remote host. The `sock' is the socket to the remote connection. 
1319  *    Application can use this function if it does not want the client library
1320  *    to create the connection. 
1321  *
1322  ***/
1323 void silc_client_perform_key_agreement_fd(SilcClient client,
1324                                           SilcClientConnection conn,
1325                                           SilcClientEntry client_entry,
1326                                           int sock,
1327                                           char *hostname,
1328                                           SilcKeyAgreementCallback completion,
1329                                           void *context);
1330
1331 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1332  *
1333  * SYNOPSIS
1334  *
1335  *    void silc_client_abort_key_agreement(SilcClient client,
1336  *                                         SilcClientConnection conn,
1337  *                                         SilcClientEntry client_entry);
1338  *
1339  * DESCRIPTION
1340  *
1341  *    This function can be called to unbind the hostname and the port for
1342  *    the key agreement protocol. However, this function has effect only 
1343  *    before the key agreement protocol has been performed. After it has
1344  *    been performed the library will automatically unbind the port. The 
1345  *    `client_entry' is the client to which we sent the key agreement 
1346  *    request. 
1347  *
1348  ***/
1349 void silc_client_abort_key_agreement(SilcClient client,
1350                                      SilcClientConnection conn,
1351                                      SilcClientEntry client_entry);
1352
1353
1354 /* Misc functions */
1355
1356 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1357  *
1358  * SYNOPSIS
1359  *
1360  *    void silc_client_set_away_message(SilcClient client,
1361  *                                      SilcClientConnection conn,
1362  *                                      char *message);
1363  *
1364  * DESCRIPTION
1365  *
1366  *    Sets away `message'.  The away message may be set when the client's
1367  *    mode is changed to SILC_UMODE_GONE and the client whishes to reply
1368  *    to anyone who sends private message.  The `message' will be sent
1369  *    automatically back to the the client who send private message.  If
1370  *    away message is already set this replaces the old message with the
1371  *    new one.  If `message' is NULL the old away message is removed. 
1372  *    The sender may freely free the memory of the `message'. 
1373  *
1374  ***/
1375 void silc_client_set_away_message(SilcClient client,
1376                                   SilcClientConnection conn,
1377                                   char *message);
1378
1379 #endif