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 * int 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 bool 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 (*SilcGetClientCallback)(SilcClient client,
968 * SilcClientConnection conn,
969 * SilcClientEntry *clients,
970 * uint32 clients_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 /* Command management (command.c) */
1122 /****f* silcclient/SilcClientAPI/silc_client_command_alloc
1126 * SilcClientCommandContext silc_client_command_alloc();
1130 * Allocate Command Context. The context is defined in `command.h' file.
1131 * The context is used by the library commands and applications should use
1132 * it as well. However, application may choose to use some own context
1133 * for its local commands. All library commands, however, must use this
1137 SilcClientCommandContext silc_client_command_alloc();
1139 /****f* silcclient/SilcClientAPI/silc_client_command_free
1143 * void silc_client_command_free(SilcClientCommandContext ctx);
1147 * Free command context and its internals. If the contex was duplicated
1148 * with silc_client_command_dup this may not actually free the data,
1149 * instead it will decrease the reference counter of the context. The
1150 * context will be freed when the reference counter hits zero.
1153 void silc_client_command_free(SilcClientCommandContext ctx);
1155 /****f* silcclient/SilcClientAPI/silc_client_command_dup
1159 * SilcClientCommandContext
1160 * silc_client_command_dup(SilcClientCommandContext ctx);
1164 * Duplicate Command Context by adding reference counter. The context won't
1165 * be free'd untill it hits zero.
1168 SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
1170 /****f* silcclient/SilcClientAPI/silc_client_command_find
1174 * SilcClientCommand *silc_client_command_find(const char *name);
1178 * Finds and returns a pointer to the command list. Return NULL if the
1179 * command is not found. See the `command.[ch]' for the command list.
1182 SilcClientCommand *silc_client_command_find(const char *name);
1184 /****f* silcclient/SilcClientAPI/silc_client_send_command
1188 * void silc_client_send_command(SilcClient client,
1189 * SilcClientConnection conn,
1190 * SilcCommand command, uint16 ident,
1191 * uint32 argc, ...);
1195 * Generic function to send any command. The arguments must be sent already
1196 * encoded into correct form and in correct order.
1199 void silc_client_send_command(SilcClient client, SilcClientConnection conn,
1200 SilcCommand command, uint16 ident,
1203 /****f* silcclient/SilcClientAPI/SilcClientPendingDestructor
1207 * typedef void (*SilcClientPendingDestructor)(void *context);
1211 * Pending Command callback destructor. This is called after calling the
1212 * pending callback or if error occurs while processing the pending command.
1213 * If error occurs then the callback won't be called at all, and only this
1214 * destructor is called. The `context' is the context given for the function
1215 * silc_client_command_pending.
1218 typedef void (*SilcClientPendingDestructor)(void *context);
1220 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1224 * void silc_client_command_pending(SilcClientConnection conn,
1225 * SilcCommand reply_cmd,
1227 * SilcClientPendingDestructor destructor,
1228 * SilcCommandCb callback,
1233 * Add new pending command to be executed when reply to a command has been
1234 * received. The `reply_cmd' is the command that will call the `callback'
1235 * with `context' when reply has been received. If `ident is non-zero
1236 * the `callback' will be executed when received reply with command
1237 * identifier `ident'.
1240 void silc_client_command_pending(SilcClientConnection conn,
1241 SilcCommand reply_cmd,
1243 SilcClientPendingDestructor destructor,
1244 SilcCommandCb callback,
1248 /* Private Message key management (client_prvmsg.c) */
1250 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1254 * int silc_client_add_private_message_key(SilcClient client,
1255 * SilcClientConnection conn,
1256 * SilcClientEntry client_entry,
1258 * unsigned char *key,
1260 * bool generate_key,
1265 * Adds private message key to the client library. The key will be used to
1266 * encrypt all private message between the client and the remote client
1267 * indicated by the `client_entry'. If the `key' is NULL and the boolean
1268 * value `generate_key' is TRUE the library will generate random key.
1269 * The `key' maybe for example pre-shared-key, passphrase or similar.
1270 * The `cipher' MAY be provided but SHOULD be NULL to assure that the
1271 * requirements of the SILC protocol are met. The API, however, allows
1272 * to allocate any cipher.
1274 * If `responder' is TRUE then the sending and receiving keys will be
1275 * set according the client being the receiver of the private key. If
1276 * FALSE the client is being the sender (or negotiator) of the private
1279 * It is not necessary to set key for normal private message usage. If the
1280 * key is not set then the private messages are encrypted using normal
1281 * session keys. Setting the private key, however, increases the security.
1283 * Returns FALSE if the key is already set for the `client_entry', TRUE
1287 int silc_client_add_private_message_key(SilcClient client,
1288 SilcClientConnection conn,
1289 SilcClientEntry client_entry,
1296 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1300 * int silc_client_add_private_message_key_ske(SilcClient client,
1301 * SilcClientConnection conn,
1302 * SilcClientEntry client_entry,
1304 * SilcSKEKeyMaterial *key);
1308 * Same as silc_client_add_private_message_key but takes the key material
1309 * from the SKE key material structure. This structure is received if
1310 * the application uses the silc_client_send_key_agreement to negotiate
1311 * the key material. The `cipher' SHOULD be provided as it is negotiated
1312 * also in the SKE protocol.
1315 int silc_client_add_private_message_key_ske(SilcClient client,
1316 SilcClientConnection conn,
1317 SilcClientEntry client_entry,
1319 SilcSKEKeyMaterial *key,
1322 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
1326 * int silc_client_send_private_message_key(SilcClient client,
1327 * SilcClientConnection conn,
1328 * SilcClientEntry client_entry,
1333 * Sends private message key payload to the remote client indicated by
1334 * the `client_entry'. If the `force_send' is TRUE the packet is sent
1335 * immediately. Returns FALSE if error occurs, TRUE otherwise. The
1336 * application should call this function after setting the key to the
1339 * Note that the key sent using this function is sent to the remote client
1340 * through the SILC network. The packet is protected using normal session
1344 int silc_client_send_private_message_key(SilcClient client,
1345 SilcClientConnection conn,
1346 SilcClientEntry client_entry,
1349 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1353 * int silc_client_del_private_message_key(SilcClient client,
1354 * SilcClientConnection conn,
1355 * SilcClientEntry client_entry);
1359 * Removes the private message from the library. The key won't be used
1360 * after this to protect the private messages with the remote `client_entry'
1361 * client. Returns FALSE on error, TRUE otherwise.
1364 int silc_client_del_private_message_key(SilcClient client,
1365 SilcClientConnection conn,
1366 SilcClientEntry client_entry);
1368 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1372 * SilcPrivateMessageKeys
1373 * silc_client_list_private_message_keys(SilcClient client,
1374 * SilcClientConnection conn,
1375 * uint32 *key_count);
1379 * Returns array of set private message keys associated to the connection
1380 * `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1381 * count to the `key_count' argument. The array must be freed by the caller
1382 * by calling the silc_client_free_private_message_keys function. Note:
1383 * the keys returned in the array is in raw format. It might not be desired
1384 * to show the keys as is. The application might choose not to show the keys
1385 * at all or to show the fingerprints of the keys.
1388 SilcPrivateMessageKeys
1389 silc_client_list_private_message_keys(SilcClient client,
1390 SilcClientConnection conn,
1393 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1397 * void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1398 * uint32 key_count);
1402 * Frees the SilcPrivateMessageKeys array returned by the function
1403 * silc_client_list_private_message_keys.
1406 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1410 /* Channel private key management (client_channel.c,
1411 SilcChannelPrivateKey is defined in idlist.h) */
1413 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1417 * int silc_client_add_channel_private_key(SilcClient client,
1418 * SilcClientConnection conn,
1419 * SilcChannelEntry channel,
1422 * unsigned char *key,
1427 * Adds private key for channel. This may be set only if the channel's mode
1428 * mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1429 * mode is not set. When channel has private key then the messages are
1430 * encrypted using that key. All clients on the channel must also know the
1431 * key in order to decrypt the messages. However, it is possible to have
1432 * several private keys per one channel. In this case only some of the
1433 * clients on the channel may know the one key and only some the other key.
1435 * The private key for channel is optional. If it is not set then the
1436 * channel messages are encrypted using the channel key generated by the
1437 * server. However, setting the private key (or keys) for the channel
1438 * significantly adds security. If more than one key is set the library
1439 * will automatically try all keys at the message decryption phase. Note:
1440 * setting many keys slows down the decryption phase as all keys has to
1441 * be tried in order to find the correct decryption key. However, setting
1442 * a few keys does not have big impact to the decryption performace.
1446 * NOTE: This is entirely local setting. The key set using this function
1447 * is not sent to the network at any phase.
1449 * NOTE: If the key material was originated by the SKE protocol (using
1450 * silc_client_send_key_agreement) then the `key' MUST be the
1451 * key->send_enc_key as this is dictated by the SILC protocol. However,
1452 * currently it is not expected that the SKE key material would be used
1453 * as channel private key. However, this API allows it.
1456 int silc_client_add_channel_private_key(SilcClient client,
1457 SilcClientConnection conn,
1458 SilcChannelEntry channel,
1464 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1468 * int silc_client_del_channel_private_keys(SilcClient client,
1469 * SilcClientConnection conn,
1470 * SilcChannelEntry channel);
1474 * Removes all private keys from the `channel'. The old channel key is used
1475 * after calling this to protect the channel messages. Returns FALSE on
1476 * on error, TRUE otherwise.
1479 int silc_client_del_channel_private_keys(SilcClient client,
1480 SilcClientConnection conn,
1481 SilcChannelEntry channel);
1483 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1487 * int silc_client_del_channel_private_key(SilcClient client,
1488 * SilcClientConnection conn,
1489 * SilcChannelEntry channel,
1490 * SilcChannelPrivateKey key);
1494 * Removes and frees private key `key' from the channel `channel'.
1495 * The `key' is retrieved by calling the function
1496 * silc_client_list_channel_private_keys. The key is not used after
1497 * this. If the key was last private key then the old channel key is
1498 * used hereafter to protect the channel messages. This returns FALSE
1499 * on error, TRUE otherwise.
1502 int silc_client_del_channel_private_key(SilcClient client,
1503 SilcClientConnection conn,
1504 SilcChannelEntry channel,
1505 SilcChannelPrivateKey key);
1507 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1511 * SilcChannelPrivateKey *
1512 * silc_client_list_channel_private_keys(SilcClient client,
1513 * SilcClientConnection conn,
1514 * SilcChannelEntry channel,
1515 * uint32 *key_count);
1519 * Returns array (pointers) of private keys associated to the `channel'.
1520 * The caller must free the array by calling the function
1521 * silc_client_free_channel_private_keys. The pointers in the array may be
1522 * used to delete the specific key by giving the pointer as argument to the
1523 * function silc_client_del_channel_private_key.
1526 SilcChannelPrivateKey *
1527 silc_client_list_channel_private_keys(SilcClient client,
1528 SilcClientConnection conn,
1529 SilcChannelEntry channel,
1532 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1536 * void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1537 * uint32 key_count);
1541 * Frees the SilcChannelPrivateKey array.
1544 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1548 /* Key Agreement routines (client_keyagr.c) */
1550 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1554 * void silc_client_send_key_agreement(SilcClient client,
1555 * SilcClientConnection conn,
1556 * SilcClientEntry client_entry,
1559 * uint32 timeout_secs,
1560 * SilcKeyAgreementCallback completion,
1565 * Sends key agreement request to the remote client indicated by the
1566 * `client_entry'. If the caller provides the `hostname' and the `port'
1567 * arguments then the library will bind the client to that hostname and
1568 * that port for the key agreement protocol. It also sends the `hostname'
1569 * and the `port' in the key agreement packet to the remote client. This
1570 * would indicate that the remote client may initiate the key agreement
1571 * protocol to the `hostname' on the `port'. If port is zero then the
1572 * bound port is undefined (the operating system defines it).
1574 * If the `hostname' and `port' is not provided then empty key agreement
1575 * packet is sent to the remote client. The remote client may reply with
1576 * the same packet including its hostname and port. If the library receives
1577 * the reply from the remote client the `key_agreement' client operation
1578 * callback will be called to verify whether the user wants to perform the
1579 * key agreement or not.
1583 * NOTE: If the application provided the `hostname' and the `port' and the
1584 * remote side initiates the key agreement protocol it is not verified
1585 * from the user anymore whether the protocol should be executed or not.
1586 * By setting the `hostname' and `port' the user gives permission to
1587 * perform the protocol (we are responder in this case).
1589 * NOTE: If the remote side decides not to initiate the key agreement
1590 * or decides not to reply with the key agreement packet then we cannot
1591 * perform the key agreement at all. If the key agreement protocol is
1592 * performed the `completion' callback with the `context' will be called.
1593 * If remote side decides to ignore the request the `completion' will be
1594 * called after the specified timeout, `timeout_secs'.
1596 * NOTE: If the `hostname' and the `port' was not provided the `completion'
1597 * will not be called at all since this does nothing more than sending
1598 * a packet to the remote host.
1600 * NOTE: There can be only one active key agreement for one client entry.
1601 * Before setting new one, the old one must be finished (it is finished
1602 * after calling the completion callback) or the function
1603 * silc_client_abort_key_agreement must be called.
1606 void silc_client_send_key_agreement(SilcClient client,
1607 SilcClientConnection conn,
1608 SilcClientEntry client_entry,
1609 const char *hostname,
1610 const char *bindhost,
1612 uint32 timeout_secs,
1613 SilcKeyAgreementCallback completion,
1616 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
1621 * silc_client_perform_key_agreement(SilcClient client,
1622 * SilcClientConnection conn,
1623 * SilcClientEntry client_entry,
1626 * SilcKeyAgreementCallback completion,
1631 * Performs the actual key agreement protocol. Application may use this
1632 * to initiate the key agreement protocol. This can be called for example
1633 * after the application has received the `key_agreement' client operation,
1634 * and did not return TRUE from it.
1636 * The `hostname' is the remote hostname (or IP address) and the `port'
1637 * is the remote port. The `completion' callback with the `context' will
1638 * be called after the key agreement protocol.
1642 * NOTE: If the application returns TRUE in the `key_agreement' client
1643 * operation the library will automatically start the key agreement. In this
1644 * case the application must not call this function. However, application
1645 * may choose to just ignore the `key_agreement' client operation (and
1646 * merely just print information about it on the screen) and call this
1647 * function when the user whishes to do so (by, for example, giving some
1648 * specific command). Thus, the API provides both, automatic and manual
1649 * initiation of the key agreement. Calling this function is the manual
1650 * initiation and returning TRUE in the `key_agreement' client operation
1651 * is the automatic initiation.
1654 void silc_client_perform_key_agreement(SilcClient client,
1655 SilcClientConnection conn,
1656 SilcClientEntry client_entry,
1659 SilcKeyAgreementCallback completion,
1662 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
1667 * silc_client_perform_key_agreement_fd(SilcClient client,
1668 * SilcClientConnection conn,
1669 * SilcClientEntry client_entry,
1672 * SilcKeyAgreementCallback completion,
1677 * Same as above but application has created already the connection to
1678 * the remote host. The `sock' is the socket to the remote connection.
1679 * Application can use this function if it does not want the client library
1680 * to create the connection.
1683 void silc_client_perform_key_agreement_fd(SilcClient client,
1684 SilcClientConnection conn,
1685 SilcClientEntry client_entry,
1688 SilcKeyAgreementCallback completion,
1691 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
1695 * void silc_client_abort_key_agreement(SilcClient client,
1696 * SilcClientConnection conn,
1697 * SilcClientEntry client_entry);
1701 * This function can be called to unbind the hostname and the port for
1702 * the key agreement protocol. However, this function has effect only
1703 * before the key agreement protocol has been performed. After it has
1704 * been performed the library will automatically unbind the port. The
1705 * `client_entry' is the client to which we sent the key agreement
1706 * request. The key agreement completion callback will be called
1707 * with SILC_KEY_AGREEMENT_ABORTED status.
1710 void silc_client_abort_key_agreement(SilcClient client,
1711 SilcClientConnection conn,
1712 SilcClientEntry client_entry);
1715 /* Misc functions */
1717 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
1721 * void silc_client_set_away_message(SilcClient client,
1722 * SilcClientConnection conn,
1727 * Sets away `message'. The away message may be set when the client's
1728 * mode is changed to SILC_UMODE_GONE and the client whishes to reply
1729 * to anyone who sends private message. The `message' will be sent
1730 * automatically back to the the client who send private message. If
1731 * away message is already set this replaces the old message with the
1732 * new one. If `message' is NULL the old away message is removed.
1733 * The sender may freely free the memory of the `message'.
1736 void silc_client_set_away_message(SilcClient client,
1737 SilcClientConnection conn,
1741 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
1745 * typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1746 * SilcClientConnection conn,
1747 * SilcAuthMethod auth_meth,
1752 * Connection authentication method request callback. This is called
1753 * by the client library after it has received the authentication method
1754 * that the application requested by calling the function
1755 * silc_client_request_authentication_method.
1758 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
1759 SilcClientConnection conn,
1760 SilcAuthMethod auth_meth,
1763 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
1768 * silc_client_request_authentication_method(SilcClient client,
1769 * SilcClientConnection conn,
1770 * SilcConnectionAuthRequest
1776 * This function can be used to request the current authentication method
1777 * from the server. This may be called when connecting to the server
1778 * and the client library requests the authentication data from the
1779 * application. If the application does not know the current authentication
1780 * method it can request it from the server using this function.
1781 * The `callback' with `context' will be called after the server has
1782 * replied back with the current authentication method.
1786 silc_client_request_authentication_method(SilcClient client,
1787 SilcClientConnection conn,
1788 SilcConnectionAuthRequest callback,
1791 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
1795 * typedef enum { ... } SilcClientMonitorStatus;
1799 * File transmission session status types. These will indicate
1800 * the status of the file transmission session.
1805 SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT, /* In key agreemenet phase */
1806 SILC_CLIENT_FILE_MONITOR_SEND, /* Sending file */
1807 SILC_CLIENT_FILE_MONITOR_RECEIVE, /* Receiving file */
1808 SILC_CLIENT_FILE_MONITOR_GET,
1809 SILC_CLIENT_FILE_MONITOR_PUT,
1810 SILC_CLIENT_FILE_MONITOR_CLOSED, /* Session closed */
1811 SILC_CLIENT_FILE_MONITOR_ERROR, /* Error during session */
1812 } SilcClientMonitorStatus;
1815 /****d* silcclient/SilcClientAPI/SilcClientFileError
1819 * typedef enum { ... } SilcClientFileError;
1823 * File transmission error types. These types are returned by
1824 * some of the file transmission functions, and by the monitor
1825 * callback to indicate error.
1830 SILC_CLIENT_FILE_OK,
1831 SILC_CLIENT_FILE_ERROR,
1832 SILC_CLIENT_FILE_UNKNOWN_SESSION,
1833 SILC_CLIENT_FILE_ALREADY_STARTED,
1834 SILC_CLIENT_FILE_NO_SUCH_FILE,
1835 SILC_CLIENT_FILE_PERMISSION_DENIED,
1836 } SilcClientFileError;
1839 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
1843 * typedef void (*SilcClientFileMonitor)(SilcClient client,
1844 * SilcClientConnection conn,
1845 * SilcClientMonitorStatus status,
1846 * SilcClientFileError error,
1849 * SilcClientEntry client_entry,
1850 * uint32 session_id,
1851 * const char *filepath,
1856 * Monitor callback that is called during the file transmission to
1857 * monitor the transmission process. The `status' indicates the current
1858 * monitoring process. The `error' will indicate the error type
1859 * if `status' is SILC_CLIENT_FILE_MONITOR_ERROR. The `offset' is the
1860 * currently transmitted amount of total `filesize'. The `client_entry'
1861 * indicates the remote client, and the transmission session ID is the
1862 * `session_id'. The filename being transmitted is indicated by the
1866 typedef void (*SilcClientFileMonitor)(SilcClient client,
1867 SilcClientConnection conn,
1868 SilcClientMonitorStatus status,
1869 SilcClientFileError error,
1872 SilcClientEntry client_entry,
1874 const char *filepath,
1877 /****f* silcclient/SilcClientAPI/silc_client_file_send
1881 * uint32 silc_client_file_send(SilcClient client,
1882 * SilcClientConnection conn,
1883 * SilcClientFileMonitor monitor,
1884 * void *monitor_context,
1885 * const char *local_ip,
1886 * uint32 local_port,
1887 * SilcClientEntry client_entry,
1888 * const char *filepath);
1892 * Sends a file indicated by the `filepath' to the remote client
1893 * indicated by the `client_entry'. This will negotiate a secret key
1894 * with the remote client before actually starting the transmission of
1895 * the file. The `monitor' callback will be called to monitor the
1896 * transmission of the file.
1898 * This returns a file session ID for the file transmission. It can
1899 * be used to close the session (and abort the file transmission) by
1900 * calling the silc_client_file_close function. The session ID is
1901 * also returned in the `monitor' callback. This returns 0 if the
1902 * file indicated by the `filepath' is being transmitted to the remote
1903 * client indicated by the `client_entry', already.
1905 * If the `local_ip' is provided then this will try to bind the
1906 * listener for key exchange protocol to that IP. If `local_port' is
1907 * non-zero that port is used. If `local_ip' is NULL then this will
1908 * automatically attempt to bind it to local IP address of the machine.
1909 * If that fails then this does not bind to any address and port, and
1910 * assume that the remote client will provide the listener for the
1911 * key exchange protocol.
1913 * If error will occur during the file transfer process the error
1914 * status will be returned in the monitor callback. In this case
1915 * the application must call silc_client_file_close to close the
1919 uint32 silc_client_file_send(SilcClient client,
1920 SilcClientConnection conn,
1921 SilcClientFileMonitor monitor,
1922 void *monitor_context,
1923 const char *local_ip,
1925 SilcClientEntry client_entry,
1926 const char *filepath);
1928 /****f* silcclient/SilcClientAPI/silc_client_file_receive
1932 * SilcClientFileError
1933 * silc_client_file_receive(SilcClient client,
1934 * SilcClientConnection conn,
1935 * SilcClientFileMonitor monitor,
1936 * void *monitor_context,
1937 * uint32 session_id);
1941 * Receives a file from a client indicated by the `client_entry'. The
1942 * `session_id' indicates the file transmission session and it has been
1943 * received in the `ftp' client operation function. This will actually
1944 * perform the key agreement protocol with the remote client before
1945 * actually starting the file transmission. The `monitor' callback
1946 * will be called to monitor the transmission.
1948 * If error will occur during the file transfer process the error
1949 * status will be returned in the monitor callback. In this case
1950 * the application must call silc_client_file_close to close the
1955 silc_client_file_receive(SilcClient client,
1956 SilcClientConnection conn,
1957 SilcClientFileMonitor monitor,
1958 void *monitor_context,
1961 /****f* silcclient/SilcClientAPI/silc_client_file_close
1965 * SilcClientFileError silc_client_file_close(SilcClient client,
1966 * SilcClientConnection conn,
1967 * uint32 session_id);
1971 * Closes file transmission session indicated by the `session_id'.
1972 * If file transmission is being conducted it will be aborted
1973 * automatically. This function is also used to close the session
1974 * after successful file transmission. This function can be used
1975 * also to reject incoming file transmission request.
1978 SilcClientFileError silc_client_file_close(SilcClient client,
1979 SilcClientConnection conn,