refresh patches
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.21 / 999-backport_ip_hdr_and_friends.patch
1 --- a/include/linux/ip.h
2 +++ b/include/linux/ip.h
3 @@ -104,6 +104,16 @@ struct iphdr {
4         /*The options start here. */
5  };
6  
7 +#ifdef __KERNEL__
8 +#include <linux/skbuff.h>
9 +
10 +static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
11 +{
12 +       return (struct iphdr *)skb_network_header(skb);
13 +}
14 +
15 +#endif
16 +
17  struct ip_auth_hdr {
18         __u8  nexthdr;
19         __u8  hdrlen;           /* This one is measured in 32 bit units! */
20 --- a/include/linux/skbuff.h
21 +++ b/include/linux/skbuff.h
22 @@ -966,6 +966,16 @@ static inline void skb_reserve(struct sk
23         skb->tail += len;
24  }
25  
26 +static inline unsigned char *skb_network_header(const struct sk_buff *skb)
27 +{
28 +       return skb->nh.raw;
29 +}
30 +
31 +static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
32 +{
33 +       return skb->tail;
34 +}
35 +
36  /*
37   * CPUs often take a performance hit when accessing unaligned memory
38   * locations. The actual performance hit varies, it can be small if the
39 --- a/include/net/ip.h
40 +++ b/include/net/ip.h
41 @@ -43,6 +43,11 @@ struct inet_skb_parm
42  #define IPSKB_REROUTED         16
43  };
44  
45 +static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
46 +{
47 +       return ip_hdr(skb)->ihl * 4;
48 +}
49 +
50  struct ipcm_cookie
51  {
52         __be32                  addr;