1 |
dpavlin |
1 |
/* |
2 |
|
|
* Cisco 7200 (Predator) simulation platform. |
3 |
|
|
* Copyright (c) 2006 Christophe Fillot (cf@utc.fr) |
4 |
|
|
* |
5 |
|
|
* Hypervisor routines. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef __HYPERVISOR_H__ |
9 |
|
|
#define __HYPERVISOR_H__ |
10 |
|
|
|
11 |
|
|
/* Default TCP port */ |
12 |
|
|
#define HYPERVISOR_TCP_PORT 7200 |
13 |
|
|
|
14 |
|
|
/* Maximum listening socket number */ |
15 |
|
|
#define HYPERVISOR_MAX_FD 10 |
16 |
|
|
|
17 |
|
|
/* Maximum tokens per line */ |
18 |
|
|
#define HYPERVISOR_MAX_TOKENS 16 |
19 |
|
|
|
20 |
|
|
/* Hypervisor status codes */ |
21 |
|
|
#define HSC_INFO_OK 100 /* ok */ |
22 |
|
|
#define HSC_INFO_MSG 101 /* informative message */ |
23 |
|
|
#define HSC_INFO_DEBUG 102 /* debugging message */ |
24 |
|
|
#define HSC_ERR_PARSING 200 /* parse error */ |
25 |
|
|
#define HSC_ERR_UNK_MODULE 201 /* unknown module */ |
26 |
|
|
#define HSC_ERR_UNK_CMD 202 /* unknown command */ |
27 |
|
|
#define HSC_ERR_BAD_PARAM 203 /* bad number of parameters */ |
28 |
|
|
#define HSC_ERR_INV_PARAM 204 /* invalid parameter */ |
29 |
|
|
#define HSC_ERR_BINDING 205 /* binding error */ |
30 |
|
|
#define HSC_ERR_CREATE 206 /* unable to create object */ |
31 |
|
|
#define HSC_ERR_DELETE 207 /* unable to delete object */ |
32 |
|
|
#define HSC_ERR_UNK_OBJ 208 /* unknown object */ |
33 |
|
|
#define HSC_ERR_START 209 /* unable to start object */ |
34 |
|
|
#define HSC_ERR_STOP 210 /* unable to stop object */ |
35 |
|
|
#define HSC_ERR_FILE 211 /* file error */ |
36 |
|
|
#define HSC_ERR_BAD_OBJ 212 /* Bad object */ |
37 |
|
|
|
38 |
|
|
/* Hypervisor connection */ |
39 |
|
|
typedef struct hypervisor_conn hypervisor_conn_t; |
40 |
|
|
struct hypervisor_conn { |
41 |
|
|
pthread_t tid; /* Thread identifier */ |
42 |
|
|
volatile int active; /* Connection is active ? */ |
43 |
|
|
int client_fd; /* Client FD */ |
44 |
|
|
FILE *in,*out; /* I/O buffered streams */ |
45 |
|
|
hypervisor_conn_t *next,**pprev; |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
/* Hypervisor command handler */ |
49 |
|
|
typedef int (*hypervisor_cmd_handler)(hypervisor_conn_t *conn,int argc, |
50 |
|
|
char *argv[]); |
51 |
|
|
|
52 |
|
|
/* Hypervisor command */ |
53 |
|
|
typedef struct hypervisor_cmd hypervisor_cmd_t; |
54 |
|
|
struct hypervisor_cmd { |
55 |
|
|
char *name; |
56 |
|
|
int min_param,max_param; |
57 |
|
|
hypervisor_cmd_handler handler; |
58 |
|
|
hypervisor_cmd_t *next; |
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
/* Hypervisor module */ |
62 |
|
|
typedef struct hypervisor_module hypervisor_module_t; |
63 |
|
|
struct hypervisor_module { |
64 |
|
|
char *name; |
65 |
|
|
hypervisor_cmd_t *cmd_list; |
66 |
|
|
hypervisor_module_t *next; |
67 |
|
|
}; |
68 |
|
|
|
69 |
|
|
/* Hypervisor NIO initialization */ |
70 |
|
|
extern int hypervisor_nio_init(void); |
71 |
|
|
|
72 |
|
|
/* Hypervisor NIO bridge initialization */ |
73 |
|
|
extern int hypervisor_nio_bridge_init(void); |
74 |
|
|
|
75 |
|
|
/* Hypervisor Frame-Relay switch initialization */ |
76 |
|
|
extern int hypervisor_frsw_init(void); |
77 |
|
|
|
78 |
|
|
/* Hypervisor ATM switch initialization */ |
79 |
|
|
extern int hypervisor_atmsw_init(void); |
80 |
|
|
|
81 |
|
|
/* Hypervisor Ethernet switch initialization */ |
82 |
|
|
extern int hypervisor_ethsw_init(void); |
83 |
|
|
|
84 |
|
|
/* Hypervisor VM initialization */ |
85 |
|
|
extern int hypervisor_vm_init(void); |
86 |
|
|
|
87 |
|
|
/* Hypervisor C7200 initialization */ |
88 |
|
|
extern int hypervisor_c7200_init(void); |
89 |
|
|
|
90 |
|
|
/* Hypervisor C3600 initialization */ |
91 |
|
|
extern int hypervisor_c3600_init(void); |
92 |
|
|
|
93 |
|
|
/* Send a reply */ |
94 |
|
|
int hypervisor_send_reply(hypervisor_conn_t *conn,int code,int done, |
95 |
|
|
char *format,...); |
96 |
|
|
|
97 |
|
|
/* Find a module */ |
98 |
|
|
hypervisor_module_t *hypervisor_find_module(char *name); |
99 |
|
|
|
100 |
|
|
/* Find a command in a module */ |
101 |
|
|
hypervisor_cmd_t *hypervisor_find_cmd(hypervisor_module_t *module,char *name); |
102 |
|
|
|
103 |
|
|
/* Find an object in the registry */ |
104 |
|
|
void *hypervisor_find_object(hypervisor_conn_t *conn,char *name,int obj_type); |
105 |
|
|
|
106 |
|
|
/* Find a VM in the registry */ |
107 |
|
|
void *hypervisor_find_vm(hypervisor_conn_t *conn,char *name,int vm_type); |
108 |
|
|
|
109 |
|
|
/* Register a module */ |
110 |
|
|
hypervisor_module_t *hypervisor_register_module(char *name); |
111 |
|
|
|
112 |
|
|
/* Register a list of commands */ |
113 |
|
|
int hypervisor_register_cmd_list(hypervisor_module_t *module, |
114 |
|
|
hypervisor_cmd_t *cmd_list); |
115 |
|
|
|
116 |
|
|
/* Register an array of commands */ |
117 |
|
|
int hypervisor_register_cmd_array(hypervisor_module_t *module, |
118 |
|
|
hypervisor_cmd_t *cmd_array); |
119 |
|
|
|
120 |
|
|
/* Stop hypervisor from sighandler */ |
121 |
|
|
int hypervisor_stopsig(void); |
122 |
|
|
|
123 |
|
|
/* Hypervisor TCP server */ |
124 |
|
|
int hypervisor_tcp_server(int tcp_port); |
125 |
|
|
|
126 |
|
|
#endif |