ia64/xen-unstable

view tools/vnet/vnet-module/skb_util.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 3233e7ecfa9f
children 06d84bf87159
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 */
19 #ifndef _VNET_SKB_UTIL_H_
20 #define _VNET_SKB_UTIL_H_
22 #include <net/route.h>
23 #include <linux/skbuff.h>
25 struct scatterlist;
27 extern int skb_make_room(struct sk_buff **pskb, struct sk_buff *skb, int head_n, int tail_n);
29 extern int skb_put_bits(const struct sk_buff *skb, int offset, void *src, int len);
31 extern int pskb_put(struct sk_buff *skb, int n);
33 extern void skb_print_bits(struct sk_buff *skb, int offset, int n);
35 extern void buf_print(char *buf, int n);
37 extern void *skb_trim_tail(struct sk_buff *skb, int n);
39 extern int skb_scatterlist(struct sk_buff *skb, struct scatterlist *sg,
40 int *sg_n, int offset, int len);
42 extern void print_skb_data(char *msg, int count, struct sk_buff *skb, u8 *data, int len);
45 /* The mac.ethernet field went away in 2.6 in favour of eth_hdr().
46 */
47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
48 #else
49 static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
50 {
51 return (struct ethhdr *)skb->mac.raw;
52 }
53 #endif
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
58 static inline int skb_route(struct sk_buff *skb, struct rtable **prt){
59 int err = 0;
60 struct flowi fl = {
61 .nl_u = {
62 .ip4_u = {
63 .daddr = skb->nh.iph->daddr,
64 .saddr = skb->nh.iph->saddr,
65 .tos = skb->nh.iph->tos,
66 }
67 }
68 };
70 if(skb->dev){
71 fl.oif = skb->dev->ifindex;
72 }
73 err = ip_route_output_key(prt, &fl);
74 return err;
75 }
77 #else
79 static inline int skb_route(struct sk_buff *skb, struct rtable **prt){
80 int err = 0;
81 struct rt_key key = { };
82 key.dst = skb->nh.iph->daddr;
83 key.src = skb->nh.iph->saddr;
84 key.tos = skb->nh.iph->tos;
85 if(skb->dev){
86 key.oif = skb->dev->ifindex;
87 }
88 err = ip_route_output_key(prt, &key);
89 return err;
90 }
92 #endif
94 #endif