updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 30 Mar 2001 13:56:10 +0000 (13:56 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 30 Mar 2001 13:56:10 +0000 (13:56 +0000)
apps/silcd/command.c
doc/draft-riikonen-silc-pp-01.nroff
doc/draft-riikonen-silc-spec-01.nroff
lib/silcclient/client_notify.c

index ccc3cbb6a9ab8b243f2b8911b7f3c57ef4042a16..74426a3b46dbdd37b04a2319c2a0c74fa389809e 100644 (file)
@@ -2517,21 +2517,47 @@ SILC_SERVER_CMD_FUNC(info)
   SilcServerCommandContext cmd = (SilcServerCommandContext)context;
   SilcServer server = cmd->server;
   SilcBuffer packet, idp;
+  unsigned char *tmp;
+  unsigned int tmp_len;
   char *dest_server, *server_info = NULL, *server_name;
   unsigned short ident = silc_command_get_ident(cmd->payload);
   SilcServerEntry entry = NULL;
+  SilcServerID *server_id = NULL;
 
-  SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_INFO, cmd, 1, 1);
+  SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_INFO, cmd, 0, 2);
 
   /* Get server name */
   dest_server = silc_argument_get_arg_type(cmd->args, 1, NULL);
-  if (!dest_server) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
-                                         SILC_STATUS_ERR_NO_SUCH_SERVER);
-    goto out;
+
+  /* Get Server ID */
+  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+  if (tmp) {
+    server_id = silc_id_payload_parse_id(tmp, tmp_len);
+    if (!server_id) {
+      silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
+                                           SILC_STATUS_ERR_NO_SERVER_ID);
+      goto out;
+    }
   }
 
-  if (!strncasecmp(dest_server, server->server_name, strlen(dest_server))) {
+  if (server_id) {
+    /* Check whether we have this server cached */
+    entry = silc_idlist_find_server_by_id(server->local_list,
+                                         server_id, NULL);
+    if (!entry) {
+      entry = silc_idlist_find_server_by_id(server->global_list,
+                                           server_id, NULL);
+      if (!entry && server->server_type == SILC_ROUTER) {
+       silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
+                                             SILC_STATUS_ERR_NO_SUCH_SERVER);
+       goto out;
+      }
+    }
+  }
+
+  if ((!dest_server && !server_id) || 
+      (dest_server && !cmd->pending && 
+       !strncasecmp(dest_server, server->server_name, strlen(dest_server)))) {
     /* Send our reply */
     char info_string[256];
 
@@ -2547,14 +2573,17 @@ SILC_SERVER_CMD_FUNC(info)
     entry = server->id_entry;
   } else {
     /* Check whether we have this server cached */
-    entry = silc_idlist_find_server_by_name(server->global_list,
-                                           dest_server, NULL);
-    if (!entry) {
-      entry = silc_idlist_find_server_by_name(server->local_list,
+    if (!entry && dest_server) {
+      entry = silc_idlist_find_server_by_name(server->global_list,
                                              dest_server, NULL);
+      if (!entry) {
+       entry = silc_idlist_find_server_by_name(server->local_list,
+                                               dest_server, NULL);
+      }
     }
 
-    if (server->server_type == SILC_ROUTER && entry && !entry->server_info) {
+    if (!cmd->pending &&
+       server->server_type == SILC_ROUTER && entry && !entry->server_info) {
       /* Send to the server */
       SilcBuffer tmpbuf;
       unsigned short old_ident;
@@ -2605,6 +2634,9 @@ SILC_SERVER_CMD_FUNC(info)
     }
   }
 
+  if (server_id)
+    silc_free(server_id);
+
   if (!entry) {
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
                                          SILC_STATUS_ERR_NO_SUCH_SERVER);
@@ -2614,7 +2646,7 @@ SILC_SERVER_CMD_FUNC(info)
   idp = silc_id_payload_encode(entry->id, SILC_ID_SERVER);
   if (!server_info)
     server_info = entry->server_info;
-  server_name = dest_server;
+  server_name = entry->server_name;
 
   /* Send the reply */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
@@ -3637,7 +3669,8 @@ SILC_SERVER_CMD_FUNC(cmode)
     silc_server_send_notify_cmode(server, server->router->connection,
                                  server->server_type == SILC_ROUTER ? 
                                  TRUE : FALSE, channel,
-                                 mode_mask, client->id, SILC_ID_CLIENT_LEN,
+                                 mode_mask, client->id, SILC_ID_CLIENT,
+                                 SILC_ID_CLIENT_LEN,
                                  cipher, hmac);
 
   /* Send command reply to sender */
index 03be1d9598eb9e5206a4dbde66557193e5635181..cd71928af7e155ba5ed2581f919e7e83b484b63a 100644 (file)
@@ -1160,11 +1160,7 @@ ID's sent in arguments are sent inside ID Payload.
           Arguments:  (1) [<Client ID>]       (2) <Channel ID>
 
       The <Client ID> is the client that joined to the channel indicated
-      by the <Channel ID>.  The <adding client> and <removing client>
-      indicates the added or removed client in the current invite list.
-      The format of the <adding client> and the <removing client> is
-      defined in the [SILC1] with SILC_COMMAND_INVITE command.  If the
-      <Client ID> is not provided then this
+      by the <Channel ID>.
 
 
 3     SILC_NOTIFY_TYPE_LEAVE
index c74e7cbbcdf151aa34f12fdfcb0ccc68545d4871..09e03cee32cb8b9b81405ac4342d58882a269873 100644 (file)
@@ -2380,13 +2380,16 @@ List of all defined commands in SILC follows.
 
    10   SILC_COMMAND_INFO
 
-        Max Arguments:  1
-            Arguments:  (1) [<server>]
+        Max Arguments:  2
+            Arguments:  (1) [<server>]  (2) [<Server ID>]
 
         This command is used to fetch various information about a server.
         If <server> argument is specified the command must be sent to
         the requested server.
 
+        If the <Server ID> is specified the server information if fetched
+        by the provided Server ID.
+
         Reply messages to the command:
 
         Max Arguments:  4
@@ -2404,6 +2407,8 @@ List of all defined commands in SILC follows.
             SILC_STATUS_ERR_NOT_ENOUGH_PARAMS
             SILC_STATUS_ERR_TOO_MANY_PARAMS
             SILC_STATUS_ERR_NO_SUCH_SERVER
+            SILC_STATUS_ERR_NO_SUCH_SERVER_ID
+            SILC_STATUS_ERR_NO_SERVER_ID
 
 
    11   SILC_COMMAND_CONNECT
index 0aa343ee5680cf1f5afa481cdb4b0d07736d6dce..afb95fc0d52c755f010cdb3d74acc938c02afc61 100644 (file)
@@ -75,6 +75,7 @@ void silc_client_notify_by_server(SilcClient client,
   SilcNotifyType type;
   SilcArgumentPayload args;
 
+  SilcIDPayload idp;
   SilcClientID *client_id = NULL;
   SilcChannelID *channel_id = NULL;
   SilcClientEntry client_entry;
@@ -423,15 +424,28 @@ void silc_client_notify_by_server(SilcClient client,
     if (!tmp)
       goto out;
 
-    client_id = silc_id_payload_parse_id(tmp, tmp_len);
-    if (!client_id)
+    idp = silc_id_payload_parse_data(tmp, tmp_len);
+    if (!idp)
       goto out;
 
     /* Find Client entry */
-    client_entry = 
-      silc_client_get_client_by_id(client, conn, client_id);
-    if (!client_entry)
-      goto out;
+    if (silc_id_payload_get_type(idp) == SILC_ID_CLIENT) {
+      client_id = silc_id_payload_parse_id(tmp, tmp_len);
+      if (!client_id) {
+       silc_id_payload_free(idp);
+       goto out;
+      }
+
+      client_entry = silc_client_get_client_by_id(client, conn, client_id);
+      if (!client_entry) {
+       silc_id_payload_free(idp);
+       goto out;
+      }
+    } else {
+      client_entry = NULL;
+    }
+
+    silc_id_payload_free(idp);
 
     /* Get the mode */
     tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
@@ -584,7 +598,6 @@ void silc_client_notify_by_server(SilcClient client,
     channel = (SilcChannelEntry)id_cache->context;
 
     /* Free the old ID */
-    silc_free(channel_id);
     silc_free(channel->id);
 
     /* Get the new ID */