aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/netpfil/pf/pf_nv.c14
-rw-r--r--sys/netpfil/pf/pf_nv.h1
2 files changed, 13 insertions, 2 deletions
diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c
index 73f0c55a7a21..933603066e21 100644
--- a/sys/netpfil/pf/pf_nv.c
+++ b/sys/netpfil/pf/pf_nv.c
@@ -100,6 +100,17 @@ __FBSDID("$FreeBSD$");
}
int
+pf_nvbool(const nvlist_t *nvl, const char *name, bool *val)
+{
+ if (! nvlist_exists_bool(nvl, name))
+ return (EINVAL);
+
+ *val = nvlist_get_bool(nvl, name);
+
+ return (0);
+}
+
+int
pf_nvbinary(const nvlist_t *nvl, const char *name, void *data,
size_t expected_size)
{
@@ -844,8 +855,7 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl,
sizeof(kill->psk_ifname)));
PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label,
sizeof(kill->psk_label)));
- if (nvlist_exists_bool(nvl, "kill_match"))
- kill->psk_kill_match = nvlist_get_bool(nvl, "kill_match");
+ PFNV_CHK(pf_nvbool(nvl, "kill_match", &kill->psk_kill_match));
errout:
return (error);
diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h
index 8a46aae326a6..cb6e75cb7008 100644
--- a/sys/netpfil/pf/pf_nv.h
+++ b/sys/netpfil/pf/pf_nv.h
@@ -69,6 +69,7 @@ PF_NV_DEF_UINT(uint16, uint16_t, UINT16_MAX);
PF_NV_DEF_UINT(uint32, uint32_t, UINT32_MAX);
PF_NV_DEF_UINT(uint64, uint64_t, UINT64_MAX);
+int pf_nvbool(const nvlist_t *, const char *, bool *);
int pf_nvbinary(const nvlist_t *, const char *, void *, size_t);
int pf_nvint(const nvlist_t *, const char *, int *);
int pf_nvstring(const nvlist_t *, const char *, char *, size_t);