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.
318  *
319  ***/
320 SilcClient silc_client_alloc(SilcClientOperations *ops, void *application);
321
322 /****f* silcclient/SilcClientAPI/silc_client_free
323  *
324  * SYNOPSIS
325  *
326  *    void silc_client_free(SilcClient client);
327  *
328  * DESCRIPTION
329  *
330  *    Frees client object and its internals.  The execution of the client
331  *    should be stopped with silc_client_stop function before calling
332  *    this function.
333  *
334  ***/
335 void silc_client_free(SilcClient client);
336
337 /****f* silcclient/SilcClientAPI/silc_client_init
338  *
339  * SYNOPSIS
340  *
341  *    int silc_client_init(SilcClient client);
342  *
343  * DESCRIPTION
344  *
345  *    Initializes the client. This makes all the necessary steps to make
346  *    the client ready to be run. One must call silc_client_run to run the
347  *    client. Returns FALSE if error occurred, TRUE otherwise.
348  *
349  ***/
350 int silc_client_init(SilcClient client);
351
352 /****f* silcclient/SilcClientAPI/silc_client_run
353  *
354  * SYNOPSIS
355  *
356  *    void silc_client_run(SilcClient client);
357  *
358  * DESCRIPTION
359  *
360  *    Runs the client. This starts the scheduler from the utility library.
361  *    When this functions returns the execution of the appliation is over.
362  *
363  ***/
364 void silc_client_run(SilcClient client);
365
366 /****f* silcclient/SilcClientAPI/silc_client_stop
367  *
368  * SYNOPSIS
369  *
370  *    void silc_client_stop(SilcClient client);
371  *
372  * DESCRIPTION
373  *
374  *    Stops the client. This is called to stop the client and thus to stop
375  *    the program.  The client context must be freed with the silc_client_free
376  *    function.
377  *
378  ***/
379 void silc_client_stop(SilcClient client);
380
381
382 /* Connecting functions (client.c) */
383
384 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
385  *
386  * SYNOPSIS
387  *
388  *    int silc_client_connect_to_server(SilcClient client, int port,
389  *                                      char *host, void *context);
390  *
391  * DESCRIPTION
392  *
393  *    Connects to remote server. This is the main routine used to connect
394  *    to SILC server. Returns -1 on error and the created socket otherwise. 
395  *    The `context' is user context that is saved into the SilcClientConnection
396  *    that is created after the connection is created. Note that application
397  *    may handle the connecting process outside the library. If this is the
398  *    case then this function is not used at all. When the connecting is
399  *    done the `connect' client operation is called.
400  *
401  ***/
402 int silc_client_connect_to_server(SilcClient client, int port,
403                                   char *host, void *context);
404
405 /****f* silcclient/SilcClientAPI/silc_client_add_connection
406  *
407  * SYNOPSIS
408  *
409  *    SilcClientConnection silc_client_add_connection(SilcClient client,
410  *                                                    char *hostname,
411  *                                                    int port,
412  *                                                    void *context);
413  *
414  * DESCRIPTION
415  *
416  *    Allocates and adds new connection to the client. This adds the allocated
417  *    connection to the connection table and returns a pointer to it. A client
418  *    can have multiple connections to multiple servers. Every connection must
419  *    be added to the client using this function. User data `context' may
420  *    be sent as argument. This function is normally used only if the 
421  *    application performed the connecting outside the library. The library
422  *    however may use this internally.
423  *
424  ***/
425 SilcClientConnection silc_client_add_connection(SilcClient client,
426                                                 char *hostname,
427                                                 int port,
428                                                 void *context);
429
430 /****f* silcclient/SilcClientAPI/silc_client_del_connection
431  *
432  * SYNOPSIS
433  *
434  *    void silc_client_del_connection(SilcClient client, 
435  *                                    SilcClientConnection conn);
436  *
437  * DESCRIPTION
438  *
439  *    Removes connection from client. Frees all memory. The library
440  *    call this function automatically for all connection contexts.
441  *    The application however may free the connection contexts it has
442  *    allocated.
443  *
444  ***/
445 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
446
447 /****f* silcclient/SilcClientAPI/silc_client_add_socket
448  *
449  * SYNOPSIS
450  *
451  *    void silc_client_add_socket(SilcClient client, 
452  *                                SilcSocketConnection sock);
453  *
454  * DESCRIPTION
455  *
456  *    Adds listener socket to the listener sockets table. This function is
457  *    used to add socket objects that are listeners to the client.  This should
458  *    not be used to add other connection objects.
459  *
460  ***/
461 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
462
463 /****f* silcclient/SilcClientAPI/silc_client_del_socket
464  *
465  * SYNOPSIS
466  *
467  *    void silc_client_del_socket(SilcClient client, 
468  *                                SilcSocketConnection sock);
469  *
470  * DESCRIPTION
471  *
472  *    Deletes listener socket from the listener sockets table.  If the
473  *    application has added a socket with silc_client_add_socket it must
474  *    also free it using this function.
475  *
476  ***/
477 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
478
479 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
480  *
481  * SYNOPSIS
482  *
483  *    int silc_client_start_key_exchange(SilcClient client,
484  *                                       SilcClientConnection conn,
485  *                                       int fd);
486  *
487  * DESCRIPTION
488  *
489  *    Start SILC Key Exchange (SKE) protocol to negotiate shared secret
490  *    key material between client and server.  This function can be called
491  *    directly if application is performing its own connecting and does not
492  *    use the connecting provided by this library. This function is normally
493  *    used only if the application performed the connecting outside the
494  *    library. The library however may use this internally.
495  *
496  ***/
497 int silc_client_start_key_exchange(SilcClient client,
498                                    SilcClientConnection conn,
499                                    int fd);
500
501 /****f* silcclient/SilcClientAPI/silc_client_close_connection
502  *
503  * SYNOPSIS
504  *
505  *    void silc_client_close_connection(SilcClient client,
506  *                                      SilcSocketConnection sock,
507  *                                      SilcClientConnection conn);
508  *
509  * DESCRIPTION
510  *
511  *    Closes connection to remote end. Free's all allocated data except
512  *    for some information such as nickname etc. that are valid at all time. 
513  *    If the `sock' is NULL then the conn->sock will be used.  If `sock' is
514  *    provided it will be checked whether the sock and `conn->sock' are the
515  *    same (they can be different, ie. a socket can use `conn' as its
516  *    connection but `conn->sock' might be actually a different connection
517  *    than the `sock'). 
518  *
519  ***/
520 void silc_client_close_connection(SilcClient client,
521                                   SilcSocketConnection sock,
522                                   SilcClientConnection conn);
523
524
525 /* Message sending functions (client_channel.c and client_prvmsg.c) */
526
527 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
528  *
529  * SYNOPSIS
530  *
531  *    void silc_client_send_channel_message(SilcClient client, 
532  *                                          SilcClientConnection conn,
533  *                                          SilcChannelEntry channel,
534  *                                          SilcChannelPrivateKey key,
535  *                                          SilcMessageFlags flags,
536  *                                          unsigned char *data, 
537  *                                          uint32 data_len, 
538  *                                          int force_send);
539  *
540  * DESCRIPTION
541  *
542  *    Sends packet to the `channel'. Packet to channel is always encrypted
543  *    differently from "normal" packets. SILC header of the packet is 
544  *    encrypted with the next receiver's key and the rest of the packet is
545  *    encrypted with the channel specific key. Padding and HMAC is computed
546  *    with the next receiver's key. The `data' is the channel message. If
547  *    the `force_send' is TRUE then the packet is sent immediately. 
548  *
549  *    If `key' is provided then that private key is used to encrypt the
550  *    channel message.  If it is not provided, private keys has not been
551  *    set at all, the normal channel key is used automatically.  If private
552  *    keys are set then the first key (the key that was added first as
553  *    private key) is used. 
554  *
555  ***/
556 void silc_client_send_channel_message(SilcClient client, 
557                                       SilcClientConnection conn,
558                                       SilcChannelEntry channel,
559                                       SilcChannelPrivateKey key,
560                                       SilcMessageFlags flags,
561                                       unsigned char *data, 
562                                       uint32 data_len, 
563                                       int force_send);
564
565 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
566  *
567  * SYNOPSIS
568  *
569  *    void silc_client_send_private_message(SilcClient client,
570  *                                          SilcClientConnection conn,
571  *                                          SilcClientEntry client_entry,
572  *                                          SilcMessageFlags flags,
573  *                                          unsigned char *data, 
574  *                                          uint32 data_len, 
575  *                                          int force_send);
576  *
577  * DESCRIPTION
578  *
579  *    Sends private message to remote client. If private message key has
580  *    not been set with this client then the message will be encrypted using
581  *    normal session keys. Private messages are special packets in SILC
582  *    network hence we need this own function for them. This is similar
583  *    to silc_client_packet_send_to_channel except that we send private
584  *    message. The `data' is the private message. If the `force_send' is
585  *    TRUE the packet is sent immediately. 
586  *
587  ***/
588 void silc_client_send_private_message(SilcClient client,
589                                       SilcClientConnection conn,
590                                       SilcClientEntry client_entry,
591                                       SilcMessageFlags flags,
592                                       unsigned char *data, 
593                                       uint32 data_len, 
594                                       int force_send);
595
596
597 /* Client and Channel entry retrieval (idlist.c) */
598
599 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
600  *
601  * SYNOPSIS
602  *
603  *    typedef void (*SilcGetClientCallback)(SilcClient client,
604  *                                          SilcClientConnection conn,
605  *                                          SilcClientEntry *clients,
606  *                                          uint32 clients_count,
607  *                                          void *context);
608  *
609  * DESCRIPTION
610  *
611  *    Callback function given to the silc_client_get_client function. The
612  *    found entries are allocated into the `clients' array. The array must
613  *    not be freed by the caller, the library will free it later. If the
614  *    `clients' is NULL, no such clients exist in the SILC Network.
615  *
616  ***/
617 typedef void (*SilcGetClientCallback)(SilcClient client,
618                                       SilcClientConnection conn,
619                                       SilcClientEntry *clients,
620                                       uint32 clients_count,
621                                       void *context);
622
623 /****f* silcclient/SilcClientAPI/silc_client_get_clients
624  *
625  * SYNOPSIS
626  *
627  *    void silc_client_get_clients(SilcClient client,
628  *                                 SilcClientConnection conn,
629  *                                 char *nickname,
630  *                                 char *server,
631  *                                 SilcGetClientCallback completion,
632  *                                 void *context);
633  *
634  * DESCRIPTION
635  *
636  *    Finds client entry or entries by the `nickname' and `server'. The 
637  *    completion callback will be called when the client entries has been
638  *    found.
639  *
640  * NOTES
641  *
642  *    NOTE: This function is always asynchronous and resolves the client
643  *    information from the server. Thus, if you already know the client
644  *    information then use the silc_client_get_client_by_id function to
645  *    get the client entry since this function may be very slow and should
646  *    be used only to initially get the client entries. 
647  *
648  ***/
649 void silc_client_get_clients(SilcClient client,
650                              SilcClientConnection conn,
651                              char *nickname,
652                              char *server,
653                              SilcGetClientCallback completion,
654                              void *context);
655
656 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
657  *
658  * SYNOPSIS
659  *
660  *    SilcClientEntry *silc_client_get_clients_local(SilcClient client,
661  *                                                   SilcClientConnection conn,
662  *                                                   char *nickname,
663  *                                                   char *server,
664  *                                                   uint32 *clients_count);
665  *
666  * DESCRIPTION
667  *
668  *    Same as silc_client_get_clients function but does not resolve anything
669  *    from the server.  This checks local cache and returns all clients from
670  *    the local cache. 
671  *
672  ***/
673 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
674                                                SilcClientConnection conn,
675                                                char *nickname,
676                                                char *server,
677                                                uint32 *clients_count);
678
679 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
680  *
681  * SYNOPSIS
682  *
683  *    void silc_client_get_clients_by_list(SilcClient client,
684  *                                         SilcClientConnection conn,
685  *                                         uint32 list_count,
686  *                                         SilcBuffer client_id_list,
687  *                                         SilcGetClientCallback completion,
688  *                                         void *context);
689  *
690  * DESCRIPTION
691  *
692  *    Gets client entries by the list of client ID's `client_id_list'. This
693  *    always resolves those client ID's it does not know yet from the server
694  *    so this function might take a while. The `client_id_list' is a list
695  *    of ID Payloads added one after other.  JOIN command reply and USERS
696  *    command reply for example returns this sort of list. The `completion'
697  *    will be called after the entries are available. 
698  *
699  ***/
700 void silc_client_get_clients_by_list(SilcClient client,
701                                      SilcClientConnection conn,
702                                      uint32 list_count,
703                                      SilcBuffer client_id_list,
704                                      SilcGetClientCallback completion,
705                                      void *context);
706
707 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
708  *
709  * SYNOPSIS
710  *
711  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
712  *                                                 SilcClientConnection conn,
713  *                                                 SilcClientID *client_id);
714  *
715  * DESCRIPTION
716  *
717  *    Find entry for client by the client's ID. Returns the entry or NULL
718  *    if the entry was not found. 
719  *
720  ***/
721 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
722                                              SilcClientConnection conn,
723                                              SilcClientID *client_id);
724
725 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
726  *
727  * SYNOPSIS
728  *
729  *    void 
730  *    silc_client_get_client_by_id_resolve(SilcClient client,
731  *                                         SilcClientConnection conn,
732  *                                         SilcClientID *client_id,
733  *                                         SilcGetClientCallback completion,
734  *                                         void *context);
735  *
736  * DESCRIPTION
737  *
738  *    Same as silc_client_get_client_by_id but will always resolve the
739  *    information from the server. Use this only if you know that you
740  *    do not have the entry and the only thing you know about the client
741  *    is its ID. 
742  *
743  ***/
744 void silc_client_get_client_by_id_resolve(SilcClient client,
745                                           SilcClientConnection conn,
746                                           SilcClientID *client_id,
747                                           SilcGetClientCallback completion,
748                                           void *context);
749
750 /****f* silcclient/SilcClientAPI/silc_client_get_channel
751  *
752  * SYNOPSIS
753  *
754  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
755  *                                             SilcClientConnection conn,
756  *                                             char *channel);
757  *
758  * DESCRIPTION
759  *
760  *    Finds entry for channel by the channel name. Returns the entry or NULL
761  *    if the entry was not found. It is found only if the client is joined
762  *    to the channel. 
763  *
764  ***/
765 SilcChannelEntry silc_client_get_channel(SilcClient client,
766                                          SilcClientConnection conn,
767                                          char *channel);
768
769
770 /* Command management (command.c) */
771
772 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
773  *
774  * SYNOPSIS
775  *
776  *    SilcClientCommandContext silc_client_command_alloc();
777  *
778  * DESCRIPTION
779  *
780  *    Allocate Command Context. The context is defined in `command.h' file.
781  *    The context is used by the library commands and applications should use
782  *    it as well. However, application may choose to use some own context
783  *    for its local commands. All library commands, however, must use this
784  *    context. 
785  *
786  ***/
787 SilcClientCommandContext silc_client_command_alloc();
788
789 /****f* silcclient/SilcClientAPI/silc_client_command_free
790  *
791  * SYNOPSIS
792  *
793  *    void silc_client_command_free(SilcClientCommandContext ctx);
794  *
795  * DESCRIPTION
796  *
797  *    Free command context and its internals.  If the contex was duplicated
798  *    with silc_client_command_dup this may not actually free the data, 
799  *    instead it will decrease the reference counter of the context.  The
800  *    context will be freed when the reference counter hits zero.
801  *
802  ***/
803 void silc_client_command_free(SilcClientCommandContext ctx);
804
805 /****f* silcclient/SilcClientAPI/silc_client_command_dup
806  *
807  * SYNOPSIS
808  *
809  *    SilcClientCommandContext 
810  *    silc_client_command_dup(SilcClientCommandContext ctx);
811  *
812  * DESCRIPTION
813  *
814  *    Duplicate Command Context by adding reference counter. The context won't
815  *    be free'd untill it hits zero. 
816  *
817  ***/
818 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
819
820 /****f* silcclient/SilcClientAPI/silc_client_command_find
821  *
822  * SYNOPSIS
823  *
824  *    SilcClientCommand *silc_client_command_find(const char *name);
825  *
826  * DESCRIPTION
827  *
828  *    Finds and returns a pointer to the command list. Return NULL if the
829  *    command is not found. See the `command.[ch]' for the command list. 
830  *
831  ***/
832 SilcClientCommand *silc_client_command_find(const char *name);
833
834 /****f* silcclient/SilcClientAPI/silc_client_send_command
835  *
836  * SYNOPSIS
837  *
838  *    void silc_client_send_command(SilcClient client, 
839  *                                  SilcClientConnection conn,
840  *                                  SilcCommand command, uint16 ident,
841  *                                  uint32 argc, ...);
842  *
843  * DESCRIPTION
844  *
845  *    Generic function to send any command. The arguments must be sent already
846  *    encoded into correct form and in correct order. 
847  *
848  ***/
849 void silc_client_send_command(SilcClient client, SilcClientConnection conn,
850                               SilcCommand command, uint16 ident,
851                               uint32 argc, ...);
852
853 /****f* silcclient/SilcClientAPI/SilcClientPendingDestructor
854  *
855  * SYNOPSIS
856  *
857  *    typedef void (*SilcClientPendingDestructor)(void *context);
858  *
859  * DESCRIPTION
860  *
861  *    Pending Command callback destructor. This is called after calling the
862  *    pending callback or if error occurs while processing the pending command.
863  *    If error occurs then the callback won't be called at all, and only this
864  *    destructor is called. The `context' is the context given for the function
865  *    silc_client_command_pending. 
866  *
867  ***/
868 typedef void (*SilcClientPendingDestructor)(void *context);
869
870 /****f* silcclient/SilcClientAPI/silc_client_command_pending
871  *
872  * SYNOPSIS
873  *
874  *    void silc_client_command_pending(SilcClientConnection conn,
875  *                                     SilcCommand reply_cmd,
876  *                                     uint16 ident,
877  *                                     SilcClientPendingDestructor destructor,
878  *                                     SilcCommandCb callback,
879  *                                     void *context);
880  *
881  * DESCRIPTION
882  *
883  *    Add new pending command to be executed when reply to a command has been
884  *    received.  The `reply_cmd' is the command that will call the `callback'
885  *    with `context' when reply has been received.  If `ident is non-zero
886  *    the `callback' will be executed when received reply with command 
887  *    identifier `ident'. 
888  *
889  ***/
890 void silc_client_command_pending(SilcClientConnection conn,
891                                  SilcCommand reply_cmd,
892                                  uint16 ident,
893                                  SilcClientPendingDestructor destructor,
894                                  SilcCommandCb callback,
895                                  void *context);
896
897
898 /* Private Message key management (client_prvmsg.c) */
899
900 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
901  *
902  * SYNOPSIS
903  *
904  *    int silc_client_add_private_message_key(SilcClient client,
905  *                                            SilcClientConnection conn,
906  *                                            SilcClientEntry client_entry,
907  *                                            char *cipher,
908  *                                            unsigned char *key,
909  *                                            uint32 key_len,
910  *                                            int generate_key);
911  *
912  * DESCRIPTION
913  *
914  *    Adds private message key to the client library. The key will be used to
915  *    encrypt all private message between the client and the remote client
916  *    indicated by the `client_entry'. If the `key' is NULL and the boolean
917  *    value `generate_key' is TRUE the library will generate random key.
918  *    The `key' maybe for example pre-shared-key, passphrase or similar.
919  *    The `cipher' MAY be provided but SHOULD be NULL to assure that the
920  *    requirements of the SILC protocol are met. The API, however, allows
921  *    to allocate any cipher.
922  *
923  *    It is not necessary to set key for normal private message usage. If the
924  *    key is not set then the private messages are encrypted using normal
925  *    session keys. Setting the private key, however, increases the security. 
926  *
927  *    Returns FALSE if the key is already set for the `client_entry', TRUE
928  *    otherwise. 
929  *
930  ***/
931 int silc_client_add_private_message_key(SilcClient client,
932                                         SilcClientConnection conn,
933                                         SilcClientEntry client_entry,
934                                         char *cipher,
935                                         unsigned char *key,
936                                         uint32 key_len,
937                                         int generate_key);
938
939 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
940  *
941  * SYNOPSIS
942  *
943  *    int silc_client_add_private_message_key_ske(SilcClient client,
944  *                                                SilcClientConnection conn,
945  *                                                SilcClientEntry client_entry,
946  *                                                char *cipher,
947  *                                                SilcSKEKeyMaterial *key);
948  *
949  * DESCRIPTION
950  *
951  *    Same as above but takes the key material from the SKE key material
952  *    structure. This structure is received if the application uses the
953  *    silc_client_send_key_agreement to negotiate the key material. The
954  *    `cipher' SHOULD be provided as it is negotiated also in the SKE
955  *    protocol. 
956  *
957  ***/
958 int silc_client_add_private_message_key_ske(SilcClient client,
959                                             SilcClientConnection conn,
960                                             SilcClientEntry client_entry,
961                                             char *cipher,
962                                             SilcSKEKeyMaterial *key);
963
964 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
965  *
966  * SYNOPSIS
967  *
968  *    int silc_client_send_private_message_key(SilcClient client,
969  *                                             SilcClientConnection conn,
970  *                                             SilcClientEntry client_entry,
971  *                                             int force_send);
972  *
973  * DESCRIPTION
974  *
975  *    Sends private message key payload to the remote client indicated by
976  *    the `client_entry'. If the `force_send' is TRUE the packet is sent
977  *    immediately. Returns FALSE if error occurs, TRUE otherwise. The
978  *    application should call this function after setting the key to the
979  *    client.
980  *
981  *    Note that the key sent using this function is sent to the remote client
982  *    through the SILC network. The packet is protected using normal session
983  *    keys. 
984  *
985  ***/
986 int silc_client_send_private_message_key(SilcClient client,
987                                          SilcClientConnection conn,
988                                          SilcClientEntry client_entry,
989                                          int force_send);
990
991 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
992  *
993  * SYNOPSIS
994  *
995  *    int silc_client_del_private_message_key(SilcClient client,
996  *                                            SilcClientConnection conn,
997  *                                            SilcClientEntry client_entry);
998  *
999  * DESCRIPTION
1000  *
1001  *    Removes the private message from the library. The key won't be used
1002  *    after this to protect the private messages with the remote `client_entry'
1003  *    client. Returns FALSE on error, TRUE otherwise. 
1004  *
1005  ***/
1006 int silc_client_del_private_message_key(SilcClient client,
1007                                         SilcClientConnection conn,
1008                                         SilcClientEntry client_entry);
1009
1010 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1011  *
1012  * SYNOPSIS
1013  *
1014  *    SilcPrivateMessageKeys
1015  *    silc_client_list_private_message_keys(SilcClient client,
1016  *                                          SilcClientConnection conn,
1017  *                                          uint32 *key_count);
1018  * 
1019  * DESCRIPTION
1020  *
1021  *    Returns array of set private message keys associated to the connection
1022  *    `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1023  *    count to the `key_count' argument. The array must be freed by the caller
1024  *    by calling the silc_client_free_private_message_keys function. Note: 
1025  *    the keys returned in the array is in raw format. It might not be desired
1026  *    to show the keys as is. The application might choose not to show the keys
1027  *    at all or to show the fingerprints of the keys. 
1028  *
1029  ***/
1030 SilcPrivateMessageKeys
1031 silc_client_list_private_message_keys(SilcClient client,
1032                                       SilcClientConnection conn,
1033                                       uint32 *key_count);
1034
1035 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1036  *
1037  * SYNOPSIS
1038  *
1039  *    void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1040  *                                               uint32 key_count);
1041  * 
1042  * DESCRIPTION
1043  *
1044  *    Frees the SilcPrivateMessageKeys array returned by the function
1045  *    silc_client_list_private_message_keys. 
1046  *
1047  ***/
1048 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1049                                            uint32 key_count);
1050
1051
1052 /* Channel private key management (client_channel.c, 
1053    SilcChannelPrivateKey is defined in idlist.h) */
1054
1055 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1056  *
1057  * SYNOPSIS
1058  *
1059  *    int silc_client_add_channel_private_key(SilcClient client,
1060  *                                            SilcClientConnection conn,
1061  *                                            SilcChannelEntry channel,
1062  *                                            char *cipher,
1063  *                                            char *hmac,
1064  *                                            unsigned char *key,
1065  *                                            uint32 key_len);
1066  * 
1067  * DESCRIPTION
1068  *
1069  *    Adds private key for channel. This may be set only if the channel's mode
1070  *    mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1071  *    mode is not set. When channel has private key then the messages are
1072  *    encrypted using that key. All clients on the channel must also know the
1073  *    key in order to decrypt the messages. However, it is possible to have
1074  *    several private keys per one channel. In this case only some of the
1075  *    clients on the channel may know the one key and only some the other key.
1076  *
1077  *    The private key for channel is optional. If it is not set then the
1078  *    channel messages are encrypted using the channel key generated by the
1079  *    server. However, setting the private key (or keys) for the channel 
1080  *    significantly adds security. If more than one key is set the library
1081  *    will automatically try all keys at the message decryption phase. Note:
1082  *    setting many keys slows down the decryption phase as all keys has to
1083  *    be tried in order to find the correct decryption key. However, setting
1084  *    a few keys does not have big impact to the decryption performace. 
1085  *
1086  * NOTES
1087  *
1088  *    NOTE: This is entirely local setting. The key set using this function
1089  *    is not sent to the network at any phase.
1090  *
1091  *    NOTE: If the key material was originated by the SKE protocol (using
1092  *    silc_client_send_key_agreement) then the `key' MUST be the
1093  *    key->send_enc_key as this is dictated by the SILC protocol. However,
1094  *    currently it is not expected that the SKE key material would be used
1095  *    as channel private key. However, this API allows it. 
1096  *
1097  ***/
1098 int silc_client_add_channel_private_key(SilcClient client,
1099                                         SilcClientConnection conn,
1100                                         SilcChannelEntry channel,
1101                                         char *cipher,
1102                                         char *hmac,
1103                                         unsigned char *key,
1104                                         uint32 key_len);
1105
1106 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1107  *
1108  * SYNOPSIS
1109  *
1110  *    int silc_client_del_channel_private_keys(SilcClient client,
1111  *                                             SilcClientConnection conn,
1112  *                                             SilcChannelEntry channel);
1113  * 
1114  * DESCRIPTION
1115  *
1116  *    Removes all private keys from the `channel'. The old channel key is used
1117  *    after calling this to protect the channel messages. Returns FALSE on
1118  *    on error, TRUE otherwise. 
1119  *
1120  ***/
1121 int silc_client_del_channel_private_keys(SilcClient client,
1122                                          SilcClientConnection conn,
1123                                          SilcChannelEntry channel);
1124
1125 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1126  *
1127  * SYNOPSIS
1128  *
1129  *    int silc_client_del_channel_private_key(SilcClient client,
1130  *                                            SilcClientConnection conn,
1131  *                                            SilcChannelEntry channel,
1132  *                                            SilcChannelPrivateKey key);
1133  * 
1134  * DESCRIPTION
1135  *
1136  *    Removes and frees private key `key' from the channel `channel'. 
1137  *    The `key' is retrieved by calling the function 
1138  *    silc_client_list_channel_private_keys. The key is not used after
1139  *    this. If the key was last private key then the old channel key is
1140  *    used hereafter to protect the channel messages. This returns FALSE
1141  *    on error, TRUE otherwise. 
1142  *
1143  ***/
1144 int silc_client_del_channel_private_key(SilcClient client,
1145                                         SilcClientConnection conn,
1146                                         SilcChannelEntry channel,
1147                                         SilcChannelPrivateKey key);
1148
1149 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1150  *
1151  * SYNOPSIS
1152  *
1153  *    SilcChannelPrivateKey *
1154  *    silc_client_list_channel_private_keys(SilcClient client,
1155  *                                          SilcClientConnection conn,
1156  *                                          SilcChannelEntry channel,
1157  *                                          uint32 *key_count);
1158  *
1159  * DESCRIPTION
1160  *
1161  *    Returns array (pointers) of private keys associated to the `channel'.
1162  *    The caller must free the array by calling the function
1163  *    silc_client_free_channel_private_keys. The pointers in the array may be
1164  *    used to delete the specific key by giving the pointer as argument to the
1165  *    function silc_client_del_channel_private_key. 
1166  *
1167  ***/
1168 SilcChannelPrivateKey *
1169 silc_client_list_channel_private_keys(SilcClient client,
1170                                       SilcClientConnection conn,
1171                                       SilcChannelEntry channel,
1172                                       uint32 *key_count);
1173
1174 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1175  *
1176  * SYNOPSIS
1177  *
1178  *    void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1179  *                                               uint32 key_count);
1180  *
1181  * DESCRIPTION
1182  *
1183  *    Frees the SilcChannelPrivateKey array.
1184  *
1185  ***/
1186 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1187                                            uint32 key_count);
1188
1189
1190 /* Key Agreement routines (client_keyagr.c) */
1191
1192 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1193  *
1194  * SYNOPSIS
1195  *
1196  *    void silc_client_send_key_agreement(SilcClient client,
1197  *                                        SilcClientConnection conn,
1198  *                                        SilcClientEntry client_entry,
1199  *                                        char *hostname,
1200  *                                        int port,
1201  *                                        uint32 timeout_secs,
1202  *                                        SilcKeyAgreementCallback completion,
1203  *                                        void *context);
1204  *
1205  * DESCRIPTION
1206  *
1207  *    Sends key agreement request to the remote client indicated by the
1208  *    `client_entry'. If the caller provides the `hostname' and the `port'
1209  *    arguments then the library will bind the client to that hostname and
1210  *    that port for the key agreement protocol. It also sends the `hostname'
1211  *    and the `port' in the key agreement packet to the remote client. This
1212  *    would indicate that the remote client may initiate the key agreement
1213  *    protocol to the `hostname' on the `port'.  If port is zero then the
1214  *    bound port is undefined (the operating system defines it).
1215  *
1216  *    If the `hostname' and `port' is not provided then empty key agreement
1217  *    packet is sent to the remote client. The remote client may reply with
1218  *    the same packet including its hostname and port. If the library receives
1219  *    the reply from the remote client the `key_agreement' client operation
1220  *    callback will be called to verify whether the user wants to perform the
1221  *    key agreement or not. 
1222  *
1223  * NOTES
1224  *
1225  *    NOTE: If the application provided the `hostname' and the `port' and the 
1226  *    remote side initiates the key agreement protocol it is not verified
1227  *    from the user anymore whether the protocol should be executed or not.
1228  *    By setting the `hostname' and `port' the user gives permission to
1229  *    perform the protocol (we are responder in this case).
1230  *
1231  *    NOTE: If the remote side decides not to initiate the key agreement
1232  *    or decides not to reply with the key agreement packet then we cannot
1233  *    perform the key agreement at all. If the key agreement protocol is
1234  *    performed the `completion' callback with the `context' will be called.
1235  *    If remote side decides to ignore the request the `completion' will be
1236  *    called after the specified timeout, `timeout_secs'. 
1237  *
1238  *    NOTE: There can be only one active key agreement for one client entry.
1239  *    Before setting new one, the old one must be finished (it is finished
1240  *    after calling the completion callback) or the function 
1241  *    silc_client_abort_key_agreement must be called. 
1242  *
1243  ***/
1244 void silc_client_send_key_agreement(SilcClient client,
1245                                     SilcClientConnection conn,
1246                                     SilcClientEntry client_entry,
1247                                     char *hostname,
1248                                     int port,
1249                                     uint32 timeout_secs,
1250                                     SilcKeyAgreementCallback completion,
1251                                     void *context);
1252
1253 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1254  *
1255  * SYNOPSIS
1256  *
1257  *    void 
1258  *    silc_client_perform_key_agreement(SilcClient client,
1259  *                                      SilcClientConnection conn,
1260  *                                      SilcClientEntry client_entry,
1261  *                                      char *hostname,
1262  *                                      int port,
1263  *                                      SilcKeyAgreementCallback completion,
1264  *                                      void *context);
1265  *
1266  * DESCRIPTION
1267  *
1268  *    Performs the actual key agreement protocol. Application may use this
1269  *    to initiate the key agreement protocol. This can be called for example
1270  *    after the application has received the `key_agreement' client operation,
1271  *    and did not return TRUE from it.
1272  *
1273  *    The `hostname' is the remote hostname (or IP address) and the `port'
1274  *    is the remote port. The `completion' callback with the `context' will
1275  *    be called after the key agreement protocol.
1276  *
1277  * NOTES
1278  * 
1279  *    NOTE: If the application returns TRUE in the `key_agreement' client
1280  *    operation the library will automatically start the key agreement. In this
1281  *    case the application must not call this function. However, application
1282  *    may choose to just ignore the `key_agreement' client operation (and
1283  *    merely just print information about it on the screen) and call this
1284  *    function when the user whishes to do so (by, for example, giving some
1285  *    specific command). Thus, the API provides both, automatic and manual
1286  *    initiation of the key agreement. Calling this function is the manual
1287  *    initiation and returning TRUE in the `key_agreement' client operation
1288  *    is the automatic initiation. 
1289  *
1290  ***/
1291 void silc_client_perform_key_agreement(SilcClient client,
1292                                        SilcClientConnection conn,
1293                                        SilcClientEntry client_entry,
1294                                        char *hostname,
1295                                        int port,
1296                                        SilcKeyAgreementCallback completion,
1297                                        void *context);
1298
1299 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1300  *
1301  * SYNOPSIS
1302  *
1303  *    void
1304  *    silc_client_perform_key_agreement_fd(SilcClient client,
1305  *                                         SilcClientConnection conn,
1306  *                                         SilcClientEntry client_entry,
1307  *                                         int sock,
1308  *                                         char *hostname,
1309  *                                         SilcKeyAgreementCallback completion,
1310  *                                         void *context);
1311  *
1312  * DESCRIPTION
1313  *
1314  *    Same as above but application has created already the connection to 
1315  *    the remote host. The `sock' is the socket to the remote connection. 
1316  *    Application can use this function if it does not want the client library
1317  *    to create the connection. 
1318  *
1319  ***/
1320 void silc_client_perform_key_agreement_fd(SilcClient client,
1321                                           SilcClientConnection conn,
1322                                           SilcClientEntry client_entry,
1323                                           int sock,
1324                                           char *hostname,
1325                                           SilcKeyAgreementCallback completion,
1326                                           void *context);
1327
1328 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1329  *
1330  * SYNOPSIS
1331  *
1332  *    void silc_client_abort_key_agreement(SilcClient client,
1333  *                                         SilcClientConnection conn,
1334  *                                         SilcClientEntry client_entry);
1335  *
1336  * DESCRIPTION
1337  *
1338  *    This function can be called to unbind the hostname and the port for
1339  *    the key agreement protocol. However, this function has effect only 
1340  *    before the key agreement protocol has been performed. After it has
1341  *    been performed the library will automatically unbind the port. The 
1342  *    `client_entry' is the client to which we sent the key agreement 
1343  *    request. 
1344  *
1345  ***/
1346 void silc_client_abort_key_agreement(SilcClient client,
1347                                      SilcClientConnection conn,
1348                                      SilcClientEntry client_entry);
1349
1350
1351 /* Misc functions */
1352
1353 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1354  *
1355  * SYNOPSIS
1356  *
1357  *    void silc_client_set_away_message(SilcClient client,
1358  *                                      SilcClientConnection conn,
1359  *                                      char *message);
1360  *
1361  * DESCRIPTION
1362  *
1363  *    Sets away `message'.  The away message may be set when the client's
1364  *    mode is changed to SILC_UMODE_GONE and the client whishes to reply
1365  *    to anyone who sends private message.  The `message' will be sent
1366  *    automatically back to the the client who send private message.  If
1367  *    away message is already set this replaces the old message with the
1368  *    new one.  If `message' is NULL the old away message is removed. 
1369  *    The sender may freely free the memory of the `message'. 
1370  *
1371  ***/
1372 void silc_client_set_away_message(SilcClient client,
1373                                   SilcClientConnection conn,
1374                                   char *message);
1375
1376 #endif