diff options
-rw-r--r-- | usr.bin/ftp/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/ftp/fetch.c | 6 | ||||
-rw-r--r-- | usr.bin/ftp/ftp.1 | 12 | ||||
-rw-r--r-- | usr.bin/ftp/ftp.c | 6 | ||||
-rw-r--r-- | usr.bin/ftp/main.c | 14 |
5 files changed, 29 insertions, 12 deletions
diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h index f5b7cc43b94..02602055249 100644 --- a/usr.bin/ftp/extern.h +++ b/usr.bin/ftp/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.22 2002/02/17 19:42:30 millert Exp $ */ +/* $OpenBSD: extern.h,v 1.23 2002/05/30 06:51:46 deraadt Exp $ */ /* $NetBSD: extern.h,v 1.17 1997/08/18 10:20:19 lukem Exp $ */ /* @@ -202,6 +202,7 @@ extern FILE *cout; extern int data; extern char *home; extern jmp_buf jabort; +extern int family; extern int proxy; extern char reply_string[]; extern off_t restart_point; diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index e78b107543b..ad03aa0e807 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.38 2002/02/16 21:27:46 millert Exp $ */ +/* $OpenBSD: fetch.c,v 1.39 2002/05/30 06:51:46 deraadt Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fetch.c,v 1.38 2002/02/16 21:27:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: fetch.c,v 1.39 2002/05/30 06:51:46 deraadt Exp $"; #endif /* not lint */ /* @@ -285,7 +285,7 @@ url_get(origline, proxyenv, outfile) host, portnum, path, savefile); memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; port = portnum ? portnum : httpport; error = getaddrinfo(host, port, &hints, &res0); diff --git a/usr.bin/ftp/ftp.1 b/usr.bin/ftp/ftp.1 index ad8c0db18bb..167944fd3c2 100644 --- a/usr.bin/ftp/ftp.1 +++ b/usr.bin/ftp/ftp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ftp.1,v 1.34 2001/08/22 17:26:34 beck Exp $ +.\" $OpenBSD: ftp.1,v 1.35 2002/05/30 06:51:46 deraadt Exp $ .\" $NetBSD: ftp.1,v 1.22 1997/08/18 10:20:22 lukem Exp $ .\" .\" Copyright (c) 1985, 1989, 1990, 1993 @@ -44,7 +44,7 @@ file transfer program .Sh SYNOPSIS .Nm ftp -.Op Fl AVadegimnptv +.Op Fl AVadegimnptv46 .Op Fl o Ar output .Op Fl P Ar port .Op Fl r Ar seconds @@ -152,6 +152,14 @@ as report on data transfer statistics. .It Fl V Disable verbose mode, overriding the default of enabled when input is from a terminal. +.It Fl 4 +Forces +.Nm +to use IPv4 addresses only. +.It Fl 6 +Forces +.Nm +to use IPv6 addresses only. .El .Pp The client host with which diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 24990c955aa..ccbef5a8278 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp.c,v 1.44 2002/04/25 10:58:05 itojun Exp $ */ +/* $OpenBSD: ftp.c,v 1.45 2002/05/30 06:51:46 deraadt Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* @@ -67,7 +67,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: ftp.c,v 1.44 2002/04/25 10:58:05 itojun Exp $"; +static char rcsid[] = "$OpenBSD: ftp.c,v 1.45 2002/05/30 06:51:46 deraadt Exp $"; #endif #endif /* not lint */ @@ -139,7 +139,7 @@ hookup(host, port) memset((char *)&hisctladdr, 0, sizeof (hisctladdr)); memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; error = getaddrinfo(host, port, &hints, &res0); diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index 2bb149ce1f0..e36aca7010d 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.48 2001/06/23 22:48:45 millert Exp $ */ +/* $OpenBSD: main.c,v 1.49 2002/05/30 06:51:46 deraadt Exp $ */ /* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ /* @@ -73,7 +73,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.48 2001/06/23 22:48:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.49 2002/05/30 06:51:46 deraadt Exp $"; #endif #endif /* not lint */ @@ -95,6 +95,8 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.48 2001/06/23 22:48:45 millert Exp $ #include "ftp_var.h" +int family = PF_UNSPEC; + int main(argc, argv) volatile int argc; @@ -180,8 +182,14 @@ main(argc, argv) if (isatty(fileno(ttyout)) && !dumb_terminal && foregroundproc()) progress = 1; /* progress bar on if tty is usable */ - while ((ch = getopt(argc, argv, "Aadegimno:pP:r:tvV")) != -1) { + while ((ch = getopt(argc, argv, "46Aadegimno:pP:r:tvV")) != -1) { switch (ch) { + case '4': + family = PF_INET; + break; + case '6': + family = PF_INET6; + break; case 'A': activefallback = 0; passivemode = 0; |