391 |
391 |
int i, count;
|
392 |
392 |
nvlist_t *nvl;
|
393 |
393 |
caddr_t key;
|
|
394 |
size_t sa_sz;
|
394 |
395 |
struct wg_allowedip *aip;
|
|
396 |
struct wg_endpoint *ep;
|
395 |
397 |
|
396 |
398 |
if ((nvl = nvlist_create(0)) == NULL)
|
397 |
399 |
return (NULL);
|
398 |
400 |
key = peer->p_remote.r_public;
|
399 |
401 |
nvlist_add_binary(nvl, "public-key", key, WG_KEY_SIZE);
|
400 |
|
nvlist_add_binary(nvl, "endpoint", &peer->p_endpoint.e_remote, sizeof(struct sockaddr));
|
|
402 |
ep = &peer->p_endpoint;
|
|
403 |
if (ep->e_remote.r_sa.sa_family != 0) {
|
|
404 |
sa_sz = (ep->e_remote.r_sa.sa_family == AF_INET) ?
|
|
405 |
sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
|
|
406 |
nvlist_add_binary(nvl, "endpoint", &ep->e_remote, sa_sz);
|
|
407 |
}
|
401 |
408 |
i = count = 0;
|
402 |
409 |
CK_LIST_FOREACH(rt, &peer->p_routes, r_entry) {
|
403 |
410 |
count++;
|
... | ... | |
592 |
599 |
}
|
593 |
600 |
if (nvlist_exists_binary(nvl, "endpoint")) {
|
594 |
601 |
endpoint = nvlist_get_binary(nvl, "endpoint", &size);
|
595 |
|
if (size != sizeof(*endpoint)) {
|
|
602 |
if (size > sizeof(peer->p_endpoint.e_remote)) {
|
596 |
603 |
device_printf(dev, "%s bad length for endpoint %zu\n", __func__, size);
|
597 |
604 |
err = EBADMSG;
|
598 |
605 |
goto out;
|
599 |
606 |
}
|
600 |
|
memcpy(&peer->p_endpoint.e_remote, endpoint,
|
601 |
|
sizeof(peer->p_endpoint.e_remote));
|
|
607 |
memcpy(&peer->p_endpoint.e_remote, endpoint, size);
|
602 |
608 |
}
|
603 |
609 |
if (nvlist_exists_binary(nvl, "pre-shared-key")) {
|
604 |
610 |
const void *key;
|