From: Pekka Riikonen Date: Fri, 30 Mar 2001 13:56:10 +0000 (+0000) Subject: updates. X-Git-Tag: SILC.0.1~72 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=ed701f7bcca82b686cb7dc566757c9eefb66de96 updates. --- diff --git a/apps/silcd/command.c b/apps/silcd/command.c index ccc3cbb6..74426a3b 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -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 */ diff --git a/doc/draft-riikonen-silc-pp-01.nroff b/doc/draft-riikonen-silc-pp-01.nroff index 03be1d95..cd71928a 100644 --- a/doc/draft-riikonen-silc-pp-01.nroff +++ b/doc/draft-riikonen-silc-pp-01.nroff @@ -1160,11 +1160,7 @@ ID's sent in arguments are sent inside ID Payload. Arguments: (1) [] (2) The is the client that joined to the channel indicated - by the . The and - indicates the added or removed client in the current invite list. - The format of the and the is - defined in the [SILC1] with SILC_COMMAND_INVITE command. If the - is not provided then this + by the . 3 SILC_NOTIFY_TYPE_LEAVE diff --git a/doc/draft-riikonen-silc-spec-01.nroff b/doc/draft-riikonen-silc-spec-01.nroff index c74e7cbb..09e03cee 100644 --- a/doc/draft-riikonen-silc-spec-01.nroff +++ b/doc/draft-riikonen-silc-spec-01.nroff @@ -2380,13 +2380,16 @@ List of all defined commands in SILC follows. 10 SILC_COMMAND_INFO - Max Arguments: 1 - Arguments: (1) [] + Max Arguments: 2 + Arguments: (1) [] (2) [] This command is used to fetch various information about a server. If argument is specified the command must be sent to the requested server. + If the 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 diff --git a/lib/silcclient/client_notify.c b/lib/silcclient/client_notify.c index 0aa343ee..afb95fc0 100644 --- a/lib/silcclient/client_notify.c +++ b/lib/silcclient/client_notify.c @@ -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 */