Changeset View
Changeset View
Standalone View
Standalone View
sbin/ipfw/ipfw2.c
Context not available. | |||||
*/ | */ | ||||
static int lookup_key[] = { | static int lookup_key[] = { | ||||
TOK_DSTIP, TOK_SRCIP, TOK_DSTPORT, TOK_SRCPORT, | TOK_DSTIP, TOK_SRCIP, TOK_DSTPORT, TOK_SRCPORT, | ||||
TOK_UID, TOK_JAIL, TOK_DSCP, -1 }; | TOK_UID, TOK_JAIL, TOK_DSCP, TOK_DSTMAC, TOK_SRCMAC, -1 }; | ||||
static struct _s_x rule_options[] = { | static struct _s_x rule_options[] = { | ||||
{ "tagged", TOK_TAGGED }, | { "tagged", TOK_TAGGED }, | ||||
Context not available. | |||||
{ "src-ip", TOK_SRCIP }, | { "src-ip", TOK_SRCIP }, | ||||
{ "dst-port", TOK_DSTPORT }, | { "dst-port", TOK_DSTPORT }, | ||||
{ "src-port", TOK_SRCPORT }, | { "src-port", TOK_SRCPORT }, | ||||
{ "dst-mac", TOK_DSTMAC }, | |||||
{ "src-mac", TOK_SRCMAC }, | |||||
{ "proto", TOK_PROTO }, | { "proto", TOK_PROTO }, | ||||
{ "MAC", TOK_MAC }, | { "MAC", TOK_MAC }, | ||||
{ "mac", TOK_MAC }, | { "mac", TOK_MAC }, | ||||
Context not available. | |||||
{ "dst-ip6", TOK_DSTIP6}, | { "dst-ip6", TOK_DSTIP6}, | ||||
{ "src-ipv6", TOK_SRCIP6}, | { "src-ipv6", TOK_SRCIP6}, | ||||
{ "src-ip6", TOK_SRCIP6}, | { "src-ip6", TOK_SRCIP6}, | ||||
{ "dst-mac", TOK_DSTMAC}, | |||||
{ "src-mac", TOK_SRCMAC}, | |||||
{ "lookup", TOK_LOOKUP}, | { "lookup", TOK_LOOKUP}, | ||||
{ "flow", TOK_FLOW}, | { "flow", TOK_FLOW}, | ||||
{ "defer-action", TOK_SKIPACTION }, | { "defer-action", TOK_SKIPACTION }, | ||||
Context not available. | |||||
format_mac(bp, mac->addr + 6, mac->mask + 6); | format_mac(bp, mac->addr + 6, mac->mask + 6); | ||||
} | } | ||||
static void | |||||
print_mac_lookup(struct buf_pr *bp, const struct format_opts *fo, | |||||
const ipfw_insn *cmd) | |||||
{ | |||||
uint32_t len = F_LEN(cmd); | |||||
char *t; | |||||
bprintf(bp, " "); | |||||
t = table_search_ctlv(fo->tstate, cmd->arg1); | |||||
bprintf(bp, "table(%s", t); | |||||
if (len == F_INSN_SIZE(ipfw_insn_u32)) | |||||
bprintf(bp, ",%u", ((const ipfw_insn_u32 *)cmd)->d[0]); | |||||
bprintf(bp, ")"); | |||||
} | |||||
static void | static void | ||||
fill_icmptypes(ipfw_insn_u32 *cmd, char *av) | fill_icmptypes(ipfw_insn_u32 *cmd, char *av) | ||||
{ | { | ||||
Context not available. | |||||
bprintf(bp, " dst-ip6"); | bprintf(bp, " dst-ip6"); | ||||
print_ip6(bp, insntod(cmd, ip6)); | print_ip6(bp, insntod(cmd, ip6)); | ||||
break; | break; | ||||
case O_MAC_SRC_LOOKUP: | |||||
bprintf(bp, " src-mac"); | |||||
print_mac_lookup(bp, fo, cmd); | |||||
break; | |||||
case O_MAC_DST_LOOKUP: | |||||
bprintf(bp, " dst-mac"); | |||||
print_mac_lookup(bp, fo, cmd); | |||||
break; | |||||
case O_FLOW6ID: | case O_FLOW6ID: | ||||
print_flow6id(bp, insntod(cmd, u32)); | print_flow6id(bp, insntod(cmd, u32)); | ||||
break; | break; | ||||
Context not available. | |||||
return cmd; | return cmd; | ||||
} | } | ||||
static ipfw_insn * | |||||
add_srcmac(ipfw_insn *cmd, char *av, struct tidx *tstate) | |||||
{ | |||||
if (strncmp(av, "table(", 6) == 0) | |||||
fill_table(cmd, av, O_MAC_SRC_LOOKUP, tstate); | |||||
else | |||||
errx(EX_DATAERR, "only mac table lookup is supported %s", av); | |||||
return cmd; | |||||
} | |||||
static ipfw_insn * | |||||
add_dstmac(ipfw_insn *cmd, char *av, struct tidx *tstate) | |||||
{ | |||||
if (strncmp(av, "table(", 6) == 0) | |||||
fill_table(cmd, av, O_MAC_DST_LOOKUP, tstate); | |||||
else | |||||
errx(EX_DATAERR, "only mac table lookup is supported %s", av); | |||||
return cmd; | |||||
} | |||||
static struct _s_x f_reserved_keywords[] = { | static struct _s_x f_reserved_keywords[] = { | ||||
{ "altq", TOK_OR }, | { "altq", TOK_OR }, | ||||
{ "//", TOK_OR }, | { "//", TOK_OR }, | ||||
Context not available. | |||||
} | } | ||||
break; | break; | ||||
case TOK_SRCMAC: | |||||
NEED1("missing source MAC"); | |||||
if (add_srcmac(cmd, *av, tstate)) { | |||||
av++; | |||||
} | |||||
break; | |||||
case TOK_DSTMAC: | |||||
NEED1("missing destination MAC"); | |||||
if (add_dstmac(cmd, *av, tstate)) { | |||||
av++; | |||||
} | |||||
break; | |||||
case TOK_SRCPORT: | case TOK_SRCPORT: | ||||
NEED1("missing source port"); | NEED1("missing source port"); | ||||
if (_substrcmp(*av, "any") == 0 || | if (_substrcmp(*av, "any") == 0 || | ||||
Context not available. |