aboutsummaryrefslogtreecommitdiff
path: root/sys/netpfil/pf/pf_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netpfil/pf/pf_ioctl.c')
-rw-r--r--sys/netpfil/pf/pf_ioctl.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index 66726b754a97..5312e48c2f76 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -1646,6 +1646,36 @@ pf_addr_to_nvaddr(const struct pf_addr *paddr)
}
static int
+pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape)
+{
+ int error = 0;
+
+ bzero(mape, sizeof(*mape));
+ PFNV_CHK(pf_nvuint8(nvl, "offset", &mape->offset));
+ PFNV_CHK(pf_nvuint8(nvl, "psidlen", &mape->psidlen));
+ PFNV_CHK(pf_nvuint16(nvl, "psid", &mape->psid));
+
+errout:
+ return (error);
+}
+
+static nvlist_t *
+pf_mape_to_nvmape(const struct pf_mape_portset *mape)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ if (nvl == NULL)
+ return (NULL);
+
+ nvlist_add_number(nvl, "offset", mape->offset);
+ nvlist_add_number(nvl, "psidlen", mape->psidlen);
+ nvlist_add_number(nvl, "psid", mape->psid);
+
+ return (nvl);
+}
+
+static int
pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool)
{
int error = 0;
@@ -1664,6 +1694,11 @@ pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool)
NULL));
PFNV_CHK(pf_nvuint8(nvl, "opts", &kpool->opts));
+ if (nvlist_exists_nvlist(nvl, "mape")) {
+ PFNV_CHK(pf_nvmape_to_mape(nvlist_get_nvlist(nvl, "mape"),
+ &kpool->mape));
+ }
+
errout:
return (error);
}
@@ -1688,6 +1723,11 @@ pf_pool_to_nvpool(const struct pf_kpool *pool)
pf_uint16_array_nv(nvl, "proxy_port", pool->proxy_port, 2);
nvlist_add_number(nvl, "opts", pool->opts);
+ tmp = pf_mape_to_nvmape(&pool->mape);
+ if (tmp == NULL)
+ goto error;
+ nvlist_add_nvlist(nvl, "mape", tmp);
+
return (nvl);
error: