aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/sysinstall/ftp.c
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1995-05-24 01:27:15 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1995-05-24 01:27:15 +0000
commit9b03310b0c2bec09c28078e1a2d29f745fbf0759 (patch)
tree7e001d70a2e1ec65b4b789b26acd5bcd541a7c0b /usr.sbin/sysinstall/ftp.c
parent95e34bfc2ef72df7348fbe5dcafa8aeecc463b0a (diff)
downloadsrc-9b03310b0c2bec09c28078e1a2d29f745fbf0759.tar.gz
src-9b03310b0c2bec09c28078e1a2d29f745fbf0759.zip
Notes
Diffstat (limited to 'usr.sbin/sysinstall/ftp.c')
-rw-r--r--usr.sbin/sysinstall/ftp.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c
index 0d0cf17b8e7b..4a908e5e3e77 100644
--- a/usr.sbin/sysinstall/ftp.c
+++ b/usr.sbin/sysinstall/ftp.c
@@ -114,11 +114,12 @@ int
FtpOpen(FTP_t ftp, char *host, char *user, char *passwd)
{
- struct hostent *he, hdef;
- struct servent *se, sdef;
- struct sockaddr_in sin;
- int s;
- char a,*p,buf[BUFSIZ];
+ struct hostent *he, hdef;
+ struct servent *se, sdef;
+ struct sockaddr_in sin;
+ int s;
+ char a,*p,buf[BUFSIZ];
+ unsigned long temp;
if (!user)
user = "ftp";
@@ -126,17 +127,28 @@ FtpOpen(FTP_t ftp, char *host, char *user, char *passwd)
if (!passwd)
passwd = "??@??(FreeBSD:libftp)"; /* XXX */
- he = gethostbyname(host);
- if (!he)
- return ENOENT;
+ msgDebug("FtpOpen(ftp, %s, %s, %s)\n", host, user, passwd);
- se = getservbyname("ftp","tcp");
- if (!se)
+ temp = inet_addr(host);
+ if (temp != INADDR_NONE)
+ {
+ msgDebug("Using dotted IP address `%s'\n", host);
+ ftp->addrtype = sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = temp;
+ } else {
+ msgDebug("Trying to resolve `%s'\n", host);
+ he = gethostbyname(host);
+ if (!he)
+ {
+ msgDebug("Lookup of `%s' failed!\n", host);
return ENOENT;
+ }
+ ftp->addrtype = sin.sin_family = he->h_addrtype;
+ bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
+ }
+
+ sin.sin_port = htons(21);
- ftp->addrtype = sin.sin_family = he->h_addrtype;
- bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
- sin.sin_port = se->s_port;
if ((s = socket(he->h_addrtype, SOCK_STREAM, 0)) < 0)
return s;