5bcf556d9171cf49a8622784c6e1e4890d631b99
[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  *    void 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 void 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(void);
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(void);
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(SilcClient client,
1175  *                                               const char *name);
1176  *
1177  * DESCRIPTION
1178  *
1179  *    Finds and returns a pointer to the command list. Return NULL if the
1180  *    command is not found. See the `command.[ch]' for the command list. 
1181  *
1182  ***/
1183 SilcClientCommand silc_client_command_find(SilcClient client,
1184                                            const char *name);
1185
1186 /****f* silcclient/SilcClientAPI/silc_client_command_call
1187  *
1188  * SYNOPSIS
1189  *
1190  *    void silc_client_command_call(SilcClientCommand command);
1191  *
1192  * DESCRIPTION
1193  *
1194  *    Calls the command (executes it).  Application can call this after
1195  *    it has allocated the SilcClientCommandContext with the function
1196  *    silc_client_command_alloc and found the command from the client
1197  *    library by calling silc_client_command_find.  This will execute
1198  *    the command.
1199  *
1200  *    Application can call the command function directly too if it
1201  *    wishes to do so.  See the command.h for details of the
1202  *    SilcClientCommand structure.
1203  *
1204  ***/
1205 void silc_client_command_call(SilcClientCommand command,
1206                               SilcClientCommandContext cmd);
1207
1208 /****f* silcclient/SilcClientAPI/silc_client_command_send
1209  *
1210  * SYNOPSIS
1211  *
1212  *    void silc_client_command_send(SilcClient client, 
1213  *                                  SilcClientConnection conn,
1214  *                                  SilcCommand command, uint16 ident,
1215  *                                  uint32 argc, ...);
1216  *
1217  * DESCRIPTION
1218  *
1219  *    Generic function to send any command. The arguments must be sent already
1220  *    encoded into correct form and in correct order. If application wants
1221  *    to perform the commands by itself, it can do so and send the data
1222  *    directly to the server using this function.  If application is using
1223  *    the silc_client_command_call, this function is usually not used.
1224  *
1225  ***/
1226 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1227                               SilcCommand command, uint16 ident,
1228                               uint32 argc, ...);
1229
1230 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1231  *
1232  * SYNOPSIS
1233  *
1234  *    void silc_client_command_pending(SilcClientConnection conn,
1235  *                                     SilcCommand reply_cmd,
1236  *                                     uint16 ident,
1237  *                                     SilcCommandCb callback,
1238  *                                     void *context);
1239  *
1240  * DESCRIPTION
1241  *
1242  *    Add new pending command to be executed when reply to a command has been
1243  *    received.  The `reply_cmd' is the command that will call the `callback'
1244  *    with `context' when reply has been received.  If `ident' is non-zero
1245  *    the `callback' will be executed when received reply with command 
1246  *    identifier `ident'. 
1247  *
1248  *    Note that the application is notified about the received command
1249  *    reply through the `command_reply' client operation before calling
1250  *    the `callback` pending command callback.
1251  *
1252  ***/
1253 void silc_client_command_pending(SilcClientConnection conn,
1254                                  SilcCommand reply_cmd,
1255                                  uint16 ident,
1256                                  SilcCommandCb callback,
1257                                  void *context);
1258
1259
1260 /* Private Message key management (client_prvmsg.c) */
1261
1262 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1263  *
1264  * SYNOPSIS
1265  *
1266  *    int silc_client_add_private_message_key(SilcClient client,
1267  *                                            SilcClientConnection conn,
1268  *                                            SilcClientEntry client_entry,
1269  *                                            char *cipher,
1270  *                                            unsigned char *key,
1271  *                                            uint32 key_len,
1272  *                                            bool generate_key,
1273  *                                            bool responder);
1274  *
1275  * DESCRIPTION
1276  *
1277  *    Adds private message key to the client library. The key will be used to
1278  *    encrypt all private message between the client and the remote client
1279  *    indicated by the `client_entry'. If the `key' is NULL and the boolean
1280  *    value `generate_key' is TRUE the library will generate random key.
1281  *    The `key' maybe for example pre-shared-key, passphrase or similar.
1282  *    The `cipher' MAY be provided but SHOULD be NULL to assure that the
1283  *    requirements of the SILC protocol are met. The API, however, allows
1284  *    to allocate any cipher.
1285  *
1286  *    If `responder' is TRUE then the sending and receiving keys will be
1287  *    set according the client being the receiver of the private key.  If
1288  *    FALSE the client is being the sender (or negotiator) of the private
1289  *    key.
1290  *
1291  *    It is not necessary to set key for normal private message usage. If the
1292  *    key is not set then the private messages are encrypted using normal
1293  *    session keys. Setting the private key, however, increases the security. 
1294  *
1295  *    Returns FALSE if the key is already set for the `client_entry', TRUE
1296  *    otherwise. 
1297  *
1298  ***/
1299 int silc_client_add_private_message_key(SilcClient client,
1300                                         SilcClientConnection conn,
1301                                         SilcClientEntry client_entry,
1302                                         char *cipher,
1303                                         unsigned char *key,
1304                                         uint32 key_len,
1305                                         bool generate_key,
1306                                         bool responder);
1307
1308 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1309  *
1310  * SYNOPSIS
1311  *
1312  *    int silc_client_add_private_message_key_ske(SilcClient client,
1313  *                                                SilcClientConnection conn,
1314  *                                                SilcClientEntry client_entry,
1315  *                                                char *cipher,
1316  *                                                SilcSKEKeyMaterial *key);
1317  *
1318  * DESCRIPTION
1319  *
1320  *    Same as silc_client_add_private_message_key but takes the key material
1321  *    from the SKE key material structure. This structure is received if
1322  *    the application uses the silc_client_send_key_agreement to negotiate
1323  *    the key material. The `cipher' SHOULD be provided as it is negotiated
1324  *    also in the SKE protocol. 
1325  *
1326  ***/
1327 int silc_client_add_private_message_key_ske(SilcClient client,
1328                                             SilcClientConnection conn,
1329                                             SilcClientEntry client_entry,
1330                                             char *cipher,
1331                                             SilcSKEKeyMaterial *key,
1332                                             bool responder);
1333
1334 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
1335  *
1336  * SYNOPSIS
1337  *
1338  *    int silc_client_send_private_message_key(SilcClient client,
1339  *                                             SilcClientConnection conn,
1340  *                                             SilcClientEntry client_entry,
1341  *                                             int force_send);
1342  *
1343  * DESCRIPTION
1344  *
1345  *    Sends private message key payload to the remote client indicated by
1346  *    the `client_entry'. If the `force_send' is TRUE the packet is sent
1347  *    immediately. Returns FALSE if error occurs, TRUE otherwise. The
1348  *    application should call this function after setting the key to the
1349  *    client.
1350  *
1351  *    Note that the key sent using this function is sent to the remote client
1352  *    through the SILC network. The packet is protected using normal session
1353  *    keys. 
1354  *
1355  ***/
1356 int silc_client_send_private_message_key(SilcClient client,
1357                                          SilcClientConnection conn,
1358                                          SilcClientEntry client_entry,
1359                                          int force_send);
1360
1361 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1362  *
1363  * SYNOPSIS
1364  *
1365  *    int silc_client_del_private_message_key(SilcClient client,
1366  *                                            SilcClientConnection conn,
1367  *                                            SilcClientEntry client_entry);
1368  *
1369  * DESCRIPTION
1370  *
1371  *    Removes the private message from the library. The key won't be used
1372  *    after this to protect the private messages with the remote `client_entry'
1373  *    client. Returns FALSE on error, TRUE otherwise. 
1374  *
1375  ***/
1376 int silc_client_del_private_message_key(SilcClient client,
1377                                         SilcClientConnection conn,
1378                                         SilcClientEntry client_entry);
1379
1380 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1381  *
1382  * SYNOPSIS
1383  *
1384  *    SilcPrivateMessageKeys
1385  *    silc_client_list_private_message_keys(SilcClient client,
1386  *                                          SilcClientConnection conn,
1387  *                                          uint32 *key_count);
1388  * 
1389  * DESCRIPTION
1390  *
1391  *    Returns array of set private message keys associated to the connection
1392  *    `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1393  *    count to the `key_count' argument. The array must be freed by the caller
1394  *    by calling the silc_client_free_private_message_keys function. Note: 
1395  *    the keys returned in the array is in raw format. It might not be desired
1396  *    to show the keys as is. The application might choose not to show the keys
1397  *    at all or to show the fingerprints of the keys. 
1398  *
1399  ***/
1400 SilcPrivateMessageKeys
1401 silc_client_list_private_message_keys(SilcClient client,
1402                                       SilcClientConnection conn,
1403                                       uint32 *key_count);
1404
1405 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1406  *
1407  * SYNOPSIS
1408  *
1409  *    void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1410  *                                               uint32 key_count);
1411  * 
1412  * DESCRIPTION
1413  *
1414  *    Frees the SilcPrivateMessageKeys array returned by the function
1415  *    silc_client_list_private_message_keys. 
1416  *
1417  ***/
1418 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1419                                            uint32 key_count);
1420
1421
1422 /* Channel private key management (client_channel.c, 
1423    SilcChannelPrivateKey is defined in idlist.h) */
1424
1425 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1426  *
1427  * SYNOPSIS
1428  *
1429  *    int silc_client_add_channel_private_key(SilcClient client,
1430  *                                            SilcClientConnection conn,
1431  *                                            SilcChannelEntry channel,
1432  *                                            char *cipher,
1433  *                                            char *hmac,
1434  *                                            unsigned char *key,
1435  *                                            uint32 key_len);
1436  * 
1437  * DESCRIPTION
1438  *
1439  *    Adds private key for channel. This may be set only if the channel's mode
1440  *    mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1441  *    mode is not set. When channel has private key then the messages are
1442  *    encrypted using that key. All clients on the channel must also know the
1443  *    key in order to decrypt the messages. However, it is possible to have
1444  *    several private keys per one channel. In this case only some of the
1445  *    clients on the channel may know the one key and only some the other key.
1446  *
1447  *    The private key for channel is optional. If it is not set then the
1448  *    channel messages are encrypted using the channel key generated by the
1449  *    server. However, setting the private key (or keys) for the channel 
1450  *    significantly adds security. If more than one key is set the library
1451  *    will automatically try all keys at the message decryption phase. Note:
1452  *    setting many keys slows down the decryption phase as all keys has to
1453  *    be tried in order to find the correct decryption key. However, setting
1454  *    a few keys does not have big impact to the decryption performace. 
1455  *
1456  * NOTES
1457  *
1458  *    NOTE: This is entirely local setting. The key set using this function
1459  *    is not sent to the network at any phase.
1460  *
1461  *    NOTE: If the key material was originated by the SKE protocol (using
1462  *    silc_client_send_key_agreement) then the `key' MUST be the
1463  *    key->send_enc_key as this is dictated by the SILC protocol. However,
1464  *    currently it is not expected that the SKE key material would be used
1465  *    as channel private key. However, this API allows it. 
1466  *
1467  ***/
1468 int silc_client_add_channel_private_key(SilcClient client,
1469                                         SilcClientConnection conn,
1470                                         SilcChannelEntry channel,
1471                                         char *cipher,
1472                                         char *hmac,
1473                                         unsigned char *key,
1474                                         uint32 key_len);
1475
1476 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1477  *
1478  * SYNOPSIS
1479  *
1480  *    int silc_client_del_channel_private_keys(SilcClient client,
1481  *                                             SilcClientConnection conn,
1482  *                                             SilcChannelEntry channel);
1483  * 
1484  * DESCRIPTION
1485  *
1486  *    Removes all private keys from the `channel'. The old channel key is used
1487  *    after calling this to protect the channel messages. Returns FALSE on
1488  *    on error, TRUE otherwise. 
1489  *
1490  ***/
1491 int silc_client_del_channel_private_keys(SilcClient client,
1492                                          SilcClientConnection conn,
1493                                          SilcChannelEntry channel);
1494
1495 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1496  *
1497  * SYNOPSIS
1498  *
1499  *    int silc_client_del_channel_private_key(SilcClient client,
1500  *                                            SilcClientConnection conn,
1501  *                                            SilcChannelEntry channel,
1502  *                                            SilcChannelPrivateKey key);
1503  * 
1504  * DESCRIPTION
1505  *
1506  *    Removes and frees private key `key' from the channel `channel'. 
1507  *    The `key' is retrieved by calling the function 
1508  *    silc_client_list_channel_private_keys. The key is not used after
1509  *    this. If the key was last private key then the old channel key is
1510  *    used hereafter to protect the channel messages. This returns FALSE
1511  *    on error, TRUE otherwise. 
1512  *
1513  ***/
1514 int silc_client_del_channel_private_key(SilcClient client,
1515                                         SilcClientConnection conn,
1516                                         SilcChannelEntry channel,
1517                                         SilcChannelPrivateKey key);
1518
1519 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1520  *
1521  * SYNOPSIS
1522  *
1523  *    SilcChannelPrivateKey *
1524  *    silc_client_list_channel_private_keys(SilcClient client,
1525  *                                          SilcClientConnection conn,
1526  *                                          SilcChannelEntry channel,
1527  *                                          uint32 *key_count);
1528  *
1529  * DESCRIPTION
1530  *
1531  *    Returns array (pointers) of private keys associated to the `channel'.
1532  *    The caller must free the array by calling the function
1533  *    silc_client_free_channel_private_keys. The pointers in the array may be
1534  *    used to delete the specific key by giving the pointer as argument to the
1535  *    function silc_client_del_channel_private_key. 
1536  *
1537  ***/
1538 SilcChannelPrivateKey *
1539 silc_client_list_channel_private_keys(SilcClient client,
1540                                       SilcClientConnection conn,
1541                                       SilcChannelEntry channel,
1542                                       uint32 *key_count);
1543
1544 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1545  *
1546  * SYNOPSIS
1547  *
1548  *    void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1549  *                                               uint32 key_count);
1550  *
1551  * DESCRIPTION
1552  *
1553  *    Frees the SilcChannelPrivateKey array.
1554  *
1555  ***/
1556 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1557                                            uint32 key_count);
1558
1559
1560 /* Key Agreement routines (client_keyagr.c) */
1561
1562 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1563  *
1564  * SYNOPSIS
1565  *
1566  *    void silc_client_send_key_agreement(SilcClient client,
1567  *                                        SilcClientConnection conn,
1568  *                                        SilcClientEntry client_entry,
1569  *                                        char *hostname,
1570  *                                        int port,
1571  *                                        uint32 timeout_secs,
1572  *                                        SilcKeyAgreementCallback completion,
1573  *                                        void *context);
1574  *
1575  * DESCRIPTION
1576  *
1577  *    Sends key agreement request to the remote client indicated by the
1578  *    `client_entry'. If the caller provides the `hostname' and the `port'
1579  *    arguments then the library will bind the client to that hostname and
1580  *    that port for the key agreement protocol. It also sends the `hostname'
1581  *    and the `port' in the key agreement packet to the remote client. This
1582  *    would indicate that the remote client may initiate the key agreement
1583  *    protocol to the `hostname' on the `port'.  If port is zero then the
1584  *    bound port is undefined (the operating system defines it).
1585  *
1586  *    If the `hostname' and `port' is not provided then empty key agreement
1587  *    packet is sent to the remote client. The remote client may reply with
1588  *    the same packet including its hostname and port. If the library receives
1589  *    the reply from the remote client the `key_agreement' client operation
1590  *    callback will be called to verify whether the user wants to perform the
1591  *    key agreement or not. 
1592  *
1593  * NOTES
1594  *
1595  *    NOTE: If the application provided the `hostname' and the `port' and the 
1596  *    remote side initiates the key agreement protocol it is not verified
1597  *    from the user anymore whether the protocol should be executed or not.
1598  *    By setting the `hostname' and `port' the user gives permission to
1599  *    perform the protocol (we are responder in this case).
1600  *
1601  *    NOTE: If the remote side decides not to initiate the key agreement
1602  *    or decides not to reply with the key agreement packet then we cannot
1603  *    perform the key agreement at all. If the key agreement protocol is
1604  *    performed the `completion' callback with the `context' will be called.
1605  *    If remote side decides to ignore the request the `completion' will be
1606  *    called after the specified timeout, `timeout_secs'. 
1607  *
1608  *    NOTE: If the `hostname' and the `port' was not provided the `completion'
1609  *    will not be called at all since this does nothing more than sending
1610  *    a packet to the remote host.
1611  *
1612  *    NOTE: There can be only one active key agreement for one client entry.
1613  *    Before setting new one, the old one must be finished (it is finished
1614  *    after calling the completion callback) or the function 
1615  *    silc_client_abort_key_agreement must be called. 
1616  *
1617  ***/
1618 void silc_client_send_key_agreement(SilcClient client,
1619                                     SilcClientConnection conn,
1620                                     SilcClientEntry client_entry,
1621                                     const char *hostname,
1622                                     const char *bindhost,
1623                                     int port,
1624                                     uint32 timeout_secs,
1625                                     SilcKeyAgreementCallback completion,
1626                                     void *context);
1627
1628 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1629  *
1630  * SYNOPSIS
1631  *
1632  *    void 
1633  *    silc_client_perform_key_agreement(SilcClient client,
1634  *                                      SilcClientConnection conn,
1635  *                                      SilcClientEntry client_entry,
1636  *                                      char *hostname,
1637  *                                      int port,
1638  *                                      SilcKeyAgreementCallback completion,
1639  *                                      void *context);
1640  *
1641  * DESCRIPTION
1642  *
1643  *    Performs the actual key agreement protocol. Application may use this
1644  *    to initiate the key agreement protocol. This can be called for example
1645  *    after the application has received the `key_agreement' client operation,
1646  *    and did not return TRUE from it.
1647  *
1648  *    The `hostname' is the remote hostname (or IP address) and the `port'
1649  *    is the remote port. The `completion' callback with the `context' will
1650  *    be called after the key agreement protocol.
1651  *
1652  * NOTES
1653  * 
1654  *    NOTE: If the application returns TRUE in the `key_agreement' client
1655  *    operation the library will automatically start the key agreement. In this
1656  *    case the application must not call this function. However, application
1657  *    may choose to just ignore the `key_agreement' client operation (and
1658  *    merely just print information about it on the screen) and call this
1659  *    function when the user whishes to do so (by, for example, giving some
1660  *    specific command). Thus, the API provides both, automatic and manual
1661  *    initiation of the key agreement. Calling this function is the manual
1662  *    initiation and returning TRUE in the `key_agreement' client operation
1663  *    is the automatic initiation. 
1664  *
1665  ***/
1666 void silc_client_perform_key_agreement(SilcClient client,
1667                                        SilcClientConnection conn,
1668                                        SilcClientEntry client_entry,
1669                                        char *hostname,
1670                                        int port,
1671                                        SilcKeyAgreementCallback completion,
1672                                        void *context);
1673
1674 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1675  *
1676  * SYNOPSIS
1677  *
1678  *    void
1679  *    silc_client_perform_key_agreement_fd(SilcClient client,
1680  *                                         SilcClientConnection conn,
1681  *                                         SilcClientEntry client_entry,
1682  *                                         int sock,
1683  *                                         char *hostname,
1684  *                                         SilcKeyAgreementCallback completion,
1685  *                                         void *context);
1686  *
1687  * DESCRIPTION
1688  *
1689  *    Same as above but application has created already the connection to 
1690  *    the remote host. The `sock' is the socket to the remote connection. 
1691  *    Application can use this function if it does not want the client library
1692  *    to create the connection. 
1693  *
1694  ***/
1695 void silc_client_perform_key_agreement_fd(SilcClient client,
1696                                           SilcClientConnection conn,
1697                                           SilcClientEntry client_entry,
1698                                           int sock,
1699                                           char *hostname,
1700                                           SilcKeyAgreementCallback completion,
1701                                           void *context);
1702
1703 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1704  *
1705  * SYNOPSIS
1706  *
1707  *    void silc_client_abort_key_agreement(SilcClient client,
1708  *                                         SilcClientConnection conn,
1709  *                                         SilcClientEntry client_entry);
1710  *
1711  * DESCRIPTION
1712  *
1713  *    This function can be called to unbind the hostname and the port for
1714  *    the key agreement protocol. However, this function has effect only 
1715  *    before the key agreement protocol has been performed. After it has
1716  *    been performed the library will automatically unbind the port. The 
1717  *    `client_entry' is the client to which we sent the key agreement 
1718  *    request.  The key agreement completion callback will be called
1719  *    with SILC_KEY_AGREEMENT_ABORTED status.
1720  *
1721  ***/
1722 void silc_client_abort_key_agreement(SilcClient client,
1723                                      SilcClientConnection conn,
1724                                      SilcClientEntry client_entry);
1725
1726
1727 /* Misc functions */
1728
1729 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1730  *
1731  * SYNOPSIS
1732  *
1733  *    void silc_client_set_away_message(SilcClient client,
1734  *                                      SilcClientConnection conn,
1735  *                                      char *message);
1736  *
1737  * DESCRIPTION
1738  *
1739  *    Sets away `message'.  The away message may be set when the client's
1740  *    mode is changed to SILC_UMODE_GONE and the client whishes to reply
1741  *    to anyone who sends private message.  The `message' will be sent
1742  *    automatically back to the the client who send private message.  If
1743  *    away message is already set this replaces the old message with the
1744  *    new one.  If `message' is NULL the old away message is removed. 
1745  *    The sender may freely free the memory of the `message'. 
1746  *
1747  ***/
1748 void silc_client_set_away_message(SilcClient client,
1749                                   SilcClientConnection conn,
1750                                   char *message);
1751
1752
1753 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
1754  *
1755  * SYNOPSIS
1756  *
1757  *    typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1758  *                                              SilcClientConnection conn,
1759  *                                              SilcAuthMethod auth_meth,
1760  *                                              void *context);
1761  *
1762  * DESCRIPTION
1763  *
1764  *    Connection authentication method request callback. This is called
1765  *    by the client library after it has received the authentication method
1766  *    that the application requested by calling the function
1767  *    silc_client_request_authentication_method.
1768  *
1769  ***/
1770 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1771                                           SilcClientConnection conn,
1772                                           SilcAuthMethod auth_meth,
1773                                           void *context);
1774
1775 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
1776  *
1777  * SYNOPSIS
1778  *
1779  *    void 
1780  *    silc_client_request_authentication_method(SilcClient client,
1781  *                                              SilcClientConnection conn,
1782  *                                              SilcConnectionAuthRequest 
1783  *                                                callback,
1784  *                                              void *context);
1785  *
1786  * DESCRIPTION
1787  *
1788  *    This function can be used to request the current authentication method
1789  *    from the server. This may be called when connecting to the server
1790  *    and the client library requests the authentication data from the
1791  *    application. If the application does not know the current authentication
1792  *    method it can request it from the server using this function.
1793  *    The `callback' with `context' will be called after the server has
1794  *    replied back with the current authentication method.
1795  *
1796  ***/
1797 void 
1798 silc_client_request_authentication_method(SilcClient client,
1799                                           SilcClientConnection conn,
1800                                           SilcConnectionAuthRequest callback,
1801                                           void *context);
1802
1803 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
1804  *
1805  * NAME
1806  *
1807  *    typedef enum { ... } SilcClientMonitorStatus;
1808  *
1809  * DESCRIPTION
1810  *
1811  *    File transmission session status types.  These will indicate
1812  *    the status of the file transmission session.
1813  *
1814  * SOURCE
1815  */
1816 typedef enum {
1817   SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT,    /* In key agreemenet phase */
1818   SILC_CLIENT_FILE_MONITOR_SEND,             /* Sending file */
1819   SILC_CLIENT_FILE_MONITOR_RECEIVE,          /* Receiving file */
1820   SILC_CLIENT_FILE_MONITOR_GET,
1821   SILC_CLIENT_FILE_MONITOR_PUT,
1822   SILC_CLIENT_FILE_MONITOR_CLOSED,           /* Session closed */
1823   SILC_CLIENT_FILE_MONITOR_ERROR,            /* Error during session */
1824 } SilcClientMonitorStatus;
1825 /***/
1826
1827 /****d* silcclient/SilcClientAPI/SilcClientFileError
1828  *
1829  * NAME
1830  *
1831  *    typedef enum { ... } SilcClientFileError;
1832  *
1833  * DESCRIPTION
1834  *
1835  *    File transmission error types.  These types are returned by
1836  *    some of the file transmission functions, and by the monitor
1837  *    callback to indicate error.
1838  *
1839  * SOURCE
1840  */
1841 typedef enum {
1842   SILC_CLIENT_FILE_OK,
1843   SILC_CLIENT_FILE_ERROR,
1844   SILC_CLIENT_FILE_UNKNOWN_SESSION,
1845   SILC_CLIENT_FILE_ALREADY_STARTED,
1846   SILC_CLIENT_FILE_NO_SUCH_FILE,
1847   SILC_CLIENT_FILE_PERMISSION_DENIED,
1848 } SilcClientFileError;
1849 /***/
1850
1851 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
1852  *
1853  * SYNOPSIS
1854  *
1855  *    typedef void (*SilcClientFileMonitor)(SilcClient client,
1856  *                                          SilcClientConnection conn,
1857  *                                          SilcClientMonitorStatus status,
1858  *                                          SilcClientFileError error,
1859  *                                          uint64 offset,
1860  *                                          uint64 filesize,
1861  *                                          SilcClientEntry client_entry,
1862  *                                          uint32 session_id,
1863  *                                          const char *filepath,
1864  *                                          void *context);
1865  *
1866  * DESCRIPTION
1867  *
1868  *    Monitor callback that is called during the file transmission to
1869  *    monitor the transmission process.  The `status' indicates the current
1870  *    monitoring process.  The `error' will indicate the error type
1871  *    if `status' is SILC_CLIENT_FILE_MONITOR_ERROR.  The `offset' is the
1872  *    currently transmitted amount of total `filesize'.  The `client_entry'
1873  *    indicates the remote client, and the transmission session ID is the 
1874  *    `session_id'.  The filename being transmitted is indicated by the 
1875  *    `filepath'.
1876  *
1877  ***/
1878 typedef void (*SilcClientFileMonitor)(SilcClient client,
1879                                       SilcClientConnection conn,
1880                                       SilcClientMonitorStatus status,
1881                                       SilcClientFileError error,
1882                                       uint64 offset,
1883                                       uint64 filesize,
1884                                       SilcClientEntry client_entry,
1885                                       uint32 session_id,
1886                                       const char *filepath,
1887                                       void *context);
1888
1889 /****f* silcclient/SilcClientAPI/silc_client_file_send
1890  *
1891  * SYNOPSIS
1892  *
1893  *    uint32 silc_client_file_send(SilcClient client,
1894  *                                 SilcClientConnection conn,
1895  *                                 SilcClientFileMonitor monitor,
1896  *                                 void *monitor_context,
1897  *                                 const char *local_ip,
1898  *                                 uint32 local_port,
1899  *                                 SilcClientEntry client_entry,
1900  *                                 const char *filepath);
1901  *
1902  * DESCRIPTION
1903  *
1904  *    Sends a file indicated by the `filepath' to the remote client 
1905  *    indicated by the `client_entry'.  This will negotiate a secret key
1906  *    with the remote client before actually starting the transmission of
1907  *    the file.  The `monitor' callback will be called to monitor the
1908  *    transmission of the file.
1909  *
1910  *    This returns a file session ID for the file transmission.  It can
1911  *    be used to close the session (and abort the file transmission) by
1912  *    calling the silc_client_file_close function.  The session ID is
1913  *    also returned in the `monitor' callback. This returns 0 if the
1914  *    file indicated by the `filepath' is being transmitted to the remote
1915  *    client indicated by the `client_entry', already.
1916  *
1917  *    If the `local_ip' is provided then this will try to bind the 
1918  *    listener for key exchange protocol to that IP.  If `local_port' is
1919  *    non-zero that port is used.  If `local_ip' is NULL then this will
1920  *    automatically attempt to bind it to local IP address of the machine.
1921  *    If that fails then this does not bind to any address and port, and
1922  *    assume that the remote client will provide the listener for the
1923  *    key exchange protocol.
1924  *
1925  *    If error will occur during the file transfer process the error
1926  *    status will be returned in the monitor callback.  In this case
1927  *    the application must call silc_client_file_close to close the
1928  *    session.
1929  *
1930  ***/
1931 uint32 silc_client_file_send(SilcClient client,
1932                              SilcClientConnection conn,
1933                              SilcClientFileMonitor monitor,
1934                              void *monitor_context,
1935                              const char *local_ip,
1936                              uint32 local_port,
1937                              SilcClientEntry client_entry,
1938                              const char *filepath);
1939
1940 /****f* silcclient/SilcClientAPI/silc_client_file_receive
1941  *
1942  * SYNOPSIS
1943  *
1944  *    SilcClientFileError 
1945  *    silc_client_file_receive(SilcClient client,
1946  *                             SilcClientConnection conn,
1947  *                             SilcClientFileMonitor monitor,
1948  *                             void *monitor_context,
1949  *                             uint32 session_id);
1950  *
1951  * DESCRIPTION
1952  *
1953  *    Receives a file from a client indicated by the `client_entry'.  The
1954  *    `session_id' indicates the file transmission session and it has been
1955  *    received in the `ftp' client operation function.  This will actually
1956  *    perform the key agreement protocol with the remote client before
1957  *    actually starting the file transmission.  The `monitor' callback
1958  *    will be called to monitor the transmission.
1959  *
1960  *    If error will occur during the file transfer process the error
1961  *    status will be returned in the monitor callback.  In this case
1962  *    the application must call silc_client_file_close to close the
1963  *    session.
1964  *
1965  ***/
1966 SilcClientFileError 
1967 silc_client_file_receive(SilcClient client,
1968                          SilcClientConnection conn,
1969                          SilcClientFileMonitor monitor,
1970                          void *monitor_context,
1971                          uint32 session_id);
1972
1973 /****f* silcclient/SilcClientAPI/silc_client_file_close
1974  *
1975  * SYNOPSIS
1976  *
1977  *    SilcClientFileError silc_client_file_close(SilcClient client,
1978  *                                               SilcClientConnection conn,
1979  *                                               uint32 session_id);
1980  *
1981  * DESCRIPTION
1982  *
1983  *    Closes file transmission session indicated by the `session_id'.
1984  *    If file transmission is being conducted it will be aborted
1985  *    automatically. This function is also used to close the session
1986  *    after successful file transmission. This function can be used
1987  *    also to reject incoming file transmission request.
1988  *
1989  ***/
1990 SilcClientFileError silc_client_file_close(SilcClient client,
1991                                            SilcClientConnection conn,
1992                                            uint32 session_id);
1993
1994 #endif