/[packages]/cauldron/iptables/current/SOURCES/libipt_IFWLOG.c
ViewVC logotype

Contents of /cauldron/iptables/current/SOURCES/libipt_IFWLOG.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 590 - (show annotations) (download)
Sat Jan 8 13:46:14 2011 UTC (13 years, 3 months ago) by blino
File MIME type: text/plain
File size: 2684 byte(s)
imported package iptables
1 /* Shared library add-on to iptables for the TTL target
2 * This program is distributed under the terms of GNU GPL
3 * (C) 2005 by Samir Bellabes <sbellabes@mandriva.com>
4 * $Id: libipt_IFWLOG.c 475942 2009-12-10 13:55:57Z eugeni $
5 *
6 */
7 #include <stdio.h>
8 #include <string.h>
9 #include <stdlib.h>
10 #include <getopt.h>
11 #include <iptables.h>
12
13 #include <linux/netfilter_ipv4/ip_tables.h>
14 #include <linux/netfilter_ipv4/ipt_IFWLOG.h>
15
16 static void ifwlog_init(struct xt_entry_target *t)
17 {
18 }
19
20 static void ifwlog_help(void)
21 {
22 printf(
23 "IFWLOG target option\n"
24 " --log-prefix prefix Prefix log messages with this prefix\n");
25 }
26
27 static struct option ifwlog_opts[] = {
28 { .name = "log-prefix", .has_arg = 1, .flag = 0, .val = 'a' },
29 { .name = 0 }
30 };
31
32 #define IPT_IFWLOG_OPT_PREFIX 0x01
33
34 static int ifwlog_parse(int c, char **argv, int invert, unsigned int *flags,
35 const void *entry, struct xt_entry_target **target)
36 {
37 struct ipt_IFWLOG_info *info = (struct ipt_IFWLOG_info *) (*target)->data;
38
39 switch (c) {
40 case 'a':
41 if (*flags & IPT_IFWLOG_OPT_PREFIX)
42 xtables_error(PARAMETER_PROBLEM,
43 "Can't specify --log-prefix twice");
44
45 if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
46 xtables_error(PARAMETER_PROBLEM,
47 "Unexpected '!' after --log-prefix ");
48
49 if (strlen(optarg) > sizeof(info->prefix) - 1)
50 xtables_error(PARAMETER_PROBLEM,
51 "Maximum prefix length %d for --log-prefix",
52 (unsigned int)sizeof(info->prefix) - 1);
53
54 if (strlen(optarg) != strlen(strtok(optarg,"\n")))
55 xtables_error(PARAMETER_PROBLEM,
56 "New lines are not allowed in --log-prefix");
57
58 strcpy(info->prefix, optarg);
59 *flags |= IPT_IFWLOG_OPT_PREFIX;
60 break;
61 default:
62 return 0;
63 }
64
65 return 1;
66 }
67
68 static void ifwlog_save(const void *ip, const struct xt_entry_target *target)
69 {
70 const struct ipt_IFWLOG_info *info =
71 (struct ipt_IFWLOG_info *) target->data;
72
73 if (strcmp(info->prefix, "") != 0)
74 printf("--log-prefix \"%s\"", info->prefix);
75 }
76
77 static void ifwlog_print(const void *ip, const struct xt_entry_target *target,
78 int numeric)
79 {
80 const struct ipt_IFWLOG_info *info =
81 (struct ipt_IFWLOG_info *) target->data;
82
83 printf("IFWLOG ");
84 if (strcmp(info->prefix, "") !=0)
85 printf("prefix '%s' ", info->prefix);
86
87 }
88
89 static struct xtables_target IFWLOG_tg_reg = {
90 .name = "IFWLOG",
91 .version = XTABLES_VERSION,
92 .size = XT_ALIGN(sizeof(struct ipt_IFWLOG_info)),
93 .userspacesize = XT_ALIGN(sizeof(struct ipt_IFWLOG_info)),
94 .help = &ifwlog_help,
95 .init = &ifwlog_init,
96 .parse = &ifwlog_parse,
97 .print = &ifwlog_print,
98 .save = &ifwlog_save,
99 .extra_opts = ifwlog_opts,
100 };
101
102 void _init(void)
103 {
104 xtables_register_target(&IFWLOG_tg_reg);
105 }

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.30