Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf_ioctl.c
Show First 20 Lines • Show All 1,639 Lines • ▼ Show 20 Lines | if (nvl == NULL) | ||||
return (NULL); | return (NULL); | ||||
nvlist_add_binary(nvl, "addr", paddr, sizeof(*paddr)); | nvlist_add_binary(nvl, "addr", paddr, sizeof(*paddr)); | ||||
return (nvl); | return (nvl); | ||||
} | } | ||||
static int | 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) | pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool) | ||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
bzero(kpool, sizeof(*kpool)); | bzero(kpool, sizeof(*kpool)); | ||||
PFNV_CHK(pf_nvbinary(nvl, "key", &kpool->key, sizeof(kpool->key))); | PFNV_CHK(pf_nvbinary(nvl, "key", &kpool->key, sizeof(kpool->key))); | ||||
if (nvlist_exists_nvlist(nvl, "counter")) { | if (nvlist_exists_nvlist(nvl, "counter")) { | ||||
PFNV_CHK(pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "counter"), | PFNV_CHK(pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "counter"), | ||||
&kpool->counter)); | &kpool->counter)); | ||||
} | } | ||||
PFNV_CHK(pf_nvint(nvl, "tblidx", &kpool->tblidx)); | PFNV_CHK(pf_nvint(nvl, "tblidx", &kpool->tblidx)); | ||||
PFNV_CHK(pf_nvuint16_array(nvl, "proxy_port", kpool->proxy_port, 2, | PFNV_CHK(pf_nvuint16_array(nvl, "proxy_port", kpool->proxy_port, 2, | ||||
NULL)); | NULL)); | ||||
PFNV_CHK(pf_nvuint8(nvl, "opts", &kpool->opts)); | 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: | errout: | ||||
return (error); | return (error); | ||||
} | } | ||||
static nvlist_t * | static nvlist_t * | ||||
pf_pool_to_nvpool(const struct pf_kpool *pool) | pf_pool_to_nvpool(const struct pf_kpool *pool) | ||||
{ | { | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
nvlist_t *tmp; | nvlist_t *tmp; | ||||
nvl = nvlist_create(0); | nvl = nvlist_create(0); | ||||
if (nvl == NULL) | if (nvl == NULL) | ||||
return (NULL); | return (NULL); | ||||
nvlist_add_binary(nvl, "key", &pool->key, sizeof(pool->key)); | nvlist_add_binary(nvl, "key", &pool->key, sizeof(pool->key)); | ||||
tmp = pf_addr_to_nvaddr(&pool->counter); | tmp = pf_addr_to_nvaddr(&pool->counter); | ||||
if (tmp == NULL) | if (tmp == NULL) | ||||
goto error; | goto error; | ||||
nvlist_add_nvlist(nvl, "counter", tmp); | nvlist_add_nvlist(nvl, "counter", tmp); | ||||
nvlist_add_number(nvl, "tblidx", pool->tblidx); | nvlist_add_number(nvl, "tblidx", pool->tblidx); | ||||
pf_uint16_array_nv(nvl, "proxy_port", pool->proxy_port, 2); | pf_uint16_array_nv(nvl, "proxy_port", pool->proxy_port, 2); | ||||
nvlist_add_number(nvl, "opts", pool->opts); | 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); | return (nvl); | ||||
error: | error: | ||||
nvlist_destroy(nvl); | nvlist_destroy(nvl); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,902 Lines • Show Last 20 Lines |