Changeset View
Changeset View
Standalone View
Standalone View
crypto/openssh/sshconnect.c
| Show First 20 Lines • Show All 452 Lines • ▼ Show 20 Lines | ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, | ||||
| int oerrno, sock = -1, attempt; | int oerrno, sock = -1, attempt; | ||||
| char ntop[NI_MAXHOST], strport[NI_MAXSERV]; | char ntop[NI_MAXHOST], strport[NI_MAXSERV]; | ||||
| struct addrinfo *ai; | struct addrinfo *ai; | ||||
| debug3_f("entering"); | debug3_f("entering"); | ||||
| memset(ntop, 0, sizeof(ntop)); | memset(ntop, 0, sizeof(ntop)); | ||||
| memset(strport, 0, sizeof(strport)); | memset(strport, 0, sizeof(strport)); | ||||
| int inet_supported = feature_present("inet"); | |||||
| int inet6_supported = feature_present("inet6"); | |||||
| for (attempt = 0; attempt < connection_attempts; attempt++) { | for (attempt = 0; attempt < connection_attempts; attempt++) { | ||||
| if (attempt > 0) { | if (attempt > 0) { | ||||
| /* Sleep a moment before retrying. */ | /* Sleep a moment before retrying. */ | ||||
| sleep(1); | sleep(1); | ||||
| debug("Trying again..."); | debug("Trying again..."); | ||||
| } | } | ||||
| /* | /* | ||||
| * Loop through addresses for this host, and try each one in | * Loop through addresses for this host, and try each one in | ||||
| * sequence until the connection succeeds. | * sequence until the connection succeeds. | ||||
| */ | */ | ||||
| for (ai = aitop; ai; ai = ai->ai_next) { | for (ai = aitop; ai; ai = ai->ai_next) { | ||||
| if (ai->ai_family != AF_INET && | if (ai->ai_family != AF_INET && | ||||
| ai->ai_family != AF_INET6) { | ai->ai_family != AF_INET6) { | ||||
| errno = EAFNOSUPPORT; | errno = EAFNOSUPPORT; | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (getnameinfo(ai->ai_addr, ai->ai_addrlen, | if (getnameinfo(ai->ai_addr, ai->ai_addrlen, | ||||
| ntop, sizeof(ntop), strport, sizeof(strport), | ntop, sizeof(ntop), strport, sizeof(strport), | ||||
| NI_NUMERICHOST|NI_NUMERICSERV) != 0) { | NI_NUMERICHOST|NI_NUMERICSERV) != 0) { | ||||
| oerrno = errno; | oerrno = errno; | ||||
| error_f("getnameinfo failed"); | error_f("getnameinfo failed"); | ||||
| errno = oerrno; | errno = oerrno; | ||||
| continue; | |||||
| } | |||||
| if ((ai->ai_family == AF_INET && !inet_supported) || | |||||
| (ai->ai_family == AF_INET6 && !inet6_supported)) { | |||||
| debug2_f("skipping address [%s]:%s: " | |||||
| "unsupported address family", ntop, strport); | |||||
| errno = EAFNOSUPPORT; | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (options.address_family != AF_UNSPEC && | if (options.address_family != AF_UNSPEC && | ||||
| ai->ai_family != options.address_family) { | ai->ai_family != options.address_family) { | ||||
| debug2_f("skipping address [%s]:%s: " | debug2_f("skipping address [%s]:%s: " | ||||
| "wrong address family", ntop, strport); | "wrong address family", ntop, strport); | ||||
| errno = EAFNOSUPPORT; | errno = EAFNOSUPPORT; | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 1,272 Lines • Show Last 20 Lines | |||||