aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-25 21:04:18 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:25:31 -0400
commit9c70220b73908f64792422a2c39c593c4792f2c5 (patch)
tree2090ea10aaa2714a5e095bae8cc02e743c378a3a /include
parenta27ef749e7be3b06fb58df53d94eb97a21f18707 (diff)
[SK_BUFF]: Introduce skb_transport_header(skb)
For the places where we need a pointer to the transport header, it is still legal to touch skb->h.raw directly if just adding to, subtracting from or setting it to another layer header. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/atalk.h4
-rw-r--r--include/linux/dccp.h19
-rw-r--r--include/linux/icmp.h2
-rw-r--r--include/linux/icmpv6.h2
-rw-r--r--include/linux/igmp.h6
-rw-r--r--include/linux/ip.h2
-rw-r--r--include/linux/ipv6.h2
-rw-r--r--include/linux/sctp.h2
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--include/linux/tcp.h2
-rw-r--r--include/linux/udp.h2
-rw-r--r--include/net/ipx.h2
-rw-r--r--include/net/pkt_cls.h2
-rw-r--r--include/net/udp.h4
14 files changed, 33 insertions, 23 deletions
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
index d12984ddaa9f..ced8a1ed080c 100644
--- a/include/linux/atalk.h
+++ b/include/linux/atalk.h
@@ -101,7 +101,7 @@ struct ddpehdr {
101 101
102static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb) 102static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
103{ 103{
104 return (struct ddpehdr *)skb->h.raw; 104 return (struct ddpehdr *)skb_transport_header(skb);
105} 105}
106 106
107/* AppleTalk AARP headers */ 107/* AppleTalk AARP headers */
@@ -129,7 +129,7 @@ struct elapaarp {
129 129
130static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb) 130static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
131{ 131{
132 return (struct elapaarp *)skb->h.raw; 132 return (struct elapaarp *)skb_transport_header(skb);
133} 133}
134 134
135/* Not specified - how long till we drop a resolved entry */ 135/* Not specified - how long till we drop a resolved entry */
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 1f4df61735f7..fdd4217f1047 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -260,19 +260,20 @@ enum {
260 260
261static inline struct dccp_hdr *dccp_hdr(const struct sk_buff *skb) 261static inline struct dccp_hdr *dccp_hdr(const struct sk_buff *skb)
262{ 262{
263 return (struct dccp_hdr *)skb->h.raw; 263 return (struct dccp_hdr *)skb_transport_header(skb);
264} 264}
265 265
266static inline struct dccp_hdr *dccp_zeroed_hdr(struct sk_buff *skb, int headlen) 266static inline struct dccp_hdr *dccp_zeroed_hdr(struct sk_buff *skb, int headlen)
267{ 267{
268 skb_push(skb, headlen); 268 skb_push(skb, headlen);
269 skb_reset_transport_header(skb); 269 skb_reset_transport_header(skb);
270 return memset(skb->h.raw, 0, headlen); 270 return memset(skb_transport_header(skb), 0, headlen);
271} 271}
272 272
273static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb) 273static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb)
274{ 274{
275 return (struct dccp_hdr_ext *)(skb->h.raw + sizeof(struct dccp_hdr)); 275 return (struct dccp_hdr_ext *)(skb_transport_header(skb) +
276 sizeof(struct dccp_hdr));
276} 277}
277 278
278static inline unsigned int __dccp_basic_hdr_len(const struct dccp_hdr *dh) 279static inline unsigned int __dccp_basic_hdr_len(const struct dccp_hdr *dh)
@@ -301,12 +302,14 @@ static inline __u64 dccp_hdr_seq(const struct sk_buff *skb)
301 302
302static inline struct dccp_hdr_request *dccp_hdr_request(struct sk_buff *skb) 303static inline struct dccp_hdr_request *dccp_hdr_request(struct sk_buff *skb)
303{ 304{
304 return (struct dccp_hdr_request *)(skb->h.raw + dccp_basic_hdr_len(skb)); 305 return (struct dccp_hdr_request *)(skb_transport_header(skb) +
306 dccp_basic_hdr_len(skb));
305} 307}
306 308
307static inline struct dccp_hdr_ack_bits *dccp_hdr_ack_bits(const struct sk_buff *skb) 309static inline struct dccp_hdr_ack_bits *dccp_hdr_ack_bits(const struct sk_buff *skb)
308{ 310{
309 return (struct dccp_hdr_ack_bits *)(skb->h.raw + dccp_basic_hdr_len(skb)); 311 return (struct dccp_hdr_ack_bits *)(skb_transport_header(skb) +
312 dccp_basic_hdr_len(skb));
310} 313}
311 314
312static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb) 315static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb)
@@ -317,12 +320,14 @@ static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb)
317 320
318static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb) 321static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb)
319{ 322{
320 return (struct dccp_hdr_response *)(skb->h.raw + dccp_basic_hdr_len(skb)); 323 return (struct dccp_hdr_response *)(skb_transport_header(skb) +
324 dccp_basic_hdr_len(skb));
321} 325}
322 326
323static inline struct dccp_hdr_reset *dccp_hdr_reset(struct sk_buff *skb) 327static inline struct dccp_hdr_reset *dccp_hdr_reset(struct sk_buff *skb)
324{ 328{
325 return (struct dccp_hdr_reset *)(skb->h.raw + dccp_basic_hdr_len(skb)); 329 return (struct dccp_hdr_reset *)(skb_transport_header(skb) +
330 dccp_basic_hdr_len(skb));
326} 331}
327 332
328static inline unsigned int __dccp_hdr_len(const struct dccp_hdr *dh) 333static inline unsigned int __dccp_hdr_len(const struct dccp_hdr *dh)
diff --git a/include/linux/icmp.h b/include/linux/icmp.h
index cd3017a15789..474f2a51cf0a 100644
--- a/include/linux/icmp.h
+++ b/include/linux/icmp.h
@@ -87,7 +87,7 @@ struct icmphdr {
87 87
88static inline struct icmphdr *icmp_hdr(const struct sk_buff *skb) 88static inline struct icmphdr *icmp_hdr(const struct sk_buff *skb)
89{ 89{
90 return (struct icmphdr *)skb->h.raw; 90 return (struct icmphdr *)skb_transport_header(skb);
91} 91}
92#endif 92#endif
93 93
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index 0b5ba5eb7ed2..7c5e9817e998 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -80,7 +80,7 @@ struct icmp6hdr {
80 80
81static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) 81static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
82{ 82{
83 return (struct icmp6hdr *)skb->h.raw; 83 return (struct icmp6hdr *)skb_transport_header(skb);
84} 84}
85#endif 85#endif
86 86
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index ca285527b879..f510e7e382a8 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -85,19 +85,19 @@ struct igmpv3_query {
85 85
86static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb) 86static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
87{ 87{
88 return (struct igmphdr *)skb->h.raw; 88 return (struct igmphdr *)skb_transport_header(skb);
89} 89}
90 90
91static inline struct igmpv3_report * 91static inline struct igmpv3_report *
92 igmpv3_report_hdr(const struct sk_buff *skb) 92 igmpv3_report_hdr(const struct sk_buff *skb)
93{ 93{
94 return (struct igmpv3_report *)skb->h.raw; 94 return (struct igmpv3_report *)skb_transport_header(skb);
95} 95}
96 96
97static inline struct igmpv3_query * 97static inline struct igmpv3_query *
98 igmpv3_query_hdr(const struct sk_buff *skb) 98 igmpv3_query_hdr(const struct sk_buff *skb)
99{ 99{
100 return (struct igmpv3_query *)skb->h.raw; 100 return (struct igmpv3_query *)skb_transport_header(skb);
101} 101}
102#endif 102#endif
103 103
diff --git a/include/linux/ip.h b/include/linux/ip.h
index 19578440b5fc..bd0a2a8631c6 100644
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -114,7 +114,7 @@ static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
114 114
115static inline struct iphdr *ipip_hdr(const struct sk_buff *skb) 115static inline struct iphdr *ipip_hdr(const struct sk_buff *skb)
116{ 116{
117 return (struct iphdr *)skb->h.raw; 117 return (struct iphdr *)skb_transport_header(skb);
118} 118}
119#endif 119#endif
120 120
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index b768fcc0a4c4..09ea01a8a99c 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -230,7 +230,7 @@ static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
230 230
231static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb) 231static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb)
232{ 232{
233 return (struct ipv6hdr *)skb->h.raw; 233 return (struct ipv6hdr *)skb_transport_header(skb);
234} 234}
235 235
236/* 236/*
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index d76767dfe59e..d70df61a029f 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -68,7 +68,7 @@ typedef struct sctphdr {
68 68
69static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb) 69static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
70{ 70{
71 return (struct sctphdr *)skb->h.raw; 71 return (struct sctphdr *)skb_transport_header(skb);
72} 72}
73#endif 73#endif
74 74
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d3f186230ee2..39a6da243b24 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -951,6 +951,11 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
951 skb->tail += len; 951 skb->tail += len;
952} 952}
953 953
954static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
955{
956 return skb->h.raw;
957}
958
954static inline void skb_reset_transport_header(struct sk_buff *skb) 959static inline void skb_reset_transport_header(struct sk_buff *skb)
955{ 960{
956 skb->h.raw = skb->data; 961 skb->h.raw = skb->data;
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 911d937fb4c1..c6b9f92e8289 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -180,7 +180,7 @@ struct tcp_md5sig {
180 180
181static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb) 181static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
182{ 182{
183 return (struct tcphdr *)skb->h.raw; 183 return (struct tcphdr *)skb_transport_header(skb);
184} 184}
185 185
186static inline unsigned int tcp_hdrlen(const struct sk_buff *skb) 186static inline unsigned int tcp_hdrlen(const struct sk_buff *skb)
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 1f58503af9a6..6de445c31a64 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -31,7 +31,7 @@ struct udphdr {
31 31
32static inline struct udphdr *udp_hdr(const struct sk_buff *skb) 32static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
33{ 33{
34 return (struct udphdr *)skb->h.raw; 34 return (struct udphdr *)skb_transport_header(skb);
35} 35}
36#endif 36#endif
37 37
diff --git a/include/net/ipx.h b/include/net/ipx.h
index c6b2ee610866..4cc0b4eca948 100644
--- a/include/net/ipx.h
+++ b/include/net/ipx.h
@@ -43,7 +43,7 @@ struct ipxhdr {
43 43
44static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb) 44static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
45{ 45{
46 return (struct ipxhdr *)skb->h.raw; 46 return (struct ipxhdr *)skb_transport_header(skb);
47} 47}
48 48
49struct ipx_interface { 49struct ipx_interface {
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index 880eb7b54164..dcb3a91f1364 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -328,7 +328,7 @@ static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer)
328 case TCF_LAYER_NETWORK: 328 case TCF_LAYER_NETWORK:
329 return skb_network_header(skb); 329 return skb_network_header(skb);
330 case TCF_LAYER_TRANSPORT: 330 case TCF_LAYER_TRANSPORT:
331 return skb->h.raw; 331 return skb_transport_header(skb);
332 } 332 }
333 333
334 return NULL; 334 return NULL;
diff --git a/include/net/udp.h b/include/net/udp.h
index 4a9699f79281..4906ed7113e7 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -89,8 +89,8 @@ static inline int udp_lib_checksum_complete(struct sk_buff *skb)
89 */ 89 */
90static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb) 90static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb)
91{ 91{
92 __wsum csum = csum_partial(skb->h.raw, sizeof(struct udphdr), 0); 92 __wsum csum = csum_partial(skb_transport_header(skb),
93 93 sizeof(struct udphdr), 0);
94 skb_queue_walk(&sk->sk_write_queue, skb) { 94 skb_queue_walk(&sk->sk_write_queue, skb) {
95 csum = csum_add(csum, skb->csum); 95 csum = csum_add(csum, skb->csum);
96 } 96 }