--- upstream/dynamips-0.2.5/hypervisor.c 2007/10/06 16:01:44 1 +++ upstream/dynamips-0.2.7-RC2/hypervisor.c 2007/10/06 16:24:54 8 @@ -1,5 +1,5 @@ /* - * Cisco 7200 (Predator) simulation platform. + * Cisco router simulation platform. * Copyright (c) 2006 Christophe Fillot (cf@utc.fr) * * Hypervisor routines. @@ -32,10 +32,15 @@ #include "parser.h" #include "net.h" #include "registry.h" -#include "mips64.h" +#include "cpu.h" +#include "vm.h" #include "dynamips.h" #include "dev_c7200.h" #include "dev_c3600.h" +#include "dev_c2691.h" +#include "dev_c3725.h" +#include "dev_c3745.h" +#include "dev_c2600.h" #include "hypervisor.h" #include "net_io.h" #include "net_io_bridge.h" @@ -58,6 +63,20 @@ return(0); } +/* Parser test */ +static int cmd_parser_test(hypervisor_conn_t *conn,int argc,char *argv[]) +{ + int i; + + for(i=0;iactive) { - if (!m_fgets(buffer,sizeof(buffer),conn->in)) + if (!fgets(buffer,sizeof(buffer),conn->in)) break; if (!*buffer) continue; /* Tokenize command line */ - tokens = NULL; - res = parser_tokenize(buffer,&tok_list,&tok_count); + res = parser_scan_buffer(&ctx,buffer,strlen(buffer)); - if (res != 0) { - hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"Parse error: %s", - parser_strerror(res)); - continue; - } + if (res != 0) { + tokens = NULL; - if (tok_count < 2) { - hypervisor_send_reply(conn,HSC_ERR_PARSING,1, - "At least a module and a command " - "must be specified"); - goto free_tokens; - } + if (ctx.error != 0) { + hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"Parse error: %s", + parser_strerror(&ctx)); + goto free_tokens; + } + + if (ctx.tok_count < 2) { + hypervisor_send_reply(conn,HSC_ERR_PARSING,1, + "At least a module and a command " + "must be specified"); + goto free_tokens; + } - /* Map token list to an array */ - tokens = parser_map_array(tok_list,tok_count); + /* Map token list to an array */ + tokens = parser_map_array(&ctx); - if (!tokens) { - hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"No memory"); - goto free_tokens; - } - - /* Execute command */ - m_log("hypervisor_exec","%s\n",buffer); - hypervisor_exec_cmd(conn,tokens[0],tokens[1],tok_count-2,&tokens[2]); + if (!tokens) { + hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"No memory"); + goto free_tokens; + } + + /* Execute command */ + //m_log("hypervisor_exec","%s\n",buffer); + hypervisor_exec_cmd(conn,tokens[0],tokens[1],ctx. + tok_count-2,&tokens[2]); - free_tokens: - free(tokens); - parser_free_tokens(tok_list); + free_tokens: + free(tokens); + tokens = NULL; + parser_context_free(&ctx); + } } + free(tokens); + parser_context_free(&ctx); return NULL; } @@ -518,8 +552,13 @@ hypervisor_atmsw_init(); hypervisor_ethsw_init(); hypervisor_vm_init(); + hypervisor_vm_debug_init(); hypervisor_c7200_init(); hypervisor_c3600_init(); + hypervisor_c2691_init(); + hypervisor_c3725_init(); + hypervisor_c3745_init(); + hypervisor_c2600_init(); signal(SIGPIPE,sigpipe_handler); @@ -534,7 +573,7 @@ } /* Start accepting connections */ - printf("Hypervisor TCP control server started.\n"); + printf("Hypervisor TCP control server started (port %d).\n",tcp_port); hypervisor_running = TRUE; while(hypervisor_running) {