2
* Copyright (C) 2004 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
#include <linux/config.h>
20
#include <linux/kernel.h>
21
#include <linux/skbuff.h>
22
#include <linux/slab.h>
24
#include <skb_context.h>
26
#define MODULE_NAME "VNET"
31
SkbContext *SkbContext_create(u32 vnet, u32 addr, int protocol, void *data,
32
void (*free_fn)(SkbContext *)){
33
SkbContext *context = NULL;
35
context = kmalloc(sizeof(SkbContext), GFP_ATOMIC);
36
if(!context) goto exit;
39
context->protocol = protocol;
41
context->free_fn = free_fn;
43
atomic_set(&context ->refcount, 1);
48
void SkbContext_free(SkbContext *context){
50
if(context->next) SkbContext_decref(context->next);
51
if(context->free_fn) context->free_fn(context);
54
context->protocol = 0;
55
context->free_fn = NULL;
61
int SkbContext_push(SkbContext **val, u32 vnet, u32 addr, int protocol,
62
void *data, void (*free_fn)(SkbContext *)){
64
SkbContext *context = NULL;
66
dprintf("> vnet=%u addr=%u.%u.%u.%u protocol=%d\n",
67
vnet, NIPQUAD(addr), protocol);
68
context = SkbContext_create(vnet, addr, protocol, data, free_fn);
76
dprintf("< err=%d\n", err);
80
int skb_push_context(struct sk_buff *skb, u32 vnet, u32 addr, int protocol,
81
void *data, void (*free_fn)(SkbContext *)){
83
//SkbContext *ctxt = SKB_CONTEXT(skb);
84
dprintf("> skb=%p\n", skb);
86
//err = SkbContext_push(&ctxt, vnet, addr, protocol, data, free_fn); //todo fixme
87
//SKB_CONTEXT(skb) = ctxt;//todo fixme
88
dprintf("< err=%d\n", err);