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>
20 * This is free software. You are permitted to use,
21 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
27 #include <palacios/vmm.h>
28 #include <palacios/vmm_string.h>
29 #include <palacios/vmm_types.h>
30 #include <palacios/vmm_queue.h>
31 #include <palacios/vmm_hashtable.h>
32 #include <palacios/vmm_sprintf.h>
34 #define ETHERNET_HEADER_LEN 14
35 #define ETHERNET_DATA_MIN 46
36 #define ETHERNET_DATA_MAX 1500
37 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN + ETHERNET_DATA_MAX)
39 typedef enum {MAC_ANY, MAC_NOT, MAC_NONE, MAC_EMPTY} mac_type_t; //for 'src_mac_qual' and 'dst_mac_qual'
40 typedef enum {LINK_INTERFACE, LINK_EDGE, LINK_ANY} link_type_t; //for 'type' and 'src_type' in struct routing
41 typedef enum {TCP_TYPE, UDP_TYPE, NONE_TYPE} prot_type_t;
51 int link_idx; //link[dest] is the link to be used to send pkt
52 link_type_t link_type; //EDGE|INTERFACE|ANY
55 link_type_t src_type; //EDGE|INTERFACE|ANY
56 }__attribute__((packed));
62 uint16_t type; // indicates layer 3 protocol type
63 }__attribute__((packed));
78 }__attribute__((packed));
84 uint16_t csum;//set to zero, disable the xsum
85 }__attribute__((packed));
87 struct udp_link_header {
88 struct eth_header eth_hdr;
89 struct ip_header ip_hdr;
90 struct udp_header udp_hdr;
91 }__attribute__((packed));
93 #define DEVICE_NAME_LEN 20
94 struct vnet_if_device {
95 char name[DEVICE_NAME_LEN];
97 struct vm_device *dev;
99 int (*input)(uchar_t *data, uint32_t len, void *private_data);
102 }__attribute__((packed));
105 struct vnet_if_link {
106 prot_type_t pro_type; //protocal type of this link
107 unsigned long dest_ip;
110 struct udp_link_header vnet_header; //header applied to the packet in/out from this link
112 int (*input)(uchar_t *data, uint32_t len, void *private_data);
115 }__attribute__((packed));
123 struct vnet_if_device *dst_dev;
124 struct vnet_if_link *dst_link;
125 } __attribute__((packed));
128 }__attribute__((packed));
131 int v3_vnet_send_rawpkt(uchar_t *buf, int len, void *private_data);
132 int v3_vnet_send_udppkt(uchar_t *buf, int len, void *private_data);
133 //int vnet_register_device(struct vm_device *vdev,
136 // int (*netif_input)(uchar_t * pkt, uint_t size, void *private_data),
138 //int vnet_unregister_device(char *dev_name);
140 int v3_vnet_pkt_process();
142 void v3_vnet_init(struct guest_info *vm);