updates.
[silc.git] / lib / silcclient / silcapi.h
index 06704abdaa0f114b47e8440d62e2c49066b8b754..140f2f2227aec9e84027105d24e034c0be6c3e9a 100644 (file)
@@ -59,7 +59,7 @@
  *
  * NAME
  *
- *    SilcKeyAgreementStatus
+ *    typedef enum { ... } SilcKeyAgreementStatus;
  *
  * DESCRIPTION
  *
@@ -110,7 +110,7 @@ typedef void (*SilcKeyAgreementCallback)(SilcClient client,
  *
  * NAME
  *
- *    SilcPrivateMessageKeys
+ *    typedef struct { ... } SilcPrivateMessageKeys;
  *
  * DESCRIPTION
  *
@@ -166,11 +166,32 @@ typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
  ***/
 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
 
+/****d* silcclient/SilcClientAPI/SilcClientMessageType
+ *
+ * NAME
+ *
+ *    typedef enum { ... } SilcClientMessageType;
+ *
+ * DESCRIPTION
+ *
+ *    Different message types for `say' client operation.  The application
+ *    may filter the message sent by the library according this type.
+ *
+ * SOURCE
+ */
+typedef enum {
+  SILC_CLIENT_MESSAGE_INFO,           /* Informational */
+  SILC_CLIENT_MESSAGE_WARNING,        /* Warning */
+  SILC_CLIENT_MESSAGE_ERROR,          /* Error */
+  SILC_CLIENT_MESSAGE_AUDIT,          /* Auditable */
+} SilcClientMessageType;
+/***/
+
 /****s* silcclient/SilcClientAPI/SilcClientOperations
  *
  * NAME
  *
- *    SilcClientOperations
+ *    typedef struct { ... } SilcClientOperations;
  *
  * DESCRIPTION
  *
@@ -183,8 +204,12 @@ typedef void (*SilcVerifyPublicKey)(bool success, void *context);
  */
 typedef struct {
   /* Message sent to the application by library. `conn' associates the
-     message to a specific connection.  `conn', however, may be NULL. */
-  void (*say)(SilcClient client, SilcClientConnection conn, char *msg, ...);
+     message to a specific connection.  `conn', however, may be NULL. 
+     The `type' indicates the type of the message sent by the library.
+     The applicationi can for example filter the message according the
+     type. */
+  void (*say)(SilcClient client, SilcClientConnection conn, 
+             SilcClientMessageType type, char *msg, ...);
 
   /* Message for a channel. The `sender' is the sender of the message 
      The `channel' is the channel. */
@@ -307,17 +332,21 @@ typedef struct {
  * SYNOPSIS
  *
  *    SilcClient silc_client_alloc(SilcClientOperations *ops, 
- *                                 void *application);
+ *                                 void *application,
+ *                                 const char *silc_version);
  *
  * DESCRIPTION
  *
- * Allocates new client object. This has to be done before client may
- * work. After calling this one must call silc_client_init to initialize
- * the client. The `application' is application specific user data pointer
- * and caller must free it.
+ *    Allocates new client object. This has to be done before client may
+ *    work. After calling this one must call silc_client_init to initialize
+ *    the client. The `application' is application specific user data pointer
+ *    and caller must free it. The `silc_version' is the application version
+ *    that will be used to compare against remote host's (usually a server)
+ *    version string.
  *
  ***/
-SilcClient silc_client_alloc(SilcClientOperations *ops, void *application);
+SilcClient silc_client_alloc(SilcClientOperations *ops, void *application,
+                            const char *silc_version);
 
 /****f* silcclient/SilcClientAPI/silc_client_free
  *
@@ -747,6 +776,40 @@ void silc_client_get_client_by_id_resolve(SilcClient client,
                                          SilcGetClientCallback completion,
                                          void *context);
 
+/****f* silcclient/SilcClientAPI/silc_client_del_client
+ *
+ * SYNOPSIS
+ *
+ *    bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+ *                                SilcClientEntry client_entry)
+ *
+ * DESCRIPTION
+ *
+ *    Removes client from local cache by the client entry indicated by
+ *    the `client_entry'.  Returns TRUE if the deletion were successful.
+ *
+ ***/
+bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+                           SilcClientEntry client_entry);
+
+/****f* silcclient/SilcClientAPI/silc_client_del_client_by_id
+ *
+ * SYNOPSIS
+ *
+ *    bool silc_client_del_client_by_id(SilcClient client, 
+ *                                      SilcClientConnection conn,
+ *                                      SilcClientID *client_id);
+ *
+ * DESCRIPTION
+ *
+ *    Removes client from local cache by the Client ID indicated by
+ *    the `Client ID'.  Returns TRUE if the deletion were successful.
+ *
+ ***/
+bool silc_client_del_client_by_id(SilcClient client, 
+                                 SilcClientConnection conn,
+                                 SilcClientID *client_id);
+
 /****f* silcclient/SilcClientAPI/silc_client_get_channel
  *
  * SYNOPSIS
@@ -766,6 +829,24 @@ SilcChannelEntry silc_client_get_channel(SilcClient client,
                                         SilcClientConnection conn,
                                         char *channel);
 
+/****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
+ *
+ * SYNOPSIS
+ *
+ *    SilcServerEntry silc_client_get_server_by_id(SilcClient client,
+ *                                                 SilcClientConnection conn,
+ *                                                 SilcServerID *server_id);
+ *
+ * DESCRIPTION
+ *
+ *    Finds entry for server by the server ID. Returns the entry or NULL
+ *    if the entry was not found.
+ *
+ ***/
+SilcServerEntry silc_client_get_server_by_id(SilcClient client,
+                                            SilcClientConnection conn,
+                                            SilcServerID *server_id);
+
 
 /* Command management (command.c) */
 
@@ -907,7 +988,8 @@ void silc_client_command_pending(SilcClientConnection conn,
  *                                            char *cipher,
  *                                            unsigned char *key,
  *                                            uint32 key_len,
- *                                            int generate_key);
+ *                                            bool generate_key,
+ *                                            bool responder);
  *
  * DESCRIPTION
  *
@@ -920,6 +1002,11 @@ void silc_client_command_pending(SilcClientConnection conn,
  *    requirements of the SILC protocol are met. The API, however, allows
  *    to allocate any cipher.
  *
+ *    If `responder' is TRUE then the sending and receiving keys will be
+ *    set according the client being the receiver of the private key.  If
+ *    FALSE the client is being the sender (or negotiator) of the private
+ *    key.
+ *
  *    It is not necessary to set key for normal private message usage. If the
  *    key is not set then the private messages are encrypted using normal
  *    session keys. Setting the private key, however, increases the security. 
@@ -934,7 +1021,8 @@ int silc_client_add_private_message_key(SilcClient client,
                                        char *cipher,
                                        unsigned char *key,
                                        uint32 key_len,
-                                       int generate_key);
+                                       bool generate_key,
+                                       bool responder);
 
 /****f* silcclient/SilcClientAPI/silc_client_add_private_message_key_ske
  *
@@ -948,18 +1036,19 @@ int silc_client_add_private_message_key(SilcClient client,
  *
  * DESCRIPTION
  *
- *    Same as above but takes the key material from the SKE key material
- *    structure. This structure is received if the application uses the
- *    silc_client_send_key_agreement to negotiate the key material. The
- *    `cipher' SHOULD be provided as it is negotiated also in the SKE
- *    protocol. 
+ *    Same as silc_client_add_private_message_key but takes the key material
+ *    from the SKE key material structure. This structure is received if
+ *    the application uses the silc_client_send_key_agreement to negotiate
+ *    the key material. The `cipher' SHOULD be provided as it is negotiated
+ *    also in the SKE protocol. 
  *
  ***/
 int silc_client_add_private_message_key_ske(SilcClient client,
                                            SilcClientConnection conn,
                                            SilcClientEntry client_entry,
                                            char *cipher,
-                                           SilcSKEKeyMaterial *key);
+                                           SilcSKEKeyMaterial *key,
+                                           bool responder);
 
 /****f* silcclient/SilcClientAPI/silc_client_send_private_message_key
  *
@@ -1235,6 +1324,10 @@ void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
  *    If remote side decides to ignore the request the `completion' will be
  *    called after the specified timeout, `timeout_secs'. 
  *
+ *    NOTE: If the `hostname' and the `port' was not provided the `completion'
+ *    will not be called at all since this does nothing more than sending
+ *    a packet to the remote host.
+ *
  *    NOTE: There can be only one active key agreement for one client entry.
  *    Before setting new one, the old one must be finished (it is finished
  *    after calling the completion callback) or the function