3 PATH=/sbin:/usr/sbin:/bin:/usr/bin; export PATH
8 maj=`expr $rev : '\([0-9]*\)\.'`
9 min=`expr $rev : '[0-9]*\.\([0-9]*\)'`
10 sub=`expr $rev : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
12 # try to bomb out fast if anything fails....
15 fullrev=`printf '%02d%02d%02d' $maj $min $sub`
18 archdir="/sys/arch/$karch"
20 if [ -d /sys/contrib/ipfilter ] ; then
21 ipfdir=/sys/contrib/ipfilter/netinet
23 if [ -d /sys/dist/ipf ] ; then
24 ipfdir=/sys/dist/ipf/netinet
26 confdir="$archdir/conf"
27 if [ -f /dev/ipnat ] ; then
28 major=`ls -l /dev/ipnat | sed -e 's/.* \([0-9]*\),.*/\1/'`
29 echo "Major number for IP Filter is $major"
34 if [ ! -f ip_rules.c -o ! -f ip_rules.h ] ; then
35 echo "Trying to build ip_rules.c and ip_rules.h"
37 if [ ! -f ip_rules.c -o ! -f ip_rules.h ] ; then
38 echo "Please do a build of ipfilter and then run the following"
39 echo "command to build extra files:"
41 echo "make ip_rules.c"
47 for j in auth frag nat proxy scan state sync pool htable lookup rules; do
48 for i in ip_$j.[ch]; do
69 filc=ip_fil_`echo $os | tr A-Z a-z`.c
72 cp mlfk_ipl.c $ipfdir/
80 if [ -f $ipfdir/$filc ] ; then
81 echo -n "$filc -> $ipfdir/$filc "
82 cp $filc $ipfdir/$filc
83 chmod 644 $ipfdir/$filc
85 if [ -f $ipfdir/ip_fil.c ] ; then
86 echo -n "$filc -> $ipfdir/ip_fil.c "
87 cp $filc $ipfdir/ip_fil.c
88 chmod 644 $ipfdir/ip_fil.c
91 for i in ip_fil.h fil.c ip_log.c ip_compat.h ipl.h ip_*_pxy.c; do
97 echo -n "Installing into /usr/include/netinet"
98 for j in auth compat fil frag nat proxy scan state sync pool htable lookup; do
100 if [ -f "$i" ] ; then
102 cp $i /usr/include/netinet/$i
103 chmod 644 /usr/include/netinet/$i
107 if [ -f "$j" ] ; then
109 cp $j /usr/include/netinet/$j
110 chmod 644 /usr/include/netinet/$j
115 if [ -f /sys/netinet/ip_fil_compat.h ] ; then
116 echo "Linking /sys/netinet/ip_compat.h to /sys/netinet/ip_fil_compat.h"
117 rm /sys/netinet/ip_fil_compat.h
118 ln -s /sys/netinet/ip_compat.h /sys/netinet/ip_fil_compat.h
121 if [ $major != x ] ; then
122 if [ ! -e /dev/ipsync ] ; then
123 echo "Creating /dev/ipsync"
124 mknod /dev/ipsync c $major 4
127 if [ ! -e /dev/ipsync ] ; then
128 echo "Creating /dev/ipscan"
129 mknod /dev/ipsync c $major 5
132 if [ ! -e /dev/iplookup ] ; then
133 echo "Creating /dev/iplookup"
134 mknod /dev/iplookup c $major 6
140 if [ $os = FreeBSD -a -f /sys/conf/files ] ; then
142 if [ -f options ] ; then
143 if [ ! -f options.preipf4 ] ; then
144 mv options options.preipf4
145 cp -p options.preipf4 options
147 for i in SCAN SYNC LOOKUP COMPILED; do
148 grep IPFILTER_$i options >/dev/null 2>&1
149 if [ $? -ne 0 ] ; then
151 echo "# extra option for IP Filter" >> options
152 echo "IPFILTER_$i opt_ipfilter.h" >> options
156 if [ ! -f files.preipf4 ] ; then
157 mv files files.preipf4
158 cp -p files.preipf4 files
160 for i in htable pool lookup; do
161 grep ip_$i.c files >/dev/null 2>&1
162 if [ $? -ne 0 ] ; then
163 echo "contrib/ipfilter/netinet/ip_$i.c optional ipfilter inet ipfilter_lookup" >> files
166 grep ip_sync.c files >/dev/null 2>&1
167 if [ $? -ne 0 ] ; then
168 echo 'contrib/ipfilter/netinet/ip_sync.c optional ipfilter inet ipfilter_sync' >> files
170 grep ip_scan.c files >/dev/null 2>&1
171 if [ $? -ne 0 ] ; then
172 echo 'contrib/ipfilter/netinet/ip_scan.c optional ipfilter inet ipfilter_scan' >> files
174 grep ip_rules.c files >/dev/null 2>&1
175 if [ $? -ne 0 ] ; then
176 echo 'contrib/ipfilter/netinet/ip_rules.c optional ipfilter inet ipfilter_compiled' >> files
179 if [ $os = NetBSD -a -f /sys/conf/files ] ; then
181 if [ ! -f files.preipf4 ] ; then
182 mv files files.preipf4
183 cp -p files.preipf4 files
185 if [ $fullrev -ge 010600 -a $fullrev -lt 020000 ] ; then
186 for i in htable pool lookup; do
187 grep ip_$i.c files >/dev/null 2>&1
188 if [ $? -ne 0 ] ; then
189 echo "file netinet/ip_$i.c ipfilter & ipfilter_lookup" >> files
192 grep ip_sync.c files >/dev/null 2>&1
193 if [ $? -ne 0 ] ; then
194 echo 'file netinet/ip_sync.c ipfilter & ipfilter_sync' >> files
196 grep ip_scan.c files >/dev/null 2>&1
197 if [ $? -ne 0 ] ; then
198 echo 'file netinet/ip_scan.c ipfilter & ipfilter_scan' >> files
200 grep ip_rules.c files >/dev/null 2>&1
201 if [ $? -ne 0 ] ; then
202 echo 'file netinet/ip_rules.c ipfilter & ipfilter_compiled' >> files
206 if [ $os = OpenBSD -a -f /sys/conf/files ] ; then
208 if [ ! -f files.preipf4 ] ; then
209 mv files files.preipf4
210 cp -p files.preipf4 files
212 if [ $fullrev -ge 030400 ] ; then
213 for i in htable pool lookup; do
214 grep ip_$i.c files >/dev/null 2>&1
215 if [ $? -ne 0 ] ; then
216 echo "file netinet/ip_$i.c ipfilter & ipfilter_lookup" >> files
219 grep ip_sync.c files >/dev/null 2>&1
220 if [ $? -ne 0 ] ; then
221 echo 'file netinet/ip_sync.c ipfilter & ipfilter_sync' >> files
223 grep ip_scan.c files >/dev/null 2>&1
224 if [ $? -ne 0 ] ; then
225 echo 'file netinet/ip_scan.c ipfilter & ipfilter_scan' >> files
227 grep ip_rules.c files >/dev/null 2>&1
228 if [ $? -ne 0 ] ; then
229 echo 'file netinet/ip_rules.c ipfilter & ipfilter_compiled' >> files
234 if [ -f /usr/src/sys/modules/ipfilter/Makefile -a \
235 ! -f /usr/src/sys/modules/ipfilter/Makefile.orig ] ; then
236 cat | (cd /usr/src/sys/modules/ipfilter; patch) <<__EOF__
237 *** Makefile.orig Mon Mar 28 09:10:11 2005
238 --- Makefile Mon Mar 28 09:12:51 2005
242 SRCS= mlfk_ipl.c ip_nat.c ip_frag.c ip_state.c ip_proxy.c ip_auth.c \\
243 ! ip_log.c ip_fil.c fil.c
245 .if !defined(NOINET6)
248 CFLAGS+= -I$${.CURDIR}/../../contrib/ipfilter
249 ! CFLAGS+= -DIPFILTER=1 -DIPFILTER_LKM -DIPFILTER_LOG -DPFIL_HOOKS
252 SRCS= mlfk_ipl.c ip_nat.c ip_frag.c ip_state.c ip_proxy.c ip_auth.c \\
253 ! ip_log.c ip_fil.c fil.c ip_lookup.c ip_pool.c ip_htable.c \\
254 ! ip_sync.c ip_scan.c ip_rules.c
256 .if !defined(NOINET6)
259 CFLAGS+= -I$${.CURDIR}/../../contrib/ipfilter
260 ! CFLAGS+= -DIPFILTER=1 -DIPFILTER_LKM -DIPFILTER_LOG -DPFIL_HOOKS \\
261 ! -DIPFILTER_LOOKUP -DIPFILTER_COMPILED