summaryrefslogtreecommitdiffstats
path: root/usr.bin/ftp/main.c
diff options
context:
space:
mode:
authorshin <shin@FreeBSD.org>2000-02-15 15:11:40 +0000
committershin <shin@FreeBSD.org>2000-02-15 15:11:40 +0000
commitc83f0a97bdc03cca93e16e1bc2758c713aef5fdf (patch)
tree04189aeeb90e88a6a240f49392fa61d89316107a /usr.bin/ftp/main.c
parent6768336e3b66310544efe8dbe769fdda673c93f8 (diff)
downloadFreeBSD-src-c83f0a97bdc03cca93e16e1bc2758c713aef5fdf.zip
FreeBSD-src-c83f0a97bdc03cca93e16e1bc2758c713aef5fdf.tar.gz
Add -4 and -6 options.
Current getaddrinfo() implemetation has a problem of too much resolving waiting time on INET6 enabled systems. -4 and -6 options can limit name resolving address family and is a possible workaround for the problem. Approved by: jkh
Diffstat (limited to 'usr.bin/ftp/main.c')
-rw-r--r--usr.bin/ftp/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index 48bf77e..4460878 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -70,6 +70,8 @@ __RCSID_SOURCE("$NetBSD: main.c,v 1.26 1997/10/14 16:31:22 christos Exp $");
#include "ftp_var.h"
#include "pathnames.h"
+int family = AF_UNSPEC;
+
int main __P((int, char **));
int
@@ -151,8 +153,16 @@ main(argc, argv)
if (isatty(fileno(stdout)) && !dumbterm)
progress = 1; /* progress bar on if tty is usable */
- while ((ch = getopt(argc, argv, "adeginpP:s:tUvV")) != -1) {
+ while ((ch = getopt(argc, argv, "46adeginpP:s:tUvV")) != -1) {
switch (ch) {
+ case '4':
+ family = AF_INET;
+ break;
+#ifdef INET6
+ case '6':
+ family = AF_INET6;
+ break;
+#endif
case 'a':
anonftp = 1;
break;
@@ -228,7 +238,7 @@ main(argc, argv)
int error;
memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
+ hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(src_addr, NULL, &hints, &res);
if (error) {
@@ -697,7 +707,7 @@ void
usage()
{
(void)fprintf(stderr,
- "usage: %s [-adeginptUvV] [-P port] [-s src_addr] [host [port]]\n"
+ "usage: %s [-46adeginptUvV] [-P port] [-s src_addr] [host [port]]\n"
" %s host:path[/]\n"
" %s ftp://host[:port]/path[/]\n"
" %s http://host[:port]/file\n",
OpenPOWER on IntegriCloud