Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf_nv.c
Show First 20 Lines • Show All 1,058 Lines • ▼ Show 20 Lines | pf_keth_rule_to_nvl(const struct pf_keth_rule *krule) | ||||
nvlist_add_number(nvl, "bytes-in", | nvlist_add_number(nvl, "bytes-in", | ||||
counter_u64_fetch(krule->bytes[0])); | counter_u64_fetch(krule->bytes[0])); | ||||
nvlist_add_number(nvl, "bytes-out", | nvlist_add_number(nvl, "bytes-out", | ||||
counter_u64_fetch(krule->bytes[1])); | counter_u64_fetch(krule->bytes[1])); | ||||
nvlist_add_string(nvl, "qname", krule->qname); | nvlist_add_string(nvl, "qname", krule->qname); | ||||
nvlist_add_string(nvl, "tagname", krule->tagname); | nvlist_add_string(nvl, "tagname", krule->tagname); | ||||
nvlist_add_number(nvl, "dnpipe", krule->dnpipe); | |||||
nvlist_add_number(nvl, "dnflags", krule->dnflags); | |||||
nvlist_add_number(nvl, "action", krule->action); | nvlist_add_number(nvl, "action", krule->action); | ||||
return (nvl); | return (nvl); | ||||
} | } | ||||
int | int | ||||
pf_nvl_to_keth_rule(const nvlist_t *nvl, | pf_nvl_to_keth_rule(const nvlist_t *nvl, | ||||
struct pf_keth_rule *krule) | struct pf_keth_rule *krule) | ||||
{ | { | ||||
int error; | int error = 0; | ||||
bzero(krule, sizeof(*krule)); | bzero(krule, sizeof(*krule)); | ||||
if (! nvlist_exists_number(nvl, "nr")) | if (! nvlist_exists_number(nvl, "nr")) | ||||
return (EBADMSG); | return (EBADMSG); | ||||
krule->nr = nvlist_get_number(nvl, "nr"); | krule->nr = nvlist_get_number(nvl, "nr"); | ||||
if (nvlist_exists_bool(nvl, "quick")) | if (nvlist_exists_bool(nvl, "quick")) | ||||
Show All 28 Lines | pf_nvl_to_keth_rule(const nvlist_t *nvl, | ||||
if (nvlist_exists(nvl, "qname")) | if (nvlist_exists(nvl, "qname")) | ||||
strlcpy(krule->qname, nvlist_get_string(nvl, "qname"), | strlcpy(krule->qname, nvlist_get_string(nvl, "qname"), | ||||
PF_QNAME_SIZE); | PF_QNAME_SIZE); | ||||
if (nvlist_exists_string(nvl, "tagname")) | if (nvlist_exists_string(nvl, "tagname")) | ||||
strlcpy(krule->tagname, nvlist_get_string(nvl, "tagname"), | strlcpy(krule->tagname, nvlist_get_string(nvl, "tagname"), | ||||
PF_TAG_NAME_SIZE); | PF_TAG_NAME_SIZE); | ||||
PFNV_CHK(pf_nvuint16_opt(nvl, "dnpipe", &krule->dnpipe, 0)); | |||||
PFNV_CHK(pf_nvuint32_opt(nvl, "dnflags", &krule->dnflags, 0)); | |||||
if (! nvlist_exists_number(nvl, "action")) | if (! nvlist_exists_number(nvl, "action")) | ||||
return (EBADMSG); | return (EBADMSG); | ||||
krule->action = nvlist_get_number(nvl, "action"); | krule->action = nvlist_get_number(nvl, "action"); | ||||
return (0); | errout: | ||||
return (error); | |||||
} | } |