/[dynamips]/trunk/hv_c1700.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/hv_c1700.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 3828 byte(s)
make working copy

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4 *
5 * Hypervisor C1700 routines.
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <string.h>
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <sys/mman.h>
15 #include <signal.h>
16 #include <fcntl.h>
17 #include <errno.h>
18 #include <assert.h>
19 #include <stdarg.h>
20 #include <sys/ioctl.h>
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <arpa/inet.h>
24 #include <pthread.h>
25
26 #include "cpu.h"
27 #include "vm.h"
28 #include "device.h"
29 #include "dev_c1700.h"
30 #include "dev_vtty.h"
31 #include "utils.h"
32 #include "net.h"
33 #include "atm.h"
34 #include "frame_relay.h"
35 #include "crc.h"
36 #include "net_io.h"
37 #include "net_io_bridge.h"
38 #ifdef GEN_ETH
39 #include "gen_eth.h"
40 #endif
41 #include "registry.h"
42 #include "hypervisor.h"
43
44 /* Set the chassis type */
45 static int cmd_set_chassis(hypervisor_conn_t *conn,int argc,char *argv[])
46 {
47 vm_instance_t *vm;
48
49 if (!(vm = hypervisor_find_vm(conn,argv[0])))
50 return(-1);
51
52 if ((c1700_mainboard_set_type(VM_C1700(vm),argv[1])) == -1) {
53 vm_release(vm);
54 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
55 "unable to set Chassis type for router '%s'",
56 argv[0]);
57 return(-1);
58 }
59
60 vm_release(vm);
61 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
62 return(0);
63 }
64
65 /* Set the I/O mem size */
66 static int cmd_set_iomem(hypervisor_conn_t *conn,int argc,char *argv[])
67 {
68 vm_instance_t *vm;
69
70 if (!(vm = hypervisor_find_vm(conn,argv[0])))
71 return(-1);
72
73 vm->nm_iomem_size = 0x8000 | atoi(argv[1]);
74
75 vm_release(vm);
76 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
77 return(0);
78 }
79
80 /* Set the base MAC address for the chassis */
81 static int cmd_set_mac_addr(hypervisor_conn_t *conn,int argc,char *argv[])
82 {
83 vm_instance_t *vm;
84
85 if (!(vm = hypervisor_find_vm(conn,argv[0])))
86 return(-1);
87
88 if ((c1700_chassis_set_mac_addr(VM_C1700(vm),argv[1])) == -1) {
89 vm_release(vm);
90 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
91 "unable to set MAC address for router '%s'",
92 argv[0]);
93 return(-1);
94 }
95
96 vm_release(vm);
97 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
98 return(0);
99 }
100
101 /* Show C1700 hardware */
102 static int cmd_show_hardware(hypervisor_conn_t *conn,int argc,char *argv[])
103 {
104 vm_instance_t *vm;
105 c1700_t *router;
106
107 if (!(vm = hypervisor_find_vm(conn,argv[0])))
108 return(-1);
109
110 router = VM_C1700(vm);
111 c1700_show_hardware(router);
112
113 vm_release(vm);
114 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
115 return(0);
116 }
117
118 /* Show info about C1700 object */
119 static void cmd_show_c1700_list(registry_entry_t *entry,void *opt,int *err)
120 {
121 hypervisor_conn_t *conn = opt;
122 vm_instance_t *vm = entry->data;
123
124 if (vm->platform == conn->cur_module->opt)
125 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s",entry->name);
126 }
127
128 /* C1700 List */
129 static int cmd_c1700_list(hypervisor_conn_t *conn,int argc,char *argv[])
130 {
131 int err = 0;
132 registry_foreach_type(OBJ_TYPE_VM,cmd_show_c1700_list,conn,&err);
133 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
134 return(0);
135 }
136
137 /* C1700 commands */
138 static hypervisor_cmd_t c1700_cmd_array[] = {
139 { "set_chassis", 2, 2, cmd_set_chassis, NULL },
140 { "set_iomem", 2, 2, cmd_set_iomem, NULL },
141 { "set_mac_addr", 2, 2, cmd_set_mac_addr, NULL },
142 { "show_hardware", 1, 1, cmd_show_hardware, NULL },
143 { "list", 0, 0, cmd_c1700_list, NULL },
144 { NULL, -1, -1, NULL, NULL },
145 };
146
147 /* Hypervisor C1700 initialization */
148 int hypervisor_c1700_init(vm_platform_t *platform)
149 {
150 hypervisor_module_t *module;
151
152 module = hypervisor_register_module(platform->name,platform);
153 assert(module != NULL);
154
155 hypervisor_register_cmd_array(module,c1700_cmd_array);
156 return(0);
157 }

  ViewVC Help
Powered by ViewVC 1.1.26