Lines Matching refs:cmd

93 #define	CHECK_CMDLEN	CHECK_LENGTH(cblen, F_LEN((ipfw_insn *)cmd))
911 print_newports(struct buf_pr *bp, const ipfw_insn_u16 *cmd, int proto, int opcode) in print_newports() argument
913 const uint16_t *p = cmd->ports; in print_newports()
924 for (i = F_LEN((const ipfw_insn *)cmd) - 1; i > 0; i--, p += 2) { in print_newports()
1004 fill_newports(ipfw_insn_u16 *cmd, char *av, int proto, int cblen) in fill_newports() argument
1006 uint16_t a, b, *p = cmd->ports; in fill_newports()
1044 cmd->o.len |= i + 1; /* leave F_NOT and F_OR untouched */ in fill_newports()
1053 fill_dscp(ipfw_insn *cmd, char *av, int cblen) in fill_dscp() argument
1059 cmd->opcode = O_DSCP; in fill_dscp()
1060 cmd->len |= F_INSN_SIZE(ipfw_insn_u32) + 1; in fill_dscp()
1064 low = (uint32_t *)(cmd + 1); in fill_dscp()
1170 print_flags(struct buf_pr *bp, char const *name, const ipfw_insn *cmd, in print_flags() argument
1175 uint8_t set = cmd->arg1 & 0xff; in print_flags()
1176 uint8_t clear = (cmd->arg1 >> 8) & 0xff; in print_flags()
1204 const ipfw_insn_ip *cmd) in print_ip() argument
1208 const uint32_t *a = ((const ipfw_insn_u32 *)cmd)->d; in print_ip()
1209 uint32_t len = F_LEN((const ipfw_insn *)cmd); in print_ip()
1213 if (cmd->o.opcode == O_IP_DST_LOOKUP && len > F_INSN_SIZE(ipfw_insn_u32)) { in print_ip()
1220 ((const ipfw_insn *)cmd)->arg1); in print_ip()
1224 if (cmd->o.opcode == O_IP_SRC_ME || cmd->o.opcode == O_IP_DST_ME) { in print_ip()
1228 if (cmd->o.opcode == O_IP_SRC_LOOKUP || in print_ip()
1229 cmd->o.opcode == O_IP_DST_LOOKUP) { in print_ip()
1231 ((const ipfw_insn *)cmd)->arg1); in print_ip()
1238 if (cmd->o.opcode == O_IP_SRC_SET || cmd->o.opcode == O_IP_DST_SET) { in print_ip()
1239 const uint32_t *map = (const uint32_t *)&cmd->mask; in print_ip()
1245 x = cmd->o.arg1 - 1; in print_ip()
1247 addr.s_addr = htonl(cmd->addr.s_addr); in print_ip()
1250 x = cmd->addr.s_addr; in print_ip()
1258 for (i=0; i < cmd->o.arg1; i++) in print_ip()
1260 for (j=i+1; j < cmd->o.arg1; j++) in print_ip()
1280 (cmd->o.opcode == O_IP_SRC || cmd->o.opcode == O_IP_DST) ? in print_ip()
1335 fill_icmptypes(ipfw_insn_u32 *cmd, char *av) in fill_icmptypes() argument
1339 cmd->d[0] = 0; in fill_icmptypes()
1352 cmd->d[0] |= 1 << type; in fill_icmptypes()
1354 cmd->o.opcode = O_ICMPTYPE; in fill_icmptypes()
1355 cmd->o.len |= F_INSN_SIZE(ipfw_insn_u32); in fill_icmptypes()
1359 print_icmptypes(struct buf_pr *bp, const ipfw_insn_u32 *cmd) in print_icmptypes() argument
1366 if ( (cmd->d[0] & (1 << (i))) == 0) in print_icmptypes()
1374 print_dscp(struct buf_pr *bp, const ipfw_insn_u32 *cmd) in print_dscp() argument
1382 v = cmd->d; in print_dscp()
1397 #define insntod(cmd, type) ((const ipfw_insn_ ## type *)(cmd)) argument
1434 is_printed_opcode(struct show_state *state, const ipfw_insn *cmd) in is_printed_opcode() argument
1437 return (state->printed[cmd - state->rule->cmd]); in is_printed_opcode()
1441 mark_printed(struct show_state *state, const ipfw_insn *cmd) in mark_printed() argument
1444 state->printed[cmd - state->rule->cmd] = 1; in mark_printed()
1466 struct show_state *state, const ipfw_insn *cmd) in print_instruction() argument
1474 if (is_printed_opcode(state, cmd)) in print_instruction()
1476 if ((cmd->len & F_OR) != 0 && state->or_block == 0) in print_instruction()
1478 if (cmd->opcode != O_IN && (cmd->len & F_NOT) != 0) in print_instruction()
1481 switch (cmd->opcode) { in print_instruction()
1483 d = 1.0 * insntod(cmd, u32)->d[0] / 0x7fffffff; in print_instruction()
1496 print_ip(bp, fo, insntod(cmd, ip)); in print_instruction()
1505 print_ip(bp, fo, insntod(cmd, ip)); in print_instruction()
1512 print_ip6(bp, insntod(cmd, ip6)); in print_instruction()
1519 print_ip6(bp, insntod(cmd, ip6)); in print_instruction()
1522 print_flow6id(bp, insntod(cmd, u32)); in print_instruction()
1526 print_newports(bp, insntod(cmd, u16), state->proto, in print_instruction()
1528 (HAVE_SRCIP | HAVE_DSTIP) ? cmd->opcode: 0); in print_instruction()
1531 pe = getprotobynumber(cmd->arg1); in print_instruction()
1537 bprintf(bp, " %u", cmd->arg1); in print_instruction()
1538 state->proto = cmd->arg1; in print_instruction()
1541 print_mac(bp, insntod(cmd, mac)); in print_instruction()
1544 print_newports(bp, insntod(cmd, u16), in print_instruction()
1545 IPPROTO_ETHERTYPE, cmd->opcode); in print_instruction()
1548 print_flags(bp, "frag", cmd, f_ipoff); in print_instruction()
1551 bprintf(bp, " fib %u", cmd->arg1); in print_instruction()
1557 bprintf(bp, cmd->len & F_NOT ? " out" : " in"); in print_instruction()
1560 switch (cmd->arg1) { in print_instruction()
1571 bprintf(bp, " diverted-?<%u>", cmd->arg1); in print_instruction()
1581 if (cmd->opcode == O_XMIT) in print_instruction()
1583 else if (cmd->opcode == O_RECV) in print_instruction()
1587 switch (insntod(cmd, if)->name[0]) { in print_instruction()
1590 inet_ntoa(insntod(cmd, if)->p.ip)); in print_instruction()
1595 insntod(cmd, if)->p.kidx)); in print_instruction()
1599 insntod(cmd, if)->name); in print_instruction()
1603 s = table_search_ctlv(fo->tstate, cmd->arg1); in print_instruction()
1605 if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn_u32)) in print_instruction()
1606 bprintf(bp, ",%u", insntod(cmd, u32)->d[0]); in print_instruction()
1615 if (F_LEN(cmd) == 1) { in print_instruction()
1616 switch (cmd->opcode) { in print_instruction()
1639 bprintf(bp, " %s %u", s, cmd->arg1); in print_instruction()
1641 print_newports(bp, insntod(cmd, u16), 0, in print_instruction()
1642 cmd->opcode); in print_instruction()
1645 bprintf(bp, " ipver %u", cmd->arg1); in print_instruction()
1648 bprintf(bp, " ipprecedence %u", cmd->arg1 >> 5); in print_instruction()
1651 print_dscp(bp, insntod(cmd, u32)); in print_instruction()
1654 print_flags(bp, "ipoptions", cmd, f_ipopts); in print_instruction()
1657 print_flags(bp, "iptos", cmd, f_iptos); in print_instruction()
1660 print_icmptypes(bp, insntod(cmd, u32)); in print_instruction()
1666 print_flags(bp, "tcpflags", cmd, f_tcpflags); in print_instruction()
1669 print_flags(bp, "tcpoptions", cmd, f_tcpopts); in print_instruction()
1673 ntohl(insntod(cmd, u32)->d[0])); in print_instruction()
1677 ntohl(insntod(cmd, u32)->d[0])); in print_instruction()
1680 pwd = getpwuid(insntod(cmd, u32)->d[0]); in print_instruction()
1685 insntod(cmd, u32)->d[0]); in print_instruction()
1688 grp = getgrgid(insntod(cmd, u32)->d[0]); in print_instruction()
1693 insntod(cmd, u32)->d[0]); in print_instruction()
1696 bprintf(bp, " jail %d", insntod(cmd, u32)->d[0]); in print_instruction()
1711 bprintf(bp, " // %s", (const char *)(cmd + 1)); in print_instruction()
1719 object_search_ctlv(fo->tstate, cmd->arg1, in print_instruction()
1727 print_limit_mask(bp, insntod(cmd, limit)); in print_instruction()
1729 object_search_ctlv(fo->tstate, cmd->arg1, in print_instruction()
1743 print_icmp6types(bp, insntod(cmd, u32)); in print_instruction()
1746 print_ext6hdr(bp, cmd); in print_instruction()
1749 if (F_LEN(cmd) == 1) in print_instruction()
1750 bprint_uint_arg(bp, " tagged ", cmd->arg1); in print_instruction()
1752 print_newports(bp, insntod(cmd, u16), in print_instruction()
1759 bprintf(bp, " [opcode %d len %d]", cmd->opcode, in print_instruction()
1760 cmd->len); in print_instruction()
1762 if (cmd->len & F_OR) { in print_instruction()
1769 mark_printed(state, cmd); in print_instruction()
1778 ipfw_insn *cmd; in print_opcode() local
1781 for (l = state->rule->act_ofs, cmd = state->rule->cmd; in print_opcode()
1782 l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) { in print_opcode()
1784 if (opcode >= 0 && cmd->opcode != opcode) in print_opcode()
1790 if (cmd->opcode == O_NOP && opcode != O_NOP) in print_opcode()
1792 if (!print_instruction(bp, fo, state, cmd)) in print_opcode()
1794 return (cmd); in print_opcode()
1800 print_fwd(struct buf_pr *bp, const ipfw_insn *cmd) in print_fwd() argument
1807 if (cmd->opcode == O_FORWARD_IP) { in print_fwd()
1808 sa = insntod(cmd, sa); in print_fwd()
1815 sa6 = insntod(cmd, sa6); in print_fwd()
1829 struct show_state *state, const ipfw_insn *cmd) in print_action_instruction() argument
1833 if (is_printed_opcode(state, cmd)) in print_action_instruction()
1835 switch (cmd->opcode) { in print_action_instruction()
1838 if (cmd->arg1 != 0) in print_action_instruction()
1839 s = object_search_ctlv(fo->tstate, cmd->arg1, in print_action_instruction()
1855 if (cmd->arg1 == ICMP_REJECT_RST) in print_action_instruction()
1857 else if (cmd->arg1 == ICMP_REJECT_ABORT) in print_action_instruction()
1859 else if (cmd->arg1 == ICMP_UNREACH_HOST) in print_action_instruction()
1862 print_reject_code(bp, cmd->arg1); in print_action_instruction()
1865 if (cmd->arg1 == ICMP6_UNREACH_RST) in print_action_instruction()
1867 else if (cmd->arg1 == ICMP6_UNREACH_ABORT) in print_action_instruction()
1870 print_unreach6_code(bp, cmd->arg1); in print_action_instruction()
1873 bprint_uint_arg(bp, "skipto ", cmd->arg1); in print_action_instruction()
1876 bprint_uint_arg(bp, "pipe ", cmd->arg1); in print_action_instruction()
1879 bprint_uint_arg(bp, "queue ", cmd->arg1); in print_action_instruction()
1882 bprint_uint_arg(bp, "divert ", cmd->arg1); in print_action_instruction()
1885 bprint_uint_arg(bp, "tee ", cmd->arg1); in print_action_instruction()
1888 bprint_uint_arg(bp, "netgraph ", cmd->arg1); in print_action_instruction()
1891 bprint_uint_arg(bp, "ngtee ", cmd->arg1); in print_action_instruction()
1895 print_fwd(bp, cmd); in print_action_instruction()
1898 if (insntod(cmd, log)->max_log > 0) in print_action_instruction()
1900 insntod(cmd, log)->max_log); in print_action_instruction()
1906 print_altq_cmd(bp, insntod(cmd, altq)); in print_action_instruction()
1910 bprint_uint_arg(bp, cmd->len & F_NOT ? " untag ": in print_action_instruction()
1911 " tag ", cmd->arg1); in print_action_instruction()
1914 if (cmd->arg1 != IP_FW_NAT44_GLOBAL) in print_action_instruction()
1915 bprint_uint_arg(bp, "nat ", cmd->arg1); in print_action_instruction()
1920 if (cmd->arg1 == IP_FW_TARG) in print_action_instruction()
1921 bprint_uint_arg(bp, "setfib ", cmd->arg1); in print_action_instruction()
1923 bprintf(bp, "setfib %u", cmd->arg1 & 0x7FFF); in print_action_instruction()
1935 state->eaction = cmd; in print_action_instruction()
1936 s = object_search_ctlv(fo->tstate, cmd->arg1, in print_action_instruction()
1956 s = object_search_ctlv(fo->tstate, cmd->arg1, 0); in print_action_instruction()
1959 cmd->arg1, IPFW_TLV_EACTION_NAME( in print_action_instruction()
1971 if (cmd->len == F_INSN_SIZE(ipfw_insn)) in print_action_instruction()
1972 bprintf(bp, " %u", cmd->arg1); in print_action_instruction()
1975 cmd->len * sizeof(uint32_t)); in print_action_instruction()
1978 if (cmd->arg1 == IP_FW_TARG) { in print_action_instruction()
1982 s = match_value(f_ipdscp, cmd->arg1 & 0x3F); in print_action_instruction()
1986 bprintf(bp, "setdscp %u", cmd->arg1 & 0x3F); in print_action_instruction()
1992 if (cmd->len & F_NOT) in print_action_instruction()
1995 bprint_uint_arg(bp, "call ", cmd->arg1); in print_action_instruction()
1999 cmd->opcode, cmd->len); in print_action_instruction()
2001 mark_printed(state, cmd); in print_action_instruction()
2011 ipfw_insn *cmd; in print_action() local
2015 cmd = ACTION_PTR(state->rule); l > 0; in print_action()
2016 l -= F_LEN(cmd), cmd += F_LEN(cmd)) { in print_action()
2017 if (cmd->opcode != opcode) in print_action()
2019 if (!print_action_instruction(bp, fo, state, cmd)) in print_action()
2021 return (cmd); in print_action()
2030 ipfw_insn *cmd; in print_proto() local
2035 for (l = state->rule->act_ofs, cmd = state->rule->cmd; in print_proto()
2036 l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) { in print_proto()
2037 switch (cmd->opcode) { in print_proto()
2043 if (cmd->len & F_OR) in print_proto()
2048 if (cmd->len & F_OR) in print_proto()
2062 cmd = NULL; in print_proto()
2064 cmd = print_opcode(bp, fo, state, ip4 > ip6 ? O_IP4: O_IP6); in print_proto()
2065 if (cmd != NULL && (cmd->len & F_OR)) in print_proto()
2066 cmd = print_opcode(bp, fo, state, ip4 > ip6 ? O_IP6: O_IP4); in print_proto()
2067 if (cmd == NULL || (cmd->len & F_OR)) in print_proto()
2069 cmd = print_opcode(bp, fo, state, O_PROTO); in print_proto()
2070 if (cmd == NULL || (cmd->len & F_OR) == 0) in print_proto()
2095 ipfw_insn *cmd; in print_address() local
2099 for (l = state->rule->act_ofs, cmd = state->rule->cmd; in print_address()
2100 l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) { in print_address()
2101 if (match_opcode(cmd->opcode, opcodes, nops)) in print_address()
2103 else if (cmd->opcode == portop) in print_address()
2108 for (l = state->rule->act_ofs, cmd = state->rule->cmd; in print_address()
2109 l > 0 && count > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) { in print_address()
2110 if (!match_opcode(cmd->opcode, opcodes, nops)) in print_address()
2112 print_instruction(bp, fo, state, cmd); in print_address()
2113 if ((cmd->len & F_OR) == 0) in print_address()
2122 for (l = state->rule->act_ofs, cmd = state->rule->cmd, pf = 0; in print_address()
2123 l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) { in print_address()
2124 if (cmd->opcode != portop) { in print_address()
2125 pf = (cmd->len & F_OR); in print_address()
2129 if (pf == 0 && (cmd->len & F_OR) == 0) in print_address()
2130 print_instruction(bp, fo, state, cmd); in print_address()
2166 ipfw_insn *cmd; in show_static_rule() local
2220 cmd = print_opcode(bp, fo, &state, O_PROB); in show_static_rule()
2223 cmd = print_action(bp, fo, &state, action_opcodes[i]); in show_static_rule()
2224 if (cmd == NULL) in show_static_rule()
2227 switch (cmd->opcode) { in show_static_rule()
2271 cmd = print_opcode(bp, fo, &state, O_NOP); in show_static_rule()
2272 if (co->comment_only != 0 && cmd == NULL) in show_static_rule()
2361 do_range_cmd(int cmd, ipfw_range_tlv *rt) in do_range_cmd() argument
2372 if (do_get3(cmd, &rh.opheader, &sz) != 0) in do_range_cmd()
2395 uint8_t cmd; in ipfw_sets_handler() local
2438 cmd = IP_FW_XMOVE; in ipfw_sets_handler()
2441 cmd = IP_FW_SET_MOVE; /* Move set to new one */ in ipfw_sets_handler()
2447 if (cmd == IP_FW_XMOVE) { in ipfw_sets_handler()
2453 if (!isdigit(*(av[0])) || (cmd == 3 && rt.set > RESVD_SET) || in ipfw_sets_handler()
2454 (cmd == 2 && rt.start_rule == IPFW_DEFAULT_RULE) ) in ipfw_sets_handler()
2458 i = do_range_cmd(cmd, &rt); in ipfw_sets_handler()
2461 cmd == IP_FW_SET_MOVE ? "set": "rule"); in ipfw_sets_handler()
3077 fill_table(struct _ipfw_insn *cmd, char *av, uint8_t opcode, in fill_table() argument
3080 uint32_t *d = ((ipfw_insn_u32 *)cmd)->d; in fill_table()
3094 cmd->opcode = opcode; in fill_table()
3095 cmd->arg1 = uidx; in fill_table()
3097 cmd->len |= F_INSN_SIZE(ipfw_insn_u32); in fill_table()
3100 cmd->len |= F_INSN_SIZE(ipfw_insn); in fill_table()
3116 fill_ip(ipfw_insn_ip *cmd, char *av, int cblen, struct tidx *tstate) in fill_ip() argument
3119 uint32_t *d = ((ipfw_insn_u32 *)cmd)->d; in fill_ip()
3121 cmd->o.len &= ~F_LEN_MASK; /* zero len */ in fill_ip()
3127 cmd->o.len |= F_INSN_SIZE(ipfw_insn); in fill_ip()
3132 fill_table(&cmd->o, av, O_IP_DST_LOOKUP, tstate); in fill_ip()
3202 uint32_t *map = (uint32_t *)&cmd->mask; in fill_ip()
3210 cmd->o.arg1 = 1<<(32-i); /* map length */ in fill_ip()
3212 cmd->o.opcode = O_IP_DST_SET; /* default */ in fill_ip()
3213 cmd->o.len |= F_INSN_SIZE(ipfw_insn_u32) + (cmd->o.arg1+31)/32; in fill_ip()
3214 for (i = 0; i < (cmd->o.arg1+31)/32 ; i++) in fill_ip()
3219 high = low + cmd->o.arg1 - 1; in fill_ip()
3273 if (cmd->o.len & F_NOT) { /* "not any" never matches */ in fill_ip()
3282 cmd->o.len |= F_INSN_SIZE(ipfw_insn_u32); in fill_ip()
3290 cmd->o.len |= len+1; in fill_ip()
3314 fill_flags_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, in fill_flags_cmd() argument
3323 cmd->opcode = opcode; in fill_flags_cmd()
3324 cmd->len = (cmd->len & (F_NOT | F_OR)) | 1; in fill_flags_cmd()
3325 cmd->arg1 = (set & 0xff) | ( (clear & 0xff) << 8); in fill_flags_cmd()
3414 fill_iface(ipfw_insn_if *cmd, char *arg, int cblen, struct tidx *tstate) in fill_iface() argument
3419 cmd->name[0] = '\0'; in fill_iface()
3420 cmd->o.len |= F_INSN_SIZE(ipfw_insn_if); in fill_iface()
3426 cmd->o.len = 0; /* effectively ignore this command */ in fill_iface()
3437 cmd->name[0] = '\1'; /* Special value indicating table */ in fill_iface()
3438 cmd->p.kidx = uidx; in fill_iface()
3440 strlcpy(cmd->name, arg, sizeof(cmd->name)); in fill_iface()
3441 cmd->p.glob = strpbrk(arg, "*?[") != NULL ? 1 : 0; in fill_iface()
3442 } else if (!inet_aton(arg, &cmd->p.ip)) in fill_iface()
3500 next_cmd(ipfw_insn *cmd, int *len) in next_cmd() argument
3502 *len -= F_LEN(cmd); in next_cmd()
3504 cmd += F_LEN(cmd); in next_cmd()
3505 bzero(cmd, sizeof(*cmd)); in next_cmd()
3506 return cmd; in next_cmd()
3513 fill_comment(ipfw_insn *cmd, char **av, int cblen) in fill_comment() argument
3516 char *p = (char *)(cmd + 1); in fill_comment()
3518 cmd->opcode = O_NOP; in fill_comment()
3519 cmd->len = (cmd->len & (F_NOT | F_OR)); in fill_comment()
3530 cmd->len = (cmd->len & (F_NOT | F_OR)) | l; in fill_comment()
3546 fill_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, int flags, uint16_t arg) in fill_cmd() argument
3548 cmd->opcode = opcode; in fill_cmd()
3549 cmd->len = ((cmd->len | flags) & (F_NOT | F_OR)) | 1; in fill_cmd()
3550 cmd->arg1 = arg; in fill_cmd()
3558 add_mac(ipfw_insn *cmd, char *av[], int cblen) in add_mac() argument
3565 cmd->opcode = O_MACADDR2; in add_mac()
3566 cmd->len = (cmd->len & (F_NOT | F_OR)) | F_INSN_SIZE(ipfw_insn_mac); in add_mac()
3569 mac = (ipfw_insn_mac *)cmd; in add_mac()
3573 return cmd; in add_mac()
3577 add_mactype(ipfw_insn *cmd, char *av, int cblen) in add_mactype() argument
3582 fill_newports((ipfw_insn_u16 *)cmd, av, IPPROTO_ETHERTYPE, in add_mactype()
3584 cmd->opcode = O_MAC_TYPE; in add_mactype()
3585 return cmd; in add_mactype()
3591 add_proto0(ipfw_insn *cmd, char *av, u_char *protop) in add_proto0() argument
3604 fill_cmd(cmd, O_PROTO, 0, proto); in add_proto0()
3606 return cmd; in add_proto0()
3610 add_proto(ipfw_insn *cmd, char *av, u_char *protop) in add_proto() argument
3618 fill_cmd(cmd, O_IP4, 0, 0); in add_proto()
3622 fill_cmd(cmd, O_IP6, 0, 0); in add_proto()
3624 return add_proto0(cmd, av, protop); in add_proto()
3627 return cmd; in add_proto()
3631 add_proto_compat(ipfw_insn *cmd, char *av, u_char *protop) in add_proto_compat() argument
3639 fill_cmd(cmd, O_IP4, 0, 0); in add_proto_compat()
3643 fill_cmd(cmd, O_IP6, 0, 0); in add_proto_compat()
3645 return add_proto0(cmd, av, protop); in add_proto_compat()
3648 return cmd; in add_proto_compat()
3652 add_srcip(ipfw_insn *cmd, char *av, int cblen, struct tidx *tstate) in add_srcip() argument
3654 fill_ip((ipfw_insn_ip *)cmd, av, cblen, tstate); in add_srcip()
3655 if (cmd->opcode == O_IP_DST_SET) /* set */ in add_srcip()
3656 cmd->opcode = O_IP_SRC_SET; in add_srcip()
3657 else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */ in add_srcip()
3658 cmd->opcode = O_IP_SRC_LOOKUP; in add_srcip()
3659 else if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn)) /* me */ in add_srcip()
3660 cmd->opcode = O_IP_SRC_ME; in add_srcip()
3661 else if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn_u32)) /* one IP */ in add_srcip()
3662 cmd->opcode = O_IP_SRC; in add_srcip()
3664 cmd->opcode = O_IP_SRC_MASK; in add_srcip()
3665 return cmd; in add_srcip()
3669 add_dstip(ipfw_insn *cmd, char *av, int cblen, struct tidx *tstate) in add_dstip() argument
3671 fill_ip((ipfw_insn_ip *)cmd, av, cblen, tstate); in add_dstip()
3672 if (cmd->opcode == O_IP_DST_SET) /* set */ in add_dstip()
3674 else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */ in add_dstip()
3676 else if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn)) /* me */ in add_dstip()
3677 cmd->opcode = O_IP_DST_ME; in add_dstip()
3678 else if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn_u32)) /* one IP */ in add_dstip()
3679 cmd->opcode = O_IP_DST; in add_dstip()
3681 cmd->opcode = O_IP_DST_MASK; in add_dstip()
3682 return cmd; in add_dstip()
3706 add_ports(ipfw_insn *cmd, char *av, u_char proto, int opcode, int cblen) in add_ports() argument
3712 if (fill_newports((ipfw_insn_u16 *)cmd, av, proto, cblen)) { in add_ports()
3714 cmd->opcode = opcode; in add_ports()
3715 return cmd; in add_ports()
3721 add_src(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate) in add_src() argument
3740 ret = add_srcip6(cmd, av, cblen, tstate); in add_src()
3744 ret = add_srcip(cmd, av, cblen, tstate); in add_src()
3746 ret = cmd; in add_src()
3752 add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate) in add_dst() argument
3771 ret = add_dstip6(cmd, av, cblen, tstate); in add_dst()
3775 ret = add_dstip(cmd, av, cblen, tstate); in add_dst()
3777 ret = cmd; in add_dst()
3806 ipfw_insn *src, *dst, *cmd, *action, *prev=NULL; in compile_rule() local
3834 cmd = (ipfw_insn *)cmdbuf; in compile_rule()
4255 ipfw_insn_log *c = (ipfw_insn_log *)cmd; in compile_rule()
4262 cmd->len = F_INSN_SIZE(ipfw_insn_log); in compile_rule()
4264 cmd->opcode = O_LOG; in compile_rule()
4292 ipfw_insn_altq *a = (ipfw_insn_altq *)cmd; in compile_rule()
4299 cmd->len = F_INSN_SIZE(ipfw_insn_altq); in compile_rule()
4301 cmd->opcode = O_ALTQ; in compile_rule()
4317 have_tag = cmd; in compile_rule()
4318 fill_cmd(cmd, O_TAG, (i == TOK_TAG) ? 0: F_NOT, tag); in compile_rule()
4326 cmd = next_cmd(cmd, &cblen); in compile_rule()
4334 fill_comment(cmd, av, cblen); in compile_rule()
4335 cmd = next_cmd(cmd, &cblen); in compile_rule()
4369 if (cmd->len & F_NOT) \ in compile_rule()
4371 cmd->len |= F_NOT; \ in compile_rule()
4385 first_cmd = cmd; in compile_rule()
4398 add_mac(cmd, av); /* exits in case of errors */ in compile_rule()
4399 cmd = next_cmd(cmd); in compile_rule()
4403 if (add_mactype(cmd, av[0])) in compile_rule()
4404 cmd = next_cmd(cmd); in compile_rule()
4416 if (add_proto_compat(cmd, *av, &proto)) { in compile_rule()
4418 if (F_LEN(cmd) != 0) { in compile_rule()
4419 prev = cmd; in compile_rule()
4420 cmd = next_cmd(cmd, &cblen); in compile_rule()
4422 } else if (first_cmd != cmd) { in compile_rule()
4430 first_cmd = cmd; /* update pointer to use in compact form */ in compile_rule()
4445 if (add_src(cmd, *av, proto, cblen, tstate)) { in compile_rule()
4447 if (F_LEN(cmd) != 0) { /* ! any */ in compile_rule()
4448 prev = cmd; in compile_rule()
4449 cmd = next_cmd(cmd, &cblen); in compile_rule()
4461 add_ports(cmd, *av, proto, O_IP_SRCPORT, cblen)) { in compile_rule()
4463 if (F_LEN(cmd) != 0) in compile_rule()
4464 cmd = next_cmd(cmd, &cblen); in compile_rule()
4481 if (add_dst(cmd, *av, proto, cblen, tstate)) { in compile_rule()
4483 if (F_LEN(cmd) != 0) { /* ! any */ in compile_rule()
4484 prev = cmd; in compile_rule()
4485 cmd = next_cmd(cmd, &cblen); in compile_rule()
4497 add_ports(cmd, *av, proto, O_IP_DSTPORT, cblen)) { in compile_rule()
4499 if (F_LEN(cmd) != 0) in compile_rule()
4500 cmd = next_cmd(cmd, &cblen); in compile_rule()
4503 if (first_cmd == cmd) in compile_rule()
4513 cmd32 = (ipfw_insn_u32 *)cmd; in compile_rule()
4516 if (cmd->len & F_NOT) in compile_rule()
4518 cmd->len = F_NOT; in compile_rule()
4525 if (cmd->len & F_NOT) in compile_rule()
4527 cmd->len = F_NOT; in compile_rule()
4550 fill_cmd(cmd, O_IN, 0, 0); in compile_rule()
4554 cmd->len ^= F_NOT; /* toggle F_NOT */ in compile_rule()
4555 fill_cmd(cmd, O_IN, 0, 0); in compile_rule()
4559 fill_cmd(cmd, O_DIVERTED, 0, 3); in compile_rule()
4563 fill_cmd(cmd, O_DIVERTED, 0, 1); in compile_rule()
4567 fill_cmd(cmd, O_DIVERTED, 0, 2); in compile_rule()
4584 fill_cmd(cmd, O_FRAG, 0, in compile_rule()
4590 fill_cmd(cmd, O_LAYER2, 0, 0); in compile_rule()
4598 fill_iface((ipfw_insn_if *)cmd, av[0], cblen, tstate); in compile_rule()
4600 if (F_LEN(cmd) == 0) /* not a valid address */ in compile_rule()
4603 cmd->opcode = O_XMIT; in compile_rule()
4605 cmd->opcode = O_RECV; in compile_rule()
4607 cmd->opcode = O_VIA; in compile_rule()
4612 fill_icmptypes((ipfw_insn_u32 *)cmd, *av); in compile_rule()
4618 fill_icmp6types((ipfw_insn_icmp6 *)cmd, *av, cblen); in compile_rule()
4625 if (!add_ports(cmd, *av, 0, O_IPTTL, cblen)) in compile_rule()
4628 fill_cmd(cmd, O_IPTTL, 0, strtoul(*av, NULL, 0)); in compile_rule()
4635 if (!add_ports(cmd, *av, 0, O_IPID, cblen)) in compile_rule()
4638 fill_cmd(cmd, O_IPID, 0, strtoul(*av, NULL, 0)); in compile_rule()
4645 if (!add_ports(cmd, *av, 0, O_IPLEN, cblen)) in compile_rule()
4648 fill_cmd(cmd, O_IPLEN, 0, strtoul(*av, NULL, 0)); in compile_rule()
4654 fill_cmd(cmd, O_IPVER, 0, strtoul(*av, NULL, 0)); in compile_rule()
4660 fill_cmd(cmd, O_IPPRECEDENCE, 0, in compile_rule()
4667 fill_dscp(cmd, *av, cblen); in compile_rule()
4673 fill_flags_cmd(cmd, O_IPOPT, f_ipopts, *av); in compile_rule()
4679 fill_flags_cmd(cmd, O_IPTOS, f_iptos, *av); in compile_rule()
4690 cmd->opcode = O_UID; in compile_rule()
4696 cmd->len |= F_INSN_SIZE(ipfw_insn_u32); in compile_rule()
4708 cmd->opcode = O_GID; in compile_rule()
4714 cmd->len |= F_INSN_SIZE(ipfw_insn_u32); in compile_rule()
4725 cmd->opcode = O_JAIL; in compile_rule()
4744 cmd->len |= F_INSN_SIZE(ipfw_insn_u32); in compile_rule()
4750 fill_cmd(cmd, O_ESTAB, 0, 0); in compile_rule()
4754 fill_cmd(cmd, O_TCPFLAGS, 0, in compile_rule()
4761 if (!add_ports(cmd, *av, 0, O_TCPDATALEN, cblen)) in compile_rule()
4764 fill_cmd(cmd, O_TCPDATALEN, 0, in compile_rule()
4771 fill_flags_cmd(cmd, O_TCPOPTS, f_tcpopts, *av); in compile_rule()
4778 cmd->len = F_INSN_SIZE(ipfw_insn_u32); in compile_rule()
4779 cmd->opcode = (i == TOK_TCPSEQ) ? O_TCPSEQ : O_TCPACK; in compile_rule()
4788 if (add_ports(cmd, *av, 0, in compile_rule()
4794 fill_cmd(cmd, i == TOK_TCPWIN ? O_TCPWIN : in compile_rule()
4801 cmd->opcode = O_TCPFLAGS; in compile_rule()
4802 fill_flags_cmd(cmd, O_TCPFLAGS, f_tcpflags, *av); in compile_rule()
4826 have_state = cmd; in compile_rule()
4828 fill_cmd(cmd, O_KEEP_STATE, 0, uidx); in compile_rule()
4834 ipfw_insn_limit *c = (ipfw_insn_limit *)cmd; in compile_rule()
4843 have_state = cmd; in compile_rule()
4846 cmd->len = F_INSN_SIZE(ipfw_insn_limit); in compile_rule()
4848 cmd->opcode = O_LIMIT; in compile_rule()
4869 cmd->arg1 = pack_object(tstate, *av + 1, in compile_rule()
4873 cmd->arg1 = pack_object(tstate, in compile_rule()
4880 if (add_proto(cmd, *av, &proto)) { in compile_rule()
4889 if (add_srcip(cmd, *av, cblen, tstate)) { in compile_rule()
4896 if (add_dstip(cmd, *av, cblen, tstate)) { in compile_rule()
4903 if (add_srcip6(cmd, *av, cblen, tstate)) { in compile_rule()
4910 if (add_dstip6(cmd, *av, cblen, tstate)) { in compile_rule()
4918 add_ports(cmd, *av, proto, O_IP_SRCPORT, cblen)) { in compile_rule()
4927 add_ports(cmd, *av, proto, O_IP_DSTPORT, cblen)) { in compile_rule()
4935 if (add_mac(cmd, av, cblen)) in compile_rule()
4941 if (!add_mactype(cmd, *av, cblen)) in compile_rule()
4947 fill_cmd(cmd, O_VERREVPATH, 0, 0); in compile_rule()
4951 fill_cmd(cmd, O_VERSRCREACH, 0, 0); in compile_rule()
4955 fill_cmd(cmd, O_ANTISPOOF, 0, 0); in compile_rule()
4959 fill_cmd(cmd, O_IPSEC, 0, 0); in compile_rule()
4963 fill_cmd(cmd, O_IP6, 0, 0); in compile_rule()
4967 fill_cmd(cmd, O_IP4, 0, 0); in compile_rule()
4972 fill_ext6hdr( cmd, *av ); in compile_rule()
4980 fill_flow6( (ipfw_insn_u32 *) cmd, *av, cblen); in compile_rule()
4985 fill_comment(cmd, av, cblen); in compile_rule()
4991 if (!add_ports(cmd, *av, 0, O_TAGGED, cblen)) in compile_rule()
5000 fill_cmd(cmd, O_TAGGED, 0, tag); in compile_rule()
5007 fill_cmd(cmd, O_FIB, 0, strtoul(*av, NULL, 0)); in compile_rule()
5011 fill_cmd(cmd, O_SOCKARG, 0, 0); in compile_rule()
5015 ipfw_insn_u32 *c = (ipfw_insn_u32 *)cmd; in compile_rule()
5020 cmd->opcode = O_IP_DST_LOOKUP; in compile_rule()
5021 cmd->len |= F_INSN_SIZE(ipfw_insn) + 2; in compile_rule()
5035 cmd->arg1 = j; in compile_rule()
5044 fill_table(cmd, *av, O_IP_FLOW_LOOKUP, tstate); in compile_rule()
5052 have_skipcmd = cmd; in compile_rule()
5053 fill_cmd(cmd, O_SKIP_ACTION, 0, 0); in compile_rule()
5059 if (F_LEN(cmd) > 0) { /* prepare to advance */ in compile_rule()
5060 prev = cmd; in compile_rule()
5061 cmd = next_cmd(cmd, &cblen); in compile_rule()
5078 dst = (ipfw_insn *)rule->cmd; in compile_rule()
5102 for (src = (ipfw_insn *)cmdbuf; src != cmd; src += i) { in compile_rule()
5143 rule->act_ofs = dst - rule->cmd; in compile_rule()
5175 rule->cmd_len = (uint32_t *)dst - (uint32_t *)(rule->cmd); in compile_rule()