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

📄 dynamips.c

📁 思科路由器仿真器,用来仿7200系列得,可以在电脑上模拟路由器-Cisco router simulator, used to fake a 7200 series can be simulated
💻 C
📖 第 1 页 / 共 3 页
字号:
                "   \"slot:nm_driver\"\n"                "\n");         printf("<nm_nio> format:\n"                "   \"slot:port:netio_type{:netio_parameters}\"\n"                "\n");         /* Show the possible NM drivers */         c3745_nm_show_drivers();         break;   }      /* Show the possible NETIO types */   netio_show_types();}/* Find an option in the command line */static char *cli_find_option(int argc,char *argv[],char *opt){   int i;   for(i=1;i<argc;i++) {      if (!strncmp(argv[i],opt,2)) {         if (argv[i][2] != 0)            return(&argv[i][2]);         else {            if (argv[i+1] != NULL)               return(argv[i+1]);            else {               fprintf(stderr,"Error: option '%s': no argument specified.\n",                       opt);               exit(EXIT_FAILURE);            }         }      }   }   return NULL;}/* Determine the platform (Cisco 3600, 7200). Default is Cisco 7200 */static int cli_get_platform_type(int argc,char *argv[]){   int vm_type = VM_TYPE_C7200;   char *str;   if ((str = cli_find_option(argc,argv,"-P"))) {      if (!strcmp(str,"3600"))         vm_type = VM_TYPE_C3600;      else if (!strcmp(str,"7200"))         vm_type = VM_TYPE_C7200;      else if (!strcmp(str,"2691"))         vm_type = VM_TYPE_C2691;      else if (!strcmp(str,"3725"))         vm_type = VM_TYPE_C3725;      else if (!strcmp(str,"3745"))         vm_type = VM_TYPE_C3745;      else         fprintf(stderr,"Invalid platform type '%s'\n",str);   }   return(vm_type);}/* Command Line long options */#define OPT_DISK0_SIZE  0x100#define OPT_DISK1_SIZE  0x101#define OPT_EXEC_AREA   0x102#define OPT_IDLE_PC     0x103#define OPT_TIMER_ITV   0x104#define OPT_VM_DEBUG    0x105#define OPT_IOMEM_SIZE  0x106static struct option cmd_line_lopts[] = {   { "disk0"      , 1, NULL, OPT_DISK0_SIZE },   { "disk1"      , 1, NULL, OPT_DISK1_SIZE },   { "exec-area"  , 1, NULL, OPT_EXEC_AREA },   { "idle-pc"    , 1, NULL, OPT_IDLE_PC },   { "timer-itv"  , 1, NULL, OPT_TIMER_ITV },   { "vm-debug"   , 1, NULL, OPT_VM_DEBUG },   { "iomem-size" , 1, NULL, OPT_IOMEM_SIZE },   { NULL         , 0, NULL, 0 },};/* Parse specific options for the Cisco 7200 platform */static int cli_parse_c7200_options(vm_instance_t *vm,int option){   c7200_t *router;   router = VM_C7200(vm);   switch(option) {      /* NPE type */      case 't':         c7200_npe_set_type(router,optarg);         break;      /* Midplane type */      case 'M':         c7200_midplane_set_type(router,optarg);         break;      /* Set the base MAC address */      case 'm':         if (!c7200_midplane_set_mac_addr(router,optarg))            printf("MAC address set to '%s'.\n",optarg);         break;      /* PA settings */      case 'p':         return(c7200_cmd_pa_create(router,optarg));      /* PA NIO settings */      case 's':         return(c7200_cmd_add_nio(router,optarg));      /* Unknown option */      default:         return(-1);   }   return(0);}/* Parse specific options for the Cisco 3600 platform */static int cli_parse_c3600_options(vm_instance_t *vm,int option){   c3600_t *router;   router = VM_C3600(vm);   switch(option) {      /* chassis type */      case 't':         c3600_chassis_set_type(router,optarg);         break;      /* IO memory reserved for NMs (in percents!) */      case OPT_IOMEM_SIZE:         router->nm_iomem_size = 0x8000 | atoi(optarg);         break;      /* NM settings */      case 'p':         return(c3600_cmd_nm_create(router,optarg));      /* NM NIO settings */      case 's':         return(c3600_cmd_add_nio(router,optarg));      /* Unknown option */      default:         return(-1);   }   return(0);}/* Parse specific options for the Cisco 2691 platform */static int cli_parse_c2691_options(vm_instance_t *vm,int option){   c2691_t *router;   router = VM_C2691(vm);   switch(option) {      /* IO memory reserved for NMs (in percents!) */      case OPT_IOMEM_SIZE:         router->nm_iomem_size = 0x8000 | atoi(optarg);         break;      /* NM settings */      case 'p':         return(c2691_cmd_nm_create(router,optarg));      /* NM NIO settings */      case 's':         return(c2691_cmd_add_nio(router,optarg));      /* Unknown option */      default:         return(-1);   }   return(0);}/* Parse specific options for the Cisco 3725 platform */static int cli_parse_c3725_options(vm_instance_t *vm,int option){   c3725_t *router;   router = VM_C3725(vm);   switch(option) {      /* IO memory reserved for NMs (in percents!) */      case OPT_IOMEM_SIZE:         router->nm_iomem_size = 0x8000 | atoi(optarg);         break;      /* NM settings */      case 'p':         return(c3725_cmd_nm_create(router,optarg));      /* NM NIO settings */      case 's':         return(c3725_cmd_add_nio(router,optarg));      /* Unknown option */      default:         return(-1);   }   return(0);}/* Parse specific options for the Cisco 3745 platform */static int cli_parse_c3745_options(vm_instance_t *vm,int option){   c3745_t *router;   router = VM_C3745(vm);   switch(option) {      /* IO memory reserved for NMs (in percents!) */      case OPT_IOMEM_SIZE:         router->nm_iomem_size = 0x8000 | atoi(optarg);         break;      /* NM settings */      case 'p':         return(c3745_cmd_nm_create(router,optarg));      /* NM NIO settings */      case 's':         return(c3745_cmd_add_nio(router,optarg));      /* Unknown option */      default:         return(-1);   }   return(0);}/* Create a router instance */static vm_instance_t *cli_create_instance(char *name,int platform_type,                                          int instance_id){   c7200_t *c7200;   c3600_t *c3600;   c2691_t *c2691;   c3725_t *c3725;   c3745_t *c3745;   switch(platform_type) {      case VM_TYPE_C7200:         if (!(c7200 = c7200_create_instance(name,instance_id))) {            fprintf(stderr,"C7200: unable to create instance!\n");            return NULL;         }         return(c7200->vm);      case VM_TYPE_C3600:         if (!(c3600 = c3600_create_instance(name,instance_id))) {            fprintf(stderr,"C3600: unable to create instance!\n");            return NULL;         }         return(c3600->vm);      case VM_TYPE_C2691:         if (!(c2691 = c2691_create_instance(name,instance_id))) {            fprintf(stderr,"C2691: unable to create instance!\n");            return NULL;         }         return(c2691->vm);      case VM_TYPE_C3725:         if (!(c3725 = c3725_create_instance(name,instance_id))) {            fprintf(stderr,"C3725: unable to create instance!\n");            return NULL;         }         return(c3725->vm);      case VM_TYPE_C3745:         if (!(c3745 = c3745_create_instance(name,instance_id))) {            fprintf(stderr,"C3745: unable to create instance!\n");            return NULL;         }         return(c3745->vm);      default:         fprintf(stderr,"Unknown platform type '%d'!\n",platform_type);         return NULL;   }}/* Parse the command line */static int parse_std_cmd_line(int argc,char *argv[],int *platform){   char *options_list =       "r:o:n:c:m:l:C:i:jt:p:s:k:T:U:A:B:a:f:E:b:S:R:M:eXP:N:G:g:";   vm_instance_t *vm;   int instance_id;   int res,option;   char *str;   /* Get the instance ID */   instance_id = 0;   /* Use the old VM file naming type */   vm_file_naming_type = 1;   if ((str = cli_find_option(argc,argv,"-i"))) {      instance_id = atoi(str);      printf("Instance ID set to %d.\n",instance_id);   }   if ((str = cli_find_option(argc,argv,"-N")))      vm_file_naming_type = atoi(str);   /* Get the platform type */   *platform = cli_get_platform_type(argc,argv);   /* Create the default instance */   if (!(vm = cli_create_instance("default",*platform,instance_id)))      exit(EXIT_FAILURE);   opterr = 0;   while((option = getopt_long(argc,argv,options_list,                               cmd_line_lopts,NULL)) != -1)    {      switch(option)      {         /* Instance ID (already managed) */         case 'i':            break;         /* Platform (already managed) */         case 'P':            break;         /* RAM size */         case 'r':            vm->ram_size = strtol(optarg, NULL, 10);            printf("Virtual RAM size set to %d MB.\n",vm->ram_size);            break;         /* ROM size */         case 'o':            vm->rom_size = strtol(optarg, NULL, 10);            printf("Virtual ROM size set to %d MB.\n",vm->rom_size);            break;         /* 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;

⌨️ 快捷键说明

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