5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2000 - 2001 Pekka Riikonen
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.
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.
21 /****h* silcclient/SilcClientAPI
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.
32 * o SILC Client Operations
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.
37 * To use this structure: define a static SilcClientOperations variable,
38 * fill it and pass its pointer to silc_client_alloc function.
40 * o SILC Client Library API
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.
46 * Please, refer to the README file in this directory for the directions
47 * of how to use the SILC Client Library.
54 #include "clientlibincludes.h"
56 /* General definitions */
58 /****d* silcclient/SilcClientAPI/SilcKeyAgreementStatus
62 * typedef enum { ... } SilcKeyAgreementStatus;
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.
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;
81 /****f* silcclient/SilcClientAPI/SilcKeyAgreementCallback
85 * typedef void (*SilcKeyAgreementCallback)(SilcClient client,
86 * SilcClientConnection conn,
87 * SilcClientEntry client_entry,
88 * SilcKeyAgreementStatus status,
89 * SilcSKEKeyMaterial *key,
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.
103 typedef void (*SilcKeyAgreementCallback)(SilcClient client,
104 SilcClientConnection conn,
105 SilcClientEntry client_entry,
106 SilcKeyAgreementStatus status,
107 SilcSKEKeyMaterial *key,
110 /****s* silcclient/SilcClientAPI/SilcPrivateMessageKeys
114 * typedef struct { ... } SilcPrivateMessageKeys;
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
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;
136 /****f* silcclient/SilcClientAPI/SilcAskPassphrase
140 * typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
141 * uint32 passphrase_len,
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.
151 typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
152 uint32 passphrase_len,
155 /****f* silcclient/SilcClientAPI/SilcVerifyPublicKey
159 * typedef void (*SilcVerifyPublicKey)(bool success, void *context);
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.
168 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
170 /****f* silcclient/SilcClientAPI/SilcGetAuthMeth
174 * typedef void (*SilcGetAuthMeth)(bool success,
175 * SilcProtocolAuthMeth auth_meth,
176 * const unsigned char *auth_data,
177 * uint32 auth_data_len, void *context);
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.
191 typedef void (*SilcGetAuthMeth)(bool success,
192 SilcProtocolAuthMeth auth_meth,
193 const unsigned char *auth_data,
194 uint32 auth_data_len, void *context);
196 /****d* silcclient/SilcClientAPI/SilcClientMessageType
200 * typedef enum { ... } SilcClientMessageType;
204 * Different message types for `say' client operation. The application
205 * may filter the message sent by the library according this type.
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;
217 /****s* silcclient/SilcClientAPI/SilcClientOperations
221 * typedef struct { ... } SilcClientOperations;
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.
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
238 void (*say)(SilcClient client, SilcClientConnection conn,
239 SilcClientMessageType type, char *msg, ...);
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
244 void (*channel_message)(SilcClient client, SilcClientConnection conn,
245 SilcClientEntry sender, SilcChannelEntry channel,
246 SilcMessageFlags flags, char *msg);
248 /* Private message to the client. The `sender' is the sender of the
250 void (*private_message)(SilcClient client, SilcClientConnection conn,
251 SilcClientEntry sender, SilcMessageFlags flags,
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, ...);
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);
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
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, ...);
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);
304 /* Called to indicate that connection was disconnected to the server. */
305 void (*disconnect)(SilcClient client, SilcClientConnection conn);
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'
312 void (*get_auth_method)(SilcClient client, SilcClientConnection conn,
313 char *hostname, uint16 port,
314 SilcGetAuthMeth completion, void *context);
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);
325 /* Ask (interact, that is) a passphrase from user. The passphrase is
326 returned to the library by calling the `completion' callback with
328 void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
329 SilcAskPassphrase completion, void *context);
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
338 void (*failure)(SilcClient client, SilcClientConnection conn,
339 SilcProtocol protocol, void *failure);
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,
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;
365 /****f* silcclient/SilcClientAPI/SilcNicknameFormatParse
369 * typedef void (*SilcNicknameFormatParse)(const char *nickname,
370 * char **ret_nickname);
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
381 typedef void (*SilcNicknameFormatParse)(const char *nickname,
382 char **ret_nickname);
384 /****s* silcclient/SilcClientAPI/SilcClientParams
388 * typedef struct { ... } SilcClientParams;
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.
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
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;
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;
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
425 Following format types are available:
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)
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)
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.
445 char nickname_format[32];
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
453 bool nickname_force_format;
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;
468 /* Initialization functions (client.c) */
470 /****f* silcclient/SilcClientAPI/silc_client_alloc
474 * SilcClient silc_client_alloc(SilcClientOperations *ops,
475 * SilcClientParams *params,
477 * const char *silc_version);
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)
489 SilcClient silc_client_alloc(SilcClientOperations *ops,
490 SilcClientParams *params,
492 const char *silc_version);
494 /****f* silcclient/SilcClientAPI/silc_client_free
498 * void silc_client_free(SilcClient client);
502 * Frees client object and its internals. The execution of the client
503 * should be stopped with silc_client_stop function before calling
507 void silc_client_free(SilcClient client);
509 /****f* silcclient/SilcClientAPI/silc_client_init
513 * int silc_client_init(SilcClient client);
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.
522 int silc_client_init(SilcClient client);
524 /****f* silcclient/SilcClientAPI/silc_client_run
528 * void silc_client_run(SilcClient client);
532 * Runs the client. This starts the scheduler from the utility library.
533 * When this functions returns the execution of the appliation is over.
536 void silc_client_run(SilcClient client);
538 /****f* silcclient/SilcClientAPI/silc_client_run_one
542 * void silc_client_run_one(SilcClient client);
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.
555 void silc_client_run_one(SilcClient client);
557 /****f* silcclient/SilcClientAPI/silc_client_stop
561 * void silc_client_stop(SilcClient client);
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
570 void silc_client_stop(SilcClient client);
573 /* Connecting functions (client.c) */
575 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
579 * int silc_client_connect_to_server(SilcClient client, int port,
580 * char *host, void *context);
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.
593 int silc_client_connect_to_server(SilcClient client, int port,
594 char *host, void *context);
596 /****f* silcclient/SilcClientAPI/silc_client_add_connection
600 * SilcClientConnection silc_client_add_connection(SilcClient client,
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.
616 SilcClientConnection silc_client_add_connection(SilcClient client,
621 /****f* silcclient/SilcClientAPI/silc_client_del_connection
625 * void silc_client_del_connection(SilcClient client,
626 * SilcClientConnection conn);
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
636 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
638 /****f* silcclient/SilcClientAPI/silc_client_add_socket
642 * void silc_client_add_socket(SilcClient client,
643 * SilcSocketConnection sock);
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.
652 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
654 /****f* silcclient/SilcClientAPI/silc_client_del_socket
658 * void silc_client_del_socket(SilcClient client,
659 * SilcSocketConnection sock);
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.
668 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
670 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
674 * void silc_client_start_key_exchange(SilcClient client,
675 * SilcClientConnection conn,
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.
689 void silc_client_start_key_exchange(SilcClient client,
690 SilcClientConnection conn,
693 /****f* silcclient/SilcClientAPI/silc_client_close_connection
697 * void silc_client_close_connection(SilcClient client,
698 * SilcSocketConnection sock,
699 * SilcClientConnection conn);
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
712 void silc_client_close_connection(SilcClient client,
713 SilcSocketConnection sock,
714 SilcClientConnection conn);
717 /* Message sending functions (client_channel.c and client_prvmsg.c) */
719 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
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,
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.
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.
748 void silc_client_send_channel_message(SilcClient client,
749 SilcClientConnection conn,
750 SilcChannelEntry channel,
751 SilcChannelPrivateKey key,
752 SilcMessageFlags flags,
757 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
761 * void silc_client_send_private_message(SilcClient client,
762 * SilcClientConnection conn,
763 * SilcClientEntry client_entry,
764 * SilcMessageFlags flags,
765 * unsigned char *data,
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.
780 void silc_client_send_private_message(SilcClient client,
781 SilcClientConnection conn,
782 SilcClientEntry client_entry,
783 SilcMessageFlags flags,
789 /* Client and Channel entry retrieval (idlist.c) */
791 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
795 * typedef void (*SilcGetClientCallback)(SilcClient client,
796 * SilcClientConnection conn,
797 * SilcClientEntry *clients,
798 * uint32 clients_count,
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.
809 typedef void (*SilcGetClientCallback)(SilcClient client,
810 SilcClientConnection conn,
811 SilcClientEntry *clients,
812 uint32 clients_count,
815 /****f* silcclient/SilcClientAPI/silc_client_get_clients
819 * void silc_client_get_clients(SilcClient client,
820 * SilcClientConnection conn,
821 * const char *nickname,
822 * const char *server,
823 * SilcGetClientCallback completion,
828 * Finds client entry or entries by the `nickname' and `server'. The
829 * completion callback will be called when the client entries has been
830 * found. After the server returns the client information it is cached
831 * and can be accesses locally at a later time.
835 * NOTE: This function is always asynchronous and resolves the client
836 * information from the server. Thus, if you already know the client
837 * information then use the silc_client_get_client_by_id function to
838 * get the client entry since this function may be very slow and should
839 * be used only to initially get the client entries.
842 void silc_client_get_clients(SilcClient client,
843 SilcClientConnection conn,
844 const char *nickname,
846 SilcGetClientCallback completion,
849 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
853 * SilcClientEntry *silc_client_get_clients_local(SilcClient client,
854 * SilcClientConnection conn,
855 * const char *nickname,
856 * const char *format,
857 * uint32 *clients_count);
861 * Same as silc_client_get_clients function but does not resolve anything
862 * from the server. This checks local cache and returns all matching
863 * clients from the local cache. If none was found this returns NULL.
864 * The `nickname' is the real nickname of the client, and the `format'
865 * is the formatted nickname to find exact match from multiple found
866 * entries. The format must be same as given in the SilcClientParams
867 * structure to the client library. If the `format' is NULL all found
868 * clients by `nickname' are returned. The caller must return the
872 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
873 SilcClientConnection conn,
874 const char *nickname,
876 uint32 *clients_count);
878 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
882 * void silc_client_get_clients_by_list(SilcClient client,
883 * SilcClientConnection conn,
885 * SilcBuffer client_id_list,
886 * SilcGetClientCallback completion,
891 * Gets client entries by the list of client ID's `client_id_list'. This
892 * always resolves those client ID's it does not know yet from the server
893 * so this function might take a while. The `client_id_list' is a list
894 * of ID Payloads added one after other. JOIN command reply and USERS
895 * command reply for example returns this sort of list. The `completion'
896 * will be called after the entries are available. When server returns
897 * the client information it will be cached and can be accessed locally
901 void silc_client_get_clients_by_list(SilcClient client,
902 SilcClientConnection conn,
904 SilcBuffer client_id_list,
905 SilcGetClientCallback completion,
908 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
912 * SilcClientEntry silc_client_get_client_by_id(SilcClient client,
913 * SilcClientConnection conn,
914 * SilcClientID *client_id);
918 * Find entry for client by the client's ID. Returns the entry or NULL
919 * if the entry was not found. This checks the local cache and does
920 * not resolve anything from server.
923 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
924 SilcClientConnection conn,
925 SilcClientID *client_id);
927 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
932 * silc_client_get_client_by_id_resolve(SilcClient client,
933 * SilcClientConnection conn,
934 * SilcClientID *client_id,
935 * SilcGetClientCallback completion,
940 * Same as silc_client_get_client_by_id but will always resolve the
941 * information from the server. Use this only if you know that you
942 * do not have the entry and the only thing you know about the client
943 * is its ID. When server returns the client information it will be
944 * cache and can be accessed locally at a later time.
947 void silc_client_get_client_by_id_resolve(SilcClient client,
948 SilcClientConnection conn,
949 SilcClientID *client_id,
950 SilcGetClientCallback completion,
953 /****f* silcclient/SilcClientAPI/silc_client_del_client
957 * bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
958 * SilcClientEntry client_entry)
962 * Removes client from local cache by the client entry indicated by
963 * the `client_entry'. Returns TRUE if the deletion were successful.
966 bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
967 SilcClientEntry client_entry);
969 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
973 * typedef void (*SilcGetChannelCallback)(SilcClient client,
974 * SilcClientConnection conn,
975 * SilcChannelEntry *channels,
976 * uint32 channels_count,
981 * Callback function given to the silc_client_get_channel_* functions.
982 * The found entries are allocated into the `channels' array. The array
983 * must not be freed by the receiver, the library will free it later.
984 * If the `channel' is NULL, no such channel exist in the SILC Network.
987 typedef void (*SilcGetChannelCallback)(SilcClient client,
988 SilcClientConnection conn,
989 SilcChannelEntry *channels,
990 uint32 channels_count,
993 /****f* silcclient/SilcClientAPI/silc_client_get_channel
997 * SilcChannelEntry silc_client_get_channel(SilcClient client,
998 * SilcClientConnection conn,
1003 * Finds entry for channel by the channel name. Returns the entry or NULL
1004 * if the entry was not found. It is found only if the client is joined
1008 SilcChannelEntry silc_client_get_channel(SilcClient client,
1009 SilcClientConnection conn,
1012 /****f* silcclient/SilcClientAPI/silc_client_get_channel_id_resolve
1017 * silc_client_get_channel_by_id_resolve(SilcClient client,
1018 * SilcClientConnection conn,
1019 * SilcChannelID *channel_id,
1020 * SilcGetClientCallback completion,
1025 * Finds channel entry by the channel name. Returns the entry or NULL
1026 * if it was not found.
1029 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
1030 SilcClientConnection conn,
1031 SilcChannelID *channel_id);
1033 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
1038 * silc_client_get_channel_by_id_resolve(SilcClient client,
1039 * SilcClientConnection conn,
1040 * SilcChannelID *channel_id,
1041 * SilcGetClientCallback completion,
1046 * Resolves the channel information (its name mainly) from the server
1047 * by the `channel_id'. Use this only if you know that you do not have
1048 * the entry cached locally.
1051 void silc_client_get_channel_by_id_resolve(SilcClient client,
1052 SilcClientConnection conn,
1053 SilcChannelID *channel_id,
1054 SilcGetChannelCallback completion,
1057 /****f* silcclient/SilcClientAPI/silc_client_del_channel
1061 * bool silc_client_del_channel(SilcClient client,
1062 * SilcClientConnection conn,
1063 * SilcChannelEntry channel)
1067 * Removes channel from local cache by the channel entry indicated by
1068 * the `channel'. Returns TRUE if the deletion were successful.
1071 bool silc_client_del_channel(SilcClient client, SilcClientConnection conn,
1072 SilcChannelEntry channel);
1074 /****f* silcclient/SilcClientAPI/silc_client_get_server
1078 * SilcServerEntry silc_client_get_server(SilcClient client,
1079 * SilcClientConnection conn,
1080 * char *server_name)
1084 * Finds entry for server by the server name. Returns the entry or NULL
1085 * if the entry was not found.
1088 SilcServerEntry silc_client_get_server(SilcClient client,
1089 SilcClientConnection conn,
1092 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
1096 * SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1097 * SilcClientConnection conn,
1098 * SilcServerID *server_id);
1102 * Finds entry for server by the server ID. Returns the entry or NULL
1103 * if the entry was not found.
1106 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1107 SilcClientConnection conn,
1108 SilcServerID *server_id);
1110 /****f* silcclient/SilcClientAPI/silc_client_del_server
1114 * bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1115 * SilcServerEntry server);
1119 * Removes server from local cache by the server entry indicated by
1120 * the `server'. Returns TRUE if the deletion were successful.
1123 bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1124 SilcServerEntry server);
1126 /****f* silcclient/SilcClientAPI/silc_client_on_channel
1130 * SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1131 * SilcClientEntry client_entry);
1135 * Returns the ChannelUser entry if the `client_entry' is joined on the
1136 * channel indicated by the `channel'. NULL if client is not joined on
1140 SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1141 SilcClientEntry client_entry);
1143 /* Command management (command.c) */
1145 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
1149 * SilcClientCommandContext silc_client_command_alloc(void);
1153 * Allocate Command Context. The context is defined in `command.h' file.
1154 * The context is used by the library commands and applications should use
1155 * it as well. However, application may choose to use some own context
1156 * for its local commands. All library commands, however, must use this
1160 SilcClientCommandContext silc_client_command_alloc(void);
1162 /****f* silcclient/SilcClientAPI/silc_client_command_free
1166 * void silc_client_command_free(SilcClientCommandContext ctx);
1170 * Free command context and its internals. If the contex was duplicated
1171 * with silc_client_command_dup this may not actually free the data,
1172 * instead it will decrease the reference counter of the context. The
1173 * context will be freed when the reference counter hits zero.
1176 void silc_client_command_free(SilcClientCommandContext ctx);
1178 /****f* silcclient/SilcClientAPI/silc_client_command_dup
1182 * SilcClientCommandContext
1183 * silc_client_command_dup(SilcClientCommandContext ctx);
1187 * Duplicate Command Context by adding reference counter. The context won't
1188 * be free'd untill it hits zero.
1191 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
1193 /****f* silcclient/SilcClientAPI/silc_client_command_find
1197 * SilcClientCommand silc_client_command_find(SilcClient client,
1198 * const char *name);
1202 * Finds and returns a pointer to the command list. Return NULL if the
1203 * command is not found. See the `command.[ch]' for the command list.
1204 * Command names are not case-sensitive.
1207 SilcClientCommand silc_client_command_find(SilcClient client,
1210 /****f* silcclient/SilcClientAPI/silc_client_command_call
1214 * void silc_client_command_call(SilcClientCommand command);
1218 * Calls the command (executes it). Application can call this after
1219 * it has allocated the SilcClientCommandContext with the function
1220 * silc_client_command_alloc and found the command from the client
1221 * library by calling silc_client_command_find. This will execute
1224 * Application can call the command function directly too if it
1225 * wishes to do so. See the command.h for details of the
1226 * SilcClientCommand structure.
1229 void silc_client_command_call(SilcClientCommand command,
1230 SilcClientCommandContext cmd);
1232 /****f* silcclient/SilcClientAPI/silc_client_command_send
1236 * void silc_client_command_send(SilcClient client,
1237 * SilcClientConnection conn,
1238 * SilcCommand command, uint16 ident,
1239 * uint32 argc, ...);
1243 * Generic function to send any command. The arguments must be sent already
1244 * encoded into correct form and in correct order. If application wants
1245 * to perform the commands by itself, it can do so and send the data
1246 * directly to the server using this function. If application is using
1247 * the silc_client_command_call, this function is usually not used.
1250 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1251 SilcCommand command, uint16 ident,
1254 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1258 * void silc_client_command_pending(SilcClientConnection conn,
1259 * SilcCommand reply_cmd,
1261 * SilcCommandCb callback,
1266 * Add new pending command to be executed when reply to a command has been
1267 * received. The `reply_cmd' is the command that will call the `callback'
1268 * with `context' when reply has been received. If `ident' is non-zero
1269 * the `callback' will be executed when received reply with command
1270 * identifier `ident'.
1272 * Note that the application is notified about the received command
1273 * reply through the `command_reply' client operation before calling
1274 * the `callback` pending command callback.
1277 void silc_client_command_pending(SilcClientConnection conn,
1278 SilcCommand reply_cmd,
1280 SilcCommandCb callback,
1284 /* Private Message key management (client_prvmsg.c) */
1286 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1290 * int silc_client_add_private_message_key(SilcClient client,
1291 * SilcClientConnection conn,
1292 * SilcClientEntry client_entry,
1294 * unsigned char *key,
1296 * bool generate_key,
1301 * Adds private message key to the client library. The key will be used to
1302 * encrypt all private message between the client and the remote client
1303 * indicated by the `client_entry'. If the `key' is NULL and the boolean
1304 * value `generate_key' is TRUE the library will generate random key.
1305 * The `key' maybe for example pre-shared-key, passphrase or similar.
1306 * The `cipher' MAY be provided but SHOULD be NULL to assure that the
1307 * requirements of the SILC protocol are met. The API, however, allows
1308 * to allocate any cipher.
1310 * If `responder' is TRUE then the sending and receiving keys will be
1311 * set according the client being the receiver of the private key. If
1312 * FALSE the client is being the sender (or negotiator) of the private
1315 * It is not necessary to set key for normal private message usage. If the
1316 * key is not set then the private messages are encrypted using normal
1317 * session keys. Setting the private key, however, increases the security.
1319 * Returns FALSE if the key is already set for the `client_entry', TRUE
1323 int silc_client_add_private_message_key(SilcClient client,
1324 SilcClientConnection conn,
1325 SilcClientEntry client_entry,
1332 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1336 * int silc_client_add_private_message_key_ske(SilcClient client,
1337 * SilcClientConnection conn,
1338 * SilcClientEntry client_entry,
1340 * SilcSKEKeyMaterial *key);
1344 * Same as silc_client_add_private_message_key but takes the key material
1345 * from the SKE key material structure. This structure is received if
1346 * the application uses the silc_client_send_key_agreement to negotiate
1347 * the key material. The `cipher' SHOULD be provided as it is negotiated
1348 * also in the SKE protocol.
1351 int silc_client_add_private_message_key_ske(SilcClient client,
1352 SilcClientConnection conn,
1353 SilcClientEntry client_entry,
1355 SilcSKEKeyMaterial *key,
1358 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
1362 * int silc_client_send_private_message_key(SilcClient client,
1363 * SilcClientConnection conn,
1364 * SilcClientEntry client_entry,
1369 * Sends private message key payload to the remote client indicated by
1370 * the `client_entry'. If the `force_send' is TRUE the packet is sent
1371 * immediately. Returns FALSE if error occurs, TRUE otherwise. The
1372 * application should call this function after setting the key to the
1375 * Note that the key sent using this function is sent to the remote client
1376 * through the SILC network. The packet is protected using normal session
1380 int silc_client_send_private_message_key(SilcClient client,
1381 SilcClientConnection conn,
1382 SilcClientEntry client_entry,
1385 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1389 * int silc_client_del_private_message_key(SilcClient client,
1390 * SilcClientConnection conn,
1391 * SilcClientEntry client_entry);
1395 * Removes the private message from the library. The key won't be used
1396 * after this to protect the private messages with the remote `client_entry'
1397 * client. Returns FALSE on error, TRUE otherwise.
1400 int silc_client_del_private_message_key(SilcClient client,
1401 SilcClientConnection conn,
1402 SilcClientEntry client_entry);
1404 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1408 * SilcPrivateMessageKeys
1409 * silc_client_list_private_message_keys(SilcClient client,
1410 * SilcClientConnection conn,
1411 * uint32 *key_count);
1415 * Returns array of set private message keys associated to the connection
1416 * `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1417 * count to the `key_count' argument. The array must be freed by the caller
1418 * by calling the silc_client_free_private_message_keys function. Note:
1419 * the keys returned in the array is in raw format. It might not be desired
1420 * to show the keys as is. The application might choose not to show the keys
1421 * at all or to show the fingerprints of the keys.
1424 SilcPrivateMessageKeys
1425 silc_client_list_private_message_keys(SilcClient client,
1426 SilcClientConnection conn,
1429 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1433 * void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1434 * uint32 key_count);
1438 * Frees the SilcPrivateMessageKeys array returned by the function
1439 * silc_client_list_private_message_keys.
1442 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1446 /* Channel private key management (client_channel.c,
1447 SilcChannelPrivateKey is defined in idlist.h) */
1449 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1453 * int silc_client_add_channel_private_key(SilcClient client,
1454 * SilcClientConnection conn,
1455 * SilcChannelEntry channel,
1458 * unsigned char *key,
1463 * Adds private key for channel. This may be set only if the channel's mode
1464 * mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1465 * mode is not set. When channel has private key then the messages are
1466 * encrypted using that key. All clients on the channel must also know the
1467 * key in order to decrypt the messages. However, it is possible to have
1468 * several private keys per one channel. In this case only some of the
1469 * clients on the channel may know the one key and only some the other key.
1471 * The private key for channel is optional. If it is not set then the
1472 * channel messages are encrypted using the channel key generated by the
1473 * server. However, setting the private key (or keys) for the channel
1474 * significantly adds security. If more than one key is set the library
1475 * will automatically try all keys at the message decryption phase. Note:
1476 * setting many keys slows down the decryption phase as all keys has to
1477 * be tried in order to find the correct decryption key. However, setting
1478 * a few keys does not have big impact to the decryption performace.
1482 * NOTE: This is entirely local setting. The key set using this function
1483 * is not sent to the network at any phase.
1485 * NOTE: If the key material was originated by the SKE protocol (using
1486 * silc_client_send_key_agreement) then the `key' MUST be the
1487 * key->send_enc_key as this is dictated by the SILC protocol. However,
1488 * currently it is not expected that the SKE key material would be used
1489 * as channel private key. However, this API allows it.
1492 int silc_client_add_channel_private_key(SilcClient client,
1493 SilcClientConnection conn,
1494 SilcChannelEntry channel,
1500 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1504 * int silc_client_del_channel_private_keys(SilcClient client,
1505 * SilcClientConnection conn,
1506 * SilcChannelEntry channel);
1510 * Removes all private keys from the `channel'. The old channel key is used
1511 * after calling this to protect the channel messages. Returns FALSE on
1512 * on error, TRUE otherwise.
1515 int silc_client_del_channel_private_keys(SilcClient client,
1516 SilcClientConnection conn,
1517 SilcChannelEntry channel);
1519 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1523 * int silc_client_del_channel_private_key(SilcClient client,
1524 * SilcClientConnection conn,
1525 * SilcChannelEntry channel,
1526 * SilcChannelPrivateKey key);
1530 * Removes and frees private key `key' from the channel `channel'.
1531 * The `key' is retrieved by calling the function
1532 * silc_client_list_channel_private_keys. The key is not used after
1533 * this. If the key was last private key then the old channel key is
1534 * used hereafter to protect the channel messages. This returns FALSE
1535 * on error, TRUE otherwise.
1538 int silc_client_del_channel_private_key(SilcClient client,
1539 SilcClientConnection conn,
1540 SilcChannelEntry channel,
1541 SilcChannelPrivateKey key);
1543 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1547 * SilcChannelPrivateKey *
1548 * silc_client_list_channel_private_keys(SilcClient client,
1549 * SilcClientConnection conn,
1550 * SilcChannelEntry channel,
1551 * uint32 *key_count);
1555 * Returns array (pointers) of private keys associated to the `channel'.
1556 * The caller must free the array by calling the function
1557 * silc_client_free_channel_private_keys. The pointers in the array may be
1558 * used to delete the specific key by giving the pointer as argument to the
1559 * function silc_client_del_channel_private_key.
1562 SilcChannelPrivateKey *
1563 silc_client_list_channel_private_keys(SilcClient client,
1564 SilcClientConnection conn,
1565 SilcChannelEntry channel,
1568 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1572 * void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1573 * uint32 key_count);
1577 * Frees the SilcChannelPrivateKey array.
1580 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1584 /* Key Agreement routines (client_keyagr.c) */
1586 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1590 * void silc_client_send_key_agreement(SilcClient client,
1591 * SilcClientConnection conn,
1592 * SilcClientEntry client_entry,
1595 * uint32 timeout_secs,
1596 * SilcKeyAgreementCallback completion,
1601 * Sends key agreement request to the remote client indicated by the
1602 * `client_entry'. If the caller provides the `hostname' and the `port'
1603 * arguments then the library will bind the client to that hostname and
1604 * that port for the key agreement protocol. It also sends the `hostname'
1605 * and the `port' in the key agreement packet to the remote client. This
1606 * would indicate that the remote client may initiate the key agreement
1607 * protocol to the `hostname' on the `port'. If port is zero then the
1608 * bound port is undefined (the operating system defines it).
1610 * If the `hostname' and `port' is not provided then empty key agreement
1611 * packet is sent to the remote client. The remote client may reply with
1612 * the same packet including its hostname and port. If the library receives
1613 * the reply from the remote client the `key_agreement' client operation
1614 * callback will be called to verify whether the user wants to perform the
1615 * key agreement or not.
1619 * NOTE: If the application provided the `hostname' and the `port' and the
1620 * remote side initiates the key agreement protocol it is not verified
1621 * from the user anymore whether the protocol should be executed or not.
1622 * By setting the `hostname' and `port' the user gives permission to
1623 * perform the protocol (we are responder in this case).
1625 * NOTE: If the remote side decides not to initiate the key agreement
1626 * or decides not to reply with the key agreement packet then we cannot
1627 * perform the key agreement at all. If the key agreement protocol is
1628 * performed the `completion' callback with the `context' will be called.
1629 * If remote side decides to ignore the request the `completion' will be
1630 * called after the specified timeout, `timeout_secs'.
1632 * NOTE: If the `hostname' and the `port' was not provided the `completion'
1633 * will not be called at all since this does nothing more than sending
1634 * a packet to the remote host.
1636 * NOTE: There can be only one active key agreement for one client entry.
1637 * Before setting new one, the old one must be finished (it is finished
1638 * after calling the completion callback) or the function
1639 * silc_client_abort_key_agreement must be called.
1642 void silc_client_send_key_agreement(SilcClient client,
1643 SilcClientConnection conn,
1644 SilcClientEntry client_entry,
1645 const char *hostname,
1646 const char *bindhost,
1648 uint32 timeout_secs,
1649 SilcKeyAgreementCallback completion,
1652 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1657 * silc_client_perform_key_agreement(SilcClient client,
1658 * SilcClientConnection conn,
1659 * SilcClientEntry client_entry,
1662 * SilcKeyAgreementCallback completion,
1667 * Performs the actual key agreement protocol. Application may use this
1668 * to initiate the key agreement protocol. This can be called for example
1669 * after the application has received the `key_agreement' client operation,
1670 * and did not return TRUE from it.
1672 * The `hostname' is the remote hostname (or IP address) and the `port'
1673 * is the remote port. The `completion' callback with the `context' will
1674 * be called after the key agreement protocol.
1678 * NOTE: If the application returns TRUE in the `key_agreement' client
1679 * operation the library will automatically start the key agreement. In this
1680 * case the application must not call this function. However, application
1681 * may choose to just ignore the `key_agreement' client operation (and
1682 * merely just print information about it on the screen) and call this
1683 * function when the user whishes to do so (by, for example, giving some
1684 * specific command). Thus, the API provides both, automatic and manual
1685 * initiation of the key agreement. Calling this function is the manual
1686 * initiation and returning TRUE in the `key_agreement' client operation
1687 * is the automatic initiation.
1690 void silc_client_perform_key_agreement(SilcClient client,
1691 SilcClientConnection conn,
1692 SilcClientEntry client_entry,
1695 SilcKeyAgreementCallback completion,
1698 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1703 * silc_client_perform_key_agreement_fd(SilcClient client,
1704 * SilcClientConnection conn,
1705 * SilcClientEntry client_entry,
1708 * SilcKeyAgreementCallback completion,
1713 * Same as above but application has created already the connection to
1714 * the remote host. The `sock' is the socket to the remote connection.
1715 * Application can use this function if it does not want the client library
1716 * to create the connection.
1719 void silc_client_perform_key_agreement_fd(SilcClient client,
1720 SilcClientConnection conn,
1721 SilcClientEntry client_entry,
1724 SilcKeyAgreementCallback completion,
1727 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1731 * void silc_client_abort_key_agreement(SilcClient client,
1732 * SilcClientConnection conn,
1733 * SilcClientEntry client_entry);
1737 * This function can be called to unbind the hostname and the port for
1738 * the key agreement protocol. However, this function has effect only
1739 * before the key agreement protocol has been performed. After it has
1740 * been performed the library will automatically unbind the port. The
1741 * `client_entry' is the client to which we sent the key agreement
1742 * request. The key agreement completion callback will be called
1743 * with SILC_KEY_AGREEMENT_ABORTED status.
1746 void silc_client_abort_key_agreement(SilcClient client,
1747 SilcClientConnection conn,
1748 SilcClientEntry client_entry);
1751 /* Misc functions */
1753 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1757 * void silc_client_set_away_message(SilcClient client,
1758 * SilcClientConnection conn,
1763 * Sets away `message'. The away message may be set when the client's
1764 * mode is changed to SILC_UMODE_GONE and the client whishes to reply
1765 * to anyone who sends private message. The `message' will be sent
1766 * automatically back to the the client who send private message. If
1767 * away message is already set this replaces the old message with the
1768 * new one. If `message' is NULL the old away message is removed.
1769 * The sender may freely free the memory of the `message'.
1772 void silc_client_set_away_message(SilcClient client,
1773 SilcClientConnection conn,
1777 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
1781 * typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1782 * SilcClientConnection conn,
1783 * SilcAuthMethod auth_meth,
1788 * Connection authentication method request callback. This is called
1789 * by the client library after it has received the authentication method
1790 * that the application requested by calling the function
1791 * silc_client_request_authentication_method.
1794 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1795 SilcClientConnection conn,
1796 SilcAuthMethod auth_meth,
1799 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
1804 * silc_client_request_authentication_method(SilcClient client,
1805 * SilcClientConnection conn,
1806 * SilcConnectionAuthRequest
1812 * This function can be used to request the current authentication method
1813 * from the server. This may be called when connecting to the server
1814 * and the client library requests the authentication data from the
1815 * application. If the application does not know the current authentication
1816 * method it can request it from the server using this function.
1817 * The `callback' with `context' will be called after the server has
1818 * replied back with the current authentication method.
1822 silc_client_request_authentication_method(SilcClient client,
1823 SilcClientConnection conn,
1824 SilcConnectionAuthRequest callback,
1827 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
1831 * typedef enum { ... } SilcClientMonitorStatus;
1835 * File transmission session status types. These will indicate
1836 * the status of the file transmission session.
1841 SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT, /* In key agreemenet phase */
1842 SILC_CLIENT_FILE_MONITOR_SEND, /* Sending file */
1843 SILC_CLIENT_FILE_MONITOR_RECEIVE, /* Receiving file */
1844 SILC_CLIENT_FILE_MONITOR_GET,
1845 SILC_CLIENT_FILE_MONITOR_PUT,
1846 SILC_CLIENT_FILE_MONITOR_CLOSED, /* Session closed */
1847 SILC_CLIENT_FILE_MONITOR_ERROR, /* Error during session */
1848 } SilcClientMonitorStatus;
1851 /****d* silcclient/SilcClientAPI/SilcClientFileError
1855 * typedef enum { ... } SilcClientFileError;
1859 * File transmission error types. These types are returned by
1860 * some of the file transmission functions, and by the monitor
1861 * callback to indicate error.
1866 SILC_CLIENT_FILE_OK,
1867 SILC_CLIENT_FILE_ERROR,
1868 SILC_CLIENT_FILE_UNKNOWN_SESSION,
1869 SILC_CLIENT_FILE_ALREADY_STARTED,
1870 SILC_CLIENT_FILE_NO_SUCH_FILE,
1871 SILC_CLIENT_FILE_PERMISSION_DENIED,
1872 SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED,
1873 } SilcClientFileError;
1876 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
1880 * typedef void (*SilcClientFileMonitor)(SilcClient client,
1881 * SilcClientConnection conn,
1882 * SilcClientMonitorStatus status,
1883 * SilcClientFileError error,
1886 * SilcClientEntry client_entry,
1887 * uint32 session_id,
1888 * const char *filepath,
1893 * Monitor callback that is called during the file transmission to
1894 * monitor the transmission process. The `status' indicates the current
1895 * monitoring process. The `error' will indicate the error type
1896 * if `status' is SILC_CLIENT_FILE_MONITOR_ERROR. The `offset' is the
1897 * currently transmitted amount of total `filesize'. The `client_entry'
1898 * indicates the remote client, and the transmission session ID is the
1899 * `session_id'. The filename being transmitted is indicated by the
1903 typedef void (*SilcClientFileMonitor)(SilcClient client,
1904 SilcClientConnection conn,
1905 SilcClientMonitorStatus status,
1906 SilcClientFileError error,
1909 SilcClientEntry client_entry,
1911 const char *filepath,
1914 /****f* silcclient/SilcClientAPI/silc_client_file_send
1918 * SilcClientFileError
1919 * silc_client_file_send(SilcClient client,
1920 * SilcClientConnection conn,
1921 * SilcClientFileMonitor monitor,
1922 * void *monitor_context,
1923 * const char *local_ip,
1924 * uint32 local_port,
1925 * SilcClientEntry client_entry,
1926 * const char *filepath);
1927 * uint32 *session_id);
1931 * Sends a file indicated by the `filepath' to the remote client
1932 * indicated by the `client_entry'. This will negotiate a secret key
1933 * with the remote client before actually starting the transmission of
1934 * the file. The `monitor' callback will be called to monitor the
1935 * transmission of the file.
1937 * This returns a file session ID for the file transmission to the
1938 * `session_id' pointer.. It can be used to close the session (and
1939 * abort the file transmission) by calling the silc_client_file_close
1940 * function. The session ID is also returned in the `monitor' callback.
1942 * If the `local_ip' is provided then this will try to bind the
1943 * listener for key exchange protocol to that IP. If `local_port' is
1944 * non-zero that port is used. If `local_ip' is NULL then this will
1945 * automatically attempt to bind it to local IP address of the machine.
1946 * If that fails then this does not bind to any address and port, and
1947 * assume that the remote client will provide the listener for the
1948 * key exchange protocol.
1950 * If error will occur during the file transfer process the error
1951 * status will be returned in the monitor callback. In this case
1952 * the application must call silc_client_file_close to close the
1957 silc_client_file_send(SilcClient client,
1958 SilcClientConnection conn,
1959 SilcClientFileMonitor monitor,
1960 void *monitor_context,
1961 const char *local_ip,
1963 SilcClientEntry client_entry,
1964 const char *filepath,
1965 uint32 *session_id);
1967 /****f* silcclient/SilcClientAPI/silc_client_file_receive
1971 * SilcClientFileError
1972 * silc_client_file_receive(SilcClient client,
1973 * SilcClientConnection conn,
1974 * SilcClientFileMonitor monitor,
1975 * void *monitor_context,
1976 * uint32 session_id);
1980 * Receives a file from a client indicated by the `client_entry'. The
1981 * `session_id' indicates the file transmission session and it has been
1982 * received in the `ftp' client operation function. This will actually
1983 * perform the key agreement protocol with the remote client before
1984 * actually starting the file transmission. The `monitor' callback
1985 * will be called to monitor the transmission.
1987 * If error will occur during the file transfer process the error
1988 * status will be returned in the monitor callback. In this case
1989 * the application must call silc_client_file_close to close the
1994 silc_client_file_receive(SilcClient client,
1995 SilcClientConnection conn,
1996 SilcClientFileMonitor monitor,
1997 void *monitor_context,
2000 /****f* silcclient/SilcClientAPI/silc_client_file_close
2004 * SilcClientFileError silc_client_file_close(SilcClient client,
2005 * SilcClientConnection conn,
2006 * uint32 session_id);
2010 * Closes file transmission session indicated by the `session_id'.
2011 * If file transmission is being conducted it will be aborted
2012 * automatically. This function is also used to close the session
2013 * after successful file transmission. This function can be used
2014 * also to reject incoming file transmission request.
2017 SilcClientFileError silc_client_file_close(SilcClient client,
2018 SilcClientConnection conn,