Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Checked in Vnet code
[palacios.git] / palacios / include / devices / vnet.h
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2009, Lei Xia <lxia@northwestern.edu> 
11  * Copyright (c) 2009, Yuan Tang <ytang@northwestern.edu> 
12  * Copyright (c) 2009, Jack Lange <jarusl@cs.northwestern.edu> 
13  * Copyright (c) 2009, Peter Dinda <pdinda@northwestern.edu
14  * Copyright (c) 2009, The V3VEE Project <http://www.v3vee.org> 
15  * All rights reserved.
16  *
17  * Author: Lei Xia <lxia@northwestern.edu>
18  *            Yuan Tang <ytang@northwestern.edu>
19  *                Jack Lange <jarusl@cs.northwestern.edu> 
20  *                Peter Dinda <pdinda@northwestern.edu
21  *
22  * This is free software.  You are permitted to use,
23  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
24  */
25 #if 0
26
27 #ifndef __VNET_H__
28 #define __VNET_H__
29
30 #include <palacios/vmm.h>
31 #include <palacios/vmm_string.h>
32 #include <palacios/vmm_types.h>
33 #include <palacios/vmm_queue.h>
34 #include <palacios/vmm_socket.h>
35 #include <palacios/vmm_hashtable.h>
36
37
38 #define ETHERNET_HEADER_LEN 14
39 #define ETHERNET_DATA_MIN   46
40 #define ETHERNET_DATA_MAX   1500
41
42 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN+ETHERNET_DATA_MAX)
43
44
45 struct gen_queue * vnet_inpkt_q;
46
47 struct ethAddr{
48   char addr[6];
49 };
50
51 typedef struct vnet_device{
52         char name[50];
53 //      struct ethAddr device_addr;
54         int (*input)(uchar_t * pkt, uint_t size);
55
56         void *data;
57         //....
58 }iface_t;
59
60 #define ROUTE 1
61 //#define ROUTE 0
62
63 #if ROUTE //new routing accrding to VNET-VTL, no hash --YT
64
65 //struct gen_queue *src_link_index_q;
66
67 #define SOCK int
68 #define MAX_LINKS 100
69 #define MAX_ROUTES 500
70 #define MAX_DEVICES 16
71
72 #define TCP_TYPE 0
73 #define UDP_TYPE 1
74
75 #define TCP_STR "TCP"
76 #define UDP_STR "UDP"
77
78 /*   
79 #define HANDLER_ERROR -1
80 #define HANDLER_SUCCESS 0
81 */
82 /* These are the return codes for the Control Session */
83 /*
84 #define CTRL_DO_NOTHING 0
85 #define CTRL_CLOSE 1
86 #define CTRL_DELETE_TCP_SOCK 3
87 #define CTRL_ADD_TCP_SOCK 4
88 #define CTRL_EXIT 5
89 #define CTRL_ERROR -1
90 */
91
92 #define ANY "any"
93 #define NOT "not"
94 #define NONE "none"
95 #define EMPTY "empty"
96
97 #define ANY_TYPE 0
98 #define NOT_TYPE 1
99 #define NONE_TYPE 2
100 #define EMPTY_TYPE 3
101
102 #define INTERFACE "INTERFACE"
103 #define EDGE "EDGE"
104 #define ANY_SRC "ANY"
105
106 #define INTERFACE_TYPE 0
107 #define EDGE_TYPE 1
108 #define ANY_SRC_TYPE 2
109
110 //This is the structure that stores the routing entries
111 struct routing {
112   char src_mac[6];
113   char dest_mac[6];
114
115   int src_mac_qual;
116   int dest_mac_qual;
117
118   int dest;
119   int type; //EDGE_TYPE|INTERFACE_TYPE
120  
121   int src;
122   int src_type;
123
124   int use;
125
126   int next;
127   int prev;
128 };
129
130  //This is the structure that stores the topology 
131 struct topology {
132   SOCK link_sock;
133
134   unsigned long dest;
135
136   // Port for UDP
137   unsigned short remote_port;
138
139   // LINK OR GATEWAY
140 //  int link_class;
141
142   int use;
143 //  int authenticated;
144   int type; //TCP=0, UDP=1,VTP=2, can be extended so on
145
146   int next;
147   int prev;
148 };
149
150 struct sock_list {
151   SOCK sock;
152
153   int next;
154   int prev;
155 };
156
157 typedef struct sock_list con_t;
158
159 struct device_list {
160   char *device_name;
161
162   iface_t * vnet_device;
163
164   int type;
165   int use;
166
167   int next;
168   int prev;
169 };
170
171 // 14 (ethernet frame) + 20 bytes
172 struct HEADERS {
173   char ethernetdest[6];
174   char ethernetsrc[6];
175   unsigned char ethernettype[2]; // indicates layer 3 protocol type
176   char ip[20];
177 };
178
179 #define FOREACH(iter, list, start) for (iter = start; iter != -1; iter = list[iter].next)
180
181 #define FOREACH_SOCK(iter, socks, start) FOREACH(iter, socks, start)
182 #define FOREACH_LINK(iter, links, start) FOREACH(iter, links, start)
183 #define FOREACH_ROUTE(iter, routes, start) FOREACH(iter, routes, start)
184 #define FOREACH_DEVICE(iter, devices, start) FOREACH(iter, devices, start)
185
186 #endif
187
188 int V3_Send_pkt(uchar_t *buf, int length);
189 int V3_Register_pkt_event(int (*netif_input)(uchar_t * pkt, uint_t size));
190
191
192 int vnet_send_pkt(char *buf, int length);
193 int vnet_register_pkt_event(char *dev_name, int (*netif_input)(uchar_t * pkt, uint_t size), void *data);
194
195 //check if there are incoming packet in the queue for VNIC, if yes, send the packet to the VNIC
196 //this should put in the svm exit handler
197 int vnet_check();
198
199 void vnet_init();
200
201 #endif
202 #endif
203