--- ../patch-o-matic-ng/patchlets/IPV4OPTSSTRIP/linux-2.6/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c.orig 2007-05-02 15:32:00.000000000 +0200 +++ ../patch-o-matic-ng/patchlets/IPV4OPTSSTRIP/linux-2.6/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c 2007-09-13 21:19:41.000000000 +0200 @@ -5,6 +5,7 @@ * This software is distributed under GNU GPL v2, 1991 */ +#include #include #include #include @@ -21,8 +22,15 @@ const struct net_device *in, const struct net_device *out, unsigned int hooknum, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) + const struct xt_target *target, +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) const void *targinfo, void *userinfo) +#else + const void *targinfo) +#endif { struct iphdr *iph; struct sk_buff *skb; @@ -30,12 +38,21 @@ unsigned char *optiph; int l; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19) + if (!skb_make_writable(pskb, (*pskb)->len)) +#else if (!skb_ip_make_writable(pskb, (*pskb)->len)) +#endif return NF_DROP; skb = (*pskb); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) + iph = ip_hdr(*pskb); + optiph = skb->network_header; +#else iph = (*pskb)->nh.iph; optiph = skb->nh.raw; +#endif l = ((struct ip_options *)(&(IPCB(skb)->opt)))->optlen; /* if no options in packet then nothing to clear. */ @@ -54,9 +71,18 @@ static int checkentry(const char *tablename, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + const void *e, +#else const struct ipt_entry *e, +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) + const struct xt_target *target, +#endif void *targinfo, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) unsigned int targinfosize, +#endif unsigned int hook_mask) { if (strcmp(tablename, "mangle")) { @@ -66,21 +92,35 @@ /* nothing else to check because no parameters */ return 1; } - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) +static struct xt_target xt_ipv4optsstrip_reg = { +#else static struct ipt_target ipt_ipv4optsstrip_reg = { +#endif .name = "IPV4OPTSSTRIP", +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) + .family = AF_INET, +#endif .target = target, .checkentry = checkentry, .me = THIS_MODULE }; static int __init init(void) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) + return xt_register_target(&xt_ipv4optsstrip_reg); +#else return ipt_register_target(&ipt_ipv4optsstrip_reg); +#endif } static void __exit fini(void) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) + xt_unregister_target(&xt_ipv4optsstrip_reg); +#else ipt_unregister_target(&ipt_ipv4optsstrip_reg); +#endif } module_init(init);