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

« back to all changes in this revision

Viewing changes to extensions/libip6t_hl.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:
10
10
#include <stdlib.h>
11
11
#include <string.h>
12
12
#include <getopt.h>
13
 
#include <ip6tables.h>
 
13
#include <xtables.h>
14
14
 
15
 
#include <linux/netfilter_ipv6/ip6_tables.h>
16
15
#include <linux/netfilter_ipv6/ip6t_hl.h>
17
16
 
18
17
static void hl_help(void)
19
18
{
20
19
        printf(
21
20
"hl match options:\n"
22
 
"  --hl-eq [!] value    Match hop limit value\n"
 
21
"[!] --hl-eq value      Match hop limit value\n"
23
22
"  --hl-lt value        Match HL < value\n"
24
23
"  --hl-gt value        Match HL > value\n");
25
24
}
30
29
        struct ip6t_hl_info *info = (struct ip6t_hl_info *) (*match)->data;
31
30
        u_int8_t value;
32
31
 
33
 
        check_inverse(optarg, &invert, &optind, 0);
 
32
        xtables_check_inverse(optarg, &invert, &optind, 0);
34
33
        value = atoi(argv[optind-1]);
35
34
 
36
35
        if (*flags) 
37
 
                exit_error(PARAMETER_PROBLEM, 
 
36
                xtables_error(PARAMETER_PROBLEM,
38
37
                                "Can't specify HL option twice");
39
38
 
40
39
        if (!optarg)
41
 
                exit_error(PARAMETER_PROBLEM,
 
40
                xtables_error(PARAMETER_PROBLEM,
42
41
                                "hl: You must specify a value");
43
42
        switch (c) {
44
43
                case '2':
54
53
                        break;
55
54
                case '3':
56
55
                        if (invert) 
57
 
                                exit_error(PARAMETER_PROBLEM,
 
56
                                xtables_error(PARAMETER_PROBLEM,
58
57
                                                "hl: unexpected `!'");
59
58
 
60
59
                        info->mode = IP6T_HL_LT;
64
63
                        break;
65
64
                case '4':
66
65
                        if (invert)
67
 
                                exit_error(PARAMETER_PROBLEM,
 
66
                                xtables_error(PARAMETER_PROBLEM,
68
67
                                                "hl: unexpected `!'");
69
68
 
70
69
                        info->mode = IP6T_HL_GT;
82
81
static void hl_check(unsigned int flags)
83
82
{
84
83
        if (!flags) 
85
 
                exit_error(PARAMETER_PROBLEM,
 
84
                xtables_error(PARAMETER_PROBLEM,
86
85
                        "HL match: You must specify one of "
87
86
                        "`--hl-eq', `--hl-lt', `--hl-gt'");
88
87
}
104
103
 
105
104
static void hl_save(const void *ip, const struct xt_entry_match *match)
106
105
{
107
 
        static const char *op[] = {
108
 
                [IP6T_HL_EQ] = "eq",
109
 
                [IP6T_HL_NE] = "eq !",
110
 
                [IP6T_HL_LT] = "lt",
111
 
                [IP6T_HL_GT] = "gt" };
 
106
        static const char *const op[] = {
 
107
                [IP6T_HL_EQ] = "--hl-eq",
 
108
                [IP6T_HL_NE] = "! --hl-eq",
 
109
                [IP6T_HL_LT] = "--hl-lt",
 
110
                [IP6T_HL_GT] = "--hl-gt" };
112
111
 
113
112
        const struct ip6t_hl_info *info =
114
113
                (struct ip6t_hl_info *) match->data;
115
114
 
116
 
        printf("--hl-%s %u ", op[info->mode], info->hop_limit);
 
115
        printf("%s %u ", op[info->mode], info->hop_limit);
117
116
}
118
117
 
119
118
static const struct option hl_opts[] = {
127
126
static struct xtables_match hl_mt6_reg = {
128
127
        .name          = "hl",
129
128
        .version       = XTABLES_VERSION,
130
 
        .family        = PF_INET6,
 
129
        .family        = NFPROTO_IPV6,
131
130
        .size          = XT_ALIGN(sizeof(struct ip6t_hl_info)),
132
131
        .userspacesize = XT_ALIGN(sizeof(struct ip6t_hl_info)),
133
132
        .help          = hl_help,