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