Changeset View
Changeset View
Standalone View
Standalone View
sbin/pfctl/pfctl.c
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#include <limits.h> | #include <limits.h> | ||||
#include <netdb.h> | #include <netdb.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "pfctl_ioctl.h" | |||||
#include "pfctl_parser.h" | #include "pfctl_parser.h" | ||||
#include "pfctl.h" | #include "pfctl.h" | ||||
void usage(void); | void usage(void); | ||||
int pfctl_enable(int, int); | int pfctl_enable(int, int); | ||||
int pfctl_disable(int, int); | int pfctl_disable(int, int); | ||||
int pfctl_clear_stats(int, int); | int pfctl_clear_stats(int, int); | ||||
int pfctl_get_skip_ifaces(void); | int pfctl_get_skip_ifaces(void); | ||||
▲ Show 20 Lines • Show All 873 Lines • ▼ Show 20 Lines | else if (format == PFCTL_SHOW_LABELS && labels) | ||||
pfctl_print_title("LABEL COUNTERS:"); | pfctl_print_title("LABEL COUNTERS:"); | ||||
} | } | ||||
mnr = pr.nr; | mnr = pr.nr; | ||||
if (opts & PF_OPT_CLRRULECTRS) | if (opts & PF_OPT_CLRRULECTRS) | ||||
pr.action = PF_GET_CLR_CNTR; | pr.action = PF_GET_CLR_CNTR; | ||||
for (nr = 0; nr < mnr; ++nr) { | for (nr = 0; nr < mnr; ++nr) { | ||||
pr.nr = nr; | pr.nr = nr; | ||||
if (ioctl(dev, DIOCGETRULE, &pr)) { | if (pfctl_get_rule(dev, nr, pr.ticket, path, PF_SCRUB, | ||||
warn("DIOCGETRULE"); | &pr.rule, pr.anchor_call)) { | ||||
warn("DIOCGETRULENV"); | |||||
goto error; | goto error; | ||||
} | } | ||||
if (pfctl_get_pool(dev, &pr.rule.rpool, | if (pfctl_get_pool(dev, &pr.rule.rpool, | ||||
nr, pr.ticket, PF_SCRUB, path) != 0) | nr, pr.ticket, PF_SCRUB, path) != 0) | ||||
goto error; | goto error; | ||||
switch (format) { | switch (format) { | ||||
Show All 14 Lines | pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, | ||||
pr.rule.action = PF_PASS; | pr.rule.action = PF_PASS; | ||||
if (ioctl(dev, DIOCGETRULES, &pr)) { | if (ioctl(dev, DIOCGETRULES, &pr)) { | ||||
warn("DIOCGETRULES"); | warn("DIOCGETRULES"); | ||||
goto error; | goto error; | ||||
} | } | ||||
mnr = pr.nr; | mnr = pr.nr; | ||||
for (nr = 0; nr < mnr; ++nr) { | for (nr = 0; nr < mnr; ++nr) { | ||||
pr.nr = nr; | pr.nr = nr; | ||||
if (ioctl(dev, DIOCGETRULE, &pr)) { | if (pfctl_get_rule(dev, nr, pr.ticket, path, PF_PASS, | ||||
&pr.rule, pr.anchor_call)) { | |||||
warn("DIOCGETRULE"); | warn("DIOCGETRULE"); | ||||
goto error; | goto error; | ||||
} | } | ||||
if (pfctl_get_pool(dev, &pr.rule.rpool, | if (pfctl_get_pool(dev, &pr.rule.rpool, | ||||
nr, pr.ticket, PF_PASS, path) != 0) | nr, pr.ticket, PF_PASS, path) != 0) | ||||
goto error; | goto error; | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | for (i = 0; i < 3; i++) { | ||||
pr.rule.action = nattype[i]; | pr.rule.action = nattype[i]; | ||||
if (ioctl(dev, DIOCGETRULES, &pr)) { | if (ioctl(dev, DIOCGETRULES, &pr)) { | ||||
warn("DIOCGETRULES"); | warn("DIOCGETRULES"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
mnr = pr.nr; | mnr = pr.nr; | ||||
for (nr = 0; nr < mnr; ++nr) { | for (nr = 0; nr < mnr; ++nr) { | ||||
pr.nr = nr; | pr.nr = nr; | ||||
if (ioctl(dev, DIOCGETRULE, &pr)) { | if (pfctl_get_rule(dev, nr, pr.ticket, anchorname, | ||||
nattype[i], &pr.rule, pr.anchor_call)) { | |||||
warn("DIOCGETRULE"); | warn("DIOCGETRULE"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (pfctl_get_pool(dev, &pr.rule.rpool, nr, | if (pfctl_get_pool(dev, &pr.rule.rpool, nr, | ||||
pr.ticket, nattype[i], anchorname) != 0) | pr.ticket, nattype[i], anchorname) != 0) | ||||
return (-1); | return (-1); | ||||
if (dotitle) { | if (dotitle) { | ||||
pfctl_print_title("TRANSLATION RULES:"); | pfctl_print_title("TRANSLATION RULES:"); | ||||
▲ Show 20 Lines • Show All 1,621 Lines • Show Last 20 Lines |