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

« back to all changes in this revision

Viewing changes to extensions/libipt_realm.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:
11
11
#else
12
12
#include <linux/if_ether.h>
13
13
#endif
14
 
#include <iptables.h>
 
14
#include <xtables.h>
15
15
#include <linux/netfilter_ipv4/ipt_realm.h>
16
16
 
17
 
/* Function which prints out usage message. */
18
17
static void realm_help(void)
19
18
{
20
19
        printf(
21
20
"realm match options:\n"
22
 
" --realm [!] value[/mask]\n"
 
21
"[!] --realm value[/mask]\n"
23
22
"                               Match realm\n");
24
23
}
25
24
 
149
148
        return NULL;
150
149
}
151
150
 
152
 
 
153
 
/* Function which parses command options; returns true if it
154
 
   ate an option */
155
151
static int realm_parse(int c, char **argv, int invert, unsigned int *flags,
156
152
                       const void *entry, struct xt_entry_match **match)
157
153
{
161
157
        switch (c) {
162
158
                char *end;
163
159
        case '1':
164
 
                check_inverse(argv[optind-1], &invert, &optind, 0);
 
160
                xtables_check_inverse(argv[optind-1], &invert, &optind, 0);
165
161
                end = optarg = argv[optind-1];
166
162
                realminfo->id = strtoul(optarg, &end, 0);
167
163
                if (end != optarg && (*end == '/' || *end == '\0')) {
170
166
                        else
171
167
                                realminfo->mask = 0xffffffff;
172
168
                        if (*end != '\0' || end == optarg)
173
 
                                exit_error(PARAMETER_PROBLEM,
 
169
                                xtables_error(PARAMETER_PROBLEM,
174
170
                                           "Bad realm value `%s'", optarg);
175
171
                } else {
176
172
                        id = realm_name2id(optarg);
177
173
                        if (id == -1)
178
 
                                exit_error(PARAMETER_PROBLEM,
 
174
                                xtables_error(PARAMETER_PROBLEM,
179
175
                                           "Realm `%s' not found", optarg);
180
 
                        realminfo->id = (u_int32_t)id;
 
176
                        realminfo->id = id;
181
177
                        realminfo->mask = 0xffffffff;
182
178
                }
183
179
                if (invert)
208
204
        }
209
205
}
210
206
 
211
 
/* Prints out the matchinfo. */
212
207
static void realm_print(const void *ip, const struct xt_entry_match *match,
213
208
                        int numeric)
214
209
{
221
216
        print_realm(ri->id, ri->mask, numeric);
222
217
}
223
218
 
224
 
 
225
 
/* Saves the union ipt_matchinfo in parsable form to stdout. */
226
219
static void realm_save(const void *ip, const struct xt_entry_match *match)
227
220
{
228
221
        struct ipt_realm_info *ri = (struct ipt_realm_info *) match->data;
234
227
        print_realm(ri->id, ri->mask, 0);
235
228
}
236
229
 
237
 
/* Final check; must have specified --mark. */
238
230
static void realm_check(unsigned int flags)
239
231
{
240
232
        if (!flags)
241
 
                exit_error(PARAMETER_PROBLEM,
 
233
                xtables_error(PARAMETER_PROBLEM,
242
234
                           "realm match: You must specify `--realm'");
243
235
}
244
236
 
245
237
static struct xtables_match realm_mt_reg = {
246
238
        .name           = "realm",
247
239
        .version        = XTABLES_VERSION,
248
 
        .family         = PF_INET,
 
240
        .family         = NFPROTO_IPV4,
249
241
        .size           = XT_ALIGN(sizeof(struct ipt_realm_info)),
250
242
        .userspacesize  = XT_ALIGN(sizeof(struct ipt_realm_info)),
251
243
        .help           = realm_help,
260
252
{
261
253
        xtables_register_match(&realm_mt_reg);
262
254
}
263
 
 
264