Beispiel #1
0
static void time_save(const void *ip, const struct xt_entry_match *match)
{
	const struct xt_time_info *info = (const void *)match->data;
	unsigned int h, m, s;

	if (info->daytime_start != XT_TIME_MIN_DAYTIME ||
	    info->daytime_stop != XT_TIME_MAX_DAYTIME) {
		divide_time(info->daytime_start, &h, &m, &s);
		printf(" --timestart %02u:%02u:%02u", h, m, s);
		divide_time(info->daytime_stop, &h, &m, &s);
		printf(" --timestop %02u:%02u:%02u", h, m, s);
	}
	if (info->monthdays_match != XT_TIME_ALL_MONTHDAYS) {
		printf(" --monthdays");
		time_print_monthdays(info->monthdays_match, false);
	}
	if (info->weekdays_match != XT_TIME_ALL_WEEKDAYS) {
		printf(" --weekdays");
		time_print_weekdays(info->weekdays_match);
	}
	time_print_date(info->date_start, "--datestart");
	time_print_date(info->date_stop, "--datestop");
	if (info->flags & XT_TIME_LOCAL_TZ)
		printf(" --kerneltz");
	if (info->flags & XT_TIME_CONTIGUOUS)
		printf(" --contiguous");
}
/* Saves the data in parsable form to stdout. */
static void
save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
{
	struct ipt_time_info *time = ((struct ipt_time_info *)match->data);
	int hour_start, hour_stop, minute_start, minute_stop;

	divide_time(time->time_start, &hour_start, &minute_start);
	divide_time(time->time_stop, &hour_stop, &minute_stop);
	if (time->time_start != 0)
		printf("--timestart %.2d:%.2d ",
		        hour_start, minute_start);
	
	if (time->time_stop != 1439) /* 23*60+59 = 1439 */
		printf("--timestop %.2d:%.2d ",
		        hour_stop, minute_stop);
	
	if (time->days_match != 127)
	{
		printf("--days ");
		print_days(time->days_match);
		printf(" ");
	}
	print_date(time->date_start, "--datestart");
	print_date(time->date_stop, "--datestop");
}
/* Prints out the matchinfo. */
static void
print(const struct ipt_ip *ip,
      const struct ipt_entry_match *match,
      int numeric)
{
	struct ipt_time_info *time = ((struct ipt_time_info *)match->data);
	int hour_start, hour_stop, minute_start, minute_stop;

	divide_time(time->time_start, &hour_start, &minute_start);
	divide_time(time->time_stop, &hour_stop, &minute_stop);
	printf("TIME ");
	if (time->time_start != 0)
		printf("from %d:%d ", hour_start, minute_start);
	if (time->time_stop != 1439) /* 23*60+59 = 1439 */
		printf("to %d:%d ", hour_stop, minute_stop);
	printf("on ");
	if (time->days_match == 127)
		printf("all days ");
	else
		print_days(time->days_match);
	if (time->date_start != 0)
	{
		printf("starting from ");
		print_date(time->date_start, NULL);
	}
	if (time->date_stop != LONG_MAX)
	{
		printf("until date ");
		print_date(time->date_stop, NULL);
	}
}
static void time_print(const void *ip, const struct xt_entry_match *match,
                       int numeric)
{
	const struct xt_time_info *info = (const void *)match->data;
	unsigned int h, m, s;

	printf("TIME ");

	if (info->daytime_start != XT_TIME_MIN_DAYTIME ||
	    info->daytime_stop != XT_TIME_MAX_DAYTIME) {
		divide_time(info->daytime_start, &h, &m, &s);
		printf("from %02u:%02u:%02u ", h, m, s);
		divide_time(info->daytime_stop, &h, &m, &s);
		printf("to %02u:%02u:%02u ", h, m, s);
	}
	if (info->weekdays_match != XT_TIME_ALL_WEEKDAYS) {
		printf("on ");
		time_print_weekdays(info->weekdays_match);
	}
	if (info->monthdays_match != XT_TIME_ALL_MONTHDAYS) {
		printf("on ");
		time_print_monthdays(info->monthdays_match, true);
	}
	if (info->date_start != 0) {
		printf("starting from ");
		time_print_date(info->date_start, NULL);
	}
	if (info->date_stop != INT_MAX) {
		printf("until date ");
		time_print_date(info->date_stop, NULL);
	}
	if (!(info->flags & XT_TIME_LOCAL_TZ))
		printf("UTC ");
}
/* Saves the data in parsable form to stdout. */
static void
save(const struct ipt_ip *ip, const struct ebt_entry_match *match)
{
	struct ebt_time_info *time = ((struct ebt_time_info *)match->data);
	int hour_start, hour_stop, minute_start, minute_stop;

	divide_time(time->time_start, &hour_start, &minute_start);
	divide_time(time->time_stop, &hour_stop, &minute_stop);
	printf(" --timestart %.2d:%.2d --timestop %.2d:%.2d --days ",
	       hour_start, minute_start,
	       hour_stop, minute_stop);
	print_days(time->days_match);
	printf(" ");
}
/* Prints out the matchinfo. */
static void
print(const struct ebt_u_entry *entry,
      const struct ebt_entry_match *match)
{
	struct ebt_time_info *time = ((struct ebt_time_info *)match->data);
	int hour_start, hour_stop, minute_start, minute_stop;

	divide_time(time->time_start, &hour_start, &minute_start);
	divide_time(time->time_stop, &hour_stop, &minute_stop);
	printf(" TIME from %d:%d to %d:%d on ",
	       hour_start, minute_start,
	       hour_stop, minute_stop);
	print_days(time->days_match);
	printf(" ");
}