Changeset View
Changeset View
Standalone View
Standalone View
sbin/pfctl/pfctl.c
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
int pfctl_load_debug(struct pfctl *, unsigned int); | int pfctl_load_debug(struct pfctl *, unsigned int); | ||||
int pfctl_load_logif(struct pfctl *, char *); | int pfctl_load_logif(struct pfctl *, char *); | ||||
int pfctl_load_hostid(struct pfctl *, u_int32_t); | int pfctl_load_hostid(struct pfctl *, u_int32_t); | ||||
int pfctl_load_syncookies(struct pfctl *, u_int8_t); | int pfctl_load_syncookies(struct pfctl *, u_int8_t); | ||||
int pfctl_get_pool(int, struct pfctl_pool *, u_int32_t, u_int32_t, int, | int pfctl_get_pool(int, struct pfctl_pool *, u_int32_t, u_int32_t, int, | ||||
char *); | char *); | ||||
void pfctl_print_eth_rule_counters(struct pfctl_eth_rule *, int); | void pfctl_print_eth_rule_counters(struct pfctl_eth_rule *, int); | ||||
void pfctl_print_rule_counters(struct pfctl_rule *, int); | void pfctl_print_rule_counters(struct pfctl_rule *, int); | ||||
int pfctl_show_eth_rules(int, int); | int pfctl_show_eth_rules(int, int, enum pfctl_show); | ||||
int pfctl_show_rules(int, char *, int, enum pfctl_show, char *, int); | int pfctl_show_rules(int, char *, int, enum pfctl_show, char *, int); | ||||
int pfctl_show_nat(int, int, char *); | int pfctl_show_nat(int, int, char *); | ||||
int pfctl_show_src_nodes(int, int); | int pfctl_show_src_nodes(int, int); | ||||
int pfctl_show_states(int, const char *, int); | int pfctl_show_states(int, const char *, int); | ||||
int pfctl_show_status(int, int); | int pfctl_show_status(int, int); | ||||
int pfctl_show_running(int); | int pfctl_show_running(int); | ||||
int pfctl_show_timeouts(int, int); | int pfctl_show_timeouts(int, int); | ||||
int pfctl_show_limits(int, int); | int pfctl_show_limits(int, int); | ||||
▲ Show 20 Lines • Show All 937 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (!first_title) | if (!first_title) | ||||
printf("\n"); | printf("\n"); | ||||
first_title = 0; | first_title = 0; | ||||
printf("%s\n", title); | printf("%s\n", title); | ||||
} | } | ||||
int | int | ||||
pfctl_show_eth_rules(int dev, int opts) | pfctl_show_eth_rules(int dev, int opts, enum pfctl_show format) | ||||
{ | { | ||||
struct pfctl_eth_rules_info info; | struct pfctl_eth_rules_info info; | ||||
struct pfctl_eth_rule rule; | struct pfctl_eth_rule rule; | ||||
int dotitle = opts & PF_OPT_SHOWALL; | int dotitle = opts & PF_OPT_SHOWALL; | ||||
if (pfctl_get_eth_rules_info(dev, &info)) { | if (pfctl_get_eth_rules_info(dev, &info)) { | ||||
warn("DIOCGETETHRULES"); | warn("DIOCGETETHRULES"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
for (int nr = 0; nr < info.nr; nr++) { | for (int nr = 0; nr < info.nr; nr++) { | ||||
if (pfctl_get_eth_rule(dev, nr, info.ticket, &rule, false) | if (pfctl_get_eth_rule(dev, nr, info.ticket, &rule, | ||||
!= 0) { | opts & PF_OPT_CLRRULECTRS) != 0) { | ||||
warn("DIOCGETETHRULE"); | warn("DIOCGETETHRULE"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (dotitle) { | if (dotitle) { | ||||
pfctl_print_title("ETH RULES:"); | pfctl_print_title("ETH RULES:"); | ||||
dotitle = 0; | dotitle = 0; | ||||
} | } | ||||
print_eth_rule(&rule, opts & (PF_OPT_VERBOSE2 | PF_OPT_DEBUG)); | print_eth_rule(&rule, opts & (PF_OPT_VERBOSE2 | PF_OPT_DEBUG)); | ||||
▲ Show 20 Lines • Show All 1,502 Lines • ▼ Show 20 Lines | case 'R': | ||||
break; | break; | ||||
case 't': | case 't': | ||||
pfctl_show_timeouts(dev, opts); | pfctl_show_timeouts(dev, opts); | ||||
break; | break; | ||||
case 'm': | case 'm': | ||||
pfctl_show_limits(dev, opts); | pfctl_show_limits(dev, opts); | ||||
break; | break; | ||||
case 'e': | case 'e': | ||||
pfctl_show_eth_rules(dev, opts); | pfctl_show_eth_rules(dev, opts, 0); | ||||
break; | break; | ||||
case 'a': | case 'a': | ||||
opts |= PF_OPT_SHOWALL; | opts |= PF_OPT_SHOWALL; | ||||
pfctl_load_fingerprints(dev, opts); | pfctl_load_fingerprints(dev, opts); | ||||
pfctl_show_eth_rules(dev, opts); | pfctl_show_eth_rules(dev, opts, 0); | ||||
pfctl_show_nat(dev, opts, anchorname); | pfctl_show_nat(dev, opts, anchorname); | ||||
pfctl_show_rules(dev, path, opts, 0, anchorname, 0); | pfctl_show_rules(dev, path, opts, 0, anchorname, 0); | ||||
pfctl_show_altq(dev, ifaceopt, opts, 0); | pfctl_show_altq(dev, ifaceopt, opts, 0); | ||||
pfctl_show_states(dev, ifaceopt, opts); | pfctl_show_states(dev, ifaceopt, opts); | ||||
pfctl_show_src_nodes(dev, opts); | pfctl_show_src_nodes(dev, opts); | ||||
pfctl_show_status(dev, opts); | pfctl_show_status(dev, opts); | ||||
pfctl_show_rules(dev, path, opts, 1, anchorname, 0); | pfctl_show_rules(dev, path, opts, 1, anchorname, 0); | ||||
Show All 10 Lines | case 'o': | ||||
pfctl_show_fingerprints(opts); | pfctl_show_fingerprints(opts); | ||||
break; | break; | ||||
case 'I': | case 'I': | ||||
pfctl_show_ifaces(ifaceopt, opts); | pfctl_show_ifaces(ifaceopt, opts); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if ((opts & PF_OPT_CLRRULECTRS) && showopt == NULL) | if ((opts & PF_OPT_CLRRULECTRS) && showopt == NULL) { | ||||
pfctl_show_eth_rules(dev, opts, PFCTL_SHOW_NOTHING); | |||||
pfctl_show_rules(dev, path, opts, PFCTL_SHOW_NOTHING, | pfctl_show_rules(dev, path, opts, PFCTL_SHOW_NOTHING, | ||||
anchorname, 0); | anchorname, 0); | ||||
} | |||||
if (clearopt != NULL) { | if (clearopt != NULL) { | ||||
if (anchorname[0] == '_' || strstr(anchorname, "/_") != NULL) | if (anchorname[0] == '_' || strstr(anchorname, "/_") != NULL) | ||||
errx(1, "anchor names beginning with '_' cannot " | errx(1, "anchor names beginning with '_' cannot " | ||||
"be modified from the command line"); | "be modified from the command line"); | ||||
switch (*clearopt) { | switch (*clearopt) { | ||||
case 'r': | case 'r': | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |