1 | /* |
---|
2 | * Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com> |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU General Public License as published by the |
---|
6 | * Free Software Foundation; either version 2 of the License, or (at your |
---|
7 | * option) any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, but |
---|
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
---|
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
12 | * for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License along |
---|
15 | * with this program; if not, write to the Free software Foundation, Inc., |
---|
16 | * 59 Temple Place, suite 330, Boston, MA 02111-1307 USA |
---|
17 | * |
---|
18 | */ |
---|
19 | #ifndef __VNET_VNET_H__ |
---|
20 | #define __VNET_VNET_H__ |
---|
21 | |
---|
22 | #ifdef __KERNEL__ |
---|
23 | |
---|
24 | #include <asm/atomic.h> |
---|
25 | #include <linux/skbuff.h> |
---|
26 | #include <linux/if.h> |
---|
27 | #include <linux/netdevice.h> |
---|
28 | |
---|
29 | #else |
---|
30 | |
---|
31 | #include <linux/netdevice.h> // struct net_device_stats |
---|
32 | |
---|
33 | struct net_device { |
---|
34 | char name[IFNAMSIZ]; |
---|
35 | char tap[255]; |
---|
36 | int tapfd; |
---|
37 | }; |
---|
38 | |
---|
39 | #endif |
---|
40 | |
---|
41 | #include <if_varp.h> |
---|
42 | |
---|
43 | struct sk_buff; |
---|
44 | |
---|
45 | struct IOStream; |
---|
46 | struct Vmac; |
---|
47 | struct Vif; |
---|
48 | struct SkbContext; |
---|
49 | struct VarpAddr; |
---|
50 | struct Tunnel; |
---|
51 | struct SAState; |
---|
52 | |
---|
53 | /** Vnet property record. */ |
---|
54 | typedef struct Vnet { |
---|
55 | /** Vnet id. */ |
---|
56 | struct VnetId vnet; |
---|
57 | /** Reference count. */ |
---|
58 | atomic_t refcount; |
---|
59 | /** Security flag. If true the vnet requires ESP. */ |
---|
60 | int security; |
---|
61 | char device[IFNAMSIZ]; |
---|
62 | |
---|
63 | struct net_device *dev; |
---|
64 | |
---|
65 | /** Max size of the header. */ |
---|
66 | int header_n; |
---|
67 | int mtu; |
---|
68 | /** Statistics. */ |
---|
69 | struct net_device_stats stats; |
---|
70 | int recursion; |
---|
71 | } Vnet; |
---|
72 | |
---|
73 | extern void vnet_print(struct IOStream *io); |
---|
74 | extern void Vnet_print(struct Vnet *info, struct IOStream *io); |
---|
75 | |
---|
76 | extern int Vnet_lookup(struct VnetId *vnet, struct Vnet **info); |
---|
77 | extern int Vnet_create(struct Vnet *info); |
---|
78 | extern int Vnet_add(struct Vnet *info); |
---|
79 | extern int Vnet_del(struct VnetId *vnet); |
---|
80 | extern void Vnet_incref(struct Vnet *info); |
---|
81 | extern void Vnet_decref(struct Vnet *info); |
---|
82 | extern int Vnet_alloc(struct Vnet **info); |
---|
83 | extern struct Vnet *vnet_physical; |
---|
84 | |
---|
85 | extern int skb_xmit(struct sk_buff *skb); |
---|
86 | extern int skb_xmit_fwd(struct sk_buff *skb); |
---|
87 | extern int vnet_skb_send(struct sk_buff *skb, struct VnetId *vnet); |
---|
88 | extern int vnet_skb_recv(struct sk_buff *skb, struct Vnet *vnet); |
---|
89 | |
---|
90 | extern int vnet_check_context(struct VnetId *vnet, struct SkbContext *context, struct Vnet **vinfo); |
---|
91 | |
---|
92 | extern int vnet_tunnel_open(struct VnetId *vnet, struct VarpAddr *addr, struct Tunnel **tunnel); |
---|
93 | extern int vnet_tunnel_lookup(struct VnetId *vnet, struct VarpAddr *addr, struct Tunnel **tunnel); |
---|
94 | extern int vnet_tunnel_send(struct VnetId *vnet, struct VarpAddr *addr, struct sk_buff *skb); |
---|
95 | |
---|
96 | extern int vnet_init(void); |
---|
97 | |
---|
98 | extern int vnet_sa_security(u32 spi, int protocol, u32 addr); |
---|
99 | extern int vnet_sa_create(u32 spi, int protocol, u32 addr, struct SAState **sa); |
---|
100 | |
---|
101 | enum { |
---|
102 | VNET_PHYS = 1, |
---|
103 | VNET_VIF = 2, |
---|
104 | }; |
---|
105 | |
---|
106 | extern struct HashTable *vnet_table; |
---|
107 | |
---|
108 | #endif /* !__VNET_VNET_H__ */ |
---|