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.


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