remove unmaintained option (#ifdef FAITH4). sync w/kame

This commit is contained in:
itojun 2002-06-07 00:20:45 +00:00
parent a35e1a5e5b
commit 8a4859803b
4 changed files with 14 additions and 346 deletions

View File

@ -1,5 +1,5 @@
/* $NetBSD: faithd.c,v 1.25 2002/05/09 14:24:03 itojun Exp $ */
/* $KAME: faithd.c,v 1.50 2002/05/09 14:06:52 itojun Exp $ */
/* $NetBSD: faithd.c,v 1.26 2002/06/07 00:20:45 itojun Exp $ */
/* $KAME: faithd.c,v 1.53 2002/06/07 00:16:37 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@ -73,14 +73,6 @@
#include <netdb.h>
#include <ifaddrs.h>
#ifdef FAITH4
#include <resolv.h>
#include <arpa/nameser.h>
#ifndef FAITH_NS
#define FAITH_NS "FAITH_NS"
#endif
#endif
#include "faithd.h"
#include "prefix.h"
@ -110,9 +102,6 @@ static void play_service __P((int));
static void play_child __P((int, struct sockaddr *));
static int faith_prefix __P((struct sockaddr *));
static int map6to4 __P((struct sockaddr_in6 *, struct sockaddr_in *));
#ifdef FAITH4
static int map4to6 __P((struct sockaddr_in *, struct sockaddr_in6 *));
#endif
static void sig_child __P((int));
static void sig_terminate __P((int));
static void start_daemon __P((void));
@ -231,7 +220,7 @@ daemon_main(int argc, char **argv)
char *ns;
#endif /* FAITH_NS */
while ((c = getopt(argc, argv, "df:p46")) != -1) {
while ((c = getopt(argc, argv, "df:p")) != -1) {
switch (c) {
case 'd':
dflag++;
@ -242,14 +231,6 @@ daemon_main(int argc, char **argv)
case 'p':
pflag++;
break;
#ifdef FAITH4
case '4':
family = AF_INET;
break;
case '6':
family = AF_INET6;
break;
#endif
default:
usage();
/*NOTREACHED*/
@ -338,16 +319,6 @@ daemon_main(int argc, char **argv)
strerror(errno));
}
#endif
#ifdef FAITH4
#ifdef IP_FAITH
if (res->ai_family == AF_INET) {
error = setsockopt(s_wld, IPPROTO_IP, IP_FAITH, &on, sizeof(on));
if (error == -1)
exit_failure("setsockopt(IP_FAITH): %s",
strerror(errno));
}
#endif
#endif /* FAITH4 */
error = setsockopt(s_wld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (error == -1)
@ -525,17 +496,6 @@ play_child(int s_src, struct sockaddr *srcaddr)
}
syslog(LOG_INFO, "translating from v6 to v4");
break;
#ifdef FAITH4
case AF_INET:
if (!map4to6((struct sockaddr_in *)&dstaddr6,
(struct sockaddr_in6 *)&dstaddr4)) {
close(s_src);
exit_failure("map4to6 failed");
/*NOTREACHED*/
}
syslog(LOG_INFO, "translating from v4 to v6");
break;
#endif
default:
close(s_src);
exit_failure("family not supported");
@ -713,39 +673,6 @@ map6to4(struct sockaddr_in6 *dst6, struct sockaddr_in *dst4)
return 1;
}
#ifdef FAITH4
/* 0: non faith, 1: faith */
static int
map4to6(struct sockaddr_in *dst4, struct sockaddr_in6 *dst6)
{
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
struct addrinfo hints, *res;
int ai_errno;
if (getnameinfo((struct sockaddr *)dst4, dst4->sin_len, host, sizeof(host),
serv, sizeof(serv), NI_NAMEREQD|NI_NUMERICSERV) != 0)
return 0;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = 0;
hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
if ((ai_errno = getaddrinfo(host, serv, &hints, &res)) != 0) {
syslog(LOG_INFO, "%s %s: %s", host, serv,
gai_strerror(ai_errno));
return 0;
}
memcpy(dst6, res->ai_addr, res->ai_addrlen);
freeaddrinfo(res);
return 1;
}
#endif /* FAITH4 */
static void
sig_child(int sig)
@ -755,8 +682,8 @@ sig_child(int sig)
while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) > 0)
if (WEXITSTATUS(status))
syslog(LOG_WARNING, "child %d exit status 0x%x",
pid, status);
syslog(LOG_WARNING, "child %ld exit status 0x%x",
(long)pid, status);
}
void

View File

@ -1,5 +1,5 @@
/* $NetBSD: ftp.c,v 1.8 2002/04/24 12:14:42 itojun Exp $ */
/* $KAME: ftp.c,v 1.14 2002/04/24 08:17:23 itojun Exp $ */
/* $NetBSD: ftp.c,v 1.9 2002/06/07 00:20:45 itojun Exp $ */
/* $KAME: ftp.c,v 1.15 2002/06/07 00:16:37 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@ -61,11 +61,7 @@ static struct sockaddr_storage data4; /* server data address */
static struct sockaddr_storage data6; /* client data address */
static int epsvall = 0;
#ifdef FAITH4
enum state { NONE, LPRT, EPRT, PORT, LPSV, EPSV, PASV };
#else
enum state { NONE, LPRT, EPRT, LPSV, EPSV };
#endif
static int ftp_activeconn __P((void));
static int ftp_passiveconn __P((void));
@ -440,22 +436,6 @@ ftp_copyresult(int src, int dst, enum state state)
}
write(dst, rbuf, n);
return n;
#ifdef FAITH4
case PORT:
/* expecting "200 EPRT command successful." */
if (code == 200) {
p = strstr(rbuf, "EPRT");
if (p) {
p[0] = 'P';
p[1] = 'O';
}
} else {
close(wport4);
wport4 = -1;
}
write(dst, rbuf, n);
return n;
#endif
case LPSV:
case EPSV:
/*
@ -592,123 +572,6 @@ passivefail:
return n;
}
}
#ifdef FAITH4
case PASV:
/* expecting "229 Entering Extended Passive Mode (|||x|)" */
if (code != 229) {
passivefail1:
close(wport6);
wport6 = -1;
write(dst, rbuf, n);
return n;
}
{
u_short port;
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
/*
* EPSV result -> PORT result
*/
p = param;
while (*p && *p != '(') /*)*/
p++;
if (!*p)
goto passivefail1; /*XXX*/
p++;
n = sscanf(p, "|||%hu|", &port);
if (n != 1)
goto passivefail1; /*XXX*/
/* keep EPRT parameter */
n = sizeof(data4);
error = getpeername(src, (struct sockaddr *)&data4, &n);
if (error == -1)
goto passivefail1; /*XXX*/
sin6 = (struct sockaddr_in6 *)&data4;
sin6->sin6_port = htons(port);
/* get ready for passive data connection */
memset(&data6, 0, sizeof(data6));
sin = (struct sockaddr_in *)&data6;
sin->sin_len = sizeof(*sin);
sin->sin_family = AF_INET;
wport6 = socket(sin->sin_family, SOCK_STREAM, 0);
if (wport6 == -1) {
passivefail2:
n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate from EPSV\r\n");
if (n < 0 || n >= sizeof(sbuf))
n = 0;
if (n)
write(src, sbuf, n);
return n;
}
#ifdef IP_FAITH
{
int on = 1;
error = setsockopt(wport6, IPPROTO_IP, IP_FAITH,
&on, sizeof(on));
if (error == -1)
exit_error("setsockopt(IP_FAITH): %s", strerror(errno));
}
#endif
error = bind(wport6, (struct sockaddr *)sin, sin->sin_len);
if (error == -1) {
close(wport6);
wport6 = -1;
goto passivefail2;
}
error = listen(wport6, 1);
if (error == -1) {
close(wport6);
wport6 = -1;
goto passivefail2;
}
/* transmit PORT */
/*
* addr from dst, port from wport6
*/
n = sizeof(data6);
error = getsockname(wport6, (struct sockaddr *)&data6, &n);
if (error == -1) {
close(wport6);
wport6 = -1;
goto passivefail2;
}
sin = (struct sockaddr_in *)&data6;
port = sin->sin_port;
n = sizeof(data6);
error = getsockname(dst, (struct sockaddr *)&data6, &n);
if (error == -1) {
close(wport6);
wport6 = -1;
goto passivefail2;
}
sin = (struct sockaddr_in *)&data6;
sin->sin_port = port;
{
char *a, *p;
a = (char *)&sin->sin_addr;
p = (char *)&sin->sin_port;
n = snprintf(sbuf, sizeof(sbuf),
"227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1]));
if (n < 0 || n >= sizeof(sbuf))
n = 0;
if (n)
write(dst, sbuf, n);
passivemode = 1;
return n;
}
}
#endif /* FAITH4 */
}
bad:
@ -1045,124 +908,6 @@ eprtparamfail:
if (n)
write(src, sbuf, n);
return n;
#ifdef FAITH4
} else if (strcmp(cmd, "PORT") == 0 && param) {
/*
* PORT -> EPRT
*/
char host[NI_MAXHOST], serv[NI_MAXSERV];
nstate = PORT;
close(wport4);
close(wport6);
close(port4);
close(port6);
wport4 = wport6 = port4 = port6 = -1;
p = param;
n = sscanf(p, "%u,%u,%u,%u,%u,%u",
&ho[0], &ho[1], &ho[2], &ho[3], &po[0], &po[1]);
if (n != 6) {
n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to PORT\r\n");
if (n < 0 || n >= sizeof(sbuf))
n = 0;
if (n)
write(src, sbuf, n);
return n;
}
memset(&data6, 0, sizeof(data6));
sin = (struct sockaddr_in *)&data6;
sin->sin_len = sizeof(*sin);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(
((ho[0] & 0xff) << 24) | ((ho[1] & 0xff) << 16) |
((ho[2] & 0xff) << 8) | (ho[3] & 0xff));
sin->sin_port = htons(((po[0] & 0xff) << 8) | (po[1] & 0xff));
/* get ready for active data connection */
n = sizeof(data4);
error = getsockname(dst, (struct sockaddr *)&data4, &n);
if (error == -1) {
portfail:
n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate to EPRT\r\n");
if (n < 0 || n >= sizeof(sbuf))
n = 0;
if (n)
write(src, sbuf, n);
return n;
}
if (((struct sockaddr *)&data4)->sa_family != AF_INET6)
goto portfail;
((struct sockaddr_in6 *)&data4)->sin6_port = 0;
sa = (struct sockaddr *)&data4;
wport4 = socket(sa->sa_family, SOCK_STREAM, 0);
if (wport4 == -1)
goto portfail;
error = bind(wport4, sa, sa->sa_len);
if (error == -1) {
close(wport4);
wport4 = -1;
goto portfail;
}
error = listen(wport4, 1);
if (error == -1) {
close(wport4);
wport4 = -1;
goto portfail;
}
/* transmit EPRT */
n = sizeof(data4);
error = getsockname(wport4, (struct sockaddr *)&data4, &n);
if (error == -1) {
close(wport4);
wport4 = -1;
goto portfail;
}
af = 2;
sa = (struct sockaddr *)&data4;
if (getnameinfo(sa, sa->sa_len, host, sizeof(host),
serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV)) {
close(wport4);
wport4 = -1;
goto portfail;
}
n = snprintf(sbuf, sizeof(sbuf), "EPRT |%d|%s|%s|\r\n", af, host, serv);
if (n < 0 || n >= sizeof(sbuf))
n = 0;
if (n)
write(dst, sbuf, n);
*state = nstate;
passivemode = 0;
return n;
} else if (strcmp(cmd, "PASV") == 0 && !param) {
/*
* PASV -> EPSV
*/
nstate = PASV;
close(wport4);
close(wport6);
close(port4);
close(port6);
wport4 = wport6 = port4 = port6 = -1;
/* transmit EPSV */
n = snprintf(sbuf, sizeof(sbuf), "EPSV\r\n");
if (n < 0 || n >= sizeof(sbuf))
n = 0;
if (n)
write(dst, sbuf, n);
*state = PASV;
passivemode = 0; /* to be set to 1 later */
return n;
#else /* FAITH4 */
} else if (strcmp(cmd, "PORT") == 0 || strcmp(cmd, "PASV") == 0) {
/*
* reject PORT/PASV
@ -1173,7 +918,6 @@ portfail:
if (n)
write(src, sbuf, n);
return n;
#endif /* FAITH4 */
} else if (passivemode
&& (strcmp(cmd, "STOR") == 0
|| strcmp(cmd, "STOU") == 0

View File

@ -1,5 +1,5 @@
/* $NetBSD: prefix.c,v 1.3 2001/11/21 06:52:35 itojun Exp $ */
/* $KAME: prefix.c,v 1.9 2001/07/02 14:36:49 itojun Exp $ */
/* $NetBSD: prefix.c,v 1.4 2002/06/07 00:20:45 itojun Exp $ */
/* $KAME: prefix.c,v 1.11 2001/11/13 12:38:45 jinmei Exp $ */
/*
* Copyright (C) 2000 WIDE Project.
@ -55,11 +55,7 @@ static void config_show __P((void));
#endif
struct config *config_list = NULL;
#ifdef NI_WITHSCOPEID
const int niflags = NI_NUMERICHOST | NI_WITHSCOPEID;
#else
const int niflags = NI_NUMERICHOST;
#endif
static int
prefix_set(s, prefix, slash)

View File

@ -1,5 +1,5 @@
/* $NetBSD: tcp.c,v 1.7 2002/04/24 12:14:42 itojun Exp $ */
/* $KAME: tcp.c,v 1.8 2001/11/21 07:40:22 itojun Exp $ */
/* $NetBSD: tcp.c,v 1.8 2002/06/07 00:20:45 itojun Exp $ */
/* $KAME: tcp.c,v 1.9 2002/05/26 01:17:02 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@ -93,7 +93,8 @@ sig_child(int sig)
pid = wait3(&status, WNOHANG, (struct rusage *)0);
if (pid > 0 && WEXITSTATUS(status))
syslog(LOG_WARNING, "child %d exit status 0x%x", pid, status);
syslog(LOG_WARNING, "child %ld exit status 0x%x",
(long)pid, status);
exit_success("terminate connection due to child termination");
}