aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorHajimu UMEMOTO <ume@FreeBSD.org>2000-05-22 17:18:38 +0000
committerHajimu UMEMOTO <ume@FreeBSD.org>2000-05-22 17:18:38 +0000
commit07da07565e2c3f8f7f443e0f7b0cfccdce2bf02c (patch)
treeb5da2574e3adaa99abe53db160a53b16d26ffc75 /usr.bin/ftp
parentd4af7a50dcfa42f11a65e43f78481f064310a566 (diff)
downloadsrc-07da07565e2c3f8f7f443e0f7b0cfccdce2bf02c.tar.gz
src-07da07565e2c3f8f7f443e0f7b0cfccdce2bf02c.zip
Replace isurl() with isipv6addr().
Reported by: Koji Kondo <koji@jp.above.net> Obtained from: NetBSD
Notes
Notes: svn path=/head/; revision=60805
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/extern.h1
-rw-r--r--usr.bin/ftp/main.c2
-rw-r--r--usr.bin/ftp/util.c30
3 files changed, 32 insertions, 1 deletions
diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h
index 278be80b1bef..d935d9e86fa4 100644
--- a/usr.bin/ftp/extern.h
+++ b/usr.bin/ftp/extern.h
@@ -77,6 +77,7 @@ char *hookup __P((const char *, char *));
void idle __P((int, char **));
int initconn __P((void));
void intr __P((void));
+int isipv6addr __P((const char *));
void list_vertical __P((StringList *));
void lcd __P((int, char **));
int login __P((const char *, char *, char *));
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index 446087898d0e..eb98a97279d8 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -273,7 +273,7 @@ main(argc, argv)
#endif
if (argc > 0) {
- if (isurl(argv[0])) {
+ if (strchr(argv[0], ':') != NULL && ! isipv6addr(argv[0])) {
anonftp = 1; /* Handle "automatic" transfers. */
rval = auto_fetch(argc, argv);
if (rval >= 0) /* -1 == connected and cd-ed */
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 4aa315ccfc43..0cb2e59ad02b 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -58,6 +58,9 @@ __RCSID_SOURCE("$NetBSD: util.c,v 1.16.2.1 1997/11/18 01:02:33 mellon Exp $");
#include <string.h>
#include <time.h>
#include <unistd.h>
+#ifdef INET6
+#include <netdb.h>
+#endif
#include "ftp_var.h"
#include "pathnames.h"
@@ -846,3 +849,30 @@ controlediting()
}
}
#endif /* !SMALL */
+
+/*
+ * Determine if given string is an IPv6 address or not.
+ * Return 1 for yes, 0 for no
+ */
+int
+isipv6addr(const char *addr)
+{
+ int rv = 0;
+#ifdef INET6
+ struct addrinfo hints, *res;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_INET6;
+ hints.ai_socktype = SOCK_DGRAM; /*dummy*/
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo(addr, "0", &hints, &res) != 0)
+ rv = 0;
+ else {
+ rv = 1;
+ freeaddrinfo(res);
+ }
+ if (debug)
+ printf("isipv6addr: got %d for %sn", rv, addr);
+#endif
+ return (rv == 1) ? 1 : 0;
+}