Changeset View
Changeset View
Standalone View
Standalone View
lib/libcasper/services/cap_dns/cap_dns.c
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | fail: | ||||
h_errno = NO_RECOVERY; | h_errno = NO_RECOVERY; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
struct hostent * | struct hostent * | ||||
cap_gethostbyname(cap_channel_t *chan, const char *name) | cap_gethostbyname(cap_channel_t *chan, const char *name) | ||||
{ | { | ||||
if (!cap_enable(chan)) | |||||
return (gethostbyname(name)); | |||||
return (cap_gethostbyname2(chan, name, AF_INET)); | return (cap_gethostbyname2(chan, name, AF_INET)); | ||||
} | } | ||||
struct hostent * | struct hostent * | ||||
cap_gethostbyname2(cap_channel_t *chan, const char *name, int type) | cap_gethostbyname2(cap_channel_t *chan, const char *name, int type) | ||||
{ | { | ||||
struct hostent *hp; | struct hostent *hp; | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
if (!cap_enable(chan)) | |||||
return (gethostbyname2(name, type)); | |||||
nvl = nvlist_create(0); | nvl = nvlist_create(0); | ||||
nvlist_add_string(nvl, "cmd", "gethostbyname"); | nvlist_add_string(nvl, "cmd", "gethostbyname"); | ||||
nvlist_add_number(nvl, "family", (uint64_t)type); | nvlist_add_number(nvl, "family", (uint64_t)type); | ||||
nvlist_add_string(nvl, "name", name); | nvlist_add_string(nvl, "name", name); | ||||
nvl = cap_xfer_nvlist(chan, nvl, 0); | nvl = cap_xfer_nvlist(chan, nvl, 0); | ||||
if (nvl == NULL) { | if (nvl == NULL) { | ||||
h_errno = NO_RECOVERY; | h_errno = NO_RECOVERY; | ||||
return (NULL); | return (NULL); | ||||
Show All 11 Lines | |||||
struct hostent * | struct hostent * | ||||
cap_gethostbyaddr(cap_channel_t *chan, const void *addr, socklen_t len, | cap_gethostbyaddr(cap_channel_t *chan, const void *addr, socklen_t len, | ||||
int type) | int type) | ||||
{ | { | ||||
struct hostent *hp; | struct hostent *hp; | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
if (!cap_enable(chan)) | |||||
return (gethostbyaddr(addr, len, type)); | |||||
nvl = nvlist_create(0); | nvl = nvlist_create(0); | ||||
nvlist_add_string(nvl, "cmd", "gethostbyaddr"); | nvlist_add_string(nvl, "cmd", "gethostbyaddr"); | ||||
nvlist_add_binary(nvl, "addr", addr, (size_t)len); | nvlist_add_binary(nvl, "addr", addr, (size_t)len); | ||||
nvlist_add_number(nvl, "family", (uint64_t)type); | nvlist_add_number(nvl, "family", (uint64_t)type); | ||||
nvl = cap_xfer_nvlist(chan, nvl, 0); | nvl = cap_xfer_nvlist(chan, nvl, 0); | ||||
if (nvl == NULL) { | if (nvl == NULL) { | ||||
h_errno = NO_RECOVERY; | h_errno = NO_RECOVERY; | ||||
return (NULL); | return (NULL); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct addrinfo *firstai, *prevai, *curai; | struct addrinfo *firstai, *prevai, *curai; | ||||
unsigned int ii; | unsigned int ii; | ||||
const nvlist_t *nvlai; | const nvlist_t *nvlai; | ||||
char nvlname[64]; | char nvlname[64]; | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
int error, n; | int error, n; | ||||
if (!cap_enable(chan)) | |||||
return (getaddrinfo(hostname, servname, hints, res)); | |||||
nvl = nvlist_create(0); | nvl = nvlist_create(0); | ||||
nvlist_add_string(nvl, "cmd", "getaddrinfo"); | nvlist_add_string(nvl, "cmd", "getaddrinfo"); | ||||
if (hostname != NULL) | if (hostname != NULL) | ||||
nvlist_add_string(nvl, "hostname", hostname); | nvlist_add_string(nvl, "hostname", hostname); | ||||
if (servname != NULL) | if (servname != NULL) | ||||
nvlist_add_string(nvl, "servname", servname); | nvlist_add_string(nvl, "servname", servname); | ||||
if (hints != NULL) { | if (hints != NULL) { | ||||
nvlist_add_number(nvl, "hints.ai_flags", | nvlist_add_number(nvl, "hints.ai_flags", | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
int | int | ||||
cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen, | cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen, | ||||
char *host, size_t hostlen, char *serv, size_t servlen, int flags) | char *host, size_t hostlen, char *serv, size_t servlen, int flags) | ||||
{ | { | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
int error; | int error; | ||||
if (!cap_enable(chan)) { | |||||
return (getnameinfo(sa, salen, host, hostlen, serv, servlen, | |||||
flags)); | |||||
} | |||||
nvl = nvlist_create(0); | nvl = nvlist_create(0); | ||||
nvlist_add_string(nvl, "cmd", "getnameinfo"); | nvlist_add_string(nvl, "cmd", "getnameinfo"); | ||||
nvlist_add_number(nvl, "hostlen", (uint64_t)hostlen); | nvlist_add_number(nvl, "hostlen", (uint64_t)hostlen); | ||||
nvlist_add_number(nvl, "servlen", (uint64_t)servlen); | nvlist_add_number(nvl, "servlen", (uint64_t)servlen); | ||||
nvlist_add_binary(nvl, "sa", sa, (size_t)salen); | nvlist_add_binary(nvl, "sa", sa, (size_t)salen); | ||||
nvlist_add_number(nvl, "flags", (uint64_t)flags); | nvlist_add_number(nvl, "flags", (uint64_t)flags); | ||||
nvl = cap_xfer_nvlist(chan, nvl, 0); | nvl = cap_xfer_nvlist(chan, nvl, 0); | ||||
▲ Show 20 Lines • Show All 469 Lines • Show Last 20 Lines |