Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp add dual-stack (IPv4/v6) support. hope I broke ...
details: https://anonhg.NetBSD.org/src/rev/b1f0b859347e
branches: trunk
changeset: 474251:b1f0b859347e
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Jul 02 08:07:40 1999 +0000
description:
add dual-stack (IPv4/v6) support. hope I broke no other part...
diffstat:
usr.bin/ftp/Makefile | 4 +-
usr.bin/ftp/cmds.c | 49 +++++-
usr.bin/ftp/cmdtab.c | 6 +-
usr.bin/ftp/extern.h | 34 ++++-
usr.bin/ftp/fetch.c | 129 +++++++++++++---
usr.bin/ftp/ftp.1 | 12 +-
usr.bin/ftp/ftp.c | 397 ++++++++++++++++++++++++++++++++++++-------------
usr.bin/ftp/ftp_var.h | 41 ++++-
usr.bin/ftp/main.c | 76 +++++----
usr.bin/ftp/util.c | 11 +-
10 files changed, 570 insertions(+), 189 deletions(-)
diffs (truncated from 1349 to 300 lines):
diff -r 7b6850f83a2e -r b1f0b859347e usr.bin/ftp/Makefile
--- a/usr.bin/ftp/Makefile Fri Jul 02 07:59:56 1999 +0000
+++ b/usr.bin/ftp/Makefile Fri Jul 02 08:07:40 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.19 1999/04/16 23:01:55 lukem Exp $
+# $NetBSD: Makefile,v 1.20 1999/07/02 08:07:40 itojun Exp $
# from: @(#)Makefile 8.2 (Berkeley) 4/3/94
PROG= ftp
@@ -13,4 +13,6 @@
LDADD+= -ledit -ltermcap -lutil
DPADD+= ${LIBEDIT} ${LIBTERMCAP} ${LIBUTIL}
+CPPFLAGS+= -DINET6
+
.include <bsd.prog.mk>
diff -r 7b6850f83a2e -r b1f0b859347e usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c Fri Jul 02 07:59:56 1999 +0000
+++ b/usr.bin/ftp/cmds.c Fri Jul 02 08:07:40 1999 +0000
@@ -1,4 +1,33 @@
-/* $NetBSD: cmds.c,v 1.53 1999/06/29 12:41:22 lukem Exp $ */
+/* $NetBSD: cmds.c,v 1.54 1999/07/02 08:07:40 itojun Exp $ */
+
+/*
+ * Copyright (C) 1997 and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -78,7 +107,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmds.c,v 1.53 1999/06/29 12:41:22 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.54 1999/07/02 08:07:40 itojun Exp $");
#endif
#endif /* not lint */
@@ -700,8 +729,8 @@
}
pswitch(0);
}
- fprintf(ttyout, "Gate ftp: %s, server %s, port %d.\n", onoff(gatemode),
- *gateserver ? gateserver : "(none)", ntohs(gateport));
+ fprintf(ttyout, "Gate ftp: %s, server %s, port %s.\n", onoff(gatemode),
+ *gateserver ? gateserver : "(none)", gateport);
fprintf(ttyout, "Passive mode: %s.\n", onoff(passivemode));
fprintf(ttyout, "Mode: %s; Type: %s; Form: %s; Structure: %s.\n",
modename, typename, formname, structname);
@@ -869,7 +898,7 @@
}
/*
- * Toggle PORT cmd use before each data connection.
+ * Toggle PORT/LPRT cmd use before each data connection.
*/
/*VARARGS*/
void
@@ -878,7 +907,7 @@
char *argv[];
{
- code = togglevar(argc, argv, &sendport, "Use of PORT cmds");
+ code = togglevar(argc, argv, &sendport, "Use of PORT/LPRT cmds");
}
/*
@@ -934,6 +963,7 @@
gatemode = 0;
else {
if (argc == 3) {
+#if 0
char *ep;
long port;
@@ -947,6 +977,9 @@
return;
}
gateport = htons(port);
+#else
+ gateport = strdup(argv[2]);
+#endif
}
strncpy(gsbuf, argv[1], sizeof(gsbuf) - 1);
gsbuf[sizeof(gsbuf) - 1] = '\0';
@@ -959,9 +992,9 @@
"Disabling gate-ftp mode - no gate-ftp server defined.\n");
gatemode = 0;
} else {
- fprintf(ttyout, "Gate ftp: %s, server %s, port %d.\n",
+ fprintf(ttyout, "Gate ftp: %s, server %s, port %s.\n",
onoff(gatemode), *gateserver ? gateserver : "(none)",
- ntohs(gateport));
+ gateport);
}
code = gatemode;
}
diff -r 7b6850f83a2e -r b1f0b859347e usr.bin/ftp/cmdtab.c
--- a/usr.bin/ftp/cmdtab.c Fri Jul 02 07:59:56 1999 +0000
+++ b/usr.bin/ftp/cmdtab.c Fri Jul 02 08:07:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmdtab.c,v 1.23 1999/06/29 10:43:17 lukem Exp $ */
+/* $NetBSD: cmdtab.c,v 1.24 1999/07/02 08:07:41 itojun Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmdtab.c,v 1.23 1999/06/29 10:43:17 lukem Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.24 1999/07/02 08:07:41 itojun Exp $");
#endif
#endif /* not lint */
@@ -93,7 +93,7 @@
char ntranshelp[] = "set translation table for default file name mapping";
char pagehelp[] = "view a remote file through your pager";
char passivehelp[] = "enter passive transfer mode";
-char porthelp[] = "toggle use of PORT cmd for each data connection";
+char porthelp[] = "toggle use of PORT/LPRT cmd for each data connection";
char preservehelp[] ="toggle preservation of modification time of "
"retrieved files";
char progresshelp[] ="toggle transfer progress meter";
diff -r 7b6850f83a2e -r b1f0b859347e usr.bin/ftp/extern.h
--- a/usr.bin/ftp/extern.h Fri Jul 02 07:59:56 1999 +0000
+++ b/usr.bin/ftp/extern.h Fri Jul 02 08:07:40 1999 +0000
@@ -1,4 +1,33 @@
-/* $NetBSD: extern.h,v 1.31 1999/06/29 10:43:17 lukem Exp $ */
+/* $NetBSD: extern.h,v 1.32 1999/07/02 08:07:41 itojun Exp $ */
+
+/*
+ * Copyright (C) 1997 and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
/*-
* Copyright (c) 1994 The Regents of the University of California.
@@ -78,10 +107,11 @@
int globulize __P((char **));
char *gunique __P((const char *));
void help __P((int, char **));
-char *hookup __P((const char *, in_port_t));
+char *hookup __P((char *, char *));
void idle __P((int, char **));
int initconn __P((void));
void intr __P((void));
+int isurl __P((const char *));
void list_vertical __P((StringList *));
void lcd __P((int, char **));
void lostpeer __P((void));
diff -r 7b6850f83a2e -r b1f0b859347e usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c Fri Jul 02 07:59:56 1999 +0000
+++ b/usr.bin/ftp/fetch.c Fri Jul 02 08:07:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fetch.c,v 1.59 1999/06/29 10:43:17 lukem Exp $ */
+/* $NetBSD: fetch.c,v 1.60 1999/07/02 08:07:41 itojun Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.59 1999/06/29 10:43:17 lukem Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.60 1999/07/02 08:07:41 itojun Exp $");
#endif /* not lint */
/*
@@ -88,7 +88,7 @@
static int fetch_ftp __P((const char *));
static int fetch_url __P((const char *, const char *, char *, char *));
static int parse_url __P((const char *, const char *, url_t *, char **,
- char **, char **, in_port_t *, char **));
+ char **, char **, char **, char **));
static void url_decode __P((char *));
static int redirect_loop;
@@ -285,7 +285,7 @@
char **user;
char **pass;
char **host;
- in_port_t *port;
+ char **port;
char **path;
{
char *cp, *ep, *thost;
@@ -297,7 +297,7 @@
*type = UNKNOWN_URL_T;
*user = *pass = *host = *path = NULL;
- *port = 0;
+ *port = NULL;
if (strncasecmp(url, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
url += sizeof(HTTP_URL) - 1;
@@ -316,6 +316,7 @@
FREEPTR(*user);
FREEPTR(*pass);
FREEPTR(*host);
+ FREEPTR(*port);
FREEPTR(*path);
return (-1);
}
@@ -353,8 +354,24 @@
} else
*host = thost;
+ /* look for IPv6 address URL */
+ if (*thost == '[' && (cp = strrchr(thost, ']'))) {
+ size_t len = cp - thost - 1 ;
+ *host = (char *)xmalloc(len + 1);
+ strncpy(*host, thost + 1, len);
+ (*host)[len] = '\0';
+ cp = strrchr(++cp, ':');
+ } else if ((cp = strrchr(thost, ':')) != NULL) {
+ size_t len = cp - thost;
+ *host = (char *)xmalloc(len + 1);
+ strncpy(*host, thost, len);
+ (*host)[len] = '\0';
+ } else {
+ *host = xstrdup(thost);
+ cp = NULL;
+ }
+
/* look for [:port] */
- cp = strrchr(*host, ':');
if (cp != NULL) {
long nport;
@@ -364,14 +381,15 @@
warnx("Invalid port `%s' in %s `%s'", cp, desc, url);
goto cleanup_parse_url;
}
- *port = htons((in_port_t)nport);
+ *port = (char *)xmalloc(6); /* large enough for "65535\0" */
+ snprintf(*port, 6, "%ld", nport);
}
if (debug)
fprintf(ttyout,
- "parse_url: user `%s' pass `%s' host %s:%d path `%s'\n",
+ "parse_url: user `%s' pass `%s' host %s:%s path `%s'\n",
*user ? *user : "<null>", *pass ? *pass : "<null>",
- *host ? *host : "<null>", ntohs(*port),
+ *host ? *host : "<null>", *port ? *port : "<null>",
*path ? *path : "<null>");
return (0);
@@ -395,8 +413,7 @@
char *proxyauth;
Home |
Main Index |
Thread Index |
Old Index