GNU General Public License for more details.
*/
-/*
- * $Id$
- * $Log$
- * Revision 1.1 2000/06/27 11:36:56 priikone
- * Initial revision
- *
- *
- */
+/* $Id$ */
#include "serverincludes.h"
#include "server_internal.h"
#include "command_reply.h"
/* Server command reply list. Not all commands have reply function as
- they are never sent as forwarded command packets by server. More
- maybe added later if need appears. */
+ they are never sent by server. More maybe added later if need appears. */
SilcServerCommandReply silc_command_reply_list[] =
{
SILC_SERVER_CMD_REPLY(join, JOIN),
+ SILC_SERVER_CMD_REPLY(identify, IDENTIFY),
{ NULL, 0 },
};
SilcCommandPayload payload;
/* Get command reply payload from packet */
- payload = silc_command_parse_payload(buffer);
+ payload = silc_command_payload_parse(buffer);
if (!payload) {
/* Silently ignore bad reply packet */
SILC_LOG_DEBUG(("Bad command reply packet"));
ctx->server = server;
ctx->sock = sock;
ctx->payload = payload;
+ ctx->args = silc_command_get_args(ctx->payload);
/* Check for pending commands and mark to be exeucted */
SILC_SERVER_COMMAND_CHECK_PENDING(ctx);
SilcServer server = cmd->server;
SilcCommandStatus status;
SilcChannelID *id;
- SilcChannelList *entry;
- unsigned int argc;
+ SilcChannelEntry entry;
+ unsigned int len;
unsigned char *id_string;
char *channel_name, *tmp;
-#define LCC(x) server->local_list->channel_cache[(x) - 32]
-#define LCCC(x) server->local_list->channel_cache_count[(x) - 32]
-
SILC_LOG_DEBUG(("Start"));
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK)
goto out;
/* Get channel name */
- tmp = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!tmp)
goto out;
/* Get channel ID */
- id_string = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ id_string = silc_argument_get_arg_type(cmd->args, 3, &len);
if (!id_string)
goto out;
channel_name = strdup(tmp);
/* Add the channel to our local list. */
- id = silc_id_str2id(id_string, SILC_ID_CHANNEL);
- silc_idlist_add_channel(&server->local_list->channels, channel_name,
- SILC_CHANNEL_MODE_NONE, id,
- server->id_entry->router, NULL, &entry);
- LCCC(channel_name[0]) = silc_idcache_add(&LCC(channel_name[0]),
- LCCC(channel_name[0]),
- channel_name, SILC_ID_CHANNEL,
- (void *)id, (void *)entry);
+ id = silc_id_payload_parse_id(id_string, len);
+ entry = silc_idlist_add_channel(server->local_list, channel_name,
+ SILC_CHANNEL_MODE_NONE, id,
+ server->id_entry->router, NULL);
+ if (!entry) {
+ silc_free(channel_name);
+ silc_free(id);
+ goto out;
+ }
+
entry->global_users = TRUE;
/* Execute pending JOIN command so that the client who originally
out:
silc_server_command_reply_free(cmd);
-#undef LCC
-#undef LCCC
+}
+
+/* Received reply for forwarded IDENTIFY command. We have received the
+ requested identify information now and we will cache it. After this we
+ will call the pending command so that the requestee gets the information
+ after all. */
+
+SILC_SERVER_CMD_REPLY_FUNC(identify)
+{
+ SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcServer server = cmd->server;
+ SilcCommandStatus status;
+
+ SILC_LOG_DEBUG(("Start"));
+
+ SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
+ if (status != SILC_STATUS_OK)
+ goto out;
+
+ /* Process one identify reply */
+ if (status == SILC_STATUS_OK) {
+ SilcClientID *client_id;
+ unsigned int len;
+ unsigned char *id_data;
+ char *nickname, *username;
+
+ id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
+ nickname = silc_argument_get_arg_type(cmd->args, 3, NULL);
+ if (!id_data || !nickname)
+ goto out;
+
+ username = silc_argument_get_arg_type(cmd->args, 4, NULL);
+ client_id = silc_id_payload_parse_id(id_data, len);
+
+ /* Add the client always to our global list. If normal or router server
+ ever gets here it means they don't have this client's information
+ in their cache. */
+ silc_idlist_add_client(server->global_list, strdup(nickname),
+ username, NULL, client_id, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
+ }
+
+ if (status == SILC_STATUS_LIST_START) {
+
+ }
+
+ if (status == SILC_STATUS_LIST_END) {
+
+ }
+
+ /* Execute pending IDENTIFY command so that the client who originally
+ requested the identify information will get it after all. */
+ SILC_SERVER_COMMAND_EXEC_PENDING(cmd, SILC_COMMAND_IDENTIFY);
+
+ out:
+ silc_server_command_reply_free(cmd);
}