| #!/bin/sh |
| # |
| # Major device number definition from /dev/MAKEDEV: |
| C_IPFLTR=59 # IP packet filtering device |
| # |
| PATH=/sbin:/usr/etc:/usr/sbin:${PATH} |
| if [ -r /var/sysgen/boot/ipflkm.o ]; then |
| ipflkm=true |
| id=`/sbin/ml list -l | grep ipflkm | awk ' { print $2 } ' -` |
| else |
| ipflkm=false |
| id="" |
| fi |
| pid=`ps -e | grep ipmon | awk ' { print $1 } ' -` |
| |
| IPFILCONF=/etc/ipf.conf |
| IPNATCONF=/etc/ipnat.conf |
| |
| case "$1" in |
| start) |
| if [ x$pid != x ] ; then |
| kill -TERM $pid |
| fi |
| if [ x$id != x ] ; then |
| /sbin/ml unld $id |
| fi |
| id="" |
| if ${ipflkm}; then |
| idout="`/sbin/ml ld -v -c /var/sysgen/boot/ipflkm.o -p ipl`" |
| if [ $? -eq 0 ]; then |
| id="`echo $idout | sed -n '/^Module id is [0-9][0-9]*\.$/s/Module id is \([0-9][0-9]*\)\.$/\1/p'`" |
| fi |
| else |
| id=${C_IPFLTR} |
| fi |
| if [ "$id" -gt 0 ]; then |
| (cd /dev && rm -f ipf ipl ipnat ipstate ipauth) |
| mknod /dev/ipf c $id 0 |
| mknod /dev/ipl c $id 0 |
| mknod /dev/ipnat c $id 1 |
| mknod /dev/ipstate c $id 2 |
| mknod /dev/ipauth c $id 3 |
| (cd /dev && chmod 600 ipf ipl ipnat ipstate ipauth) |
| ${ipflkm} || ipf -E |
| [ -r ${IPFILCONF} ] && ipf -Fa -f ${IPFILCONF} |
| [ -r ${IPNATCONF} ] && ipnat -CF -f ${IPNATCONF} |
| fi |
| ipmon -sn </dev/null >/dev/null 2>&1 & |
| ;; |
| |
| stop) |
| if [ x$pid != x ] ; then |
| kill -TERM $pid |
| fi |
| if ${ipflkm}; then |
| if [ x$id != x ] ; then |
| /sbin/ml unld $id && \ |
| (cd /dev && rm -f ipf ipl ipnat ipstate ipauth) |
| fi |
| else |
| ipf -D |
| fi |
| ;; |
| |
| reload) |
| if [ -r ${IPFILCONF} ]; then |
| ipf -I -Fa -f ${IPFILCONF} |
| if [ $? != 0 ]; then |
| echo "$0: reload of ${IPFILCONF} into alternate set failed" |
| else |
| ipf -s |
| fi |
| fi |
| if [ -r ${IPNATCONF} ]; then |
| ipnat -CF -f ${IPNATCONF} |
| if [ $? != 0 ]; then |
| echo "$0: reload of ${IPNATCONF} failed" |
| fi |
| fi |
| ;; |
| |
| *) |
| echo "Usage: $0 (start|stop|reload)" >&2 |
| exit 1 |
| ;; |
| |
| esac |
| exit 0 |