13 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/netfilter/x_tables.h>
31 static const u_int16_t days_since_year[] = {
32 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
35 static const u_int16_t days_since_leapyear[] = {
36 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335,
47 static const u_int16_t days_since_epoch[] = {
49 25202, 24837, 24472, 24106, 23741, 23376, 23011, 22645, 22280, 21915,
51 21550, 21184, 20819, 20454, 20089, 19723, 19358, 18993, 18628, 18262,
53 17897, 17532, 17167, 16801, 16436, 16071, 15706, 15340, 14975, 14610,
55 14245, 13879, 13514, 13149, 12784, 12418, 12053, 11688, 11323, 10957,
57 10592, 10227, 9862, 9496, 9131, 8766, 8401, 8035, 7670, 7305,
59 6940, 6574, 6209, 5844, 5479, 5113, 4748, 4383, 4018, 3652,
61 3287, 2922, 2557, 2191, 1826, 1461, 1096, 730, 365, 0,
64 static inline bool is_leap(
unsigned int y)
66 return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
96 r->
dse = time / 86400;
117 for (i = 0, year =
DSE_FIRST; days_since_epoch[
i] >
w;
121 w -= days_since_epoch[
i];
141 i > 0 && days_since_leapyear[
i] >
w; --
i)
143 r->
monthday = w - days_since_leapyear[
i] + 1;
146 i > 0 && days_since_year[
i] >
w; --
i)
148 r->
monthday = w - days_since_year[
i] + 1;
158 unsigned int packet_time;
159 struct xtm current_time;
172 __net_timestamp((
struct sk_buff *)skb);
174 stamp = ktime_to_ns(skb->
tstamp);
179 stamp -= 60 *
sys_tz.tz_minuteswest;
193 packet_time = localtime_1(¤t_time, stamp);
196 if (packet_time < info->daytime_start ||
200 if (packet_time < info->daytime_start &&
213 packet_time <= info->daytime_stop)
217 localtime_2(¤t_time, stamp);
224 localtime_3(¤t_time, stamp);
238 pr_info(
"invalid argument - start or "
239 "stop time greater than 23:59:59\n");
259 .checkentry = time_mt_check,
264 static int __init time_mt_init(
void)
266 int minutes =
sys_tz.tz_minuteswest;
270 ": kernel timezone is +%02d%02d\n",
271 -minutes / 60, -minutes % 60);
274 ": kernel timezone is -%02d%02d\n",
275 minutes / 60, minutes % 60);
280 static void __exit time_mt_exit(
void)