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.


Move vnet code to src/palacios
[palacios.git] / palacios / include / palacios / vmm_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 #include <palacios/vmm_sprintf.h>
36
37
38 #define ETHERNET_HEADER_LEN 14
39 #define ETHERNET_DATA_MIN   46
40 #define ETHERNET_DATA_MAX   1500
41 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN + ETHERNET_DATA_MAX)
42
43 #define SOCK int
44
45 //the routing entry
46 struct routing{
47     char src_mac[6];
48     char dest_mac[6];
49
50     int src_mac_qual;
51     int dest_mac_qual;
52
53     int dest; //link[dest] is the link to be used to send pkt
54     int type; //EDGE|INTERFACE|ANY
55  
56     int src;
57     int src_type; //EDGE|INTERFACE|ANY
58
59     int use;
60
61     int next;
62     int prev;
63   //  struct list_head entry_list;
64 };
65
66 //struct  gen_route {
67  //   uint_t num_entries;
68   //  struct list_head entries;
69 //}
70
71  //This is the structure that stores the topology 
72 struct topology {
73     SOCK link_sock;
74
75     unsigned long dest;
76
77     // Port for UDP
78     unsigned short remote_port;
79
80     int use;
81     int type; //TCP=0, UDP=1,VTP=2, can be extended so on
82
83     int next;
84     int prev;
85 };
86
87 struct sock_list {
88     SOCK sock;
89
90     int next;
91     int prev;
92 };
93
94
95 #define GENERAL_NIC 0
96
97 struct ethAddr{
98   char addr[6];
99 };
100
101 struct vnet_if_device {
102     char name[50];
103     struct ethAddr device_addr;
104     
105     int (*input)(uchar_t * pkt, uint_t size);
106     
107     void * data;
108 };
109
110
111 struct device_list {
112     struct vnet_if_device *device;
113
114     int use;
115     int type;
116
117     int next;
118     int prev;
119 };
120
121 // 14 (ethernet frame) + 20 bytes
122 struct HEADERS {
123     char ethernetdest[6];
124     char ethernetsrc[6];
125     unsigned char ethernettype[2]; // indicates layer 3 protocol type
126     char ip[20];
127 };
128
129 #define FOREACH(iter, list, start) for (iter = start; iter != -1; iter = list[iter].next)
130 #define FOREACH_SOCK(iter, socks, start) FOREACH(iter, socks, start)
131 #define FOREACH_LINK(iter, links, start) FOREACH(iter, links, start)
132 #define FOREACH_ROUTE(iter, routes, start) FOREACH(iter, routes, start)
133 #define FOREACH_DEVICE(iter, devices, start) FOREACH(iter, devices, start)
134
135
136 int v3_Send_pkt(uchar_t *buf, int length);
137 int v3_Register_pkt_event(int (*netif_input)(uchar_t * pkt, uint_t size));
138
139
140 int vnet_send_pkt(char *buf, int length);
141 int vnet_register_pkt_event(char *dev_name, int (*netif_input)(uchar_t * pkt, uint_t size), void *data);
142
143 int v3_vnet_pkt_process();
144
145 void v3_vnet_init();
146
147 #endif
148
149