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