static struct option base_opts[] = {
{ .name = "match", .has_arg = 1, .val = 'm' },
{ .name = "jump", .has_arg = 1, .val = 'j' },
- { .name = "append", .has_arg = 1, .val = 'A' },
{ NULL }
};
static void
ip4prefix2mask(int prefix, struct in_addr *mask)
{
- mask->s_addr = htonl(~((1 << (32 - prefix)) - 1));
+ if (prefix > 0)
+ mask->s_addr = htonl(~((1 << (32 - prefix)) - 1));
+ else
+ mask->s_addr = 0;
}
#ifndef DISABLE_IPV6
void
fw3_ipt_rule_mac(struct fw3_ipt_rule *r, struct fw3_mac *mac)
{
+ char buf[sizeof("ff:ff:ff:ff:ff:ff\0")];
+
if (!mac)
return;
+ sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
+ mac->mac[0], mac->mac[1], mac->mac[2],
+ mac->mac[3], mac->mac[4], mac->mac[5]);
+
fw3_ipt_rule_addarg(r, false, "-m", "mac");
- fw3_ipt_rule_addarg(r, mac->invert, "--mac-source", ether_ntoa(&mac->mac));
+ fw3_ipt_rule_addarg(r, mac->invert, "--mac-source", buf);
}
void
optind = 0;
opterr = 0;
- while ((optc = getopt_long(r->argc, r->argv, "m:j:", g->opts, NULL)) != -1)
+ while ((optc = getopt_long(r->argc, r->argv, "-:m:j:", g->opts,
+ NULL)) != -1)
{
switch (optc)
{
case 1:
if ((optarg[0] == '!') && (optarg[1] == '\0'))
{
+ optarg[0] = '\0';
inv = true;
continue;
}