Resolve conflicts from merge of 3.2a7, take 2. Also, eliminate some

silly differences between the NetBSD copy of the code and the
vendor branch, keeping only those which are necessary.  Of those
differences that currently exist, several "portability to NetBSD"
issues, which will be fed back to the ipfilter author.
This commit is contained in:
thorpej 1997-05-28 00:17:11 +00:00
parent d0968e6141
commit 41d4822677
13 changed files with 93 additions and 58 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fil.c,v 1.8 1997/05/27 01:09:13 thorpej Exp $ */
/* $NetBSD: fil.c,v 1.9 1997/05/28 00:17:11 thorpej Exp $ */
/*
* (C)opyright 1993-1996 by Darren Reed.
@ -9,7 +9,7 @@
*/
#if !defined(lint) && defined(LIBC_SCCS)
static char sccsid[] = "@(#)fil.c 1.36 6/5/96 (C) 1993-1996 Darren Reed";
static char rcsid[] = "$Id: fil.c,v 1.8 1997/05/27 01:09:13 thorpej Exp $";
static char rcsid[] = "Id: fil.c,v 2.0.2.13 1997/05/24 07:33:37 darrenr Exp ";
#endif
#include <sys/errno.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_compat.h,v 1.5 1997/05/25 12:40:12 darrenr Exp $ */
/* $NetBSD: ip_compat.h,v 1.6 1997/05/28 00:17:13 thorpej Exp $ */
/*
* (C)opyright 1993-1997 by Darren Reed.
@ -8,7 +8,7 @@
* to the original author and the contributors.
*
* @(#)ip_compat.h 1.8 1/14/96
* $Id: ip_compat.h,v 1.5 1997/05/25 12:40:12 darrenr Exp $
* Id: ip_compat.h,v 2.0.2.11 1997/05/04 05:29:02 darrenr Exp
*/
#ifndef __IP_COMPAT_H__

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_fil.c,v 1.16 1997/05/27 01:15:21 thorpej Exp $ */
/* $NetBSD: ip_fil.c,v 1.17 1997/05/28 00:17:15 thorpej Exp $ */
/*
* (C)opyright 1993-1997 by Darren Reed.
@ -9,11 +9,11 @@
*/
#if !defined(lint) && defined(LIBC_SCCS)
static char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-1995 Darren Reed";
static char rcsid[] = "$Id: ip_fil.c,v 1.16 1997/05/27 01:15:21 thorpej Exp $";
static char rcsid[] = "Id: ip_fil.c,v 2.0.2.12 1997/05/24 07:39:56 darrenr Exp ";
#endif
#ifndef SOLARIS
# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
#endif
#ifdef __FreeBSD__
@ -27,9 +27,9 @@ static char rcsid[] = "$Id: ip_fil.c,v 1.16 1997/05/27 01:15:21 thorpej Exp $";
# endif
#endif
#ifndef _KERNEL
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include <sys/errno.h>
#include <sys/types.h>
@ -43,7 +43,7 @@ static char rcsid[] = "$Id: ip_fil.c,v 1.16 1997/05/27 01:15:21 thorpej Exp $";
#endif
#include <sys/time.h>
#ifdef _KERNEL
# include <sys/systm.h>
#include <sys/systm.h>
#endif
#include <sys/uio.h>
#if !SOLARIS
@ -52,7 +52,7 @@ static char rcsid[] = "$Id: ip_fil.c,v 1.16 1997/05/27 01:15:21 thorpej Exp $";
# else
# include <sys/dir.h>
# endif
# include <sys/mbuf.h>
#include <sys/mbuf.h>
#else
#include <sys/filio.h>
#endif
@ -117,7 +117,11 @@ caddr_t iplh[3], iplt[3];
int iplused[3] = {0,0,0};
#endif /* IPFILTER_LOG */
static void frflush __P((caddr_t));
#if defined(__NetBSD__)
static int frrequest __P((u_long, caddr_t, int));
#else
static int frrequest __P((int, caddr_t, int));
#endif
static void frzerostats __P((caddr_t));
#ifdef _KERNEL
static int (*fr_savep) __P((struct ip *, int, struct ifnet *,
@ -132,6 +136,7 @@ static int write_output __P((struct ifnet *, struct mbuf *,
struct sockaddr *, struct rtentry *));
#endif
#if (_BSDI_VERSION >= 199510) && defined(_KERNEL)
# include <sys/device.h>
# include <sys/conf.h>
@ -227,15 +232,15 @@ int ipl_enable()
fr_saveslowtimo = inetsw[0].pr_slowtimo;
inetsw[0].pr_slowtimo = ipfr_slowtimer;
# ifdef IPFILTER_LOG
/*
* Set log buffer pointers for each of the log buffers
*/
#ifdef IPFILTER_LOG
for (i = 0; i <= 2; i++) {
iplh[i] = iplbuf[i];
iplt[i] = iplbuf[i];
}
# endif
#endif
SPLX(s);
if (fr_pass & FR_PASS)
defpass = "pass";
@ -497,7 +502,11 @@ int mode;
static int frrequest(req, data, set)
#if defined(__NetBSD__)
u_long req;
#else
int req;
#endif
int set;
caddr_t data;
{
@ -605,7 +614,7 @@ caddr_t data;
* routines below for saving IP headers to buffer
*/
int iplopen(dev, flags
# if ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || (NetBSD >= 199511) || \
#if ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || (NetBSD >= 199511) || \
(__FreeBSD_version >= 220000)) && defined(_KERNEL)
, devtype, p)
int devtype;
@ -627,7 +636,7 @@ int flags;
int iplclose(dev, flags
# if ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || (NetBSD >= 199511) || \
#if ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || (NetBSD >= 199511) || \
(__FreeBSD_version >= 220000)) && defined(_KERNEL)
, devtype, p)
int devtype;
@ -800,9 +809,9 @@ struct tcpiphdr *ti;
struct tcphdr *tcp;
struct mbuf *m;
int tlen = 0;
# if defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)
#if defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)
struct route ro;
# endif
#endif
if (ti->ti_flags & TH_RST)
return -1; /* feedback loop */
@ -847,17 +856,17 @@ struct tcpiphdr *ti;
ip->ip_ttl = ip_defttl;
# endif
# if defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)
#if defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)
bzero((char *)&ro, sizeof(ro));
(void) ip_output(m, (struct mbuf *)0, &ro, 0, 0);
if (ro.ro_rt)
RTFREE(ro.ro_rt);
# else
#else
/*
* extra 0 in case of multicast
*/
(void) ip_output(m, (struct mbuf *)0, 0, 0, 0);
# endif
#endif
return 0;
}
@ -903,10 +912,10 @@ frdest_t *fdp;
dst = (struct sockaddr_in *)&ro->ro_dst;
dst->sin_family = AF_INET;
dst->sin_addr = fdp->fd_ip.s_addr ? fdp->fd_ip : ip->ip_dst;
# ifdef __bsdi__
#ifdef __bsdi__
dst->sin_len = sizeof(*dst);
# endif
# if (BSD >= 199306) && !defined(__NetBSD__) && !defined(__bsdi__)
#endif
#if (BSD >= 199306) && !defined(__NetBSD__) && !defined(__bsdi__)
# ifdef RTF_CLONING
rtalloc_ign(ro, RTF_CLONING);
# else
@ -1080,18 +1089,18 @@ ip_t *ip;
FILE *fp;
char fname[32];
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
sprintf(fname, "/tmp/%s", ifp->if_xname);
if ((fp = fopen(fname, "a"))) {
fclose(fp);
}
# else
#else
sprintf(fname, "/tmp/%s%d", ifp->if_name, ifp->if_unit);
if ((fp = fopen(fname, "a"))) {
fwrite((char *)ip, ntohs(ip->ip_len), 1, fp);
fclose(fp);
}
# endif
#endif
}
@ -1099,12 +1108,12 @@ struct ifnet *get_unit(name)
char *name;
{
struct ifnet *ifp, **ifa;
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
if (!strcmp(name, ifp->if_xname))
return ifp;
}
# else
#else
char ifname[32], *s;
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
@ -1112,7 +1121,7 @@ char *name;
if (!strcmp(name, ifname))
return ifp;
}
# endif
#endif
if (!ifneta) {
ifneta = (struct ifnet **)malloc(sizeof(ifp) * 2);
@ -1128,9 +1137,9 @@ char *name;
}
ifp = ifneta[nifs - 1];
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
strncpy(ifp->if_xname, name, sizeof(ifp->if_xname));
# else
#else
for (s = name; *s && !isdigit(*s); s++)
;
if (*s && isdigit(*s)) {
@ -1142,7 +1151,7 @@ char *name;
ifp->if_name = strdup(name);
ifp->if_unit = -1;
}
# endif
#endif
ifp->if_output = no_output;
return ifp;
}
@ -1153,14 +1162,14 @@ void init_ifp()
FILE *fp;
struct ifnet *ifp, **ifa;
char fname[32];
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606))
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
ifp->if_output = write_output;
sprintf(fname, "/tmp/%s", ifp->if_xname);
if ((fp = fopen(fname, "w")))
fclose(fp);
}
# else
#else
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
ifp->if_output = write_output;
@ -1168,7 +1177,7 @@ void init_ifp()
if ((fp = fopen(fname, "w")))
fclose(fp);
}
# endif
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_fil.h,v 1.12 1997/05/27 01:17:04 thorpej Exp $ */
/* $NetBSD: ip_fil.h,v 1.13 1997/05/28 00:17:16 thorpej Exp $ */
/*
* (C)opyright 1993-1997 by Darren Reed.
@ -8,7 +8,7 @@
* to the original author and the contributors.
*
* @(#)ip_fil.h 1.35 6/5/96
* $Id: ip_fil.h,v 1.12 1997/05/27 01:17:04 thorpej Exp $
* Id: ip_fil.h,v 2.0.2.13 1997/05/24 07:41:55 darrenr Exp
*/
#ifndef __IP_FIL_H__

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_frag.c,v 1.5 1997/05/27 01:18:47 thorpej Exp $ */
/* $NetBSD: ip_frag.c,v 1.6 1997/05/28 00:17:17 thorpej Exp $ */
/*
* (C)opyright 1993,1994,1995 by Darren Reed.
@ -9,7 +9,7 @@
*/
#if !defined(lint) && defined(LIBC_SCCS)
static char sccsid[] = "@(#)ip_frag.c 1.11 3/24/96 (C) 1993-1995 Darren Reed";
static char rcsid[] = "$Id: ip_frag.c,v 1.5 1997/05/27 01:18:47 thorpej Exp $";
static char rcsid[] = "Id: ip_frag.c,v 2.0.2.10 1997/05/24 07:36:23 darrenr Exp ";
#endif
#if !defined(_KERNEL) && !defined(KERNEL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_frag.h,v 1.4 1997/05/25 12:40:16 darrenr Exp $ */
/* $NetBSD: ip_frag.h,v 1.5 1997/05/28 00:17:18 thorpej Exp $ */
/*
* (C)opyright 1993-1997 by Darren Reed.
@ -8,7 +8,7 @@
* to the original author and the contributors.
*
* @(#)ip_frag.h 1.5 3/24/96
* $Id: ip_frag.h,v 1.4 1997/05/25 12:40:16 darrenr Exp $
* Id: ip_frag.h,v 2.0.2.7 1997/05/08 10:10:18 darrenr Exp
*/
#ifndef __IP_FRAG_H__

View File

@ -1,3 +1,5 @@
/* $NetBSD: ip_ftp_pxy.c,v 1.3 1997/05/28 00:17:19 thorpej Exp $ */
/*
* Simple FTP transparent proxy for in-kernel.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_nat.c,v 1.6 1997/05/27 01:20:46 thorpej Exp $ */
/* $NetBSD: ip_nat.c,v 1.7 1997/05/28 00:17:20 thorpej Exp $ */
/*
* (C)opyright 1995-1996 by Darren Reed.
@ -11,7 +11,11 @@
*/
#if !defined(lint) && defined(LIBC_SCCS)
static char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed";
static char rcsid[] = "$Id: ip_nat.c,v 1.6 1997/05/27 01:20:46 thorpej Exp $";
static char rcsid[] = "Id: ip_nat.c,v 2.0.2.18 1997/05/24 07:34:44 darrenr Exp ";
#endif
#if defined(__FreeBSD__) && defined(KERNEL) && !defined(_KERNEL)
#define _KERNEL
#endif
#if !defined(_KERNEL) && !defined(KERNEL)
@ -442,14 +446,30 @@ int direction;
struct ifaddr *ifa;
struct sockaddr_in *sin;
# if (__FreeBSD_version >= 300000)
ifa = TAILQ_FIRST(&ifp->if_addrhead);
# else
# ifdef __NetBSD__
ifa = ifp->if_addrlist.tqh_first;
# else
ifa = ifp->if_addrlist;
# endif
# endif
# if BSD < 199306
sin = (SOCKADDR_IN *)&ifa->ifa_addr;
# else
sin = (SOCKADDR_IN *)ifa->ifa_addr;
while (sin && ifa &&
sin->sin_family != AF_INET) {
# if (__FreeBSD_version >= 300000)
ifa = TAILQ_NEXT(ifa, ifa_link);
# else
# ifdef __NetBSD__
ifa = ifa->ifa_list.tqe_next;
# else
ifa = ifa->ifa_next;
# endif
# endif
sin = (SOCKADDR_IN *)ifa->ifa_addr;
}
if (!ifa)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_nat.h,v 1.6 1997/05/27 01:21:33 thorpej Exp $ */
/* $NetBSD: ip_nat.h,v 1.7 1997/05/28 00:17:22 thorpej Exp $ */
/*
* (C)opyright 1995-1997 by Darren Reed.
@ -8,7 +8,7 @@
* to the original author and the contributors.
*
* @(#)ip_nat.h 1.5 2/4/96
* $Id: ip_nat.h,v 1.6 1997/05/27 01:21:33 thorpej Exp $
* Id: ip_nat.h,v 2.0.2.12 1997/05/24 07:35:20 darrenr Exp
*/
#ifndef __IP_NAT_H__

View File

@ -1,3 +1,5 @@
/* $NetBSD: ip_proxy.c,v 1.3 1997/05/28 00:17:22 thorpej Exp $ */
/*
* (C)opyright 1997 by Darren Reed.
*
@ -6,7 +8,7 @@
* to the original author and the contributors.
*/
#if !defined(lint) && defined(LIBC_SCCS)
static char rcsid[] = "$Id: ip_proxy.c,v 1.2 1997/05/27 01:22:52 thorpej Exp $";
static char rcsid[] = "Id: ip_proxy.c,v 2.0.2.3 1997/05/24 07:36:22 darrenr Exp ";
#endif
#if defined(__FreeBSD__) && defined(KERNEL) && !defined(_KERNEL)

View File

@ -1,3 +1,5 @@
/* $NetBSD: ip_proxy.h,v 1.3 1997/05/28 00:17:23 thorpej Exp $ */
/*
* (C)opyright 1997 by Darren Reed.
*
@ -5,7 +7,7 @@
* provided that this notice is preserved and due credit is given
* to the original author and the contributors.
*
* $Id: ip_proxy.h,v 1.2 1997/05/27 01:23:50 thorpej Exp $
* Id: ip_proxy.h,v 2.0.2.2 1997/05/24 07:36:44 darrenr Exp
*/
#ifndef __IP_PROXY_H__

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_state.c,v 1.5 1997/05/27 01:24:31 thorpej Exp $ */
/* $NetBSD: ip_state.c,v 1.6 1997/05/28 00:17:24 thorpej Exp $ */
/*
* (C)opyright 1995 by Darren Reed.
@ -9,7 +9,7 @@
*/
#if !defined(lint) && defined(LIBC_SCCS)
static char sccsid[] = "@(#)ip_state.c 1.8 6/5/96 (C) 1993-1995 Darren Reed";
static char rcsid[] = "$Id: ip_state.c,v 1.5 1997/05/27 01:24:31 thorpej Exp $";
static char rcsid[] = "Id: ip_state.c,v 2.0.2.12 1997/05/24 07:34:10 darrenr Exp ";
#endif
#if !defined(_KERNEL) && !defined(KERNEL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_state.h,v 1.4 1997/05/25 12:40:20 darrenr Exp $ */
/* $NetBSD: ip_state.h,v 1.5 1997/05/28 00:17:25 thorpej Exp $ */
/*
* (C)opyright 1995-1997 by Darren Reed.
@ -8,7 +8,7 @@
* to the original author and the contributors.
*
* @(#)ip_state.h 1.3 1/12/96 (C) 1995 Darren Reed
* $Id: ip_state.h,v 1.4 1997/05/25 12:40:20 darrenr Exp $
* Id: ip_state.h,v 2.0.2.9 1997/05/24 07:35:11 darrenr Exp
*/
#ifndef __IP_STATE_H__
#define __IP_STATE_H__