silcclient: auto-negotiation of private message key using SKE over SILCnet
[silc.git] / lib / silcclient / silcclient.h
index 536f3ee915a21e3130e5f6b81464cd397057032f..58e43f158c85230ee5f126acb31649d01f56329f 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2000 - 2007 Pekka Riikonen
+  Copyright (C) 2000 - 2014 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -232,6 +232,18 @@ struct SilcClientConnectionStruct {
   void *callback_context;             /* Connection context */
   SilcClient client;                  /* Pointer back to SilcClient */
 
+  /* Current say() operation associated context, identifies the client,
+     channel or server the message is related to.  Application can use
+     this information to target the message better. */
+  union {
+    SilcClientEntry client_entry;
+    SilcChannelEntry channel_entry;
+    SilcServerEntry server_entry;
+  };
+  SilcIdType context_type;             /* Defines which pointer is set
+                                          in the union.  If SILC_ID_NONE
+                                          pointer is NULL. */
+
   /* Application specific data.  Application may set here whatever it wants. */
   void *context;
 
@@ -401,7 +413,7 @@ struct SilcChannelPrivateKeyStruct {
  *
  * SYNOPSIS
  *
- *    typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
+ *    typedef void (*SilcAskPassphrase)(const unsigned char *passphrase,
  *                                     SilcUInt32 passphrase_len,
  *                                     void *context);
  *
@@ -414,7 +426,7 @@ struct SilcChannelPrivateKeyStruct {
  *    encoded, and if it is not then library will attempt to encode it.
  *
  ***/
-typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
+typedef void (*SilcAskPassphrase)(const unsigned char *passphrase,
                                  SilcUInt32 passphrase_len,
                                  void *context);
 
@@ -437,9 +449,8 @@ typedef void (*SilcVerifyPublicKey)(SilcBool success, void *context);
  *
  * SYNOPSIS
  *
- *    typedef void (*SilcGetAuthMeth)(SilcBool success,
- *                                    SilcAuthMethod auth_meth,
- *                                    void *auth, SilcUInt32 auth_len,
+ *    typedef void (*SilcGetAuthMeth)(SilcAuthMethod auth_meth,
+ *                                    const void *auth, SilcUInt32 auth_len,
  *                                    void *context);
  *
  * DESCRIPTION
@@ -461,7 +472,7 @@ typedef void (*SilcVerifyPublicKey)(SilcBool success, void *context);
  *
  ***/
 typedef void (*SilcGetAuthMeth)(SilcAuthMethod auth_meth,
-                               void *auth, SilcUInt32 auth_len,
+                               const void *auth, SilcUInt32 auth_len,
                                void *context);
 
 /****d* silcclient/SilcClientAPI/SilcClientMessageType
@@ -507,7 +518,9 @@ typedef struct SilcClientOperationsStruct {
      The `type' indicates the type of the message sent by the library.
      The application can for example filter the message according the
      type.  The variable argument list is arguments to the formatted
-     message that `msg' may be. */
+     message `msg'.  A SilcClientEntry, SilcChannelEntry or SilcServerEntry
+     can be associated with the message inside the `conn' by the library,
+     and application may use it to better target the message. */
   void (*say)(SilcClient client, SilcClientConnection conn,
              SilcClientMessageType type, char *msg, ...);
 
@@ -666,13 +679,16 @@ typedef struct SilcClientParamsStruct {
      %H  full hostname - the full hostname of the client
 
      Example format strings: "%n#%a"     (fe. nick#2, nick#3)
-                             "%n@%h%a"   (fe. nick@host, nick@host2)
-                             "%a!%n@%h"  (fe. nick@host, 2!nick@host)
+                             "%n#%h%a"   (fe. nick#host, nick#host2)
+                             "%a!%n#%h"  (fe. nick#host, 2!nick#host)
 
      Note that there must always be some separator characters around '%n'
      format.  It is not possible to put format characters before or after
      '%n' without separators (such ash '#').  Also note that the separator
      character should be a character that cannot be part of normal nickname.
+     Note that, using '@' as a separator is not recommended as the nickname
+     string may contain it to separate a server name from the nickname (eg.
+     nickname@silcnet.org).
   */
   char nickname_format[32];
 
@@ -684,11 +700,30 @@ typedef struct SilcClientParamsStruct {
      value. */
   SilcBool nickname_force_format;
 
+  /* If this is set to TRUE then all nickname strings returned by the library
+     and stored by the library are in the format of 'nickname@server', eg.
+     nickname@silcnet.org.  If this is FALSE then the server name of the
+     nickname is available only from the SilcClientEntry structure.  When this
+     is TRUE the server name is still parsed to SilcClientEntry. */
+  SilcBool full_nicknames;
+
+  /* If this is set to TRUE then all channel name strings returned by the
+     library and stored by the library are in the format of 'channel@server',
+     eg. silc@silcnet.org.  If this is FALSE then the server name of the
+     channel is available only from the SilcChannelEntry structure.  When this
+     is TRUE the server name is still parsed to SilcChannelEntry.  Note that,
+     not all SILC server versions return such channel name strings. */
+  SilcBool full_channel_names;
+
   /* If this is set to TRUE, the silcclient library will not register and
      deregister the cipher, pkcs, hash and hmac algorithms. The application
      itself will need to handle that. */
   SilcBool dont_register_crypto_library;
 
+  /* If this is set to TRUE, the silcclient library will not automatically
+     negotiate private message keys using SKE over the SILC network but will
+     use normal session keys to protect private messages. */
+  SilcBool dont_autoneg_prvmsg_keys;
 } SilcClientParams;
 /***/
 
@@ -926,6 +961,10 @@ typedef struct SilcClientConnectionParamsStruct {
      silc_client_attribute_add for more information on attributes. */
   SilcBool ignore_requested_attributes;
 
+  /* User context for SilcClientConnection.  If non-NULL this context is
+     set to the 'context' field in SilcClientConnection when the connection
+     context is created. */
+  void *context;
 } SilcClientConnectionParams;
 /***/
 
@@ -1142,7 +1181,7 @@ void silc_client_close_connection(SilcClient client,
  *
  *    Returns TRUE if the message was sent, and FALSE if error occurred or
  *    the sending is not allowed due to channel modes (like sending is
- *    blocked).  This function is thread safe and private messages can be
+ *    blocked).  This function is thread safe and channel messages can be
  *    sent from multiple threads.
  *
  ***/
@@ -1310,9 +1349,12 @@ SilcChannelUser silc_client_on_channel(SilcChannelEntry channel,
  *    be the command name.  The variable argument list must be terminated
  *    with NULL.
  *
- *    Returns FALSE if the command is not known and TRUE after command.
- *    execution.  The `command' client operation callback will be called when
- *    the command is executed to indicate whether or not the command executed
+ *    Returns command identifier for this sent command.  It can be used
+ *    to additionally attach to the command reply using the function
+ *    silc_client_command_pending, if needed.  Returns 0 on error.
+ *
+ *    The `command' client operation callback will be called when the
+ *    command is executed to indicate whether or not the command executed
  *    successfully.
  *
  *    The `command_reply' client operation callbak will be called when reply