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. The `msg' is the message.  Note that
243      `msg' maybe NULL. */
244   void (*channel_message)(SilcClient client, SilcClientConnection conn, 
245                           SilcClientEntry sender, SilcChannelEntry channel, 
246                           SilcMessageFlags flags, char *msg);
247
248   /* Private message to the client. The `sender' is the sender of the
249      message. */
250   void (*private_message)(SilcClient client, SilcClientConnection conn,
251                           SilcClientEntry sender, SilcMessageFlags flags,
252                           char *msg);
253
254   /* Notify message to the client. The notify arguments are sent in the
255      same order as servers sends them. The arguments are same as received
256      from the server except for ID's.  If ID is received application receives
257      the corresponding entry to the ID. For example, if Client ID is received
258      application receives SilcClientEntry.  Also, if the notify type is
259      for channel the channel entry is sent to application (even if server
260      does not send it because client library gets the channel entry from
261      the Channel ID in the packet's header). */
262   void (*notify)(SilcClient client, SilcClientConnection conn, 
263                  SilcNotifyType type, ...);
264
265   /* Command handler. This function is called always in the command function.
266      If error occurs it will be called as well. `conn' is the associated
267      client connection. `cmd_context' is the command context that was
268      originally sent to the command. `success' is FALSE if error occurred
269      during command. `command' is the command being processed. It must be
270      noted that this is not reply from server. This is merely called just
271      after application has called the command. Just to tell application
272      that the command really was processed. */
273   void (*command)(SilcClient client, SilcClientConnection conn, 
274                   SilcClientCommandContext cmd_context, int success,
275                   SilcCommand command);
276
277   /* Command reply handler. This function is called always in the command reply
278      function. If error occurs it will be called as well. Normal scenario
279      is that it will be called after the received command data has been parsed
280      and processed. The function is used to pass the received command data to
281      the application. 
282      
283      `conn' is the associated client connection. `cmd_payload' is the command
284      payload data received from server and it can be ignored. It is provided
285      if the application would like to re-parse the received command data,
286      however, it must be noted that the data is parsed already by the library
287      thus the payload can be ignored. `success' is FALSE if error occurred.
288      In this case arguments are not sent to the application. The `status' is
289      the command reply status server returned. The `command' is the command
290      reply being processed. The function has variable argument list and each
291      command defines the number and type of arguments it passes to the
292      application (on error they are not sent). */
293   void (*command_reply)(SilcClient client, SilcClientConnection conn,
294                         SilcCommandPayload cmd_payload, int success,
295                         SilcCommand command, SilcCommandStatus status, ...);
296
297   /* Called to indicate that connection was either successfully established
298      or connecting failed.  This is also the first time application receives
299      the SilcClientConnection objecet which it should save somewhere.
300      If the `success' is FALSE the application must always call the function
301      silc_client_close_connection. */
302   void (*connect)(SilcClient client, SilcClientConnection conn, int success);
303
304   /* Called to indicate that connection was disconnected to the server. */
305   void (*disconnect)(SilcClient client, SilcClientConnection conn);
306
307   /* Find authentication method and authentication data by hostname and
308      port. The hostname may be IP address as well. When the authentication
309      method has been resolved the `completion' callback with the found
310      authentication method and authentication data is called. The `conn'
311      may be NULL. */
312   void (*get_auth_method)(SilcClient client, SilcClientConnection conn,
313                           char *hostname, uint16 port,
314                           SilcGetAuthMeth completion, void *context);
315
316   /* Verifies received public key. The `conn_type' indicates which entity
317      (server, client etc.) has sent the public key. If user decides to trust
318      the key may be saved as trusted public key for later use. The 
319      `completion' must be called after the public key has been verified. */
320   void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
321                             SilcSocketType conn_type, unsigned char *pk, 
322                             uint32 pk_len, SilcSKEPKType pk_type,
323                             SilcVerifyPublicKey completion, void *context);
324
325   /* Ask (interact, that is) a passphrase from user. The passphrase is
326      returned to the library by calling the `completion' callback with
327      the `context'. */
328   void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
329                          SilcAskPassphrase completion, void *context);
330
331   /* Notifies application that failure packet was received.  This is called
332      if there is some protocol active in the client.  The `protocol' is the
333      protocol context.  The `failure' is opaque pointer to the failure
334      indication.  Note, that the `failure' is protocol dependant and
335      application must explicitly cast it to correct type.  Usually `failure'
336      is 32 bit failure type (see protocol specs for all protocol failure
337      types). */
338   void (*failure)(SilcClient client, SilcClientConnection conn, 
339                   SilcProtocol protocol, void *failure);
340
341   /* Asks whether the user would like to perform the key agreement protocol.
342      This is called after we have received an key agreement packet or an
343      reply to our key agreement packet. This returns TRUE if the user wants
344      the library to perform the key agreement protocol and FALSE if it is not
345      desired (application may start it later by calling the function
346      silc_client_perform_key_agreement). If TRUE is returned also the
347      `completion' and `context' arguments must be set by the application. */
348   int (*key_agreement)(SilcClient client, SilcClientConnection conn,
349                        SilcClientEntry client_entry, const char *hostname,
350                        uint16 port, SilcKeyAgreementCallback *completion,
351                        void **context);
352
353   /* Notifies application that file transfer protocol session is being
354      requested by the remote client indicated by the `client_entry' from
355      the `hostname' and `port'. The `session_id' is the file transfer
356      session and it can be used to either accept or reject the file
357      transfer request, by calling the silc_client_file_receive or
358      silc_client_file_close, respectively. */
359   void (*ftp)(SilcClient client, SilcClientConnection conn,
360               SilcClientEntry client_entry, uint32 session_id,
361               const char *hostname, uint16 port);
362 } SilcClientOperations;
363 /***/
364
365 /****f* silcclient/SilcClientAPI/SilcNicknameFormatParse
366  *
367  * SYNOPSIS
368  *
369  *    typedef void (*SilcNicknameFormatParse)(const char *nickname,
370  *                                            char **ret_nickname);
371  *
372  * DESCRIPTION
373  *
374  *    A callback function provided by the application for the library in
375  *    SilcClientParams structure. This function parses the formatted
376  *    nickname string `nickname' and returns the true nickname to the
377  *    `ret_nickname' pointer. The library can call this function at
378  *    any time.
379  *
380  ***/
381 typedef void (*SilcNicknameFormatParse)(const char *nickname,
382                                         char **ret_nickname);
383
384 /****s* silcclient/SilcClientAPI/SilcClientParams
385  *
386  * NAME
387  *
388  *    typedef struct { ... } SilcClientParams;
389  *
390  * DESCRIPTION
391  *
392  *    Client parameters. This can be filled with proper values and
393  *    given as argument to the silc_client_alloc function. The structure
394  *    hold various parameters which affects the function of the client.
395  *
396  * SOURCE
397  */
398 typedef struct {
399   /* Number of maximum tasks the client library's scheduler can handle.
400      If set to zero, the default value will be used (200). For WIN32
401      systems this should be set to 64 as it is the hard limit dictated
402      by the WIN32. */
403   int task_max;
404
405   /* Rekey timeout in seconds. The client will perform rekey in this
406      time interval. If set to zero, the default value will be used. */
407   unsigned int rekey_secs;
408
409   /* Connection authentication method request timeout. If server does not
410      reply back the current authentication method when we've requested it
411      in this time interval we'll assume the reply will not come at all. 
412      If set to zero, the default value (2 seconds) will be used. */
413   unsigned int connauth_request_secs;
414
415   /* Nickname format string. This can be used to order the client library
416      to save the nicknames in the library in a certain format. Since 
417      nicknames are not unique in SILC it is possible to have multiple same
418      nicknames. Using this format string it is possible to order the library
419      to separate the multiple same nicknames from each other. The format
420      types are defined below and they can appear in any order in the format
421      string. If this is NULL then default format is used which is the
422      default nickname without anything else. The string MUST be NULL
423      terminated.
424      
425      Following format types are available:
426      
427      %n  nickname      - the real nickname returned by the server (mandatory)
428      %h  hostname      - the stripped hostname of the client
429      %H  full hostname - the full hostname of the client
430      %s  server name   - the server name the client is connected
431      %S  full server   - the full server name the client is connected
432      %a  number        - ascending number in case there are several
433                          same nicknames (fe. nick@host and nick@host2)
434
435      Example format strings: "%n@%h%a"   (fe. nick@host, nick@host2)
436                              "%a!%n@%s"  (fe. nick@server, 2!nick@server)
437                              "%n@%H"     (fe. nick@host.domain.com)
438
439      By default this format is employed to the nicknames by the libary
440      only when there appears multiple same nicknames. If the library has
441      only one nickname cached the nickname is saved as is and without the
442      defined format. If you want always to save the nickname in the defined
443      format set the boolean field `nickname_force_format' to value TRUE.
444   */
445   char nickname_format[32];
446
447   /* If this is set to TRUE then the `nickname_format' is employed to all
448      saved nicknames even if there are no multiple same nicknames in the 
449      cache. By default this is FALSE, which means that the `nickname_format'
450      is employed only if the library will receive a nickname that is
451      already saved in the cache. It is recommended to leave this to FALSE
452      value. */
453   bool nickname_force_format;
454
455   /* A callback function provided by the application for the library to
456      parse the nickname from the formatted nickname string. Even though
457      the libary formats the nicknames the application knows generally the
458      format better so this function should be provided for the library
459      if the application sets the `nickname_format' field. The library
460      will call this to get the true nickname from the provided formatted
461      nickname string whenever it needs the true nickname. */
462   SilcNicknameFormatParse nickname_parse;
463
464 } SilcClientParams;
465 /***/
466
467
468 /* Initialization functions (client.c) */
469
470 /****f* silcclient/SilcClientAPI/silc_client_alloc
471  *
472  * SYNOPSIS
473  *
474  *    SilcClient silc_client_alloc(SilcClientOperations *ops, 
475  *                                 SilcClientParams *params,
476  *                                 void *application,
477  *                                 const char *silc_version);
478  *
479  * DESCRIPTION
480  *
481  *    Allocates new client object. This has to be done before client may
482  *    work. After calling this one must call silc_client_init to initialize
483  *    the client. The `application' is application specific user data pointer
484  *    and caller must free it. The `silc_version' is the application version
485  *    that will be used to compare against remote host's (usually a server)
486  *    version string.
487  *
488  ***/
489 SilcClient silc_client_alloc(SilcClientOperations *ops, 
490                              SilcClientParams *params,
491                              void *application,
492                              const char *silc_version);
493
494 /****f* silcclient/SilcClientAPI/silc_client_free
495  *
496  * SYNOPSIS
497  *
498  *    void silc_client_free(SilcClient client);
499  *
500  * DESCRIPTION
501  *
502  *    Frees client object and its internals.  The execution of the client
503  *    should be stopped with silc_client_stop function before calling
504  *    this function.
505  *
506  ***/
507 void silc_client_free(SilcClient client);
508
509 /****f* silcclient/SilcClientAPI/silc_client_init
510  *
511  * SYNOPSIS
512  *
513  *    int silc_client_init(SilcClient client);
514  *
515  * DESCRIPTION
516  *
517  *    Initializes the client. This makes all the necessary steps to make
518  *    the client ready to be run. One must call silc_client_run to run the
519  *    client. Returns FALSE if error occurred, TRUE otherwise.
520  *
521  ***/
522 int silc_client_init(SilcClient client);
523
524 /****f* silcclient/SilcClientAPI/silc_client_run
525  *
526  * SYNOPSIS
527  *
528  *    void silc_client_run(SilcClient client);
529  *
530  * DESCRIPTION
531  *
532  *    Runs the client. This starts the scheduler from the utility library.
533  *    When this functions returns the execution of the appliation is over.
534  *
535  ***/
536 void silc_client_run(SilcClient client);
537
538 /****f* silcclient/SilcClientAPI/silc_client_run_one
539  *
540  * SYNOPSIS
541  *
542  *    void silc_client_run_one(SilcClient client);
543  *
544  * DESCRIPTION
545  *
546  *    Runs the client and returns immeadiately. This function is used when
547  *    the SILC Client object indicated by the `client' is run under some
548  *    other scheduler, or event loop or main loop.  On GUI applications,
549  *    for example this may be desired to used to run the client under the
550  *    GUI application's main loop.  Typically the GUI application would
551  *    register an idle task that calls this function multiple times in
552  *    a second to quickly process the SILC specific data.
553  *
554  ***/
555 void silc_client_run_one(SilcClient client);
556
557 /****f* silcclient/SilcClientAPI/silc_client_stop
558  *
559  * SYNOPSIS
560  *
561  *    void silc_client_stop(SilcClient client);
562  *
563  * DESCRIPTION
564  *
565  *    Stops the client. This is called to stop the client and thus to stop
566  *    the program.  The client context must be freed with the silc_client_free
567  *    function.
568  *
569  ***/
570 void silc_client_stop(SilcClient client);
571
572
573 /* Connecting functions (client.c) */
574
575 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
576  *
577  * SYNOPSIS
578  *
579  *    int silc_client_connect_to_server(SilcClient client, int port,
580  *                                      char *host, void *context);
581  *
582  * DESCRIPTION
583  *
584  *    Connects to remote server. This is the main routine used to connect
585  *    to SILC server. Returns -1 on error and the created socket otherwise. 
586  *    The `context' is user context that is saved into the SilcClientConnection
587  *    that is created after the connection is created. Note that application
588  *    may handle the connecting process outside the library. If this is the
589  *    case then this function is not used at all. When the connecting is
590  *    done the `connect' client operation is called.
591  *
592  ***/
593 int silc_client_connect_to_server(SilcClient client, int port,
594                                   char *host, void *context);
595
596 /****f* silcclient/SilcClientAPI/silc_client_add_connection
597  *
598  * SYNOPSIS
599  *
600  *    SilcClientConnection silc_client_add_connection(SilcClient client,
601  *                                                    char *hostname,
602  *                                                    int port,
603  *                                                    void *context);
604  *
605  * DESCRIPTION
606  *
607  *    Allocates and adds new connection to the client. This adds the allocated
608  *    connection to the connection table and returns a pointer to it. A client
609  *    can have multiple connections to multiple servers. Every connection must
610  *    be added to the client using this function. User data `context' may
611  *    be sent as argument. This function is normally used only if the 
612  *    application performed the connecting outside the library. The library
613  *    however may use this internally.
614  *
615  ***/
616 SilcClientConnection silc_client_add_connection(SilcClient client,
617                                                 char *hostname,
618                                                 int port,
619                                                 void *context);
620
621 /****f* silcclient/SilcClientAPI/silc_client_del_connection
622  *
623  * SYNOPSIS
624  *
625  *    void silc_client_del_connection(SilcClient client, 
626  *                                    SilcClientConnection conn);
627  *
628  * DESCRIPTION
629  *
630  *    Removes connection from client. Frees all memory. The library
631  *    call this function automatically for all connection contexts.
632  *    The application however may free the connection contexts it has
633  *    allocated.
634  *
635  ***/
636 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
637
638 /****f* silcclient/SilcClientAPI/silc_client_add_socket
639  *
640  * SYNOPSIS
641  *
642  *    void silc_client_add_socket(SilcClient client, 
643  *                                SilcSocketConnection sock);
644  *
645  * DESCRIPTION
646  *
647  *    Adds listener socket to the listener sockets table. This function is
648  *    used to add socket objects that are listeners to the client.  This should
649  *    not be used to add other connection objects.
650  *
651  ***/
652 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
653
654 /****f* silcclient/SilcClientAPI/silc_client_del_socket
655  *
656  * SYNOPSIS
657  *
658  *    void silc_client_del_socket(SilcClient client, 
659  *                                SilcSocketConnection sock);
660  *
661  * DESCRIPTION
662  *
663  *    Deletes listener socket from the listener sockets table.  If the
664  *    application has added a socket with silc_client_add_socket it must
665  *    also free it using this function.
666  *
667  ***/
668 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
669
670 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
671  *
672  * SYNOPSIS
673  *
674  *    void silc_client_start_key_exchange(SilcClient client,
675  *                                        SilcClientConnection conn,
676  *                                        int fd);
677  *
678  * DESCRIPTION
679  *
680  *    Start SILC Key Exchange (SKE) protocol to negotiate shared secret
681  *    key material between client and server.  This function can be called
682  *    directly if application is performing its own connecting and does not
683  *    use the connecting provided by this library. This function is normally
684  *    used only if the application performed the connecting outside the
685  *    library. The library however may use this internally. Returns FALSE
686  *    if the key exchange could not be started.
687  *
688  ***/
689 void silc_client_start_key_exchange(SilcClient client,
690                                     SilcClientConnection conn,
691                                     int fd);
692
693 /****f* silcclient/SilcClientAPI/silc_client_close_connection
694  *
695  * SYNOPSIS
696  *
697  *    void silc_client_close_connection(SilcClient client,
698  *                                      SilcSocketConnection sock,
699  *                                      SilcClientConnection conn);
700  *
701  * DESCRIPTION
702  *
703  *    Closes connection to remote end. Free's all allocated data except
704  *    for some information such as nickname etc. that are valid at all time. 
705  *    If the `sock' is NULL then the conn->sock will be used.  If `sock' is
706  *    provided it will be checked whether the sock and `conn->sock' are the
707  *    same (they can be different, ie. a socket can use `conn' as its
708  *    connection but `conn->sock' might be actually a different connection
709  *    than the `sock'). 
710  *
711  ***/
712 void silc_client_close_connection(SilcClient client,
713                                   SilcSocketConnection sock,
714                                   SilcClientConnection conn);
715
716
717 /* Message sending functions (client_channel.c and client_prvmsg.c) */
718
719 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
720  *
721  * SYNOPSIS
722  *
723  *    void silc_client_send_channel_message(SilcClient client, 
724  *                                          SilcClientConnection conn,
725  *                                          SilcChannelEntry channel,
726  *                                          SilcChannelPrivateKey key,
727  *                                          SilcMessageFlags flags,
728  *                                          unsigned char *data, 
729  *                                          uint32 data_len, 
730  *                                          int force_send);
731  *
732  * DESCRIPTION
733  *
734  *    Sends packet to the `channel'. Packet to channel is always encrypted
735  *    differently from "normal" packets. SILC header of the packet is 
736  *    encrypted with the next receiver's key and the rest of the packet is
737  *    encrypted with the channel specific key. Padding and HMAC is computed
738  *    with the next receiver's key. The `data' is the channel message. If
739  *    the `force_send' is TRUE then the packet is sent immediately. 
740  *
741  *    If `key' is provided then that private key is used to encrypt the
742  *    channel message.  If it is not provided, private keys has not been
743  *    set at all, the normal channel key is used automatically.  If private
744  *    keys are set then the first key (the key that was added first as
745  *    private key) is used. 
746  *
747  ***/
748 void silc_client_send_channel_message(SilcClient client, 
749                                       SilcClientConnection conn,
750                                       SilcChannelEntry channel,
751                                       SilcChannelPrivateKey key,
752                                       SilcMessageFlags flags,
753                                       unsigned char *data, 
754                                       uint32 data_len, 
755                                       int force_send);
756
757 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
758  *
759  * SYNOPSIS
760  *
761  *    void silc_client_send_private_message(SilcClient client,
762  *                                          SilcClientConnection conn,
763  *                                          SilcClientEntry client_entry,
764  *                                          SilcMessageFlags flags,
765  *                                          unsigned char *data, 
766  *                                          uint32 data_len, 
767  *                                          int force_send);
768  *
769  * DESCRIPTION
770  *
771  *    Sends private message to remote client. If private message key has
772  *    not been set with this client then the message will be encrypted using
773  *    normal session keys. Private messages are special packets in SILC
774  *    network hence we need this own function for them. This is similar
775  *    to silc_client_packet_send_to_channel except that we send private
776  *    message. The `data' is the private message. If the `force_send' is
777  *    TRUE the packet is sent immediately. 
778  *
779  ***/
780 void silc_client_send_private_message(SilcClient client,
781                                       SilcClientConnection conn,
782                                       SilcClientEntry client_entry,
783                                       SilcMessageFlags flags,
784                                       unsigned char *data, 
785                                       uint32 data_len, 
786                                       int force_send);
787
788
789 /* Client and Channel entry retrieval (idlist.c) */
790
791 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
792  *
793  * SYNOPSIS
794  *
795  *    typedef void (*SilcGetClientCallback)(SilcClient client,
796  *                                          SilcClientConnection conn,
797  *                                          SilcClientEntry *clients,
798  *                                          uint32 clients_count,
799  *                                          void *context);
800  *
801  * DESCRIPTION
802  *
803  *    Callback function given to the silc_client_get_client function. The
804  *    found entries are allocated into the `clients' array. The array must
805  *    not be freed by the receiver, the library will free it later. If the
806  *    `clients' is NULL, no such clients exist in the SILC Network.
807  *
808  ***/
809 typedef void (*SilcGetClientCallback)(SilcClient client,
810                                       SilcClientConnection conn,
811                                       SilcClientEntry *clients,
812                                       uint32 clients_count,
813                                       void *context);
814
815 /****f* silcclient/SilcClientAPI/silc_client_get_clients
816  *
817  * SYNOPSIS
818  *
819  *    void silc_client_get_clients(SilcClient client,
820  *                                 SilcClientConnection conn,
821  *                                 const char *nickname,
822  *                                 const char *server,
823  *                                 SilcGetClientCallback completion,
824  *                                 void *context);
825  *
826  * DESCRIPTION
827  *
828  *    Finds client entry or entries by the `nickname' and `server'. The 
829  *    completion callback will be called when the client entries has been
830  *    found.
831  *
832  * NOTES
833  *
834  *    NOTE: This function is always asynchronous and resolves the client
835  *    information from the server. Thus, if you already know the client
836  *    information then use the silc_client_get_client_by_id function to
837  *    get the client entry since this function may be very slow and should
838  *    be used only to initially get the client entries. 
839  *
840  ***/
841 void silc_client_get_clients(SilcClient client,
842                              SilcClientConnection conn,
843                              const char *nickname,
844                              const char *server,
845                              SilcGetClientCallback completion,
846                              void *context);
847
848 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
849  *
850  * SYNOPSIS
851  *
852  *    SilcClientEntry *silc_client_get_clients_local(SilcClient client,
853  *                                                   SilcClientConnection conn,
854  *                                                   const char *nickname,
855  *                                                   const char *format,
856  *                                                   uint32 *clients_count);
857  *
858  * DESCRIPTION
859  *
860  *    Same as silc_client_get_clients function but does not resolve anything
861  *    from the server. This checks local cache and returns all matching
862  *    clients from the local cache. If none was found this returns NULL.
863  *    The `nickname' is the real nickname of the client, and the `format'
864  *    is the formatted nickname to find exact match from multiple found
865  *    entries. The format must be same as given in the SilcClientParams
866  *    structure to the client library. If the `format' is NULL all found
867  *    clients by `nickname' are returned. The caller must return the
868  *    returned array.
869  *
870  ***/
871 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
872                                                SilcClientConnection conn,
873                                                const char *nickname,
874                                                const char *format,
875                                                uint32 *clients_count);
876
877 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
878  *
879  * SYNOPSIS
880  *
881  *    void silc_client_get_clients_by_list(SilcClient client,
882  *                                         SilcClientConnection conn,
883  *                                         uint32 list_count,
884  *                                         SilcBuffer client_id_list,
885  *                                         SilcGetClientCallback completion,
886  *                                         void *context);
887  *
888  * DESCRIPTION
889  *
890  *    Gets client entries by the list of client ID's `client_id_list'. This
891  *    always resolves those client ID's it does not know yet from the server
892  *    so this function might take a while. The `client_id_list' is a list
893  *    of ID Payloads added one after other.  JOIN command reply and USERS
894  *    command reply for example returns this sort of list. The `completion'
895  *    will be called after the entries are available. 
896  *
897  ***/
898 void silc_client_get_clients_by_list(SilcClient client,
899                                      SilcClientConnection conn,
900                                      uint32 list_count,
901                                      SilcBuffer client_id_list,
902                                      SilcGetClientCallback completion,
903                                      void *context);
904
905 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
906  *
907  * SYNOPSIS
908  *
909  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
910  *                                                 SilcClientConnection conn,
911  *                                                 SilcClientID *client_id);
912  *
913  * DESCRIPTION
914  *
915  *    Find entry for client by the client's ID. Returns the entry or NULL
916  *    if the entry was not found. 
917  *
918  ***/
919 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
920                                              SilcClientConnection conn,
921                                              SilcClientID *client_id);
922
923 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
924  *
925  * SYNOPSIS
926  *
927  *    void 
928  *    silc_client_get_client_by_id_resolve(SilcClient client,
929  *                                         SilcClientConnection conn,
930  *                                         SilcClientID *client_id,
931  *                                         SilcGetClientCallback completion,
932  *                                         void *context);
933  *
934  * DESCRIPTION
935  *
936  *    Same as silc_client_get_client_by_id but will always resolve the
937  *    information from the server. Use this only if you know that you
938  *    do not have the entry and the only thing you know about the client
939  *    is its ID. 
940  *
941  ***/
942 void silc_client_get_client_by_id_resolve(SilcClient client,
943                                           SilcClientConnection conn,
944                                           SilcClientID *client_id,
945                                           SilcGetClientCallback completion,
946                                           void *context);
947
948 /****f* silcclient/SilcClientAPI/silc_client_del_client
949  *
950  * SYNOPSIS
951  *
952  *    bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
953  *                                SilcClientEntry client_entry)
954  *
955  * DESCRIPTION
956  *
957  *    Removes client from local cache by the client entry indicated by
958  *    the `client_entry'.  Returns TRUE if the deletion were successful.
959  *
960  ***/
961 bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
962                             SilcClientEntry client_entry);
963
964 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
965  *
966  * SYNOPSIS
967  *
968  *    typedef void (*SilcGetChannelCallback)(SilcClient client,
969  *                                           SilcClientConnection conn,
970  *                                           SilcChannelEntry *channels,
971  *                                           uint32 channels_count,
972  *                                           void *context);
973  *
974  * DESCRIPTION
975  *
976  *    Callback function given to the silc_client_get_channel_* functions.
977  *    The found entries are allocated into the `channels' array. The array
978  *    must not be freed by the receiver, the library will free it later.
979  *    If the `channel' is NULL, no such channel exist in the SILC Network.
980  *
981  ***/
982 typedef void (*SilcGetChannelCallback)(SilcClient client,
983                                        SilcClientConnection conn,
984                                        SilcChannelEntry *channels,
985                                        uint32 channels_count,
986                                        void *context);
987
988 /****f* silcclient/SilcClientAPI/silc_client_get_channel
989  *
990  * SYNOPSIS
991  *
992  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
993  *                                             SilcClientConnection conn,
994  *                                             char *channel);
995  *
996  * DESCRIPTION
997  *
998  *    Finds entry for channel by the channel name. Returns the entry or NULL
999  *    if the entry was not found. It is found only if the client is joined
1000  *    to the channel. 
1001  *
1002  ***/
1003 SilcChannelEntry silc_client_get_channel(SilcClient client,
1004                                          SilcClientConnection conn,
1005                                          char *channel);
1006
1007 /****f* silcclient/SilcClientAPI/silc_client_get_channel_id_resolve
1008  *
1009  * SYNOPSIS
1010  *
1011  *    void 
1012  *    silc_client_get_channel_by_id_resolve(SilcClient client,
1013  *                                          SilcClientConnection conn,
1014  *                                          SilcChannelID *channel_id,
1015  *                                          SilcGetClientCallback completion,
1016  *                                          void *context);
1017  *
1018  * DESCRIPTION
1019  *
1020  *    Finds channel entry by the channel name. Returns the entry or NULL
1021  *    if it was not found.
1022  *
1023  ***/
1024 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
1025                                                SilcClientConnection conn,
1026                                                SilcChannelID *channel_id);
1027
1028 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
1029  *
1030  * SYNOPSIS
1031  *
1032  *    void 
1033  *    silc_client_get_channel_by_id_resolve(SilcClient client,
1034  *                                          SilcClientConnection conn,
1035  *                                          SilcChannelID *channel_id,
1036  *                                          SilcGetClientCallback completion,
1037  *                                          void *context);
1038  *
1039  * DESCRIPTION
1040  *
1041  *    Resolves the channel information (its name mainly) from the server
1042  *    by the `channel_id'. Use this only if you know that you do not have
1043  *    the entry cached locally.
1044  *
1045  ***/
1046 void silc_client_get_channel_by_id_resolve(SilcClient client,
1047                                            SilcClientConnection conn,
1048                                            SilcChannelID *channel_id,
1049                                            SilcGetChannelCallback completion,
1050                                            void *context);
1051
1052 /****f* silcclient/SilcClientAPI/silc_client_del_channel
1053  *
1054  * SYNOPSIS
1055  *
1056  *    bool silc_client_del_channel(SilcClient client, 
1057  *                                 SilcClientConnection conn,
1058  *                                 SilcChannelEntry channel)
1059  *
1060  * DESCRIPTION
1061  *
1062  *    Removes channel from local cache by the channel entry indicated by
1063  *    the `channel'.  Returns TRUE if the deletion were successful.
1064  *
1065  ***/
1066 bool silc_client_del_channel(SilcClient client, SilcClientConnection conn,
1067                              SilcChannelEntry channel);
1068
1069 /****f* silcclient/SilcClientAPI/silc_client_get_server
1070  *
1071  * SYNOPSIS
1072  *
1073  *    SilcServerEntry silc_client_get_server(SilcClient client,
1074  *                                           SilcClientConnection conn,
1075  *                                           char *server_name)
1076  *
1077  * DESCRIPTION
1078  *
1079  *    Finds entry for server by the server name. Returns the entry or NULL
1080  *    if the entry was not found.
1081  *
1082  ***/
1083 SilcServerEntry silc_client_get_server(SilcClient client,
1084                                        SilcClientConnection conn,
1085                                        char *server_name);
1086
1087 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
1088  *
1089  * SYNOPSIS
1090  *
1091  *    SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1092  *                                                 SilcClientConnection conn,
1093  *                                                 SilcServerID *server_id);
1094  *
1095  * DESCRIPTION
1096  *
1097  *    Finds entry for server by the server ID. Returns the entry or NULL
1098  *    if the entry was not found.
1099  *
1100  ***/
1101 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1102                                              SilcClientConnection conn,
1103                                              SilcServerID *server_id);
1104
1105 /****f* silcclient/SilcClientAPI/silc_client_del_server
1106  *
1107  * SYNOPSIS
1108  *
1109  *    bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1110  *                                SilcServerEntry server);
1111  *
1112  * DESCRIPTION
1113  *
1114  *    Removes server from local cache by the server entry indicated by
1115  *    the `server'.  Returns TRUE if the deletion were successful.
1116  *
1117  ***/
1118 bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1119                             SilcServerEntry server);
1120
1121 /****f* silcclient/SilcClientAPI/silc_client_on_channel
1122  *
1123  * SYNOPSIS
1124  *
1125  *    SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1126  *                                           SilcClientEntry client_entry);
1127  *
1128  * DESCRIPTION
1129  *
1130  *    Returns the ChannelUser entry if the `client_entry' is joined on the 
1131  *    channel indicated by the `channel'. NULL if client is not joined on
1132  *    the channel. 
1133  *
1134  ***/
1135 SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1136                                        SilcClientEntry client_entry);
1137
1138 /* Command management (command.c) */
1139
1140 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
1141  *
1142  * SYNOPSIS
1143  *
1144  *    SilcClientCommandContext silc_client_command_alloc(void);
1145  *
1146  * DESCRIPTION
1147  *
1148  *    Allocate Command Context. The context is defined in `command.h' file.
1149  *    The context is used by the library commands and applications should use
1150  *    it as well. However, application may choose to use some own context
1151  *    for its local commands. All library commands, however, must use this
1152  *    context. 
1153  *
1154  ***/
1155 SilcClientCommandContext silc_client_command_alloc(void);
1156
1157 /****f* silcclient/SilcClientAPI/silc_client_command_free
1158  *
1159  * SYNOPSIS
1160  *
1161  *    void silc_client_command_free(SilcClientCommandContext ctx);
1162  *
1163  * DESCRIPTION
1164  *
1165  *    Free command context and its internals.  If the contex was duplicated
1166  *    with silc_client_command_dup this may not actually free the data, 
1167  *    instead it will decrease the reference counter of the context.  The
1168  *    context will be freed when the reference counter hits zero.
1169  *
1170  ***/
1171 void silc_client_command_free(SilcClientCommandContext ctx);
1172
1173 /****f* silcclient/SilcClientAPI/silc_client_command_dup
1174  *
1175  * SYNOPSIS
1176  *
1177  *    SilcClientCommandContext 
1178  *    silc_client_command_dup(SilcClientCommandContext ctx);
1179  *
1180  * DESCRIPTION
1181  *
1182  *    Duplicate Command Context by adding reference counter. The context won't
1183  *    be free'd untill it hits zero. 
1184  *
1185  ***/
1186 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
1187
1188 /****f* silcclient/SilcClientAPI/silc_client_command_find
1189  *
1190  * SYNOPSIS
1191  *
1192  *    SilcClientCommand silc_client_command_find(SilcClient client,
1193  *                                               const char *name);
1194  *
1195  * DESCRIPTION
1196  *
1197  *    Finds and returns a pointer to the command list. Return NULL if the
1198  *    command is not found. See the `command.[ch]' for the command list. 
1199  *    Command names are not case-sensitive.
1200  *
1201  ***/
1202 SilcClientCommand silc_client_command_find(SilcClient client,
1203                                            const char *name);
1204
1205 /****f* silcclient/SilcClientAPI/silc_client_command_call
1206  *
1207  * SYNOPSIS
1208  *
1209  *    void silc_client_command_call(SilcClientCommand command);
1210  *
1211  * DESCRIPTION
1212  *
1213  *    Calls the command (executes it).  Application can call this after
1214  *    it has allocated the SilcClientCommandContext with the function
1215  *    silc_client_command_alloc and found the command from the client
1216  *    library by calling silc_client_command_find.  This will execute
1217  *    the command.
1218  *
1219  *    Application can call the command function directly too if it
1220  *    wishes to do so.  See the command.h for details of the
1221  *    SilcClientCommand structure.
1222  *
1223  ***/
1224 void silc_client_command_call(SilcClientCommand command,
1225                               SilcClientCommandContext cmd);
1226
1227 /****f* silcclient/SilcClientAPI/silc_client_command_send
1228  *
1229  * SYNOPSIS
1230  *
1231  *    void silc_client_command_send(SilcClient client, 
1232  *                                  SilcClientConnection conn,
1233  *                                  SilcCommand command, uint16 ident,
1234  *                                  uint32 argc, ...);
1235  *
1236  * DESCRIPTION
1237  *
1238  *    Generic function to send any command. The arguments must be sent already
1239  *    encoded into correct form and in correct order. If application wants
1240  *    to perform the commands by itself, it can do so and send the data
1241  *    directly to the server using this function.  If application is using
1242  *    the silc_client_command_call, this function is usually not used.
1243  *
1244  ***/
1245 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1246                               SilcCommand command, uint16 ident,
1247                               uint32 argc, ...);
1248
1249 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1250  *
1251  * SYNOPSIS
1252  *
1253  *    void silc_client_command_pending(SilcClientConnection conn,
1254  *                                     SilcCommand reply_cmd,
1255  *                                     uint16 ident,
1256  *                                     SilcCommandCb callback,
1257  *                                     void *context);
1258  *
1259  * DESCRIPTION
1260  *
1261  *    Add new pending command to be executed when reply to a command has been
1262  *    received.  The `reply_cmd' is the command that will call the `callback'
1263  *    with `context' when reply has been received.  If `ident' is non-zero
1264  *    the `callback' will be executed when received reply with command 
1265  *    identifier `ident'. 
1266  *
1267  *    Note that the application is notified about the received command
1268  *    reply through the `command_reply' client operation before calling
1269  *    the `callback` pending command callback.
1270  *
1271  ***/
1272 void silc_client_command_pending(SilcClientConnection conn,
1273                                  SilcCommand reply_cmd,
1274                                  uint16 ident,
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   SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED,
1868 } SilcClientFileError;
1869 /***/
1870
1871 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
1872  *
1873  * SYNOPSIS
1874  *
1875  *    typedef void (*SilcClientFileMonitor)(SilcClient client,
1876  *                                          SilcClientConnection conn,
1877  *                                          SilcClientMonitorStatus status,
1878  *                                          SilcClientFileError error,
1879  *                                          uint64 offset,
1880  *                                          uint64 filesize,
1881  *                                          SilcClientEntry client_entry,
1882  *                                          uint32 session_id,
1883  *                                          const char *filepath,
1884  *                                          void *context);
1885  *
1886  * DESCRIPTION
1887  *
1888  *    Monitor callback that is called during the file transmission to
1889  *    monitor the transmission process.  The `status' indicates the current
1890  *    monitoring process.  The `error' will indicate the error type
1891  *    if `status' is SILC_CLIENT_FILE_MONITOR_ERROR.  The `offset' is the
1892  *    currently transmitted amount of total `filesize'.  The `client_entry'
1893  *    indicates the remote client, and the transmission session ID is the 
1894  *    `session_id'.  The filename being transmitted is indicated by the 
1895  *    `filepath'.
1896  *
1897  ***/
1898 typedef void (*SilcClientFileMonitor)(SilcClient client,
1899                                       SilcClientConnection conn,
1900                                       SilcClientMonitorStatus status,
1901                                       SilcClientFileError error,
1902                                       uint64 offset,
1903                                       uint64 filesize,
1904                                       SilcClientEntry client_entry,
1905                                       uint32 session_id,
1906                                       const char *filepath,
1907                                       void *context);
1908
1909 /****f* silcclient/SilcClientAPI/silc_client_file_send
1910  *
1911  * SYNOPSIS
1912  *
1913  *    SilcClientFileError 
1914  *    silc_client_file_send(SilcClient client,
1915  *                          SilcClientConnection conn,
1916  *                          SilcClientFileMonitor monitor,
1917  *                          void *monitor_context,
1918  *                          const char *local_ip,
1919  *                          uint32 local_port,
1920  *                          SilcClientEntry client_entry,
1921  *                          const char *filepath);
1922  *                          uint32 *session_id);
1923  *
1924  * DESCRIPTION
1925  *
1926  *    Sends a file indicated by the `filepath' to the remote client 
1927  *    indicated by the `client_entry'.  This will negotiate a secret key
1928  *    with the remote client before actually starting the transmission of
1929  *    the file.  The `monitor' callback will be called to monitor the
1930  *    transmission of the file.
1931  *
1932  *    This returns a file session ID for the file transmission to the
1933  *    `session_id' pointer..  It can be used to close the session (and
1934  *    abort the file transmission) by calling the silc_client_file_close
1935  *    function.  The session ID is also returned in the `monitor' callback. 
1936  *
1937  *    If the `local_ip' is provided then this will try to bind the 
1938  *    listener for key exchange protocol to that IP.  If `local_port' is
1939  *    non-zero that port is used.  If `local_ip' is NULL then this will
1940  *    automatically attempt to bind it to local IP address of the machine.
1941  *    If that fails then this does not bind to any address and port, and
1942  *    assume that the remote client will provide the listener for the
1943  *    key exchange protocol.
1944  *
1945  *    If error will occur during the file transfer process the error
1946  *    status will be returned in the monitor callback.  In this case
1947  *    the application must call silc_client_file_close to close the
1948  *    session.
1949  *
1950  ***/
1951 SilcClientFileError 
1952 silc_client_file_send(SilcClient client,
1953                       SilcClientConnection conn,
1954                       SilcClientFileMonitor monitor,
1955                       void *monitor_context,
1956                       const char *local_ip,
1957                       uint32 local_port,
1958                       SilcClientEntry client_entry,
1959                       const char *filepath,
1960                       uint32 *session_id);
1961
1962 /****f* silcclient/SilcClientAPI/silc_client_file_receive
1963  *
1964  * SYNOPSIS
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  * DESCRIPTION
1974  *
1975  *    Receives a file from a client indicated by the `client_entry'.  The
1976  *    `session_id' indicates the file transmission session and it has been
1977  *    received in the `ftp' client operation function.  This will actually
1978  *    perform the key agreement protocol with the remote client before
1979  *    actually starting the file transmission.  The `monitor' callback
1980  *    will be called to monitor the transmission.
1981  *
1982  *    If error will occur during the file transfer process the error
1983  *    status will be returned in the monitor callback.  In this case
1984  *    the application must call silc_client_file_close to close the
1985  *    session.
1986  *
1987  ***/
1988 SilcClientFileError 
1989 silc_client_file_receive(SilcClient client,
1990                          SilcClientConnection conn,
1991                          SilcClientFileMonitor monitor,
1992                          void *monitor_context,
1993                          uint32 session_id);
1994
1995 /****f* silcclient/SilcClientAPI/silc_client_file_close
1996  *
1997  * SYNOPSIS
1998  *
1999  *    SilcClientFileError silc_client_file_close(SilcClient client,
2000  *                                               SilcClientConnection conn,
2001  *                                               uint32 session_id);
2002  *
2003  * DESCRIPTION
2004  *
2005  *    Closes file transmission session indicated by the `session_id'.
2006  *    If file transmission is being conducted it will be aborted
2007  *    automatically. This function is also used to close the session
2008  *    after successful file transmission. This function can be used
2009  *    also to reject incoming file transmission request.
2010  *
2011  ***/
2012 SilcClientFileError silc_client_file_close(SilcClient client,
2013                                            SilcClientConnection conn,
2014                                            uint32 session_id);
2015
2016 #endif