From 4d473766d13416ed86508d2cef5b341debe4b8e6 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 23 May 1998 12:15:21 +0000 Subject: fix multi-address host connects; cstone@pobox.com print new address as it is tried; deraadt --- usr.bin/telnet/commands.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 112dc0f84fb..3ea2882bf07 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.15 1998/05/15 03:16:35 art Exp $ */ +/* $OpenBSD: commands.c,v 1.16 1998/05/23 12:15:20 deraadt Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -2561,8 +2561,11 @@ tn(argc, argv) } if (connect(net, sa, sa_size) < 0) { + int retry = 0; + if (host && host->h_addr_list[1]) { int oerrno = errno; + retry = 1; switch(family) { case AF_INET : @@ -2573,7 +2576,7 @@ tn(argc, argv) #if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6) case AF_INET6: { char buf[INET6_ADDRSTRLEN]; - + fprintf(stderr, "telnet: connect to address %s: ", inet_ntop(AF_INET6, &sin6.sin6_addr, buf, sizeof(buf))); @@ -2587,9 +2590,22 @@ tn(argc, argv) errno = oerrno; perror(NULL); - host->h_addr_list++; - memmove((caddr_t)&sin.sin_addr, - host->h_addr_list[0], host->h_length); + + switch(family) { + case AF_INET : + printf("Trying %s...\r\n", inet_ntoa(sin.sin_addr)); + break; +#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6) + case AF_INET6: { + printf("Trying %s...\r\n", inet_ntop(AF_INET6, + &sin6.sin6_addr, + buf, + sizeof(buf))); + break; + } +#endif + } + (void) NetClose(net); continue; } -- cgit v1.2.3