ia64/xen-unstable

view tools/vnet/vnet-module/skb_context.h @ 8740:3d7ea7972b39

Update patches for linux 2.6.15.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Feb 02 17:16:00 2006 +0000 (2006-02-02)
parents 0a4b76b6b5a0
children 71b0f00f6344
line source
1 /*
2 * Copyright (C) 2004 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 */
20 #ifndef __VNET_SKB_CONTEXT_H__
21 #define __VNET_SKB_CONTEXT_H__
23 #include <linux/config.h>
24 #include <linux/kernel.h>
25 #include <asm/atomic.h>
26 #include <linux/types.h>
28 /** Structure used to record inbound processing path for skbs.
29 * For example, the ETHERIP protocol handler can use this to
30 * tell whether an inbound packet came through IPSEC ESP or not.
31 */
32 typedef struct SkbContext {
33 u32 vnet;
34 u32 addr;
35 int protocol;
36 void *data;
37 void (*free_fn)(struct SkbContext *);
38 atomic_t refcount;
39 struct SkbContext *next;
40 } SkbContext;
42 /** Decrement the reference count, freeing if zero.
43 *
44 * @param context context (may be null)
45 */
46 static inline void SkbContext_decref(SkbContext *context){
47 extern void SkbContext_free(SkbContext *context);
48 if(!context) return;
49 if(atomic_dec_and_test(&context->refcount)){
50 SkbContext_free(context);
51 }
52 }
54 /** Increment the reference count.
55 *
56 * @param context context (may be null)
57 */
58 static inline void SkbContext_incref(SkbContext *context){
59 if(!context) return;
60 atomic_inc(&context->refcount);
61 }
63 extern SkbContext *SkbContext_create(u32 vnet, u32 addr, int protocol, void *data,
64 void (*free_fn)(SkbContext *));
66 extern int SkbContext_push(SkbContext **val, u32 vnet, u32 addr, int protocol,
67 void *data, void (*free_fn)(SkbContext *));
69 struct sk_buff;
70 extern int skb_push_context(struct sk_buff *skb, u32 vnet, u32 addr, int protocol,
71 void *data, void (*free_fn)(SkbContext *));
73 //todo: fixme
74 #define SKB_CONTEXT(_skb) ((SkbContext *)(&(_skb)->cb[0]))
76 #endif /* !__VNET_SKB_CONTEXT_H__ */