20
21
static const struct option connlimit_opts[] = {
21
{"connlimit-above", 1, NULL, 'A'},
22
{"connlimit-mask", 1, NULL, 'M'},
22
{.name = "connlimit-above", .has_arg = true, .val = 'A'},
23
{.name = "connlimit-mask", .has_arg = true, .val = 'M'},
26
27
static void connlimit_init(struct xt_entry_match *match)
65
66
xtables_error(PARAMETER_PROBLEM,
66
67
"--connlimit-above may be given only once");
68
xtables_check_inverse(optarg, &invert, &optind, 0);
69
info->limit = strtoul(argv[optind-1], NULL, 0);
69
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
70
info->limit = strtoul(optarg, NULL, 0);
70
71
info->inverse = invert;
75
76
"--connlimit-mask may be given only once");
78
i = strtoul(argv[optind-1], &err, 0);
79
i = strtoul(optarg, &err, 0);
79
80
if (family == NFPROTO_IPV6) {
80
81
if (i > 128 || *err != '\0')
81
82
xtables_error(PARAMETER_PROBLEM,
179
180
count_bits6(info->v6_mask));
182
static struct xtables_match connlimit_match = {
184
.family = NFPROTO_IPV4,
185
.version = XTABLES_VERSION,
186
.size = XT_ALIGN(sizeof(struct xt_connlimit_info)),
187
.userspacesize = offsetof(struct xt_connlimit_info, data),
188
.help = connlimit_help,
189
.init = connlimit_init,
190
.parse = connlimit_parse4,
191
.final_check = connlimit_check,
192
.print = connlimit_print4,
193
.save = connlimit_save4,
194
.extra_opts = connlimit_opts,
197
static struct xtables_match connlimit_match6 = {
199
.family = NFPROTO_IPV6,
200
.version = XTABLES_VERSION,
201
.size = XT_ALIGN(sizeof(struct xt_connlimit_info)),
202
.userspacesize = offsetof(struct xt_connlimit_info, data),
203
.help = connlimit_help,
204
.init = connlimit_init,
205
.parse = connlimit_parse6,
206
.final_check = connlimit_check,
207
.print = connlimit_print6,
208
.save = connlimit_save6,
209
.extra_opts = connlimit_opts,
183
static struct xtables_match connlimit_mt_reg[] = {
186
.family = NFPROTO_IPV4,
187
.version = XTABLES_VERSION,
188
.size = XT_ALIGN(sizeof(struct xt_connlimit_info)),
189
.userspacesize = offsetof(struct xt_connlimit_info, data),
190
.help = connlimit_help,
191
.init = connlimit_init,
192
.parse = connlimit_parse4,
193
.final_check = connlimit_check,
194
.print = connlimit_print4,
195
.save = connlimit_save4,
196
.extra_opts = connlimit_opts,
200
.family = NFPROTO_IPV6,
201
.version = XTABLES_VERSION,
202
.size = XT_ALIGN(sizeof(struct xt_connlimit_info)),
203
.userspacesize = offsetof(struct xt_connlimit_info, data),
204
.help = connlimit_help,
205
.init = connlimit_init,
206
.parse = connlimit_parse6,
207
.final_check = connlimit_check,
208
.print = connlimit_print6,
209
.save = connlimit_save6,
210
.extra_opts = connlimit_opts,
214
xtables_register_match(&connlimit_match);
215
xtables_register_match(&connlimit_match6);
216
xtables_register_matches(connlimit_mt_reg, ARRAY_SIZE(connlimit_mt_reg));