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