Changeset View
Changeset View
Standalone View
Standalone View
sbin/pfctl/pfctl.c
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
static char *rulesopt; | static char *rulesopt; | ||||
static const char *showopt; | static const char *showopt; | ||||
static const char *debugopt; | static const char *debugopt; | ||||
static char *anchoropt; | static char *anchoropt; | ||||
static const char *optiopt = NULL; | static const char *optiopt = NULL; | ||||
static const char *pf_device = "/dev/pf"; | static const char *pf_device = "/dev/pf"; | ||||
static char *ifaceopt; | static char *ifaceopt; | ||||
static char *tableopt; | static char *tableopt; | ||||
static char *schedule; | |||||
static const char *tblcmdopt; | static const char *tblcmdopt; | ||||
static int src_node_killers; | static int src_node_killers; | ||||
static char *src_node_kill[2]; | static char *src_node_kill[2]; | ||||
static int state_killers; | static int state_killers; | ||||
static char *state_kill[2]; | static char *state_kill[2]; | ||||
int loadopt; | int loadopt; | ||||
int altqsupport; | int altqsupport; | ||||
▲ Show 20 Lines • Show All 1,981 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
int optimize = PF_OPTIMIZE_BASIC; | int optimize = PF_OPTIMIZE_BASIC; | ||||
char anchorname[MAXPATHLEN]; | char anchorname[MAXPATHLEN]; | ||||
char *path; | char *path; | ||||
if (argc < 2) | if (argc < 2) | ||||
usage(); | usage(); | ||||
while ((ch = getopt(argc, argv, | while ((ch = getopt(argc, argv, | ||||
"a:AdD:eqf:F:ghi:k:K:mnNOo:Pp:rRs:t:T:vx:z")) != -1) { | "a:AdD:eqf:F:ghi:k:K:mnNOo:Pp:rRs:t:T:vx:y:z")) != -1) { | ||||
switch (ch) { | switch (ch) { | ||||
case 'a': | case 'a': | ||||
anchoropt = optarg; | anchoropt = optarg; | ||||
break; | break; | ||||
case 'd': | case 'd': | ||||
opts |= PF_OPT_DISABLE; | opts |= PF_OPT_DISABLE; | ||||
mode = O_RDWR; | mode = O_RDWR; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | while ((ch = getopt(argc, argv, | ||||
case 'x': | case 'x': | ||||
debugopt = pfctl_lookup_option(optarg, debugopt_list); | debugopt = pfctl_lookup_option(optarg, debugopt_list); | ||||
if (debugopt == NULL) { | if (debugopt == NULL) { | ||||
warnx("Unknown debug level '%s'", optarg); | warnx("Unknown debug level '%s'", optarg); | ||||
usage(); | usage(); | ||||
} | } | ||||
mode = O_RDWR; | mode = O_RDWR; | ||||
break; | break; | ||||
case 'y': | |||||
if (schedule != NULL && strlen(schedule) > | |||||
PF_RULE_LABEL_SIZE) | |||||
errx(1, "Schedule label cannot be more than %d" | |||||
" characters\n", PF_RULE_LABEL_SIZE); | |||||
schedule = optarg; | |||||
mode = O_RDWR; | |||||
break; | |||||
case 'z': | case 'z': | ||||
opts |= PF_OPT_CLRRULECTRS; | opts |= PF_OPT_CLRRULECTRS; | ||||
mode = O_RDWR; | mode = O_RDWR; | ||||
break; | break; | ||||
case 'h': | case 'h': | ||||
/* FALLTHROUGH */ | /* FALLTHROUGH */ | ||||
default: | default: | ||||
usage(); | usage(); | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | if (state_killers) { | ||||
else if (!strcmp(state_kill[0], "id")) | else if (!strcmp(state_kill[0], "id")) | ||||
pfctl_id_kill_states(dev, ifaceopt, opts); | pfctl_id_kill_states(dev, ifaceopt, opts); | ||||
else | else | ||||
pfctl_net_kill_states(dev, ifaceopt, opts); | pfctl_net_kill_states(dev, ifaceopt, opts); | ||||
} | } | ||||
if (src_node_killers) | if (src_node_killers) | ||||
pfctl_kill_src_nodes(dev, ifaceopt, opts); | pfctl_kill_src_nodes(dev, ifaceopt, opts); | ||||
if (schedule) { | |||||
int killed; | |||||
if (libpfctl_kill_schedule(dev, schedule, &killed)) | |||||
err(1, "DIOCKILLSCHEDULE"); | |||||
if ((opts & PF_OPT_QUIET) == 0) | |||||
fprintf(stderr, "killed %d states from %s schedule label\n", | |||||
killed, schedule); | |||||
} | |||||
if (tblcmdopt != NULL) { | if (tblcmdopt != NULL) { | ||||
error = pfctl_command_tables(argc, argv, tableopt, | error = pfctl_command_tables(argc, argv, tableopt, | ||||
tblcmdopt, rulesopt, anchorname, opts); | tblcmdopt, rulesopt, anchorname, opts); | ||||
rulesopt = NULL; | rulesopt = NULL; | ||||
} | } | ||||
if (optiopt != NULL) { | if (optiopt != NULL) { | ||||
switch (*optiopt) { | switch (*optiopt) { | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |