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.


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