335 lines
9.3 KiB
Bash
335 lines
9.3 KiB
Bash
#! /bin/sh
|
|
#
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
#
|
|
# Copyright (c) 1996 Matthew R. Green
|
|
# 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. All advertising materials mentioning features or use of this software
|
|
# must display the following acknowledgement:
|
|
# This product includes software developed by Matthew R. Green for
|
|
# the NetBSD Project.
|
|
# 4. The name of the author may not be used to endorse or promote products
|
|
# derived from this software without specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
# ipfilter2netbsd: convert a ipfilter source tree into a
|
|
# netbsd ipfilter source tree, under src/sys, src/usr.sbin,
|
|
# etc., ready for importing.
|
|
|
|
if [ $# -ne 2 ]; then echo "ipfilter2netbsd src dest"; exit 1; fi
|
|
|
|
r=$1
|
|
d=$2/ipfilter
|
|
|
|
case "$d" in
|
|
/*)
|
|
;;
|
|
*)
|
|
d=`/bin/pwd`/$d
|
|
;;
|
|
esac
|
|
|
|
case "$r" in
|
|
/*)
|
|
;;
|
|
*)
|
|
r=`/bin/pwd`/$r
|
|
;;
|
|
esac
|
|
|
|
echo preparing directory $d
|
|
rm -rf $d
|
|
mkdir -p $d; cd $d
|
|
mkdir -p src/usr.sbin/ipf/ipf src/sys/netinet src/usr.sbin/ipf/ipfstat src/usr.sbin/ipf/ipftest src/usr.sbin/ipf/ipmon src/usr.sbin/ipf/ipnat src/usr.sbin/ipf/ipresend src/usr.sbin/ipf/ipsend src/usr.sbin/ipf/iptest src/sys/lkm/netinet/if_ipl
|
|
|
|
### start ipf ###############################
|
|
cd $r
|
|
echo ipf:
|
|
src='ipf.c parse.c opt.c ipf.h'
|
|
man='ipf.1 ipf.4 ipf.5 ipl.4'
|
|
|
|
pax -rvw $src $d/src/usr.sbin/ipf/ipf
|
|
cd man; pax -rvw $man $d/src/usr.sbin/ipf/ipf; cd ..
|
|
|
|
cd $d/src/usr.sbin/ipf/ipf
|
|
mv ipf.1 ipf.8
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipf
|
|
SRCS= ipf.c parse.c opt.c
|
|
MAN= ipf.8 ipf.4 ipf.5 ipl.4
|
|
MLINKS= ipl.4 ipfilter.4
|
|
|
|
BINDIR= /sbin
|
|
LDSTATIC= -static
|
|
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end ipf ###############################
|
|
|
|
### start ipfstat ###############################
|
|
cd $r
|
|
echo ipfstat:
|
|
src='kmem.c kmem.h fils.c'
|
|
man=ipfstat.8
|
|
|
|
pax -rvw $src $d/src/usr.sbin/ipf/ipfstat
|
|
cd man; pax -rvw $man $d/src/usr.sbin/ipf/ipfstat; cd ..
|
|
|
|
cd $d/src/usr.sbin/ipf/ipfstat
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipfstat
|
|
SRCS= kmem.c fils.c opt.c parse.c
|
|
MAN= ipfstat.8
|
|
CFLAGS+=-I${.CURDIR}/../ipf
|
|
|
|
.PATH: ${.CURDIR}/../ipf
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
|
|
### end ipfstat ###############################
|
|
|
|
### start ipftest ###############################
|
|
cd $r
|
|
echo ipftest:
|
|
src='ipt.c ipft_sn.c ipft_ef.c ipft_td.c ipft_pc.c ipft_tx.c misc.c ipft_hx.c ipt.h snoop.h pcap.h'
|
|
|
|
pax -rvw $src test $d/src/usr.sbin/ipf/ipftest
|
|
|
|
cd $d/src/usr.sbin/ipf/ipftest
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipftest
|
|
SRCS= ipt.c ipft_sn.c ipft_ef.c ipft_td.c ipft_pc.c opt.c ipft_tx.c misc.c ip_frag.c ip_state.c ip_nat.c ipft_hx.c ip_fil.c fil.c parse.c ip_proxy.c
|
|
NOMAN= yes
|
|
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../ipf -I${.CURDIR}/../../../sys
|
|
|
|
.PATH: ${.CURDIR}/../ipf ${.CURDIR}/../../../sys/netinet
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end ipftest ###############################
|
|
|
|
### start ipmon ###############################
|
|
cd $r
|
|
echo ipmon:
|
|
src=ipmon.c
|
|
man=ipmon.8
|
|
|
|
pax -rvw $src $d/src/usr.sbin/ipf/ipmon
|
|
cd man; pax -rvw $man $d/src/usr.sbin/ipf/ipmon; cd ..
|
|
|
|
cd $d/src/usr.sbin/ipf/ipmon
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipmon
|
|
MAN= ipmon.8
|
|
CFLAGS+=-DLOGFAC=LOG_LOCAL0 -I${.CURDIR}/../ipf
|
|
|
|
.PATH: ${.CURDIR}/../ipf
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end ipmon ###############################
|
|
|
|
### start ipnat ###############################
|
|
cd $r
|
|
echo ipnat:
|
|
src=ipnat.c
|
|
man='ipnat.1 ipnat.4 ipnat.5'
|
|
|
|
pax -rvw $src $d/src/usr.sbin/ipf/ipnat
|
|
cd man; pax -rvw $man $d/src/usr.sbin/ipf/ipnat; cd ..
|
|
|
|
cd $d/src/usr.sbin/ipf/ipnat
|
|
mv ipnat.1 ipnat.8
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipnat
|
|
SRCS= kmem.c ipnat.c
|
|
MAN= ipnat.8 ipnat.4 ipnat.5
|
|
CFLAGS+=-I${.CURDIR}/../ipf -I${.CURDIR}/../ipfstat
|
|
|
|
.PATH: ${.CURDIR}/../ipf ${.CURDIR}/../ipfstat
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end ipnat ###############################
|
|
|
|
### start of ipresend ##############################
|
|
cd $r
|
|
echo ipresend:
|
|
src='ipresend.c resend.c'
|
|
|
|
cd ipsend; pax -rvw $src $d/src/usr.sbin/ipf/ipresend
|
|
|
|
cd $d/src/usr.sbin/ipf/ipresend
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipresend
|
|
SRCS= ipresend.c ip.c resend.c opt.c ipft_ef.c ipft_hx.c ipft_sn.c ipft_td.c ipft_tx.c sbpf.c 44arp.c
|
|
NOMAN= yes
|
|
CFLAGS+=-I${.CURDIR}/../ipfstat -I${.CURDIR}/../ipsend -I${.CURDIR}/../ipftest -I${.CURDIR}/../ipf
|
|
|
|
.PATH: ${.CURDIR}/../ipf ${.CURDIR}/../ipfstat ${.CURDIR}/../ipsend ${.CURDIR}/../ipftest
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end of ipresend ###############################
|
|
|
|
### start of ipsend ##############################
|
|
cd $r
|
|
echo ipsend:
|
|
# XXX Want to also include tcpip.h, but can't right now because
|
|
# XXX the license on that file does not allow redistribution!
|
|
src='44arp.c ip.c ip_compat.h ipsend.c ipsend.h ipsopt.c sbpf.c'
|
|
|
|
cd ipsend; pax -rvw $src $d/src/usr.sbin/ipf/ipsend
|
|
|
|
cd $d/src/usr.sbin/ipf/ipsend
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= ipsend
|
|
SRCS= ipsend.c ip.c ipsopt.c 44arp.c sbpf.c
|
|
NOMAN= yes
|
|
CFLAGS+=-I${.CURDIR}/../ipftest -I${.CURDIR}/../ipf
|
|
|
|
.PATH: ${.CURDIR}/../ipf
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end of ipsend ###############################
|
|
|
|
### start of iptest ##############################
|
|
cd $r
|
|
echo iptest:
|
|
src='iptest.c iptests.c sock.c'
|
|
|
|
cd ipsend; pax -rvw $src $d/src/usr.sbin/ipf/iptest
|
|
|
|
cd $d/src/usr.sbin/ipf/iptest
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
PROG= iptest
|
|
SRCS= iptest.c iptests.c ip.c sbpf.c 44arp.c sock.c
|
|
NOMAN= yes
|
|
CFLAGS+=-I${.CURDIR}/../ipsend -I${.CURDIR}/../ipftest -I${.CURDIR}/../ipf
|
|
|
|
.PATH: ${.CURDIR}/../ipf ${.CURDIR}/../ipsend
|
|
.include <bsd.prog.mk>
|
|
__eof_makefile
|
|
### end of iptest ###############################
|
|
|
|
### start ipfilter in kernel #######################
|
|
cd $r
|
|
echo kernel modules:
|
|
src='ip_fil.c fil.c ip_nat.c ip_frag.c ip_state.c ip_fil.h ip_compat.h ip_frag.h ip_nat.h ip_state.h ip_proxy.c ip_proxy.h ip_ftp_pxy.c'
|
|
|
|
pax -rvw $src $d/src/sys/netinet
|
|
### end ipfilter in kernel #######################
|
|
|
|
### start ip_fil lkm #######################
|
|
cd $r
|
|
echo loadable kernel modules:
|
|
src='mln_ipl.c ipl.h'
|
|
|
|
pax -rvw $src $d/src/sys/lkm/netinet/if_ipl
|
|
|
|
cd $d/src/sys/lkm/netinet/if_ipl
|
|
|
|
echo creating Makefile
|
|
cat > Makefile<<'__eof_makefile'
|
|
# $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $
|
|
|
|
.include "../Makefile.inc"
|
|
|
|
.PATH: $S/netinet
|
|
|
|
KMOD= if_ipl
|
|
SRCS= ip_fil.c fil.c mln_ipl.c ip_nat.c ip_frag.c ip_state.c ip_proxy.c
|
|
NOMAN= yes
|
|
|
|
.include <bsd.kmod.mk>
|
|
__eof_makefile
|
|
### end ip_fil lkm #######################
|
|
|
|
find $d -name '*.[ch]' -print | while read c; do
|
|
sed -e 's/"ip_fil.h"/<netinet\/ip_fil.h>/
|
|
s/"ip_compat.h"/<netinet\/ip_compat.h>/
|
|
s/"ip_nat.h"/<netinet\/ip_nat.h>/
|
|
s/"ip_frag.h"/<netinet\/ip_frag.h>/
|
|
s/"ip_state.h"/<netinet\/ip_state.h>/
|
|
s/"ip_proxy.h"/<netinet\/ip_proxy.h>/
|
|
s/<sys\/ip_fil.h>/<netinet\/ip_fil.h>/
|
|
s/\$\(Id.*\)\$/\1/' \
|
|
< $c > /tmp/ipf2n$$ && mv /tmp/ipf2n$$ $c && echo transformed $c
|
|
sed 1q < $c | grep '\$NetBSD' || (
|
|
cat <<'__eof_header'
|
|
/* $NetBSD: ipfilter2netbsd,v 1.6 1997/05/28 03:05:55 thorpej Exp $ */
|
|
|
|
__eof_header
|
|
cat $c
|
|
) > /tmp/ipf3n$$ && cp /tmp/ipf3n$$ $c && echo added RCS tags to $c
|
|
done
|
|
|
|
echo done
|
|
|
|
# ipsend.h needs to include it's own private copy of ip_compat.h,
|
|
# which is very different from the copy in sys/netinet. (sigh.)
|
|
echo "fixing up $d/src/usr.sbin/ipf/ipsend/ipsend.h"
|
|
(
|
|
cd $d/src/usr.sbin/ipf/ipsend
|
|
sed -e 's/<netinet\/ip_compat.h>/"ip_compat.h"/' \
|
|
< ipsend.h > /tmp/ipf2n$$ && mv /tmp/ipf2n$$ ipsend.h
|
|
)
|
|
echo done
|
|
|
|
# Clean up any CVS directories that might be around.
|
|
echo "cleaning up CVS residue."
|
|
(
|
|
cd $d
|
|
find . -type d -name "CVS" -print | xargs rm -r
|
|
)
|
|
echo done
|
|
exit 0
|