1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

nwrap: move setting of ai_{flags|socktype|protocol} into nwrap_convert_he_ai

This makes the code in nwrap_getaddrinfo() more readable
and also treats all ai stuctures in the linked list, not
just the first one!

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Michael Adam 2015-11-12 11:15:03 +01:00
parent a66606cd02
commit 062c97be19

View File

@ -5055,12 +5055,23 @@ static int nwrap_convert_he_ai(const struct hostent *he,
return EAI_MEMORY;
}
ai->ai_flags = 0;
ai->ai_flags = hints->ai_flags;
ai->ai_family = he->h_addrtype;
ai->ai_socktype = hints->ai_socktype;
ai->ai_protocol = hints->ai_protocol;
ai->ai_canonname = NULL;
if (ai->ai_socktype == 0) {
ai->ai_socktype = SOCK_DGRAM;
}
if (ai->ai_protocol == 0) {
if (ai->ai_socktype == SOCK_DGRAM) {
ai->ai_protocol = IPPROTO_UDP;
} else if (ai->ai_socktype == SOCK_STREAM) {
ai->ai_protocol = IPPROTO_TCP;
}
}
ai->ai_addrlen = socklen;
ai->ai_addr = (void *)(ai + 1);
@ -5244,18 +5255,6 @@ valid_port:
return rc;
}
if (ai->ai_flags == 0) {
ai->ai_flags = hints->ai_flags;
}
if (ai->ai_socktype == 0) {
ai->ai_socktype = SOCK_DGRAM;
}
if (ai->ai_protocol == 0 && ai->ai_socktype == SOCK_DGRAM) {
ai->ai_protocol = IPPROTO_UDP;
} else if (ai->ai_protocol == 0 && ai->ai_socktype == SOCK_STREAM) {
ai->ai_protocol = IPPROTO_TCP;
}
if (hints->ai_socktype == 0) {
/* Add second ai */
struct addrinfo *ai_head = ai;