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.


Vnet code update
[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
26 #ifndef __VNET_H__
27 #define __VNET_H__
28
29 #include <palacios/vmm.h>
30 #include <palacios/vmm_string.h>
31 #include <palacios/vmm_types.h>
32 #include <palacios/vmm_queue.h>
33 #include <palacios/vmm_socket.h>
34 #include <palacios/vmm_hashtable.h>
35
36
37 #define ETHERNET_HEADER_LEN 14
38 #define ETHERNET_DATA_MIN   46
39 #define ETHERNET_DATA_MAX   1500
40 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN+ETHERNET_DATA_MAX)
41
42 struct ethAddr{
43   char addr[6];
44 };
45
46 #define SOCK int
47
48 #define TCP_TYPE 0
49 #define UDP_TYPE 1
50
51 #define TCP_STR "TCP"
52 #define UDP_STR "UDP"
53
54 /*   
55 #define HANDLER_ERROR -1
56 #define HANDLER_SUCCESS 0
57 */
58
59 //the routing entry
60 struct routing {
61   char src_mac[6];
62   char dest_mac[6];
63
64   int src_mac_qual;
65   int dest_mac_qual;
66
67   int dest;
68   int type; //EDGE_TYPE|INTERFACE_TYPE
69  
70   int src;
71   int src_type;
72
73   int use;
74
75   int next;
76   int prev;
77 };
78
79  //This is the structure that stores the topology 
80 struct topology {
81   SOCK link_sock;
82
83   unsigned long dest;
84
85   // Port for UDP
86   unsigned short remote_port;
87
88   // LINK OR GATEWAY
89   // int link_class;
90
91   int use;
92   int type; //TCP=0, UDP=1,VTP=2, can be extended so on
93
94   int next;
95   int prev;
96 };
97
98 struct sock_list {
99   SOCK sock;
100
101   int next;
102   int prev;
103 };
104
105
106 #define GENERAL_NIC 0
107
108 struct vnet_if_device{
109         char name[50];
110         struct ethAddr device_addr;
111
112         int (*input)(uchar_t * pkt, uint_t size);
113
114         void *data;
115 };
116
117
118 struct device_list {
119   struct vnet_if_device *device;
120
121   int use;
122   int type;
123
124   int next;
125   int prev;
126 };
127
128 // 14 (ethernet frame) + 20 bytes
129 struct HEADERS {
130   char ethernetdest[6];
131   char ethernetsrc[6];
132   unsigned char ethernettype[2]; // indicates layer 3 protocol type
133   char ip[20];
134 };
135
136 #define FOREACH(iter, list, start) for (iter = start; iter != -1; iter = list[iter].next)
137 #define FOREACH_SOCK(iter, socks, start) FOREACH(iter, socks, start)
138 #define FOREACH_LINK(iter, links, start) FOREACH(iter, links, start)
139 #define FOREACH_ROUTE(iter, routes, start) FOREACH(iter, routes, start)
140 #define FOREACH_DEVICE(iter, devices, start) FOREACH(iter, devices, start)
141
142
143 int V3_Send_pkt(uchar_t *buf, int length);
144 int V3_Register_pkt_event(int (*netif_input)(uchar_t * pkt, uint_t size));
145
146
147 int vnet_send_pkt(char *buf, int length);
148 int vnet_register_pkt_event(char *dev_name, int (*netif_input)(uchar_t * pkt, uint_t size), void *data);
149
150 int vnet_pkt_process();
151
152 void vnet_init();
153
154 #endif
155
156