Moved util routines for BeOS from Unix, instead of using them
[silc.git] / lib / silcclient / silcapi.h
1 /*
2
3   silcapi.h
4   
5   Author: Pekka Riikonen <priikone@silcnet.org>
6   
7   Copyright (C) 2000 - 2001 Pekka Riikonen
8   
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13  
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 /****h* silcclient/SilcClientAPI
22  *
23  * DESCRIPTION
24  *
25  * This interface defines the SILC Client Library API for the application.
26  * The 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   SILC_KEY_AGREEMENT_ABORTED,          /* The protocol aborted */
78 } SilcKeyAgreementStatus;
79 /***/
80
81 /****f* silcclient/SilcClientAPI/SilcKeyAgreementCallback
82  *
83  * SYNOPSIS
84  *
85  *    typedef void (*SilcKeyAgreementCallback)(SilcClient client,
86  *                                             SilcClientConnection conn,
87  *                                             SilcClientEntry client_entry,
88  *                                             SilcKeyAgreementStatus status,
89  *                                             SilcSKEKeyMaterial *key,
90  *                                             void *context);
91  *
92  * DESCRIPTION
93  *
94  *    Key agreement callback that is called after the key agreement protocol
95  *    has been performed. This is called also if error occurred during the
96  *    key agreement protocol. The `key' is the allocated key material and
97  *    the caller is responsible of freeing it. The `key' is NULL if error
98  *    has occurred. The application can freely use the `key' to whatever
99  *    purpose it needs. See lib/silcske/silcske.h for the definition of
100  *    the SilcSKEKeyMaterial structure.
101  *
102  ***/
103 typedef void (*SilcKeyAgreementCallback)(SilcClient client,
104                                          SilcClientConnection conn,
105                                          SilcClientEntry client_entry,
106                                          SilcKeyAgreementStatus status,
107                                          SilcSKEKeyMaterial *key,
108                                          void *context);
109
110 /****s* silcclient/SilcClientAPI/SilcPrivateMessageKeys
111  *
112  * NAME
113  *
114  *    typedef struct { ... } SilcPrivateMessageKeys;
115  *
116  * DESCRIPTION
117  *
118  *    Structure to hold the list of private message keys. The array of this
119  *    structure is returned by the silc_client_list_private_message_keys
120  *    function.
121  *
122  * SOURCE
123  */
124 typedef struct {
125   SilcClientEntry client_entry;       /* The remote client entry */
126   char *cipher;                       /* The cipher name */
127   unsigned char *key;                 /* The original key, If the appliation
128                                          provided it. This is NULL if the
129                                          library generated the key or if
130                                          the SKE key material was used. */
131   uint32 key_len;                     /* The key length */
132 } *SilcPrivateMessageKeys;
133 /***/
134
135
136 /****f* silcclient/SilcClientAPI/SilcAskPassphrase
137  *
138  * SYNOPSIS
139  *
140  *    typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
141  *                                      uint32 passphrase_len,
142  *                                      void *context);
143  *
144  * DESCRIPTION
145  *
146  *    Ask passphrase callback. This is called by the application when the
147  *    library calls `ask_passphrase' client operation.  The callback delivers
148  *    the passphrase to the library.
149  *
150  ***/
151 typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
152                                   uint32 passphrase_len,
153                                   void *context);
154
155 /****f* silcclient/SilcClientAPI/SilcVerifyPublicKey
156  *
157  * SYNOPSIS
158  *
159  *    typedef void (*SilcVerifyPublicKey)(bool success, void *context);
160  *
161  * DESCRIPTION
162  *
163  *    Public key (or certificate) verification callback. This is called
164  *    by the application to indicate that the public key verification was
165  *    either success or failure.
166  *
167  ***/
168 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
169
170 /****f* silcclient/SilcClientAPI/SilcGetAuthMeth
171  *
172  * SYNOPSIS
173  *
174  *    typedef void (*SilcGetAuthMeth)(bool success, 
175  *                                    SilcProtocolAuthMeth auth_meth,
176  *                                    const unsigned char *auth_data,
177  *                                    uint32 auth_data_len, void *context);
178  * 
179  * DESCRIPTION
180  *
181  *    Authentication method resolving callback. This is called by the
182  *    application to return the resolved authentication method. The client
183  *    library has called the get_auth_method client operation and given
184  *    this function pointer as argument. The `success' will indicate whether
185  *    the authentication method could be resolved. The `auth_meth' is the
186  *    resolved authentication method. The `auth_data' and the `auth_data_len'
187  *    are the resolved authentication data. The `context' is the libary's
188  *    context sent to the get_auth_method client operation.
189  *
190  ***/
191 typedef void (*SilcGetAuthMeth)(bool success, 
192                                 SilcProtocolAuthMeth auth_meth,
193                                 const unsigned char *auth_data,
194                                 uint32 auth_data_len, void *context);
195
196 /****d* silcclient/SilcClientAPI/SilcClientMessageType
197  *
198  * NAME
199  *
200  *    typedef enum { ... } SilcClientMessageType;
201  *
202  * DESCRIPTION
203  *
204  *    Different message types for `say' client operation.  The application
205  *    may filter the message sent by the library according this type.
206  *
207  * SOURCE
208  */
209 typedef enum {
210   SILC_CLIENT_MESSAGE_INFO,            /* Informational */
211   SILC_CLIENT_MESSAGE_WARNING,         /* Warning */
212   SILC_CLIENT_MESSAGE_ERROR,           /* Error */
213   SILC_CLIENT_MESSAGE_AUDIT,           /* Auditable */
214 } SilcClientMessageType;
215 /***/
216
217 /****s* silcclient/SilcClientAPI/SilcClientOperations
218  *
219  * NAME
220  *
221  *    typedef struct { ... } SilcClientOperations;
222  *
223  * DESCRIPTION
224  *
225  *    SILC Client Operations. These must be implemented by the application.
226  *    The Client library may call any of these routines at any time.  The
227  *    routines are used to deliver certain information to the application
228  *    or from the application to the client library.
229  *
230  * SOURCE
231  */
232 typedef struct {
233   /* Message sent to the application by library. `conn' associates the
234      message to a specific connection.  `conn', however, may be NULL. 
235      The `type' indicates the type of the message sent by the library.
236      The applicationi can for example filter the message according the
237      type. */
238   void (*say)(SilcClient client, SilcClientConnection conn, 
239               SilcClientMessageType type, char *msg, ...);
240
241   /* Message for a channel. The `sender' is the sender of the message 
242      The `channel' is the channel. The `msg' is the message.  Note that
243      `msg' maybe NULL. */
244   void (*channel_message)(SilcClient client, SilcClientConnection conn, 
245                           SilcClientEntry sender, SilcChannelEntry channel, 
246                           SilcMessageFlags flags, char *msg);
247
248   /* Private message to the client. The `sender' is the sender of the
249      message. */
250   void (*private_message)(SilcClient client, SilcClientConnection conn,
251                           SilcClientEntry sender, SilcMessageFlags flags,
252                           char *msg);
253
254   /* Notify message to the client. The notify arguments are sent in the
255      same order as servers sends them. The arguments are same as received
256      from the server except for ID's.  If ID is received application receives
257      the corresponding entry to the ID. For example, if Client ID is received
258      application receives SilcClientEntry.  Also, if the notify type is
259      for channel the channel entry is sent to application (even if server
260      does not send it because client library gets the channel entry from
261      the Channel ID in the packet's header). */
262   void (*notify)(SilcClient client, SilcClientConnection conn, 
263                  SilcNotifyType type, ...);
264
265   /* Command handler. This function is called always in the command function.
266      If error occurs it will be called as well. `conn' is the associated
267      client connection. `cmd_context' is the command context that was
268      originally sent to the command. `success' is FALSE if error occurred
269      during command. `command' is the command being processed. It must be
270      noted that this is not reply from server. This is merely called just
271      after application has called the command. Just to tell application
272      that the command really was processed. */
273   void (*command)(SilcClient client, SilcClientConnection conn, 
274                   SilcClientCommandContext cmd_context, int success,
275                   SilcCommand command);
276
277   /* Command reply handler. This function is called always in the command reply
278      function. If error occurs it will be called as well. Normal scenario
279      is that it will be called after the received command data has been parsed
280      and processed. The function is used to pass the received command data to
281      the application. 
282      
283      `conn' is the associated client connection. `cmd_payload' is the command
284      payload data received from server and it can be ignored. It is provided
285      if the application would like to re-parse the received command data,
286      however, it must be noted that the data is parsed already by the library
287      thus the payload can be ignored. `success' is FALSE if error occurred.
288      In this case arguments are not sent to the application. The `status' is
289      the command reply status server returned. The `command' is the command
290      reply being processed. The function has variable argument list and each
291      command defines the number and type of arguments it passes to the
292      application (on error they are not sent). */
293   void (*command_reply)(SilcClient client, SilcClientConnection conn,
294                         SilcCommandPayload cmd_payload, int success,
295                         SilcCommand command, SilcCommandStatus status, ...);
296
297   /* Called to indicate that connection was either successfully established
298      or connecting failed.  This is also the first time application receives
299      the SilcClientConnection objecet which it should save somewhere.
300      If the `success' is FALSE the application must always call the function
301      silc_client_close_connection. */
302   void (*connect)(SilcClient client, SilcClientConnection conn, int success);
303
304   /* Called to indicate that connection was disconnected to the server. */
305   void (*disconnect)(SilcClient client, SilcClientConnection conn);
306
307   /* Find authentication method and authentication data by hostname and
308      port. The hostname may be IP address as well. When the authentication
309      method has been resolved the `completion' callback with the found
310      authentication method and authentication data is called. The `conn'
311      may be NULL. */
312   void (*get_auth_method)(SilcClient client, SilcClientConnection conn,
313                           char *hostname, uint16 port,
314                           SilcGetAuthMeth completion, void *context);
315
316   /* Verifies received public key. The `conn_type' indicates which entity
317      (server, client etc.) has sent the public key. If user decides to trust
318      the key may be saved as trusted public key for later use. The 
319      `completion' must be called after the public key has been verified. */
320   void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
321                             SilcSocketType conn_type, unsigned char *pk, 
322                             uint32 pk_len, SilcSKEPKType pk_type,
323                             SilcVerifyPublicKey completion, void *context);
324
325   /* Ask (interact, that is) a passphrase from user. The passphrase is
326      returned to the library by calling the `completion' callback with
327      the `context'. */
328   void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
329                          SilcAskPassphrase completion, void *context);
330
331   /* Notifies application that failure packet was received.  This is called
332      if there is some protocol active in the client.  The `protocol' is the
333      protocol context.  The `failure' is opaque pointer to the failure
334      indication.  Note, that the `failure' is protocol dependant and
335      application must explicitly cast it to correct type.  Usually `failure'
336      is 32 bit failure type (see protocol specs for all protocol failure
337      types). */
338   void (*failure)(SilcClient client, SilcClientConnection conn, 
339                   SilcProtocol protocol, void *failure);
340
341   /* Asks whether the user would like to perform the key agreement protocol.
342      This is called after we have received an key agreement packet or an
343      reply to our key agreement packet. This returns TRUE if the user wants
344      the library to perform the key agreement protocol and FALSE if it is not
345      desired (application may start it later by calling the function
346      silc_client_perform_key_agreement). If TRUE is returned also the
347      `completion' and `context' arguments must be set by the application. */
348   int (*key_agreement)(SilcClient client, SilcClientConnection conn,
349                        SilcClientEntry client_entry, const char *hostname,
350                        uint16 port, SilcKeyAgreementCallback *completion,
351                        void **context);
352
353   /* Notifies application that file transfer protocol session is being
354      requested by the remote client indicated by the `client_entry' from
355      the `hostname' and `port'. The `session_id' is the file transfer
356      session and it can be used to either accept or reject the file
357      transfer request, by calling the silc_client_file_receive or
358      silc_client_file_close, respectively. */
359   void (*ftp)(SilcClient client, SilcClientConnection conn,
360               SilcClientEntry client_entry, uint32 session_id,
361               const char *hostname, uint16 port);
362 } SilcClientOperations;
363 /***/
364
365 /****f* silcclient/SilcClientAPI/SilcNicknameFormatParse
366  *
367  * SYNOPSIS
368  *
369  *    typedef void (*SilcNicknameFormatParse)(const char *nickname,
370  *                                            char **ret_nickname);
371  *
372  * DESCRIPTION
373  *
374  *    A callback function provided by the application for the library in
375  *    SilcClientParams structure. This function parses the formatted
376  *    nickname string `nickname' and returns the true nickname to the
377  *    `ret_nickname' pointer. The library can call this function at
378  *    any time.
379  *
380  ***/
381 typedef void (*SilcNicknameFormatParse)(const char *nickname,
382                                         char **ret_nickname);
383
384 /****s* silcclient/SilcClientAPI/SilcClientParams
385  *
386  * NAME
387  *
388  *    typedef struct { ... } SilcClientParams;
389  *
390  * DESCRIPTION
391  *
392  *    Client parameters. This can be filled with proper values and
393  *    given as argument to the silc_client_alloc function. The structure
394  *    hold various parameters which affects the function of the client.
395  *
396  * SOURCE
397  */
398 typedef struct {
399   /* Number of maximum tasks the client library's scheduler can handle.
400      If set to zero, the default value will be used (200). For WIN32
401      systems this should be set to 64 as it is the hard limit dictated
402      by the WIN32. */
403   int task_max;
404
405   /* Rekey timeout in seconds. The client will perform rekey in this
406      time interval. If set to zero, the default value will be used. */
407   unsigned int rekey_secs;
408
409   /* Connection authentication method request timeout. If server does not
410      reply back the current authentication method when we've requested it
411      in this time interval we'll assume the reply will not come at all. 
412      If set to zero, the default value (2 seconds) will be used. */
413   unsigned int connauth_request_secs;
414
415   /* Nickname format string. This can be used to order the client library
416      to save the nicknames in the library in a certain format. Since 
417      nicknames are not unique in SILC it is possible to have multiple same
418      nicknames. Using this format string it is possible to order the library
419      to separate the multiple same nicknames from each other. The format
420      types are defined below and they can appear in any order in the format
421      string. If this is NULL then default format is used which is the
422      default nickname without anything else. The string MUST be NULL
423      terminated.
424      
425      Following format types are available:
426      
427      %n  nickname      - the real nickname returned by the server (mandatory)
428      %h  hostname      - the stripped hostname of the client
429      %H  full hostname - the full hostname of the client
430      %s  server name   - the server name the client is connected
431      %S  full server   - the full server name the client is connected
432      %a  number        - ascending number in case there are several
433                          same nicknames (fe. nick@host and nick@host2)
434
435      Example format strings: "%n@%h%a"   (fe. nick@host, nick@host2)
436                              "%a!%n@%s"  (fe. nick@server, 2!nick@server)
437                              "%n@%H"     (fe. nick@host.domain.com)
438
439      By default this format is employed to the nicknames by the libary
440      only when there appears multiple same nicknames. If the library has
441      only one nickname cached the nickname is saved as is and without the
442      defined format. If you want always to save the nickname in the defined
443      format set the boolean field `nickname_force_format' to value TRUE.
444   */
445   char nickname_format[32];
446
447   /* If this is set to TRUE then the `nickname_format' is employed to all
448      saved nicknames even if there are no multiple same nicknames in the 
449      cache. By default this is FALSE, which means that the `nickname_format'
450      is employed only if the library will receive a nickname that is
451      already saved in the cache. It is recommended to leave this to FALSE
452      value. */
453   bool nickname_force_format;
454
455   /* A callback function provided by the application for the library to
456      parse the nickname from the formatted nickname string. Even though
457      the libary formats the nicknames the application knows generally the
458      format better so this function should be provided for the library
459      if the application sets the `nickname_format' field. The library
460      will call this to get the true nickname from the provided formatted
461      nickname string whenever it needs the true nickname. */
462   SilcNicknameFormatParse nickname_parse;
463
464 } SilcClientParams;
465 /***/
466
467
468 /* Initialization functions (client.c) */
469
470 /****f* silcclient/SilcClientAPI/silc_client_alloc
471  *
472  * SYNOPSIS
473  *
474  *    SilcClient silc_client_alloc(SilcClientOperations *ops, 
475  *                                 SilcClientParams *params,
476  *                                 void *application,
477  *                                 const char *silc_version);
478  *
479  * DESCRIPTION
480  *
481  *    Allocates new client object. This has to be done before client may
482  *    work. After calling this one must call silc_client_init to initialize
483  *    the client. The `application' is application specific user data pointer
484  *    and caller must free it. The `silc_version' is the application version
485  *    that will be used to compare against remote host's (usually a server)
486  *    version string.
487  *
488  ***/
489 SilcClient silc_client_alloc(SilcClientOperations *ops, 
490                              SilcClientParams *params,
491                              void *application,
492                              const char *silc_version);
493
494 /****f* silcclient/SilcClientAPI/silc_client_free
495  *
496  * SYNOPSIS
497  *
498  *    void silc_client_free(SilcClient client);
499  *
500  * DESCRIPTION
501  *
502  *    Frees client object and its internals.  The execution of the client
503  *    should be stopped with silc_client_stop function before calling
504  *    this function.
505  *
506  ***/
507 void silc_client_free(SilcClient client);
508
509 /****f* silcclient/SilcClientAPI/silc_client_init
510  *
511  * SYNOPSIS
512  *
513  *    int silc_client_init(SilcClient client);
514  *
515  * DESCRIPTION
516  *
517  *    Initializes the client. This makes all the necessary steps to make
518  *    the client ready to be run. One must call silc_client_run to run the
519  *    client. Returns FALSE if error occurred, TRUE otherwise.
520  *
521  ***/
522 int silc_client_init(SilcClient client);
523
524 /****f* silcclient/SilcClientAPI/silc_client_run
525  *
526  * SYNOPSIS
527  *
528  *    void silc_client_run(SilcClient client);
529  *
530  * DESCRIPTION
531  *
532  *    Runs the client. This starts the scheduler from the utility library.
533  *    When this functions returns the execution of the appliation is over.
534  *
535  ***/
536 void silc_client_run(SilcClient client);
537
538 /****f* silcclient/SilcClientAPI/silc_client_run_one
539  *
540  * SYNOPSIS
541  *
542  *    void silc_client_run_one(SilcClient client);
543  *
544  * DESCRIPTION
545  *
546  *    Runs the client and returns immeadiately. This function is used when
547  *    the SILC Client object indicated by the `client' is run under some
548  *    other scheduler, or event loop or main loop.  On GUI applications,
549  *    for example this may be desired to used to run the client under the
550  *    GUI application's main loop.  Typically the GUI application would
551  *    register an idle task that calls this function multiple times in
552  *    a second to quickly process the SILC specific data.
553  *
554  ***/
555 void silc_client_run_one(SilcClient client);
556
557 /****f* silcclient/SilcClientAPI/silc_client_stop
558  *
559  * SYNOPSIS
560  *
561  *    void silc_client_stop(SilcClient client);
562  *
563  * DESCRIPTION
564  *
565  *    Stops the client. This is called to stop the client and thus to stop
566  *    the program.  The client context must be freed with the silc_client_free
567  *    function.
568  *
569  ***/
570 void silc_client_stop(SilcClient client);
571
572
573 /* Connecting functions (client.c) */
574
575 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
576  *
577  * SYNOPSIS
578  *
579  *    int silc_client_connect_to_server(SilcClient client, int port,
580  *                                      char *host, void *context);
581  *
582  * DESCRIPTION
583  *
584  *    Connects to remote server. This is the main routine used to connect
585  *    to SILC server. Returns -1 on error and the created socket otherwise. 
586  *    The `context' is user context that is saved into the SilcClientConnection
587  *    that is created after the connection is created. Note that application
588  *    may handle the connecting process outside the library. If this is the
589  *    case then this function is not used at all. When the connecting is
590  *    done the `connect' client operation is called.
591  *
592  ***/
593 int silc_client_connect_to_server(SilcClient client, int port,
594                                   char *host, void *context);
595
596 /****f* silcclient/SilcClientAPI/silc_client_add_connection
597  *
598  * SYNOPSIS
599  *
600  *    SilcClientConnection silc_client_add_connection(SilcClient client,
601  *                                                    char *hostname,
602  *                                                    int port,
603  *                                                    void *context);
604  *
605  * DESCRIPTION
606  *
607  *    Allocates and adds new connection to the client. This adds the allocated
608  *    connection to the connection table and returns a pointer to it. A client
609  *    can have multiple connections to multiple servers. Every connection must
610  *    be added to the client using this function. User data `context' may
611  *    be sent as argument. This function is normally used only if the 
612  *    application performed the connecting outside the library. The library
613  *    however may use this internally.
614  *
615  ***/
616 SilcClientConnection silc_client_add_connection(SilcClient client,
617                                                 char *hostname,
618                                                 int port,
619                                                 void *context);
620
621 /****f* silcclient/SilcClientAPI/silc_client_del_connection
622  *
623  * SYNOPSIS
624  *
625  *    void silc_client_del_connection(SilcClient client, 
626  *                                    SilcClientConnection conn);
627  *
628  * DESCRIPTION
629  *
630  *    Removes connection from client. Frees all memory. The library
631  *    call this function automatically for all connection contexts.
632  *    The application however may free the connection contexts it has
633  *    allocated.
634  *
635  ***/
636 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
637
638 /****f* silcclient/SilcClientAPI/silc_client_add_socket
639  *
640  * SYNOPSIS
641  *
642  *    void silc_client_add_socket(SilcClient client, 
643  *                                SilcSocketConnection sock);
644  *
645  * DESCRIPTION
646  *
647  *    Adds listener socket to the listener sockets table. This function is
648  *    used to add socket objects that are listeners to the client.  This should
649  *    not be used to add other connection objects.
650  *
651  ***/
652 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
653
654 /****f* silcclient/SilcClientAPI/silc_client_del_socket
655  *
656  * SYNOPSIS
657  *
658  *    void silc_client_del_socket(SilcClient client, 
659  *                                SilcSocketConnection sock);
660  *
661  * DESCRIPTION
662  *
663  *    Deletes listener socket from the listener sockets table.  If the
664  *    application has added a socket with silc_client_add_socket it must
665  *    also free it using this function.
666  *
667  ***/
668 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
669
670 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
671  *
672  * SYNOPSIS
673  *
674  *    void silc_client_start_key_exchange(SilcClient client,
675  *                                        SilcClientConnection conn,
676  *                                        int fd);
677  *
678  * DESCRIPTION
679  *
680  *    Start SILC Key Exchange (SKE) protocol to negotiate shared secret
681  *    key material between client and server.  This function can be called
682  *    directly if application is performing its own connecting and does not
683  *    use the connecting provided by this library. This function is normally
684  *    used only if the application performed the connecting outside the
685  *    library. The library however may use this internally. Returns FALSE
686  *    if the key exchange could not be started.
687  *
688  ***/
689 void silc_client_start_key_exchange(SilcClient client,
690                                     SilcClientConnection conn,
691                                     int fd);
692
693 /****f* silcclient/SilcClientAPI/silc_client_close_connection
694  *
695  * SYNOPSIS
696  *
697  *    void silc_client_close_connection(SilcClient client,
698  *                                      SilcSocketConnection sock,
699  *                                      SilcClientConnection conn);
700  *
701  * DESCRIPTION
702  *
703  *    Closes connection to remote end. Free's all allocated data except
704  *    for some information such as nickname etc. that are valid at all time. 
705  *    If the `sock' is NULL then the conn->sock will be used.  If `sock' is
706  *    provided it will be checked whether the sock and `conn->sock' are the
707  *    same (they can be different, ie. a socket can use `conn' as its
708  *    connection but `conn->sock' might be actually a different connection
709  *    than the `sock'). 
710  *
711  ***/
712 void silc_client_close_connection(SilcClient client,
713                                   SilcSocketConnection sock,
714                                   SilcClientConnection conn);
715
716
717 /* Message sending functions (client_channel.c and client_prvmsg.c) */
718
719 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
720  *
721  * SYNOPSIS
722  *
723  *    void silc_client_send_channel_message(SilcClient client, 
724  *                                          SilcClientConnection conn,
725  *                                          SilcChannelEntry channel,
726  *                                          SilcChannelPrivateKey key,
727  *                                          SilcMessageFlags flags,
728  *                                          unsigned char *data, 
729  *                                          uint32 data_len, 
730  *                                          int force_send);
731  *
732  * DESCRIPTION
733  *
734  *    Sends packet to the `channel'. Packet to channel is always encrypted
735  *    differently from "normal" packets. SILC header of the packet is 
736  *    encrypted with the next receiver's key and the rest of the packet is
737  *    encrypted with the channel specific key. Padding and HMAC is computed
738  *    with the next receiver's key. The `data' is the channel message. If
739  *    the `force_send' is TRUE then the packet is sent immediately. 
740  *
741  *    If `key' is provided then that private key is used to encrypt the
742  *    channel message.  If it is not provided, private keys has not been
743  *    set at all, the normal channel key is used automatically.  If private
744  *    keys are set then the first key (the key that was added first as
745  *    private key) is used. 
746  *
747  ***/
748 void silc_client_send_channel_message(SilcClient client, 
749                                       SilcClientConnection conn,
750                                       SilcChannelEntry channel,
751                                       SilcChannelPrivateKey key,
752                                       SilcMessageFlags flags,
753                                       unsigned char *data, 
754                                       uint32 data_len, 
755                                       int force_send);
756
757 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
758  *
759  * SYNOPSIS
760  *
761  *    void silc_client_send_private_message(SilcClient client,
762  *                                          SilcClientConnection conn,
763  *                                          SilcClientEntry client_entry,
764  *                                          SilcMessageFlags flags,
765  *                                          unsigned char *data, 
766  *                                          uint32 data_len, 
767  *                                          int force_send);
768  *
769  * DESCRIPTION
770  *
771  *    Sends private message to remote client. If private message key has
772  *    not been set with this client then the message will be encrypted using
773  *    normal session keys. Private messages are special packets in SILC
774  *    network hence we need this own function for them. This is similar
775  *    to silc_client_packet_send_to_channel except that we send private
776  *    message. The `data' is the private message. If the `force_send' is
777  *    TRUE the packet is sent immediately. 
778  *
779  ***/
780 void silc_client_send_private_message(SilcClient client,
781                                       SilcClientConnection conn,
782                                       SilcClientEntry client_entry,
783                                       SilcMessageFlags flags,
784                                       unsigned char *data, 
785                                       uint32 data_len, 
786                                       int force_send);
787
788
789 /* Client and Channel entry retrieval (idlist.c) */
790
791 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
792  *
793  * SYNOPSIS
794  *
795  *    typedef void (*SilcGetClientCallback)(SilcClient client,
796  *                                          SilcClientConnection conn,
797  *                                          SilcClientEntry *clients,
798  *                                          uint32 clients_count,
799  *                                          void *context);
800  *
801  * DESCRIPTION
802  *
803  *    Callback function given to the silc_client_get_client function. The
804  *    found entries are allocated into the `clients' array. The array must
805  *    not be freed by the receiver, the library will free it later. If the
806  *    `clients' is NULL, no such clients exist in the SILC Network.
807  *
808  ***/
809 typedef void (*SilcGetClientCallback)(SilcClient client,
810                                       SilcClientConnection conn,
811                                       SilcClientEntry *clients,
812                                       uint32 clients_count,
813                                       void *context);
814
815 /****f* silcclient/SilcClientAPI/silc_client_get_clients
816  *
817  * SYNOPSIS
818  *
819  *    void silc_client_get_clients(SilcClient client,
820  *                                 SilcClientConnection conn,
821  *                                 const char *nickname,
822  *                                 const char *server,
823  *                                 SilcGetClientCallback completion,
824  *                                 void *context);
825  *
826  * DESCRIPTION
827  *
828  *    Finds client entry or entries by the `nickname' and `server'. The 
829  *    completion callback will be called when the client entries has been
830  *    found.  After the server returns the client information it is cached
831  *    and can be accesses locally at a later time.
832  *
833  * NOTES
834  *
835  *    NOTE: This function is always asynchronous and resolves the client
836  *    information from the server. Thus, if you already know the client
837  *    information then use the silc_client_get_client_by_id function to
838  *    get the client entry since this function may be very slow and should
839  *    be used only to initially get the client entries. 
840  *
841  ***/
842 void silc_client_get_clients(SilcClient client,
843                              SilcClientConnection conn,
844                              const char *nickname,
845                              const char *server,
846                              SilcGetClientCallback completion,
847                              void *context);
848
849 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
850  *
851  * SYNOPSIS
852  *
853  *    SilcClientEntry *silc_client_get_clients_local(SilcClient client,
854  *                                                   SilcClientConnection conn,
855  *                                                   const char *nickname,
856  *                                                   const char *format,
857  *                                                   uint32 *clients_count);
858  *
859  * DESCRIPTION
860  *
861  *    Same as silc_client_get_clients function but does not resolve anything
862  *    from the server. This checks local cache and returns all matching
863  *    clients from the local cache. If none was found this returns NULL.
864  *    The `nickname' is the real nickname of the client, and the `format'
865  *    is the formatted nickname to find exact match from multiple found
866  *    entries. The format must be same as given in the SilcClientParams
867  *    structure to the client library. If the `format' is NULL all found
868  *    clients by `nickname' are returned. The caller must return the
869  *    returned array.
870  *
871  ***/
872 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
873                                                SilcClientConnection conn,
874                                                const char *nickname,
875                                                const char *format,
876                                                uint32 *clients_count);
877
878 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
879  *
880  * SYNOPSIS
881  *
882  *    void silc_client_get_clients_by_list(SilcClient client,
883  *                                         SilcClientConnection conn,
884  *                                         uint32 list_count,
885  *                                         SilcBuffer client_id_list,
886  *                                         SilcGetClientCallback completion,
887  *                                         void *context);
888  *
889  * DESCRIPTION
890  *
891  *    Gets client entries by the list of client ID's `client_id_list'. This
892  *    always resolves those client ID's it does not know yet from the server
893  *    so this function might take a while. The `client_id_list' is a list
894  *    of ID Payloads added one after other.  JOIN command reply and USERS
895  *    command reply for example returns this sort of list. The `completion'
896  *    will be called after the entries are available. When server returns
897  *    the client information it will be cached and can be accessed locally
898  *    at a later time.
899  *
900  ***/
901 void silc_client_get_clients_by_list(SilcClient client,
902                                      SilcClientConnection conn,
903                                      uint32 list_count,
904                                      SilcBuffer client_id_list,
905                                      SilcGetClientCallback completion,
906                                      void *context);
907
908 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
909  *
910  * SYNOPSIS
911  *
912  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
913  *                                                 SilcClientConnection conn,
914  *                                                 SilcClientID *client_id);
915  *
916  * DESCRIPTION
917  *
918  *    Find entry for client by the client's ID. Returns the entry or NULL
919  *    if the entry was not found.  This checks the local cache and does
920  *    not resolve anything from server.
921  *
922  ***/
923 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
924                                              SilcClientConnection conn,
925                                              SilcClientID *client_id);
926
927 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
928  *
929  * SYNOPSIS
930  *
931  *    void 
932  *    silc_client_get_client_by_id_resolve(SilcClient client,
933  *                                         SilcClientConnection conn,
934  *                                         SilcClientID *client_id,
935  *                                         SilcGetClientCallback completion,
936  *                                         void *context);
937  *
938  * DESCRIPTION
939  *
940  *    Same as silc_client_get_client_by_id but will always resolve the
941  *    information from the server. Use this only if you know that you
942  *    do not have the entry and the only thing you know about the client
943  *    is its ID. When server returns the client information it will be
944  *    cache and can be accessed locally at a later time.
945  *
946  ***/
947 void silc_client_get_client_by_id_resolve(SilcClient client,
948                                           SilcClientConnection conn,
949                                           SilcClientID *client_id,
950                                           SilcGetClientCallback completion,
951                                           void *context);
952
953 /****f* silcclient/SilcClientAPI/silc_client_del_client
954  *
955  * SYNOPSIS
956  *
957  *    bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
958  *                                SilcClientEntry client_entry)
959  *
960  * DESCRIPTION
961  *
962  *    Removes client from local cache by the client entry indicated by
963  *    the `client_entry'.  Returns TRUE if the deletion were successful.
964  *
965  ***/
966 bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
967                             SilcClientEntry client_entry);
968
969 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
970  *
971  * SYNOPSIS
972  *
973  *    typedef void (*SilcGetChannelCallback)(SilcClient client,
974  *                                           SilcClientConnection conn,
975  *                                           SilcChannelEntry *channels,
976  *                                           uint32 channels_count,
977  *                                           void *context);
978  *
979  * DESCRIPTION
980  *
981  *    Callback function given to the silc_client_get_channel_* functions.
982  *    The found entries are allocated into the `channels' array. The array
983  *    must not be freed by the receiver, the library will free it later.
984  *    If the `channel' is NULL, no such channel exist in the SILC Network.
985  *
986  ***/
987 typedef void (*SilcGetChannelCallback)(SilcClient client,
988                                        SilcClientConnection conn,
989                                        SilcChannelEntry *channels,
990                                        uint32 channels_count,
991                                        void *context);
992
993 /****f* silcclient/SilcClientAPI/silc_client_get_channel
994  *
995  * SYNOPSIS
996  *
997  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
998  *                                             SilcClientConnection conn,
999  *                                             char *channel);
1000  *
1001  * DESCRIPTION
1002  *
1003  *    Finds entry for channel by the channel name. Returns the entry or NULL
1004  *    if the entry was not found. It is found only if the client is joined
1005  *    to the channel. 
1006  *
1007  ***/
1008 SilcChannelEntry silc_client_get_channel(SilcClient client,
1009                                          SilcClientConnection conn,
1010                                          char *channel);
1011
1012 /****f* silcclient/SilcClientAPI/silc_client_get_channel_id_resolve
1013  *
1014  * SYNOPSIS
1015  *
1016  *    void 
1017  *    silc_client_get_channel_by_id_resolve(SilcClient client,
1018  *                                          SilcClientConnection conn,
1019  *                                          SilcChannelID *channel_id,
1020  *                                          SilcGetClientCallback completion,
1021  *                                          void *context);
1022  *
1023  * DESCRIPTION
1024  *
1025  *    Finds channel entry by the channel name. Returns the entry or NULL
1026  *    if it was not found.
1027  *
1028  ***/
1029 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
1030                                                SilcClientConnection conn,
1031                                                SilcChannelID *channel_id);
1032
1033 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
1034  *
1035  * SYNOPSIS
1036  *
1037  *    void 
1038  *    silc_client_get_channel_by_id_resolve(SilcClient client,
1039  *                                          SilcClientConnection conn,
1040  *                                          SilcChannelID *channel_id,
1041  *                                          SilcGetClientCallback completion,
1042  *                                          void *context);
1043  *
1044  * DESCRIPTION
1045  *
1046  *    Resolves the channel information (its name mainly) from the server
1047  *    by the `channel_id'. Use this only if you know that you do not have
1048  *    the entry cached locally.
1049  *
1050  ***/
1051 void silc_client_get_channel_by_id_resolve(SilcClient client,
1052                                            SilcClientConnection conn,
1053                                            SilcChannelID *channel_id,
1054                                            SilcGetChannelCallback completion,
1055                                            void *context);
1056
1057 /****f* silcclient/SilcClientAPI/silc_client_del_channel
1058  *
1059  * SYNOPSIS
1060  *
1061  *    bool silc_client_del_channel(SilcClient client, 
1062  *                                 SilcClientConnection conn,
1063  *                                 SilcChannelEntry channel)
1064  *
1065  * DESCRIPTION
1066  *
1067  *    Removes channel from local cache by the channel entry indicated by
1068  *    the `channel'.  Returns TRUE if the deletion were successful.
1069  *
1070  ***/
1071 bool silc_client_del_channel(SilcClient client, SilcClientConnection conn,
1072                              SilcChannelEntry channel);
1073
1074 /****f* silcclient/SilcClientAPI/silc_client_get_server
1075  *
1076  * SYNOPSIS
1077  *
1078  *    SilcServerEntry silc_client_get_server(SilcClient client,
1079  *                                           SilcClientConnection conn,
1080  *                                           char *server_name)
1081  *
1082  * DESCRIPTION
1083  *
1084  *    Finds entry for server by the server name. Returns the entry or NULL
1085  *    if the entry was not found.
1086  *
1087  ***/
1088 SilcServerEntry silc_client_get_server(SilcClient client,
1089                                        SilcClientConnection conn,
1090                                        char *server_name);
1091
1092 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
1093  *
1094  * SYNOPSIS
1095  *
1096  *    SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1097  *                                                 SilcClientConnection conn,
1098  *                                                 SilcServerID *server_id);
1099  *
1100  * DESCRIPTION
1101  *
1102  *    Finds entry for server by the server ID. Returns the entry or NULL
1103  *    if the entry was not found.
1104  *
1105  ***/
1106 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1107                                              SilcClientConnection conn,
1108                                              SilcServerID *server_id);
1109
1110 /****f* silcclient/SilcClientAPI/silc_client_del_server
1111  *
1112  * SYNOPSIS
1113  *
1114  *    bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1115  *                                SilcServerEntry server);
1116  *
1117  * DESCRIPTION
1118  *
1119  *    Removes server from local cache by the server entry indicated by
1120  *    the `server'.  Returns TRUE if the deletion were successful.
1121  *
1122  ***/
1123 bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1124                             SilcServerEntry server);
1125
1126 /****f* silcclient/SilcClientAPI/silc_client_on_channel
1127  *
1128  * SYNOPSIS
1129  *
1130  *    SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1131  *                                           SilcClientEntry client_entry);
1132  *
1133  * DESCRIPTION
1134  *
1135  *    Returns the ChannelUser entry if the `client_entry' is joined on the 
1136  *    channel indicated by the `channel'. NULL if client is not joined on
1137  *    the channel. 
1138  *
1139  ***/
1140 SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1141                                        SilcClientEntry client_entry);
1142
1143 /* Command management (command.c) */
1144
1145 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
1146  *
1147  * SYNOPSIS
1148  *
1149  *    SilcClientCommandContext silc_client_command_alloc(void);
1150  *
1151  * DESCRIPTION
1152  *
1153  *    Allocate Command Context. The context is defined in `command.h' file.
1154  *    The context is used by the library commands and applications should use
1155  *    it as well. However, application may choose to use some own context
1156  *    for its local commands. All library commands, however, must use this
1157  *    context. 
1158  *
1159  ***/
1160 SilcClientCommandContext silc_client_command_alloc(void);
1161
1162 /****f* silcclient/SilcClientAPI/silc_client_command_free
1163  *
1164  * SYNOPSIS
1165  *
1166  *    void silc_client_command_free(SilcClientCommandContext ctx);
1167  *
1168  * DESCRIPTION
1169  *
1170  *    Free command context and its internals.  If the contex was duplicated
1171  *    with silc_client_command_dup this may not actually free the data, 
1172  *    instead it will decrease the reference counter of the context.  The
1173  *    context will be freed when the reference counter hits zero.
1174  *
1175  ***/
1176 void silc_client_command_free(SilcClientCommandContext ctx);
1177
1178 /****f* silcclient/SilcClientAPI/silc_client_command_dup
1179  *
1180  * SYNOPSIS
1181  *
1182  *    SilcClientCommandContext 
1183  *    silc_client_command_dup(SilcClientCommandContext ctx);
1184  *
1185  * DESCRIPTION
1186  *
1187  *    Duplicate Command Context by adding reference counter. The context won't
1188  *    be free'd untill it hits zero. 
1189  *
1190  ***/
1191 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
1192
1193 /****f* silcclient/SilcClientAPI/silc_client_command_find
1194  *
1195  * SYNOPSIS
1196  *
1197  *    SilcClientCommand silc_client_command_find(SilcClient client,
1198  *                                               const char *name);
1199  *
1200  * DESCRIPTION
1201  *
1202  *    Finds and returns a pointer to the command list. Return NULL if the
1203  *    command is not found. See the `command.[ch]' for the command list. 
1204  *    Command names are not case-sensitive.
1205  *
1206  ***/
1207 SilcClientCommand silc_client_command_find(SilcClient client,
1208                                            const char *name);
1209
1210 /****f* silcclient/SilcClientAPI/silc_client_command_call
1211  *
1212  * SYNOPSIS
1213  *
1214  *    void silc_client_command_call(SilcClientCommand command);
1215  *
1216  * DESCRIPTION
1217  *
1218  *    Calls the command (executes it).  Application can call this after
1219  *    it has allocated the SilcClientCommandContext with the function
1220  *    silc_client_command_alloc and found the command from the client
1221  *    library by calling silc_client_command_find.  This will execute
1222  *    the command.
1223  *
1224  *    Application can call the command function directly too if it
1225  *    wishes to do so.  See the command.h for details of the
1226  *    SilcClientCommand structure.
1227  *
1228  ***/
1229 void silc_client_command_call(SilcClientCommand command,
1230                               SilcClientCommandContext cmd);
1231
1232 /****f* silcclient/SilcClientAPI/silc_client_command_send
1233  *
1234  * SYNOPSIS
1235  *
1236  *    void silc_client_command_send(SilcClient client, 
1237  *                                  SilcClientConnection conn,
1238  *                                  SilcCommand command, uint16 ident,
1239  *                                  uint32 argc, ...);
1240  *
1241  * DESCRIPTION
1242  *
1243  *    Generic function to send any command. The arguments must be sent already
1244  *    encoded into correct form and in correct order. If application wants
1245  *    to perform the commands by itself, it can do so and send the data
1246  *    directly to the server using this function.  If application is using
1247  *    the silc_client_command_call, this function is usually not used.
1248  *
1249  ***/
1250 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1251                               SilcCommand command, uint16 ident,
1252                               uint32 argc, ...);
1253
1254 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1255  *
1256  * SYNOPSIS
1257  *
1258  *    void silc_client_command_pending(SilcClientConnection conn,
1259  *                                     SilcCommand reply_cmd,
1260  *                                     uint16 ident,
1261  *                                     SilcCommandCb callback,
1262  *                                     void *context);
1263  *
1264  * DESCRIPTION
1265  *
1266  *    Add new pending command to be executed when reply to a command has been
1267  *    received.  The `reply_cmd' is the command that will call the `callback'
1268  *    with `context' when reply has been received.  If `ident' is non-zero
1269  *    the `callback' will be executed when received reply with command 
1270  *    identifier `ident'. 
1271  *
1272  *    Note that the application is notified about the received command
1273  *    reply through the `command_reply' client operation before calling
1274  *    the `callback` pending command callback.
1275  *
1276  ***/
1277 void silc_client_command_pending(SilcClientConnection conn,
1278                                  SilcCommand reply_cmd,
1279                                  uint16 ident,
1280                                  SilcCommandCb callback,
1281                                  void *context);
1282
1283
1284 /* Private Message key management (client_prvmsg.c) */
1285
1286 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1287  *
1288  * SYNOPSIS
1289  *
1290  *    int silc_client_add_private_message_key(SilcClient client,
1291  *                                            SilcClientConnection conn,
1292  *                                            SilcClientEntry client_entry,
1293  *                                            char *cipher,
1294  *                                            unsigned char *key,
1295  *                                            uint32 key_len,
1296  *                                            bool generate_key,
1297  *                                            bool responder);
1298  *
1299  * DESCRIPTION
1300  *
1301  *    Adds private message key to the client library. The key will be used to
1302  *    encrypt all private message between the client and the remote client
1303  *    indicated by the `client_entry'. If the `key' is NULL and the boolean
1304  *    value `generate_key' is TRUE the library will generate random key.
1305  *    The `key' maybe for example pre-shared-key, passphrase or similar.
1306  *    The `cipher' MAY be provided but SHOULD be NULL to assure that the
1307  *    requirements of the SILC protocol are met. The API, however, allows
1308  *    to allocate any cipher.
1309  *
1310  *    If `responder' is TRUE then the sending and receiving keys will be
1311  *    set according the client being the receiver of the private key.  If
1312  *    FALSE the client is being the sender (or negotiator) of the private
1313  *    key.
1314  *
1315  *    It is not necessary to set key for normal private message usage. If the
1316  *    key is not set then the private messages are encrypted using normal
1317  *    session keys. Setting the private key, however, increases the security. 
1318  *
1319  *    Returns FALSE if the key is already set for the `client_entry', TRUE
1320  *    otherwise. 
1321  *
1322  ***/
1323 int silc_client_add_private_message_key(SilcClient client,
1324                                         SilcClientConnection conn,
1325                                         SilcClientEntry client_entry,
1326                                         char *cipher,
1327                                         unsigned char *key,
1328                                         uint32 key_len,
1329                                         bool generate_key,
1330                                         bool responder);
1331
1332 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1333  *
1334  * SYNOPSIS
1335  *
1336  *    int silc_client_add_private_message_key_ske(SilcClient client,
1337  *                                                SilcClientConnection conn,
1338  *                                                SilcClientEntry client_entry,
1339  *                                                char *cipher,
1340  *                                                SilcSKEKeyMaterial *key);
1341  *
1342  * DESCRIPTION
1343  *
1344  *    Same as silc_client_add_private_message_key but takes the key material
1345  *    from the SKE key material structure. This structure is received if
1346  *    the application uses the silc_client_send_key_agreement to negotiate
1347  *    the key material. The `cipher' SHOULD be provided as it is negotiated
1348  *    also in the SKE protocol. 
1349  *
1350  ***/
1351 int silc_client_add_private_message_key_ske(SilcClient client,
1352                                             SilcClientConnection conn,
1353                                             SilcClientEntry client_entry,
1354                                             char *cipher,
1355                                             SilcSKEKeyMaterial *key,
1356                                             bool responder);
1357
1358 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
1359  *
1360  * SYNOPSIS
1361  *
1362  *    int silc_client_send_private_message_key(SilcClient client,
1363  *                                             SilcClientConnection conn,
1364  *                                             SilcClientEntry client_entry,
1365  *                                             int force_send);
1366  *
1367  * DESCRIPTION
1368  *
1369  *    Sends private message key payload to the remote client indicated by
1370  *    the `client_entry'. If the `force_send' is TRUE the packet is sent
1371  *    immediately. Returns FALSE if error occurs, TRUE otherwise. The
1372  *    application should call this function after setting the key to the
1373  *    client.
1374  *
1375  *    Note that the key sent using this function is sent to the remote client
1376  *    through the SILC network. The packet is protected using normal session
1377  *    keys. 
1378  *
1379  ***/
1380 int silc_client_send_private_message_key(SilcClient client,
1381                                          SilcClientConnection conn,
1382                                          SilcClientEntry client_entry,
1383                                          int force_send);
1384
1385 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1386  *
1387  * SYNOPSIS
1388  *
1389  *    int silc_client_del_private_message_key(SilcClient client,
1390  *                                            SilcClientConnection conn,
1391  *                                            SilcClientEntry client_entry);
1392  *
1393  * DESCRIPTION
1394  *
1395  *    Removes the private message from the library. The key won't be used
1396  *    after this to protect the private messages with the remote `client_entry'
1397  *    client. Returns FALSE on error, TRUE otherwise. 
1398  *
1399  ***/
1400 int silc_client_del_private_message_key(SilcClient client,
1401                                         SilcClientConnection conn,
1402                                         SilcClientEntry client_entry);
1403
1404 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1405  *
1406  * SYNOPSIS
1407  *
1408  *    SilcPrivateMessageKeys
1409  *    silc_client_list_private_message_keys(SilcClient client,
1410  *                                          SilcClientConnection conn,
1411  *                                          uint32 *key_count);
1412  * 
1413  * DESCRIPTION
1414  *
1415  *    Returns array of set private message keys associated to the connection
1416  *    `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1417  *    count to the `key_count' argument. The array must be freed by the caller
1418  *    by calling the silc_client_free_private_message_keys function. Note: 
1419  *    the keys returned in the array is in raw format. It might not be desired
1420  *    to show the keys as is. The application might choose not to show the keys
1421  *    at all or to show the fingerprints of the keys. 
1422  *
1423  ***/
1424 SilcPrivateMessageKeys
1425 silc_client_list_private_message_keys(SilcClient client,
1426                                       SilcClientConnection conn,
1427                                       uint32 *key_count);
1428
1429 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1430  *
1431  * SYNOPSIS
1432  *
1433  *    void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1434  *                                               uint32 key_count);
1435  * 
1436  * DESCRIPTION
1437  *
1438  *    Frees the SilcPrivateMessageKeys array returned by the function
1439  *    silc_client_list_private_message_keys. 
1440  *
1441  ***/
1442 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1443                                            uint32 key_count);
1444
1445
1446 /* Channel private key management (client_channel.c, 
1447    SilcChannelPrivateKey is defined in idlist.h) */
1448
1449 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1450  *
1451  * SYNOPSIS
1452  *
1453  *    int silc_client_add_channel_private_key(SilcClient client,
1454  *                                            SilcClientConnection conn,
1455  *                                            SilcChannelEntry channel,
1456  *                                            char *cipher,
1457  *                                            char *hmac,
1458  *                                            unsigned char *key,
1459  *                                            uint32 key_len);
1460  * 
1461  * DESCRIPTION
1462  *
1463  *    Adds private key for channel. This may be set only if the channel's mode
1464  *    mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1465  *    mode is not set. When channel has private key then the messages are
1466  *    encrypted using that key. All clients on the channel must also know the
1467  *    key in order to decrypt the messages. However, it is possible to have
1468  *    several private keys per one channel. In this case only some of the
1469  *    clients on the channel may know the one key and only some the other key.
1470  *
1471  *    The private key for channel is optional. If it is not set then the
1472  *    channel messages are encrypted using the channel key generated by the
1473  *    server. However, setting the private key (or keys) for the channel 
1474  *    significantly adds security. If more than one key is set the library
1475  *    will automatically try all keys at the message decryption phase. Note:
1476  *    setting many keys slows down the decryption phase as all keys has to
1477  *    be tried in order to find the correct decryption key. However, setting
1478  *    a few keys does not have big impact to the decryption performace. 
1479  *
1480  * NOTES
1481  *
1482  *    NOTE: This is entirely local setting. The key set using this function
1483  *    is not sent to the network at any phase.
1484  *
1485  *    NOTE: If the key material was originated by the SKE protocol (using
1486  *    silc_client_send_key_agreement) then the `key' MUST be the
1487  *    key->send_enc_key as this is dictated by the SILC protocol. However,
1488  *    currently it is not expected that the SKE key material would be used
1489  *    as channel private key. However, this API allows it. 
1490  *
1491  ***/
1492 int silc_client_add_channel_private_key(SilcClient client,
1493                                         SilcClientConnection conn,
1494                                         SilcChannelEntry channel,
1495                                         char *cipher,
1496                                         char *hmac,
1497                                         unsigned char *key,
1498                                         uint32 key_len);
1499
1500 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1501  *
1502  * SYNOPSIS
1503  *
1504  *    int silc_client_del_channel_private_keys(SilcClient client,
1505  *                                             SilcClientConnection conn,
1506  *                                             SilcChannelEntry channel);
1507  * 
1508  * DESCRIPTION
1509  *
1510  *    Removes all private keys from the `channel'. The old channel key is used
1511  *    after calling this to protect the channel messages. Returns FALSE on
1512  *    on error, TRUE otherwise. 
1513  *
1514  ***/
1515 int silc_client_del_channel_private_keys(SilcClient client,
1516                                          SilcClientConnection conn,
1517                                          SilcChannelEntry channel);
1518
1519 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1520  *
1521  * SYNOPSIS
1522  *
1523  *    int silc_client_del_channel_private_key(SilcClient client,
1524  *                                            SilcClientConnection conn,
1525  *                                            SilcChannelEntry channel,
1526  *                                            SilcChannelPrivateKey key);
1527  * 
1528  * DESCRIPTION
1529  *
1530  *    Removes and frees private key `key' from the channel `channel'. 
1531  *    The `key' is retrieved by calling the function 
1532  *    silc_client_list_channel_private_keys. The key is not used after
1533  *    this. If the key was last private key then the old channel key is
1534  *    used hereafter to protect the channel messages. This returns FALSE
1535  *    on error, TRUE otherwise. 
1536  *
1537  ***/
1538 int silc_client_del_channel_private_key(SilcClient client,
1539                                         SilcClientConnection conn,
1540                                         SilcChannelEntry channel,
1541                                         SilcChannelPrivateKey key);
1542
1543 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1544  *
1545  * SYNOPSIS
1546  *
1547  *    SilcChannelPrivateKey *
1548  *    silc_client_list_channel_private_keys(SilcClient client,
1549  *                                          SilcClientConnection conn,
1550  *                                          SilcChannelEntry channel,
1551  *                                          uint32 *key_count);
1552  *
1553  * DESCRIPTION
1554  *
1555  *    Returns array (pointers) of private keys associated to the `channel'.
1556  *    The caller must free the array by calling the function
1557  *    silc_client_free_channel_private_keys. The pointers in the array may be
1558  *    used to delete the specific key by giving the pointer as argument to the
1559  *    function silc_client_del_channel_private_key. 
1560  *
1561  ***/
1562 SilcChannelPrivateKey *
1563 silc_client_list_channel_private_keys(SilcClient client,
1564                                       SilcClientConnection conn,
1565                                       SilcChannelEntry channel,
1566                                       uint32 *key_count);
1567
1568 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1569  *
1570  * SYNOPSIS
1571  *
1572  *    void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1573  *                                               uint32 key_count);
1574  *
1575  * DESCRIPTION
1576  *
1577  *    Frees the SilcChannelPrivateKey array.
1578  *
1579  ***/
1580 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1581                                            uint32 key_count);
1582
1583
1584 /* Key Agreement routines (client_keyagr.c) */
1585
1586 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1587  *
1588  * SYNOPSIS
1589  *
1590  *    void silc_client_send_key_agreement(SilcClient client,
1591  *                                        SilcClientConnection conn,
1592  *                                        SilcClientEntry client_entry,
1593  *                                        char *hostname,
1594  *                                        int port,
1595  *                                        uint32 timeout_secs,
1596  *                                        SilcKeyAgreementCallback completion,
1597  *                                        void *context);
1598  *
1599  * DESCRIPTION
1600  *
1601  *    Sends key agreement request to the remote client indicated by the
1602  *    `client_entry'. If the caller provides the `hostname' and the `port'
1603  *    arguments then the library will bind the client to that hostname and
1604  *    that port for the key agreement protocol. It also sends the `hostname'
1605  *    and the `port' in the key agreement packet to the remote client. This
1606  *    would indicate that the remote client may initiate the key agreement
1607  *    protocol to the `hostname' on the `port'.  If port is zero then the
1608  *    bound port is undefined (the operating system defines it).
1609  *
1610  *    If the `hostname' and `port' is not provided then empty key agreement
1611  *    packet is sent to the remote client. The remote client may reply with
1612  *    the same packet including its hostname and port. If the library receives
1613  *    the reply from the remote client the `key_agreement' client operation
1614  *    callback will be called to verify whether the user wants to perform the
1615  *    key agreement or not. 
1616  *
1617  * NOTES
1618  *
1619  *    NOTE: If the application provided the `hostname' and the `port' and the 
1620  *    remote side initiates the key agreement protocol it is not verified
1621  *    from the user anymore whether the protocol should be executed or not.
1622  *    By setting the `hostname' and `port' the user gives permission to
1623  *    perform the protocol (we are responder in this case).
1624  *
1625  *    NOTE: If the remote side decides not to initiate the key agreement
1626  *    or decides not to reply with the key agreement packet then we cannot
1627  *    perform the key agreement at all. If the key agreement protocol is
1628  *    performed the `completion' callback with the `context' will be called.
1629  *    If remote side decides to ignore the request the `completion' will be
1630  *    called after the specified timeout, `timeout_secs'. 
1631  *
1632  *    NOTE: If the `hostname' and the `port' was not provided the `completion'
1633  *    will not be called at all since this does nothing more than sending
1634  *    a packet to the remote host.
1635  *
1636  *    NOTE: There can be only one active key agreement for one client entry.
1637  *    Before setting new one, the old one must be finished (it is finished
1638  *    after calling the completion callback) or the function 
1639  *    silc_client_abort_key_agreement must be called. 
1640  *
1641  ***/
1642 void silc_client_send_key_agreement(SilcClient client,
1643                                     SilcClientConnection conn,
1644                                     SilcClientEntry client_entry,
1645                                     const char *hostname,
1646                                     const char *bindhost,
1647                                     int port,
1648                                     uint32 timeout_secs,
1649                                     SilcKeyAgreementCallback completion,
1650                                     void *context);
1651
1652 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1653  *
1654  * SYNOPSIS
1655  *
1656  *    void 
1657  *    silc_client_perform_key_agreement(SilcClient client,
1658  *                                      SilcClientConnection conn,
1659  *                                      SilcClientEntry client_entry,
1660  *                                      char *hostname,
1661  *                                      int port,
1662  *                                      SilcKeyAgreementCallback completion,
1663  *                                      void *context);
1664  *
1665  * DESCRIPTION
1666  *
1667  *    Performs the actual key agreement protocol. Application may use this
1668  *    to initiate the key agreement protocol. This can be called for example
1669  *    after the application has received the `key_agreement' client operation,
1670  *    and did not return TRUE from it.
1671  *
1672  *    The `hostname' is the remote hostname (or IP address) and the `port'
1673  *    is the remote port. The `completion' callback with the `context' will
1674  *    be called after the key agreement protocol.
1675  *
1676  * NOTES
1677  * 
1678  *    NOTE: If the application returns TRUE in the `key_agreement' client
1679  *    operation the library will automatically start the key agreement. In this
1680  *    case the application must not call this function. However, application
1681  *    may choose to just ignore the `key_agreement' client operation (and
1682  *    merely just print information about it on the screen) and call this
1683  *    function when the user whishes to do so (by, for example, giving some
1684  *    specific command). Thus, the API provides both, automatic and manual
1685  *    initiation of the key agreement. Calling this function is the manual
1686  *    initiation and returning TRUE in the `key_agreement' client operation
1687  *    is the automatic initiation. 
1688  *
1689  ***/
1690 void silc_client_perform_key_agreement(SilcClient client,
1691                                        SilcClientConnection conn,
1692                                        SilcClientEntry client_entry,
1693                                        char *hostname,
1694                                        int port,
1695                                        SilcKeyAgreementCallback completion,
1696                                        void *context);
1697
1698 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1699  *
1700  * SYNOPSIS
1701  *
1702  *    void
1703  *    silc_client_perform_key_agreement_fd(SilcClient client,
1704  *                                         SilcClientConnection conn,
1705  *                                         SilcClientEntry client_entry,
1706  *                                         int sock,
1707  *                                         char *hostname,
1708  *                                         SilcKeyAgreementCallback completion,
1709  *                                         void *context);
1710  *
1711  * DESCRIPTION
1712  *
1713  *    Same as above but application has created already the connection to 
1714  *    the remote host. The `sock' is the socket to the remote connection. 
1715  *    Application can use this function if it does not want the client library
1716  *    to create the connection. 
1717  *
1718  ***/
1719 void silc_client_perform_key_agreement_fd(SilcClient client,
1720                                           SilcClientConnection conn,
1721                                           SilcClientEntry client_entry,
1722                                           int sock,
1723                                           char *hostname,
1724                                           SilcKeyAgreementCallback completion,
1725                                           void *context);
1726
1727 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1728  *
1729  * SYNOPSIS
1730  *
1731  *    void silc_client_abort_key_agreement(SilcClient client,
1732  *                                         SilcClientConnection conn,
1733  *                                         SilcClientEntry client_entry);
1734  *
1735  * DESCRIPTION
1736  *
1737  *    This function can be called to unbind the hostname and the port for
1738  *    the key agreement protocol. However, this function has effect only 
1739  *    before the key agreement protocol has been performed. After it has
1740  *    been performed the library will automatically unbind the port. The 
1741  *    `client_entry' is the client to which we sent the key agreement 
1742  *    request.  The key agreement completion callback will be called
1743  *    with SILC_KEY_AGREEMENT_ABORTED status.
1744  *
1745  ***/
1746 void silc_client_abort_key_agreement(SilcClient client,
1747                                      SilcClientConnection conn,
1748                                      SilcClientEntry client_entry);
1749
1750
1751 /* Misc functions */
1752
1753 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1754  *
1755  * SYNOPSIS
1756  *
1757  *    void silc_client_set_away_message(SilcClient client,
1758  *                                      SilcClientConnection conn,
1759  *                                      char *message);
1760  *
1761  * DESCRIPTION
1762  *
1763  *    Sets away `message'.  The away message may be set when the client's
1764  *    mode is changed to SILC_UMODE_GONE and the client whishes to reply
1765  *    to anyone who sends private message.  The `message' will be sent
1766  *    automatically back to the the client who send private message.  If
1767  *    away message is already set this replaces the old message with the
1768  *    new one.  If `message' is NULL the old away message is removed. 
1769  *    The sender may freely free the memory of the `message'. 
1770  *
1771  ***/
1772 void silc_client_set_away_message(SilcClient client,
1773                                   SilcClientConnection conn,
1774                                   char *message);
1775
1776
1777 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
1778  *
1779  * SYNOPSIS
1780  *
1781  *    typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1782  *                                              SilcClientConnection conn,
1783  *                                              SilcAuthMethod auth_meth,
1784  *                                              void *context);
1785  *
1786  * DESCRIPTION
1787  *
1788  *    Connection authentication method request callback. This is called
1789  *    by the client library after it has received the authentication method
1790  *    that the application requested by calling the function
1791  *    silc_client_request_authentication_method.
1792  *
1793  ***/
1794 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1795                                           SilcClientConnection conn,
1796                                           SilcAuthMethod auth_meth,
1797                                           void *context);
1798
1799 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
1800  *
1801  * SYNOPSIS
1802  *
1803  *    void 
1804  *    silc_client_request_authentication_method(SilcClient client,
1805  *                                              SilcClientConnection conn,
1806  *                                              SilcConnectionAuthRequest 
1807  *                                                callback,
1808  *                                              void *context);
1809  *
1810  * DESCRIPTION
1811  *
1812  *    This function can be used to request the current authentication method
1813  *    from the server. This may be called when connecting to the server
1814  *    and the client library requests the authentication data from the
1815  *    application. If the application does not know the current authentication
1816  *    method it can request it from the server using this function.
1817  *    The `callback' with `context' will be called after the server has
1818  *    replied back with the current authentication method.
1819  *
1820  ***/
1821 void 
1822 silc_client_request_authentication_method(SilcClient client,
1823                                           SilcClientConnection conn,
1824                                           SilcConnectionAuthRequest callback,
1825                                           void *context);
1826
1827 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
1828  *
1829  * NAME
1830  *
1831  *    typedef enum { ... } SilcClientMonitorStatus;
1832  *
1833  * DESCRIPTION
1834  *
1835  *    File transmission session status types.  These will indicate
1836  *    the status of the file transmission session.
1837  *
1838  * SOURCE
1839  */
1840 typedef enum {
1841   SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT,    /* In key agreemenet phase */
1842   SILC_CLIENT_FILE_MONITOR_SEND,             /* Sending file */
1843   SILC_CLIENT_FILE_MONITOR_RECEIVE,          /* Receiving file */
1844   SILC_CLIENT_FILE_MONITOR_GET,
1845   SILC_CLIENT_FILE_MONITOR_PUT,
1846   SILC_CLIENT_FILE_MONITOR_CLOSED,           /* Session closed */
1847   SILC_CLIENT_FILE_MONITOR_ERROR,            /* Error during session */
1848 } SilcClientMonitorStatus;
1849 /***/
1850
1851 /****d* silcclient/SilcClientAPI/SilcClientFileError
1852  *
1853  * NAME
1854  *
1855  *    typedef enum { ... } SilcClientFileError;
1856  *
1857  * DESCRIPTION
1858  *
1859  *    File transmission error types.  These types are returned by
1860  *    some of the file transmission functions, and by the monitor
1861  *    callback to indicate error.
1862  *
1863  * SOURCE
1864  */
1865 typedef enum {
1866   SILC_CLIENT_FILE_OK,
1867   SILC_CLIENT_FILE_ERROR,
1868   SILC_CLIENT_FILE_UNKNOWN_SESSION,
1869   SILC_CLIENT_FILE_ALREADY_STARTED,
1870   SILC_CLIENT_FILE_NO_SUCH_FILE,
1871   SILC_CLIENT_FILE_PERMISSION_DENIED,
1872   SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED,
1873 } SilcClientFileError;
1874 /***/
1875
1876 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
1877  *
1878  * SYNOPSIS
1879  *
1880  *    typedef void (*SilcClientFileMonitor)(SilcClient client,
1881  *                                          SilcClientConnection conn,
1882  *                                          SilcClientMonitorStatus status,
1883  *                                          SilcClientFileError error,
1884  *                                          uint64 offset,
1885  *                                          uint64 filesize,
1886  *                                          SilcClientEntry client_entry,
1887  *                                          uint32 session_id,
1888  *                                          const char *filepath,
1889  *                                          void *context);
1890  *
1891  * DESCRIPTION
1892  *
1893  *    Monitor callback that is called during the file transmission to
1894  *    monitor the transmission process.  The `status' indicates the current
1895  *    monitoring process.  The `error' will indicate the error type
1896  *    if `status' is SILC_CLIENT_FILE_MONITOR_ERROR.  The `offset' is the
1897  *    currently transmitted amount of total `filesize'.  The `client_entry'
1898  *    indicates the remote client, and the transmission session ID is the 
1899  *    `session_id'.  The filename being transmitted is indicated by the 
1900  *    `filepath'.
1901  *
1902  ***/
1903 typedef void (*SilcClientFileMonitor)(SilcClient client,
1904                                       SilcClientConnection conn,
1905                                       SilcClientMonitorStatus status,
1906                                       SilcClientFileError error,
1907                                       uint64 offset,
1908                                       uint64 filesize,
1909                                       SilcClientEntry client_entry,
1910                                       uint32 session_id,
1911                                       const char *filepath,
1912                                       void *context);
1913
1914 /****f* silcclient/SilcClientAPI/silc_client_file_send
1915  *
1916  * SYNOPSIS
1917  *
1918  *    SilcClientFileError 
1919  *    silc_client_file_send(SilcClient client,
1920  *                          SilcClientConnection conn,
1921  *                          SilcClientFileMonitor monitor,
1922  *                          void *monitor_context,
1923  *                          const char *local_ip,
1924  *                          uint32 local_port,
1925  *                          SilcClientEntry client_entry,
1926  *                          const char *filepath);
1927  *                          uint32 *session_id);
1928  *
1929  * DESCRIPTION
1930  *
1931  *    Sends a file indicated by the `filepath' to the remote client 
1932  *    indicated by the `client_entry'.  This will negotiate a secret key
1933  *    with the remote client before actually starting the transmission of
1934  *    the file.  The `monitor' callback will be called to monitor the
1935  *    transmission of the file.
1936  *
1937  *    This returns a file session ID for the file transmission to the
1938  *    `session_id' pointer..  It can be used to close the session (and
1939  *    abort the file transmission) by calling the silc_client_file_close
1940  *    function.  The session ID is also returned in the `monitor' callback. 
1941  *
1942  *    If the `local_ip' is provided then this will try to bind the 
1943  *    listener for key exchange protocol to that IP.  If `local_port' is
1944  *    non-zero that port is used.  If `local_ip' is NULL then this will
1945  *    automatically attempt to bind it to local IP address of the machine.
1946  *    If that fails then this does not bind to any address and port, and
1947  *    assume that the remote client will provide the listener for the
1948  *    key exchange protocol.
1949  *
1950  *    If error will occur during the file transfer process the error
1951  *    status will be returned in the monitor callback.  In this case
1952  *    the application must call silc_client_file_close to close the
1953  *    session.
1954  *
1955  ***/
1956 SilcClientFileError 
1957 silc_client_file_send(SilcClient client,
1958                       SilcClientConnection conn,
1959                       SilcClientFileMonitor monitor,
1960                       void *monitor_context,
1961                       const char *local_ip,
1962                       uint32 local_port,
1963                       SilcClientEntry client_entry,
1964                       const char *filepath,
1965                       uint32 *session_id);
1966
1967 /****f* silcclient/SilcClientAPI/silc_client_file_receive
1968  *
1969  * SYNOPSIS
1970  *
1971  *    SilcClientFileError 
1972  *    silc_client_file_receive(SilcClient client,
1973  *                             SilcClientConnection conn,
1974  *                             SilcClientFileMonitor monitor,
1975  *                             void *monitor_context,
1976  *                             uint32 session_id);
1977  *
1978  * DESCRIPTION
1979  *
1980  *    Receives a file from a client indicated by the `client_entry'.  The
1981  *    `session_id' indicates the file transmission session and it has been
1982  *    received in the `ftp' client operation function.  This will actually
1983  *    perform the key agreement protocol with the remote client before
1984  *    actually starting the file transmission.  The `monitor' callback
1985  *    will be called to monitor the transmission.
1986  *
1987  *    If error will occur during the file transfer process the error
1988  *    status will be returned in the monitor callback.  In this case
1989  *    the application must call silc_client_file_close to close the
1990  *    session.
1991  *
1992  ***/
1993 SilcClientFileError 
1994 silc_client_file_receive(SilcClient client,
1995                          SilcClientConnection conn,
1996                          SilcClientFileMonitor monitor,
1997                          void *monitor_context,
1998                          uint32 session_id);
1999
2000 /****f* silcclient/SilcClientAPI/silc_client_file_close
2001  *
2002  * SYNOPSIS
2003  *
2004  *    SilcClientFileError silc_client_file_close(SilcClient client,
2005  *                                               SilcClientConnection conn,
2006  *                                               uint32 session_id);
2007  *
2008  * DESCRIPTION
2009  *
2010  *    Closes file transmission session indicated by the `session_id'.
2011  *    If file transmission is being conducted it will be aborted
2012  *    automatically. This function is also used to close the session
2013  *    after successful file transmission. This function can be used
2014  *    also to reject incoming file transmission request.
2015  *
2016  ***/
2017 SilcClientFileError silc_client_file_close(SilcClient client,
2018                                            SilcClientConnection conn,
2019                                            uint32 session_id);
2020
2021 #endif