{ NULL, 0 } /* terminator */
};
-/* index of 'lookup ... ' keys in the kernel */
+/*
+ * The 'lookup' instruction accepts one of the following arguments.
+ * -1 is a terminator for the list.
+ * Arguments are passed as v[1] in O_DST_LOOKUP options.
+ */
static int lookup_key[] = {
TOK_DSTIP, TOK_SRCIP, TOK_DSTPORT, TOK_SRCPORT,
- TOK_UID, TOK_GID, TOK_JAIL,
- TOK_PROTO, TOK_MACTYPE, 0, };
+ TOK_UID, TOK_JAIL, -1 };
static struct _s_x rule_options[] = {
{ "tagged", TOK_TAGGED },
if (s < 0)
err(EX_UNAVAILABLE, "socket");
- if (optname == IP_FW_GET || optname == IP_FW_DYN_GET ||
- optname == IP_DUMMYNET_GET ||
+ if (optname == IP_FW_GET || optname == IP_DUMMYNET_GET ||
+ optname == IP_FW_DYN_GET ||
optname == IP_FW_ADD || optname == IP_FW_TABLE_LIST ||
optname == IP_FW_TABLE_GETSIZE ||
optname == IP_FW_NAT_GET_CONFIG ||
if (d < sizeof(lookup_key)/sizeof(lookup_key[0]))
arg = match_value(rule_options, lookup_key[d]);
- printf("%s lookup %s %d,%d", cmd->o.len & F_NOT ? " not": "",
- arg, cmd->o.arg1, a[0]);
+ printf("%s lookup %s %d", cmd->o.len & F_NOT ? " not": "",
+ arg, cmd->o.arg1);
return;
}
printf("%s%s ", cmd->o.len & F_NOT ? " not": "", s);
* the routing code seems to use it too.
*/
p->sa.sin_family = AF_INET;
- //p->sa.sin_len = sizeof(struct sockaddr_in);
+ p->sa.sin_len = sizeof(struct sockaddr_in);
p->sa.sin_port = 0;
/*
* locate the address-port separator (':' or ',')
int j;
if (ac < 2)
- errx(EX_USAGE, "format: lookup argument tablenum[,arg]");
+ errx(EX_USAGE, "format: lookup argument tablenum");
cmd->opcode = O_IP_DST_LOOKUP;
cmd->len |= F_INSN_SIZE(ipfw_insn) + 2;
i = match_token(rule_options, *av);
- for (j = 0; lookup_key[j] ; j++) {
+ for (j = 0; lookup_key[j] >= 0 ; j++) {
if (i == lookup_key[j])
break;
}
- if (lookup_key[j] == 0)
+ if (lookup_key[j] <= 0)
errx(EX_USAGE, "format: cannot lookup on %s", *av);
c->d[1] = j; // i converted to option
ac--; av++;
- p = strchr(*av, ',');
- if (p) {
- *p++ = '\0';
- c->d[0] = strtoul(p, NULL, 0);
- } else {
- c->d[0] = ~0;
- }
- cmd->arg1 = strtoul(*av, NULL, 0);
+ cmd->arg1 = strtoul(*av, &p, 0);
+ if (p && *p)
+ errx(EX_USAGE, "format: lookup argument tablenum");
ac--; av++;
}
break;