2
* Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
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.
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
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
19
#ifndef __VNET_TUNNEL_H__
20
#define __VNET_TUNNEL_H__
23
#include <linux/types.h>
24
#include <asm/atomic.h>
28
//#include <linux/types.h>
29
#include "sys_kernel.h"
39
typedef struct TunnelType {
41
int (*open)(struct Tunnel *tunnel);
42
int (*send)(struct Tunnel *tunnel, struct sk_buff *skb);
43
void (*close)(struct Tunnel *tunnel);
46
typedef struct TunnelStats {
53
typedef struct TunnelKey {
58
typedef struct Tunnel {
59
/** Key identifying the tunnel. Must be first. */
61
/** Reference count. */
64
struct TunnelType *type;
66
struct TunnelStats send_stats;
67
/** Type-dependent state. */
69
/** Underlying tunnel (may be null). */
73
extern void Tunnel_free(struct Tunnel *tunnel);
75
/** Decrement the reference count, freeing if zero.
77
* @param tunnel tunnel (may be null)
79
static inline void Tunnel_decref(struct Tunnel *tunnel){
81
if(atomic_dec_and_test(&tunnel->refcount)){
86
/** Increment the reference count.
88
* @param tunnel tunnel (may be null)
90
static inline void Tunnel_incref(struct Tunnel *tunnel){
92
atomic_inc(&tunnel->refcount);
95
extern int Tunnel_init(void);
96
extern int Tunnel_lookup(struct VnetId *vnet, struct VarpAddr *addr, struct Tunnel **tunnel);
97
extern int Tunnel_open(struct VnetId *vnet, struct VarpAddr *addr,
98
int (*ctor)(struct VnetId *vnet,
99
struct VarpAddr *addr,
100
struct Tunnel **ptunnel),
101
struct Tunnel **ptunnel);
102
extern int Tunnel_add(struct Tunnel *tunnel);
103
extern int Tunnel_del(struct Tunnel *tunnel);
104
extern void Tunnel_print(struct Tunnel *tunnel);
105
extern int Tunnel_send(struct Tunnel *tunnel, struct sk_buff *skb);
107
extern int Tunnel_create(struct TunnelType *type, struct VnetId *vnet, struct VarpAddr *addr,
108
struct Tunnel *base, struct Tunnel **tunnelp);
110
extern int tunnel_module_init(void);
111
extern void tunnel_module_exit(void);
113
#endif /* !__VNET_TUNNEL_H__ */