5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2000 - 2002 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; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcclient/Client Library Interface
24 * This interface defines the SILC Client Library API for the application.
25 * The client operations are defined first. These are callback functions that
26 * the application MUST implement since the library may call the functions
27 * at any time. At the end of file is the API for the application that
28 * it can use from the library. This is the only file that the application
29 * may include from the SIlC Client Library.
31 * o SILC Client Operations
33 * These functions must be implemented by the application calling the SILC
34 * client library. The client library can call these functions at any time.
36 * To use this structure: define a static SilcClientOperations variable,
37 * fill it and pass its pointer to silc_client_alloc function.
39 * o SILC Client Library API
41 * This is the API that is published by the SILC Client Library for the
42 * applications. These functions are implemented in the SILC Client Library.
43 * Application may freely call these functions from the library.
45 * Please, refer to the README file in this directory for the directions
46 * of how to use the SILC Client Library.
59 /* General definitions */
61 /****s* silcclient/SilcClientAPI/SilcClient
65 * typedef struct SilcClientStruct { ... } *SilcClient
69 * This is the actual SILC Client structure which represents one
70 * SILC Client. It is allocated with the silc_client_alloc function
71 * and given as argument to all SILC Client Library functions. It
72 * is initialized with silc_client_init function, and freed with
73 * silc_client_free function.
77 struct SilcClientStruct {
79 * The following fields are set by application
81 char *nickname; /* Nickname, MAY be set by application */
82 char *username; /* Username, MUST be set by application */
83 char *hostname; /* hostname, MUST be set by application */
84 char *realname; /* Real name, MUST be set be application */
86 SilcPublicKey public_key; /* Public key of user, set by application */
87 SilcPrivateKey private_key; /* Private key of user, set by application */
88 SilcPKCS pkcs; /* PKCS allocated by application */
91 * The following fields are set by the library
94 /* Scheduler, set by library. Application may use this pointer. */
95 SilcSchedule schedule;
97 /* Random Number Generator. Application should use this as its primary
98 random number generator. */
101 /* Application specific user data pointer. Client library does not
102 touch this. This the context sent as argument to silc_client_alloc.
103 Application can use it freely. */
106 /* Generic hash context for application usage */
110 /* Internal data for client library. Application cannot access this
112 SilcClientInternal internal;
116 /****s* silcclient/SilcClientAPI/SilcClientConnection
120 * typedef struct SilcClientConnectionStruct { ... }
121 * *SilcClientConnection
125 * This structure represents a connection. When connection is created
126 * to server this is context is returned to the application in the
127 * "connected" client operation. It includes all the important
128 * data for the session, such as nickname, local and remote IDs, and
133 struct SilcClientConnectionStruct {
137 char *nickname; /* Current nickname */
138 SilcClientEntry local_entry; /* Own Client Entry */
139 SilcClientID *local_id; /* Current Client ID */
140 unsigned char *local_id_data; /* Current Client ID decoded */
141 SilcUInt32 local_id_data_len;
146 char *remote_host; /* Remote host name */
147 int remote_port; /* Remote port */
148 SilcServerID *remote_id; /* Remote Server ID */
149 unsigned char *remote_id_data; /* Remote Server ID decoded */
150 SilcUInt32 remote_id_data_len;
156 /* Current command identifier for a command that was sent last.
157 Application may get the value from this variable to find out the
158 command identifier for last command. */
159 SilcUInt16 cmd_ident;
161 /* User data context. Library does not touch this. Application may
162 freely set and use this pointer for its needs. */
165 /* Pointer back to the SilcClient. Application may use this. */
168 /* Current channel. Application may use and set this pointer if needed. */
169 SilcChannelEntry current_channel;
171 /* Socket connection object for this connection. Application may
172 use this if needed. The sock->user_data is back pointer to this
174 SilcSocketConnection sock;
176 /* Internal data for client library. Application cannot access this
178 SilcClientConnectionInternal internal;
182 /****s* silcclient/SilcClientAPI/SilcClientEntry
186 * typedef struct SilcClientEntryStruct { ... } *SilcClientEntry
190 * This structure represents a client or a user in the SILC network.
191 * The local user has this structure also and it can be accessed from
192 * SilcClientConnection structure. All other users in the SILC network
193 * that are accessed using the Client Library routines will have their
194 * own SilcClientEntry structure. For example, when finding users by
195 * their nickname the Client Library returns this structure back to
200 struct SilcClientEntryStruct {
201 /* General information */
202 char *nickname; /* nickname */
203 char *username; /* username */
204 char *hostname; /* hostname */
205 char *server; /* SILC server name */
206 char *realname; /* Realname (userinfo) */
208 /* Mode, ID and other information */
209 SilcUInt32 mode; /* User mode in SILC */
210 SilcClientID *id; /* The Client ID */
211 SilcDList attrs; /* Requested Attributes (maybe NULL) */
212 unsigned char *fingerprint; /* Fingerprint of client's public key */
213 SilcUInt32 fingerprint_len; /* Length of the fingerprint */
215 /* Private message keys */
216 SilcCipher send_key; /* Private message key for sending */
217 SilcCipher receive_key; /* Private message key for receiving */
218 unsigned char *key; /* Set only if appliation provided the
219 key material. NULL if the library
220 generated the key. */
221 SilcUInt32 key_len; /* Key length */
222 SilcClientKeyAgreement ke; /* Current key agreement context or NULL */
224 /* SilcClientEntry status information */
225 SilcEntryStatus status; /* Status mask */
226 SilcHashTable channels; /* All channels client has joined */
227 SilcUInt16 resolve_cmd_ident; /* Command identifier when resolving */
228 bool generated; /* TRUE if library generated `key' */
229 bool valid; /* FALSE if this entry is not valid */
233 /****s* silcclient/SilcClientAPI/SilcChannelEntry
237 * typedef struct SilcChannelEntryStruct { ... } *SilcChannelEntry
241 * This structure represents a channel in the SILC network. All
242 * channels that the client are aware of or have joined in will be
243 * represented as SilcChannelEntry. The structure includes information
248 struct SilcChannelEntryStruct {
249 /* General information */
250 char *channel_name; /* Channel name */
251 SilcChannelID *id; /* Channel ID */
252 SilcUInt32 mode; /* Channel mode */
254 /* All clients that has joined this channel */
255 SilcHashTable user_list;
258 SilcCipher channel_key; /* The channel key */
259 unsigned char *key; /* Raw key data */
260 SilcUInt32 key_len; /* Raw key data length */
261 unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]; /* Current IV */
262 SilcHmac hmac; /* Current HMAC */
264 /* Channel private keys */
265 SilcDList private_keys; /* List of private keys or NULL */
266 SilcChannelPrivateKey curr_key; /* Current private key */
268 /* SilcChannelEntry status information */
269 SilcCipher old_channel_key;
272 SilcUInt16 resolve_cmd_ident; /* Command identifier when
273 resolving this entry */
277 /****s* silcclient/SilcClientAPI/SilcServerEntry
281 * typedef struct SilcServerEntryStruct { ... } *SilcServerEntry
285 * This structure represents a server in the SILC network. All servers
286 * that the client is aware of and have for example resolved with
287 * SILC_COMMAND_INFO command have their on SilcServerEntry structure.
291 struct SilcServerEntryStruct {
292 /* General information */
293 char *server_name; /* Server name */
294 char *server_info; /* Server info */
295 SilcServerID *server_id; /* Server ID */
296 SilcUInt16 resolve_cmd_ident; /* Command identifier when
297 resolving this entry */
301 /****d* silcclient/SilcClientAPI/SilcKeyAgreementStatus
305 * typedef enum { ... } SilcKeyAgreementStatus;
309 * Key agreement status types indicating the status of the key
310 * agreement protocol. These types are returned to the application
311 * in the SilcKeyAgreementCallback callback function.
316 SILC_KEY_AGREEMENT_OK, /* Everything is Ok */
317 SILC_KEY_AGREEMENT_ERROR, /* Unknown error occurred */
318 SILC_KEY_AGREEMENT_FAILURE, /* The protocol failed */
319 SILC_KEY_AGREEMENT_TIMEOUT, /* The protocol timeout */
320 SILC_KEY_AGREEMENT_ABORTED, /* The protocol aborted */
321 SILC_KEY_AGREEMENT_ALREADY_STARTED, /* Already started */
322 SILC_KEY_AGREEMENT_SELF_DENIED, /* Negotiationg with itself denied */
323 } SilcKeyAgreementStatus;
326 /****f* silcclient/SilcClientAPI/SilcKeyAgreementCallback
330 * typedef void (*SilcKeyAgreementCallback)(SilcClient client,
331 * SilcClientConnection conn,
332 * SilcClientEntry client_entry,
333 * SilcKeyAgreementStatus status,
334 * SilcSKEKeyMaterial *key,
339 * Key agreement callback that is called after the key agreement protocol
340 * has been performed. This is called also if error occurred during the
341 * key agreement protocol. The `key' is the allocated key material and
342 * the caller is responsible of freeing it. The `key' is NULL if error
343 * has occurred. The application can freely use the `key' to whatever
344 * purpose it needs. See lib/silcske/silcske.h for the definition of
345 * the SilcSKEKeyMaterial structure.
348 typedef void (*SilcKeyAgreementCallback)(SilcClient client,
349 SilcClientConnection conn,
350 SilcClientEntry client_entry,
351 SilcKeyAgreementStatus status,
352 SilcSKEKeyMaterial *key,
355 /****s* silcclient/SilcClientAPI/SilcPrivateMessageKeys
359 * typedef struct { ... } SilcPrivateMessageKeys;
363 * Structure to hold the list of private message keys. The array of this
364 * structure is returned by the silc_client_list_private_message_keys
370 SilcClientEntry client_entry; /* The remote client entry */
371 char *cipher; /* The cipher name */
372 unsigned char *key; /* The original key, If the appliation
373 provided it. This is NULL if the
374 library generated the key or if
375 the SKE key material was used. */
376 SilcUInt32 key_len; /* The key length */
377 } *SilcPrivateMessageKeys;
380 /****s* silcclient/SilcClientAPI/SilcChannelPrivateKey
384 * typedef struct SilcChannelPrivateKeyStruct { ... }
385 * *SilcChannelPrivateKey;
389 * Structure to hold one channel private key. The array of this structure
390 * is returned by silc_client_list_channel_private_keys function.
394 struct SilcChannelPrivateKeyStruct {
395 char *name; /* Application given name */
396 SilcCipher cipher; /* The cipher and key */
397 SilcHmac hmac; /* The HMAC and hmac key */
398 unsigned char *key; /* The key data */
399 SilcUInt32 key_len; /* The key length */
403 /****f* silcclient/SilcClientAPI/SilcAskPassphrase
407 * typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
408 * SilcUInt32 passphrase_len,
413 * Ask passphrase callback. This is called by the application when the
414 * library calls `ask_passphrase' client operation. The callback delivers
415 * the passphrase to the library. The passphrases in SILC protocol
416 * MUST be in UTF-8 encoding, therefore the `passphrase' SHOULD be UTF-8
417 * encoded, and if it is not then library will attempt to encode it.
420 typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
421 SilcUInt32 passphrase_len,
424 /****f* silcclient/SilcClientAPI/SilcVerifyPublicKey
428 * typedef void (*SilcVerifyPublicKey)(bool success, void *context);
432 * Public key (or certificate) verification callback. This is called
433 * by the application to indicate that the public key verification was
434 * either success or failure.
437 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
439 /****f* silcclient/SilcClientAPI/SilcGetAuthMeth
443 * typedef void (*SilcGetAuthMeth)(bool success,
444 * SilcProtocolAuthMeth auth_meth,
445 * const unsigned char *auth_data,
446 * SilcUInt32 auth_data_len, void *context);
450 * Authentication method resolving callback. This is called by the
451 * application to return the resolved authentication method. The client
452 * library has called the get_auth_method client operation and given
453 * this function pointer as argument. The `success' will indicate whether
454 * the authentication method could be resolved. The `auth_meth' is the
455 * resolved authentication method. The `auth_data' and the `auth_data_len'
456 * are the resolved authentication data. The `context' is the libary's
457 * context sent to the get_auth_method client operation.
460 typedef void (*SilcGetAuthMeth)(bool success,
461 SilcProtocolAuthMeth auth_meth,
462 const unsigned char *auth_data,
463 SilcUInt32 auth_data_len, void *context);
465 /****d* silcclient/SilcClientAPI/SilcClientMessageType
469 * typedef enum { ... } SilcClientMessageType;
473 * Different message types for `say' client operation. The application
474 * may filter the message sent by the library according this type.
479 SILC_CLIENT_MESSAGE_INFO, /* Informational */
480 SILC_CLIENT_MESSAGE_WARNING, /* Warning */
481 SILC_CLIENT_MESSAGE_ERROR, /* Error */
482 SILC_CLIENT_MESSAGE_AUDIT, /* Auditable */
483 } SilcClientMessageType;
486 /****d* silcclient/SilcClientAPI/SilcClientConnectionStatus
490 * typedef enum { ... } SilcClientConnectionStatus
494 * This type is returned to the `connect' client operation to indicate
495 * the status of the created connection. It can indicated if it was
496 * successful or whether an error occurred.
501 SILC_CLIENT_CONN_SUCCESS, /* Successfully connected */
502 SILC_CLIENT_CONN_SUCCESS_RESUME, /* Successfully connected and
503 resumed old detached session */
504 SILC_CLIENT_CONN_ERROR, /* Error occurred during connecting */
505 } SilcClientConnectionStatus;
508 /****s* silcclient/SilcClientAPI/SilcClientOperations
512 * typedef struct { ... } SilcClientOperations;
516 * SILC Client Operations. These must be implemented by the application.
517 * The Client library may call any of these routines at any time. The
518 * routines are used to deliver certain information to the application
519 * or from the application to the client library.
524 /* Message sent to the application by library. `conn' associates the
525 message to a specific connection. `conn', however, may be NULL.
526 The `type' indicates the type of the message sent by the library.
527 The application can for example filter the message according the
529 void (*say)(SilcClient client, SilcClientConnection conn,
530 SilcClientMessageType type, char *msg, ...);
532 /* Message for a channel. The `sender' is the sender of the message
533 The `channel' is the channel. The `message' is the message. Note
534 that `message' maybe NULL. The `flags' indicates message flags
535 and it is used to determine how the message can be interpreted
536 (like it may tell the message is multimedia message). */
537 void (*channel_message)(SilcClient client, SilcClientConnection conn,
538 SilcClientEntry sender, SilcChannelEntry channel,
539 SilcMessageFlags flags,
540 const unsigned char *message,
541 SilcUInt32 message_len);
543 /* Private message to the client. The `sender' is the sender of the
544 message. The message is `message'and maybe NULL. The `flags'
545 indicates message flags and it is used to determine how the message
546 can be interpreted (like it may tell the message is multimedia
548 void (*private_message)(SilcClient client, SilcClientConnection conn,
549 SilcClientEntry sender, SilcMessageFlags flags,
550 const unsigned char *message,
551 SilcUInt32 message_len);
553 /* Notify message to the client. The notify arguments are sent in the
554 same order as servers sends them. The arguments are same as received
555 from the server except for ID's. If ID is received application receives
556 the corresponding entry to the ID. For example, if Client ID is received
557 application receives SilcClientEntry. Also, if the notify type is
558 for channel the channel entry is sent to application (even if server
559 does not send it because client library gets the channel entry from
560 the Channel ID in the packet's header). */
561 void (*notify)(SilcClient client, SilcClientConnection conn,
562 SilcNotifyType type, ...);
564 /* Command handler. This function is called always in the command function.
565 If error occurs it will be called as well. `conn' is the associated
566 client connection. `cmd_context' is the command context that was
567 originally sent to the command. `success' is FALSE if error occurred
568 during command. `command' is the command being processed. It must be
569 noted that this is not reply from server. This is merely called just
570 after application has called the command. Just to tell application
571 that the command really was processed. */
572 void (*command)(SilcClient client, SilcClientConnection conn,
573 SilcClientCommandContext cmd_context, bool success,
574 SilcCommand command, SilcStatus status);
576 /* Command reply handler. This function is called always in the command reply
577 function. If error occurs it will be called as well. Normal scenario
578 is that it will be called after the received command data has been parsed
579 and processed. The function is used to pass the received command data to
582 `conn' is the associated client connection. `cmd_payload' is the command
583 payload data received from server and it can be ignored. It is provided
584 if the application would like to re-parse the received command data,
585 however, it must be noted that the data is parsed already by the library
586 thus the payload can be ignored. `success' is FALSE if error occurred.
587 In this case arguments are not sent to the application. The `status' is
588 the command reply status server returned. The `command' is the command
589 reply being processed. The function has variable argument list and each
590 command defines the number and type of arguments it passes to the
591 application (on error they are not sent).
593 The arguments are sent in the same order as servers sends them. The
594 arguments are same as received from the server except for ID's. If
595 ID is received application receives the corresponding entry to the
596 ID. For example, if Client ID is receives application receives
598 void (*command_reply)(SilcClient client, SilcClientConnection conn,
599 SilcCommandPayload cmd_payload, bool success,
600 SilcCommand command, SilcStatus status, ...);
602 /* Called to indicate that connection was either successfully established
603 or connecting failed. This is also the first time application receives
604 the SilcClientConnection object which it should save somewhere.
605 The `status' indicated whether the connection were successful. If it
606 is error value the application must always call the function
607 silc_client_close_connection. */
608 void (*connected)(SilcClient client, SilcClientConnection conn,
609 SilcClientConnectionStatus status);
611 /* Called to indicate that connection was disconnected to the server.
612 The `status' may tell the reason of the disconnection, and if the
613 `message' is non-NULL it may include the disconnection message
614 received from server. */
615 void (*disconnected)(SilcClient client, SilcClientConnection conn,
616 SilcStatus status, const char *message);
618 /* Find authentication method and authentication data by hostname and
619 port. The hostname may be IP address as well. When the authentication
620 method has been resolved the `completion' callback with the found
621 authentication method and authentication data is called. The `conn'
623 void (*get_auth_method)(SilcClient client, SilcClientConnection conn,
624 char *hostname, SilcUInt16 port,
625 SilcGetAuthMeth completion, void *context);
627 /* Verifies received public key. The `conn_type' indicates which entity
628 (server, client etc.) has sent the public key. If user decides to trust
629 the application may save the key as trusted public key for later
630 use. The `completion' must be called after the public key has been
632 void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
633 SilcSocketType conn_type, unsigned char *pk,
634 SilcUInt32 pk_len, SilcSKEPKType pk_type,
635 SilcVerifyPublicKey completion, void *context);
637 /* Ask (interact, that is) a passphrase from user. The passphrase is
638 returned to the library by calling the `completion' callback with
639 the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
640 if not then the library will attempt to encode. */
641 void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
642 SilcAskPassphrase completion, void *context);
644 /* Notifies application that failure packet was received. This is called
645 if there is some protocol active in the client. The `protocol' is the
646 protocol context. The `failure' is opaque pointer to the failure
647 indication. Note, that the `failure' is protocol dependant and
648 application must explicitly cast it to correct type. Usually `failure'
649 is 32 bit failure type (see protocol specs for all protocol failure
651 void (*failure)(SilcClient client, SilcClientConnection conn,
652 SilcProtocol protocol, void *failure);
654 /* Asks whether the user would like to perform the key agreement protocol.
655 This is called after we have received an key agreement packet or an
656 reply to our key agreement packet. This returns TRUE if the user wants
657 the library to perform the key agreement protocol and FALSE if it is not
658 desired (application may start it later by calling the function
659 silc_client_perform_key_agreement). If TRUE is returned also the
660 `completion' and `context' arguments must be set by the application. */
661 bool (*key_agreement)(SilcClient client, SilcClientConnection conn,
662 SilcClientEntry client_entry, const char *hostname,
663 SilcUInt16 port, SilcKeyAgreementCallback *completion,
666 /* Notifies application that file transfer protocol session is being
667 requested by the remote client indicated by the `client_entry' from
668 the `hostname' and `port'. The `session_id' is the file transfer
669 session and it can be used to either accept or reject the file
670 transfer request, by calling the silc_client_file_receive or
671 silc_client_file_close, respectively. */
672 void (*ftp)(SilcClient client, SilcClientConnection conn,
673 SilcClientEntry client_entry, SilcUInt32 session_id,
674 const char *hostname, SilcUInt16 port);
676 /* Delivers SILC session detachment data indicated by `detach_data' to the
677 application. If application has issued SILC_COMMAND_DETACH command
678 the client session in the SILC network is not quit. The client remains
679 in the network but is detached. The detachment data may be used later
680 to resume the session in the SILC Network. The appliation is
681 responsible of saving the `detach_data', to for example in a file.
683 The detachment data can be given as argument to the functions
684 silc_client_connect_to_server, or silc_client_add_connection when
685 creating connection to remote server, inside SilcClientConnectionParams
686 structure. If it is provided the client library will attempt to resume
687 the session in the network. After the connection is created
688 successfully, the application is responsible of setting the user
689 interface for user into the same state it was before detaching (showing
690 same channels, channel modes, etc). It can do this by fetching the
691 information (like joined channels) from the client library. */
692 void (*detach)(SilcClient client, SilcClientConnection conn,
693 const unsigned char *detach_data,
694 SilcUInt32 detach_data_len);
695 } SilcClientOperations;
698 /****f* silcclient/SilcClientAPI/SilcNicknameFormatParse
702 * typedef void (*SilcNicknameFormatParse)(const char *nickname,
703 * char **ret_nickname);
707 * A callback function provided by the application for the library in
708 * SilcClientParams structure. This function parses the formatted
709 * nickname string `nickname' and returns the true nickname to the
710 * `ret_nickname' pointer. The library can call this function at
714 typedef void (*SilcNicknameFormatParse)(const char *nickname,
715 char **ret_nickname);
717 /****s* silcclient/SilcClientAPI/SilcClientParams
721 * typedef struct { ... } SilcClientParams;
725 * Client parameters. This can be filled with proper values and
726 * given as argument to the silc_client_alloc function. The structure
727 * hold various parameters which affects the function of the client.
732 /* Number of maximum tasks the client library's scheduler can handle.
733 If set to zero, the default value will be used (200). For WIN32
734 systems this should be set to 64 as it is the hard limit dictated
738 /* Rekey timeout in seconds. The client will perform rekey in this
739 time interval. If set to zero, the default value will be used. */
740 unsigned int rekey_secs;
742 /* Connection authentication method request timeout. If server does not
743 reply back the current authentication method when we've requested it
744 in this time interval we'll assume the reply will not come at all.
745 If set to zero, the default value (2 seconds) will be used. */
746 unsigned int connauth_request_secs;
748 /* Nickname format string. This can be used to order the client library
749 to save the nicknames in the library in a certain format. Since
750 nicknames are not unique in SILC it is possible to have multiple same
751 nicknames. Using this format string it is possible to order the library
752 to separate the multiple same nicknames from each other. The format
753 types are defined below and they can appear in any order in the format
754 string. If this is NULL then default format is used which is the
755 default nickname without anything else. The string MUST be NULL
758 Following format types are available:
760 %n nickname - the real nickname returned by the server (mandatory)
761 %h hostname - the stripped hostname of the client
762 %H full hostname - the full hostname of the client
763 %s server name - the server name the client is connected
764 %S full server - the full server name the client is connected
765 %a number - ascending number in case there are several
766 same nicknames (fe. nick@host and nick@host2)
768 Example format strings: "%n@%h%a" (fe. nick@host, nick@host2)
769 "%a!%n@%s" (fe. nick@server, 2!nick@server)
770 "%n@%H" (fe. nick@host.domain.com)
772 By default this format is employed to the nicknames by the libary
773 only when there appears multiple same nicknames. If the library has
774 only one nickname cached the nickname is saved as is and without the
775 defined format. If you want always to save the nickname in the defined
776 format set the boolean field `nickname_force_format' to value TRUE.
778 char nickname_format[32];
780 /* If this is set to TRUE then the `nickname_format' is employed to all
781 saved nicknames even if there are no multiple same nicknames in the
782 cache. By default this is FALSE, which means that the `nickname_format'
783 is employed only if the library will receive a nickname that is
784 already saved in the cache. It is recommended to leave this to FALSE
786 bool nickname_force_format;
788 /* A callback function provided by the application for the library to
789 parse the nickname from the formatted nickname string. Even though
790 the libary formats the nicknames the application knows generally the
791 format better so this function should be provided for the library
792 if the application sets the `nickname_format' field. The library
793 will call this to get the true nickname from the provided formatted
794 nickname string whenever it needs the true nickname. */
795 SilcNicknameFormatParse nickname_parse;
797 /* If this is set to TRUE then the client will ignore all incoming
798 Requested Attributes queries and does not reply anything back. This
799 usually leads into situation where server does not anymore send
800 the queries after seeing that client does not reply anything back.
801 If your application does not support Requested Attributes or you do
802 not want to use them set this to TRUE. See SilcAttribute and
803 silc_client_attribute_add for more information on attributes. */
804 bool ignore_requested_attributes;
810 /* Initialization functions (client.c) */
812 /****f* silcclient/SilcClientAPI/silc_client_alloc
816 * SilcClient silc_client_alloc(SilcClientOperations *ops,
817 * SilcClientParams *params,
819 * const char *silc_version);
823 * Allocates new client object. This has to be done before client may
824 * work. After calling this one must call silc_client_init to initialize
825 * the client. The `application' is application specific user data pointer
826 * and caller must free it. The `silc_version' is the application version
827 * that will be used to compare against remote host's (usually a server)
828 * version string. The `application' context is accessible by the
829 * application by client->application, client being SilcClient.
832 SilcClient silc_client_alloc(SilcClientOperations *ops,
833 SilcClientParams *params,
835 const char *version_string);
837 /****f* silcclient/SilcClientAPI/silc_client_free
841 * void silc_client_free(SilcClient client);
845 * Frees client object and its internals. The execution of the client
846 * should be stopped with silc_client_stop function before calling
850 void silc_client_free(SilcClient client);
852 /****f* silcclient/SilcClientAPI/silc_client_init
856 * int silc_client_init(SilcClient client);
860 * Initializes the client. This makes all the necessary steps to make
861 * the client ready to be run. One must call silc_client_run to run the
862 * client. Returns FALSE if error occurred, TRUE otherwise.
865 int silc_client_init(SilcClient client);
867 /****f* silcclient/SilcClientAPI/silc_client_run
871 * void silc_client_run(SilcClient client);
875 * Runs the client. This starts the scheduler from the utility library.
876 * When this functions returns the execution of the appliation is over.
877 * The client must be initialized before calling this.
880 void silc_client_run(SilcClient client);
882 /****f* silcclient/SilcClientAPI/silc_client_run_one
886 * void silc_client_run_one(SilcClient client);
890 * Runs the client and returns immeadiately. This function is used when
891 * the SILC Client object indicated by the `client' is run under some
892 * other scheduler, or event loop or main loop. On GUI applications,
893 * for example this may be desired to used to run the client under the
894 * GUI application's main loop. Typically the GUI application would
895 * register an idle task that calls this function multiple times in
896 * a second to quickly process the SILC specific data.
899 void silc_client_run_one(SilcClient client);
901 /****f* silcclient/SilcClientAPI/silc_client_stop
905 * void silc_client_stop(SilcClient client);
909 * Stops the client. This is called to stop the client and thus to stop
910 * the program. The client context must be freed with the silc_client_free
914 void silc_client_stop(SilcClient client);
917 /* Connecting functions (client.c) */
919 /****s* silcclient/SilcClientAPI/SilcClientConnectionParams
923 * typedef struct { ... } SilcClientConnectionParams;
927 * Client connection parameters. This can be filled by the application
928 * and given as argument to silc_client_connect_to_server or to
929 * silc_client_add_connection.
934 /* The SILC session detachment data that was returned by `detach' client
935 operation when the application detached from the network. Application
936 is responsible of saving the data and giving it as argument here
937 for resuming the session in the SILC network.
939 If this is provided here the client library will attempt to resume
940 the session in the network. After the connection is created
941 successfully, the application is responsible of setting the user
942 interface for user into the same state it was before detaching (showing
943 same channels, channel modes, etc). It can do this by fetching the
944 information (like joined channels) from the client library. */
945 unsigned char *detach_data;
946 SilcUInt32 detach_data_len;
948 } SilcClientConnectionParams;
951 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
955 * int silc_client_connect_to_server(SilcClient client,
956 * SilcClientConnectionParams *params,
957 * int port, char *host, void *context);
961 * Connects to remote server. This is the main routine used to connect
962 * to SILC server. Returns -1 on error and the created socket otherwise.
963 * The `context' is user context that is saved into the SilcClientConnection
964 * that is created after the connection is created. Note that application
965 * may handle the connecting process outside the library. If this is the
966 * case then this function is not used at all. When the connecting is
967 * done the `connect' client operation is called, and the `context' is
968 * accessible with conn->context, conn being SilcClientConnection.
969 * If the `params' is provided they are used by the routine.
972 int silc_client_connect_to_server(SilcClient client,
973 SilcClientConnectionParams *params,
974 int port, char *host, void *context);
976 /****f* silcclient/SilcClientAPI/silc_client_add_connection
981 * SilcClientConnection
982 * silc_client_add_connection(SilcClient client,
983 * SilcClientConnectionParams *params,
984 * char *hostname, int port, void *context);
988 * Allocates and adds new connection to the client. This adds the allocated
989 * connection to the connection table and returns a pointer to it. A client
990 * can have multiple connections to multiple servers. Every connection must
991 * be added to the client using this function. User data `context' may
992 * be sent as argument. If the `params' is provided they are used by
997 * This function is normally used only if the application performed
998 * the connecting outside the library, and did not called the
999 * silc_client_connect_to_server function at all. The library
1000 * however may use this internally.
1003 SilcClientConnection
1004 silc_client_add_connection(SilcClient client,
1005 SilcClientConnectionParams *params,
1006 char *hostname, int port, void *context);
1008 /****f* silcclient/SilcClientAPI/silc_client_del_connection
1012 * void silc_client_del_connection(SilcClient client,
1013 * SilcClientConnection conn);
1017 * Removes connection from client. Frees all memory. The library
1018 * call this function automatically for all connection contexts.
1019 * The application however may free the connection contexts it has
1023 void silc_client_del_connection(SilcClient client, SilcClientConnection conn);
1025 /****f* silcclient/SilcClientAPI/silc_client_add_socket
1029 * void silc_client_add_socket(SilcClient client,
1030 * SilcSocketConnection sock);
1034 * Adds listener socket to the listener sockets table. This function is
1035 * used to add socket objects that are listeners to the client. This should
1036 * not be used to add other connection objects.
1039 void silc_client_add_socket(SilcClient client, SilcSocketConnection sock);
1041 /****f* silcclient/SilcClientAPI/silc_client_del_socket
1045 * void silc_client_del_socket(SilcClient client,
1046 * SilcSocketConnection sock);
1050 * Deletes listener socket from the listener sockets table. If the
1051 * application has added a socket with silc_client_add_socket it must
1052 * also free it using this function.
1055 void silc_client_del_socket(SilcClient client, SilcSocketConnection sock);
1057 /****f* silcclient/SilcClientAPI/silc_client_start_key_exchange
1061 * void silc_client_start_key_exchange(SilcClient client,
1062 * SilcClientConnection conn,
1067 * Start SILC Key Exchange (SKE) protocol to negotiate shared secret
1068 * key material between client and server. This function can be called
1069 * directly if application is performing its own connecting and does not
1070 * use the connecting provided by this library. This function is normally
1071 * used only if the application performed the connecting outside the
1072 * library. The library however may use this internally. After the
1073 * key exchange is performed the `connect' client operation is called.
1076 void silc_client_start_key_exchange(SilcClient client,
1077 SilcClientConnection conn,
1080 /****f* silcclient/SilcClientAPI/silc_client_close_connection
1084 * void silc_client_close_connection(SilcClient client,
1085 * SilcClientConnection conn);
1089 * Closes connection to remote end. Free's all allocated data except
1090 * for some information such as nickname etc. that are valid at all time.
1093 void silc_client_close_connection(SilcClient client,
1094 SilcClientConnection conn);
1097 /* Message sending functions (client_channel.c and client_prvmsg.c) */
1099 /****f* silcclient/SilcClientAPI/silc_client_send_channel_message
1103 * void silc_client_send_channel_message(SilcClient client,
1104 * SilcClientConnection conn,
1105 * SilcChannelEntry channel,
1106 * SilcChannelPrivateKey key,
1107 * SilcMessageFlags flags,
1108 * unsigned char *data,
1109 * SilcUInt32 data_len,
1114 * Sends packet to the `channel'. Packet to channel is always encrypted
1115 * differently from "normal" packets. SILC header of the packet is
1116 * encrypted with the next receiver's key and the rest of the packet is
1117 * encrypted with the channel specific key. Padding and HMAC is computed
1118 * with the next receiver's key. The `data' is the channel message. If
1119 * the `force_send' is TRUE then the packet is sent immediately.
1121 * If `key' is provided then that private key is used to encrypt the
1122 * channel message. If it is not provided, private keys has not been
1123 * set at all, the normal channel key is used automatically. If private
1124 * keys are set then the first key (the key that was added first as
1125 * private key) is used.
1128 void silc_client_send_channel_message(SilcClient client,
1129 SilcClientConnection conn,
1130 SilcChannelEntry channel,
1131 SilcChannelPrivateKey key,
1132 SilcMessageFlags flags,
1133 unsigned char *data,
1134 SilcUInt32 data_len,
1137 /****f* silcclient/SilcClientAPI/silc_client_send_private_message
1141 * void silc_client_send_private_message(SilcClient client,
1142 * SilcClientConnection conn,
1143 * SilcClientEntry client_entry,
1144 * SilcMessageFlags flags,
1145 * unsigned char *data,
1146 * SilcUInt32 data_len,
1151 * Sends private message to remote client. If private message key has
1152 * not been set with this client then the message will be encrypted using
1153 * normal session keys. Private messages are special packets in SILC
1154 * network hence we need this own function for them. This is similar
1155 * to silc_client_packet_send_to_channel except that we send private
1156 * message. The `data' is the private message. If the `force_send' is
1157 * TRUE the packet is sent immediately.
1160 void silc_client_send_private_message(SilcClient client,
1161 SilcClientConnection conn,
1162 SilcClientEntry client_entry,
1163 SilcMessageFlags flags,
1164 unsigned char *data,
1165 SilcUInt32 data_len,
1169 /* Client and Channel entry retrieval (idlist.c) */
1171 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
1175 * typedef void (*SilcGetClientCallback)(SilcClient client,
1176 * SilcClientConnection conn,
1177 * SilcClientEntry *clients,
1178 * SilcUInt32 clients_count,
1183 * Callback function given to the silc_client_get_client function. The
1184 * found entries are allocated into the `clients' array. The array must
1185 * not be freed by the receiver, the library will free it later. If the
1186 * `clients' is NULL, no such clients exist in the SILC Network.
1189 typedef void (*SilcGetClientCallback)(SilcClient client,
1190 SilcClientConnection conn,
1191 SilcClientEntry *clients,
1192 SilcUInt32 clients_count,
1195 /****f* silcclient/SilcClientAPI/silc_client_get_clients
1199 * void silc_client_get_clients(SilcClient client,
1200 * SilcClientConnection conn,
1201 * const char *nickname,
1202 * const char *server,
1203 * SilcGetClientCallback completion,
1208 * Finds client entry or entries by the `nickname' and `server'. The
1209 * completion callback will be called when the client entries has been
1210 * found. After the server returns the client information it is cached
1211 * and can be accesses locally at a later time.
1215 * NOTE: This function is always asynchronous and resolves the client
1216 * information from the server. Thus, if you already know the client
1217 * information then use the silc_client_get_client_by_id function to
1218 * get the client entry since this function may be very slow and should
1219 * be used only to initially get the client entries.
1222 void silc_client_get_clients(SilcClient client,
1223 SilcClientConnection conn,
1224 const char *nickname,
1226 SilcGetClientCallback completion,
1229 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
1233 * SilcClientEntry *silc_client_get_clients_local(SilcClient client,
1234 * SilcClientConnection conn,
1235 * const char *nickname,
1236 * const char *format,
1237 * SilcUInt32 *clients_count);
1241 * Same as silc_client_get_clients function but does not resolve anything
1242 * from the server. This checks local cache and returns all matching
1243 * clients from the local cache. If none was found this returns NULL.
1244 * The `nickname' is the real nickname of the client, and the `format'
1245 * is the formatted nickname to find exact match from multiple found
1246 * entries. The format must be same as given in the SilcClientParams
1247 * structure to the client library. If the `format' is NULL all found
1248 * clients by `nickname' are returned. The caller must return the
1252 SilcClientEntry *silc_client_get_clients_local(SilcClient client,
1253 SilcClientConnection conn,
1254 const char *nickname,
1256 SilcUInt32 *clients_count);
1258 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
1262 * void silc_client_get_clients_by_list(SilcClient client,
1263 * SilcClientConnection conn,
1264 * SilcUInt32 list_count,
1265 * SilcBuffer client_id_list,
1266 * SilcGetClientCallback completion,
1271 * Gets client entries by the list of client ID's `client_id_list'. This
1272 * always resolves those client ID's it does not know yet from the server
1273 * so this function might take a while. The `client_id_list' is a list
1274 * of ID Payloads added one after other. JOIN command reply and USERS
1275 * command reply for example returns this sort of list. The `completion'
1276 * will be called after the entries are available. When server returns
1277 * the client information it will be cached and can be accessed locally
1281 void silc_client_get_clients_by_list(SilcClient client,
1282 SilcClientConnection conn,
1283 SilcUInt32 list_count,
1284 SilcBuffer client_id_list,
1285 SilcGetClientCallback completion,
1288 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
1292 * SilcClientEntry silc_client_get_client_by_id(SilcClient client,
1293 * SilcClientConnection conn,
1294 * SilcClientID *client_id);
1298 * Find entry for client by the client's ID. Returns the entry or NULL
1299 * if the entry was not found. This checks the local cache and does
1300 * not resolve anything from server.
1303 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
1304 SilcClientConnection conn,
1305 SilcClientID *client_id);
1307 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
1312 * silc_client_get_client_by_id_resolve(SilcClient client,
1313 * SilcClientConnection conn,
1314 * SilcClientID *client_id,
1315 * SilcBuffer attributes,
1316 * SilcGetClientCallback completion,
1321 * Same as silc_client_get_client_by_id but will always resolve the
1322 * information from the server. Use this only if you know that you
1323 * do not have the entry and the only thing you know about the client
1324 * is its ID. When server returns the client information it will be
1325 * cache and can be accessed locally at a later time.
1327 * If the `attributes' is non-NULL then the buffer includes Requested
1328 * Attributes which can be used to fetch very detailed information
1329 * about the user. If it is NULL then only normal WHOIS query is
1330 * made (for more information about attributes see SilcAttribute).
1331 * Caller may create the `attributes' with silc_client_attributes_request
1335 void silc_client_get_client_by_id_resolve(SilcClient client,
1336 SilcClientConnection conn,
1337 SilcClientID *client_id,
1338 SilcBuffer attributes,
1339 SilcGetClientCallback completion,
1342 /****f* silcclient/SilcClientAPI/silc_client_del_client
1346 * bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
1347 * SilcClientEntry client_entry)
1351 * Removes client from local cache by the client entry indicated by
1352 * the `client_entry'. Returns TRUE if the deletion were successful.
1355 bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
1356 SilcClientEntry client_entry);
1358 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
1362 * typedef void (*SilcGetChannelCallback)(SilcClient client,
1363 * SilcClientConnection conn,
1364 * SilcChannelEntry *channels,
1365 * SilcUInt32 channels_count,
1370 * Callback function given to the silc_client_get_channel_* functions.
1371 * The found entries are allocated into the `channels' array. The array
1372 * must not be freed by the receiver, the library will free it later.
1373 * If the `channel' is NULL, no such channel exist in the SILC Network.
1376 typedef void (*SilcGetChannelCallback)(SilcClient client,
1377 SilcClientConnection conn,
1378 SilcChannelEntry *channels,
1379 SilcUInt32 channels_count,
1382 /****f* silcclient/SilcClientAPI/silc_client_get_channel
1386 * SilcChannelEntry silc_client_get_channel(SilcClient client,
1387 * SilcClientConnection conn,
1392 * Finds entry for channel by the channel name. Returns the entry or NULL
1393 * if the entry was not found. It is found only if the client is joined
1397 SilcChannelEntry silc_client_get_channel(SilcClient client,
1398 SilcClientConnection conn,
1401 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id
1406 * silc_client_get_channel_by_id(SilcClient client,
1407 * SilcClientConnection conn,
1408 * SilcChannelID *channel_id);
1412 * Finds channel entry by the channel name. Returns the entry or NULL
1413 * if it was not found.
1416 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
1417 SilcClientConnection conn,
1418 SilcChannelID *channel_id);
1420 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
1425 * silc_client_get_channel_by_id_resolve(SilcClient client,
1426 * SilcClientConnection conn,
1427 * SilcChannelID *channel_id,
1428 * SilcGetClientCallback completion,
1433 * Resolves the channel information (its name mainly) from the server
1434 * by the `channel_id'. Use this only if you know that you do not have
1435 * the entry cached locally.
1438 void silc_client_get_channel_by_id_resolve(SilcClient client,
1439 SilcClientConnection conn,
1440 SilcChannelID *channel_id,
1441 SilcGetChannelCallback completion,
1444 /****f* silcclient/SilcClientAPI/silc_client_del_channel
1448 * bool silc_client_del_channel(SilcClient client,
1449 * SilcClientConnection conn,
1450 * SilcChannelEntry channel)
1454 * Removes channel from local cache by the channel entry indicated by
1455 * the `channel'. Returns TRUE if the deletion were successful.
1458 bool silc_client_del_channel(SilcClient client, SilcClientConnection conn,
1459 SilcChannelEntry channel);
1461 /****f* silcclient/SilcClientAPI/silc_client_get_server
1465 * SilcServerEntry silc_client_get_server(SilcClient client,
1466 * SilcClientConnection conn,
1467 * char *server_name)
1471 * Finds entry for server by the server name. Returns the entry or NULL
1472 * if the entry was not found.
1475 SilcServerEntry silc_client_get_server(SilcClient client,
1476 SilcClientConnection conn,
1479 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
1483 * SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1484 * SilcClientConnection conn,
1485 * SilcServerID *server_id);
1489 * Finds entry for server by the server ID. Returns the entry or NULL
1490 * if the entry was not found.
1493 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
1494 SilcClientConnection conn,
1495 SilcServerID *server_id);
1497 /****f* silcclient/SilcClientAPI/silc_client_del_server
1501 * bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1502 * SilcServerEntry server);
1506 * Removes server from local cache by the server entry indicated by
1507 * the `server'. Returns TRUE if the deletion were successful.
1510 bool silc_client_del_server(SilcClient client, SilcClientConnection conn,
1511 SilcServerEntry server);
1513 /****f* silcclient/SilcClientAPI/silc_client_on_channel
1517 * SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1518 * SilcClientEntry client_entry);
1522 * Returns the ChannelUser entry if the `client_entry' is joined on the
1523 * channel indicated by the `channel'. NULL if client is not joined on
1527 SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
1528 SilcClientEntry client_entry);
1530 /* Command management (command.c) */
1532 /****f* silcclient/SilcClientAPI/silc_client_command_call
1536 * void silc_client_command_call(SilcClient client,
1537 * SilcClientConnection conn,
1538 * const char *command_line, ...);
1542 * Calls and executes the command indicated by the `command_name'.
1543 * The `command_line' is a string which includes the command's name and
1544 * its arguments separated with whitespaces (' '). If `command_line'
1545 * is non-NULL then all variable arguments are ignored by default.
1547 * If `command_line' is NULL, then the variable arguments define the
1548 * command's name and its arguments. The first variable argument must
1549 * be the command name. The variable argument list must be terminated
1552 * Returns FALSE if the command is not known and TRUE after command.
1553 * execution. The "command" client operation is called when the
1554 * command is executed to indicate whether the command executed
1555 * successfully or not.
1557 * The "command_reply" client operation will be called when reply is
1558 * received from the server to the command. Application may also use
1559 * the silc_client_command_pending to attach to the command reply.
1560 * The command identifier for silc_client_command_pending function after
1561 * this function call is conn->cmd_ident, which application may use.
1565 * silc_client_command_call(client, conn, NULL, "PING", "silc.silcnet.org",
1567 * silc_client_command_call(client, conn, "PING silc.silcnet.org");
1570 bool silc_client_command_call(SilcClient client,
1571 SilcClientConnection conn,
1572 const char *command_line, ...);
1574 /****f* silcclient/SilcClientAPI/silc_client_command_send
1578 * void silc_client_command_send(SilcClient client,
1579 * SilcClientConnection conn,
1580 * SilcCommand command, SilcUInt16 ident,
1581 * SilcUInt32 argc, ...);
1585 * Generic function to send any command. The arguments must be sent already
1586 * encoded into correct form and in correct order. If application wants
1587 * to perform the commands by itself, it can do so and send the data
1588 * directly to the server using this function. If application is using
1589 * the silc_client_command_call, this function is usually not used.
1590 * Note that this overriders the Client Librarys commands and sends
1591 * the command packet directly to server.
1593 * The variable arguments are a pair of { type, data, data_length },
1594 * and the `argc' is the number of these pairs.
1598 * silc_client_command_send(client, conn, SILC_COMMAND_WHOIS, 0, 1,
1599 * 1, nickname, strlen(nickname));
1602 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
1603 SilcCommand command, SilcUInt16 ident,
1604 SilcUInt32 argc, ...);
1606 /****f* silcclient/SilcClientAPI/silc_client_command_pending
1610 * void silc_client_command_pending(SilcClientConnection conn,
1611 * SilcCommand reply_cmd,
1613 * SilcCommandCb callback,
1618 * This function can be used to add pending command callback to be
1619 * called when an command reply is received to an earlier sent command.
1620 * The `reply_cmd' is the command that must be received in order for
1621 * the pending command callback indicated by `callback' to be called.
1623 * The `ident' is a command identifier which was set for the earlier
1624 * sent command. The command reply will include the same identifier
1625 * and pending command callback will be called when the reply is
1626 * received with the same command identifier. It is possible to
1627 * add multiple pending command callbacks for same command and for
1630 * Application may use this function to add its own command reply
1631 * handlers if it wishes not to use the standard `command_reply'
1632 * client operation. However, note that the pending command callback
1633 * does not deliver parsed command reply, but application must parse
1636 * Note also that the application is notified about the received command
1637 * reply through the `command_reply' client operation before calling
1638 * the `callback` pending command callback. That is the normal
1639 * command reply handling, and is called regardless whether pending
1640 * command callbacks are used or not.
1642 * Commands that application calls with silc_client_command_call
1643 * will use a command identifier from conn->cmd_ident variable. After
1644 * calling the silc_client_command_call, the conn->cmd_ident includes
1645 * the command identifier that was used for the command sending.
1649 * silc_client_command_call(client, conn, "PING silc.silcnet.org");
1650 * silc_client_command_pending(conn, SILC_COMMAND_PING, conn->cmd_ident,
1651 * my_ping_handler, my_ping_context);
1654 void silc_client_command_pending(SilcClientConnection conn,
1655 SilcCommand reply_cmd,
1657 SilcCommandCb callback,
1661 /* Private Message key management (client_prvmsg.c) */
1663 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
1667 * int silc_client_add_private_message_key(SilcClient client,
1668 * SilcClientConnection conn,
1669 * SilcClientEntry client_entry,
1671 * unsigned char *key,
1672 * SilcUInt32 key_len,
1673 * bool generate_key,
1678 * Adds private message key to the client library. The key will be used to
1679 * encrypt all private message between the client and the remote client
1680 * indicated by the `client_entry'. If the `key' is NULL and the boolean
1681 * value `generate_key' is TRUE the library will generate random key.
1682 * The `key' maybe for example pre-shared-key, passphrase or similar.
1683 * The `cipher' MAY be provided but SHOULD be NULL to assure that the
1684 * requirements of the SILC protocol are met. The API, however, allows
1685 * to allocate any cipher.
1687 * If `responder' is TRUE then the sending and receiving keys will be
1688 * set according the client being the receiver of the private key. If
1689 * FALSE the client is being the sender (or negotiator) of the private
1692 * It is not necessary to set key for normal private message usage. If the
1693 * key is not set then the private messages are encrypted using normal
1694 * session keys. Setting the private key, however, increases the security.
1696 * Returns FALSE if the key is already set for the `client_entry', TRUE
1700 int silc_client_add_private_message_key(SilcClient client,
1701 SilcClientConnection conn,
1702 SilcClientEntry client_entry,
1709 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
1713 * int silc_client_add_private_message_key_ske(SilcClient client,
1714 * SilcClientConnection conn,
1715 * SilcClientEntry client_entry,
1717 * SilcSKEKeyMaterial *key);
1721 * Same as silc_client_add_private_message_key but takes the key material
1722 * from the SKE key material structure. This structure is received if
1723 * the application uses the silc_client_send_key_agreement to negotiate
1724 * the key material. The `cipher' SHOULD be provided as it is negotiated
1725 * also in the SKE protocol.
1728 int silc_client_add_private_message_key_ske(SilcClient client,
1729 SilcClientConnection conn,
1730 SilcClientEntry client_entry,
1732 SilcSKEKeyMaterial *key,
1735 /****f* silcclient/SilcClientAPI/silc_client_del_private_message_key
1739 * int silc_client_del_private_message_key(SilcClient client,
1740 * SilcClientConnection conn,
1741 * SilcClientEntry client_entry);
1745 * Removes the private message from the library. The key won't be used
1746 * after this to protect the private messages with the remote `client_entry'
1747 * client. Returns FALSE on error, TRUE otherwise.
1750 int silc_client_del_private_message_key(SilcClient client,
1751 SilcClientConnection conn,
1752 SilcClientEntry client_entry);
1754 /****f* silcclient/SilcClientAPI/silc_client_list_private_message_keys
1758 * SilcPrivateMessageKeys
1759 * silc_client_list_private_message_keys(SilcClient client,
1760 * SilcClientConnection conn,
1761 * SilcUInt32 *key_count);
1765 * Returns array of set private message keys associated to the connection
1766 * `conn'. Returns allocated SilcPrivateMessageKeys array and the array
1767 * count to the `key_count' argument. The array must be freed by the caller
1768 * by calling the silc_client_free_private_message_keys function. Note:
1769 * the keys returned in the array is in raw format. It might not be desired
1770 * to show the keys as is. The application might choose not to show the keys
1771 * at all or to show the fingerprints of the keys.
1774 SilcPrivateMessageKeys
1775 silc_client_list_private_message_keys(SilcClient client,
1776 SilcClientConnection conn,
1777 SilcUInt32 *key_count);
1779 /****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
1783 * void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1784 * SilcUInt32 key_count);
1788 * Frees the SilcPrivateMessageKeys array returned by the function
1789 * silc_client_list_private_message_keys.
1792 void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
1793 SilcUInt32 key_count);
1796 /* Channel private key management (client_channel.c,
1797 SilcChannelPrivateKey is defined in idlist.h) */
1799 /****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
1803 * int silc_client_add_channel_private_key(SilcClient client,
1804 * SilcClientConnection conn,
1805 * SilcChannelEntry channel,
1809 * unsigned char *key,
1810 * SilcUInt32 key_len);
1814 * Adds private key for channel. This may be set only if the channel's mode
1815 * mask includes the SILC_CHANNEL_MODE_PRIVKEY. This returns FALSE if the
1816 * mode is not set. When channel has private key then the messages are
1817 * encrypted using that key. All clients on the channel must also know the
1818 * key in order to decrypt the messages. However, it is possible to have
1819 * several private keys per one channel. In this case only some of the
1820 * clients on the channel may know the one key and only some the other key.
1821 * The `name' can be application given name for the key.
1823 * The private key for channel is optional. If it is not set then the
1824 * channel messages are encrypted using the channel key generated by the
1825 * server. However, setting the private key (or keys) for the channel
1826 * significantly adds security. If more than one key is set the library
1827 * will automatically try all keys at the message decryption phase. Note:
1828 * setting many keys slows down the decryption phase as all keys has to
1829 * be tried in order to find the correct decryption key. However, setting
1830 * a few keys does not have big impact to the decryption performace.
1834 * NOTE: This is entirely local setting. The key set using this function
1835 * is not sent to the network at any phase.
1837 * NOTE: If the key material was originated by the SKE protocol (using
1838 * silc_client_send_key_agreement) then the `key' MUST be the
1839 * key->send_enc_key as this is dictated by the SILC protocol. However,
1840 * currently it is not expected that the SKE key material would be used
1841 * as channel private key. However, this API allows it.
1844 int silc_client_add_channel_private_key(SilcClient client,
1845 SilcClientConnection conn,
1846 SilcChannelEntry channel,
1851 SilcUInt32 key_len);
1853 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_keys
1857 * int silc_client_del_channel_private_keys(SilcClient client,
1858 * SilcClientConnection conn,
1859 * SilcChannelEntry channel);
1863 * Removes all private keys from the `channel'. The old channel key is used
1864 * after calling this to protect the channel messages. Returns FALSE on
1865 * on error, TRUE otherwise.
1868 int silc_client_del_channel_private_keys(SilcClient client,
1869 SilcClientConnection conn,
1870 SilcChannelEntry channel);
1872 /****f* silcclient/SilcClientAPI/silc_client_del_channel_private_key
1876 * int silc_client_del_channel_private_key(SilcClient client,
1877 * SilcClientConnection conn,
1878 * SilcChannelEntry channel,
1879 * SilcChannelPrivateKey key);
1883 * Removes and frees private key `key' from the channel `channel'.
1884 * The `key' is retrieved by calling the function
1885 * silc_client_list_channel_private_keys. The key is not used after
1886 * this. If the key was last private key then the old channel key is
1887 * used hereafter to protect the channel messages. This returns FALSE
1888 * on error, TRUE otherwise.
1891 int silc_client_del_channel_private_key(SilcClient client,
1892 SilcClientConnection conn,
1893 SilcChannelEntry channel,
1894 SilcChannelPrivateKey key);
1896 /****f* silcclient/SilcClientAPI/silc_client_list_channel_private_keys
1900 * SilcChannelPrivateKey *
1901 * silc_client_list_channel_private_keys(SilcClient client,
1902 * SilcClientConnection conn,
1903 * SilcChannelEntry channel,
1904 * SilcUInt32 *key_count);
1908 * Returns array (pointers) of private keys associated to the `channel'.
1909 * The caller must free the array by calling the function
1910 * silc_client_free_channel_private_keys. The pointers in the array may be
1911 * used to delete the specific key by giving the pointer as argument to the
1912 * function silc_client_del_channel_private_key.
1915 SilcChannelPrivateKey *
1916 silc_client_list_channel_private_keys(SilcClient client,
1917 SilcClientConnection conn,
1918 SilcChannelEntry channel,
1919 SilcUInt32 *key_count);
1921 /****f* silcclient/SilcClientAPI/silc_client_free_channel_private_keys
1925 * void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1926 * SilcUInt32 key_count);
1930 * Frees the SilcChannelPrivateKey array.
1933 void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
1934 SilcUInt32 key_count);
1936 /****f* silcclient/SilcClientAPI/silc_client_current_channel_private_key
1940 * void silc_client_current_channel_private_key(SilcClient client,
1941 * SilcClientConnection conn,
1942 * SilcChannelEntry channel,
1943 * SilcChannelPrivateKey key);
1947 * Sets the `key' to be used as current channel private key on the
1948 * `channel'. Packet sent after calling this function will be secured
1952 void silc_client_current_channel_private_key(SilcClient client,
1953 SilcClientConnection conn,
1954 SilcChannelEntry channel,
1955 SilcChannelPrivateKey key);
1958 /* Key Agreement routines (client_keyagr.c) */
1960 /****f* silcclient/SilcClientAPI/silc_client_send_key_agreement
1964 * void silc_client_send_key_agreement(SilcClient client,
1965 * SilcClientConnection conn,
1966 * SilcClientEntry client_entry,
1969 * SilcUInt32 timeout_secs,
1970 * SilcKeyAgreementCallback completion,
1975 * Sends key agreement request to the remote client indicated by the
1976 * `client_entry'. If the caller provides the `hostname' and the `port'
1977 * arguments then the library will bind the client to that hostname and
1978 * that port for the key agreement protocol. It also sends the `hostname'
1979 * and the `port' in the key agreement packet to the remote client. This
1980 * would indicate that the remote client may initiate the key agreement
1981 * protocol to the `hostname' on the `port'. If port is zero then the
1982 * bound port is undefined (the operating system defines it).
1984 * If the `hostname' and `port' is not provided then empty key agreement
1985 * packet is sent to the remote client. The remote client may reply with
1986 * the same packet including its hostname and port. If the library receives
1987 * the reply from the remote client the `key_agreement' client operation
1988 * callback will be called to verify whether the user wants to perform the
1989 * key agreement or not.
1993 * NOTE: If the application provided the `hostname' and the `port' and the
1994 * remote side initiates the key agreement protocol it is not verified
1995 * from the user anymore whether the protocol should be executed or not.
1996 * By setting the `hostname' and `port' the user gives permission to
1997 * perform the protocol (we are responder in this case).
1999 * NOTE: If the remote side decides not to initiate the key agreement
2000 * or decides not to reply with the key agreement packet then we cannot
2001 * perform the key agreement at all. If the key agreement protocol is
2002 * performed the `completion' callback with the `context' will be called.
2003 * If remote side decides to ignore the request the `completion' will be
2004 * called after the specified timeout, `timeout_secs'.
2006 * NOTE: If the `hostname' and the `port' was not provided the `completion'
2007 * will not be called at all since this does nothing more than sending
2008 * a packet to the remote host.
2010 * NOTE: There can be only one active key agreement for one client entry.
2011 * Before setting new one, the old one must be finished (it is finished
2012 * after calling the completion callback) or the function
2013 * silc_client_abort_key_agreement must be called.
2016 void silc_client_send_key_agreement(SilcClient client,
2017 SilcClientConnection conn,
2018 SilcClientEntry client_entry,
2019 const char *hostname,
2020 const char *bindhost,
2022 SilcUInt32 timeout_secs,
2023 SilcKeyAgreementCallback completion,
2026 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement
2031 * silc_client_perform_key_agreement(SilcClient client,
2032 * SilcClientConnection conn,
2033 * SilcClientEntry client_entry,
2036 * SilcKeyAgreementCallback completion,
2041 * Performs the actual key agreement protocol. Application may use this
2042 * to initiate the key agreement protocol. This can be called for example
2043 * after the application has received the `key_agreement' client operation,
2044 * and did not return TRUE from it.
2046 * The `hostname' is the remote hostname (or IP address) and the `port'
2047 * is the remote port. The `completion' callback with the `context' will
2048 * be called after the key agreement protocol.
2052 * NOTE: If the application returns TRUE in the `key_agreement' client
2053 * operation the library will automatically start the key agreement. In this
2054 * case the application must not call this function. However, application
2055 * may choose to just ignore the `key_agreement' client operation (and
2056 * merely just print information about it on the screen) and call this
2057 * function when the user whishes to do so (by, for example, giving some
2058 * specific command). Thus, the API provides both, automatic and manual
2059 * initiation of the key agreement. Calling this function is the manual
2060 * initiation and returning TRUE in the `key_agreement' client operation
2061 * is the automatic initiation.
2064 void silc_client_perform_key_agreement(SilcClient client,
2065 SilcClientConnection conn,
2066 SilcClientEntry client_entry,
2069 SilcKeyAgreementCallback completion,
2072 /****f* silcclient/SilcClientAPI/silc_client_perform_key_agreement_fd
2077 * silc_client_perform_key_agreement_fd(SilcClient client,
2078 * SilcClientConnection conn,
2079 * SilcClientEntry client_entry,
2082 * SilcKeyAgreementCallback completion,
2087 * Same as above but application has created already the connection to
2088 * the remote host. The `sock' is the socket to the remote connection.
2089 * Application can use this function if it does not want the client library
2090 * to create the connection.
2093 void silc_client_perform_key_agreement_fd(SilcClient client,
2094 SilcClientConnection conn,
2095 SilcClientEntry client_entry,
2098 SilcKeyAgreementCallback completion,
2101 /****f* silcclient/SilcClientAPI/silc_client_abort_key_agreement
2105 * void silc_client_abort_key_agreement(SilcClient client,
2106 * SilcClientConnection conn,
2107 * SilcClientEntry client_entry);
2111 * This function can be called to unbind the hostname and the port for
2112 * the key agreement protocol. However, this function has effect only
2113 * before the key agreement protocol has been performed. After it has
2114 * been performed the library will automatically unbind the port. The
2115 * `client_entry' is the client to which we sent the key agreement
2116 * request. The key agreement completion callback will be called
2117 * with SILC_KEY_AGREEMENT_ABORTED status.
2120 void silc_client_abort_key_agreement(SilcClient client,
2121 SilcClientConnection conn,
2122 SilcClientEntry client_entry);
2125 /* Misc functions */
2127 /****f* silcclient/SilcClientAPI/silc_client_set_away_message
2131 * void silc_client_set_away_message(SilcClient client,
2132 * SilcClientConnection conn,
2137 * Sets away `message'. The away message may be set when the client's
2138 * mode is changed to SILC_UMODE_GONE and the client whishes to reply
2139 * to anyone who sends private message. The `message' will be sent
2140 * automatically back to the the client who send private message. If
2141 * away message is already set this replaces the old message with the
2142 * new one. If `message' is NULL the old away message is removed.
2143 * The sender may freely free the memory of the `message'.
2146 void silc_client_set_away_message(SilcClient client,
2147 SilcClientConnection conn,
2150 /****f* silcclient/SilcClientAPI/SilcConnectionAuthRequest
2154 * typedef void (*SilcConnectionAuthRequest)(SilcClient client,
2155 * SilcClientConnection conn,
2156 * SilcAuthMethod auth_meth,
2161 * Connection authentication method request callback. This is called
2162 * by the client library after it has received the authentication method
2163 * that the application requested by calling the function
2164 * silc_client_request_authentication_method.
2167 typedef void (*SilcConnectionAuthRequest)(SilcClient client,
2168 SilcClientConnection conn,
2169 SilcAuthMethod auth_meth,
2172 /****f* silcclient/SilcClientAPI/silc_client_request_authentication_method
2177 * silc_client_request_authentication_method(SilcClient client,
2178 * SilcClientConnection conn,
2179 * SilcConnectionAuthRequest
2185 * This function can be used to request the current authentication method
2186 * from the server. This may be called when connecting to the server
2187 * and the client library requests the authentication data from the
2188 * application. If the application does not know the current authentication
2189 * method it can request it from the server using this function.
2190 * The `callback' with `context' will be called after the server has
2191 * replied back with the current authentication method.
2195 silc_client_request_authentication_method(SilcClient client,
2196 SilcClientConnection conn,
2197 SilcConnectionAuthRequest callback,
2200 /****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
2204 * typedef enum { ... } SilcClientMonitorStatus;
2208 * File transmission session status types. These will indicate
2209 * the status of the file transmission session.
2214 SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT, /* In key agreemenet phase */
2215 SILC_CLIENT_FILE_MONITOR_SEND, /* Sending file */
2216 SILC_CLIENT_FILE_MONITOR_RECEIVE, /* Receiving file */
2217 SILC_CLIENT_FILE_MONITOR_GET,
2218 SILC_CLIENT_FILE_MONITOR_PUT,
2219 SILC_CLIENT_FILE_MONITOR_CLOSED, /* Session closed */
2220 SILC_CLIENT_FILE_MONITOR_ERROR, /* Error during session */
2221 } SilcClientMonitorStatus;
2224 /****d* silcclient/SilcClientAPI/SilcClientFileError
2228 * typedef enum { ... } SilcClientFileError;
2232 * File transmission error types. These types are returned by
2233 * some of the file transmission functions, and by the monitor
2234 * callback to indicate error.
2239 SILC_CLIENT_FILE_OK,
2240 SILC_CLIENT_FILE_ERROR,
2241 SILC_CLIENT_FILE_UNKNOWN_SESSION,
2242 SILC_CLIENT_FILE_ALREADY_STARTED,
2243 SILC_CLIENT_FILE_NO_SUCH_FILE,
2244 SILC_CLIENT_FILE_PERMISSION_DENIED,
2245 SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED,
2246 } SilcClientFileError;
2249 /****f* silcclient/SilcClientAPI/SilcClientFileMonitor
2253 * typedef void (*SilcClientFileMonitor)(SilcClient client,
2254 * SilcClientConnection conn,
2255 * SilcClientMonitorStatus status,
2256 * SilcClientFileError error,
2257 * SilcUInt64 offset,
2258 * SilcUInt64 filesize,
2259 * SilcClientEntry client_entry,
2260 * SilcUInt32 session_id,
2261 * const char *filepath,
2266 * Monitor callback that is called during the file transmission to
2267 * monitor the transmission process. The `status' indicates the current
2268 * monitoring process. The `error' will indicate the error type
2269 * if `status' is SILC_CLIENT_FILE_MONITOR_ERROR. The `offset' is the
2270 * currently transmitted amount of total `filesize'. The `client_entry'
2271 * indicates the remote client, and the transmission session ID is the
2272 * `session_id'. The filename being transmitted is indicated by the
2276 typedef void (*SilcClientFileMonitor)(SilcClient client,
2277 SilcClientConnection conn,
2278 SilcClientMonitorStatus status,
2279 SilcClientFileError error,
2281 SilcUInt64 filesize,
2282 SilcClientEntry client_entry,
2283 SilcUInt32 session_id,
2284 const char *filepath,
2287 /****f* silcclient/SilcClientAPI/silc_client_file_send
2291 * SilcClientFileError
2292 * silc_client_file_send(SilcClient client,
2293 * SilcClientConnection conn,
2294 * SilcClientFileMonitor monitor,
2295 * void *monitor_context,
2296 * const char *local_ip,
2297 * SilcUInt32 local_port,
2299 * SilcClientEntry client_entry,
2300 * const char *filepath);
2301 * SilcUInt32 *session_id);
2305 * Sends a file indicated by the `filepath' to the remote client
2306 * indicated by the `client_entry'. This will negotiate a secret key
2307 * with the remote client before actually starting the transmission of
2308 * the file. The `monitor' callback will be called to monitor the
2309 * transmission of the file.
2311 * This returns a file session ID for the file transmission to the
2312 * `session_id' pointer. It can be used to close the session (and
2313 * abort the file transmission) by calling the silc_client_file_close
2314 * function. The session ID is also returned in the `monitor' callback.
2316 * If the `local_ip' is provided then this will try to bind the
2317 * listener for key exchange protocol to that IP. If `local_port' is
2318 * non-zero that port is used. If `local_ip' is NULL then this will
2319 * automatically attempt to bind it to local IP address of the machine.
2320 * If `do_not_bind' is TRUE then the `local_ip' and `local_port' are
2321 * ignored and it is expected that the receiver will provide the
2322 * point of contact. This is usefull if the sender is behind NAT.
2324 * If error will occur during the file transfer process the error
2325 * status will be returned in the monitor callback. In this case
2326 * the application must call silc_client_file_close to close the
2331 silc_client_file_send(SilcClient client,
2332 SilcClientConnection conn,
2333 SilcClientFileMonitor monitor,
2334 void *monitor_context,
2335 const char *local_ip,
2336 SilcUInt32 local_port,
2338 SilcClientEntry client_entry,
2339 const char *filepath,
2340 SilcUInt32 *session_id);
2342 /****f* silcclient/SilcClientAPI/silc_client_file_receive
2346 * SilcClientFileError
2347 * silc_client_file_receive(SilcClient client,
2348 * SilcClientConnection conn,
2349 * SilcClientFileMonitor monitor,
2350 * void *monitor_context,
2352 * SilcUInt32 session_id);
2356 * Receives a file from a client indicated by the `client_entry'. The
2357 * `session_id' indicates the file transmission session and it has been
2358 * received in the `ftp' client operation function. This will actually
2359 * perform the key agreement protocol with the remote client before
2360 * actually starting the file transmission. The `monitor' callback
2361 * will be called to monitor the transmission. If `path' is non NULL
2362 * the file will be saved into that directory. If NULL the file is
2363 * saved in the current working directory.
2365 * If error will occur during the file transfer process the error
2366 * status will be returned in the monitor callback. In this case
2367 * the application must call silc_client_file_close to close the
2372 silc_client_file_receive(SilcClient client,
2373 SilcClientConnection conn,
2374 SilcClientFileMonitor monitor,
2375 void *monitor_context,
2377 SilcUInt32 session_id);
2379 /****f* silcclient/SilcClientAPI/silc_client_file_close
2383 * SilcClientFileError silc_client_file_close(SilcClient client,
2384 * SilcClientConnection conn,
2385 * SilcUInt32 session_id);
2389 * Closes file transmission session indicated by the `session_id'.
2390 * If file transmission is being conducted it will be aborted
2391 * automatically. This function is also used to close the session
2392 * after successful file transmission. This function can be used
2393 * also to reject incoming file transmission request.
2396 SilcClientFileError silc_client_file_close(SilcClient client,
2397 SilcClientConnection conn,
2398 SilcUInt32 session_id);
2400 /****f* silcclient/SilcClientAPI/silc_client_attribute_add
2404 * SilcAttributePayload
2405 * silc_client_attribute_add(SilcClient client,
2406 * SilcClientConnection conn,
2407 * SilcAttribute attribute,
2409 * SilcUInt32 object_size);
2413 * Add new Requsted Attribute for WHOIS command to the client library.
2414 * The `attribute' object indicated by `object' is added and allocated
2415 * SilcAttributePayload is returned. The `object' must be of correct
2416 * type and of correct size. See the SilcAttribute for object types
2417 * for different attributes. You may also get all added attributes
2418 * from the client with silc_client_attributes_get function.
2420 * Requested Attributes are different personal information about the
2421 * user, status information and other information which other users
2422 * may query with WHOIS command. Application may set these so that
2423 * if someone sends WHOIS query these attributes will be replied back
2424 * to the sender. The library always puts the public key to the
2425 * Requested Attributes, but if application wishes to add additional
2426 * public keys (or certificates) it can be done with this interface.
2427 * Library also always computes digital signature of the attributes
2428 * automatically, so application does not need to do that.
2431 SilcAttributePayload silc_client_attribute_add(SilcClient client,
2432 SilcClientConnection conn,
2433 SilcAttribute attribute,
2435 SilcUInt32 object_size);
2437 /****f* silcclient/SilcClientAPI/silc_client_attribute_del
2441 * bool silc_client_attribute_del(SilcClient client,
2442 * SilcClientConnection conn,
2443 * SilcAttribute attribute,
2444 * SilcAttributePayload attr);
2448 * Delete a Requested Attribute from the client. If the `attribute'
2449 * is non-zero then all attributes of that type are deleted and the
2450 * `attr' is ignored. If `attr' is non-NULL then that specific
2451 * attribute is deleted and `attribute' is ignored.
2453 * You may get all added attributes with the function
2454 * silc_client_attributes_get and to get the SilcAttributePayload.
2455 * This function Returns TRUE if the attribute was found and deleted.
2458 bool silc_client_attribute_del(SilcClient client,
2459 SilcClientConnection conn,
2460 SilcAttribute attribute,
2461 SilcAttributePayload attr);
2463 /****f* silcclient/SilcClientAPI/silc_client_attributes_get
2467 * const SilcHashTable
2468 * silc_client_attributes_get(SilcClient client,
2469 * SilcClientConnection conn);
2473 * Returns pointer to the SilcHashTable which includes all the added
2474 * Requested Attributes. The caller must not free the hash table.
2475 * The caller may use SilcHashTableList and silc_hash_table_list to
2476 * traverse the table. Each entry in the hash table is one added
2477 * SilcAttributePayload. It is possible to delete a attribute
2478 * payload while traversing the table.
2481 const SilcHashTable silc_client_attributes_get(SilcClient client,
2482 SilcClientConnection conn);
2484 /****f* silcclient/SilcClientAPI/silc_client_attributes_request
2488 * SilcBuffer silc_client_attributes_request(SilcAttribute attribute, ...);
2492 * Constructs a Requested Attributes buffer. If the `attribute' is zero (0)
2493 * then all attributes are requested. Alternatively, `attribute' and
2494 * all variable arguments can each be requested attribute. In this case
2495 * the last must be set to zero (0) to complete the variable list of
2496 * requested attributes. See SilcAttribute for all attributes.
2497 * You can give the returned buffer as argument to for example
2498 * silc_client_get_client_by_id_resolve function.
2501 SilcBuffer silc_client_attributes_request(SilcAttribute attribute, ...);
2503 /* Low level packet sending functions */
2505 /****f* silcclient/SilcClientAPI/silc_client_send_packet
2509 * bool silc_client_send_packet(SilcClient client,
2510 * SilcClientConnection conn,
2511 * SilcPacketType type,
2512 * const unsigned char *data,
2513 * SilcUInt32 data_len);
2517 * This routine can be used by application to send packets directly
2518 * to a connection indicated by `conn'. Usually application does not
2519 * need this routine since the Client Library handles the packet
2520 * sending. The `type' indicates the packet type. If `data' is
2521 * NULL then empty packet is sent. This returns FALSE if packet cannot
2525 bool silc_client_send_packet(SilcClient client,
2526 SilcClientConnection conn,
2527 SilcPacketType type,
2528 const unsigned char *data,
2529 SilcUInt32 data_len);
2531 #include "command.h"
2532 #include "command_reply.h"
2534 #include "protocol.h"
2540 #endif /* SILCCLIENT_H */