cmd->sock->user_data, cmd->payload, FALSE, \
silc_command_get(cmd->payload), status)
+/* All functions that call the COMMAND_CHECK_STATUS or the
+ COMMAND_CHECK_STATUS_LIST macros must have out: goto label. */
+
+#define COMMAND_CHECK_STATUS \
+do { \
+ SILC_LOG_DEBUG(("Start")); \
+ SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); \
+ if (status != SILC_STATUS_OK) { \
+ COMMAND_REPLY_ERROR; \
+ goto out; \
+ } \
+} while(0)
+
+#define COMMAND_CHECK_STATUS_LIST \
+do { \
+ SILC_LOG_DEBUG(("Start")); \
+ SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); \
+ if (status != SILC_STATUS_OK && \
+ status != SILC_STATUS_LIST_START && \
+ status != SILC_STATUS_LIST_ITEM && \
+ status != SILC_STATUS_LIST_END) { \
+ COMMAND_REPLY_ERROR; \
+ goto out; \
+ } \
+} while(0)
+
/* Process received command reply. */
void silc_client_command_reply_process(SilcClient client,
char *realname = NULL;
uint32 idle = 0, mode = 0;
SilcBuffer channels = NULL;
+ unsigned char *fingerprint;
+ uint32 fingerprint_len;
argc = silc_argument_get_arg_num(cmd->args);
if (tmp)
SILC_GET32_MSB(idle, tmp);
+ fingerprint = silc_argument_get_arg_type(cmd->args, 9, &fingerprint_len);
+
/* Check if we have this client cached already. */
if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id,
NULL, NULL,
silc_hash_client_id_compare, NULL,
&id_cache)) {
SILC_LOG_DEBUG(("Adding new client entry"));
-
- client_entry = silc_calloc(1, sizeof(*client_entry));
- client_entry->id = client_id;
- silc_parse_nickname(nickname, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
- client_entry->username = strdup(username);
- if (realname)
- client_entry->realname = strdup(realname);
- client_entry->mode = mode;
-
- /* Add client to cache */
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_id, (void *)client_entry, FALSE);
+ client_entry =
+ silc_client_add_client(cmd->client, conn, nickname, username, realname,
+ client_id, mode);
} else {
client_entry = (SilcClientEntry)id_cache->context;
- if (client_entry->nickname)
- silc_free(client_entry->nickname);
- if (client_entry->server)
- silc_free(client_entry->server);
- if (client_entry->username)
- silc_free(client_entry->username);
- if (client_entry->realname)
- silc_free(client_entry->realname);
- client_entry->mode = mode;
-
- SILC_LOG_DEBUG(("Updating client entry"));
-
- silc_parse_nickname(nickname, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
- client_entry->username = strdup(username);
- if (realname)
- client_entry->realname = strdup(realname);
-
- /* Remove the old cache entry and create a new one */
- silc_idcache_del_by_context(conn->client_cache, client_entry);
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_entry->id, client_entry, FALSE);
+ silc_client_update_client(cmd->client, conn, client_entry,
+ nickname, username, realname, mode);
silc_free(client_id);
}
+ if (fingerprint && !client_entry->fingerprint) {
+ client_entry->fingerprint =
+ silc_calloc(fingerprint_len,
+ sizeof(*client_entry->fingerprint));
+ memcpy(client_entry->fingerprint, fingerprint, fingerprint_len);
+ client_entry->fingerprint_len = fingerprint_len;
+ }
+
+ if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING)
+ client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
+
/* Notify application */
if (!cmd->callback)
COMMAND_REPLY((ARGS, client_entry, nickname, username, realname,
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcCommandStatus status;
- unsigned char *tmp;
- SILC_LOG_DEBUG(("Start"));
+ COMMAND_CHECK_STATUS_LIST;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_START &&
- status != SILC_STATUS_LIST_ITEM &&
- status != SILC_STATUS_LIST_END) {
- COMMAND_REPLY_ERROR;
- goto out;
- }
-
- /* Display one whois reply */
- if (status == SILC_STATUS_OK)
- silc_client_command_reply_whois_save(cmd, status);
-
- /* List */
- if (status == SILC_STATUS_LIST_START ||
- status == SILC_STATUS_LIST_ITEM ||
- status == SILC_STATUS_LIST_END)
- silc_client_command_reply_whois_save(cmd, status);
+ /* Save WHOIS info */
+ silc_client_command_reply_whois_save(cmd, status);
/* Pending callbacks are not executed if this was an list entry */
if (status != SILC_STATUS_OK &&
return;
}
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_WHOIS);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_WHOIS);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOIS);
silc_client_command_reply_free(cmd);
}
SilcIDCacheEntry id_cache = NULL;
SilcClientEntry client_entry = NULL;
uint32 len;
- unsigned char *id_data, *tmp;
+ unsigned char *id_data;
char *nickname, *username;
char *realname = NULL;
- SILC_LOG_DEBUG(("Start"));
+ COMMAND_CHECK_STATUS_LIST;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_START &&
- status != SILC_STATUS_LIST_ITEM &&
- status != SILC_STATUS_LIST_END) {
- COMMAND_REPLY_ERROR;
- goto out;
- }
-
id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
if (!id_data) {
COMMAND_REPLY_ERROR;
- return;
+ goto out;
}
client_id = silc_id_payload_parse_id(id_data, len);
if (!client_id) {
COMMAND_REPLY_ERROR;
- return;
+ goto out;
}
/* Get the client entry, if exists */
realname = silc_argument_get_arg_type(cmd->args, 5, &len);
if (!nickname || !username) {
COMMAND_REPLY_ERROR;
- return;
+ goto out;
}
+
/* Notify application. We don't save any history information to any
cache. Just pass the data to the application for displaying on
the screen. */
return;
}
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_WHOIS);
-
out:
- SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOIS);
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_WHOWAS);
+ SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOWAS);
silc_client_command_reply_free(cmd);
}
silc_hash_client_id_compare, NULL,
&id_cache)) {
SILC_LOG_DEBUG(("Adding new client entry"));
-
- client_entry = silc_calloc(1, sizeof(*client_entry));
- client_entry->id = silc_id_dup(client_id, id_type);
- silc_parse_nickname(name, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
- if (info)
- client_entry->username = strdup(info);
-
- /* Add client to cache */
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_entry->id, (void *)client_entry, FALSE);
+ client_entry =
+ silc_client_add_client(cmd->client, conn, name, info, NULL,
+ silc_id_dup(client_id, id_type), 0);
} else {
client_entry = (SilcClientEntry)id_cache->context;
- if (client_entry->nickname)
- silc_free(client_entry->nickname);
- if (client_entry->server)
- silc_free(client_entry->server);
- if (info && client_entry->username)
- silc_free(client_entry->username);
-
- SILC_LOG_DEBUG(("Updating client entry"));
-
- silc_parse_nickname(name, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
-
- if (info)
- client_entry->username = strdup(info);
-
- /* Remove the old cache entry and create a new one */
- silc_idcache_del_by_context(conn->client_cache, client_entry);
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_entry->id, client_entry, FALSE);
+ silc_client_update_client(cmd->client, conn, client_entry,
+ name, info, NULL, 0);
}
+ if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING)
+ client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
+
/* Notify application */
COMMAND_REPLY((ARGS, client_entry, name, info));
break;
server_entry = silc_calloc(1, sizeof(*server_entry));
server_entry->server_id = silc_id_dup(server_id, id_type);
- server_entry->server_name = strdup(name);
+ if (name)
+ server_entry->server_name = strdup(name);
if (info)
server_entry->server_info = strdup(info);
/* Check if we have this channel cached already. */
if (!silc_idcache_find_by_id_one(conn->channel_cache,
(void *)channel_id, &id_cache)) {
+ if (!name)
+ break;
+
SILC_LOG_DEBUG(("Adding new channel entry"));
channel_entry = silc_client_new_channel_id(client, conn->sock,
- name, 0, idp);
+ strdup(name), 0, idp);
} else {
channel_entry = (SilcChannelEntry)id_cache->context;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcCommandStatus status;
- unsigned char *tmp;
-
- SILC_LOG_DEBUG(("Start"));
-
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_START &&
- status != SILC_STATUS_LIST_ITEM &&
- status != SILC_STATUS_LIST_END) {
- COMMAND_REPLY_ERROR;
- goto out;
- }
- /* Save one IDENTIFY entry */
- if (status == SILC_STATUS_OK)
- silc_client_command_reply_identify_save(cmd, status);
+ COMMAND_CHECK_STATUS_LIST;
- /* List */
- if (status == SILC_STATUS_LIST_START ||
- status == SILC_STATUS_LIST_ITEM ||
- status == SILC_STATUS_LIST_END)
- silc_client_command_reply_identify_save(cmd, status);
+ /* Save IDENTIFY info */
+ silc_client_command_reply_identify_save(cmd, status);
/* Pending callbacks are not executed if this was an list entry */
if (status != SILC_STATUS_OK &&
return;
}
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_IDENTIFY);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_IDENTIFY);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_IDENTIFY);
silc_client_command_reply_free(cmd);
}
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot set nickname: %s",
- silc_client_command_status_message(status));
+ silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
}
/* Notify application */
COMMAND_REPLY((ARGS, conn->local_entry));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_NICK);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_NICK);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_NICK);
silc_client_command_reply_free(cmd);
}
unsigned char *tmp, *name, *topic;
uint32 usercount = 0;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_START &&
- status != SILC_STATUS_LIST_ITEM &&
- status != SILC_STATUS_LIST_END) {
- COMMAND_REPLY_ERROR;
- goto out;
- }
+ COMMAND_CHECK_STATUS_LIST;
name = silc_argument_get_arg_type(cmd->args, 3, NULL);
topic = silc_argument_get_arg_type(cmd->args, 4, NULL);
return;
}
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LIST);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LIST);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_LIST);
silc_client_command_reply_free(cmd);
}
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
- SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_TOPIC);
- silc_client_command_reply_free(cmd);
- return;
+ goto out;
}
argc = silc_argument_get_arg_num(cmd->args);
/* Notify application */
COMMAND_REPLY((ARGS, channel, topic));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_TOPIC);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_TOPIC);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_TOPIC);
silc_client_command_reply_free(cmd);
}
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
- SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INVITE);
- silc_client_command_reply_free(cmd);
- return;
+ goto out;
}
/* Take Channel ID */
/* Notify application */
COMMAND_REPLY((ARGS, channel, tmp));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_INVITE);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_INVITE);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INVITE);
silc_client_command_reply_free(cmd);
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
+ SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_KILL);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_KILL);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_KILL);
silc_client_command_reply_free(cmd);
}
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
- SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INFO);
- silc_client_command_reply_free(cmd);
- return;
+ goto out;
}
/* Get server ID */
/* Notify application */
COMMAND_REPLY((ARGS, server, server->server_name, server->server_info));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_INFO);
-
out:
- if (server_id)
- silc_free(server_id);
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_INFO);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INFO);
+ silc_free(server_id);
silc_client_command_reply_free(cmd);
}
curtime = time(NULL);
id = silc_id_str2id(cmd->packet->src_id, cmd->packet->src_id_len,
cmd->packet->src_id_type);
- if (!id) {
+ if (!id || !conn->ping) {
COMMAND_REPLY_ERROR;
goto out;
}
for (i = 0; i < conn->ping_count; i++) {
+ if (!conn->ping[i].dest_id)
+ continue;
if (SILC_ID_SERVER_COMPARE(conn->ping[i].dest_id, id)) {
diff = curtime - conn->ping[i].start_time;
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_PING);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_PING);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_PING);
silc_client_command_reply_free(cmd);
}
SilcChannelUser chu;
uint32 argc, mode, len, list_count;
char *topic, *tmp, *channel_name = NULL, *hmac;
- SilcBuffer keyp = NULL, client_id_list, client_mode_list;
+ SilcBuffer keyp = NULL, client_id_list = NULL, client_mode_list = NULL;
int i;
SILC_LOG_DEBUG(("Start"));
/* Get topic */
topic = silc_argument_get_arg_type(cmd->args, 10, NULL);
+ /* If we have the channel entry, remove it and create a new one */
+ channel = silc_client_get_channel(cmd->client, conn, channel_name);
+ if (channel)
+ silc_client_del_channel(cmd->client, conn, channel);
+
/* Save received Channel ID. This actually creates the channel */
channel = silc_client_new_channel_id(cmd->client, cmd->sock, channel_name,
mode, idp);
silc_hash_client_id_compare, NULL,
&id_cache)) {
/* No, we don't have it, add entry for it. */
- client_entry = silc_calloc(1, sizeof(*client_entry));
- client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT);
- silc_idcache_add(conn->client_cache, NULL, client_entry->id,
- (void *)client_entry, FALSE);
+ client_entry =
+ silc_client_add_client(cmd->client, conn, NULL, NULL, NULL,
+ silc_id_dup(client_id, SILC_ID_CLIENT), 0);
} else {
/* Yes, we have it already */
client_entry = (SilcClientEntry)id_cache->context;
NULL, topic, hmac, list_count, client_id_list,
client_mode_list));
- /* Execute any pending command callbacks */
+ out:
SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_JOIN);
+ SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_JOIN);
+ silc_client_command_reply_free(cmd);
if (keyp)
silc_buffer_free(keyp);
- silc_buffer_free(client_id_list);
- silc_buffer_free(client_mode_list);
-
- out:
- SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_JOIN);
- silc_client_command_reply_free(cmd);
+ if (client_id_list)
+ silc_buffer_free(client_id_list);
+ if (client_mode_list)
+ silc_buffer_free(client_mode_list);
}
/* Received reply for MOTD command */
/* Notify application */
COMMAND_REPLY((ARGS, motd));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_MOTD);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_MOTD);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_MOTD);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS, mode));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_UMODE);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_UMODE);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_UMODE);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS, channel, mode));
- silc_free(channel_id);
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CMODE);
+ silc_free(channel_id);
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CMODE);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_CMODE);
silc_client_command_reply_free(cmd);
}
SilcClientEntry client_entry;
SilcChannelEntry channel;
SilcChannelUser chu;
- unsigned char *tmp, *id;
+ unsigned char *modev, *tmp, *id;
uint32 len, mode;
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
}
/* Get channel mode */
- tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
- if (!tmp) {
+ modev = silc_argument_get_arg_type(cmd->args, 2, NULL);
+ if (!modev) {
COMMAND_REPLY_ERROR;
goto out;
}
client_entry = (SilcClientEntry)id_cache->context;
/* Save the mode */
- SILC_GET32_MSB(mode, tmp);
+ SILC_GET32_MSB(mode, modev);
+ silc_list_start(channel->clients);
while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
if (chu->client == client_entry) {
chu->mode = mode;
silc_free(client_id);
silc_free(channel_id);
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CUMODE);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CUMODE);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_CUMODE);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_KICK);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_KICK);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_KICK);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SILCOPER);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SILCOPER);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_SILCOPER);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_OPER);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_OPER);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_OPER);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CONNECT);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CONNECT);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_CONNECT);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS, channel, tmp));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_BAN);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_BAN);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_BAN);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CLOSE);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CLOSE);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_CLOSE);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SHUTDOWN);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SHUTDOWN);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_SHUTDOWN);
silc_client_command_reply_free(cmd);
}
/* Notify application */
COMMAND_REPLY((ARGS));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LEAVE);
-
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LEAVE);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_LEAVE);
silc_client_command_reply_free(cmd);
}
SilcChannelEntry channel;
SilcChannelUser chu;
SilcChannelID *channel_id = NULL;
- SilcBuffer client_id_list;
- SilcBuffer client_mode_list;
+ SilcBuffer client_id_list = NULL;
+ SilcBuffer client_mode_list = NULL;
unsigned char *tmp;
uint32 tmp_len, list_count;
int i;
silc_hash_client_id_compare, NULL,
&id_cache);
- if (!id_cache || !((SilcClientEntry)id_cache->context)->username) {
+ if (!id_cache || !((SilcClientEntry)id_cache->context)->username ||
+ !((SilcClientEntry)id_cache->context)->realname) {
+
+ if (id_cache && id_cache->context) {
+ SilcClientEntry client_entry = (SilcClientEntry)id_cache->context;
+ if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) {
+ client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
+ silc_buffer_pull(client_id_list, idp_len);
+ silc_buffer_pull(client_mode_list, 4);
+ continue;
+ }
+ client_entry->status |= SILC_CLIENT_STATUS_RESOLVING;
+ }
+
/* No we don't have it (or it is incomplete in information), query
it from the server. Assemble argument table that will be sent
for the WHOIS command later. */
/* Notify application */
COMMAND_REPLY((ARGS, channel, list_count, client_id_list, client_mode_list));
- /* Execute any pending command callbacks */
- SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
-
- silc_buffer_free(client_id_list);
- silc_buffer_free(client_mode_list);
-
out:
- if (channel_id)
- silc_free(channel_id);
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_USERS);
silc_client_command_reply_free(cmd);
+ silc_free(channel_id);
+ if (client_id_list)
+ silc_buffer_free(client_id_list);
+ if (client_mode_list)
+ silc_buffer_free(client_mode_list);
}
/* Received command reply to GETKEY command. WE've received the remote
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
}
tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
- if (!tmp)
+ if (!tmp) {
+ COMMAND_REPLY_ERROR;
goto out;
+ }
idp = silc_id_payload_parse_data(tmp, len);
- if (!idp)
+ if (!idp) {
+ COMMAND_REPLY_ERROR;
goto out;
+ }
/* Get the public key payload */
tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
- if (!tmp)
- goto out;
-
- /* Decode the public key */
-
- SILC_GET16_MSB(pk_len, tmp);
- SILC_GET16_MSB(type, tmp + 2);
- pk = tmp + 4;
-
- if (type != SILC_SKE_PK_TYPE_SILC)
- goto out;
-
- if (!silc_pkcs_public_key_decode(pk, pk_len, &public_key))
- goto out;
-
+ if (tmp) {
+ /* Decode the public key */
+ SILC_GET16_MSB(pk_len, tmp);
+ SILC_GET16_MSB(type, tmp + 2);
+ pk = tmp + 4;
+
+ if (type != SILC_SKE_PK_TYPE_SILC) {
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ if (!silc_pkcs_public_key_decode(pk, pk_len, &public_key)) {
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+ }
+
id_type = silc_id_payload_get_type(idp);
if (id_type == SILC_ID_CLIENT) {
/* Received client's public key */
(void *)client_id,
NULL, NULL,
silc_hash_client_id_compare, NULL,
- &id_cache))
+ &id_cache)) {
+ COMMAND_REPLY_ERROR;
goto out;
+ }
client_entry = (SilcClientEntry)id_cache->context;
/* Received server's public key */
server_id = silc_id_payload_get_id(idp);
if (!silc_idcache_find_by_id_one(conn->server_cache, (void *)server_id,
- &id_cache))
+ &id_cache)) {
+ COMMAND_REPLY_ERROR;
goto out;
+ }
server_entry = (SilcServerEntry)id_cache->context;
}
out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_GETKEY);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_GETKEY);
if (idp)
silc_id_payload_free(idp);