From: Guo-Fu Tseng Date: Tue, 28 Jun 2011 13:48:53 +0000 (+0800) Subject: Fix compile error for udp header parse X-Git-Tag: bp-1.0.8.1~4 X-Git-Url: https://bbs.cooldavid.org/git/?p=jme.git;a=commitdiff_plain;h=65ff9ddf0790b82e63c4c678d2be91fdfc313659 Fix compile error for udp header parse --- diff --git a/jme.c b/jme.c index 351fb3b..4e4613a 100644 --- a/jme.c +++ b/jme.c @@ -979,11 +979,29 @@ static u16 jme_udpsum(struct sk_buff *skb) { u16 csum = 0xFFFFu; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) + struct iphdr *iph; + int iphlen; + struct udphdr *udph; +#endif if (skb->len < (ETH_HLEN + sizeof(struct iphdr))) return csum; if (skb->protocol != htons(ETH_P_IP)) return csum; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) + iph = (struct iphdr *)skb_pull(skb, ETH_HLEN); + iphlen = (iph->ihl << 2); + if ((iph->protocol != IPPROTO_UDP) || + (skb->len < (iphlen + sizeof(struct udphdr)))) { + skb_push(skb, ETH_HLEN); + return csum; + } + udph = (struct udphdr *)skb_pull(skb, iphlen); + csum = udph->check; + skb_push(skb, iphlen); + skb_push(skb, ETH_HLEN); +#else skb_set_network_header(skb, ETH_HLEN); if ((ip_hdr(skb)->protocol != IPPROTO_UDP) || (skb->len < (ETH_HLEN + @@ -997,6 +1015,7 @@ jme_udpsum(struct sk_buff *skb) csum = udp_hdr(skb)->check; skb_reset_transport_header(skb); skb_reset_network_header(skb); +#endif return csum; }