~ubuntu-branches/ubuntu/oneiric/iptables/oneiric

« back to all changes in this revision

Viewing changes to extensions/libipt_addrtype.c

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge, Lorenzo De Liso, Jamie Strandboge
  • Date: 2010-11-12 15:58:40 UTC
  • mfrom: (5.1.8 upstream) (2.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20101112155840-jm07l9o9722h0bvm
Tags: 1.4.10-1ubuntu1
[ Lorenzo De Liso ]
* Merge from debian unstable (LP: #671652), remaining changes:
  - Don't fail to run iptables-save if iptables module isn't loaded.
  - Revert changes between 1.4.1.1-3 and 1.4.1.1-4, thus bringing back
    the howtos.
  - Added linuxdoc-tools to Build-Depends
  - Modified debian/iptables{,-dev}.install to match DM syntax
    (removed debian/tmp)
  - Added -fno-strict-aliasing -Werror switches to regular_CFLAGS
    for catching errors early
  - Removed unused TC_NUM_RULES() and TC_GET_RULE()
* debian/patches/03-compilation-error.patch: updated
* debian/patches/0600-makefile_jedi_handwaving.patch: updated
* Dropped changes:
  - debian/patches/0902-docs-version-reference.diff: modifies files inside
    the debian/ directory and hence is not needed

[ Jamie Strandboge ]
* debian/patches/9000-howtos.patch:
  - combine 0102-howtos.patch and 0103-sgml_errors.patch into this patch
    and apply after the Debian patches for easier maintenance
  - add DEP-3 comments
* debian/patches/9001-build-libipq_pic.la.patch:
  - Build libipq_pic.la with -fPIC
  - add DEP-3 comments
* debian/iptables-dev.install: install lib/*.la in usr/lib
* merge debian/patches/9002-xt_recent-reap.patch:
  - support for the xt_recent filter --reap switch (refreshed and updated)
  - add DEP-3 comments
* debian/patches/9003-compilation-error.patch:
  - renamed 03-compilation-error.patch as 9003-compilation-error.patch
  - apply after Debian patches for easier maintenance
  - add DEP-3 comments
* debian/iptables.doc-base.{nat|packet-filter}: update for 2.6
* Dropped changes:
  - Replaced ipt_DSCP.h by xpt_DSCP.h in ipt_ECN.h and ipt_echn.h (applied
    upstream)
  - 9001-build-libipq_pic.a.patch (using la instead)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Shared library add-on to iptables to add addrtype matching support 
2
2
 * 
3
3
 * This program is released under the terms of GNU GPL */
4
 
 
 
4
#include <stdbool.h>
5
5
#include <stdio.h>
6
6
#include <stdlib.h>
7
7
#include <string.h>
106
106
                if (*flags&IPT_ADDRTYPE_OPT_SRCTYPE)
107
107
                        xtables_error(PARAMETER_PROBLEM,
108
108
                                   "addrtype: can't specify src-type twice");
109
 
                xtables_check_inverse(optarg, &invert, &optind, 0);
110
 
                parse_types(argv[optind-1], &info->source);
 
109
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
110
                parse_types(optarg, &info->source);
111
111
                if (invert)
112
112
                        info->invert_source = 1;
113
113
                *flags |= IPT_ADDRTYPE_OPT_SRCTYPE;
116
116
                if (*flags&IPT_ADDRTYPE_OPT_DSTTYPE)
117
117
                        xtables_error(PARAMETER_PROBLEM,
118
118
                                   "addrtype: can't specify dst-type twice");
119
 
                xtables_check_inverse(optarg, &invert, &optind, 0);
120
 
                parse_types(argv[optind-1], &info->dest);
 
119
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
120
                parse_types(optarg, &info->dest);
121
121
                if (invert)
122
122
                        info->invert_dest = 1;
123
123
                *flags |= IPT_ADDRTYPE_OPT_DSTTYPE;
141
141
                if (*flags & IPT_ADDRTYPE_OPT_SRCTYPE)
142
142
                        xtables_error(PARAMETER_PROBLEM,
143
143
                                   "addrtype: can't specify src-type twice");
144
 
                xtables_check_inverse(optarg, &invert, &optind, 0);
145
 
                parse_types(argv[optind-1], &info->source);
 
144
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
145
                parse_types(optarg, &info->source);
146
146
                if (invert)
147
147
                        info->flags |= IPT_ADDRTYPE_INVERT_SOURCE;
148
148
                *flags |= IPT_ADDRTYPE_OPT_SRCTYPE;
151
151
                if (*flags & IPT_ADDRTYPE_OPT_DSTTYPE)
152
152
                        xtables_error(PARAMETER_PROBLEM,
153
153
                                   "addrtype: can't specify dst-type twice");
154
 
                xtables_check_inverse(optarg, &invert, &optind, 0);
155
 
                parse_types(argv[optind-1], &info->dest);
 
154
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
155
                parse_types(optarg, &info->dest);
156
156
                if (invert)
157
157
                        info->flags |= IPT_ADDRTYPE_INVERT_DEST;
158
158
                *flags |= IPT_ADDRTYPE_OPT_DSTTYPE;
304
304
}
305
305
 
306
306
static const struct option addrtype_opts[] = {
307
 
        { "src-type", 1, NULL, '1' },
308
 
        { "dst-type", 1, NULL, '2' },
309
 
        { .name = NULL }
 
307
        {.name = "src-type", .has_arg = true, .val = '1'},
 
308
        {.name = "dst-type", .has_arg = true, .val = '2'},
 
309
        XT_GETOPT_TABLEEND,
310
310
};
311
311
 
312
312
static const struct option addrtype_opts_v0[] = {
313
 
        { "src-type", 1, NULL, '1' },
314
 
        { "dst-type", 1, NULL, '2' },
315
 
        { .name = NULL }
 
313
        {.name = "src-type", .has_arg = true, .val = '1'},
 
314
        {.name = "dst-type", .has_arg = true, .val = '2'},
 
315
        XT_GETOPT_TABLEEND,
316
316
};
317
317
 
318
318
static const struct option addrtype_opts_v1[] = {
319
 
        { "src-type", 1, NULL, '1' },
320
 
        { "dst-type", 1, NULL, '2' },
321
 
        { "limit-iface-in", 0, NULL, '3' },
322
 
        { "limit-iface-out", 0, NULL, '4' },
323
 
        { .name = NULL }
324
 
};
325
 
 
326
 
static struct xtables_match addrtype_mt_reg_v0 = {
327
 
        .name           = "addrtype",
328
 
        .version        = XTABLES_VERSION,
329
 
        .family         = NFPROTO_IPV4,
330
 
        .size           = XT_ALIGN(sizeof(struct ipt_addrtype_info)),
331
 
        .userspacesize  = XT_ALIGN(sizeof(struct ipt_addrtype_info)),
332
 
        .help           = addrtype_help_v0,
333
 
        .parse          = addrtype_parse_v0,
334
 
        .final_check    = addrtype_check_v0,
335
 
        .print          = addrtype_print_v0,
336
 
        .save           = addrtype_save_v0,
337
 
        .extra_opts     = addrtype_opts_v0,
338
 
};
339
 
 
340
 
static struct xtables_match addrtype_mt_reg_v1 = {
341
 
        .name           = "addrtype",
342
 
        .version        = XTABLES_VERSION,
343
 
        .family         = NFPROTO_IPV4,
344
 
        .size           = XT_ALIGN(sizeof(struct ipt_addrtype_info_v1)),
345
 
        .userspacesize  = XT_ALIGN(sizeof(struct ipt_addrtype_info_v1)),
346
 
        .help           = addrtype_help_v1,
347
 
        .parse          = addrtype_parse_v1,
348
 
        .final_check    = addrtype_check_v1,
349
 
        .print          = addrtype_print_v1,
350
 
        .save           = addrtype_save_v1,
351
 
        .extra_opts     = addrtype_opts_v1,
352
 
        .revision       = 1,
 
319
        {.name = "src-type",        .has_arg = true,  .val = '1'},
 
320
        {.name = "dst-type",        .has_arg = true,  .val = '2'},
 
321
        {.name = "limit-iface-in",  .has_arg = false, .val = '3'},
 
322
        {.name = "limit-iface-out", .has_arg = false, .val = '4'},
 
323
        XT_GETOPT_TABLEEND,
 
324
};
 
325
 
 
326
static struct xtables_match addrtype_mt_reg[] = {
 
327
        {
 
328
                .name          = "addrtype",
 
329
                .version       = XTABLES_VERSION,
 
330
                .family        = NFPROTO_IPV4,
 
331
                .size          = XT_ALIGN(sizeof(struct ipt_addrtype_info)),
 
332
                .userspacesize = XT_ALIGN(sizeof(struct ipt_addrtype_info)),
 
333
                .help          = addrtype_help_v0,
 
334
                .parse         = addrtype_parse_v0,
 
335
                .final_check   = addrtype_check_v0,
 
336
                .print         = addrtype_print_v0,
 
337
                .save          = addrtype_save_v0,
 
338
                .extra_opts    = addrtype_opts_v0,
 
339
        },
 
340
        {
 
341
                .name          = "addrtype",
 
342
                .revision      = 1,
 
343
                .version       = XTABLES_VERSION,
 
344
                .family        = NFPROTO_IPV4,
 
345
                .size          = XT_ALIGN(sizeof(struct ipt_addrtype_info_v1)),
 
346
                .userspacesize = XT_ALIGN(sizeof(struct ipt_addrtype_info_v1)),
 
347
                .help          = addrtype_help_v1,
 
348
                .parse         = addrtype_parse_v1,
 
349
                .final_check   = addrtype_check_v1,
 
350
                .print         = addrtype_print_v1,
 
351
                .save          = addrtype_save_v1,
 
352
                .extra_opts    = addrtype_opts_v1,
 
353
        },
353
354
};
354
355
 
355
356
 
356
357
void _init(void) 
357
358
{
358
 
        xtables_register_match(&addrtype_mt_reg_v0);
359
 
        xtables_register_match(&addrtype_mt_reg_v1);
 
359
        xtables_register_matches(addrtype_mt_reg, ARRAY_SIZE(addrtype_mt_reg));
360
360
}