--- ../patch-o-matic-ng/patchlets/time/linux-2.6/net/ipv4/netfilter/ipt_time.c.orig 2007-07-11 23:34:46.000000000 +0200 +++ ../patch-o-matic-ng/patchlets/time/linux-2.6/net/ipv4/netfilter/ipt_time.c 2008-03-15 20:55:56.000000000 +0100 @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -43,51 +42,33 @@ void localtime(const u32 time, struct tm *r); -static int +static bool match(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) const struct xt_match *match, -#endif const void *matchinfo, int offset, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) unsigned int protoff, -#endif - int *hotdrop) + bool *hotdrop) { const struct ipt_time_info *info = matchinfo; /* match info for rule */ struct tm currenttime; /* time human readable */ u_int8_t days_of_week[7] = {64, 32, 16, 8, 4, 2, 1}; u_int16_t packet_time; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) struct timeval tv; -#endif /* We might not have a timestamp, get one */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) if (skb->tstamp.tv64 == 0) -#else - if (skb->tstamp.off_sec == 0) -#endif __net_timestamp((struct sk_buff *)skb); /* First we make sure we are in the date start-stop boundaries */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) tv = ktime_to_timeval(skb->tstamp); if ((tv.tv_sec < info->date_start) || (tv.tv_sec > info->date_stop)) -#else - if ((skb->tstamp.off_sec < info->date_start) || (skb->tstamp.off_sec > info->date_stop)) -#endif return 0; /* We are outside the date boundaries */ /* Transform the timestamp of the packet, in a human readable form */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) localtime(tv.tv_sec, ¤ttime); -#else - localtime(skb->tstamp.off_sec, ¤ttime); -#endif /* check if we match this timestamp, we start by the days... */ @@ -108,29 +89,15 @@ return 1; } -static int +static bool checkentry(const char *tablename, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) const void *ip, -#else - const struct ipt_ip *ip, -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) const struct xt_match *match, -#endif void *matchinfo, -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) - unsigned int matchsize, -#endif unsigned int hook_mask) { struct ipt_time_info *info = matchinfo; /* match info for rule */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) - /* Check the size */ - if (matchsize != IPT_ALIGN(sizeof(struct ipt_time_info))) - return 0; -#endif /* Now check the coherence of the data ... */ if ((info->time_start > 1439) || /* 23*60+59 = 1439*/ @@ -143,19 +110,11 @@ return 1; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) static struct xt_match time_match = { -#else -static struct ipt_match time_match = { -#endif .name = "time", -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) .family = AF_INET, -#endif .match = &match, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) .matchsize = sizeof(struct ipt_time_info), -#endif .checkentry = &checkentry, .me = THIS_MODULE }; @@ -163,20 +122,12 @@ static int __init init(void) { printk("ipt_time loading\n"); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) return xt_register_match(&time_match); -#else - return ipt_register_match(&time_match); -#endif } static void __exit fini(void) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) xt_unregister_match(&time_match); -#else - ipt_unregister_match(&time_match); -#endif printk("ipt_time unloaded\n"); }