Skip to content

Instantly share code, notes, and snippets.

@MMcM MMcM/00-README.md
Created Jan 16, 2016

Embed
What would you like to do?
klh10 hacks

Files from 2003 that were in Comcast before they discontinued PWP.

#!/bin/sh
# iptables-based firewall for KLH10 PDP-10 emulator. 08/05 MMcM
# Based on a script by Bj�rn Victor.
## Initialization and defaults.
NAME= # The name of this firewall.
SERVICES="telnet ftp" # List of Services to forward to the PDP-10.
DNS=yes # Set up DNS.
DNSERVER= # Server to use.
OUTBOUND=yes # Allow outbound connections.
OUTEXCLUDE="smtp" # Except these if yes ...
OUTINCLUDE= # or these if no.
GWIF= # The normal LAN interface to the real world.
TUNIF= # The tunnel interface to the PDP-10.
GWADDR= # Unix external IP address.
IPADDR= # PDP-10 external IP address (if different).
TUNADDR= # Unix end of the tunnel.
PDPADDR= # PDP-10 end of the tunnel.
INIFILE= # Get some options from klh10.ini.
STOP=no # Stop the chains, rather than starting them.
QUIET=no # Suppress explanation of what we're doing.
WAIT=no # Wait for tunnel device to appear.
RETURN=no # Print ident args and return rather than doing it.
## Parse command line.
while [ $# -gt 0 ]; do
arg=$1; shift
case $arg in
help|-h*)
echo "usage: $0 [-name name] [-tunif tun_interface] [-gwif eth_interface] [-inifile [file]] [-ipaddr addr] [-services svc...] [-dns [server]] [-nodns] [-outbound [-except svc...]] [-nooutbound [-except svc]] [-stop] [-quiet] [-wait] [-return-args]"
exit 1;;
-stop)
STOP=yes;;
-ini*)
if [ -n "${1##-*}" ]; then
INIFILE=$1
shift
else
INIFILE=klh10.ini
fi
;;
-nam*)
NAME=$1
shift;;
-tun*)
TUNIF=$1
shift;;
-gw*)
GWIF=$1
shift;;
-ip*)
IPADDR=$1
shift;;
-dns)
DNS=yes
if [ -n "${1##-*}" ]; then
DNSERVER=$1
shift
fi
;;
-nodns)
DNS=no;;
-out*)
OUTBOUND=yes;;
-noout*)
OUTBOUND=no;;
-ex*)
xl=
while [ -n "${1##-*}" ]; do
xl="$xl $1"
shift
done
if [ "$OUTBOUND" == "yes" ]; then
OUTEXCLUDE="$xl"
else
OUTINCLUDE="$xl"
fi
;;
-wait*)
WAIT=yes;;
-return*)
RETURN=yes;;
-q*)
QUIET=yes;;
-s*)
SERVICES=
while [ -n "${1##-*}" ]; do
SERVICES="$SERVICES $1"
shift
done
;;
*)
echo "Illegal argument: $1" >&2
exit 1;;
esac
done
## Subroutines
# Print messages, but obey -quiet.
function qecho {
if [ "$QUIET" != "yes" ]; then
echo $*
fi
}
function get_iniopt {
echo "$INIOPTS" | awk "{ if (gsub(\".* $1=\", \"\")) print \$1 }"
}
function decode_service {
x="${1%%/@(tcp|udp)}"
if [ -z ${x//[0-9]} ]; then
echo $1
exit
fi
if [ -z ${1//[0-9]} ]; then
echo ${1}/tcp
exit
fi
SVC=$(awk "/^${1}[[:space:]]/ { print \$2; exit }" /etc/services)
if [ -n "$SVC" ]; then
echo $SVC
exit
fi
echo "Unknown service: $1" >&2
exit 1
}
## Do the actual work.
if [ -n "$INIFILE" ]; then
# Get the first enabled network device in the file.
INIOPTS=$(awk '/^devdef .+ ipaddr=/ { print $0; exit }' $INIFILE)
PDPADDR=$(get_iniopt ipaddr)
GWADDR=$(get_iniopt gwaddr)
TUNADDR=$(get_iniopt tunaddr)
fi
if [ -z "$GWIF" ]; then
if [ -n "$GWADDR" ]; then
GWIF=$(ip -f inet -o addr | awk "/ inet $GWADDR/ { print \$2 }")
else
# The first global interface.
GWIF=$(ip -f inet -o addr | awk '/ scope global/ { print $2; exit }')
fi
fi
if [ -z "$GWIF" ]; then
echo "Cannot find gateway interface to use." >&2
exit 1
fi
i=0
while [ -z "$TUNIF" ]; do
if [ -n "$TUNADDR" ]; then
TUNIF=$(ip -f inet -o addr | awk "/ inet $TUNADDR / { print \$2 }")
elif [ -n "$PDPADDR" ]; then
TUNIF=$(ip -f inet -o addr | awk "/ peer $PDPADDR/ { print \$2 }")
else
# The last tunnel interface.
TUNIF=$(ip -f inet -o addr | awk '/ peer / { TUNIF=$2 }
END { print TUNIF }')
fi
if [ -n "$TUNIF" ]; then
break
fi
if [ "$WAIT" != "yes" -o $((i++)) -ge 10 ]; then
echo "Cannot find tunnel interface to use." >&2
exit 1
fi
sleep 5
done
if [ -z "$NAME" ]; then
NAME=$TUNIF # Default unique name.
fi
if [ "$RETURN" == "yes" ]; then
# Since the tunnel may be gone by the time you want to clean up, use
# -wait -return-args to get the identifier beforehand. Then use
# it once right away to set up and once again later with -stop.
echo -name $NAME -tunif $TUNIF -gwif $GWIF
exit
fi
CHAIN="KLH10-${NAME}-FORWARD"
if [ "$STOP" == "yes" ]; then
qecho "Stopping firewall for ${NAME}."
iptables -D FORWARD -j $CHAIN
iptables -F $CHAIN
iptables -X $CHAIN
# echo 0 > /proc/sys/net/ipv4/conf/$TUNIF/forwarding
if [ $(ip -f inet -o addr | grep peer | grep -v $TUNIF | wc -l) -eq 0 ]; then
# Get rid of masquerading and forwarding if there is no other tunnel.
iptables -t nat -F
echo 0 > /proc/sys/net/ipv4/conf/$GWIF/forwarding
elif [ -n "$PDPADDR" ]; then
# Need to do it the hard way: just get rid of nat rules that go to
# the known host. Note that we have to do them in reverse order lest
# the numbering change after the first delete.
RULES=$(iptables -t nat -L --line \
| awk "/^Chain / { CHAIN=\$2 }
/[ :]${PDPADDR}[ :]/ { printf(\"%d:%s\\n\", \$1, CHAIN) }" \
| sort -n -r)
for RULE in $RULES; do
iptables -t nat -D ${RULE##*:} ${RULE%%:*}
done
fi
if [ -n "$IPADDR" ]; then
IPIF=$(ip -f inet -o addr show dev $GWIF \
| awk "/ inet $IPADDR/ { print \$NF }")
if [ -n "$IPIF" ]; then
ifconfig $IPIF down
fi
fi
exit
fi
# Get internet addresses from interfaces.
GWADDR=$(ip -f inet -o addr show dev $GWIF | grep -v secondary | sed 's/^.* inet \([[:digit:].]\+\).*/\1/')
TUNADDR=$(ip -f inet -o addr show dev $TUNIF | sed 's/^.* inet \([[:digit:].]\+\).*/\1/')
PDPADDR=$(ip -f inet -o addr show dev $TUNIF | sed 's/^.* peer \([[:digit:].]\+\).*/\1/')
if [ -z "$GWADDR" ]; then
echo "$GWIF does not appear to be active." >&2
exit 1
fi
if [ -z "$TUNADDR" -o -z "$PDPADDR" ]; then
echo "$TUNIF does not appear to be active." >&2
exit 1
fi
qecho "Setting up firewall for ${NAME} (${TUNIF}: ${TUNADDR} - ${PDPADDR})."
if [ -n "$IPADDR" ]; then
qecho "... using ${IPADDR}."
# Find an unused interface alias.
i=0
while [ $((i++)) -lt 10 ]; do
IPIF=${GWIF}:$i
ip -f inet -o addr show dev $GWIF | grep "secondary $IPIF" >/dev/null
if [ $? -ne 0 ]; then
break
fi
done
ifconfig $IPIF $IPADDR up
# Map to that in both directions.
iptables -t nat -A PREROUTING -i $GWIF -d $IPADDR \
-j DNAT --to-destination $PDPADDR
iptables -t nat -A POSTROUTING -o $GWIF -s $PDPADDR \
-j SNAT --to-source $IPADDR
else
# Turn on masquerading.
iptables -t nat -A POSTROUTING -o $GWIF -j MASQUERADE
fi
iptables -N $CHAIN
iptables -I FORWARD -j $CHAIN
if [ -z "$IPADDR" ]; then
## To PDP-10 side.
for SVC in $SERVICES; do
DSVC=$(decode_service $SVC)
if [ -n "$DSVC" ]; then
PORT=${DSVC%%/*}
PTCL=${DSVC##*/}
qecho "Serving $SVC ($PORT)."
# Translate incoming request into one for PDP-10 ...
iptables -t nat -A PREROUTING -d $GWADDR -p $PTCL --dport $PORT \
-j DNAT --to-destination $PDPADDR:$PORT
iptables -t nat -A OUTPUT -d $GWADDR -p $PTCL --dport $PORT \
-j DNAT --to-destination $PDPADDR:$PORT
# ... and let it pass the firewall.
iptables -A $CHAIN -d $PDPADDR -m state --state NEW -p $PTCL --dport $PORT \
-j LOG --log-prefix [${NAME}-${SVC}-server]
iptables -A $CHAIN -d $PDPADDR -m state --state NEW -p $PTCL --dport $PORT -j ACCEPT
fi
done
fi
## From PDP-10 side.
if [ "$DNS" == "yes" ]; then
if [ -z "$DNSERVER" ]; then
DNSERVER=$(awk '/^nameserver[[:space:]]/ { print $2; exit }' /etc/resolv.conf)
fi
if [ -n "$DNSERVER" ]; then
qecho "Forwarding name service to ${DNSERVER}."
OUTINCLUDE="${OUTINCLUDE} domain" # If disallowing generally, allow this.
iptables -t nat -A PREROUTING -s $PDPADDR -p udp --dport 53 \
-j DNAT --to-destination $DNSERVER
fi
fi
if [ "$OUTBOUND" == "yes" ]; then
qecho "Allowing outbound connections."
for SVC in $OUTEXCLUDE; do
DSVC=$(decode_service $SVC)
if [ -n "$DSVC" ]; then
PORT=${DSVC%%/*}
PTCL=${DSVC##*/}
qecho "... except $SVC ($PORT)."
iptables -A $CHAIN -s $PDPADDR -p $PTCL --dport $PORT \
-j LOG --log-prefix [${NAME}-${SVC}-disallowed]
iptables -A $CHAIN -s $PDPADDR -p $PTCL --dport $PORT -j REJECT
fi
done
# Allow others, with log entry of outbound connection through gateway.
iptables -A $CHAIN -m state --state NEW -i $TUNIF -o $GWIF \
-j LOG --log-prefix [${NAME}-out]
iptables -A $CHAIN -m state --state NEW -i $TUNIF -o $GWIF -j ACCEPT
else
qecho "Disallowing outbound connections."
# Allow continuation of open connection.
iptables -A $CHAIN -m state --state ESTABLISHED,RELATED -i $TUNIF -o $GWIF -j ACCEPT
for SVC in $OUTINCLUDE; do
DSVC=$(decode_service $SVC)
if [ -n "$DSVC" ]; then
PORT=${DSVC%%/*}
PTCL=${DSVC##*/}
qecho "... except $SVC ($PORT)."
iptables -A $CHAIN -s $PDPADDR -p $PTCL --dport $PORT \
-j LOG --log-prefix [${NAME}-${SVC}-out]
iptables -A $CHAIN -s $PDPADDR -p $PTCL --dport $PORT -j ACCEPT
fi
done
# Disallow others, with log entry.
iptables -A $CHAIN -i $TUNIF -o $GWIF \
-j LOG --log-prefix [${NAME}-out-disallowed]
iptables -A $CHAIN -i $TUNIF -o $GWIF -j DROP
fi
# Turn on forwarding.
echo 1 > /proc/sys/net/ipv4/conf/$TUNIF/forwarding
echo 1 > /proc/sys/net/ipv4/conf/$GWIF/forwarding
#!/bin/sh
# Run script for klh10 under Live CD (Debian oriented).
if [ "${1//-}" == "help" ]; then
echo "usage: $0 {ksits,klt10,kst10} [-src dsk_file_dir]... [-ipaddr addr] [-gwaddr gwaddr] [-nogo] [-norun] [-nosave] dsk_file..."
exit 1
fi
# Read-only and read-write installation directories.
INSTDIR=/opt/klh10
WORKDIR=/var/opt/klh10
# Directory under file system root to hold [compressed] disk files.
KDIR=klh10
# Default default.
DEFSYSNAM=ksits
# First arg, if present, is system type.
if [ -n "${1##-*}" ]; then
SYSNAM=$1; shift
fi
# Command option defaults.
DSKSRCS=$(pwd)
LICENSE=yes
GO=yes
RUN=yes
SAVE=maybe
HOLD=no
IPADDR=
GWADDR=
NETOPTS=
FIREWALL=
DEBUG=no
# Parse command line switches.
while [ $# -gt 0 ]; do
if [ "$1" == "${1#-}" ]; then
break
fi
arg=$1; shift
case "$arg" in
-s*)
DSKSRCS="$DSKSRCS $1"
shift;;
-ip*)
IPADDR=$1
shift;;
-gw*)
GWADDR=$1
shift;;
-nog*)
GO=no;;
-nor*)
RUN=no;;
-nos*)
SAVE=no;;
-hold)
HOLD=yes;;
-d*)
DEBUG=yes;;
*)
echo "Unknown switch: $arg"
exit 1;;
esac
done
function decho {
if [ "$DEBUG" == yes ]; then
echo $*
fi
}
# Remaining positional parameters are disk files to substitute.
DSKS=$*
# These variables can be set in init file.
INIVARS="DEFSYSNAM DEFDSKSRCS DEFSAVEDIR AGREELICENSE DEFIPADDRS"
declare $INIVARS
if [ -f ~/.klh10-live ]; then
# Read init file.
. ~/.klh10-live
fi
function do_exit {
# Save updated init file.
declare -p $INIVARS | sed 's/declare -. //' >~/.klh10-live
# Don't close window before user can see final message(s).
if [ "$HOLD" == yes ]; then
read -p "[Close this window]"
fi
exit $*
}
DSKSRCS="$DSKSRCS $DEFDSKSRCS"
function free_space {
df -P -B1 $* | awk '{ if (FNR > 1) print $4 }'
}
# Mount any unmounted user-mountable file systems read-only.
# Keep them mounted if there is a KDIR directory or some free space
# should they be remounted read-write.
function try_mount {
local FS=$1 TYPE=$2 FDSK
grep " $FS " /etc/mtab >/dev/null
if [ $? -eq 0 ]; then
decho "${FS} already mounted."
return 0
fi
mount -o ro $FS >/dev/null 2>&1
if [ $? -ne 0 ]; then
decho "${FS} mount failed."
return $?
fi
if [ -d ${FS}/${KDIR} ]; then
decho "${FS} has a ${KDIR} directory."
return 0
fi
case $TYPE in
ext2|ext3)
;;
vfat|msdos)
;;
*)
decho "${FS} is not useable for write."
umount $FS >/dev/null 2>&1
return $?;;
esac
if [ $(free_space $FS) -lt 200000000 ]; then
decho "${FS} does not have enough free space."
umount $FS >/dev/null 2>&1
return $?
fi
decho "${FS} mounted."
}
# To find the boot cdrom, either it needs to appear in mtab already or
# to be mountable from fstab. KNOPPIX is the former case: /cdrom is
# the full file system, even though a different unmountable (unless
# toram) entry appears for the cd device in fstab. SLAX is the
# latter: the cd is already mounted somewhere under /mnt/live without
# appearing in mtab; but after mounting again based on the fstab
# entry, it is all there too.
TMPF=/tmp/fstab.$$
awk 'function inarray(x, a) { for (e in a) if (a[e] == x) return 1 }
/\/dev/ { split($4,o,",")
if (inarray("noauto", o) &&
(inarray("users", o) || inarray("user", o)) &&
!match($2,"floppy"))
print "try_mount",$2,$3 }' /etc/fstab >$TMPF
. $TMPF
rm -f $TMPF
# Look for disk files in [newly] mounted file systems.
for FSDIR in $(awk '{ print $2 }' /etc/mtab); do
FSDSK=${FSDIR}/${KDIR}
if [ -d $FSDSK ]; then
decho "${FSDSK} exists."
DSKSRCS="$DSKSRCS $FSDSK"
fi
done
# Load system declaration.
cd ${INSTDIR}/live
if [ -z "$SYSNAM" ]; then
# Default from last time.
SYSNAM=$DEFSYSNAM
# Simple menu of possible systems.
for LSYSNAM in *; do
( . ./${LSYSNAM}; echo "$LSYSNAM $DESC" )
done
read -p "Choose a system to run: [${SYSNAM}] "
if [ -n "$REPLY" ]; then
SYSNAM=$REPLY
fi
fi
if [ ! -x ./${SYSNAM} ]; then
echo "Not a KLH10 system name: '${SYSNAM}'"
do_exit 1
fi
. ./${SYSNAM}
echo $DESC
DEFSYSNAM=$SYSNAM
if [ "$AGREELICENSE" != yes -a "$LICENSE" != no ]; then
echo "Use of this system is covered by the DEC 36-bit hobbyist license."
echo "See http://www.36bit.org/dec/license.html."
echo "Confirm that you are following the terms of that license."
read -p "[Confirm]"
AGREELICENSE=yes
fi
cd $WORKDIR
if [ -d "$SYSNAM" ]; then
cd $SYSNAM
else
decho "Creating ${WORKDIR}/${SYSNAM}."
mkdir $SYSNAM
cd $SYSNAM
# For convenience, fill the directory with symlinks to the executables.
# This, rather than setting PATH, so that it can be run again later
# without this script as just ./kn10.
find ${INSTDIR}/bin/${KN10%/*} -type f -exec ln -s {} . \;
mv ${KN10##*/} kn10
find ${INSTDIR}/bin -maxdepth 1 -type f -exec ln -s {} . \;
for PFILE in $(awk '/^load / { print $2 }
/^devmount / { print $3 }' ${INSTDIR}/run/${PROTO}); do
if [ "$PFILE" == "${PFILE#/}" ]; then
# Make absolute.
PFILE=${INSTDIR}/run/${PROTO%/*}/${PFILE}
fi
ln -s $PFILE .
done
fi
if [ -z "$DSKS" ]; then
# Default disk files to substitute.
DSKS=$DEFDSKS
fi
DSKDEST=$(pwd)
NEWDIRS=
# Find the necessary disk files someplace.
i=0
for DSK in $DSKS; do
decho "Looking for ${DSK}."
if [ "$DSK" == "${DSK#/*}" ]; then
# Relative pathname: take from a source.
for DSKSRC in $DSKSRCS ==END==; do
if [ "$DSKSRC" == ==END== ]; then
echo "dsk${i}: Cannot find file: ${DSK}"
do_exit 1
fi
decho "Trying ${DSKSRC}."
SDSK=${DSKSRC}/${DSK}
if [ -r "$SDSK" ]; then
DSK=$SDSK
break;
fi
ZDSK=${SDSK}.gz
if [ -r "$ZDSK" ]; then
DSK=$ZDSK
break;
fi
ZDSK=${SDSK}.bz2
if [ -r "$ZDSK" ]; then
DSK=$ZDSK
break;
fi
done
fi
decho "Found ${DSK}."
shopt -s extglob
ZDSK=${DSK%@(.gz|.bz2)}
if [ -w $DSK -a $ZDSK == $DSK ]; then
echo "dsk${i}: Using file ${DSK}."
else
# Decided to make a copy; see whether there is one already.
COPY=$(basename $ZDSK)
if [ -w $COPY ]; then
echo "dsk${i}: Using previous copy of ${COPY}."
else
echo "dsk${i}: Making a writeable copy from ${DSK}."
if [ $DSK == $ZDSK ]; then
SIZE=$(ls -l $DSK | awk '{print $5}')
elif [ $DSK == ${ZDSK}.gz ]; then
SIZE=$(gzip -l $DSK | awk '{ if (FNR > 1) print $2 }')
elif [ $DSK == ${ZDSK}.bz2 ]; then
SIZE=$(bzip2 -d -c $DSK | wc -c)
fi
while [ $(free_space $DSKDEST) -lt $SIZE ]; do
a=($(df -P -h $DSKDEST | awk '{ if (FNR > 1) print $4,$1 }'))
echo "There is not enough free space in ${DSKDEST} (${a[1]})."
echo "Need $((SIZE / 1000000))M; have only ${a[0]}."
FSDEVS=$(df -P -T -B1 | tail +2 | sort -k5 -r \
| awk -v SIZE=${SIZE} \
'/\/dev\// { if (match($2,"ext2|ext3|vfat|msdos") && ($5 > SIZE))
print $1 }')
if [ -z "$FSDEVS" ]; then
echo "There are no file systems with enough free space."
echo "You can use file system tools to delete some files"
echo "or disk partition tools to create a new EXT or FAT file system."
else
df -h -T $FSDEVS
a=($FSDEVS)
DSKDEST=$(awk "/^${a[0]//\//\\/} / { print \$2 }" /etc/mtab)/${KDIR}
fi
read -p "Copy to directory: [${DSKDEST}] "
if [ -n "$REPLY" ]; then
DSKDEST=$REPLY
fi
FSDSK=$DSKDEST
# Need to get the mount point for the destination to remount it, but the subdirectory
# may not exist yet and cannot be created first.
while [ ! -d $FSDSK ]; do
FSDSK=${FSDSK%/*}
if [ -z "$FSDSK" ]; then
FSDSK=/
break
fi
done
FSDEV=$(df -P -T $FSDSK \
| awk 'function inarray(x, a) { for (e in a) if (a[e] == x) return 1 }
{ if (ARGIND == 1) { if (FNR > 1) FSDEV=$1 }
else {
if ($1 == FSDEV) {
if ($3 == "ntfs") exit 1 # Refuse to mount NTFS R/W.
split($4,o,",")
if (inarray("ro", o)) print FSDEV
exit
} } }' - /etc/mtab)
if [ -n "$FSDEV" ]; then
decho "Remounting ${FSDEV} read-write."
mount -o rw,remount $FSDEV
if [ $? -ne 0 ]; then
do_exit $?
fi
fi
if [ ! -d $DSKDEST ]; then
mkdir -p -v ${DSKDEST}
if [ $? -ne 0 ]; then
do_exit $?
fi
NEWDIRS="$NEWDIRS $DSKDEST"
fi
done
if [ $DSKDEST == $(pwd) ]; then
DDSK=$COPY
else
DDSK=${DSKDEST}/${COPY}
fi
if [ $DSK == $ZDSK ]; then
cp $DSK $DDSK
elif [ $DSK == ${ZDSK}.gz ]; then
gunzip -c $DSK >$DDSK
elif [ $DSK == ${ZDSK}.bz2 ]; then
bzip2 -d -c $DSK >$DDSK
fi
if [ $? -ne 0 ]; then
do_exit $?
fi
if [ $DDSK != $COPY ]; then
ln -s $DDSK $COPY
fi
fi
if [ -w $DSK ]; then
# If copied compressed file from writeable store, then default
# to save it back compressed there.
DEFSAVEDIR=${DSK%/*}
fi
DSK=$COPY
COPIES="$COPIES $COPY"
fi
# Prototype file may use default disk file name, so remove any path
# and then add correct one.
SEDCMD="$SEDCMD
{ /^devdef dsk$((i++))/ { s/path=[^[:space:]]\\+//
s|$| path=${DSK}| } }"
done
# Find address of this machine (the host).
while true; do
MYIPADDR=$(ip -o addr | awk '/ inet .* global / { print $4 }')
MYIPADDR=${MYIPADDR%%/*} # Remove any subnet mask size.
if [ -n "$MYIPADDR" ]; then
break
fi
echo "This machine does not seem to have a TCP-IP address."
echo "Without it, the PDP-10 will only be able to talk to this machine."
echo "It may be that WiFi still needs to be configured. You can do that now."
read -p "Retry? (y/n) [n]"
case "$REPLY" in
y*)
;;
*)
break;;
esac
done
if [ -n "$NETOPTS" ]; then
# Set all network interface options.
SEDCMD="$SEDCMD
{ s|ipaddr=.*\$|${NETOPTS}| }"
else
# Look for an active device wanting an internet address.
a=($(sed -e '/^devdef .* lhdh /s/^.*ipaddr=\([^[:space:]]*\) gwaddr=\([^[:space:]]*\).*/\1 \2/p
/^devdef .* ni20 /s/^.*ipaddr=\([^[:space:]]*\).*/\1/p
d' ${INSTDIR}/run/${PROTO}))
n=${#a[@]}
if [ $n -gt 0 ]; then
if [ $n -ge 2 ]; then
# If tunnelling, just need a gateway. Default to host address.
if [ -z "$GWADDR" ]; then
GWADDR=$MYIPADDR
fi
elif [ -n "$MYIPADDR" ]; then
# Sharing the interface, need an address.
while true; do
if [ -n "$IPADDR" ]; then
if [ "$IPADDR" == "$MYIPADDR" ]; then
echo "$IPADDR is the address of this machine. That will not work."
else
echo "You should make sure that SYSTEM:INTERNET.ADDRESS looks like this:"
echo "IPNI#0,${IPADDR//./ },DEFAULT,PREFERRED,PACKET-SIZE:1500"
break
fi
fi
IPADDR=$(declare $DEFIPADDRS _dummy; eval echo \$$SYSNAM)
if [ -z "$IPADDR" ]; then
IPADDR="$a"
fi
echo "Need a TCP-IP address for the PDP-10. This machine is ${MYIPADDR}."
echo "It should be a different address on the same subnet,"
echo "not in use by any real machine."
read -p "IP address: [${IPADDR}] "
if [ -n "$REPLY" ]; then
IPADDR=$REPLY
fi
done
DEFIPADDRS=$(echo $(env -i $DEFIPADDRS $SYSNAM=$IPADDR env))
fi
fi
if [ -n "$IPADDR" ]; then
SEDCMD="$SEDCMD
{ s/\(ipaddr\)=\([^[:space:]]*\)/\1=${IPADDR}/ }"
fi
if [ -n "$GWADDR" ]; then
SEDCMD="$SEDCMD
{ s/\(gwaddr\)=\([^[:space:]]*\)/\1=${GWADDR}/ }"
fi
fi
# Substitute local settings into prototype init file.
sed -e "$SEDCMD" ${INSTDIR}/run/${PROTO} >klh10.ini
if [ "$GO" != no ]; then
echo 'go' >>klh10.ini
fi
# Will probably need the TUN/TAP device; make sure it's there.
if [ ! -e /dev/net/tun ]; then
(cd /dev;
if [ -x MAKEDEV ]; then
./MAKEDEV tun
else
mkdir net; mknod net/tun c 10 200
fi)
fi
if [ "$RUN" == no ]; then
do_exit
fi
FIREWALL_ARGS=./firewall.$$
rm -f $FIREWALL_ARGS
if [ -z "$MYIPADDR" ]; then
# Cannot have a firewall without a global network.
FIREWALL=
fi
function firewall_bg {
# In the background, wait for the tun interface to exist and set forwarding.
# Note that typeout at this point is with a funny tty setting.
./klh10-firewall -ini -name $SYSNAM -wait -return >$FIREWALL_ARGS
./klh10-firewall -ini $(< $FIREWALL_ARGS) $FIREWALL \
| awk '{ printf("%s\r\n", $0) }'
exit;
}
if [ -n "$(type -p iptables)" -a -n "$FIREWALL" ]; then
if [ -z "$IPADDR" ]; then
IPADDR=$(declare $DEFIPADDRS _dummy; eval echo \$$SYSNAM)
if [ -z "$IPADDR" ]; then
IPADDR=$MYIPADDR
fi
echo "Need a TCP-IP address for the PDP-10. This machine is ${MYIPADDR}."
echo "That address can be shared, in which case most services will be"
echo "forwarded to the PDP-10 and not handled by UNIX."
echo "Or you can choose a different address just for the PDP-10,"
echo "on the same subnet, but not in use by any real machine."
read -p "IP address: [${IPADDR}] "
if [ -n "$REPLY" ]; then
IPADDR=$REPLY
fi
fi
if [ "$IPADDR" != "$MYIPADDR" ]; then
FIREWALL="-ipaddr $IPADDR $FIREWALL"
DEFIPADDRS=$(echo $(env -i $DEFIPADDRS $SYSNAM=$IPADDR env))
fi
firewall_bg&
fi
./kn10
if [ -r $FIREWALL_ARGS ]; then
./klh10-firewall -ini $(< $FIREWALL_ARGS) $FIREWALL -stop
rm $FIREWALL_ARGS
fi
if [ "$SAVE" == no ]; then
do_exit
fi
# Save back updated disk images.
for DSK in $COPIES; do
while true; do
read -p "Save ${DSK}? (y/n/d) [n]"
case "$REPLY" in
y*)
;;
d*)
if [ -h $DSK ]; then
rm $(readlink $DSK)
fi
rm $DSK
break;;
*)
break;;
esac
ZDSK=
if [ -n "$DEFSAVEDIR" ]; then
ZDSK=${DEFSAVEDIR}/${DSK}.gz
fi
PRM="Save ${DSK} to: "
if [ -n "$ZDSK" ]; then
PRM="$PRM [$ZDSK] "
fi
read -e -p "$PRM"
if [ -n "$REPLY" ]; then
ZDSK=$REPLY
fi
if [ -z "$ZDSK" ]; then
continue
fi
gzip -c $DSK >$ZDSK
if [ $? -eq 0 ]; then
ls -l $ZDSK
break
fi
DEFSAVEDIR=${ZDSK%/*}
done
done
for NEWDIR in $NEWDIRS; do
if [ $(ls -A $NEWDIR | wc -l) -eq 0 ]; then
read -p "Delete empty directory ${NEWDIR}? (y/n) [y]"
case "$REPLY" in
n*)
;;
*)
rmdir $NEWDIR;;
esac
fi
done
do_exit
#!/bin/sh
# Find the address of the remote end of the tunnel for telnet, etc.
for (( i = 0; i < 10; i++ )) do
# Get the last ptp interface.
# Stick to POSIX: awk might be busybox (and gawk mawk).
TUNADDR=$(ip -f inet -o addr \
| awk '{ if (match($0,"peer [0-9.]+"))
TUNADDR = substr($0,RSTART+5,RLENGTH-5) }
END { print TUNADDR }')
if [ -n "$TUNADDR" ]; then
echo $TUNADDR
exit
fi
if [ $i -eq 0 ]; then
echo 'Waiting for tunnel to open...' >&2
fi
sleep 5
done
echo 'Giving up' >&2
echo 192.168.0.203
exit 1
*** klh10-2.0h/src/dvlites.c 2005-02-22 02:19:13.000000000 -0500
--- klh10-2.0i/src/dvlites.c 2005-09-19 22:37:10.000000000 -0400
***************
*** 31,39 ****
#if KLH10_DEV_LITES /* Moby conditional for entire file */
! #include <asm/io.h>
#include "dvlites.h"
!
/* Internal function prototypes */
--- 31,44 ----
#if KLH10_DEV_LITES /* Moby conditional for entire file */
! #include "klh10.h"
! #include <stdio.h>
! #include <string.h>
! #include <errno.h>
! #include <sys/io.h>
! #include <sys/shm.h>
#include "dvlites.h"
! #include "prmstr.h" /* For parameter parsing */
/* Internal function prototypes */
***************
*** 278,284 ****
}
}
! /* Routines specific to the primary display lights */
static unsigned char byte0 = 0; /* save of aux bits and high 4 pgm lites */
--- 283,295 ----
}
}
! /* Routines using the primary display lights */
!
! static int debug = 0;
!
! static int shmid = 0;
!
! static shm_lights *shmp = NULL;
static unsigned char byte0 = 0; /* save of aux bits and high 4 pgm lites */
***************
*** 290,304 ****
void lights_pgmlites (unsigned long lh,unsigned long rh)
{
! unsigned char data[5];
! lites_setdisplay (UNIT_PGM); /* select program display lights unit */
! /* calculate MSB with aux bits */
! byte0 = data[0] = ((lh >> 14) & 0xf) | (byte0 & 0xe0);
! data[1] = (lh >> 6) & 0xff; /* calculate other bytes */
! data[2] = ((lh << 2) | (rh >> 16)) & 0xff;
! data[3] = (rh >> 8) & 0xff;
! data[4] = rh & 0xff;
! lites_data (data); /* send data */
}
--- 301,324 ----
void lights_pgmlites (unsigned long lh,unsigned long rh)
{
! if (debug) {
! fprintf(stderr, "[lights_pgmlites: %lo,,%lo]\n", lh, rh);
! }
! if (port) {
! unsigned char data[5];
! lites_setdisplay (UNIT_PGM); /* select program display lights unit */
! /* calculate MSB with aux bits */
! byte0 = data[0] = ((lh >> 14) & 0xf) | (byte0 & 0xe0);
! data[1] = (lh >> 6) & 0xff; /* calculate other bytes */
! data[2] = ((lh << 2) | (rh >> 16)) & 0xff;
! data[3] = (rh >> 8) & 0xff;
! data[4] = rh & 0xff;
! lites_data (data); /* send data */
! }
! if (shmp) {
! shmp->lh = lh;
! shmp->rh = rh;
! }
}
***************
*** 307,315 ****
void lights_pgmaux (unsigned char aux)
{
! lites_setdisplay (UNIT_PGM); /* select program display lights unit */
! /* rewrite just the MSB */
! lites_wreg (REG_DATA_MSB,byte0 = (byte0 & 0xf) | ((aux & 0x7) << 5));
}
--- 327,343 ----
void lights_pgmaux (unsigned char aux)
{
! if (debug) {
! fprintf(stderr, "[lights_pgmaux: %X]\n", (int)aux);
! }
! if (port) {
! lites_setdisplay (UNIT_PGM); /* select program display lights unit */
! /* rewrite just the MSB */
! lites_wreg (REG_DATA_MSB,byte0 = (byte0 & 0xf) | ((aux & 0x7) << 5));
! }
! if (shmp) {
! shmp->aux = aux;
! }
}
***************
*** 322,330 ****
state |= (cpu ? STATUS_LED1 : 0) | (disk ? STATUS_LED2 : 0) |
(tape ? STATUS_LED3 : 0) | (net ? STATUS_LED4 : 0);
if (push) { /* push the state? */
! lites_status (state); /* yes, do so */
state = 0; /* clear state for next time */
}
}
#endif /* KLH10_DEV_LITES */
--- 350,494 ----
state |= (cpu ? STATUS_LED1 : 0) | (disk ? STATUS_LED2 : 0) |
(tape ? STATUS_LED3 : 0) | (net ? STATUS_LED4 : 0);
if (push) { /* push the state? */
! if (debug) {
! fprintf(stderr, "[lights_status: %X]\n", (int)state);
! }
! if (port) {
! lites_status (state); /* yes, do so */
! }
! if (shmp) {
! shmp->status = state;
! }
state = 0; /* clear state for next time */
}
}
+
+ /* Command parsing */
+
+ #define DVLITES_PARAMS \
+ prmdef(LTP_PORT,"PORT"), /* Port I/O address */\
+ prmdef(LTP_SHM, "shm"), /* Shared memory file name */\
+ prmdef(LTP_DBG, "debug") /* Debug trace */
+
+ enum {
+ # define prmdef(i,s) i
+ DVLITES_PARAMS
+ # undef prmdef
+ };
+
+ static char *ltprmtab[] = {
+ # define prmdef(i,s) s
+ DVLITES_PARAMS
+ # undef prmdef
+ , NULL
+ };
+
+ void lights_open (char *args)
+ {
+ struct prmstate_s prm;
+ char buff[200];
+ int i;
+
+ int prt = 0;
+ key_t key = (key_t)-1;
+ int okay = TRUE;
+
+ prm_init(&prm, buff, sizeof(buff),
+ args, strlen(args),
+ ltprmtab, sizeof(ltprmtab[0]));
+ while ((i = prm_next(&prm)) != PRMK_DONE) {
+ switch (i) {
+ case PRMK_NONE:
+ fprintf(stderr, "Unknown lights parameter \"%s\"\n", prm.prm_name);
+ okay = FALSE;
+ continue;
+ case PRMK_AMBI:
+ fprintf(stderr, "Ambiguous lights parameter \"%s\"\n", prm.prm_name);
+ okay = FALSE;
+ continue;
+ default: /* Handle matches not supported */
+ fprintf(stderr, "Unsupported lights parameter \"%s\"\n", prm.prm_name);
+ okay = FALSE;
+ continue;
+
+ case LTP_DBG: /* Parse as true/false boolean or number */
+ if (!prm.prm_val) /* No arg => default to 1 */
+ debug = 1;
+ else if (!s_tobool(prm.prm_val, &debug))
+ break;
+ continue;
+
+ case LTP_PORT:
+ if (!prm.prm_val) { /* No arg => default to LPT1 */
+ prt = 0x378;
+ continue;
+ }
+ else {
+ char *sloc = prm.prm_val;
+ int c;
+ while(isxdigit(c = *sloc++)) {
+ prt *= 16;
+ prt += c - (isdigit(c) ? '0' : (islower(c) ? 'a' : 'A'));
+ }
+ if (!c) switch(prt) {
+ case 0x378: /* LPT1 */
+ case 0x278: /* LPT2 */
+ continue;
+ }
+ }
+ break;
+
+ case LTP_SHM:
+ if (NULL == strchr(prm.prm_val, '/')) {
+ key = (key_t)strtoul(prm.prm_val, NULL, 0);
+ if (key == (key_t)0) {
+ fprintf(stderr, "Invalid shm key \"%s\"\n", prm.prm_val);
+ okay = FALSE;
+ }
+ }
+ else {
+ key = ftok(prm.prm_val, '0');
+ if (key == (key_t)-1) {
+ fprintf(stderr, "Cannot find shm file \"%s\"\n", prm.prm_val);
+ okay = FALSE;
+ }
+ }
+ continue;
+ }
+ okay = FALSE;
+ fprintf(stderr, "lights param \"%s\": ", prm.prm_name);
+ if (prm.prm_val)
+ fprintf(stderr, "bad value syntax: \"%s\"\n", prm.prm_val);
+ else
+ fprintf(stderr, "missing value\n");
+ }
+ if (!okay) return;
+
+ // There could be an option to say which display to use, rather than
+ // always UNIT_PGM. But then some kind of global mutex would be
+ // needed around the lites_setdisplay and data output.
+
+ if (prt) {
+ if (!lites_init(prt)) {
+ fprintf(stderr, "?Can't init lights -- probably not root\n");
+ }
+ }
+
+ if (key != (key_t)-1) {
+ shmid = shmget(key, sizeof(shm_lights), IPC_CREAT | 0666);
+ if (shmid == -1) {
+ fprintf(stderr, "Cannot get lights shared memory.\n");
+ }
+ shmp = (shm_lights *)shmat(shmid, NULL, 0);
+ }
+ }
+
+ void lights_close ()
+ {
+ if (shmp) {
+ shmdt(shmp);
+ }
+ }
+
#endif /* KLH10_DEV_LITES */
*** klh10-2.0h/src/dvlites.h 2005-02-22 02:19:13.000000000 -0500
--- klh10-2.0i/src/dvlites.h 2005-09-07 10:47:35.000000000 -0400
***************
*** 17,23 ****
#if KLH10_DEV_LITES /* Moby conditional */
! /* General routines for all displays */
/* one-time initialize and set port */
int lites_init (unsigned int prt);
--- 17,34 ----
#if KLH10_DEV_LITES /* Moby conditional */
! /* Device routines using Panda display 0 and/or shared memory */
!
! /* open lights */
! void lights_open (char *args);
! /* write program status lights */
! void lights_pgmlites (unsigned long lh,unsigned long rh);
! /* write program auxillary lights */
! void lights_pgmaux (unsigned char aux);
! /* system heartbeat */
! void lights_status (char cpu,char disk,char tape,char net,char push);
!
! /* Panda routines for all displays */
/* one-time initialize and set port */
int lites_init (unsigned int prt);
***************
*** 36,50 ****
#define STATUS_LED4 0x10 /* status LED4 */
#define STATUS_LEDS (STATUS_LED1 | STATUS_LED2 | STATUS_LED3 | STATUS_LED4)
- /* Specific routines for display 0 */
-
- /* write program status lights */
- void lights_pgmlites (unsigned long lh,unsigned long rh);
- /* write program auxillary lights */
- void lights_pgmaux (unsigned char aux);
- /* system heartbeat */
- void lights_status (char cpu,char disk,char tape,char net,char push);
#else /* KLH10_DEV_LITES */
#define lights_pgmlites(lh,rh)
#define lights_pgmaux(aux)
--- 47,57 ----
#define STATUS_LED4 0x10 /* status LED4 */
#define STATUS_LEDS (STATUS_LED1 | STATUS_LED2 | STATUS_LED3 | STATUS_LED4)
+ typedef struct {
+ unsigned long lh, rh;
+ unsigned char aux, status;
+ } shm_lights;
#else /* KLH10_DEV_LITES */
#define lights_pgmlites(lh,rh)
#define lights_pgmaux(aux)
*** klh10-2.0h/src/klh10.c 2005-02-22 02:20:34.000000000 -0500
--- klh10-2.0i/src/klh10.c 2005-09-04 14:49:43.000000000 -0400
***************
*** 325,332 ****
"[<devid>] [<secs>]",
"Wait for device (or all devs)", "")
#if KLH10_DEV_LITES
! CMDDEF(cd_lights, fc_lights, CMRF_TLIN, "<hexaddr>",
! "Set console lights I/O base address", "")
#endif
--- 325,332 ----
"[<devid>] [<secs>]",
"Wait for device (or all devs)", "")
#if KLH10_DEV_LITES
! CMDDEF(cd_lights, fc_lights, CMRF_TLIN, "[port=<hexaddr>] [shm=<file>]",
! "Set console lights mode", "")
#endif
***************
*** 2759,2788 ****
}
! /* FC_LIGHTS - Sets console lights I/O base address
! ** Currently only allow LPT1 and LPT2 ports on PC.
*/
static void
fc_lights(struct cmd_s *cm)
{
! unsigned long port = 0;
! int c;
! char *sloc = cm->cmd_arglin;
!
! if (sloc && *sloc) {
! while(isxdigit(c = *sloc++)) {
! port *= 16;
! port += c - (isdigit(c) ? '0' : (islower(c) ? 'a' : 'A'));
! }
! if (!c) switch(port) {
! case 0x378: /* LPT1 */
! case 0x278: /* LPT2 */
! if (!lites_init((unsigned int) port))
! printf("?Can't init lights -- probably not root\n");
! return;
! }
! }
! printf("?Bad address\n");
}
/* Instruction printing routines */
--- 2759,2770 ----
}
! /* FC_LIGHTS - Sets console lights mode.
*/
static void
fc_lights(struct cmd_s *cm)
{
! lights_open(cm->cmd_arglin);
}
/* Instruction printing routines */
*** supdup/Makefile.orig Mon Jun 28 19:17:04 2004
--- supdup/Makefile Sat Jul 30 00:37:31 2005
***************
*** 8,11 ****
# DEBUG
supdup: supdup.c termcaps.h
! cc -g -o supdup -DTERMCAP supdup.c -ltermcap
--- 8,11 ----
# DEBUG
supdup: supdup.c termcaps.h
! cc -g -o supdup -DTERMCAP supdup.c -lncurses
*** supdup/supdup.c.orig Sun Jun 27 18:00:28 2004
--- supdup/supdup.c Sat Jul 30 00:29:46 2005
***************
*** 1906,1911 ****
--- 1906,1916 ----
argp[1] ++; /* Increment the following arg, too! */
break;
+ case 'p': /* %p means push nth arg. */
+ tem = *p++ - '1';
+ argp = oargp + tem;
+ break;
+
case '%': /* %% means output %; no arg. */
goto ordinary;
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/shm.h>
typedef struct {
unsigned long lh, rh;
unsigned char aux, status;
} shm_lights;
int main(int argc, char **argv)
{
int count = 1;
int delay = 10;
key_t key;
int shmid;
shm_lights *shmp;
if (argc < 2) {
printf("Usage: %s [file f] [read] [count n] [delay ms] [clear] [lh n] [rh n] [aux n] [status n]\n", argv[0]);
return 1;
}
int i = 1;
while (i < argc) {
const char *arg = argv[i++];
if (!strcmp(arg, "file")) {
const char *file = argv[i++];
if (NULL == strchr(file, '/')) {
key = (key_t)strtoul(file, NULL, 0);
if (key == (key_t)0) {
fprintf(stderr, "Invalid shm key \"%s\"\n", file);
return 1;
}
}
else {
key = ftok(file, '0');
if (key == (key_t)-1) {
fprintf(stderr, "Cannot find shm file \"%s\"\n", file);
return 1;
}
}
shmid = shmget(key, sizeof(shm_lights), IPC_CREAT | 0666);
if (shmid == -1) {
fprintf(stderr, "Cannot get lights shared memory.\n");
return 1;
}
shmp = (shm_lights *)shmat(shmid, NULL, 0);
if (shmp == NULL) {
fprintf(stderr, "Cannot attach lights shared memory.\n");
return 1;
}
}
else if (!strcmp(arg, "read")) {
int n = count;
while (n-- > 0) {
printf("Lights = %lo,,%lo\nAux=%X\nStatus=%X\n\n",
shmp->lh, shmp->rh, (int)shmp->aux, (int)shmp->status);
usleep(delay);
}
}
else if (!strcmp(arg, "count")) {
count = atoi(argv[i++]);
}
else if (!strcmp(arg, "delay")) {
delay = atoi(argv[i++]) * 1000;
}
else if (!strcmp(arg, "clear")) {
memset(shmp, 0, sizeof(shm_lights));
}
else if (!strcmp(arg, "lh")) {
shmp->lh = strtoul(argv[i++], NULL, 0);
}
else if (!strcmp(arg, "rh")) {
shmp->rh = strtoul(argv[i++], NULL, 0);
}
else if (!strcmp(arg, "aux")) {
shmp->aux = (char)strtoul(argv[i++], NULL, 0);
}
else if (!strcmp(arg, "status")) {
shmp->status = (char)strtoul(argv[i++], NULL, 0);
}
else {
fprintf(stderr, "Unknown keyword \"%s\"\n", arg);
return 1;
}
}
return 0;
}
*** klh10-2.0h/bld/lnx86/00build 2005-02-22 02:47:02.000000000 -0500
--- klh10-2.0i/bld/lnx86/00build 2005-09-10 01:05:48.000000000 -0400
***************
*** 1,2 ****
#!/bin/sh
! make base-kl CONFFLAGS_AUX=-DKLH10_I_CIRC=1 LDFLAGS=-static
--- 1,2 ----
#!/bin/sh
! make -k base-kl CONFFLAGS_AUX="-DKLH10_NET_TUN=1 -DKLH10_I_CIRC=1"
*** klh10-2.0h/src/dpimp.c 2003-02-23 13:07:35.000000000 -0500
--- klh10-2.0i/src/dpimp.c 2005-09-11 10:14:55.000000000 -0400
***************
*** 279,285 ****
--- 279,289 ----
struct in_addr ihost_ip; /* IMP/Native host IP addr, net order */
struct in_addr ihost_nm; /* IMP/Native host subnet netmask, net order */
struct in_addr ihost_net; /* IMP/Native host net #, net order */
+ #if KLH10_NET_TUN
+ struct in_addr tun_ip; /* IP addr of tunnel */
+ #else
struct in_addr gwdef_ip; /* IP addr of default prime gateway */
+ #endif
struct ether_addr ehost_ea; /* Emulated host ethernet addr */
struct ether_addr ihost_ea; /* IMP/Native host ethernet addr */
***************
*** 497,503 ****
--- 501,511 ----
shared DP area.
*/
memcpy((void *)&ehost_ip, dpimp->dpimp_ip, 4); /* Host IP addr */
+ #if KLH10_NET_TUN
+ memcpy((void *)&tun_ip, dpimp->dpimp_tun, 4); /* Tunnel addr */
+ #else
memcpy((void *)&gwdef_ip, dpimp->dpimp_gw, 4); /* Default GW addr */
+ #endif
memcpy((void *)&ehost_ea, dpimp->dpimp_eth, 6); /* Host Ether addr */
/* IMP must always have IP address specified! */
***************
*** 555,560 ****
--- 563,569 ----
char ipbuf[OSN_IPSTRSIZ];
char eabuf[OSN_EASTRSIZ];
+ #if !KLH10_NET_TUN
dbprintln("ifc \"%s\" => ether %s",
dpimp->dpimp_ifnam,
eth_adrsprint(eabuf, (unsigned char *)&ihost_ea));
***************
*** 564,573 ****
ip_adrsprint(ipbuf, (unsigned char *)&ihost_nm));
dbprintln(" net %s",
ip_adrsprint(ipbuf, (unsigned char *)&ihost_net));
- dbprintln(" HOST: %s",
- ip_adrsprint(ipbuf, (unsigned char *)&ehost_ip));
dbprintln(" gwdef %s",
ip_adrsprint(ipbuf, (unsigned char *)&gwdef_ip));
}
/* Init ARP stuff - ensure can talk to native host.
--- 573,588 ----
ip_adrsprint(ipbuf, (unsigned char *)&ihost_nm));
dbprintln(" net %s",
ip_adrsprint(ipbuf, (unsigned char *)&ihost_net));
dbprintln(" gwdef %s",
ip_adrsprint(ipbuf, (unsigned char *)&gwdef_ip));
+ #else
+ dbprintln("ifc \"%s\"",
+ dpimp->dpimp_ifnam);
+ dbprintln(" tun %s",
+ ip_adrsprint(ipbuf, (unsigned char *)&tun_ip));
+ #endif
+ dbprintln(" HOST %s",
+ ip_adrsprint(ipbuf, (unsigned char *)&ehost_ip));
}
/* Init ARP stuff - ensure can talk to native host.
***************
*** 622,627 ****
--- 637,644 ----
{
struct ifreq ifr;
+ #if !KLH10_NET_TUN
+
#if 1 /* This code is identical to dpni20 - merge in osdnet? */
/* Ensure network device name, if specified, isn't too long */
***************
*** 678,683 ****
--- 695,702 ----
if (gwdef_ip.s_addr == -1 || gwdef_ip.s_addr == 0)
efatal(1, "No default prime gateway specified");
+ #endif
+
/* Set up appropriate net fd and packet filter.
** Should also determine interface's ethernet addr, if possible,
** and set ihost_ea.
***************
*** 690,701 ****
--- 709,726 ----
npf.osnpf_rdtmo = dpimp->dpimp_rdtmo;
npf.osnpf_backlog = dpimp->dpimp_backlog;
npf.osnpf_ip.ia_addr = ehost_ip;
+ #if KLH10_NET_TUN
+ npf.osnpf_tun.ia_addr = tun_ip;
+ #endif
/* Ether addr is both a potential arg and a returned value;
the packetfilter open may use and/or change it.
*/
ea_set(&npf.osnpf_ea, dpimp->dpimp_eth); /* Set requested ea if any */
pffd = osn_pfinit(&npf, (void *)dpimp); /* Will abort if fails */
ea_set(&ihost_ea, &npf.osnpf_ea); /* Copy actual ea if one */
+ #if KLH10_NET_TUN
+ tun_ip = npf.osnpf_tun.ia_addr; /* Copy actual tun if any */
+ #endif
}
}
***************
*** 1730,1736 ****
--- 1755,1765 ----
/* Hack to set host/imp value as properly as possible. */
memcpy((char *)&haddr.ia_octet[0], pp + IPBOFF_SRC, 4);
if ((haddr.ia_addr.s_addr & ihost_nm.s_addr) != ihost_net.s_addr) {
+ #if !KLH10_NET_TUN
haddr.ia_addr = gwdef_ip; /* Not local, use default GW */
+ #else
+ haddr.ia_addr = tun_ip; /* Not local, use tunnel end */
+ #endif
}
ihobuf[SIH_HSIZ+SIL_HST] = haddr.ia_octet[1];
*** klh10-2.0h/src/dpimp.h 2001-11-19 05:45:49.000000000 -0500
--- klh10-2.0i/src/dpimp.h 2005-08-16 20:05:22.000000000 -0400
***************
*** 106,111 ****
--- 106,112 ----
unsigned char dpimp_eth[6]; /* CD Ethernet address of interface */
unsigned char dpimp_ip[4]; /* C 10's IP address to filter on, if shared */
unsigned char dpimp_gw[4]; /* C Default GW address for IMP to use */
+ unsigned char dpimp_tun[4]; /* CD Tunnel address for IMP */
int dpimp_inoff; /* C Offset in buffer of input (I->H) data */
int dpimp_outoff; /* D Offset in buffer of output (H->I) data */
int dpimp_backlog; /* C Max sys backlog of rcvd packets */
*** klh10-2.0h/src/dpni20.c 2003-02-23 13:07:50.000000000 -0500
--- klh10-2.0i/src/dpni20.c 2005-09-09 20:50:47.000000000 -0400
***************
*** 177,183 ****
--- 177,188 ----
struct dp_s dp; /* Device-Process struct for DP ops */
struct in_addr ehost_ip; /* Emulated host IP addr, net order */
+ #if 0
struct in_addr ihost_ip; /* Native host's IP addr, net order */
+ #endif
+ #if KLH10_NET_TUN
+ struct in_addr tun_ip; /* Tunnel IP addr, net order */
+ #endif
struct ether_addr ihost_ea; /* Native host ether addr for selected ifc */
/* Debug flag reference. Use DBGFLG within functions that have "dpni";
***************
*** 383,396 ****
net_init(dpni);
/* Make this a status (rather than debug) printout? */
! if (DBGFLG) {
char sbuf[OSN_IPSTRSIZ+OSN_EASTRSIZ]; /* Lazily ensure big enough */
dbprintln("ifc \"%s\" => ether %s",
dpni->dpni_ifnam,
eth_adrsprint(sbuf, (unsigned char *)&ihost_ea));
dbprintln(" addr %s",
ip_adrsprint(sbuf, (unsigned char *)&ihost_ip));
dbprintln(" VHOST %s",
ip_adrsprint(sbuf, (unsigned char *)&ehost_ip));
}
--- 388,407 ----
net_init(dpni);
/* Make this a status (rather than debug) printout? */
! if (swstatus) {
char sbuf[OSN_IPSTRSIZ+OSN_EASTRSIZ]; /* Lazily ensure big enough */
dbprintln("ifc \"%s\" => ether %s",
dpni->dpni_ifnam,
eth_adrsprint(sbuf, (unsigned char *)&ihost_ea));
+ #if 0
dbprintln(" addr %s",
ip_adrsprint(sbuf, (unsigned char *)&ihost_ip));
+ #endif
+ #if KLH10_NET_TUN
+ dbprintln(" tun %s",
+ ip_adrsprint(sbuf, (unsigned char *)&tun_ip));
+ #endif
dbprintln(" VHOST %s",
ip_adrsprint(sbuf, (unsigned char *)&ehost_ip));
}
***************
*** 445,450 ****
--- 456,465 ----
/* Get the IP address we need to filter on, if shared */
memcpy((char *)&ehost_ip, (char *)&dpni->dpni_ip, 4);
+ #if KLH10_NET_TUN
+ /* Get the IP address for the tunnel, if specified */
+ memcpy((char *)&tun_ip, (char *)&dpni->dpni_tun, 4);
+ #else
/* Ensure network device name, if specified, isn't too long */
if (dpni->dpni_ifnam[0] && (strlen(dpni->dpni_ifnam)
>= sizeof(ifr.ifr_name))) {
***************
*** 476,481 ****
--- 491,497 ----
dbprintln("Using default interface \"%s\"", dpni->dpni_ifnam);
}
}
+ #endif
/* Now set remaining stuff */
***************
*** 490,501 ****
--- 506,523 ----
npf.osnpf_rdtmo = dpni->dpni_rdtmo;
npf.osnpf_backlog = dpni->dpni_backlog;
npf.osnpf_ip.ia_addr = ehost_ip;
+ #if KLH10_NET_TUN
+ npf.osnpf_tun.ia_addr = tun_ip;
+ #endif
/* Ether addr is both a potential arg and a returned value;
the packetfilter open may use and/or change it.
*/
ea_set(&npf.osnpf_ea, dpni->dpni_eth); /* Set requested ea if any */
pffd = osn_pfinit(&npf, (void *)dpni); /* Will abort if fails */
ea_set(&ihost_ea, &npf.osnpf_ea); /* Copy actual ea */
+ #if KLH10_NET_TUN
+ tun_ip = npf.osnpf_tun.ia_addr; /* Get actual tunnel addr */
+ #endif
}
/* Now set any return info values in shared struct.
***************
*** 1441,1450 ****
cnt = data.len;
/* Else cnt must be -1 as call failed */
}
- #elif KLH10_NET_NIT || KLH10_NET_PFLT || KLH10_NET_LNX
- cnt = read(pffd, buff, max);
#elif KLH10_NET_BPF
cnt = read(pffd, tbuff, tmax);
#endif
if (cnt <= cmin) { /* Must get enough for ether header */
--- 1463,1472 ----
cnt = data.len;
/* Else cnt must be -1 as call failed */
}
#elif KLH10_NET_BPF
cnt = read(pffd, tbuff, tmax);
+ #else
+ cnt = read(pffd, buff, max);
#endif
if (cnt <= cmin) { /* Must get enough for ether header */
***************
*** 1509,1515 ****
continue; /* Drop packet, continue reading */
}
#endif /* KLH10_NET_LNX */
! #if KLH10_NET_NIT || KLH10_NET_DLPI || KLH10_NET_PFLT || KLH10_NET_LNX
#if 0
if (DBGFLG)
if (((struct ether_header *)buff)->ether_type == htons(ETHERTYPE_ARP))
--- 1531,1537 ----
continue; /* Drop packet, continue reading */
}
#endif /* KLH10_NET_LNX */
! #if !KLH10_NET_BPF
#if 0
if (DBGFLG)
if (((struct ether_header *)buff)->ether_type == htons(ETHERTYPE_ARP))
***************
*** 1521,1529 ****
if (DBGFLG)
dbprint("sent RPKT");
! #endif /* KLH10_NET_NIT || KLH10_NET_DLPI || KLH10_NET_PFLT || KLH10_NET_LNX */
- #if KLH10_NET_BPF
/* Screwy BPF algorithm requires more overhead because there's
no way to ensure only one packet is read at a time; the call
may return a buffer of several packets, each of which must
--- 1543,1550 ----
if (DBGFLG)
dbprint("sent RPKT");
! #else
/* Screwy BPF algorithm requires more overhead because there's
no way to ensure only one packet is read at a time; the call
may return a buffer of several packets, each of which must
*** klh10-2.0h/src/dpni20.h 2001-11-10 16:29:01.000000000 -0500
--- klh10-2.0i/src/dpni20.h 2005-08-16 20:05:22.000000000 -0400
***************
*** 52,57 ****
--- 52,58 ----
char dpni_ifnam[16]; /* CD Interface name if any */
unsigned char dpni_eth[6]; /* CD Ethernet address of interface */
unsigned char dpni_ip[4]; /* C 10's IP address to filter on, if shared */
+ unsigned char dpni_tun[4]; /* CD host's IP address on tunnel */
int dpni_backlog; /* C Max sys backlog of rcvd packets */
int dpni_dedic; /* C TRUE if dedicated ifc, else shared */
int dpni_decnet; /* C TRUE to seize DECNET packets, if shared */
diff -r -c --exclude='*.orig' --unidirectional-new-file klh10-2.0h/src/dvlhdh.c klh10-2.0i/src/dvlhdh.c
*** klh10-2.0h/src/dvlhdh.c 2001-11-19 05:47:54.000000000 -0500
--- klh10-2.0i/src/dvlhdh.c 2005-08-16 20:05:22.000000000 -0400
***************
*** 103,108 ****
--- 103,109 ----
int lh_rdtmo; /* # secs to timeout on packetfilter reads */
unsigned char lh_ipadr[4]; /* KLH10 IP address to filter on */
unsigned char lh_gwadr[4]; /* Gateway IP address to use when needed */
+ unsigned char lh_tunadr[4]; /* Tunnel IP address on local side */
unsigned char lh_ethadr[6]; /* Ether address to use, if dedicated */
char *lh_dpname; /* Pointer to dev process pathname */
***************
*** 171,176 ****
--- 172,178 ----
\
prmdef(LHDHP_IP, "ipaddr"), /* IP address of KLH10, if shared */\
prmdef(LHDHP_GW, "gwaddr"), /* IP address of prime GW to use */\
+ prmdef(LHDHP_TUN,"tunaddr"), /* IP address of local side of tunnel */\
prmdef(LHDHP_EN, "enaddr"), /* Ethernet address to use (override) */\
prmdef(LHDHP_IFC,"ifc"), /* Ethernet interface name */\
prmdef(LHDHP_BKL,"backlog"),/* Max bklog for rcvd pkts (else sys deflt) */\
***************
*** 301,306 ****
--- 303,315 ----
break;
continue;
+ case LHDHP_TUN: /* Parse as IP address: u.u.u.u */
+ if (!prm.prm_val)
+ break;
+ if (!parip(prm.prm_val, &lh->lh_tunadr[0]))
+ break;
+ continue;
+
case LHDHP_EN: /* Parse as EN address in hex */
if (!prm.prm_val)
break;
***************
*** 1057,1062 ****
--- 1066,1073 ----
lh->lh_ipadr, 4);
memcpy((char *)dpc->dpimp_gw, /* Set our GW address for IMP */
lh->lh_gwadr, 4);
+ memcpy((char *)dpc->dpimp_tun, /* Set our IP address for tunnel */
+ lh->lh_tunadr, 4); /* (all zero if none) */
memcpy(dpc->dpimp_eth, /* Set EN address if any given */
lh->lh_ethadr, 6); /* (all zero if none) */
*** klh10-2.0h/src/dvni20.c 2001-11-10 16:29:03.000000000 -0500
--- klh10-2.0i/src/dvni20.c 2005-08-16 20:05:22.000000000 -0400
***************
*** 157,162 ****
--- 157,163 ----
int ni_lsapf; /* TRUE to filter on LSAP addr (if shared) */
int ni_lsap; /* LSAP src/dst address for above */
unsigned char ni_ipadr[4]; /* KLH10 IP address to filter (if shared) */
+ unsigned char ni_tunadr[4]; /* Tunnel IP address (if masquerading) */
int32 ni_c3dly; /* Initial-cmd delay in ticks */
int32 ni_c3dlyct; /* Countdown (no delay if 0) */
***************
*** 294,299 ****
--- 295,301 ----
prmdef(NIP_BKL,"backlog"),/* Max bklog for rcvd pkts (else sys default) */\
prmdef(NIP_DED,"dedic"), /* TRUE= Ifc dedicated (else shared) */\
prmdef(NIP_IP, "ipaddr"), /* IP address of KLH10, if shared */\
+ prmdef(NIP_TUN, "tunaddr"), /* IP address of local end of tunnel */\
prmdef(NIP_DEC,"decnet"), /* TRUE= if shared, seize DECNET pkts */\
prmdef(NIP_ARP,"doarp"), /* TRUE= if shared, do ARP hackery */\
prmdef(NIP_LSAP,"lsap"), /* Set= if shared, filter on LSAP pkts */\
***************
*** 391,396 ****
--- 393,405 ----
break;
continue;
+ case NIP_TUN: /* Parse as IP address: u.u.u.u */
+ if (!prm.prm_val)
+ break;
+ if (!parip(prm.prm_val, &ni->ni_tunadr[0]))
+ break;
+ continue;
+
case NIP_EN: /* Parse as EN address in hex */
if (!prm.prm_val)
break;
***************
*** 711,716 ****
--- 720,727 ----
dpc->dpni_ifnam[0] = '\0'; /* No specific interface */
memcpy((char *)dpc->dpni_ip, /* Set our IP address for filter */
ni->ni_ipadr, 4);
+ memcpy((char *)dpc->dpni_tun, /* Set IP address for tunnel */
+ ni->ni_tunadr, 4);
memcpy(dpc->dpni_eth, /* Set EN address if any given */
ni->ni_ethadr, 6); /* (all zero if none) */
*** klh10-2.0h/src/Makefile.mk 2005-02-22 02:16:14.000000000 -0500
--- klh10-2.0i/src/Makefile.mk 2005-08-16 20:05:22.000000000 -0400
***************
*** 302,308 ****
-DKLH10_DEV_DPRPXX=1 \
-DKLH10_DEV_DPIMP=1 \
-DKLH10_SIMP=0 \
- -DKLH10_NET_TUN=SYS_FREEBSD \
-DKLH10_MEM_SHARED=1 \
$(TINTFLAGS) \
$(DINTFLAGS) \
--- 302,307 ----
*** klh10-2.0h/src/osdnet.c 2005-04-28 18:01:04.000000000 -0400
--- klh10-2.0i/src/osdnet.c 2005-09-11 11:12:41.000000000 -0400
***************
*** 812,818 ****
ea_set(def, ifdev.default_pa);
}
! #elif KLH10_NET_LNX
{
int ownsock = FALSE;
struct ifreq ifr;
--- 812,818 ----
ea_set(def, ifdev.default_pa);
}
! #elif CENV_SYS_LINUX
{
int ownsock = FALSE;
struct ifreq ifr;
***************
*** 1131,1137 ****
char *ifnam, /* Interface name */
unsigned char *newpa) /* New ether address */
{
! #if CENV_SYS_DECOSF || KLH10_NET_LNX \
|| (CENV_SYS_FREEBSD && defined(SIOCSIFLLADDR))
/* Common preamble code */
--- 1131,1137 ----
char *ifnam, /* Interface name */
unsigned char *newpa) /* New ether address */
{
! #if CENV_SYS_DECOSF || CENV_SYS_LINUX \
|| (CENV_SYS_FREEBSD && defined(SIOCSIFLLADDR))
/* Common preamble code */
***************
*** 1162,1168 ****
return FALSE;
}
! # elif KLH10_NET_LNX
/* Address family must match what device thinks it is, so find that
out first... sigh.
--- 1162,1168 ----
return FALSE;
}
! # elif CENV_SYS_LINUX
/* Address family must match what device thinks it is, so find that
out first... sigh.
***************
*** 1225,1231 ****
int delf,
unsigned char *pa)
{
! #if CENV_SYS_DECOSF || KLH10_NET_LNX || CENV_SYS_FREEBSD
/* Common preamble code */
int ownsock = FALSE;
--- 1225,1231 ----
int delf,
unsigned char *pa)
{
! #if CENV_SYS_DECOSF || CENV_SYS_LINUX || CENV_SYS_FREEBSD
/* Common preamble code */
int ownsock = FALSE;
***************
*** 1616,1624 ****
--- 1616,1629 ----
{
int allowextern = TRUE; /* For now, always try for external access */
int fd;
+ #if CENV_SYS_LINUX /* [BV: tun support for Linux] */
+ struct ifreq ifr;
+ char ifnam[IFNAMSIZ];
+ #else
char tunname[sizeof "/dev/tun000"];
char *ifnam = tunname + sizeof("/dev/")-1;
int i = -1;
+ #endif
char ipb1[OSN_IPSTRSIZ];
char ipb2[OSN_IPSTRSIZ];
struct ifent *ife = NULL; /* Native host's default IP interface if one */
***************
*** 1628,1660 ****
/* Remote address is always that of emulated machine */
ipremote = osnpf->osnpf_ip.ia_addr;
! /* Local address is that of hardware machine if we want to permit
! external access. If not, it doesn't matter (and may not even
! exist, if there is no hardware interface)
! */
! if (allowextern) {
! if (osn_iftab_init(IFTAB_IPS) && (ife = osn_ipdefault())) {
! iplocal = ife->ife_ipia;
! } else {
! error("Cannot find default IP interface for host");
! allowextern = FALSE;
! }
! }
! if (!allowextern) {
! /* Make up bogus IP address for internal use */
! memcpy((char *)&iplocal, ipremset, 4);
}
if (DP_DBGFLG)
dbprint("Opening TUN device");
do {
sprintf(tunname, "/dev/tun%d", ++i);
} while ((fd = open(tunname, O_RDWR)) < 0 && errno == EBUSY);
if (fd < 0)
esfatal(1, "Couldn't open tunnel device %s", tunname);
if (DP_DBGFLG)
dbprintln("Opened %s, configuring for local %s, remote %s",
--- 1633,1689 ----
/* Remote address is always that of emulated machine */
ipremote = osnpf->osnpf_ip.ia_addr;
+ iplocal = osnpf->osnpf_tun.ia_addr;
! /* Local address can be set explicitly if we plan to do full IP
! masquerading. */
! if (memcmp((char *)&iplocal, "\0\0\0\0", IP_ADRSIZ) == 0) {
! /* Local address is that of hardware machine if we want to permit
! external access. If not, it doesn't matter (and may not even
! exist, if there is no hardware interface)
! */
! if (allowextern) {
! if (osn_iftab_init(IFTAB_IPS) && (ife = osn_ipdefault())) {
! iplocal = ife->ife_ipia;
! } else {
! error("Cannot find default IP interface for host");
! allowextern = FALSE;
! }
! }
! if (!allowextern) {
! /* Make up bogus IP address for internal use */
! memcpy((char *)&iplocal, ipremset, 4);
! }
! osnpf->osnpf_tun.ia_addr = iplocal;
}
if (DP_DBGFLG)
dbprint("Opening TUN device");
+ #if CENV_SYS_LINUX /* [BV: Linux way] */
+ if ((fd = open("/dev/net/tun", O_RDWR)) < 0) /* get a fresh device */
+ esfatal(0, "Couldn't open tunnel device /dev/net/tun");
+ memset(&ifr, 0, sizeof(ifr));
+ #if OSN_USE_IPONLY
+ ifr.ifr_flags = IFF_TUN | IFF_NO_PI; /* TUN (no Ethernet headers), no pkt info */
+ #else
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* TAP (yes Ethernet headers), no pkt info */
+ #endif
+ if (ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) /* turn it on */
+ esfatal(0, "Couldn't set tun device");
+ strcpy(ifnam, ifr.ifr_name); /* get device name (typically "tun0") */
+ #else
do {
+ #if OSN_USE_IPONLY
sprintf(tunname, "/dev/tun%d", ++i);
+ #else
+ sprintf(tunname, "/dev/tap%d", ++i);
+ #endif
} while ((fd = open(tunname, O_RDWR)) < 0 && errno == EBUSY);
if (fd < 0)
esfatal(1, "Couldn't open tunnel device %s", tunname);
+ #endif
if (DP_DBGFLG)
dbprintln("Opened %s, configuring for local %s, remote %s",
***************
*** 1662,1667 ****
--- 1691,1697 ----
ip_adrsprint(ipb1, (unsigned char *)&iplocal),
ip_adrsprint(ipb2, (unsigned char *)&ipremote));
+ strcpy(osnpf->osnpf_ifnam, ifnam);
/* Activate TUN device.
First address is "local" -- doesn't matter if all we care about is
***************
*** 1691,1696 ****
--- 1721,1743 ----
esfatal(1, "osn_pfinit: ifconfig failed to initialize tunnel device?");
}
}
+ #elif CENV_SYS_LINUX /* [BV: Linux tun device] */
+ /* "Hacky" but simple method */
+ {
+ char cmdbuff[128];
+ int res;
+
+ /* ifconfig DEV IPLOCAL pointopoint IPREMOTE */
+ sprintf(cmdbuff, "ifconfig %s %s pointopoint %s up",
+ ifnam,
+ ip_adrsprint(ipb1, (unsigned char *)&iplocal),
+ ip_adrsprint(ipb2, (unsigned char *)&ipremote));
+ if (DP_DBGFLG)
+ dbprintln("running \"%s\"",cmdbuff);
+ if ((res = system(cmdbuff)) != 0) {
+ esfatal(1, "osn_pfinit: ifconfig failed to initialize tunnel device?");
+ }
+ }
#else
{
/* Internal method */
***************
*** 1770,1777 ****
/* Return that as our ether address */
ea_set((char *)&osnpf->osnpf_ea, ife->ife_ea);
} else {
! /* Assume no useful ether addr */
ea_clr((char *)&osnpf->osnpf_ea);
}
if (DP_DBGFLG)
--- 1817,1835 ----
/* Return that as our ether address */
ea_set((char *)&osnpf->osnpf_ea, ife->ife_ea);
} else {
! /* ARP hackery will be handled by IP masquerading and packet forwarding. */
! #if 1 /*OSN_USE_IPONLY*/ /* TOPS-20 does not like NI20 with made up address? */
! /* Assume no useful ether addr for tun interface. */
ea_clr((char *)&osnpf->osnpf_ea);
+ #else
+ /* Assign requested address to tap interface or get kernel assigned one. */
+ if (memcmp((char *)&osnpf->osnpf_ea, "\0\0\0\0\0\0", ETHER_ADRSIZ) == 0) {
+ osn_ifeaget(-1, ifnam, (unsigned char *)&osnpf->osnpf_ea, NULL);
+ }
+ else {
+ osn_ifeaset(-1, ifnam, (unsigned char *)&osnpf->osnpf_ea);
+ }
+ #endif
}
if (DP_DBGFLG)
*** klh10-2.0h/src/osdnet.h 2001-11-19 05:34:01.000000000 -0500
--- klh10-2.0i/src/osdnet.h 2005-08-16 20:05:22.000000000 -0400
***************
*** 69,75 ****
#if !(KLH10_NET_NIT || KLH10_NET_DLPI || KLH10_NET_BPF || KLH10_NET_PFLT || \
KLH10_NET_TUN || KLH10_NET_LNX)
/* None explicitly specified, pick a reasonable default */
! # if (CENV_SYS_FREEBSD && OSN_USE_IPONLY)
# undef KLH10_NET_TUN
# define KLH10_NET_TUN 1
# elif (CENV_SYS_NETBSD || CENV_SYS_FREEBSD)
--- 69,75 ----
#if !(KLH10_NET_NIT || KLH10_NET_DLPI || KLH10_NET_BPF || KLH10_NET_PFLT || \
KLH10_NET_TUN || KLH10_NET_LNX)
/* None explicitly specified, pick a reasonable default */
! # if ((CENV_SYS_FREEBSD || CENV_SYS_LINUX) && OSN_USE_IPONLY)
# undef KLH10_NET_TUN
# define KLH10_NET_TUN 1
# elif (CENV_SYS_NETBSD || CENV_SYS_FREEBSD)
***************
*** 146,151 ****
--- 146,154 ----
# include <linux/if_packet.h>
# include <linux/if_ether.h> /* The L2 protocols */
# endif
+
+ #elif KLH10_NET_TUN && CENV_SYS_LINUX /* [BV: tun support for Linux] */
+ # include <linux/if_tun.h>
#endif
***************
*** 379,384 ****
--- 382,388 ----
int osnpf_rdtmo; /* Read timeout, if any */
int osnpf_backlog; /* Allow # backlogged packets, if any */
union ipaddr osnpf_ip; /* IP address to use */
+ union ipaddr osnpf_tun; /* INOUT: IP address of tunnel */
struct ether_addr osnpf_ea; /* OUT: ether address of ifc */
};
int osn_pfinit(struct osnpf *, void *);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.