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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
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.
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
22 * This is free software. You are permitted to use,
23 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
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>
38 #define ETHERNET_HEADER_LEN 14
39 #define ETHERNET_DATA_MIN 46
40 #define ETHERNET_DATA_MAX 1500
42 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN+ETHERNET_DATA_MAX)
45 struct gen_queue * vnet_inpkt_q;
51 typedef struct vnet_device{
53 // struct ethAddr device_addr;
54 int (*input)(uchar_t * pkt, uint_t size);
63 #if ROUTE //new routing accrding to VNET-VTL, no hash --YT
65 //struct gen_queue *src_link_index_q;
69 #define MAX_ROUTES 500
70 #define MAX_DEVICES 16
79 #define HANDLER_ERROR -1
80 #define HANDLER_SUCCESS 0
82 /* These are the return codes for the Control Session */
84 #define CTRL_DO_NOTHING 0
86 #define CTRL_DELETE_TCP_SOCK 3
87 #define CTRL_ADD_TCP_SOCK 4
102 #define INTERFACE "INTERFACE"
104 #define ANY_SRC "ANY"
106 #define INTERFACE_TYPE 0
108 #define ANY_SRC_TYPE 2
110 //This is the structure that stores the routing entries
119 int type; //EDGE_TYPE|INTERFACE_TYPE
130 //This is the structure that stores the topology
137 unsigned short remote_port;
143 // int authenticated;
144 int type; //TCP=0, UDP=1,VTP=2, can be extended so on
157 typedef struct sock_list con_t;
162 iface_t * vnet_device;
171 // 14 (ethernet frame) + 20 bytes
173 char ethernetdest[6];
175 unsigned char ethernettype[2]; // indicates layer 3 protocol type
179 #define FOREACH(iter, list, start) for (iter = start; iter != -1; iter = list[iter].next)
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)
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));
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);
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