~ubuntu-branches/ubuntu/precise/iptables/precise-updates

« back to all changes in this revision

Viewing changes to extensions/libxt_pkttype.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-07-14 15:59:54 UTC
  • mfrom: (5.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090714155954-9039kro8cnh6lb1q
Tags: 1.4.4-1ubuntu1
* Merge from debian unstable, remaining changes: LP: #399211
  - 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.
  - 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:
46
46
        unsigned int    i;
47
47
        
48
48
        printf("Valid packet types:\n");
49
 
        for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++)
50
 
        {
 
49
        for (i = 0; i < ARRAY_SIZE(supported_types); ++i)
51
50
                if(supported_types[i].printhelp == 1)
52
51
                        printf("\t%-14s\t\t%s\n", supported_types[i].name, supported_types[i].help);
53
 
        }
54
52
        printf("\n");
55
53
}
56
54
 
71
69
{
72
70
        unsigned int    i;
73
71
        
74
 
        for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++)
75
 
        {
 
72
        for (i = 0; i < ARRAY_SIZE(supported_types); ++i)
76
73
                if(strcasecmp(pkttype, supported_types[i].name)==0)
77
74
                {
78
75
                        info->pkttype=supported_types[i].pkttype;
79
76
                        return;
80
77
                }
81
 
        }
82
78
        
83
79
        xtables_error(PARAMETER_PROBLEM, "Bad packet type '%s'", pkttype);
84
80
}
111
107
                xtables_error(PARAMETER_PROBLEM, "You must specify \"--pkt-type\"");
112
108
}
113
109
 
114
 
static void print_pkttype(struct xt_pkttype_info *info)
 
110
static void print_pkttype(const struct xt_pkttype_info *info)
115
111
{
116
112
        unsigned int    i;
117
113
        
118
 
        for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++)
119
 
        {
 
114
        for (i = 0; i < ARRAY_SIZE(supported_types); ++i)
120
115
                if(supported_types[i].pkttype==info->pkttype)
121
116
                {
122
117
                        printf("%s ", supported_types[i].name);
123
118
                        return;
124
119
                }
125
 
        }
126
120
 
127
121
        printf("%d ", info->pkttype);   /* in case we didn't find an entry in named-packtes */
128
122
}
130
124
static void pkttype_print(const void *ip, const struct xt_entry_match *match,
131
125
                          int numeric)
132
126
{
133
 
        struct xt_pkttype_info *info = (struct xt_pkttype_info *)match->data;
 
127
        const struct xt_pkttype_info *info = (const void *)match->data;
134
128
        
135
129
        printf("PKTTYPE %s= ", info->invert?"!":"");
136
130
        print_pkttype(info);
138
132
 
139
133
static void pkttype_save(const void *ip, const struct xt_entry_match *match)
140
134
{
141
 
        struct xt_pkttype_info *info = (struct xt_pkttype_info *)match->data;
 
135
        const struct xt_pkttype_info *info = (const void *)match->data;
142
136
        
143
137
        printf("%s--pkt-type ", info->invert ? "! " : "");
144
138
        print_pkttype(info);
145
139
}
146
140
 
147
141
static struct xtables_match pkttype_match = {
148
 
        .family         = AF_UNSPEC,
 
142
        .family         = NFPROTO_UNSPEC,
149
143
        .name           = "pkttype",
150
144
        .version        = XTABLES_VERSION,
151
145
        .size           = XT_ALIGN(sizeof(struct xt_pkttype_info)),