[ICMP6]: Introduce icmp6_hdr()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 13 Mar 2007 17:03:22 +0000 (14:03 -0300)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:25:20 +0000 (22:25 -0700)
For consistency with all the other skb->h.raw accessors.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/icmpv6.h
net/ipv6/datagram.c
net/ipv6/icmp.c
net/ipv6/mcast.c
net/ipv6/ndisc.c

index 68d3526..0b5ba5e 100644 (file)
@@ -75,6 +75,15 @@ struct icmp6hdr {
 #define icmp6_router_pref      icmp6_dataun.u_nd_ra.router_pref
 };
 
+#ifdef __KERNEL__
+#include <linux/skbuff.h>
+
+static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
+{
+       return (struct icmp6hdr *)skb->h.raw;
+}
+#endif
+
 #define ICMPV6_ROUTER_PREF_LOW         0x3
 #define ICMPV6_ROUTER_PREF_MEDIUM      0x0
 #define ICMPV6_ROUTER_PREF_HIGH                0x1
index f429290..feba6b1 100644 (file)
@@ -209,7 +209,7 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
                     __be16 port, u32 info, u8 *payload)
 {
        struct ipv6_pinfo *np  = inet6_sk(sk);
-       struct icmp6hdr *icmph = (struct icmp6hdr *)skb->h.raw;
+       struct icmp6hdr *icmph = icmp6_hdr(skb);
        struct sock_exterr_skb *serr;
 
        if (!np->recverr)
index 3a01eff..d3edc3c 100644 (file)
@@ -222,7 +222,7 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
        if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
                goto out;
 
-       icmp6h = (struct icmp6hdr*) skb->h.raw;
+       icmp6h = icmp6_hdr(skb);
        memcpy(icmp6h, thdr, sizeof(struct icmp6hdr));
        icmp6h->icmp6_cksum = 0;
 
@@ -476,7 +476,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
        struct inet6_dev *idev;
        struct ipv6_pinfo *np;
        struct in6_addr *saddr = NULL;
-       struct icmp6hdr *icmph = (struct icmp6hdr *) skb->h.raw;
+       struct icmp6hdr *icmph = icmp6_hdr(skb);
        struct icmp6hdr tmp_hdr;
        struct flowi fl;
        struct icmpv6_msg msg;
@@ -651,7 +651,7 @@ static int icmpv6_rcv(struct sk_buff **pskb)
        if (!pskb_pull(skb, sizeof(struct icmp6hdr)))
                goto discard_it;
 
-       hdr = (struct icmp6hdr *) skb->h.raw;
+       hdr = icmp6_hdr(skb);
 
        type = hdr->icmp6_type;
 
@@ -677,7 +677,7 @@ static int icmpv6_rcv(struct sk_buff **pskb)
                 */
                if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
                        goto discard_it;
-               hdr = (struct icmp6hdr *) skb->h.raw;
+               hdr = icmp6_hdr(skb);
                orig_hdr = (struct ipv6hdr *) (hdr + 1);
                rt6_pmtu_discovery(&orig_hdr->daddr, &orig_hdr->saddr, dev,
                                   ntohl(hdr->icmp6_mtu));
index b2b37ba..1f2a3be 100644 (file)
@@ -988,7 +988,7 @@ int ipv6_is_mld(struct sk_buff *skb, int nexthdr)
        if (!pskb_may_pull(skb, sizeof(struct icmp6hdr)))
                return 0;
 
-       pic = (struct icmp6hdr *)skb->h.raw;
+       pic = icmp6_hdr(skb);
 
        switch (pic->icmp6_type) {
        case ICMPV6_MGM_QUERY:
@@ -1179,7 +1179,7 @@ int igmp6_event_query(struct sk_buff *skb)
        if (idev == NULL)
                return 0;
 
-       hdr = (struct icmp6hdr *) skb->h.raw;
+       hdr = icmp6_hdr(skb);
        group = (struct in6_addr *) (hdr + 1);
        group_type = ipv6_addr_type(group);
 
@@ -1300,7 +1300,7 @@ int igmp6_event_report(struct sk_buff *skb)
        if (!pskb_may_pull(skb, sizeof(struct in6_addr)))
                return -EINVAL;
 
-       hdr = (struct icmp6hdr*) skb->h.raw;
+       hdr = icmp6_hdr(skb);
 
        /* Drop reports with not link local source */
        addr_type = ipv6_addr_type(&ipv6_hdr(skb)->saddr);
index 00feb4c..8b946f5 100644 (file)
@@ -1366,7 +1366,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
                return;
        }
 
-       icmph = (struct icmp6hdr *) skb->h.raw;
+       icmph = icmp6_hdr(skb);
        target = (struct in6_addr *) (icmph + 1);
        dest = target + 1;