⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dynamips.c

📁 思科路由器仿真器,用来仿7200系列得,可以在电脑上模拟路由器
💻 C
📖 第 1 页 / 共 2 页
字号:
         /* NVRAM size */         case 'n':            vm->nvram_size = strtol(optarg, NULL, 10);            printf("NVRAM size set to %d KB.\n",vm->nvram_size);            break;         /* Execution area size */         case OPT_EXEC_AREA:            vm->exec_area_size = atoi(optarg);            break;         /* PCMCIA disk0 size */         case OPT_DISK0_SIZE:            vm->pcmcia_disk_size[0] = atoi(optarg);            printf("PCMCIA ATA disk0 size set to %u MB.\n",                   vm->pcmcia_disk_size[0]);            break;         /* PCMCIA disk1 size */         case OPT_DISK1_SIZE:            vm->pcmcia_disk_size[1] = atoi(optarg);            printf("PCMCIA ATA disk1 size set to %u MB.\n",                   vm->pcmcia_disk_size[1]);            break;         /* Config Register */         case 'c':            vm->conf_reg_setup = strtol(optarg, NULL, 0);            printf("Config. Register set to 0x%x.\n",vm->conf_reg_setup);            break;         /* IOS configuration file */         case 'C':            vm_ios_set_config(vm,optarg);            break;         /* Use physical memory to emulate RAM (no-mapped file) */         case 'X':            vm->ram_mmap = 0;            break;         /* Use a ghost file to simulate RAM */                    case 'G':            vm->ghost_ram_filename = strdup(optarg);            vm->ghost_status = VM_GHOST_RAM_USE;            break;         /* Generate a ghost RAM image */         case 'g':            vm->ghost_ram_filename = strdup(optarg);            vm->ghost_status = VM_GHOST_RAM_GENERATE;            break;         /* Use sparse memory */         case OPT_SPARSE_MEM:            vm->sparse_mem = TRUE;            break;         /* Alternate ROM */         case 'R':            vm->rom_filename = optarg;            break;         /* Idle PC */         case OPT_IDLE_PC:            vm->idle_pc = strtoull(optarg,NULL,0);            printf("Idle PC set to 0x%llx.\n",vm->idle_pc);            break;         /* Timer IRQ check interval */         case OPT_TIMER_ITV:            vm->timer_irq_check_itv = atoi(optarg);            break;         /* Clock divisor */         case 'k':            vm->clock_divisor = atoi(optarg);            if (!vm->clock_divisor) {               fprintf(stderr,"Invalid Clock Divisor specified!\n");               exit(EXIT_FAILURE);            }            printf("Using a clock divisor of %d.\n",vm->clock_divisor);            break;         /* Disable JIT */         case 'j':            vm->jit_use = FALSE;            break;         /* VM debug level */         case OPT_VM_DEBUG:            vm->debug_level = atoi(optarg);            break;         /* Log file */         case 'l':            if (!(log_file_name = strdup(optarg))) {               fprintf(stderr,"Unable to set log file name.\n");               exit(EXIT_FAILURE);            }            printf("Log file: writing to %s\n",log_file_name);            break;#if DEBUG_SYM_TREE         /* Symbol file */         case 'S':            vm->sym_filename = strdup(optarg);            break;#endif         /* TCP server for Console Port */         case 'T':            vm->vtty_con_type = VTTY_TYPE_TCP;            vm->vtty_con_tcp_port = atoi(optarg);            break;         /* Serial interface for Console port */         case 'U':            vm->vtty_con_type = VTTY_TYPE_SERIAL;            if (vtty_parse_serial_option(&vm->vtty_con_serial_option,optarg)) {               fprintf(stderr,                       "Invalid Console serial interface descriptor!\n");               exit(EXIT_FAILURE);            }            break;         /* TCP server for AUX Port */         case 'A':            vm->vtty_aux_type = VTTY_TYPE_TCP;            vm->vtty_aux_tcp_port = atoi(optarg);            break;         /* Serial interface for AUX port */         case 'B':            vm->vtty_aux_type = VTTY_TYPE_SERIAL;            if (vtty_parse_serial_option(&vm->vtty_aux_serial_option,optarg)) {               fprintf(stderr,"Invalid AUX serial interface descriptor!\n");               exit(EXIT_FAILURE);            }            break;         /* Port settings */         case 'p':            vm_slot_cmd_create(vm,optarg);            break;         /* NIO settings */         case 's':            vm_slot_cmd_add_nio(vm,optarg);            break;         /* Virtual ATM switch */         case 'a':            if (atmsw_start(optarg) == -1)               exit(EXIT_FAILURE);            break;         /* Virtual Frame-Relay switch */         case 'f':            if (frsw_start(optarg) == -1)               exit(EXIT_FAILURE);            break;         /* Virtual Ethernet switch */         case 'E':            if (ethsw_start(optarg) == -1)               exit(EXIT_FAILURE);            break;         /* Virtual bridge */         case 'b':            if (netio_bridge_start(optarg) == -1)               exit(EXIT_FAILURE);            break;#ifdef GEN_ETH         /* Ethernet device list */         case 'e':            gen_eth_show_dev_list();            exit(EXIT_SUCCESS);           #endif                     /* Load plugin (already handled) */         case 'L':            break;         /* Oops ! */         case '?':            show_usage(vm,argc,argv);            exit(EXIT_FAILURE);         /* Parse options specific to the platform */         default:            if (vm->platform->cli_parse_options != NULL)               if (vm->platform->cli_parse_options(vm,option) == -1)                  exit(EXIT_FAILURE);      }   }   /* Last argument, this is the IOS filename */   if (optind == (argc - 1)) {      /* setting IOS image file	*/      vm_ios_set_image(vm,argv[optind]);      printf("IOS image file: %s\n\n",vm->ios_image);   } else {       /* IOS missing */      fprintf(stderr,"Please specify an IOS image filename\n");      show_usage(vm,argc,argv);      exit(EXIT_FAILURE);   }   vm_release(vm);   return(0);}/*  * Run in hypervisor mode with a config file if the "-H" option  * is present in command line. */static int run_hypervisor(int argc,char *argv[]){   char *options_list = "H:l:hN:L:";   int i,option;   char *index;   size_t len;   for(i=1;i<argc;i++)      if (!strcmp(argv[i],"-H")) {         hypervisor_mode = 1;         break;      }   /* standard mode with one instance */   if (!hypervisor_mode)      return(FALSE);   cli_load_plugins(argc,argv);   opterr = 0;   while((option = getopt(argc,argv,options_list)) != -1) {      switch(option)      {         /* Hypervisor TCP port */         case 'H':            index = strrchr(optarg,':');            if (!index) {               hypervisor_tcp_port = atoi(optarg);            } else {               len = index - optarg;               hypervisor_ip_address = malloc(len + 1);               if (!hypervisor_ip_address) {                  fprintf(stderr,"Unable to set hypervisor IP address!\n");                  exit(EXIT_FAILURE);               }               memcpy(hypervisor_ip_address,optarg,len);               hypervisor_ip_address[len] = '\0';            }            break;         /* Log file */         case 'l':            if (!(log_file_name = malloc(strlen(optarg)+1))) {               fprintf(stderr,"Unable to set log file name!\n");               exit(EXIT_FAILURE);            }            strcpy(log_file_name, optarg);            printf("Log file: writing to %s\n",log_file_name);            break;         /* VM file naming type */         case 'N':            vm_file_naming_type = atoi(optarg);            break;         /* Load plugin (already handled) */         case 'L':            break;         /* Oops ! */         case '?':            //show_usage(argc,argv,VM_TYPE_C7200);            exit(EXIT_FAILURE);      }   }   return(TRUE);}/* Delete all objects */void dynamips_reset(void){   printf("Shutdown in progress...\n");   /* Delete all virtual router instances */   vm_delete_all_instances();   /* Delete ATM and Frame-Relay switches + bridges */   netio_bridge_delete_all();   atmsw_delete_all();   frsw_delete_all();   ethsw_delete_all();   /* Delete all NIO descriptors */   netio_delete_all();   printf("Shutdown completed.\n");}/* Default platforms */static int (*platform_register[])(void) = {   c7200_platform_register,   c3600_platform_register,   c3725_platform_register,   c3745_platform_register,   c2691_platform_register,   c2600_platform_register,   c1700_platform_register,   c6sup1_platform_register,   c6msfc1_platform_register,   NULL,};/* Register default platforms */static void register_default_platforms(void){   int i;   for(i=0;platform_register[i];i++)      platform_register[i]();}int main(int argc,char *argv[]){   vm_instance_t *vm;#ifdef PROFILE   atexit(profiler_savestat);#endif   printf("Cisco Router Simulation Platform (version %s)\n",sw_version);   printf("Copyright (c) 2005-2007 Christophe Fillot.\n");   printf("Build date: %s %s\n\n",__DATE__,__TIME__);   /* Register platforms */   register_default_platforms();   /* Initialize timers */   timer_init();   /* Initialize object registry */   registry_init();      /* Initialize ATM module (for HEC checksums) */   atm_init();   /* Initialize CRC functions */   crc_init();   /* Initialize NetIO code */   netio_rxl_init();   /* Initialize NetIO packet filters */   netio_filter_load_all();   /* Initialize VTTY code */   vtty_init();      /* Parse standard command line */   if (!run_hypervisor(argc,argv))      parse_std_cmd_line(argc,argv);   /* Create general log file */   create_log_file();   /* Periodic tasks initialization */   if (ptask_init(0) == -1)      exit(EXIT_FAILURE);   /* Create instruction lookup tables */   mips64_jit_create_ilt();   mips64_exec_create_ilt();   ppc32_jit_create_ilt();   ppc32_exec_create_ilt();      setup_signals();   if (!hypervisor_mode) {      /* Initialize the default instance */      vm = vm_acquire("default");      assert(vm != NULL);      if (vm->platform->init_instance(vm) == -1) {         fprintf(stderr,"Unable to initialize router instance.\n");         exit(EXIT_FAILURE);      }#if (DEBUG_INSN_PERF_CNT > 0) || (DEBUG_BLOCK_PERF_CNT > 0)      {         m_uint32_t counter,prev = 0,delta;         while(vm->status == VM_STATUS_RUNNING) {            counter = cpu_get_perf_counter(vm->boot_cpu);            delta = counter - prev;            prev = counter;            printf("delta = %u\n",delta);            sleep(1);         }      }#else      /* Start instance monitoring */      vm_monitor(vm);#endif      /* Free resources used by instance */      vm_release(vm);   } else {      hypervisor_tcp_server(hypervisor_ip_address,hypervisor_tcp_port);   }   dynamips_reset();   close_log_file();   return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -