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. */
243 void (*channel_message)(SilcClient client, SilcClientConnection conn,
244 SilcClientEntry sender, SilcChannelEntry channel,
245 SilcMessageFlags flags, char *msg);
247 /* Private message to the client. The `sender' is the sender of the
249 void (*private_message)(SilcClient client, SilcClientConnection conn,
250 SilcClientEntry sender, SilcMessageFlags flags,
253 /* Notify message to the client. The notify arguments are sent in the
254 same order as servers sends them. The arguments are same as received
255 from the server except for ID's. If ID is received application receives
256 the corresponding entry to the ID. For example, if Client ID is received
257 application receives SilcClientEntry. Also, if the notify type is
258 for channel the channel entry is sent to application (even if server
259 does not send it because client library gets the channel entry from
260 the Channel ID in the packet's header). */
261 void (*notify)(SilcClient client, SilcClientConnection conn,
262 SilcNotifyType type, ...);
264 /* Command handler. This function is called always in the command function.
265 If error occurs it will be called as well. `conn' is the associated
266 client connection. `cmd_context' is the command context that was
267 originally sent to the command. `success' is FALSE if error occurred
268 during command. `command' is the command being processed. It must be
269 noted that this is not reply from server. This is merely called just
270 after application has called the command. Just to tell application
271 that the command really was processed. */
272 void (*command)(SilcClient client, SilcClientConnection conn,
273 SilcClientCommandContext cmd_context, int success,
274 SilcCommand command);
276 /* Command reply handler. This function is called always in the command reply
277 function. If error occurs it will be called as well. Normal scenario
278 is that it will be called after the received command data has been parsed
279 and processed. The function is used to pass the received command data to
282 `conn' is the associated client connection. `cmd_payload' is the command
283 payload data received from server and it can be ignored. It is provided
284 if the application would like to re-parse the received command data,
285 however, it must be noted that the data is parsed already by the library
286 thus the payload can be ignored. `success' is FALSE if error occurred.
287 In this case arguments are not sent to the application. The `status' is
288 the command reply status server returned. The `command' is the command
289 reply being processed. The function has variable argument list and each
290 command defines the number and type of arguments it passes to the
291 application (on error they are not sent). */
292 void (*command_reply)(SilcClient client, SilcClientConnection conn,
293 SilcCommandPayload cmd_payload, int success,
294 SilcCommand command, SilcCommandStatus status, ...);
296 /* Called to indicate that connection was either successfully established
297 or connecting failed. This is also the first time application receives
298 the SilcClientConnection objecet which it should save somewhere.
299 If the `success' is FALSE the application must always call the function
300 silc_client_close_connection. */
301 void (*connect)(SilcClient client, SilcClientConnection conn, int success);
303 /* Called to indicate that connection was disconnected to the server. */
304 void (*disconnect)(SilcClient client, SilcClientConnection conn);
306 /* Find authentication method and authentication data by hostname and
307 port. The hostname may be IP address as well. When the authentication
308 method has been resolved the `completion' callback with the found
309 authentication method and authentication data is called. The `conn'
311 void (*get_auth_method)(SilcClient client, SilcClientConnection conn,
312 char *hostname, uint16 port,
313 SilcGetAuthMeth completion, void *context);
315 /* Verifies received public key. The `conn_type' indicates which entity
316 (server, client etc.) has sent the public key. If user decides to trust
317 the key may be saved as trusted public key for later use. The
318 `completion' must be called after the public key has been verified. */
319 void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
320 SilcSocketType conn_type, unsigned char *pk,
321 uint32 pk_len, SilcSKEPKType pk_type,
322 SilcVerifyPublicKey completion, void *context);
324 /* Ask (interact, that is) a passphrase from user. The passphrase is
325 returned to the library by calling the `completion' callback with
327 void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
328 SilcAskPassphrase completion, void *context);
330 /* Notifies application that failure packet was received. This is called
331 if there is some protocol active in the client. The `protocol' is the
332 protocol context. The `failure' is opaque pointer to the failure
333 indication. Note, that the `failure' is protocol dependant and
334 application must explicitly cast it to correct type. Usually `failure'
335 is 32 bit failure type (see protocol specs for all protocol failure
337 void (*failure)(SilcClient client, SilcClientConnection conn,
338 SilcProtocol protocol, void *failure);
340 /* Asks whether the user would like to perform the key agreement protocol.
341 This is called after we have received an key agreement packet or an
342 reply to our key agreement packet. This returns TRUE if the user wants
343 the library to perform the key agreement protocol and FALSE if it is not
344 desired (application may start it later by calling the function
345 silc_client_perform_key_agreement). If TRUE is returned also the
346 `completion' and `context' arguments must be set by the application. */
347 int (*key_agreement)(SilcClient client, SilcClientConnection conn,
348 SilcClientEntry client_entry, const char *hostname,
349 uint16 port, SilcKeyAgreementCallback *completion,
352 /* Notifies application that file transfer protocol session is being
353 requested by the remote client indicated by the `client_entry' from
354 the `hostname' and `port'. The `session_id' is the file transfer
355 session and it can be used to either accept or reject the file
356 transfer request, by calling the silc_client_file_receive or
357 silc_client_file_close, respectively. */
358 void (*ftp)(SilcClient client, SilcClientConnection conn,
359 SilcClientEntry client_entry, uint32 session_id,
360 const char *hostname, uint16 port);
361 } SilcClientOperations;
364 /****f* silcclient/SilcClientAPI/SilcNicknameFormatParse
368 * typedef void (*SilcNicknameFormatParse)(const char *nickname,
369 * char **ret_nickname);
373 * A callback function provided by the application for the library in
374 * SilcClientParams structure. This function parses the formatted
375 * nickname string `nickname' and returns the true nickname to the
376 * `ret_nickname' pointer. The library can call this function at
380 typedef void (*SilcNicknameFormatParse)(const char *nickname,
381 char **ret_nickname);
383 /****s* silcclient/SilcClientAPI/SilcClientParams
387 * typedef struct { ... } SilcClientParams;
391 * Client parameters. This can be filled with proper values and
392 * given as argument to the silc_client_alloc function. The structure
393 * hold various parameters which affects the function of the client.
398 /* Number of maximum tasks the client library's scheduler can handle.
399 If set to zero, the default value will be used (200). For WIN32
400 systems this should be set to 64 as it is the hard limit dictated
404 /* Rekey timeout in seconds. The client will perform rekey in this
405 time interval. If set to zero, the default value will be used. */
406 unsigned int rekey_secs;
408 /* Connection authentication method request timeout. If server does not
409 reply back the current authentication method when we've requested it
410 in this time interval we'll assume the reply will not come at all.
411 If set to zero, the default value (2 seconds) will be used. */
412 unsigned int connauth_request_secs;
414 /* Nickname format string. This can be used to order the client library
415 to save the nicknames in the library in a certain format. Since
416 nicknames are not unique in SILC it is possible to have multiple same
417 nicknames. Using this format string it is possible to order the library
418 to separate the multiple same nicknames from each other. The format
419 types are defined below and they can appear in any order in the format
420 string. If this is NULL then default format is used which is the
421 default nickname without anything else. The string MUST be NULL
424 Following format types are available:
426 %n nickname - the real nickname returned by the server (mandatory)
427 %h hostname - the stripped hostname of the client
428 %H full hostname - the full hostname of the client
429 %s server name - the server name the client is connected
430 %S full server - the full server name the client is connected
431 %a number - ascending number in case there are several
432 same nicknames (fe. nick@host and nick@host2)
434 Example format strings: "%n@%h%a" (fe. nick@host, nick@host2)
435 "%a!%n@%s" (fe. nick@server, 2!nick@server)
436 "%n@%H" (fe. nick@host.domain.com)
438 By default this format is employed to the nicknames by the libary
439 only when there appears multiple same nicknames. If the library has
440 only one nickname cached the nickname is saved as is and without the
441 defined format. If you want always to save the nickname in the defined
442 format set the boolean field `nickname_force_format' to value TRUE.
444 char nickname_format[32];
446 /* If this is set to TRUE then the `nickname_format' is employed to all
447 saved nicknames even if there are no multiple same nicknames in the
448 cache. By default this is FALSE, which means that the `nickname_format'
449 is employed only if the library will receive a nickname that is
450 already saved in the cache. It is recommended to leave this to FALSE
452 bool nickname_force_format;
454 /* A callback function provided by the application for the library to
455 parse the nickname from the formatted nickname string. Even though
456 the libary formats the nicknames the application knows generally the
457 format better so this function should be provided for the library
458 if the application sets the `nickname_format' field. The library
459 will call this to get the true nickname from the provided formatted
460 nickname string whenever it needs the true nickname. */
461 SilcNicknameFormatParse nickname_parse;
467 /* Initialization functions (client.c) */
469 /****f* silcclient/SilcClientAPI/silc_client_alloc
473 * SilcClient silc_client_alloc(SilcClientOperations *ops,
474 * SilcClientParams *params,
476 * const char *silc_version);
480 * Allocates new client object. This has to be done before client may
481 * work. After calling this one must call silc_client_init to initialize
482 * the client. The `application' is application specific user data pointer
483 * and caller must free it. The `silc_version' is the application version
484 * that will be used to compare against remote host's (usually a server)
488 SilcClient silc_client_alloc(SilcClientOperations *ops,
489 SilcClientParams *params,
491 const char *silc_version);
493 /****f* silcclient/SilcClientAPI/silc_client_free
497 * void silc_client_free(SilcClient client);
501 * Frees client object and its internals. The execution of the client
502 * should be stopped with silc_client_stop function before calling
506 void silc_client_free(SilcClient client);
508 /****f* silcclient/SilcClientAPI/silc_client_init
512 * int silc_client_init(SilcClient client);
516 * Initializes the client. This makes all the necessary steps to make
517 * the client ready to be run. One must call silc_client_run to run the
518 * client. Returns FALSE if error occurred, TRUE otherwise.
521 int silc_client_init(SilcClient client);
523 /****f* silcclient/SilcClientAPI/silc_client_run
527 * void silc_client_run(SilcClient client);
531 * Runs the client. This starts the scheduler from the utility library.
532 * When this functions returns the execution of the appliation is over.
535 void silc_client_run(SilcClient client);
537 /****f* silcclient/SilcClientAPI/silc_client_run_one
541 * void silc_client_run_one(SilcClient client);
545 * Runs the client and returns immeadiately. This function is used when
546 * the SILC Client object indicated by the `client' is run under some
547 * other scheduler, or event loop or main loop. On GUI applications,
548 * for example this may be desired to used to run the client under the
549 * GUI application's main loop. Typically the GUI application would
550 * register an idle task that calls this function multiple times in
551 * a second to quickly process the SILC specific data.
554 void silc_client_run_one(SilcClient client);
556 /****f* silcclient/SilcClientAPI/silc_client_stop
560 * void silc_client_stop(SilcClient client);
564 * Stops the client. This is called to stop the client and thus to stop
565 * the program. The client context must be freed with the silc_client_free
569 void silc_client_stop(SilcClient client);
572 /* Connecting functions (client.c) */
574 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
578 * int silc_client_connect_to_server(SilcClient client, int port,
579 * char *host, void *context);
583 * Connects to remote server. This is the main routine used to connect
584 * to SILC server. Returns -1 on error and the created socket otherwise.
585 * The `context' is user context that is saved into the SilcClientConnection
586 * that is created after the connection is created. Note that application
587 * may handle the connecting process outside the library. If this is the
588 * case then this function is not used at all. When the connecting is
589 * done the `connect' client operation is called.
592 int silc_client_connect_to_server(SilcClient client, int port,
593 char *host, void *context);
595 /****f* silcclient/SilcClientAPI/silc_client_add_connection
599 * SilcClientConnection silc_client_add_connection(SilcClient client,
606 * Allocates and adds new connection to the client. This adds the allocated
607 * connection to the connection table and returns a pointer to it. A client
608 * can have multiple connections to multiple servers. Every connection must
609 * be added to the client using this function. User data `context' may
610 * be sent as argument. This function is normally used only if the
611 * application performed the connecting outside the library. The library
612 * however may use this internally.
615 SilcClientConnection silc_client_add_connection(SilcClient client,
620 /****f* silcclient/SilcClientAPI/silc_client_del_connection
624 * void silc_client_del_connection(SilcClient client,
625 * SilcClientConnection conn);
629 * Removes connection from client. Frees all memory. The library
630 * call this function automatically for all connection contexts.
631 * The application however may free the connection contexts it has
635 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
637 /****f* silcclient/SilcClientAPI/silc_client_add_socket
641 * void silc_client_add_socket(SilcClient client,
642 * SilcSocketConnection sock);
646 * Adds listener socket to the listener sockets table. This function is
647 * used to add socket objects that are listeners to the client. This should
648 * not be used to add other connection objects.
651 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
653 /****f* silcclient/SilcClientAPI/silc_client_del_socket
657 * void silc_client_del_socket(SilcClient client,
658 * SilcSocketConnection sock);
662 * Deletes listener socket from the listener sockets table. If the
663 * application has added a socket with silc_client_add_socket it must
664 * also free it using this function.
667 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
669 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
673 * void silc_client_start_key_exchange(SilcClient client,
674 * SilcClientConnection conn,
679 * Start SILC Key Exchange (SKE) protocol to negotiate shared secret
680 * key material between client and server. This function can be called
681 * directly if application is performing its own connecting and does not
682 * use the connecting provided by this library. This function is normally
683 * used only if the application performed the connecting outside the
684 * library. The library however may use this internally. Returns FALSE
685 * if the key exchange could not be started.
688 void silc_client_start_key_exchange(SilcClient client,
689 SilcClientConnection conn,
692 /****f* silcclient/SilcClientAPI/silc_client_close_connection
696 * void silc_client_close_connection(SilcClient client,
697 * SilcSocketConnection sock,
698 * SilcClientConnection conn);
702 * Closes connection to remote end. Free's all allocated data except
703 * for some information such as nickname etc. that are valid at all time.
704 * If the `sock' is NULL then the conn->sock will be used. If `sock' is
705 * provided it will be checked whether the sock and `conn->sock' are the
706 * same (they can be different, ie. a socket can use `conn' as its
707 * connection but `conn->sock' might be actually a different connection
711 void silc_client_close_connection(SilcClient client,
712 SilcSocketConnection sock,
713 SilcClientConnection conn);
716 /* Message sending functions (client_channel.c and client_prvmsg.c) */
718 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
722 * void silc_client_send_channel_message(SilcClient client,
723 * SilcClientConnection conn,
724 * SilcChannelEntry channel,
725 * SilcChannelPrivateKey key,
726 * SilcMessageFlags flags,
727 * unsigned char *data,
733 * Sends packet to the `channel'. Packet to channel is always encrypted
734 * differently from "normal" packets. SILC header of the packet is
735 * encrypted with the next receiver's key and the rest of the packet is
736 * encrypted with the channel specific key. Padding and HMAC is computed
737 * with the next receiver's key. The `data' is the channel message. If
738 * the `force_send' is TRUE then the packet is sent immediately.
740 * If `key' is provided then that private key is used to encrypt the
741 * channel message. If it is not provided, private keys has not been
742 * set at all, the normal channel key is used automatically. If private
743 * keys are set then the first key (the key that was added first as
744 * private key) is used.
747 void silc_client_send_channel_message(SilcClient client,
748 SilcClientConnection conn,
749 SilcChannelEntry channel,
750 SilcChannelPrivateKey key,
751 SilcMessageFlags flags,
756 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
760 * void silc_client_send_private_message(SilcClient client,
761 * SilcClientConnection conn,
762 * SilcClientEntry client_entry,
763 * SilcMessageFlags flags,
764 * unsigned char *data,
770 * Sends private message to remote client. If private message key has
771 * not been set with this client then the message will be encrypted using
772 * normal session keys. Private messages are special packets in SILC
773 * network hence we need this own function for them. This is similar
774 * to silc_client_packet_send_to_channel except that we send private
775 * message. The `data' is the private message. If the `force_send' is
776 * TRUE the packet is sent immediately.
779 void silc_client_send_private_message(SilcClient client,
780 SilcClientConnection conn,
781 SilcClientEntry client_entry,
782 SilcMessageFlags flags,
788 /* Client and Channel entry retrieval (idlist.c) */
790 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
794 * typedef void (*SilcGetClientCallback)(SilcClient client,
795 * SilcClientConnection conn,
796 * SilcClientEntry *clients,
797 * uint32 clients_count,
802 * Callback function given to the silc_client_get_client function. The
803 * found entries are allocated into the `clients' array. The array must
804 * not be freed by the receiver, the library will free it later. If the
805 * `clients' is NULL, no such clients exist in the SILC Network.
808 typedef void (*SilcGetClientCallback)(SilcClient client,
809 SilcClientConnection conn,
810 SilcClientEntry *clients,
811 uint32 clients_count,
814 /****f* silcclient/SilcClientAPI/silc_client_get_clients
818 * void silc_client_get_clients(SilcClient client,
819 * SilcClientConnection conn,
820 * const char *nickname,
821 * const char *server,
822 * SilcGetClientCallback completion,
827 * Finds client entry or entries by the `nickname' and `server'. The
828 * completion callback will be called when the client entries has been
833 * NOTE: This function is always asynchronous and resolves the client
834 * information from the server. Thus, if you already know the client
835 * information then use the silc_client_get_client_by_id function to
836 * get the client entry since this function may be very slow and should
837 * be used only to initially get the client entries.
840 void silc_client_get_clients(SilcClient client,
841 SilcClientConnection conn,
842 const char *nickname,
844 SilcGetClientCallback completion,
847 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
851 * SilcClientEntry *silc_client_get_clients_local(SilcClient client,
852 * SilcClientConnection conn,
853 * const char *nickname,
854 * const char *format,
855 * uint32 *clients_count);
859 * Same as silc_client_get_clients function but does not resolve anything
860 * from the server. This checks local cache and returns all matching
861 * clients from the local cache. If none was found this returns NULL.
862 * The `nickname' is the real nickname of the client, and the `format'
863 * is the formatted nickname to find exact match from multiple found
864 * entries. The format must be same as given in the SilcClientParams
865 * structure to the client library. If the `format' is NULL all found
866 * clients by `nickname' are returned. The caller must return the
870 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
871 SilcClientConnection conn,
872 const char *nickname,
874 uint32 *clients_count);
876 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
880 * void silc_client_get_clients_by_list(SilcClient client,
881 * SilcClientConnection conn,
883 * SilcBuffer client_id_list,
884 * SilcGetClientCallback completion,
889 * Gets client entries by the list of client ID's `client_id_list'. This
890 * always resolves those client ID's it does not know yet from the server
891 * so this function might take a while. The `client_id_list' is a list
892 * of ID Payloads added one after other. JOIN command reply and USERS
893 * command reply for example returns this sort of list. The `completion'
894 * will be called after the entries are available.
897 void silc_client_get_clients_by_list(SilcClient client,
898 SilcClientConnection conn,
900 SilcBuffer client_id_list,
901 SilcGetClientCallback completion,
904 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
908 * SilcClientEntry silc_client_get_client_by_id(SilcClient client,
909 * SilcClientConnection conn,
910 * SilcClientID *client_id);
914 * Find entry for client by the client's ID. Returns the entry or NULL
915 * if the entry was not found.
918 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
919 SilcClientConnection conn,
920 SilcClientID *client_id);
922 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
927 * silc_client_get_client_by_id_resolve(SilcClient client,
928 * SilcClientConnection conn,
929 * SilcClientID *client_id,
930 * SilcGetClientCallback completion,
935 * Same as silc_client_get_client_by_id but will always resolve the
936 * information from the server. Use this only if you know that you
937 * do not have the entry and the only thing you know about the client
941 void silc_client_get_client_by_id_resolve(SilcClient client,
942 SilcClientConnection conn,
943 SilcClientID *client_id,
944 SilcGetClientCallback completion,
947 /****f* silcclient/SilcClientAPI/silc_client_del_client
951 * bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
952 * SilcClientEntry client_entry)
956 * Removes client from local cache by the client entry indicated by
957 * the `client_entry'. Returns TRUE if the deletion were successful.
960 bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
961 SilcClientEntry client_entry);
963 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
967 * typedef void (*SilcGetChannelCallback)(SilcClient client,
968 * SilcClientConnection conn,
969 * SilcChannelEntry *channels,
970 * uint32 channels_count,
975 * Callback function given to the silc_client_get_channel_* functions.
976 * The found entries are allocated into the `channels' array. The array
977 * must not be freed by the receiver, the library will free it later.
978 * If the `channel' is NULL, no such channel exist in the SILC Network.
981 typedef void (*SilcGetChannelCallback)(SilcClient client,
982 SilcClientConnection conn,
983 SilcChannelEntry *channels,
984 uint32 channels_count,
987 /****f* silcclient/SilcClientAPI/silc_client_get_channel
991 * SilcChannelEntry silc_client_get_channel(SilcClient client,
992 * SilcClientConnection conn,
997 * Finds entry for channel by the channel name. Returns the entry or NULL
998 * if the entry was not found. It is found only if the client is joined
1002 SilcChannelEntry silc_client_get_channel(SilcClient client,
1003 SilcClientConnection conn,
1006 /****f* silcclient/SilcClientAPI/silc_client_get_channel_id_resolve
1011 * silc_client_get_channel_by_id_resolve(SilcClient client,
1012 * SilcClientConnection conn,
1013 * SilcChannelID *channel_id,
1014 * SilcGetClientCallback completion,
1019 * Finds channel entry by the channel name. Returns the entry or NULL
1020 * if it was not found.
1023 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
1024 SilcClientConnection conn,
1025 SilcChannelID *channel_id);
1027 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
1032 * silc_client_get_channel_by_id_resolve(SilcClient client,
1033 * SilcClientConnection conn,
1034 * SilcChannelID *channel_id,
1035 * SilcGetClientCallback completion,
1040 * Resolves the channel information (its name mainly) from the server
1041 * by the `channel_id'. Use this only if you know that you do not have
1042 * the entry cached locally.
1045 void silc_client_get_channel_by_id_resolve(SilcClient client,
1046 SilcClientConnection conn,
1047 SilcChannelID *channel_id,
1048 SilcGetChannelCallback completion,
1051 /****f* silcclient/SilcClientAPI/silc_client_del_channel
1055 * bool silc_client_del_channel(SilcClient client,
1056 * SilcClientConnection conn,
1057 * SilcChannelEntry channel)
1061 * Removes channel from local cache by the channel entry indicated by
1062 * the `channel'. Returns TRUE if the deletion were successful.
1065 bool silc_client_del_channel(SilcClient client, SilcClientConnection conn,
1066 SilcChannelEntry channel);
1068 /****f* silcclient/SilcClientAPI/silc_client_get_server
1072 * SilcServerEntry silc_client_get_server(SilcClient client,
1073 * SilcClientConnection conn,
1074 * char *server_name)
1078 * Finds entry for server by the server name. Returns the entry or NULL
1079 * if the entry was not found.
1082 SilcServerEntry silc_client_get_server(SilcClient client,
1083 SilcClientConnection conn,
1086 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
1090 * SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1091 * SilcClientConnection conn,
1092 * SilcServerID *server_id);
1096 * Finds entry for server by the server ID. Returns the entry or NULL
1097 * if the entry was not found.
1100 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1101 SilcClientConnection conn,
1102 SilcServerID *server_id);
1104 /****f* silcclient/SilcClientAPI/silc_client_del_server
1108 * bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1109 * SilcServerEntry server);
1113 * Removes server from local cache by the server entry indicated by
1114 * the `server'. Returns TRUE if the deletion were successful.
1117 bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1118 SilcServerEntry server);
1120 /****f* silcclient/SilcClientAPI/silc_client_on_channel
1124 * SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1125 * SilcClientEntry client_entry);
1129 * Returns the ChannelUser entry if the `client_entry' is joined on the
1130 * channel indicated by the `channel'. NULL if client is not joined on
1134 SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1135 SilcClientEntry client_entry);
1137 /* Command management (command.c) */
1139 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
1143 * SilcClientCommandContext silc_client_command_alloc(void);
1147 * Allocate Command Context. The context is defined in `command.h' file.
1148 * The context is used by the library commands and applications should use
1149 * it as well. However, application may choose to use some own context
1150 * for its local commands. All library commands, however, must use this
1154 SilcClientCommandContext silc_client_command_alloc(void);
1156 /****f* silcclient/SilcClientAPI/silc_client_command_free
1160 * void silc_client_command_free(SilcClientCommandContext ctx);
1164 * Free command context and its internals. If the contex was duplicated
1165 * with silc_client_command_dup this may not actually free the data,
1166 * instead it will decrease the reference counter of the context. The
1167 * context will be freed when the reference counter hits zero.
1170 void silc_client_command_free(SilcClientCommandContext ctx);
1172 /****f* silcclient/SilcClientAPI/silc_client_command_dup
1176 * SilcClientCommandContext
1177 * silc_client_command_dup(SilcClientCommandContext ctx);
1181 * Duplicate Command Context by adding reference counter. The context won't
1182 * be free'd untill it hits zero.
1185 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
1187 /****f* silcclient/SilcClientAPI/silc_client_command_find
1191 * SilcClientCommand silc_client_command_find(SilcClient client,
1192 * const char *name);
1196 * Finds and returns a pointer to the command list. Return NULL if the
1197 * command is not found. See the `command.[ch]' for the command list.
1200 SilcClientCommand silc_client_command_find(SilcClient client,
1203 /****f* silcclient/SilcClientAPI/silc_client_command_call
1207 * void silc_client_command_call(SilcClientCommand command);
1211 * Calls the command (executes it). Application can call this after
1212 * it has allocated the SilcClientCommandContext with the function
1213 * silc_client_command_alloc and found the command from the client
1214 * library by calling silc_client_command_find. This will execute
1217 * Application can call the command function directly too if it
1218 * wishes to do so. See the command.h for details of the
1219 * SilcClientCommand structure.
1222 void silc_client_command_call(SilcClientCommand command,
1223 SilcClientCommandContext cmd);
1225 /****f* silcclient/SilcClientAPI/silc_client_command_send
1229 * void silc_client_command_send(SilcClient client,
1230 * SilcClientConnection conn,
1231 * SilcCommand command, uint16 ident,
1232 * uint32 argc, ...);
1236 * Generic function to send any command. The arguments must be sent already
1237 * encoded into correct form and in correct order. If application wants
1238 * to perform the commands by itself, it can do so and send the data
1239 * directly to the server using this function. If application is using
1240 * the silc_client_command_call, this function is usually not used.
1243 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1244 SilcCommand command, uint16 ident,
1247 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1251 * void silc_client_command_pending(SilcClientConnection conn,
1252 * SilcCommand reply_cmd,
1254 * SilcCommandCb callback,
1259 * Add new pending command to be executed when reply to a command has been
1260 * received. The `reply_cmd' is the command that will call the `callback'
1261 * with `context' when reply has been received. If `ident' is non-zero
1262 * the `callback' will be executed when received reply with command
1263 * identifier `ident'.
1265 * Note that the application is notified about the received command
1266 * reply through the `command_reply' client operation before calling
1267 * the `callback` pending command callback.
1270 void silc_client_command_pending(SilcClientConnection conn,
1271 SilcCommand reply_cmd,
1273 SilcCommandCb callback,
1277 /* Private Message key management (client_prvmsg.c) */
1279 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1283 * int silc_client_add_private_message_key(SilcClient client,
1284 * SilcClientConnection conn,
1285 * SilcClientEntry client_entry,
1287 * unsigned char *key,
1289 * bool generate_key,
1294 * Adds private message key to the client library. The key will be used to
1295 * encrypt all private message between the client and the remote client
1296 * indicated by the `client_entry'. If the `key' is NULL and the boolean
1297 * value `generate_key' is TRUE the library will generate random key.
1298 * The `key' maybe for example pre-shared-key, passphrase or similar.
1299 * The `cipher' MAY be provided but SHOULD be NULL to assure that the
1300 * requirements of the SILC protocol are met. The API, however, allows
1301 * to allocate any cipher.
1303 * If `responder' is TRUE then the sending and receiving keys will be
1304 * set according the client being the receiver of the private key. If
1305 * FALSE the client is being the sender (or negotiator) of the private
1308 * It is not necessary to set key for normal private message usage. If the
1309 * key is not set then the private messages are encrypted using normal
1310 * session keys. Setting the private key, however, increases the security.
1312 * Returns FALSE if the key is already set for the `client_entry', TRUE
1316 int silc_client_add_private_message_key(SilcClient client,
1317 SilcClientConnection conn,
1318 SilcClientEntry client_entry,
1325 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1329 * int silc_client_add_private_message_key_ske(SilcClient client,
1330 * SilcClientConnection conn,
1331 * SilcClientEntry client_entry,
1333 * SilcSKEKeyMaterial *key);
1337 * Same as silc_client_add_private_message_key but takes the key material
1338 * from the SKE key material structure. This structure is received if
1339 * the application uses the silc_client_send_key_agreement to negotiate
1340 * the key material. The `cipher' SHOULD be provided as it is negotiated
1341 * also in the SKE protocol.
1344 int silc_client_add_private_message_key_ske(SilcClient client,
1345 SilcClientConnection conn,
1346 SilcClientEntry client_entry,
1348 SilcSKEKeyMaterial *key,
1351 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
1355 * int silc_client_send_private_message_key(SilcClient client,
1356 * SilcClientConnection conn,
1357 * SilcClientEntry client_entry,
1362 * Sends private message key payload to the remote client indicated by
1363 * the `client_entry'. If the `force_send' is TRUE the packet is sent
1364 * immediately. Returns FALSE if error occurs, TRUE otherwise. The
1365 * application should call this function after setting the key to the
1368 * Note that the key sent using this function is sent to the remote client
1369 * through the SILC network. The packet is protected using normal session
1373 int silc_client_send_private_message_key(SilcClient client,
1374 SilcClientConnection conn,
1375 SilcClientEntry client_entry,
1378 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1382 * int silc_client_del_private_message_key(SilcClient client,
1383 * SilcClientConnection conn,
1384 * SilcClientEntry client_entry);
1388 * Removes the private message from the library. The key won't be used
1389 * after this to protect the private messages with the remote `client_entry'
1390 * client. Returns FALSE on error, TRUE otherwise.
1393 int silc_client_del_private_message_key(SilcClient client,
1394 SilcClientConnection conn,
1395 SilcClientEntry client_entry);
1397 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1401 * SilcPrivateMessageKeys
1402 * silc_client_list_private_message_keys(SilcClient client,
1403 * SilcClientConnection conn,
1404 * uint32 *key_count);
1408 * Returns array of set private message keys associated to the connection
1409 * `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1410 * count to the `key_count' argument. The array must be freed by the caller
1411 * by calling the silc_client_free_private_message_keys function. Note:
1412 * the keys returned in the array is in raw format. It might not be desired
1413 * to show the keys as is. The application might choose not to show the keys
1414 * at all or to show the fingerprints of the keys.
1417 SilcPrivateMessageKeys
1418 silc_client_list_private_message_keys(SilcClient client,
1419 SilcClientConnection conn,
1422 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1426 * void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1427 * uint32 key_count);
1431 * Frees the SilcPrivateMessageKeys array returned by the function
1432 * silc_client_list_private_message_keys.
1435 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1439 /* Channel private key management (client_channel.c,
1440 SilcChannelPrivateKey is defined in idlist.h) */
1442 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1446 * int silc_client_add_channel_private_key(SilcClient client,
1447 * SilcClientConnection conn,
1448 * SilcChannelEntry channel,
1451 * unsigned char *key,
1456 * Adds private key for channel. This may be set only if the channel's mode
1457 * mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1458 * mode is not set. When channel has private key then the messages are
1459 * encrypted using that key. All clients on the channel must also know the
1460 * key in order to decrypt the messages. However, it is possible to have
1461 * several private keys per one channel. In this case only some of the
1462 * clients on the channel may know the one key and only some the other key.
1464 * The private key for channel is optional. If it is not set then the
1465 * channel messages are encrypted using the channel key generated by the
1466 * server. However, setting the private key (or keys) for the channel
1467 * significantly adds security. If more than one key is set the library
1468 * will automatically try all keys at the message decryption phase. Note:
1469 * setting many keys slows down the decryption phase as all keys has to
1470 * be tried in order to find the correct decryption key. However, setting
1471 * a few keys does not have big impact to the decryption performace.
1475 * NOTE: This is entirely local setting. The key set using this function
1476 * is not sent to the network at any phase.
1478 * NOTE: If the key material was originated by the SKE protocol (using
1479 * silc_client_send_key_agreement) then the `key' MUST be the
1480 * key->send_enc_key as this is dictated by the SILC protocol. However,
1481 * currently it is not expected that the SKE key material would be used
1482 * as channel private key. However, this API allows it.
1485 int silc_client_add_channel_private_key(SilcClient client,
1486 SilcClientConnection conn,
1487 SilcChannelEntry channel,
1493 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1497 * int silc_client_del_channel_private_keys(SilcClient client,
1498 * SilcClientConnection conn,
1499 * SilcChannelEntry channel);
1503 * Removes all private keys from the `channel'. The old channel key is used
1504 * after calling this to protect the channel messages. Returns FALSE on
1505 * on error, TRUE otherwise.
1508 int silc_client_del_channel_private_keys(SilcClient client,
1509 SilcClientConnection conn,
1510 SilcChannelEntry channel);
1512 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1516 * int silc_client_del_channel_private_key(SilcClient client,
1517 * SilcClientConnection conn,
1518 * SilcChannelEntry channel,
1519 * SilcChannelPrivateKey key);
1523 * Removes and frees private key `key' from the channel `channel'.
1524 * The `key' is retrieved by calling the function
1525 * silc_client_list_channel_private_keys. The key is not used after
1526 * this. If the key was last private key then the old channel key is
1527 * used hereafter to protect the channel messages. This returns FALSE
1528 * on error, TRUE otherwise.
1531 int silc_client_del_channel_private_key(SilcClient client,
1532 SilcClientConnection conn,
1533 SilcChannelEntry channel,
1534 SilcChannelPrivateKey key);
1536 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1540 * SilcChannelPrivateKey *
1541 * silc_client_list_channel_private_keys(SilcClient client,
1542 * SilcClientConnection conn,
1543 * SilcChannelEntry channel,
1544 * uint32 *key_count);
1548 * Returns array (pointers) of private keys associated to the `channel'.
1549 * The caller must free the array by calling the function
1550 * silc_client_free_channel_private_keys. The pointers in the array may be
1551 * used to delete the specific key by giving the pointer as argument to the
1552 * function silc_client_del_channel_private_key.
1555 SilcChannelPrivateKey *
1556 silc_client_list_channel_private_keys(SilcClient client,
1557 SilcClientConnection conn,
1558 SilcChannelEntry channel,
1561 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1565 * void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1566 * uint32 key_count);
1570 * Frees the SilcChannelPrivateKey array.
1573 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1577 /* Key Agreement routines (client_keyagr.c) */
1579 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1583 * void silc_client_send_key_agreement(SilcClient client,
1584 * SilcClientConnection conn,
1585 * SilcClientEntry client_entry,
1588 * uint32 timeout_secs,
1589 * SilcKeyAgreementCallback completion,
1594 * Sends key agreement request to the remote client indicated by the
1595 * `client_entry'. If the caller provides the `hostname' and the `port'
1596 * arguments then the library will bind the client to that hostname and
1597 * that port for the key agreement protocol. It also sends the `hostname'
1598 * and the `port' in the key agreement packet to the remote client. This
1599 * would indicate that the remote client may initiate the key agreement
1600 * protocol to the `hostname' on the `port'. If port is zero then the
1601 * bound port is undefined (the operating system defines it).
1603 * If the `hostname' and `port' is not provided then empty key agreement
1604 * packet is sent to the remote client. The remote client may reply with
1605 * the same packet including its hostname and port. If the library receives
1606 * the reply from the remote client the `key_agreement' client operation
1607 * callback will be called to verify whether the user wants to perform the
1608 * key agreement or not.
1612 * NOTE: If the application provided the `hostname' and the `port' and the
1613 * remote side initiates the key agreement protocol it is not verified
1614 * from the user anymore whether the protocol should be executed or not.
1615 * By setting the `hostname' and `port' the user gives permission to
1616 * perform the protocol (we are responder in this case).
1618 * NOTE: If the remote side decides not to initiate the key agreement
1619 * or decides not to reply with the key agreement packet then we cannot
1620 * perform the key agreement at all. If the key agreement protocol is
1621 * performed the `completion' callback with the `context' will be called.
1622 * If remote side decides to ignore the request the `completion' will be
1623 * called after the specified timeout, `timeout_secs'.
1625 * NOTE: If the `hostname' and the `port' was not provided the `completion'
1626 * will not be called at all since this does nothing more than sending
1627 * a packet to the remote host.
1629 * NOTE: There can be only one active key agreement for one client entry.
1630 * Before setting new one, the old one must be finished (it is finished
1631 * after calling the completion callback) or the function
1632 * silc_client_abort_key_agreement must be called.
1635 void silc_client_send_key_agreement(SilcClient client,
1636 SilcClientConnection conn,
1637 SilcClientEntry client_entry,
1638 const char *hostname,
1639 const char *bindhost,
1641 uint32 timeout_secs,
1642 SilcKeyAgreementCallback completion,
1645 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1650 * silc_client_perform_key_agreement(SilcClient client,
1651 * SilcClientConnection conn,
1652 * SilcClientEntry client_entry,
1655 * SilcKeyAgreementCallback completion,
1660 * Performs the actual key agreement protocol. Application may use this
1661 * to initiate the key agreement protocol. This can be called for example
1662 * after the application has received the `key_agreement' client operation,
1663 * and did not return TRUE from it.
1665 * The `hostname' is the remote hostname (or IP address) and the `port'
1666 * is the remote port. The `completion' callback with the `context' will
1667 * be called after the key agreement protocol.
1671 * NOTE: If the application returns TRUE in the `key_agreement' client
1672 * operation the library will automatically start the key agreement. In this
1673 * case the application must not call this function. However, application
1674 * may choose to just ignore the `key_agreement' client operation (and
1675 * merely just print information about it on the screen) and call this
1676 * function when the user whishes to do so (by, for example, giving some
1677 * specific command). Thus, the API provides both, automatic and manual
1678 * initiation of the key agreement. Calling this function is the manual
1679 * initiation and returning TRUE in the `key_agreement' client operation
1680 * is the automatic initiation.
1683 void silc_client_perform_key_agreement(SilcClient client,
1684 SilcClientConnection conn,
1685 SilcClientEntry client_entry,
1688 SilcKeyAgreementCallback completion,
1691 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1696 * silc_client_perform_key_agreement_fd(SilcClient client,
1697 * SilcClientConnection conn,
1698 * SilcClientEntry client_entry,
1701 * SilcKeyAgreementCallback completion,
1706 * Same as above but application has created already the connection to
1707 * the remote host. The `sock' is the socket to the remote connection.
1708 * Application can use this function if it does not want the client library
1709 * to create the connection.
1712 void silc_client_perform_key_agreement_fd(SilcClient client,
1713 SilcClientConnection conn,
1714 SilcClientEntry client_entry,
1717 SilcKeyAgreementCallback completion,
1720 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1724 * void silc_client_abort_key_agreement(SilcClient client,
1725 * SilcClientConnection conn,
1726 * SilcClientEntry client_entry);
1730 * This function can be called to unbind the hostname and the port for
1731 * the key agreement protocol. However, this function has effect only
1732 * before the key agreement protocol has been performed. After it has
1733 * been performed the library will automatically unbind the port. The
1734 * `client_entry' is the client to which we sent the key agreement
1735 * request. The key agreement completion callback will be called
1736 * with SILC_KEY_AGREEMENT_ABORTED status.
1739 void silc_client_abort_key_agreement(SilcClient client,
1740 SilcClientConnection conn,
1741 SilcClientEntry client_entry);
1744 /* Misc functions */
1746 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1750 * void silc_client_set_away_message(SilcClient client,
1751 * SilcClientConnection conn,
1756 * Sets away `message'. The away message may be set when the client's
1757 * mode is changed to SILC_UMODE_GONE and the client whishes to reply
1758 * to anyone who sends private message. The `message' will be sent
1759 * automatically back to the the client who send private message. If
1760 * away message is already set this replaces the old message with the
1761 * new one. If `message' is NULL the old away message is removed.
1762 * The sender may freely free the memory of the `message'.
1765 void silc_client_set_away_message(SilcClient client,
1766 SilcClientConnection conn,
1770 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
1774 * typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1775 * SilcClientConnection conn,
1776 * SilcAuthMethod auth_meth,
1781 * Connection authentication method request callback. This is called
1782 * by the client library after it has received the authentication method
1783 * that the application requested by calling the function
1784 * silc_client_request_authentication_method.
1787 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1788 SilcClientConnection conn,
1789 SilcAuthMethod auth_meth,
1792 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
1797 * silc_client_request_authentication_method(SilcClient client,
1798 * SilcClientConnection conn,
1799 * SilcConnectionAuthRequest
1805 * This function can be used to request the current authentication method
1806 * from the server. This may be called when connecting to the server
1807 * and the client library requests the authentication data from the
1808 * application. If the application does not know the current authentication
1809 * method it can request it from the server using this function.
1810 * The `callback' with `context' will be called after the server has
1811 * replied back with the current authentication method.
1815 silc_client_request_authentication_method(SilcClient client,
1816 SilcClientConnection conn,
1817 SilcConnectionAuthRequest callback,
1820 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
1824 * typedef enum { ... } SilcClientMonitorStatus;
1828 * File transmission session status types. These will indicate
1829 * the status of the file transmission session.
1834 SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT, /* In key agreemenet phase */
1835 SILC_CLIENT_FILE_MONITOR_SEND, /* Sending file */
1836 SILC_CLIENT_FILE_MONITOR_RECEIVE, /* Receiving file */
1837 SILC_CLIENT_FILE_MONITOR_GET,
1838 SILC_CLIENT_FILE_MONITOR_PUT,
1839 SILC_CLIENT_FILE_MONITOR_CLOSED, /* Session closed */
1840 SILC_CLIENT_FILE_MONITOR_ERROR, /* Error during session */
1841 } SilcClientMonitorStatus;
1844 /****d* silcclient/SilcClientAPI/SilcClientFileError
1848 * typedef enum { ... } SilcClientFileError;
1852 * File transmission error types. These types are returned by
1853 * some of the file transmission functions, and by the monitor
1854 * callback to indicate error.
1859 SILC_CLIENT_FILE_OK,
1860 SILC_CLIENT_FILE_ERROR,
1861 SILC_CLIENT_FILE_UNKNOWN_SESSION,
1862 SILC_CLIENT_FILE_ALREADY_STARTED,
1863 SILC_CLIENT_FILE_NO_SUCH_FILE,
1864 SILC_CLIENT_FILE_PERMISSION_DENIED,
1865 } SilcClientFileError;
1868 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
1872 * typedef void (*SilcClientFileMonitor)(SilcClient client,
1873 * SilcClientConnection conn,
1874 * SilcClientMonitorStatus status,
1875 * SilcClientFileError error,
1878 * SilcClientEntry client_entry,
1879 * uint32 session_id,
1880 * const char *filepath,
1885 * Monitor callback that is called during the file transmission to
1886 * monitor the transmission process. The `status' indicates the current
1887 * monitoring process. The `error' will indicate the error type
1888 * if `status' is SILC_CLIENT_FILE_MONITOR_ERROR. The `offset' is the
1889 * currently transmitted amount of total `filesize'. The `client_entry'
1890 * indicates the remote client, and the transmission session ID is the
1891 * `session_id'. The filename being transmitted is indicated by the
1895 typedef void (*SilcClientFileMonitor)(SilcClient client,
1896 SilcClientConnection conn,
1897 SilcClientMonitorStatus status,
1898 SilcClientFileError error,
1901 SilcClientEntry client_entry,
1903 const char *filepath,
1906 /****f* silcclient/SilcClientAPI/silc_client_file_send
1910 * uint32 silc_client_file_send(SilcClient client,
1911 * SilcClientConnection conn,
1912 * SilcClientFileMonitor monitor,
1913 * void *monitor_context,
1914 * const char *local_ip,
1915 * uint32 local_port,
1916 * SilcClientEntry client_entry,
1917 * const char *filepath);
1921 * Sends a file indicated by the `filepath' to the remote client
1922 * indicated by the `client_entry'. This will negotiate a secret key
1923 * with the remote client before actually starting the transmission of
1924 * the file. The `monitor' callback will be called to monitor the
1925 * transmission of the file.
1927 * This returns a file session ID for the file transmission. It can
1928 * be used to close the session (and abort the file transmission) by
1929 * calling the silc_client_file_close function. The session ID is
1930 * also returned in the `monitor' callback. This returns 0 if the
1931 * file indicated by the `filepath' is being transmitted to the remote
1932 * client indicated by the `client_entry', already.
1934 * If the `local_ip' is provided then this will try to bind the
1935 * listener for key exchange protocol to that IP. If `local_port' is
1936 * non-zero that port is used. If `local_ip' is NULL then this will
1937 * automatically attempt to bind it to local IP address of the machine.
1938 * If that fails then this does not bind to any address and port, and
1939 * assume that the remote client will provide the listener for the
1940 * key exchange protocol.
1942 * If error will occur during the file transfer process the error
1943 * status will be returned in the monitor callback. In this case
1944 * the application must call silc_client_file_close to close the
1948 uint32 silc_client_file_send(SilcClient client,
1949 SilcClientConnection conn,
1950 SilcClientFileMonitor monitor,
1951 void *monitor_context,
1952 const char *local_ip,
1954 SilcClientEntry client_entry,
1955 const char *filepath);
1957 /****f* silcclient/SilcClientAPI/silc_client_file_receive
1961 * SilcClientFileError
1962 * silc_client_file_receive(SilcClient client,
1963 * SilcClientConnection conn,
1964 * SilcClientFileMonitor monitor,
1965 * void *monitor_context,
1966 * uint32 session_id);
1970 * Receives a file from a client indicated by the `client_entry'. The
1971 * `session_id' indicates the file transmission session and it has been
1972 * received in the `ftp' client operation function. This will actually
1973 * perform the key agreement protocol with the remote client before
1974 * actually starting the file transmission. The `monitor' callback
1975 * will be called to monitor the transmission.
1977 * If error will occur during the file transfer process the error
1978 * status will be returned in the monitor callback. In this case
1979 * the application must call silc_client_file_close to close the
1984 silc_client_file_receive(SilcClient client,
1985 SilcClientConnection conn,
1986 SilcClientFileMonitor monitor,
1987 void *monitor_context,
1990 /****f* silcclient/SilcClientAPI/silc_client_file_close
1994 * SilcClientFileError silc_client_file_close(SilcClient client,
1995 * SilcClientConnection conn,
1996 * uint32 session_id);
2000 * Closes file transmission session indicated by the `session_id'.
2001 * If file transmission is being conducted it will be aborted
2002 * automatically. This function is also used to close the session
2003 * after successful file transmission. This function can be used
2004 * also to reject incoming file transmission request.
2007 SilcClientFileError silc_client_file_close(SilcClient client,
2008 SilcClientConnection conn,