static void silc_server_command_status_data2(SilcServerCommand cmd, SilcCommand command, SilcStatus status, SilcStatus error, SilcUInt32 arg_type1, const unsigned char *arg1, SilcUInt32 arg_len1, SilcUInt32 arg_type2, const unsigned char *arg2, SilcUInt32 arg_len2) { SilcBuffer buffer; /* Statistics */ cmd->thread->server->stat.commands_sent++; SILC_LOG_DEBUG(("Sending command status %d", status)); buffer = silc_command_reply_payload_encode_va(command, status, 0, silc_command_get_ident(cmd->payload), 2, arg_type1, arg1, arg_len1, arg_type2, arg2, arg_len2); silc_packet_send(cmd->packet->stream, SILC_PACKET_COMMAND_REPLY, 0, buffer->data, silc_buffer_len(buffer)); silc_buffer_free(buffer); }
void silc_server_command_reply_process(SilcServer server, SilcPacketStream sock, SilcBuffer buffer) { SilcIDListData idata = silc_packet_get_context(sock); SilcServerCommandReply *cmd; SilcServerCommandReplyContext ctx; SilcCommandPayload payload; SilcCommand command; SILC_LOG_DEBUG(("Start")); /* Get command reply payload from packet */ payload = silc_command_payload_parse(buffer->data, silc_buffer_len(buffer)); if (!payload) { /* Silently ignore bad reply packet */ SILC_LOG_DEBUG(("Bad command reply packet")); return; } /* Allocate command reply context. This must be free'd by the command reply routine receiving it. */ ctx = silc_calloc(1, sizeof(*ctx)); ctx->server = server; ctx->sock = sock; ctx->payload = payload; ctx->args = silc_command_get_args(ctx->payload); ctx->ident = silc_command_get_ident(ctx->payload); command = silc_command_get(ctx->payload); silc_packet_stream_ref(sock); /* Client is not allowed to send reply to all commands */ if (idata->conn_type == SILC_CONN_CLIENT && command != SILC_COMMAND_WHOIS) { silc_server_command_reply_free(ctx); return; } /* Check for pending commands and mark to be exeucted */ ctx->callbacks = silc_server_command_pending_check(server, command, ctx->ident, &ctx->callbacks_count); /* Execute command reply */ for (cmd = silc_command_reply_list; cmd->cb; cmd++) if (cmd->cmd == command) break; if (cmd == NULL || !cmd->cb) { silc_server_command_reply_free(ctx); return; } cmd->cb(ctx, NULL); }
static void silc_server_command_status_reply(SilcServerCommand cmd, SilcCommand command, SilcStatus status, SilcStatus error) { SilcBuffer buffer; /* Statistics */ cmd->thread->server->stat.commands_sent++; SILC_LOG_DEBUG(("Sending command status %d", status)); buffer = silc_command_reply_payload_encode_va(command, status, error, silc_command_get_ident(cmd->payload), 0); silc_packet_send(cmd->packet->stream, SILC_PACKET_COMMAND_REPLY, 0, buffer->data, silc_buffer_len(buffer)); silc_buffer_free(buffer); }