Lines 1-87
Link Here
|
1 |
--- dynamips.c.orig Wed Feb 14 20:37:58 2007 |
1 |
--- dynamips.c.orig Fri Sep 7 12:03:11 2007 |
2 |
+++ dynamips.c Fri Apr 6 21:11:38 2007 |
2 |
+++ dynamips.c Fri Sep 14 10:18:10 2007 |
3 |
@@ -61,6 +61,7 @@ |
3 |
@@ -193,7 +193,7 @@ |
4 |
/* Hypervisor */ |
|
|
5 |
int hypervisor_mode = 0; |
6 |
int hypervisor_tcp_port = 0; |
7 |
+char hypervisor_ip_address[263]="\000"; /* 256(MAXHOSTNAMELEN)+1(:)+5(port)+NULL */ |
8 |
|
9 |
/* Log file */ |
10 |
char *log_file_name = NULL; |
11 |
@@ -227,7 +228,7 @@ |
12 |
printf("Usage: %s [options] <ios_image>\n\n",argv[0]); |
13 |
|
14 |
printf("Available options:\n" |
15 |
- " -H <tcp_port> : Run in hypervisor mode\n\n" |
16 |
+ " -H [ip_address:]<tcp_port> : Run in hypervisor mode\n\n" |
17 |
" -P <platform> : Platform to emulate (7200, 3600, " |
18 |
"2691, 3725 or 3745) " |
19 |
"(default: 7200)\n\n" |
20 |
@@ -254,7 +255,7 @@ |
21 |
" -R <rom_file> : Load an alternate ROM (default: embedded)\n" |
4 |
" -R <rom_file> : Load an alternate ROM (default: embedded)\n" |
22 |
" -k <clock_div> : Set the clock divisor (default: %d)\n" |
5 |
" -k <clock_div> : Set the clock divisor (default: %d)\n" |
23 |
"\n" |
6 |
"\n" |
24 |
- " -T <port> : Console is on TCP <port>\n" |
7 |
- " -T <port> : Console is on TCP <port>\n" |
25 |
+ " -T [ip_address:]<port> : Console is on TCP <port>\n" |
8 |
+ " -T [<ip_address>:]<port> : Console is on TCP <port>\n" |
26 |
" -U <si_desc> : Console in on serial interface <si_desc>\n" |
9 |
" -U <si_desc> : Console in on serial interface <si_desc>\n" |
27 |
" (default is on the terminal)\n" |
10 |
" (default is on the terminal)\n" |
28 |
"\n" |
11 |
"\n" |
29 |
@@ -780,6 +781,7 @@ |
12 |
@@ -374,6 +374,8 @@ |
30 |
int instance_id; |
13 |
int instance_id; |
31 |
int res,option; |
14 |
int option; |
32 |
char *str; |
15 |
char *str; |
33 |
+ char *index; |
16 |
+ char *index; |
|
|
17 |
+ size_t len; |
34 |
|
18 |
|
35 |
/* Get the instance ID */ |
19 |
/* Get the instance ID */ |
36 |
instance_id = 0; |
20 |
instance_id = 0; |
37 |
@@ -944,7 +946,15 @@ |
21 |
@@ -541,7 +543,25 @@ |
38 |
/* TCP server for Console Port */ |
22 |
/* TCP server for Console Port */ |
39 |
case 'T': |
23 |
case 'T': |
40 |
vm->vtty_con_type = VTTY_TYPE_TCP; |
24 |
vm->vtty_con_type = VTTY_TYPE_TCP; |
41 |
- vm->vtty_con_tcp_port = atoi(optarg); |
25 |
- vm->vtty_con_tcp_port = atoi(optarg); |
42 |
+ strncpy(hypervisor_ip_address,optarg,sizeof(hypervisor_ip_address)); |
26 |
+ |
43 |
+ index=strrchr(hypervisor_ip_address,':'); |
27 |
+ index = strrchr(optarg,':'); |
44 |
+ if (index != NULL) { |
28 |
+ |
45 |
+ *index++='\000'; |
29 |
+ if (!index) { |
46 |
+ vm->vtty_con_tcp_port = atoi(index); |
30 |
+ vm->vtty_con_tcp_port = atoi(optarg); |
47 |
+ } else { |
31 |
+ } else { |
48 |
+ vm->vtty_con_tcp_port = atoi(hypervisor_ip_address); |
32 |
+ len = index - optarg; |
49 |
+ hypervisor_ip_address[0]='\000'; |
33 |
+ hypervisor_ip_address = malloc(len + 1); |
50 |
+ } |
34 |
+ |
|
|
35 |
+ if (!hypervisor_ip_address) { |
36 |
+ fprintf(stderr,"Unable to set console IP address!\n"); |
37 |
+ exit(EXIT_FAILURE); |
38 |
+ } |
39 |
+ |
40 |
+ memcpy(hypervisor_ip_address,optarg,len); |
41 |
+ hypervisor_ip_address[len] = '\0'; |
42 |
+ |
43 |
+ vm->vtty_con_tcp_port = atoi(++index); |
44 |
+ } |
51 |
break; |
45 |
break; |
52 |
|
46 |
|
53 |
/* Serial interface for Console port */ |
47 |
/* Serial interface for Console port */ |
54 |
@@ -1061,6 +1071,7 @@ |
48 |
@@ -687,6 +707,8 @@ |
55 |
static int run_hypervisor(int argc,char *argv[]) |
|
|
56 |
{ |
57 |
char *options_list = "H:l:hN:"; |
58 |
+ char *index; |
59 |
int i,option; |
60 |
|
49 |
|
61 |
for(i=1;i<argc;i++) |
50 |
memcpy(hypervisor_ip_address,optarg,len); |
62 |
@@ -1079,7 +1090,15 @@ |
51 |
hypervisor_ip_address[len] = '\0'; |
63 |
{ |
52 |
+ |
64 |
/* Hypervisor TCP port */ |
53 |
+ hypervisor_tcp_port = atoi(++index); |
65 |
case 'H': |
54 |
} |
66 |
- hypervisor_tcp_port = atoi(optarg); |
|
|
67 |
+ strncpy(hypervisor_ip_address,optarg,sizeof(hypervisor_ip_address)); |
68 |
+ index=strrchr(hypervisor_ip_address,':'); |
69 |
+ if (index != NULL) { |
70 |
+ *index++='\000'; |
71 |
+ hypervisor_tcp_port = atoi(index); |
72 |
+ } else { |
73 |
+ hypervisor_tcp_port = atoi(hypervisor_ip_address); |
74 |
+ hypervisor_ip_address[0]='\000'; |
75 |
+ } |
76 |
break; |
55 |
break; |
77 |
|
56 |
|
78 |
/* Log file */ |
|
|
79 |
@@ -1244,7 +1263,7 @@ |
80 |
/* Free resources used by instance */ |
81 |
vm_release(vm); |
82 |
} else { |
83 |
- hypervisor_tcp_server(hypervisor_tcp_port); |
84 |
+ hypervisor_tcp_server(hypervisor_ip_address,hypervisor_tcp_port); |
85 |
} |
86 |
|
87 |
dynamips_reset(); |