updates.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 15 Apr 2002 18:08:45 +0000 (18:08 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 15 Apr 2002 18:08:45 +0000 (18:08 +0000)
24 files changed:
CHANGES
TODO
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/client_ops.h
apps/silcd/command.c
apps/silcd/command_reply.c
apps/silcd/packet_receive.c
apps/silcd/packet_send.c
apps/silcd/packet_send.h
doc/draft-riikonen-silc-commands-03.nroff
doc/draft-riikonen-silc-pp-05.nroff
doc/draft-riikonen-silc-spec-05.nroff
includes/silcincludes.h
lib/silcclient/client_notify.c
lib/silcclient/client_ops_example.c
lib/silcclient/command.c
lib/silcclient/command_reply.c
lib/silcclient/command_reply.h
lib/silcclient/silcclient.h
lib/silccore/DIRECTORY
lib/silccore/silccommand.c
lib/silccore/silccommand.h
lib/silccore/silcnotify.h
lib/silccore/silcstatus.h [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index cdebe9bfc70256cdf2bfbc156542d97f389ef20e..8464a923af93ce392e8707bc18f120eafdc174a3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,30 @@
+Mon Apr 15 19:57:57 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Added new notify type SILC_NOTIFY_TYPE_ERROR and specified
+         that it is used to send error notifys if error occurs during
+         some SILC packet processing, except commands.  The error
+         types are same as for command reply types.  Defined that
+         if private message is sent to unknown Client ID the error
+         is sent in SILC_NOTIFY_TYPE_ERROR instead of command reply.
+         Updated the protocol specs and code.  Affected files are
+         lib/silccore/silcnotify.h, added lib/silccore/silcstatus.h,
+         lib/silcclient/client_notify.c, silcd/packet_receive.c,
+         and irssi/src/silc/core/client_ops.c.  Renamed the
+          SilcCommandStatus to SilcStatus.
+
+       * Defined the use of extra WHOIS attributes in WHOIS command.
+         The <Requested Attributes> (defined in a separate document)
+         can be used to request additional information about user 
+         not returned by standard WHOIS command.  Defined that server
+         can send WHOIS command directly to client.  Client provides
+         the requested attributes to the server.  Updated the protocol
+         specs.  Protocol TODO #4.  Implementation is not done yet
+          (Protocol TODO #24).
+
+       * Renamed function silc_client_command_status_message to        
+         silc_client_status_message.  Affected files are
+         lib/silcclient/command_reply.[ch].
+
 Sun Apr 14 21:13:42 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Changed the WHOIS, IDENTIFY and WHOWAS count arguments to
diff --git a/TODO b/TODO
index b5037a6f98d5bc2bc3056c97df74696892e82c76..e0a20a8f40aab7a71851a9c9d7da09a607d9a43e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -109,19 +109,12 @@ TODO in SILC Protocol
     *after* sending successfully found entries (this way receiver may
     ignore them).  To be included in protocol version 1.1.
 
- 4. Add "request parameters" or similar to the WHOIS command, which can
-    be used to request various parameters (something not returned by
-    standard WHOIS command) about clients (info that could be fetched
-    even from clients).  Additional specification (or appendix) should 
-    be done to define the payload and the parameters.  It could be used
-    to make the WHOIS command support various search conditions as well.
-    This would be the way to extend the WHOIS command to support various
-    new features without always making the command incompatible to previous
-    version.  To be included in protocol version 1.1.
-
  17. Cell wide channel founder support, and permanent channels when
      founder mode set.
 
  20. Services support?
 
  21. Subscription/IRC's notify kind support?
+
+ 24. Implement the <Requested Attributes> and the Attribute Payload to
+     the core library, client and server.
index 5a5ee7b54ca127dfeadd24424f798b4a1bac6665..ce62c19a61ca4bc56891d164d1d32072ff160d8c 100644 (file)
@@ -614,6 +614,15 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
     }
     break;
 
+  case SILC_NOTIFY_TYPE_ERROR:
+    {
+      SilcStatus error = va_arg(va, int);
+
+      silc_say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
+               "%s", silc_client_status_message(error));
+    }
+    break;
+
   default:
     /* Unknown notify */
     printformat_module("fe-common/silc", server, NULL,
@@ -842,7 +851,7 @@ void silc_getkey_cb(bool success, void *context)
 void 
 silc_command_reply(SilcClient client, SilcClientConnection conn,
                   SilcCommandPayload cmd_payload, int success,
-                  SilcCommand command, SilcCommandStatus status, ...)
+                  SilcCommand command, SilcStatus status, ...)
 
 {
   SILC_SERVER_REC *server = conn->context;
@@ -869,7 +878,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
                                     3, NULL);
        if (tmp)
          silc_say_error("%s: %s", tmp, 
-                        silc_client_command_status_message(status));
+                        silc_client_status_message(status));
        break;
       } else if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
        /* Try to find the entry for the unknown client ID, since we
@@ -886,7 +895,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
                                                        client_id);
            if (client_entry && client_entry->nickname)
              silc_say_error("%s: %s", client_entry->nickname,
-                            silc_client_command_status_message(status));
+                            silc_client_status_message(status));
            silc_free(client_id);
          }
        }
@@ -1008,7 +1017,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
                                     3, NULL);
        if (tmp)
          silc_say_error("%s: %s", tmp, 
-                        silc_client_command_status_message(status));
+                        silc_client_status_message(status));
        break;
       } else if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
        /* Try to find the entry for the unknown client ID, since we
@@ -1025,7 +1034,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
                                                        client_id);
            if (client_entry && client_entry->nickname)
              silc_say_error("%s: %s", client_entry->nickname,
-                            silc_client_command_status_message(status));
+                            silc_client_status_message(status));
            silc_free(client_id);
          }
        }
@@ -1046,7 +1055,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
                                         3, NULL);
        if (tmp)
          silc_say_error("%s: %s", tmp, 
-                        silc_client_command_status_message(status));
+                        silc_client_status_message(status));
        break;
       }
       
index 60fda7ae1b9452001b67f9088a92738519e2614f..f76eae13f3d07183e3276db566e53b8a15d1bb69 100644 (file)
@@ -42,7 +42,7 @@ void silc_command(SilcClient client, SilcClientConnection conn,
                  SilcCommand command);
 void silc_command_reply(SilcClient client, SilcClientConnection conn,
                        SilcCommandPayload cmd_payload, int success,
-                       SilcCommand command, SilcCommandStatus status, ...);
+                       SilcCommand command, SilcStatus status, ...);
 void silc_connect(SilcClient client, SilcClientConnection conn,
                  SilcClientConnectionStatus status);
 void silc_disconnect(SilcClient client, SilcClientConnection conn);
index f49b6b44f41eae31ab4dbb1579543074789b37f6..06e5b96d7717fed78c6d947714f6f5bb70300415 100644 (file)
@@ -29,11 +29,11 @@ static int silc_server_is_registered(SilcServer server,
 static void 
 silc_server_command_send_status_reply(SilcServerCommandContext cmd,
                                      SilcCommand command,
-                                     SilcCommandStatus status);
+                                     SilcStatus status);
 static void 
 silc_server_command_send_status_data(SilcServerCommandContext cmd,
                                     SilcCommand command,
-                                    SilcCommandStatus status,
+                                    SilcStatus status,
                                     SilcUInt32 arg_type,
                                     const unsigned char *arg,
                                     SilcUInt32 arg_len);
@@ -389,7 +389,7 @@ silc_server_command_pending_check(SilcServer server,
 static void 
 silc_server_command_send_status_reply(SilcServerCommandContext cmd,
                                      SilcCommand command,
-                                     SilcCommandStatus status)
+                                     SilcStatus status)
 {
   SilcBuffer buffer;
 
@@ -411,7 +411,7 @@ silc_server_command_send_status_reply(SilcServerCommandContext cmd,
 static void 
 silc_server_command_send_status_data(SilcServerCommandContext cmd,
                                     SilcCommand command,
-                                    SilcCommandStatus status,
+                                    SilcStatus status,
                                     SilcUInt32 arg_type,
                                     const unsigned char *arg,
                                     SilcUInt32 arg_len)
@@ -704,7 +704,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
   int i, k, len, valid_count;
   SilcBuffer packet, idp, channels, umode_list = NULL;
   SilcClientEntry entry;
-  SilcCommandStatus status;
+  SilcStatus status;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
   char nh[256], uh[256];
   unsigned char idle[4], mode[4];
@@ -1097,7 +1097,7 @@ silc_server_command_whowas_send_reply(SilcServerCommandContext cmd,
   int i, k, count = 0, len;
   SilcBuffer packet, idp;
   SilcClientEntry entry = NULL;
-  SilcCommandStatus status;
+  SilcStatus status;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
   char nh[256], uh[256];
   int valid_count;
@@ -1752,7 +1752,7 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
   SilcServer server = cmd->server;
   int i, k, len, valid_count;
   SilcBuffer packet, idp;
-  SilcCommandStatus status;
+  SilcStatus status;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
   char nh[256], uh[256];
   SilcSocketConnection hsock;
@@ -2103,7 +2103,7 @@ silc_server_command_list_send_reply(SilcServerCommandContext cmd,
   int i, k;
   SilcBuffer packet, idp;
   SilcChannelEntry entry;
-  SilcCommandStatus status;
+  SilcStatus status;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
   char *topic;
   unsigned char usercount[4];
index 13e6c8db2f752c65aaabd631db176aeec5cbe339..cd93edc7a21287ca8898407eb820bef86d9a7dbe 100644 (file)
@@ -254,7 +254,7 @@ SILC_SERVER_CMD_REPLY_FUNC(whois)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
 
   COMMAND_CHECK_STATUS;
 
@@ -390,7 +390,7 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
 SILC_SERVER_CMD_REPLY_FUNC(whowas)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
 
   COMMAND_CHECK_STATUS;
 
@@ -615,7 +615,7 @@ SILC_SERVER_CMD_REPLY_FUNC(identify)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
 
   COMMAND_CHECK_STATUS;
 
@@ -664,7 +664,7 @@ SILC_SERVER_CMD_REPLY_FUNC(info)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   SilcServerEntry entry;
   SilcServerID *server_id;
   SilcUInt32 tmp_len;
@@ -721,7 +721,7 @@ SILC_SERVER_CMD_REPLY_FUNC(motd)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   SilcServerEntry entry = NULL;
   SilcServerID *server_id;
   SilcUInt32 tmp_len;
@@ -770,7 +770,7 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
   SilcIDCacheEntry cache = NULL;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   SilcChannelID *id;
   SilcClientID *client_id = NULL;
   SilcChannelEntry entry;
@@ -973,7 +973,7 @@ SILC_SERVER_CMD_REPLY_FUNC(stats)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   unsigned char *tmp;
   SilcUInt32 tmp_len;
   SilcBufferStruct buf;
@@ -1011,7 +1011,7 @@ SILC_SERVER_CMD_REPLY_FUNC(users)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   SilcChannelEntry channel;
   SilcChannelID *channel_id = NULL;
   SilcBuffer client_id_list;
@@ -1103,7 +1103,7 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   SilcClientEntry client = NULL;
   SilcServerEntry server_entry = NULL;
   SilcClientID *client_id = NULL;
@@ -1190,7 +1190,7 @@ SILC_SERVER_CMD_REPLY_FUNC(list)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcStatus status, error;
   SilcChannelID *channel_id = NULL;
   SilcChannelEntry channel;
   SilcIDCacheEntry cache;
index 6a6ab5b3acee7131be7647991a3a6dff6f87eda8..d124a91c68012b12a34fecf04572fcba09dbb97d 100644 (file)
@@ -1367,6 +1367,42 @@ void silc_server_notify(SilcServer server,
     }
     break;
 
+  case SILC_NOTIFY_TYPE_ERROR:
+    {
+      /*
+       * Error notify
+       */
+      SilcStatus error;
+
+      tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
+      if (!tmp && tmp_len != 1)
+       goto out;
+      error = (SilcStatus)tmp[0];
+
+      SILC_LOG_DEBUG(("ERROR notify (%d)", error));
+
+      if (error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
+         sock->type == SILC_SOCKET_TYPE_ROUTER) {
+       tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+       if (tmp) {
+         SILC_LOG_DEBUG(("Received invalid client ID notification, deleting "
+                         "the entry from cache"));
+         client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
+         if (!client_id)
+           goto out;
+         client = silc_idlist_find_client_by_id(server->global_list, 
+                                                client_id, FALSE, NULL);
+         if (client) {
+           silc_server_remove_from_channels(server, NULL, client, TRUE, 
+                                            NULL, TRUE);
+           silc_idlist_del_client(server->global_list, client);
+         }
+         silc_free(client_id);
+       }
+      }
+    }
+    break;
+
     /* Ignore rest of the notify types for now */
   case SILC_NOTIFY_TYPE_NONE:
   case SILC_NOTIFY_TYPE_MOTD:
@@ -1458,34 +1494,37 @@ void silc_server_private_message(SilcServer server,
                                          &idata, &client);
   if (!dst_sock) {
     SilcBuffer idp;
+    unsigned char error;
 
     if (client && client->mode & SILC_UMODE_DETACHED) {
       SILC_LOG_DEBUG(("Client is detached, discarding packet"));
       return;
     }
 
-    /* Send IDENTIFY command reply with error status to indicate that
-       such destination ID does not exist or is invalid */
+    /* Send SILC_NOTIFY_TYPE_ERROR to indicate that such destination ID
+       does not exist or is invalid. */
     idp = silc_id_payload_encode_data(packet->dst_id,
                                      packet->dst_id_len,
                                      packet->dst_id_type);
     if (!idp)
       return;
 
+    error = SILC_STATUS_ERR_NO_SUCH_CLIENT_ID;
     if (packet->src_id_type == SILC_ID_CLIENT) {
       SilcClientID *client_id = silc_id_str2id(packet->src_id,
                                               packet->src_id_len,
                                               packet->src_id_type);
-      silc_server_send_dest_command_reply(server, sock, 
-                                         client_id, SILC_ID_CLIENT,
-                                         SILC_COMMAND_IDENTIFY,
-                                         SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, 
-                                         0, 0, 1, 2, idp->data, idp->len);
+      silc_server_send_notify_dest(server, sock, FALSE,
+                                  client_id, SILC_ID_CLIENT,
+                                  SILC_NOTIFY_TYPE_ERROR, 2,
+                                  &error, 1,
+                                  idp->data, idp->len);
       silc_free(client_id);
     } else {
-      silc_server_send_command_reply(server, sock, SILC_COMMAND_IDENTIFY,
-                                    SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, 0,
-                                    0, 1, 2, idp->data, idp->len);
+      silc_server_send_notify(server, sock, FALSE,
+                             SILC_NOTIFY_TYPE_ERROR, 2,
+                             &error, 1,
+                             idp->data, idp->len);
     }
 
     silc_buffer_free(idp);
index 019df0699a68c825613d772a9ab75ff9b2794593..9272547baa0f36593ef6d46533f0c91ec7f649db 100644 (file)
@@ -1723,8 +1723,8 @@ void silc_server_send_command(SilcServer server,
 void silc_server_send_command_reply(SilcServer server, 
                                    SilcSocketConnection sock,
                                    SilcCommand command, 
-                                   SilcCommandStatus status,
-                                   SilcCommandStatus error,
+                                   SilcStatus status,
+                                   SilcStatus error,
                                    SilcUInt16 ident,
                                    SilcUInt32 argc, ...)
 {
@@ -1749,8 +1749,8 @@ void silc_server_send_dest_command_reply(SilcServer server,
                                         void *dst_id,
                                         SilcIdType dst_id_type,
                                         SilcCommand command, 
-                                        SilcCommandStatus status,
-                                        SilcCommandStatus error,
+                                        SilcStatus status,
+                                        SilcStatus error,
                                         SilcUInt16 ident,
                                         SilcUInt32 argc, ...)
 {
index c40c888ca1a2c1aaa5cc2d08727ecb5c78625934..1434ef8a3d40ac69d51cec4efdbd40b4685cb0a3 100644 (file)
@@ -232,8 +232,8 @@ void silc_server_send_command(SilcServer server,
 void silc_server_send_command_reply(SilcServer server, 
                                    SilcSocketConnection sock,
                                    SilcCommand command, 
-                                   SilcCommandStatus status,
-                                   SilcCommandStatus error,
+                                   SilcStatus status,
+                                   SilcStatus error,
                                    SilcUInt16 ident,
                                    SilcUInt32 argc, ...);
 void silc_server_send_dest_command_reply(SilcServer server, 
@@ -241,8 +241,8 @@ void silc_server_send_dest_command_reply(SilcServer server,
                                         void *dst_id,
                                         SilcIdType dst_id_type,
                                         SilcCommand command, 
-                                        SilcCommandStatus status,
-                                        SilcCommandStatus error,
+                                        SilcStatus status,
+                                        SilcStatus error,
                                         SilcUInt16 ident,
                                         SilcUInt32 argc, ...);
 void silc_server_send_heartbeat(SilcServer server,
index e7a3f21034e76bff81cc0e7404f3b66ea5b27b9c..e794d6d91f5a639289752dff3aa91689a2a4f4cf 100644 (file)
@@ -75,12 +75,11 @@ Table of Contents
 2 SILC Commands .................................................  2
   2.1 SILC Commands Syntax ......................................  2
   2.2 SILC Commands List ........................................  4
-  2.3 SILC Command Status Types ................................. 33
-      2.3.1 SILC Command Status Payload ......................... 33
-      2.3.2 SILC Command Status List ............................ 33
-3 Security Considerations ....................................... 38
-4 References .................................................... 38
-5 Author's Address .............................................. 40
+  2.3 SILC Command Status Payload ............................... 33
+3 SILC Status Types ............................................. 33
+4 Security Considerations ....................................... 38
+5 References .................................................... 38
+6 Author's Address .............................................. 40
 Appendix A ...................................................... xx
 
 
@@ -197,7 +196,7 @@ Status messages:
 
 Every command reply also defines set of status message that it
 may return inside the <Status Payload>.  All status messages
-are defined in the section 2.3 SILC Command Status Types.
+are defined in the section 2.3 SILC Command Status Payload
 
 .in 3
 Every command that has some kind of ID as argument (for example
@@ -256,18 +255,19 @@ List of all defined commands in SILC follows.
         The WHOIS request MUST be always sent to the router by server
         so that all users are searched.  However, the server still MUST
         search its locally connected clients.  The router MUST send
-        this command to the server which owns the requested client.  That
-        server MUST reply to the command.  Server MUST NOT send whois
-        replies to the client until it has received the reply from its
-        router.
+        this command to the server which owns the requested client, if
+        the router is unable to provide all mandatory information about
+        the client.  That server MUST reply to the command.  Server MUST
+        NOT send whois replies to the client until it has received the
+        reply from its router.
 
         The <Requested Attributes> is defined in [ATTRS] and can be used
         to request various information about the client.  See Appendix A
-        for definition of using these attaributes in SILC.
+        for definition of using these attributes in SILC.
 
         Reply messages to the command:
 
-        Max Arguments:  10
+        Max Arguments:  11
             Arguments:  (1) <Status Payload>       (2) <Client ID> 
                         (3) <nickname>[@<server>]  (4) <username@host> 
                         (5) <real name>            (6) [<Channel Payload 
@@ -275,6 +275,7 @@ List of all defined commands in SILC follows.
                         (7) [<user mode>]          (8) [<idle time>]
                         (9) [<fingerprint>]        (10) <channel user
                                                          mode list>
+                        (11) [<Attributes>]
 
 
         This command may reply with several command reply messages to
@@ -310,6 +311,9 @@ List of all defined commands in SILC follows.
         the corresponding private key.  Server can do this during the
         SILC Key Exchange protocol.  The <fingerprint> is SHA1 digest.
 
+        The <Attributes> is the reply to the <Requested Attributes>.
+        See the Appendix A for more information.
+
         Status messages:
 
             SILC_STATUS_OK
@@ -1724,17 +1728,15 @@ List of all defined commands in SILC follows.
 .in 3
 
 
-.ti 0
-2.3 SILC Command Status Types
-
 .ti 0
 2.3.1 SILC Command Status Payload
 
 Command Status Payload is sent in command reply messages to indicate
 the status of the command.  The payload is one of argument in the
 command thus this is the data area in Command Argument Payload described
-in [SILC2].  The payload is only 2 bytes of length.  The following diagram
-represents the Command Status Payload (field is always in MSB order).
+in [SILC2].  The payload is only 2 bytes of length.  The following
+diagram represents the Command Status Payload (field is always in
+MSB first order).
 
 
 .in 21
@@ -1796,17 +1798,31 @@ All Status messages are described in the next section.
 
 
 .ti 0
-2.3.2 SILC Command Status List
+2.3.2 SILC Status Types
+
+Status messages are returned in SILC protocol in command reply
+packet and in notify packet.  The SILC_PACKET_COMMAND_REPLY is
+the command reply packet and status types are sent inside the
+Status Payload as one of command reply argument, as defined in
+previous sections.  For SILC_PACKET_NOTIFY packet they can be sent
+as defined in [SILC2] for SILC_NOTIFY_TYPE_ERROR type.  The same
+types defined in this section are used in both cases.
 
-Command Status messages are returned in the command reply messages
-to indicate whether the command were executed without errors.  If error
-has occurred the status indicates which error occurred.  Status payload
-only sends numeric reply about the status.  Receiver of the payload must
-convert the numeric values into human readable error messages.  The
-list of status messages below has an example human readable error
-messages that client may display for the user.
+When returning status messages in the command reply message they
+indicate whether the command was executed without errors.  If error
+occurred the status indicates which error occurred.
 
-List of all defined command status messages following.
+When sending status messages in SILC_NOTIFY_TYPE_ERROR notify type
+they always send some error status.  Usually they are sent to
+indicate that error occurred while processing some SILC packet.
+Please see the [SILC1] and [SILC2] for more information sending
+status types in SILC_NOTIFY_TYPE_ERROR notify.
+
+The Status Types are only numeric values and the receiver must
+convert the numeric values into human readable messages if this
+is desired in the application.
+
+List of all defined status types:
 
 .in 0
    Generic status messages:
@@ -1900,10 +1916,14 @@ List of all defined command status messages following.
    22   SILC_STATUS_ERR_NO_SUCH_CLIENT_ID
 
         "No such Client ID".  Client ID provided does not exist.
+        The unknown Client ID MUST be provided as next argument
+        in the reply.
 
    23   SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID
 
         "No such Channel ID".  Channel ID provided does not exist.
+        The unknown Channel ID MUST be provided as next argument
+        in the reply.
 
    24   SILC_STATUS_ERR_NICKNAME_IN_USE
 
@@ -2026,6 +2046,8 @@ List of all defined command status messages following.
    47   SILC_STATUS_ERR_NO_SUCH_SERVER_ID
 
         "No such Server ID".  Server ID provided does not exist.
+        The unknown Server ID MUST be provided as next argument
+        in the reply.
 
 .in 3
 
@@ -2123,6 +2145,8 @@ Finland
 
 EMail: priikone@iki.fi
 
+This Internet-Draft expires XXX
+
 
 .ti 0
 Appendix A
@@ -2137,8 +2161,53 @@ requested attributes.  This requires the servers to relay the WHOIS
 command to the client, and it requires capability for handling the WHOIS
 command in the client end.
 
-
-
-
-This Internet-Draft expires XXX
-
+The <Requested Attributes> MAY include several attributes that are
+requested.  The format and encoding of the <Requested Attributes> is as
+defined in [ATTRS].  When <Requested Attributes> argument is set the
+server MAY process the attributes to see whether it can narrow down
+the WHOIS search, for example when searching with a nickname.  The
+normal servers MUST process the WHOIS command as normal WHOIS command,
+that is to send the command directly to the router.  The router MAY
+process the attributes, but it MUST send the command to the server
+that owns the requested client.
+
+The server that owns the client and receives the command MUST check
+whether the client is detached from the network.  If it is detached,
+that is the user mode has the SILC_UMODE_DETACHED mode set, it SHOULD
+process the attributes and provide as many of the requested attributes
+as possible and then send reply back to the sender.  If the client is
+active in the network it MUST send the command to the client for
+processing.
+
+The client receiving WHOIS command SHOULD check whether the
+<Requested Attributes> argument is set.  If it is not set then the
+WHOIS command SHOULD be discarded.  The client processes the requested
+attributes and SHOULD reply to each of the requested attribute with
+either valid value, or with an indication that the requested attribute
+is not known or supported.  This is to be done as defined in [ATTRS].
+The client always MUST send a reply to the command when some attributes
+were requested.  The client MAY also add additional attributes to the
+reply even if they were not requested.  The client MAY also digitally
+sign the attributes with ATTRIBUTE_USER_DIGITAL_SIGNATURE as defined
+in [ATTRS].  Then the client sends the reply back to the sender of
+the command.  The command reply that client assembles does not need
+to include any other argument but the <Status Payload> (1), and the
+<Attributes> (11).  The server receiving reply from client MUST allow
+this sort of command reply for WHOIS command.
+
+The information received from the client MAY be cached in the
+server's end.  The caching may be desired for example if the client
+can be detached from the network.  This way the server is then able
+to provide at least partial information for a requestor.  The
+server MAY also process the command reply and verify whether the
+attributes provided in the reply are actually valid.  If it can do
+this, and verify that they indeed are valid values it MAY append
+a digital signature at the end of the attributes with the
+ATTRIBUTE_SERVER_DIGITAL_SIGNATURE as defined in [ATTRS].  The
+server then MUST provide valid WHOIS command reply to the sender
+of the command.   Other servers and routers that receive the command
+reply enroute to the original sender MAY also cache the information.
+
+The client which receives the command reply to the WHOIS command
+SHOULD verify the ATTRIBUTE_USER_DIGITAL_SIGNATURE and the
+ATTRIBUTE_SERVER_DIGITAL_SIGNATURE if they are provided.
index fcc4b85020d93b6ed833f8bf57304146ed584d96..21ec404820476e715d2434d1f385ba0ff8d9d886 100644 (file)
@@ -1475,6 +1475,27 @@ UTF-8 [RFC2279] encoded.
       <removing client> is defined in the [SILC4] with SILC_COMMAND_BAN
       command.
 
+
+16    SILC_NOTIFY_TYPE_ERROR
+
+      Sent when an error occurs during processing some SILC procedure.
+      This is not used when error occurs during command processing, see
+      [SILC3] for more information about commands and command replies.
+      This type is sent directly to the sender of the packet whose packet
+      caused the error.  See [SILC1] for definition when this type
+      can be sent.
+
+      Max Arguments:  256
+          Arguments:  (1) <Status Type>        (n) [...]
+
+      The <Status Type> is the error type defined in [SILC3].  Note that
+      same types are also used with command replies to indicate the
+      status of a command.  Both commands and this notify type share
+      same status types.  Rest of the arguments are status type
+      dependent and are specified with those status types that can be
+      sent currently inside this notify type in [SILC3].  The <Status
+      Type> is of size of 1 byte.
+
 .in 3
 
 Notify types starting from 16384 are reserved for private notify
index 2557e8295f7a416c6dff67f376fe77a30b3781fa..4611512d80ea0232216896cadf4a2d8e2c92f613 100644 (file)
@@ -836,12 +836,14 @@ to set nickname, join to channel, change modes and many other things.
 
 Client usually sends the commands and server replies by sending a reply
 packet to the command.  Server MAY also send commands usually to serve
-the original client's request.  However, server MUST NOT send commands
-to client and there are some commands that server must not send.
+the original client's request.  Usually server cannot send commands to
+clients, however there MAY be commands that allow the server to send
+commands to client.  By default servers MAY send commands only to other
+servers and routers.
 
 Note that the command reply is usually sent only after client has sent
 the command request but server is allowed to send command reply packet
-to client even if client has not requested the command.  Client MAY,
+to client even if client has not requested the command.  Client MAY
 choose to ignore the command reply.
 
 It is expected that some of the commands may be miss-used by clients
@@ -1972,8 +1974,9 @@ If the sender has received earlier a private message from the receiver
 it should have cached the Client ID from the SILC Packet Header.
 
 If server receives a private message packet which includes invalid
-destionation Client ID the server MUST send SILC_COMMAND_IDENTIFY
-command reply packet destined to the client with error status.
+destionation Client ID the server MUST send SILC_NOTIFY_TYPE_ERROR
+notify to the client with error status indicating that such ID does
+not exist to the client.
 
 See [SILC2] for description of private message encryption and decryption
 process.
index a74228dc6b0fabccf2c77d63781229fad19c8020..e18c6ca18e345ae989fe33a64c3e8546e0ada24f 100644 (file)
@@ -237,6 +237,7 @@ extern "C" {
 #include "silcsockconn.h"
 
 /* SILC core library includes */
+#include "silcstatus.h"
 #include "silcid.h"
 #include "silcidcache.h"
 #include "silcargument.h"
index c13030695bb6c2544828ff63cf2bfb0f946c775f..12db4c73a2f08c3983da2085178811ae9cf9232a 100644 (file)
@@ -1031,6 +1031,38 @@ void silc_client_notify_by_server(SilcClient client,
     }
     break;
 
+  case SILC_NOTIFY_TYPE_ERROR:
+    {
+      /*
+       * Some has occurred and server is notifying us about it.
+       */
+      SilcStatus error;
+
+      tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
+      if (!tmp && tmp_len != 1)
+       goto out;
+      error = (SilcStatus)tmp[0];
+
+      SILC_LOG_DEBUG(("Notify: ERROR (%d)", error));
+
+      if (error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+       tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+       if (tmp) {
+         client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
+         if (!client_id)
+           goto out;
+         client_entry = silc_client_get_client_by_id(client, conn,
+                                                     client_id);
+         if (client_entry)
+           silc_client_del_client(client, conn, client_entry);
+       }
+      }
+
+      /* Notify application. */
+      client->internal->ops->notify(client, conn, type, error);
+    }
+    break;
+
   default:
     break;
   }
index 6662e8550d1c84dcacae20570f953ab73854dcd7..b410e2a2feb8718d7fbe24986b68df22cac99d43 100644 (file)
@@ -104,7 +104,7 @@ silc_command(SilcClient client, SilcClientConnection conn,
 static void 
 silc_command_reply(SilcClient client, SilcClientConnection conn, 
                   SilcCommandPayload cmd_payload, int success, 
-                  SilcCommand command, SilcCommandStatus status, ...)
+                  SilcCommand command, SilcStatus status, ...)
 {
 
 }
index e021c2a422027f779c5dfaade549c362d8a7891f..8097b7e7baf722b14820049b49ff2aa70ad793f6 100644 (file)
@@ -362,7 +362,7 @@ SILC_CLIENT_CMD_FUNC(nick_change)
   SilcClientConnection conn = cmd->conn;
   SilcClientCommandReplyContext reply = 
     (SilcClientCommandReplyContext)context2;
-  SilcCommandStatus status;
+  SilcStatus status;
 
   silc_command_get_status(reply->payload, &status, NULL);
   if (status == SILC_STATUS_OK) {
@@ -789,7 +789,7 @@ SILC_CLIENT_CMD_FUNC(kill_remove)
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientCommandReplyContext reply = 
     (SilcClientCommandReplyContext)context2;
-  SilcCommandStatus status;
+  SilcStatus status;
 
   silc_command_get_status(reply->payload, &status, NULL);
   if (status == SILC_STATUS_OK) {
@@ -2178,7 +2178,7 @@ SILC_CLIENT_CMD_FUNC(getkey)
       } else {
        SilcClientCommandReplyContext reply = 
          (SilcClientCommandReplyContext)context2;
-       SilcCommandStatus error;
+       SilcStatus error;
 
        /* If nickname was not found, then resolve the server. */
        silc_command_get_status(reply->payload, NULL, &error);
@@ -2202,9 +2202,9 @@ SILC_CLIENT_CMD_FUNC(getkey)
           server and did not find anybody. */
        if (error == SILC_STATUS_ERR_NO_SUCH_SERVER) {
          SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", 
-            silc_client_command_status_message(SILC_STATUS_ERR_NO_SUCH_NICK));
+            silc_client_status_message(SILC_STATUS_ERR_NO_SUCH_NICK));
          SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", 
-           silc_client_command_status_message(error));
+           silc_client_status_message(error));
          COMMAND_ERROR;
          goto out;
        }
index 424d3ea2cd9ac1e8993f878e71489b63ed3a52f1..735dcc9d9ad3c3a594c6d69e3033dd517d6af84d 100644 (file)
@@ -36,7 +36,7 @@
 #include "silcclient.h"
 #include "client_internal.h"
 
-const SilcCommandStatusMessage silc_command_status_messages[] = {
+const SilcStatusMessage silc_command_status_messages[] = {
 
   { STAT(NO_SUCH_NICK),      "There was no such nickname" },
   { STAT(NO_SUCH_CHANNEL),   "There was no such channel" },
@@ -158,7 +158,7 @@ void silc_client_command_reply_process(SilcClient client,
 
 /* Returns status message string */
 
-char *silc_client_command_status_message(SilcCommandStatus status)
+char *silc_client_status_message(SilcStatus status)
 {
   int i;
 
@@ -185,7 +185,7 @@ void silc_client_command_reply_free(SilcClientCommandReplyContext cmd)
 
 static void 
 silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
-                                    SilcCommandStatus status,
+                                    SilcStatus status,
                                     bool notify)
 {
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
@@ -378,7 +378,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(whowas)
 
 static void 
 silc_client_command_reply_identify_save(SilcClientCommandReplyContext cmd,
-                                       SilcCommandStatus status,
+                                       SilcStatus status,
                                        bool notify)
 {
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
@@ -554,7 +554,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick)
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
        "Cannot set nickname: %s", 
-       silc_client_command_status_message(cmd->error));
+       silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -667,7 +667,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -721,7 +721,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -763,7 +763,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(kill)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -793,7 +793,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(info)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", 
-       silc_client_command_status_message(cmd->error));
+       silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -849,7 +849,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -910,7 +910,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
   if (cmd->error != SILC_STATUS_OK) {
     if (cmd->error != SILC_STATUS_ERR_USER_ON_CHANNEL)
       SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-         "%s", silc_client_command_status_message(cmd->error));
+         "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1089,7 +1089,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(motd)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     return;
   }
@@ -1146,7 +1146,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(umode)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1182,7 +1182,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1241,7 +1241,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode)
   
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1315,7 +1315,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(kick)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1335,7 +1335,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(silcoper)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1355,7 +1355,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(oper)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1376,7 +1376,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(detach)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1409,7 +1409,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1455,7 +1455,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(leave)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1500,7 +1500,7 @@ static void silc_client_command_reply_users_cb(SilcClient client,
 
     cmd->status = cmd->error = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
     silc_client_command_reply_free(cmd);
@@ -1512,7 +1512,7 @@ static void silc_client_command_reply_users_cb(SilcClient client,
 
 static int
 silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
-                                    SilcCommandStatus status,
+                                    SilcStatus status,
                                     bool notify,
                                     SilcGetChannelCallback get_channel,
                                     SilcCommandCb get_clients)
@@ -1704,7 +1704,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1742,7 +1742,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(getkey)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1981,7 +1981,7 @@ static void silc_client_command_reply_users_i_cb(SilcClient client,
 
     cmd->status = cmd->error = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
     silc_client_command_reply_free(cmd);
@@ -2028,7 +2028,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(connect)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -2048,7 +2048,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(close)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -2068,7 +2068,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(shutdown)
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_status_message(cmd->error));
     COMMAND_REPLY_ERROR;
     goto out;
   }
index f950447d35f8944fd3c28eeff6e71e47e339c300..3696f748226e23a1f0d21c874ce3cc290360a7e1 100644 (file)
@@ -37,8 +37,8 @@ struct SilcClientCommandReplyContextStruct {
   SilcClient client;
   SilcSocketConnection sock;
   SilcCommandPayload payload;
-  SilcCommandStatus status;
-  SilcCommandStatus error;
+  SilcStatus status;
+  SilcStatus error;
   SilcArgumentPayload args;
   SilcPacketContext *packet;
 
@@ -67,20 +67,20 @@ void silc_client_command_reply_##func(void *context, void *context2)
 
 /* Status message structure. Messages are defined below. */
 typedef struct {
-  SilcCommandStatus status;
+  SilcStatus status;
   char *message;
-} SilcCommandStatusMessage;
+} SilcStatusMessage;
 
 /* Status messages returned by the server */
 #define STAT(x) SILC_STATUS_ERR_##x
-DLLAPI extern const SilcCommandStatusMessage silc_command_status_messages[];
+DLLAPI extern const SilcStatusMessage silc_command_status_messages[];
 
 /* Prototypes */
 
+char *silc_client_status_message(SilcStatus status);
 void silc_client_command_reply_process(SilcClient client,
                                       SilcSocketConnection sock,
                                       SilcPacketContext *packet);
-char *silc_client_command_status_message(SilcCommandStatus status);
 void silc_client_command_reply_free(SilcClientCommandReplyContext cmd);
 SILC_CLIENT_CMD_REPLY_FUNC(whois);
 SILC_CLIENT_CMD_REPLY_FUNC(whowas);
index 928650c788e8bfff98e8dd81c6b9bbec974bf0ad..918d266f2ef7943070c3e8b0efd95091ea2c94cf 100644 (file)
@@ -363,7 +363,7 @@ typedef struct {
      SilcClientEntry. */
   void (*command_reply)(SilcClient client, SilcClientConnection conn,
                        SilcCommandPayload cmd_payload, int success,
-                       SilcCommand command, SilcCommandStatus status, ...);
+                       SilcCommand command, SilcStatus status, ...);
 
   /* Called to indicate that connection was either successfully established
      or connecting failed.  This is also the first time application receives
index 12cd09ca40413eba350c9938be6f7cc999029b6a..5c089628e01a5b4618e9e58d272a4465da5c9899 100644 (file)
@@ -4,10 +4,11 @@
 @LINK=silcauth.html:SILC Authentication Interface
 @LINK=silcchannel.html:SILC Channel Interface
 @LINK=silccommand.html:SILC Command Interface
+@LINK=silcnotify.html:SILC Notify Interface
+@LINK=silcstatus.html:SILC Status Types
+@LINK=silcmode.html:SILC Modes
 @LINK=silcid.html:SILC ID Interface
 @LINK=silcidcache.html:SILC ID Cache Interface
-@LINK=silcmode.html:SILC Modes
-@LINK=silcnotify.html:SILC Notify Interface
 @LINK=silcargument.html:SILC Argument Interface
 @LINK=silcprivate.html:SILC Private Message Interface
 @LINK=silcpacket.html:Packet Protocol Interface
index 20b90c66535918c43917306e7d59d03f5109aeef..d8470570c205f7cb363b0d0b7d093db4138bf295 100644 (file)
@@ -271,8 +271,8 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
 
 SilcBuffer 
 silc_command_reply_payload_encode_va(SilcCommand cmd, 
-                                    SilcCommandStatus status,
-                                    SilcCommandStatus error,
+                                    SilcStatus status,
+                                    SilcStatus error,
                                     SilcUInt16 ident,
                                     SilcUInt32 argc, ...)
 {
@@ -289,8 +289,8 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
 
 SilcBuffer 
 silc_command_reply_payload_encode_vap(SilcCommand cmd, 
-                                     SilcCommandStatus status,
-                                     SilcCommandStatus error,
+                                     SilcStatus status,
+                                     SilcStatus error,
                                      SilcUInt16 ident, SilcUInt32 argc, 
                                      va_list ap)
 {
@@ -394,8 +394,8 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload)
 /* Return command status */
 
 bool silc_command_get_status(SilcCommandPayload payload, 
-                            SilcCommandStatus *status,
-                            SilcCommandStatus *error)
+                            SilcStatus *status,
+                            SilcStatus *error)
 {
   unsigned char *tmp;
   SilcUInt32 tmp_len;
@@ -409,7 +409,7 @@ bool silc_command_get_status(SilcCommandPayload payload,
   /* Check for 1.0 protocol version which didn't have `error' */
   if (tmp[0] == 0 && tmp[1] != 0) {
     /* Protocol 1.0 version */
-    SilcCommandStatus s;
+    SilcStatus s;
     SILC_GET16_MSB(s, tmp);
     if (status)
       *status = s;
@@ -422,9 +422,9 @@ bool silc_command_get_status(SilcCommandPayload payload,
 
   /* Take both status and possible error */
   if (status)
-    *status = (SilcCommandStatus)tmp[0];
+    *status = (SilcStatus)tmp[0];
   if (error)
-    *error = (SilcCommandStatus)tmp[1];
+    *error = (SilcStatus)tmp[1];
 
   /* If single error occurred have the both `status' and `error' indicate
      the error value for convenience. */
index 531f1935aa114e9c66b939c02db1d810fad226a9..691d96eee68c6a62dfaa2a6d5fafd7d53cdfb055 100644 (file)
@@ -159,67 +159,6 @@ typedef unsigned char SilcCommand;
 #define SILC_COMMAND_RESERVED           255
 /***/
 
-/****d* silccore/SilcCommandAPI/SilcCommandStatus
- *
- * NAME
- * 
- *    typedef SilcUInt8 SilcCommandStatus;
- *
- * DESCRIPTION
- *
- *    The SilcCommandStatus type definition and the status defines.
- *    The server returns a status in each Command Payload indicating
- *    the status of the command.
- *
- * SOURCE
- */
-typedef SilcUInt8 SilcCommandStatus;
-
-/* Command Status messages */
-#define SILC_STATUS_OK                      0
-#define SILC_STATUS_LIST_START              1
-#define SILC_STATUS_LIST_ITEM               2
-#define SILC_STATUS_LIST_END                3
-#define SILC_STATUS_ERR_NO_SUCH_NICK        10
-#define SILC_STATUS_ERR_NO_SUCH_CHANNEL     11
-#define SILC_STATUS_ERR_NO_SUCH_SERVER      12
-#define SILC_STATUS_ERR_TOO_MANY_TARGETS    13
-#define SILC_STATUS_ERR_NO_RECIPIENT        14
-#define SILC_STATUS_ERR_UNKNOWN_COMMAND     15
-#define SILC_STATUS_ERR_WILDCARDS           16
-#define SILC_STATUS_ERR_NO_CLIENT_ID        17
-#define SILC_STATUS_ERR_NO_CHANNEL_ID       18
-#define SILC_STATUS_ERR_NO_SERVER_ID        19
-#define SILC_STATUS_ERR_BAD_CLIENT_ID       20
-#define SILC_STATUS_ERR_BAD_CHANNEL_ID      21
-#define SILC_STATUS_ERR_NO_SUCH_CLIENT_ID   22
-#define SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID  23
-#define SILC_STATUS_ERR_NICKNAME_IN_USE     24
-#define SILC_STATUS_ERR_NOT_ON_CHANNEL      25
-#define SILC_STATUS_ERR_USER_NOT_ON_CHANNEL 26
-#define SILC_STATUS_ERR_USER_ON_CHANNEL     27
-#define SILC_STATUS_ERR_NOT_REGISTERED      28
-#define SILC_STATUS_ERR_NOT_ENOUGH_PARAMS   29
-#define SILC_STATUS_ERR_TOO_MANY_PARAMS     30
-#define SILC_STATUS_ERR_PERM_DENIED         31
-#define SILC_STATUS_ERR_BANNED_FROM_SERVER  32
-#define SILC_STATUS_ERR_BAD_PASSWORD        33
-#define SILC_STATUS_ERR_CHANNEL_IS_FULL     34
-#define SILC_STATUS_ERR_NOT_INVITED         35
-#define SILC_STATUS_ERR_BANNED_FROM_CHANNEL 36
-#define SILC_STATUS_ERR_UNKNOWN_MODE        37
-#define SILC_STATUS_ERR_NOT_YOU             38
-#define SILC_STATUS_ERR_NO_CHANNEL_PRIV     39
-#define SILC_STATUS_ERR_NO_CHANNEL_FOPRIV   40
-#define SILC_STATUS_ERR_NO_SERVER_PRIV      41
-#define SILC_STATUS_ERR_NO_ROUTER_PRIV      42
-#define SILC_STATUS_ERR_BAD_NICKNAME        43
-#define SILC_STATUS_ERR_BAD_CHANNEL         44
-#define SILC_STATUS_ERR_AUTH_FAILED         45
-#define SILC_STATUS_ERR_UNKNOWN_ALGORITHM   46
-#define SILC_STATUS_ERR_NO_SUCH_SERVER_ID   47
-/***/
-
 /* Prototypes */
 
 /****f* silccore/SilcCommandAPI/silc_command_payload_parse
@@ -324,8 +263,8 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
  *
  *    SilcBuffer 
  *    silc_command_reply_payload_encode_va(SilcCommand cmd, 
- *                                         SilcCommandStatus status,
- *                                         SilcCommandStatus error,
+ *                                         SilcStatus status,
+ *                                         SilcStatus error,
  *                                         SilcUInt16 ident,
  *                                         SilcUInt32 argc, ...);
  *
@@ -352,8 +291,8 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
  ***/
 SilcBuffer 
 silc_command_reply_payload_encode_va(SilcCommand cmd, 
-                                    SilcCommandStatus status,
-                                    SilcCommandStatus error,
+                                    SilcStatus status,
+                                    SilcStatus error,
                                     SilcUInt16 ident,
                                     SilcUInt32 argc, ...);
 
@@ -363,8 +302,8 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
  *
  *    SilcBuffer 
  *    silc_command_reply_payload_encode_vap(SilcCommand cmd, 
- *                                          SilcCommandStatus status,
- *                                          SilcCommandStatus error,
+ *                                          SilcStatus status,
+ *                                          SilcStatus error,
  *                                          SilcUInt16 ident, SilcUInt32 argc,
  *                                          va_list ap);
  *
@@ -376,8 +315,8 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
  ***/
 SilcBuffer 
 silc_command_reply_payload_encode_vap(SilcCommand cmd, 
-                                     SilcCommandStatus status,
-                                     SilcCommandStatus error,
+                                     SilcStatus status,
+                                     SilcStatus error,
                                      SilcUInt16 ident, SilcUInt32 argc, 
                                      va_list ap);
 
@@ -442,8 +381,8 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload);
  * SYNOPSIS
  *
  *    bool silc_command_get_status(SilcCommandPayload payload, 
- *                                 SilcCommandStatus *status,
- *                                 SilcCommandStatus *error);
+ *                                 SilcStatus *status,
+ *                                 SilcStatus *error);
  *
  * DESCRIPTION
  *
@@ -456,8 +395,8 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload);
  *
  ***/
 bool silc_command_get_status(SilcCommandPayload payload, 
-                            SilcCommandStatus *status,
-                            SilcCommandStatus *error);
+                            SilcStatus *status,
+                            SilcStatus *error);
 
 /****f* silccore/SilcCommandAPI/silc_command_set_ident
  *
index b95f09fd050d6b6fca66128762a4a0a5a8726fa5..bc6b5035f8cd52c0a1110b9f10bb7ea74a44952e 100644 (file)
@@ -79,6 +79,7 @@ typedef SilcUInt16 SilcNotifyType;
 #define SILC_NOTIFY_TYPE_KILLED          13 /* Killed from the network */
 #define SILC_NOTIFY_TYPE_UMODE_CHANGE    14 /* user mode was changed */
 #define SILC_NOTIFY_TYPE_BAN             15 /* ban list change */
+#define SILC_NOTIFY_TYPE_ERROR           16 /* error notify */
 /***/
 
 /* Prototypes */
@@ -87,7 +88,7 @@ typedef SilcUInt16 SilcNotifyType;
  *
  * SYNOPSIS
  *
- *    SilcNotifyPayload 
+ *    SilcNotifyPayload
  *    silc_notify_payload_parse(const unsigned char *payload,
  *                              SilcUInt32 payload_len);
  *
@@ -104,14 +105,15 @@ SilcNotifyPayload silc_notify_payload_parse(const unsigned char *payload,
  *
  * SYNOPSIS
  *
- *    SilcBuffer silc_notify_payload_encode(SilcNotifyType type, SilcUInt32 argc, 
+ *    SilcBuffer silc_notify_payload_encode(SilcNotifyType type,
+ *                                          SilcUInt32 argc,
  *                                          va_list ap);
  *
  * DESCRIPTION
  *
  *    Encode notify payload with variable argument list. If `argc' is > 0
  *    argument payloads will be associated to the notify payload. Variable
- *    arguments must be {usigned char *, SilcUInt32 (len)}.
+ *    arguments must be {unsigned char *, SilcUInt32 (len)}.
  *
  ***/
 SilcBuffer silc_notify_payload_encode(SilcNotifyType type, SilcUInt32 argc, 
@@ -121,7 +123,7 @@ SilcBuffer silc_notify_payload_encode(SilcNotifyType type, SilcUInt32 argc,
  *
  * SYNOPSIS
  *
- *    SilcBuffer silc_notify_payload_encode_args(SilcNotifyType type, 
+ *    SilcBuffer silc_notify_payload_encode_args(SilcNotifyType type,
  *                                               SilcUInt32 argc,
  *                                               SilcBuffer args);
  *
diff --git a/lib/silccore/silcstatus.h b/lib/silccore/silcstatus.h
new file mode 100644 (file)
index 0000000..73f598b
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+
+  silcstatus.h 
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 2002 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
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
+/****h* silccore/SILC Status Types
+ *
+ * DESCRIPTION
+ *
+ * This header includes the SILC Status Types that are used with
+ * command replies and with notify packets.  With command reply packets
+ * they indicate whether error occurred during procesing of the command
+ * and indicate the error type.  With notify type they always indicate
+ * which error occurred.  Both command reply and notify type share the
+ * same status types.
+ *
+ ***/
+
+#ifndef SILCSTATUS_H
+#define SILCSTATUS_H
+
+/****d* silccore/StatusTypes/SilcStatus
+ *
+ * NAME
+ * 
+ *    typedef SilcUInt8 SilcStatus
+ *
+ * DESCRIPTION
+ *
+ *    The SilcStatus type definition and the status defines.  The
+ *    server returns a status in each Command Payload indicating
+ *    the status of the command.  The server can also return this
+ *    inside SILC_NOTIFY_TYPE_ERROR notify type.
+ *
+ * SOURCE
+ */
+typedef SilcUInt8 SilcStatus;
+
+/* Command Status messages */
+#define SILC_STATUS_OK                      0
+#define SILC_STATUS_LIST_START              1
+#define SILC_STATUS_LIST_ITEM               2
+#define SILC_STATUS_LIST_END                3
+#define SILC_STATUS_ERR_NO_SUCH_NICK        10
+#define SILC_STATUS_ERR_NO_SUCH_CHANNEL     11
+#define SILC_STATUS_ERR_NO_SUCH_SERVER      12
+#define SILC_STATUS_ERR_TOO_MANY_TARGETS    13
+#define SILC_STATUS_ERR_NO_RECIPIENT        14
+#define SILC_STATUS_ERR_UNKNOWN_COMMAND     15
+#define SILC_STATUS_ERR_WILDCARDS           16
+#define SILC_STATUS_ERR_NO_CLIENT_ID        17
+#define SILC_STATUS_ERR_NO_CHANNEL_ID       18
+#define SILC_STATUS_ERR_NO_SERVER_ID        19
+#define SILC_STATUS_ERR_BAD_CLIENT_ID       20
+#define SILC_STATUS_ERR_BAD_CHANNEL_ID      21
+#define SILC_STATUS_ERR_NO_SUCH_CLIENT_ID   22
+#define SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID  23
+#define SILC_STATUS_ERR_NICKNAME_IN_USE     24
+#define SILC_STATUS_ERR_NOT_ON_CHANNEL      25
+#define SILC_STATUS_ERR_USER_NOT_ON_CHANNEL 26
+#define SILC_STATUS_ERR_USER_ON_CHANNEL     27
+#define SILC_STATUS_ERR_NOT_REGISTERED      28
+#define SILC_STATUS_ERR_NOT_ENOUGH_PARAMS   29
+#define SILC_STATUS_ERR_TOO_MANY_PARAMS     30
+#define SILC_STATUS_ERR_PERM_DENIED         31
+#define SILC_STATUS_ERR_BANNED_FROM_SERVER  32
+#define SILC_STATUS_ERR_BAD_PASSWORD        33
+#define SILC_STATUS_ERR_CHANNEL_IS_FULL     34
+#define SILC_STATUS_ERR_NOT_INVITED         35
+#define SILC_STATUS_ERR_BANNED_FROM_CHANNEL 36
+#define SILC_STATUS_ERR_UNKNOWN_MODE        37
+#define SILC_STATUS_ERR_NOT_YOU             38
+#define SILC_STATUS_ERR_NO_CHANNEL_PRIV     39
+#define SILC_STATUS_ERR_NO_CHANNEL_FOPRIV   40
+#define SILC_STATUS_ERR_NO_SERVER_PRIV      41
+#define SILC_STATUS_ERR_NO_ROUTER_PRIV      42
+#define SILC_STATUS_ERR_BAD_NICKNAME        43
+#define SILC_STATUS_ERR_BAD_CHANNEL         44
+#define SILC_STATUS_ERR_AUTH_FAILED         45
+#define SILC_STATUS_ERR_UNKNOWN_ALGORITHM   46
+#define SILC_STATUS_ERR_NO_SUCH_SERVER_ID   47
+/***/
+
+#endif /* SILCSTATUS_H */