diff -Nru ipp2p-0.8.2.orig/ipt_ipp2p.c ipp2p-0.8.2/ipt_ipp2p.c --- ipp2p-0.8.2.orig/ipt_ipp2p.c 2006-09-27 11:52:00.000000000 +0200 +++ ipp2p-0.8.2/ipt_ipp2p.c 2009-09-20 14:37:00.000000000 +0200 @@ -2,9 +2,18 @@ #include #endif #include -#include #include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) +# include +# define ipt_register_match xt_register_match +# define ipt_unregister_match xt_unregister_match +# define ipt_match xt_match +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) */ +# include //#include +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) */ + #include "ipt_ipp2p.h" #include #include @@ -725,8 +734,15 @@ }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) +static bool +#else static int +#endif match(const struct sk_buff *skb, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + const struct xt_match_param *params +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ const struct net_device *in, const struct net_device *out, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) @@ -734,21 +750,36 @@ const void *matchinfo, int offset, unsigned int myprotoff, -#else +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) */ const void *matchinfo, int offset, -#endif +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) const void *hdr, u_int16_t datalen, #endif - int *hotdrop) -{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) + bool *hotdrop +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ + int *hotdrop +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ +) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + const struct ipt_p2p_info *info = params->matchinfo; + const int offset = params->fragoff; +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ const struct ipt_p2p_info *info = matchinfo; +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ unsigned char *haystack; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) + struct iphdr *ip = ip_hdr(skb); +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ struct iphdr *ip = skb->nh.iph; +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ int p2p_result = 0, i = 0; // int head_len; int hlen = ntohs(ip->tot_len)-(ip->ihl*4); /*hlen = packet-data length*/ @@ -822,8 +853,16 @@ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) +static bool +#else static int -checkentry(const char *tablename, +#endif +checkentry( +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + const struct xt_mtchk_param *params +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ + const char *tablename, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) const void *ip, const struct xt_match *mymatch, @@ -831,8 +870,12 @@ const struct ipt_ip *ip, #endif void *matchinfo, +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) unsigned int matchsize, - unsigned int hook_mask) +#endif + unsigned int hook_mask +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ +) { /* Must specify -p tcp */ /* if (ip->proto != IPPROTO_TCP || (ip->invflags & IPT_INV_PROTO)) { @@ -843,15 +886,6 @@ } -// TODO: find out what this structure is for (scheme taken -// from kernel sources) -// content seems to have a length of 8 bytes -// (at least on my x86 machine) -struct ipp2p_match_info { - long int dunno_what_this_is_for; - long int i_also_dunno_what_this_is_for; -}; - static struct ipt_match ipp2p_match = { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) { NULL, NULL }, @@ -860,17 +894,16 @@ &checkentry, NULL, THIS_MODULE -#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) .name = "ipp2p", .match = &match, .checkentry = &checkentry, .me = THIS_MODULE, -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) */ .name = "ipp2p", .match = &match, .family = AF_INET, - .matchsize = sizeof(struct ipp2p_match_info), + .matchsize = XT_ALIGN(sizeof(struct ipt_p2p_info)), .checkentry = &checkentry, .me = THIS_MODULE, #endif