ia64/xen-unstable

view tools/vnet/vnet-module/skb_context.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
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__ */