~ubuntu-branches/ubuntu/quantal/iptables/quantal-proposed

« back to all changes in this revision

Viewing changes to extensions/libipt_set.c

  • Committer: Bazaar Package Importer
  • Author(s): Nicolas Valcárcel Scerpella
  • Date: 2009-05-06 16:35:21 UTC
  • mfrom: (5.1.6 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20090506163521-2hbruo0m33h04wxf
Tags: 1.4.3.2-2ubuntu1
* Merge from debian unstable (LP: #372920), remaining changes:
  - Don't fail to run iptables-save if iptables module isn't loaded.
  - debian/patches/0901-build-libipq_pic.a.patch - Build libipq_pic.a with
    -fPIC. Upstream changed build system and patch modified accordingly.
  - Revert changes between 1.4.1.1-3 and 1.4.1.1-4, thus bringing back
    the howtos.
* Droped unexistent patches from debian/patches/series
* Droped 0903-autoload-module-in-iptables-save.diff, fixed upstream
* Added linuxdoc-tools to Build-Depends
* Modified debian/iptables{,-dev}.install to match DM syntax 
  (removed debian/tmp)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <ctype.h>
18
18
#include <errno.h>
19
19
 
20
 
#include <iptables.h>
 
20
#include <xtables.h>
21
21
#include <linux/netfilter_ipv4/ipt_set.h>
22
22
#include "libipt_set.h"
23
23
 
24
 
/* Function which prints out usage message. */
25
24
static void set_help(void)
26
25
{
27
26
        printf("set match options:\n"
36
35
        { }
37
36
};
38
37
 
39
 
/* Initialize the match. */
40
38
static void set_init(struct xt_entry_match *match)
41
39
{
42
40
        struct ipt_set_info_match *info = 
47
45
 
48
46
}
49
47
 
50
 
/* Function which parses command options; returns true if it ate an option */
51
48
static int set_parse(int c, char **argv, int invert, unsigned int *flags,
52
49
                     const void *entry, struct xt_entry_match **match)
53
50
{
58
55
        switch (c) {
59
56
        case '1':               /* --set <set> <flag>[,<flag> */
60
57
                if (info->flags[0])
61
 
                        exit_error(PARAMETER_PROBLEM,
 
58
                        xtables_error(PARAMETER_PROBLEM,
62
59
                                   "--set can be specified only once");
63
60
 
64
 
                check_inverse(optarg, &invert, &optind, 0);
 
61
                xtables_check_inverse(optarg, &invert, &optind, 0);
65
62
                if (invert)
66
63
                        info->flags[0] |= IPSET_MATCH_INV;
67
64
 
68
65
                if (!argv[optind]
69
66
                    || argv[optind][0] == '-'
70
67
                    || argv[optind][0] == '!')
71
 
                        exit_error(PARAMETER_PROBLEM,
 
68
                        xtables_error(PARAMETER_PROBLEM,
72
69
                                   "--set requires two args.");
73
70
 
74
71
                if (strlen(argv[optind-1]) > IP_SET_MAXNAMELEN - 1)
75
 
                        exit_error(PARAMETER_PROBLEM,
 
72
                        xtables_error(PARAMETER_PROBLEM,
76
73
                                   "setname `%s' too long, max %d characters.",
77
74
                                   argv[optind-1], IP_SET_MAXNAMELEN - 1);
78
75
 
91
88
        return 1;
92
89
}
93
90
 
94
 
/* Final check; must have specified --set. */
95
91
static void set_check(unsigned int flags)
96
92
{
97
93
        if (!flags)
98
 
                exit_error(PARAMETER_PROBLEM,
 
94
                xtables_error(PARAMETER_PROBLEM,
99
95
                           "You must specify `--set' with proper arguments");
100
96
        DEBUGP("final check OK\n");
101
97
}
131
127
        print_match("set", &info->match_set);
132
128
}
133
129
 
134
 
/* Saves the matchinfo in parsable form to stdout. */
135
130
static void set_save(const void *ip, const struct xt_entry_match *match)
136
131
{
137
132
        struct ipt_set_info_match *info = 
143
138
static struct xtables_match set_mt_reg = {
144
139
        .name           = "set",
145
140
        .version        = XTABLES_VERSION,
146
 
        .family         = PF_INET,
 
141
        .family         = NFPROTO_IPV4,
147
142
        .size           = XT_ALIGN(sizeof(struct ipt_set_info_match)),
148
143
        .userspacesize  = XT_ALIGN(sizeof(struct ipt_set_info_match)),
149
144
        .help           = set_help,