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.


formatting fixes
[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  *
20  * This is free software.  You are permitted to use,
21  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
22  */
23
24 #ifndef __VNET_H__
25 #define __VNET_H__
26
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>
33
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)
38
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;
42
43 //routing table entry
44 struct routing_entry{
45     char src_mac[6];
46     char dest_mac[6];
47
48     int src_mac_qual;
49     int dest_mac_qual;
50
51     int link_idx; //link[dest] is the link to be used to send pkt
52     link_type_t link_type; //EDGE|INTERFACE|ANY
53  
54     int src_link_idx;
55     link_type_t src_type; //EDGE|INTERFACE|ANY
56 }__attribute__((packed));
57
58
59 struct vnet_if_device {
60     char name[50];
61     uchar_t mac_addr[6];
62     struct vm_device *dev;
63     
64     int (*input)(uchar_t *data, uint32_t len, void *private_data);
65     
66     void *private_data;
67 }__attribute__((packed));
68
69
70 #define VNET_HEADER_LEN  64
71 struct vnet_if_link {
72     prot_type_t pro_type; //protocal type of this link
73     unsigned long dest_ip;
74     uint16_t dest_port;
75
76     uchar_t vnet_header[VNET_HEADER_LEN]; //header applied to the packet in/out from this link
77     uint16_t hdr_len; 
78
79     int (*input)(uchar_t *data, uint32_t len, void *private_data);
80     
81     void *private_data;
82 }__attribute__((packed));
83
84
85 //link table entry
86 struct link_entry {
87     link_type_t type;
88   
89     union {
90         struct vnet_if_device *dst_dev;
91         struct vnet_if_link *dst_link;
92     } __attribute__((packed));
93
94     int use;
95 }__attribute__((packed));
96
97
98 int v3_vnet_send_pkt(uchar_t *buf, int length);
99 //int vnet_register_device(struct vm_device *vdev, 
100 //                       char *dev_name, 
101 //                       uchar_t mac[6], 
102 //                       int (*netif_input)(uchar_t * pkt, uint_t size, void *private_data), 
103 //                       void *data);
104 //int vnet_unregister_device(char *dev_name);
105
106 int v3_vnet_pkt_process(); 
107
108 void v3_vnet_init(struct guest_info *vm);
109
110 #endif
111
112