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