Changeset View
Changeset View
Standalone View
Standalone View
sbin/pfctl/pfctl.c
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
int pfctl_id_kill_states(int, const char *, int); | int pfctl_id_kill_states(int, const char *, int); | ||||
void pfctl_init_options(struct pfctl *); | void pfctl_init_options(struct pfctl *); | ||||
int pfctl_load_options(struct pfctl *); | int pfctl_load_options(struct pfctl *); | ||||
int pfctl_load_limit(struct pfctl *, unsigned int, unsigned int); | int pfctl_load_limit(struct pfctl *, unsigned int, unsigned int); | ||||
int pfctl_load_timeout(struct pfctl *, unsigned int, unsigned int); | int pfctl_load_timeout(struct pfctl *, unsigned int, unsigned int); | ||||
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_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_rule_counters(struct pfctl_rule *, int); | void pfctl_print_rule_counters(struct pfctl_rule *, int); | ||||
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); | ||||
▲ Show 20 Lines • Show All 1,198 Lines • ▼ Show 20 Lines | pfctl_show_states(int dev, const char *iface, int opts) | ||||
pfctl_free_states(&states); | pfctl_free_states(&states); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
pfctl_show_status(int dev, int opts) | pfctl_show_status(int dev, int opts) | ||||
{ | { | ||||
struct pf_status status; | struct pf_status status; | ||||
struct pfctl_syncookies cookies; | |||||
if (ioctl(dev, DIOCGETSTATUS, &status)) { | if (ioctl(dev, DIOCGETSTATUS, &status)) { | ||||
warn("DIOCGETSTATUS"); | warn("DIOCGETSTATUS"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (pfctl_get_syncookies(dev, &cookies)) { | |||||
warn("DIOCGETSYNCOOKIES"); | |||||
return (-1); | |||||
} | |||||
if (opts & PF_OPT_SHOWALL) | if (opts & PF_OPT_SHOWALL) | ||||
pfctl_print_title("INFO:"); | pfctl_print_title("INFO:"); | ||||
print_status(&status, opts); | print_status(&status, &cookies, opts); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
pfctl_show_running(int dev) | pfctl_show_running(int dev) | ||||
{ | { | ||||
struct pf_status status; | struct pf_status status; | ||||
▲ Show 20 Lines • Show All 529 Lines • ▼ Show 20 Lines | pfctl_load_options(struct pfctl *pf) | ||||
if (!(pf->opts & PF_OPT_MERGE) || pf->hostid_set) | if (!(pf->opts & PF_OPT_MERGE) || pf->hostid_set) | ||||
if (pfctl_load_hostid(pf, pf->hostid)) | if (pfctl_load_hostid(pf, pf->hostid)) | ||||
error = 1; | error = 1; | ||||
/* load keepcounters */ | /* load keepcounters */ | ||||
if (pfctl_set_keepcounters(pf->dev, pf->keep_counters)) | if (pfctl_set_keepcounters(pf->dev, pf->keep_counters)) | ||||
error = 1; | error = 1; | ||||
/* load syncookies settings */ | |||||
if (pfctl_load_syncookies(pf, pf->syncookies)) | |||||
error = 1; | |||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
pfctl_set_limit(struct pfctl *pf, const char *opt, unsigned int limit) | pfctl_set_limit(struct pfctl *pf, const char *opt, unsigned int limit) | ||||
{ | { | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | pfctl_set_hostid(struct pfctl *pf, u_int32_t hostid) | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
pfctl_load_hostid(struct pfctl *pf, u_int32_t hostid) | pfctl_load_hostid(struct pfctl *pf, u_int32_t hostid) | ||||
{ | { | ||||
if (ioctl(dev, DIOCSETHOSTID, &hostid)) { | if (ioctl(dev, DIOCSETHOSTID, &hostid)) { | ||||
warnx("DIOCSETHOSTID"); | warnx("DIOCSETHOSTID"); | ||||
return (1); | |||||
} | |||||
return (0); | |||||
} | |||||
int | |||||
pfctl_load_syncookies(struct pfctl *pf, u_int8_t val) | |||||
{ | |||||
struct pfctl_syncookies cookies; | |||||
bzero(&cookies, sizeof(cookies)); | |||||
cookies.mode = val ? PFCTL_SYNCOOKIES_ALWAYS : PFCTL_SYNCOOKIES_NEVER; | |||||
if (pfctl_set_syncookies(dev, &cookies)) { | |||||
warnx("DIOCSETSYNCOOKIES"); | |||||
return (1); | return (1); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
pfctl_set_debug(struct pfctl *pf, char *d) | pfctl_set_debug(struct pfctl *pf, char *d) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 582 Lines • Show Last 20 Lines |