|
|
fbcb50 |
diff --git a/commands.c b/commands.c
|
|
|
fbcb50 |
index 49619ac..636fb5c 100644
|
|
|
fbcb50 |
--- a/telnet/commands.c
|
|
|
fbcb50 |
+++ b/telnet/commands.c
|
|
|
fbcb50 |
@@ -2267,6 +2267,7 @@ tn(int argc, char *argv[])
|
|
|
fbcb50 |
char *srp = 0;
|
|
|
fbcb50 |
int srlen;
|
|
|
fbcb50 |
#endif
|
|
|
fbcb50 |
+ int family = AF_UNSPEC;
|
|
|
fbcb50 |
char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0;
|
|
|
fbcb50 |
int retry;
|
|
|
fbcb50 |
#ifdef NI_WITHSCOPEID
|
|
|
fbcb50 |
@@ -2317,6 +2318,21 @@ tn(int argc, char *argv[])
|
|
|
fbcb50 |
autologin = 1;
|
|
|
fbcb50 |
continue;
|
|
|
fbcb50 |
}
|
|
|
fbcb50 |
+
|
|
|
fbcb50 |
+ if (strcmp(*argv, "-6") == 0) {
|
|
|
fbcb50 |
+ --argc; ++argv;
|
|
|
fbcb50 |
+#ifdef AF_INET6
|
|
|
fbcb50 |
+ family = AF_INET6;
|
|
|
fbcb50 |
+#else
|
|
|
fbcb50 |
+ puts("IPv6 unsupported");
|
|
|
fbcb50 |
+#endif
|
|
|
fbcb50 |
+ continue;
|
|
|
fbcb50 |
+ }
|
|
|
fbcb50 |
+ if (strcmp(*argv, "-4") == 0) {
|
|
|
fbcb50 |
+ --argc; ++argv;
|
|
|
fbcb50 |
+ family = AF_INET;
|
|
|
fbcb50 |
+ continue;
|
|
|
fbcb50 |
+ }
|
|
|
fbcb50 |
if (hostp == 0) {
|
|
|
fbcb50 |
hostp = *argv++;
|
|
|
fbcb50 |
--argc;
|
|
|
fbcb50 |
@@ -2355,7 +2371,7 @@ tn(int argc, char *argv[])
|
|
|
fbcb50 |
{
|
|
|
fbcb50 |
hostname = hostp;
|
|
|
fbcb50 |
memset(&hints, 0, sizeof(hints));
|
|
|
fbcb50 |
- hints.ai_family = PF_UNSPEC;
|
|
|
fbcb50 |
+ hints.ai_family = family;
|
|
|
fbcb50 |
hints.ai_socktype = SOCK_STREAM;
|
|
|
fbcb50 |
hints.ai_flags = AI_CANONNAME;
|
|
|
fbcb50 |
if (portp == NULL) {
|
|
|
fbcb50 |
diff --git a/main.c b/main.c
|
|
|
fbcb50 |
index 5fa96e8..599f0af 100644
|
|
|
fbcb50 |
--- a/telnet/main.c
|
|
|
fbcb50 |
+++ b/telnet/main.c
|
|
|
fbcb50 |
@@ -80,10 +80,10 @@ usage(void)
|
|
|
fbcb50 |
fprintf(stderr, "Usage: %s %s%s%s%s\n",
|
|
|
fbcb50 |
prompt,
|
|
|
fbcb50 |
#ifdef AUTHENTICATION
|
|
|
fbcb50 |
- "[-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]",
|
|
|
fbcb50 |
+ "[-4] [-6] [-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]",
|
|
|
fbcb50 |
"\n\t[-k realm] [-l user] [-f/-F] [-n tracefile] [-b hostalias ] ",
|
|
|
fbcb50 |
#else
|
|
|
fbcb50 |
- "[-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
|
|
|
fbcb50 |
+ "[-4] [-6] [-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
|
|
|
fbcb50 |
"\n\t[-n tracefile] [-b hostalias ] ",
|
|
|
fbcb50 |
#endif
|
|
|
fbcb50 |
#if defined(TN3270) && defined(unix)
|
|
|
fbcb50 |
@@ -116,6 +116,7 @@ main(int argc, char *argv[])
|
|
|
fbcb50 |
#endif
|
|
|
fbcb50 |
int ch;
|
|
|
fbcb50 |
char *user, *alias;
|
|
|
fbcb50 |
+ int family;
|
|
|
fbcb50 |
#ifdef FORWARD
|
|
|
fbcb50 |
extern int forward_flags;
|
|
|
fbcb50 |
#endif /* FORWARD */
|
|
|
fbcb50 |
@@ -130,7 +131,6 @@ main(int argc, char *argv[])
|
|
|
fbcb50 |
prompt = argv[0];
|
|
|
fbcb50 |
|
|
|
fbcb50 |
user = alias = NULL;
|
|
|
fbcb50 |
-
|
|
|
fbcb50 |
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
|
|
|
fbcb50 |
|
|
|
fbcb50 |
/*
|
|
|
fbcb50 |
@@ -139,9 +139,19 @@ main(int argc, char *argv[])
|
|
|
fbcb50 |
* passed
|
|
|
fbcb50 |
*/
|
|
|
fbcb50 |
autologin = -1;
|
|
|
fbcb50 |
-
|
|
|
fbcb50 |
- while ((ch = getopt(argc, argv, "78DEKLS:X:ab:cde:fFk:l:n:rt:x")) != -1) {
|
|
|
fbcb50 |
+ family = 0;
|
|
|
fbcb50 |
+ while ((ch = getopt(argc, argv, "4678DEKLS:X:ab:cde:fFk:l:n:rt:x")) != -1) {
|
|
|
fbcb50 |
switch(ch) {
|
|
|
fbcb50 |
+ case '4':
|
|
|
fbcb50 |
+ family = AF_INET;
|
|
|
fbcb50 |
+ break;
|
|
|
fbcb50 |
+ case '6':
|
|
|
fbcb50 |
+#ifdef AF_INET6
|
|
|
fbcb50 |
+ family = AF_INET6;
|
|
|
fbcb50 |
+#else
|
|
|
fbcb50 |
+ fputs("IPv6 unsupported\n", stderr);
|
|
|
fbcb50 |
+#endif
|
|
|
fbcb50 |
+ break;
|
|
|
fbcb50 |
case '8':
|
|
|
fbcb50 |
binary = 3; /* send TELNET BINARY option for output and input */
|
|
|
fbcb50 |
break;
|
|
|
fbcb50 |
@@ -340,6 +350,9 @@ main(int argc, char *argv[])
|
|
|
fbcb50 |
*argp++ = "-b";
|
|
|
fbcb50 |
*argp++ = alias;
|
|
|
fbcb50 |
}
|
|
|
fbcb50 |
+ if (family) {
|
|
|
fbcb50 |
+ *argp++ = family == AF_INET ? "-4" : "-6";
|
|
|
fbcb50 |
+ }
|
|
|
fbcb50 |
*argp++ = argv[0]; /* host */
|
|
|
fbcb50 |
if (argc > 1)
|
|
|
fbcb50 |
*argp++ = argv[1]; /* port */
|
|
|
fbcb50 |
diff --git a/telnet.1 b/telnet.1
|
|
|
fbcb50 |
index 50015a6..f30e034 100644
|
|
|
fbcb50 |
--- a/telnet/telnet.1
|
|
|
fbcb50 |
+++ b/telnet/telnet.1
|
|
|
fbcb50 |
@@ -44,7 +44,7 @@
|
|
|
fbcb50 |
protocol
|
|
|
fbcb50 |
.Sh SYNOPSIS
|
|
|
fbcb50 |
.Nm telnet
|
|
|
fbcb50 |
-.Op Fl 8EFKLacdfrx
|
|
|
fbcb50 |
+.Op Fl 468EFKLacdfrx
|
|
|
fbcb50 |
.Op Fl X Ar authtype
|
|
|
fbcb50 |
.Op Fl b Ar hostalias
|
|
|
fbcb50 |
.Op Fl e Ar escapechar
|
|
|
fbcb50 |
@@ -76,6 +76,10 @@ command with those arguments.
|
|
|
fbcb50 |
.Pp
|
|
|
fbcb50 |
The options are as follows:
|
|
|
fbcb50 |
.Bl -tag -width Ds
|
|
|
fbcb50 |
+.It Fl 4
|
|
|
fbcb50 |
+Force IPv4 address resolution.
|
|
|
fbcb50 |
+.It Fl 6
|
|
|
fbcb50 |
+Force IPv6 address resolution.
|
|
|
fbcb50 |
.It Fl 7
|
|
|
fbcb50 |
Strip 8th bit on input and output. Telnet is 8-bit clean by default but doesn't send the TELNET BINARY option unless forced.
|
|
|
fbcb50 |
.It Fl 8
|