diff -urNp iptables-1.3.3/extensions/.IFWLOG-test iptables-1.3.3.IFWLOG/extensions/.IFWLOG-test --- iptables-1.3.3/extensions/.IFWLOG-test 1970-01-01 01:00:00.000000000 +0100 +++ iptables-1.3.3.IFWLOG/extensions/.IFWLOG-test 2005-08-03 02:29:18.000000000 +0200 @@ -0,0 +1,2 @@ +#! /bin/sh +[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_IFWLOG.h ] && echo IFWLOG diff -urNp iptables-1.3.3/extensions/libipt_IFWLOG.c iptables-1.3.3.IFWLOG/extensions/libipt_IFWLOG.c --- iptables-1.3.3/extensions/libipt_IFWLOG.c 1970-01-01 01:00:00.000000000 +0100 +++ iptables-1.3.3.IFWLOG/extensions/libipt_IFWLOG.c 2005-08-03 08:21:57.000000000 +0200 @@ -0,0 +1,113 @@ +/* Shared library add-on to iptables for the TTL target + * This program is distributed under the terms of GNU GPL + * (C) 2005 by Samir Bellabes <sbellabes@mandriva.com> + * + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <getopt.h> +#include <iptables.h> + +#include <linux/netfilter_ipv4/ip_tables.h> +#include <linux/netfilter_ipv4/ipt_IFWLOG.h> + +static void init(struct ipt_entry_target *t, unsigned int *nfcache) +{ +} + +static void help(void) +{ + printf( +"IFWLOG target v%s option\n" +" --log-prefix prefix Prefix log messages with this prefix\n", +IPTABLES_VERSION); +} + +static struct option opts[] = { + { .name = "log-prefix", .has_arg = 1, .flag = 0, .val = 'a' }, + { .name = 0 } +}; + +#define IPT_IFWLOG_OPT_PREFIX 0x01 + +static int parse(int c, char **argv, int invert, unsigned int *flags, + const struct ipt_entry *entry, + struct ipt_entry_target **target) +{ + struct ipt_IFWLOG_info *info = (struct ipt_IFWLOG_info *) (*target)->data; + + switch (c) { + case 'a': + if (*flags & IPT_IFWLOG_OPT_PREFIX) + exit_error(PARAMETER_PROBLEM, + "Can't specify --log-prefix twice"); + + if (check_inverse(optarg, &invert, NULL, 0)) + exit_error(PARAMETER_PROBLEM, + "Unexpected '!' after --log-prefix "); + + if (strlen(optarg) > sizeof(info->prefix) - 1) + exit_error(PARAMETER_PROBLEM, + "Maximum prefix length %d for --log-prefix", + (unsigned int)sizeof(info->prefix) - 1); + + if (strlen(optarg) != strlen(strtok(optarg,"\n"))) + exit_error(PARAMETER_PROBLEM, + "New lines are not allowed in --log-prefix"); + + strcpy(info->prefix, optarg); + *flags |= IPT_IFWLOG_OPT_PREFIX; + break; + default: + return 0; + } + + return 1; +} + +static void final_check(unsigned int flags) +{ +} + +static void save(const struct ipt_ip *ip, + const struct ipt_entry_target *target) +{ + const struct ipt_IFWLOG_info *info = + (struct ipt_IFWLOG_info *) target->data; + + if (strcmp(info->prefix, "") != 0) + printf("--log-prefix \"%s\"", info->prefix); +} + +static void print(const struct ipt_ip *ip, + const struct ipt_entry_target *target, int numeric) +{ + const struct ipt_IFWLOG_info *info = + (struct ipt_IFWLOG_info *) target->data; + + printf("IFWLOG "); + if (strcmp(info->prefix, "") !=0) + printf("prefix '%s' ", info->prefix); + +} + +static struct iptables_target IFWLOG = { + .next = NULL, + .name = "IFWLOG", + .version = IPTABLES_VERSION, + .size = IPT_ALIGN(sizeof(struct ipt_IFWLOG_info)), + .userspacesize = IPT_ALIGN(sizeof(struct ipt_IFWLOG_info)), + .help = &help, + .init = &init, + .parse = &parse, + .final_check = &final_check, + .print = &print, + .save = &save, + .extra_opts = opts +}; + +void _init(void) +{ + register_target(&IFWLOG); +}