All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch for ipt_time (to enable start > stop / crossing midnight)
@ 2006-01-04 14:27 Heiko Schlittermann
  2006-01-04 15:47 ` Krzysztof Oledzki
  0 siblings, 1 reply; 8+ messages in thread
From: Heiko Schlittermann @ 2006-01-04 14:27 UTC (permalink / raw)
  To: netfilter-devel


[-- Attachment #1.1: Type: text/plain, Size: 1135 bytes --]

Hello,

orginally sent to Fabrice but resending it here.  (Fabrice doesn't seem to
have time...., so I just subscribed here.)


(Beside: I was wondering, why ipt_time is not part of the official
2.6. kernel -- did I miss something?)


So I applied the `time' patch from current patch-o-matic (20060101).


But with a rule like:

    iptables -A INPUT -m time --timestart 21:00 --timestop 15:00 -j ...
    (wrapping 'round midnight).

I missed my target :)


To enable times crossing midnight I hacked a bit in ipt_time.c. My diff
is appended (against the patch-o-matic 20060101)..

It would be nice if you could

    1) check it
    2) integrate it into the official patch-o-matic (and kernel tree?)

Thank you ...

    Best regards from Dresden
    Viele Grüße aus Dresden
    Heiko Schlittermann
-- 
 SCHLITTERMANN.de ---------------------------- internet & unix support -
 Heiko Schlittermann HS12-RIPE -----------------------------------------
 gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
 gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2  7E92 EE4E AC98 48D0 359B -

[-- Attachment #1.2: ipt_time.c.diff --]
[-- Type: text/plain, Size: 1067 bytes --]

--- ipt_time.c.orig	2005-11-03 19:20:25.000000000 +0100
+++ ipt_time.c	2006-01-03 10:14:35.000000000 +0100
@@ -11,6 +11,7 @@
   2001-30-11 Fabrice : added the possibility to use the match in FORWARD/OUTPUT with a little hack,
      added Nguyen Dang Phuoc Dong <dongnd@tlnet.com.vn> patch to support timezones.
   2004-05-02 Fabrice : added support for date matching, from an idea of Fabien COELHO.
+  2006-01-03 Heiko Schlittermann <hs@schlittermann.de> : added support for timestart > timestop
 */
 
 #include <linux/module.h>
@@ -72,11 +73,14 @@
 
 	/* ... check the time now */
 	packet_time = (currenttime.tm_hour * 60) + currenttime.tm_min;
-	if ((packet_time < info->time_start) || (packet_time > info->time_stop))
-		return 0;
 
-	/* here we match ! */
-	return 1;
+	/* .hs now start > stop is possible */
+
+	if (info->time_start > info->time_stop)
+		return (packet_time >= info->time_start) || (packet_time < info->time_stop);
+
+	return (packet_time >= info->time_start) && (packet_time < info->time_stop);
+
 }
 
 static int

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-01-05  9:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-04 14:27 Patch for ipt_time (to enable start > stop / crossing midnight) Heiko Schlittermann
2006-01-04 15:47 ` Krzysztof Oledzki
2006-01-04 16:36   ` Brad Fisher
2006-01-04 17:09     ` Krzysztof Oledzki
2006-01-04 17:18       ` Brad Fisher
2006-01-04 16:44   ` Heiko Schlittermann
2006-01-04 16:58     ` Krzysztof Oledzki
2006-01-05  9:41       ` Heiko Schlittermann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.