afd
int afd = -1; /* accept socket */
if (!TEST_int_ge(afd = BIO_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, 0), 0)
|| !TEST_true(BIO_listen(afd, baddr, server_flags)))
if (!TEST_int_ge(getsockname(afd, (struct sockaddr *)&sstorage, &slen), 0))
sfd = BIO_accept_ex(afd, NULL, 0);
if (!TEST_int_ge(BIO_socket_wait(afd, 1, time(NULL) + 2), 0)) {
sfd = BIO_accept_ex(afd, NULL, 0);
if (!TEST_int_ge(BIO_socket_wait(afd, 1, time(NULL) + 2), 0)) {
sfd = BIO_accept_ex(afd, NULL, 0);
BIO_closesocket(afd);
int afd = -1, cfd = -1, sfd = -1;
afd = BIO_socket(AF_INET, socktype,
if (afd == INVALID_SOCKET)
if (bind(afd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
if (getsockname(afd, (struct sockaddr *)&sin, &slen) < 0)
if (socktype == SOCK_STREAM && listen(afd, 1) < 0)
if (!BIO_socket_nbio(afd, 1))
sfd = afd;
afd = -1;
sfd = accept(afd, NULL, 0);
if (afd != -1)
close(afd);
const struct afd *afd;
afd = find_afd(pai->ai_family);
if (afd == NULL)
GET_AI(ai, afd, afd->a_addrany);
GET_AI(ai, afd, afd->a_loopback);
const struct afd *afd;
afd = find_afd(pai->ai_family);
if (afd == NULL)
switch (afd->a_af) {
if (strlen(hostname) > afd->a_addrlen)
strncpy(path, hostname, afd->a_addrlen);
if (inet_pton(afd->a_af, hostname, pton) != 1) {
afd = &afdl[N_INET];
if (pai->ai_family == afd->a_af) {
GET_AI(ai, afd, p);
const struct afd *afd;
afd = find_afd(pai->ai_family);
if (afd == NULL)
if (!afd->a_scoped)
get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr)
if (afd->a_af == AF_INET && (pai->ai_flags & AI_V4MAPPED) != 0) {
afd = &afdl[N_INET6];
+ (afd->a_socklen));
memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
ai->ai_addr->sa_len = afd->a_socklen;
ai->ai_addrlen = afd->a_socklen;
size_t n = strnlen(addr, afd->a_addrlen);
ai->ai_addrlen -= afd->a_addrlen - n;
ai->ai_addr->sa_len -= afd->a_addrlen - n;
ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
static const struct afd *
const struct afd *afd;
for (afd = afdl; afd->a_af; afd++) {
if (afd->a_af == af)
return afd;
const struct afd *afd;
afd = find_afd(ai.ai_family);
if (afd == NULL) {
cur->ai_next = get_ai(&ai, afd, (const char *)cp);
const struct afd *, const char *);
static const struct afd *find_afd(int);
#define GET_AI(ai, afd, addr) \
(ai) = get_ai(pai, (afd), (addr)); \
const struct afd *afd;
for (afd = afdl; afd->a_af; afd++) {
if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1))
pai->ai_family = afd->a_af;
&afailist[afd - afdl]);
&afailist[afd - afdl]);
if (!error && afailist[afd - afdl])
if ((afd = find_afd(pai->ai_family)) == NULL)
afai = afailist[afd - afdl];
for (afd = afdl; afd->a_af; afd++) {
if (afailist[afd - afdl])
freeaddrinfo(afailist[afd - afdl]);
const struct afd *afd;
afd = find_afd(sa->sa_family);
if (afd == NULL)
if (salen <= afd->a_socklen -
else if (salen > afd->a_socklen)
salen = afd->a_socklen;
if (salen <= afd->a_socklen -
if (salen < afd->a_socklen)
salen = afd->a_socklen;
return ((*afd->a_func)(afd, sa, salen, host, hostlen,
static const struct afd *
const struct afd *afd;
for (afd = &afdl[0]; afd->a_af > 0; afd++) {
if (afd->a_af == af)
return (afd);
getnameinfo_inet(const struct afd *afd,
addr = (const char *)sa + afd->a_off;
switch(afd->a_af) {
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
switch(afd->a_af) {
if (inet_ntop(afd->a_af, addr, host,
getnameinfo_link(const struct afd *afd,
getnameinfo_un(const struct afd *afd,
pathlen = salen - afd->a_off;
strlcpy(host, (const char *)sa + afd->a_off, pathlen + 1);
static const struct afd *find_afd(int);
static int getnameinfo_inet(const struct afd *,
static int getnameinfo_link(const struct afd *,
static int getnameinfo_un(const struct afd *,
int (*a_func)(const struct afd *,
int afd = -1;
if ((afd = openat(fd, "xattr", O_CREAT | O_RDWR | O_XATTR, 0777)) < 0) {
if (write(afd, pbuf, 1024) < 1024) {
(void) close(afd);