+ silc_server_command_reply_free(cmd);
+ return;
+
+ err:
+ silc_server_command_process_error(cmd, error);
+ silc_server_command_reply_free(cmd);
+}
+
+/* Received reply fro INFO command. Cache the server and its information */
+
+SILC_SERVER_CMD_REPLY_FUNC(info)
+{
+ SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcServer server = cmd->server;
+ SilcStatus status, error;
+ SilcServerEntry entry;
+ SilcServerID *server_id;
+ SilcUInt32 tmp_len;
+ unsigned char *tmp, *name;
+
+ COMMAND_CHECK_STATUS;
+
+ /* Get Server ID */
+ tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+ if (!tmp)
+ goto out;
+ server_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
+ if (!server_id)
+ goto out;
+
+ /* Get the name */
+ name = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
+ if (!name)
+ goto out;
+
+ entry = silc_idlist_find_server_by_id(server->local_list, server_id,
+ FALSE, NULL);
+ if (!entry) {
+ entry = silc_idlist_find_server_by_id(server->global_list, server_id,
+ FALSE, NULL);
+ if (!entry) {
+ /* Add the server to global list */
+ server_id = silc_id_dup(server_id, SILC_ID_SERVER);
+ entry = silc_idlist_add_server(server->global_list, strdup(name), 0,
+ server_id, cmd->sock->user_data,
+ cmd->sock);
+ if (!entry) {
+ silc_free(server_id);
+ goto out;
+ }
+ entry->data.status |= SILC_IDLIST_STATUS_REGISTERED;
+ }
+ }
+
+ /* Get the info string */
+ tmp = silc_argument_get_arg_type(cmd->args, 4, &tmp_len);
+ if (tmp_len > 256)
+ tmp = NULL;
+
+ entry->server_info = tmp ? strdup(tmp) : NULL;
+
+ out:
+ SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_INFO);
+ err:
+ silc_server_command_reply_free(cmd);
+}
+
+/* Received reply fro MOTD command. */
+
+SILC_SERVER_CMD_REPLY_FUNC(motd)
+{
+ SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcServer server = cmd->server;
+ SilcStatus status, error;
+ SilcServerEntry entry = NULL;
+ SilcServerID *server_id;
+ SilcUInt32 tmp_len;
+ unsigned char *tmp;
+
+ COMMAND_CHECK_STATUS;
+
+ /* Get Server ID */
+ tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+ if (!tmp)
+ goto out;
+ server_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
+ if (!server_id)
+ goto out;
+
+ entry = silc_idlist_find_server_by_id(server->local_list, server_id,
+ TRUE, NULL);
+ if (!entry) {
+ entry = silc_idlist_find_server_by_id(server->global_list, server_id,
+ TRUE, NULL);
+ if (!entry) {
+ SilcBuffer buffer;
+
+ /* If router did not find such Server ID in its lists then this must
+ be bogus client or some router in the net is buggy. */
+ if (server->server_type != SILC_SERVER)
+ goto out;
+
+ /* entry isn't known so we IDENTIFY it. otherwise the
+ silc_server_command_motd won't know about it and tell
+ the client that there is no such server */
+ buffer = silc_command_payload_encode_va(SILC_COMMAND_IDENTIFY,
+ ++server->cmd_ident, 5,
+ 1, NULL, 0, 2, NULL, 0,
+ 3, NULL, 0, 4, NULL, 0,
+ 5, tmp, tmp_len);
+ silc_server_packet_send(server, SILC_PRIMARY_ROUTE(server),
+ SILC_PACKET_COMMAND, 0, buffer->data,
+ buffer->len, TRUE);
+ silc_server_command_pending(server, SILC_COMMAND_IDENTIFY,
+ server->cmd_ident,
+ silc_server_command_reply_motd,
+ cmd);
+ silc_buffer_free(buffer);
+ return;
+ }
+ }
+
+ /* Get the motd */
+ tmp = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
+ if (tmp_len > 256)
+ tmp = NULL;
+
+ entry->motd = tmp;