1
0
mirror of https://github.com/PDP-10/klh10.git synced 2026-01-11 23:52:54 +00:00

Add a configure script and remove a tangle of frail #if conditions

This only uses autoconf, not automake or libtool or intltool or whatever.
This also allows easy building of different emulators in different build directories.

I have tested TOPS-20 with pcap|tap+bridge, ITS with pcap|tun|tap+bridge, both on NetBSD and Linux
and hopefully everything still works after the fine-tuning.
This commit is contained in:
Olaf Seibert 2016-01-19 23:41:49 +01:00
parent 9312579251
commit 2ac5184ff2
21 changed files with 4137 additions and 379 deletions

5
.gitignore vendored
View File

@ -1,4 +1,3 @@
new
bld/*/*.h
bld/*/*.o
bld/*/dpimp
@ -13,4 +12,8 @@ bld/*/udlconv
bld/*/vdkfmt
bld/*/wfconv
bld/*/wxtest
config.status
autom4te.cache
new
src/tags
tmp*/*

23
autogen.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
#
# autogen.sh
#
# Usage: ../path/to/autogen.sh [args for configure]
#
# (Re)constructs the configure script using the appropriate invocations
# of autoconf etc, and runs configure with the given arguments.
#
# It is strongly recommended to build in a separate directory
# for easy cleanup.
srcdir=$(dirname $0)
test -z "$srcdir" && srcdir=.
builddir=$(pwd)
cd "$srcdir"
autoconf -I aclocal
autoheader
cd "$builddir"
$srcdir/configure "$@"

1438
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1810
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

152
configure.ac Normal file
View File

@ -0,0 +1,152 @@
# -*- Autoconf -*-
# Process this file with autogen.sh to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([klh10], [2.0i], [https://github.com/Rhialto/klh10])
AC_CONFIG_SRCDIR([src/klh10.h])
AC_CONFIG_HEADERS([src/config.h])
# Filter CFLAGS; the default is something like -g -O2 and we want -g3 -O3.
NEWCFLAGS=""
for cf in $CFLAGS
do
case "$cf" in
-O*) ;;
-g*) ;;
*) NEWCFLAGS="$NEWCFLAGS $cf" ;;
esac
done
CFLAGS="$NEWCFLAGS -g3 -O3"
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
# Checks for libraries.
# They may be needed for Solaris:
# -lsocket and -lnsl are needed only for osdnet.c.
# -lrt is needed for nanosleep().
# FIXME: Check if -lnsl is actually still needed for anything
dnl AC_CHECK_LIB([nsl], [main])
AC_CHECK_FUNC([nanosleep],
[],
[
AC_CHECK_LIB([rt], [nanosleep])
])
# -lsocket and -lpcap should go into NETLIBS
SAVE_LIBS="$LIBS"
LIBS=""
AC_CHECK_LIB([socket], [if_nameindex])
AC_CHECK_LIB([pcap], [pcap_findalldevs])
# Not all libpcap versions seem to have pcap_set_immediate_mode().
AC_CHECK_LIB([pcap], [pcap_set_immediate_mode],
[AC_DEFINE(HAVE_PCAP_SET_IMMEDIATE_MODE, 1, [Set to 1 if we have pcap_set_immediate_mode])]
)
NETLIBS="$LIBS"
LIBS="$SAVE_LIBS"
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h sgtty.h stddef.h stdlib.h string.h sys/file.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h net/if_tun.h linux/if_tun.h linux/if_packet.h net/if_tap.h sys/mtio.h net/nit.h sys/dlpi.h net/if_dl.h net/if_types.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_FSEEKO
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([alarm dup2 gettimeofday localtime_r memset socket strcasecmp strchr strcspn strerror strncasecmp strpbrk strrchr strtol getifaddrs if_nameindex termios sigsetops sigaction nanosleep])
# Check for CPU.
# This requires install-sh, config.sub, config.guess from automake.
AC_CANONICAL_TARGET
AC_DEFINE_UNQUOTED([KLH10S_CENV_CPU_], "$target_cpu", [String form of the CPU name])
AC_DEFINE_UNQUOTED([KLH10S_CENV_SYS_], "$target_vendor-$target_os", [String form of the host OS])
AC_SUBST([KLH10S_CENV_CPU_], [$target_cpu])
AC_SUBST([KLH10S_CENV_SYS_], [$target_vendor-$target_os])
AC_C_BIGENDIAN([
AC_DEFINE(CENV_CPUF_BIGEND, 1, [])
AC_DEFINE(CENV_CPUF_LILEND, 0, [])
],[
AC_DEFINE(CENV_CPUF_BIGEND, 0, [Set to 1 for big-endian CPU])
AC_DEFINE(CENV_CPUF_LILEND, 1, [Set to 1 for little-endian CPU])
])
# This test and auxiliary file is needed to get around a bug in the NetBSD
# /usr/include files. <stdio.h> includes <sys/types.h> which includes
# <machine/types.h> which incorrectly exposes a typedef of vaddr_t (normally
# a kernel only type), thus conflicting with KLH10's vaddr_t.
# By including this file ahead of any other source files (see the -include
# in CENVFLAGS) we can nullify the typedef.
# And while we're at it, blast paddr_t for the same reason.
# As of NetBSD 7.0, the problem has moved to <stdlib.h>.
AC_MSG_CHECKING([whether vaddr_t escapes from <std*.h>])
AC_LANG([C])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <stdlib.h>
/* see if this defines vaddr_t to something different than before */
typedef char vaddr_t;
]])],
[
# Compiles ok: nothing to do.
AC_MSG_RESULT([no (all ok)])
],
[
# Compile error: we need to hide vaddr_t.
AC_MSG_RESULT([yes (will patch it)])
CENVFLAGS="$CENVFLAGS -include vaddr-sucks.h"
])
# -------------------------------------------------------------------------
# Check whether we want bridge support
# -------------------------------------------------------------------------
AC_ARG_ENABLE(bridge,
AC_HELP_STRING([--disable-bridge],[disable bridge networking]),
[ case "${enableval}" in
yes) bridge=true ;;
no) bridge=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-bridge) ;;
esac ],
[ bridge=true ] )
if test x$bridge = xfalse
then
AC_DEFINE(KLH10_NET_BRIDGE, 0, [Set to 0 to disable bridge networking])
echo 'Compiling without bridge support'
fi
# -------------------------------------------------------------------------
# Output section. State which @VARIABLES@ are going to be substituted
# -------------------------------------------------------------------------
AC_SUBST([CC])
AC_SUBST([CFLAGS])
AC_SUBST([DESTDIR])
AC_SUBST([PREFIX])
AC_SUBST([LIBS])
AC_SUBST([NETLIBS])
AC_SUBST([MAKEFILE], [Makefile])
AC_SUBST([CENVFLAGS])
# -------------------------------------------------------------------------
# Output section. State which files are going to be constructed
# -------------------------------------------------------------------------
AC_CONFIG_FILES([bld-kl/Makefile:mk/top.mk:mk/top-kl.mk:src/Makefile.mk
bld-ks/Makefile:mk/top.mk:mk/top-ks.mk:src/Makefile.mk
bld-ks-its/Makefile:mk/top.mk:mk/top-ks-its.mk:src/Makefile.mk
])
AC_OUTPUT

View File

@ -188,6 +188,10 @@ how to recompile a kernel. You need at least these options (as of 3.0):
pseudo-device tap # cloning device for NI20
pseudo-device bridge # cloning device for NI20
Later versions of NetBSD make SHMMAXPGS configurable at runtime, via
sysctl -w kern.ipc.shmmaxpgs=value. The default value may be large enough
already.
Linux
-----
@ -930,10 +934,49 @@ The parameters for the NI20 driver are:
However, for a shared interface this will default to whatever the host
system uses for its IP datagrams, normally "ln0" or "tu0" for
OSF/1.
If really needed, you can force the choice with the environment
variable KLH10_NET_DEFAULT_IF.
The shell commands "ifconfig -a" or "netstat -i" will show the
known interfaces.
See also the ENADDR parameter.
[IFMETH=<pcap|tap|tap+bridge>] Default: system dependent
Different host operating systems have different methods to allow
access to an ethernet interface. Some may have more than one.
The desired option can be chosen at runtime from the ones that are
compiled in.
pcap uses the libpcap library and therefore is the most portable.
However, on some systems this uses a backing method that does not
allow 2-way communication between the host and the guest system.
(BPF may on some cases not allow packets sent by the guest to be
seen by the host).
pcap is essentially always available, since the library is also used
to enumerate the real ethernet interfaces.
tun uses the IP tunnel device. Implemented for *BSD and Linux. This
option is only available for dpimp, i.e. for ks-its.
tap uses the Ethernet tunnel device. Implemented for *BSD and Linux.
For the ethernet packets to be received anywhere outside the
host, they need to be bridged (tap+bridge) to a real interface,
or routing needs to be set up on the host (this is not built into klh).
With both tun and tap you can specify with ifc=tun33 which of the tun/
tap devices you want to use, for instance if you have one pre-set-up.
Otherwise, one will be created for you.
tap+bridge networking is a mix between DEDIC=TRUE and DEDIC=FALSE.
It is dedicated in the sense that the interface is virtual and can
be manipulated at will (ethernet address, multicast, etc) but it
is shared in the sense that it receives packets promiscuously,
i.e. unfiltered.
On Linux, the bridge must be pre-created by the user and connected
to an ethernet interface. The name of this bridge can be passed in
the environment variable KLH10_NET_BRIDGE. Note that the sudo command
by default cleans the environment so use sudo -E.
[ENADDR=<x:x:x:x:x:x>] Default: <none>
Normally unnecessary.
Used to specify the ethernet address to use, if the KN10 has trouble
@ -1181,7 +1224,8 @@ I/O possible is in terms of IP datagrams rather than ethernet packets.
devdef imp ub3 lhdh \
addr=767600 br=6 vec=250 \ ; Generic Unibus params
ipaddr=10.2.0.6 \ ; ITS IP address
gwaddr=199.34.53.50 ; Host platform's IP address
gwaddr=199.34.53.50 \ ; Host platform's IP address
ifmeth=tun ; networking method
The parameters for the LHDH driver are:
@ -1214,6 +1258,9 @@ The parameters for the LHDH driver are:
Normally the host platform can be specified, but a real gateway
is OK too.
[IFMETH=<tun|tap|tap+bridge|pcap>] Required
As with the NI20.
[DEBUG=<boolean>] Default: FALSE
[DEBUG] Same as DEBUG=TRUE
This can be used to turn on debug tracing as soon as the device

301
install-sh Executable file
View File

@ -0,0 +1,301 @@
#!/bin/sh
#
# $NetBSD: install-sh.in,v 1.6 2012/01/11 13:07:31 hans Exp $
# This script now also installs multiple files, but might choke on installing
# multiple files with spaces in the file names.
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
awkprog="${AWKPROG-awk}"
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
instcmd="$cpprog"
instflags=""
pathcompchmodcmd="$chmodprog 755"
chmodcmd="$chmodprog 755"
chowncmd=""
chgrpcmd=""
stripcmd=""
stripflags=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
msrc=""
dst=""
dir_arg=""
suffix=""
suffixfmt=""
while [ x"$1" != x ]; do
case $1 in
-b) suffix=".old"
shift
continue;;
-B) suffixfmt="$2"
shift
shift
continue;;
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-m*)
chmodcmd="$chmodprog ${1#-m}"
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-S) stripcmd="$stripprog"
stripflags="-S $2 $stripflags"
shift
shift
continue;;
-p) instflags="-p"
shift
continue;;
*) if [ x"$msrc" = x ]
then
msrc="$dst"
else
msrc="$msrc $dst"
fi
src="$dst"
dst="$1"
shift
continue;;
esac
done
if [ x"$dir_arg" = x ]
then
dstisfile=""
if [ ! -d "$dst" ]
then
if [ x"$msrc" = x"$src" ]
then
dstisfile=true
else
echo "install: destination is not a directory"
exit 1
fi
fi
else
msrc="$msrc $dst"
fi
if [ x"$msrc" = x ]
then
echo "install: no destination specified"
exit 1
fi
for srcarg in $msrc; do
if [ x"$dir_arg" != x ]; then
dstarg="$srcarg"
else
dstarg="$dst"
# Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f "$srcarg" ]
then
doinst="$instcmd $instflags"
elif [ -d "$srcarg" ]
then
echo "install: $srcarg: not a regular file"
exit 1
elif [ "$srcarg" = "/dev/null" ]
then
doinst="$cpprog"
else
echo "install: $srcarg does not exist"
exit 1
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d "$dstarg" ]
then
dstarg="$dstarg"/`basename "$srcarg"`
fi
fi
## this sed command emulates the dirname command
dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$doit $mkdirprog "${pathcomp}"
if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi &&
if [ x"$pathcompchmodcmd" != x ]; then $doit $pathcompchmodcmd "${pathcomp}"; else true ; fi
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
if [ -d "$dstarg" ]; then
true
else
$doit $mkdirprog "$dstarg" &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi
fi
else
if [ x"$dstisfile" = x ]
then
file=$srcarg
else
file=$dst
fi
dstfile=`basename "$file"`
dstfinal="$dstdir/$dstfile"
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Make a backup file name in the proper directory.
case x$suffixfmt in
*%*) suffix=`echo x |
$awkprog -v bname="$dstfinal" -v fmt="$suffixfmt" '
{ cnt = 0;
do {
sfx = sprintf(fmt, cnt++);
name = bname sfx;
} while (system("test -f " name) == 0);
print sfx; }' -`;;
x) ;;
*) suffix="$suffixfmt";;
esac
dstbackup="$dstfinal$suffix"
# Move or copy the file name to the temp name
$doit $doinst $srcarg "$dsttmp" &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripflags "$dsttmp"; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi &&
# Now rename the file to the real destination.
if [ x"$suffix" != x ] && [ -f "$dstfinal" ]
then
$doit $mvcmd "$dstfinal" "$dstbackup"
else
$doit $rmcmd -f "$dstfinal"
fi &&
$doit $mvcmd "$dsttmp" "$dstfinal"
fi
done &&
exit 0

5
mk/top-kl.mk Normal file
View File

@ -0,0 +1,5 @@
# Makefile fragment for building kl
all: base-kl tapedd vdkfmt wxtest enaddr
#---

5
mk/top-ks-its.mk Normal file
View File

@ -0,0 +1,5 @@
# Makefile fragment for building ks-its
all: base-ks-its tapedd vdkfmt wxtest enaddr
#---

5
mk/top-ks.mk Normal file
View File

@ -0,0 +1,5 @@
# Makefile fragment for building ks
all: base-ks tapedd vdkfmt wxtest enaddr
#---

36
mk/top.mk Normal file
View File

@ -0,0 +1,36 @@
# KLH10 Makefile for @KLH10S_CENV_SYS_@ on @KLH10S_CENV_CPU_@
#
# Copyright © 2016 Olaf 'Rhialto' Seibert
# All Rights Reserved
#
# This file is part of the KLH10 Distribution. Use, modification, and
# re-distribution is permitted subject to the terms in the file
# named "LICENSE", which contains the full text of the legal notices
# and should always accompany this Distribution.
#
# This software is provided "AS IS" with NO WARRANTY OF ANY KIND.
#
# This notice (including the copyright and warranty disclaimer)
# must be included in all copies or derivations of this software.
#
#####################################################################
SRC = @top_srcdir@/src
BLDSRC = @top_builddir@/src
CC = @CC@
CFLAGS = -c @CFLAGS@ -I$(BLDSRC) -I$(SRC)
CFLAGS_LINT = -ansi -pedantic -Wall -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wredundant-decls
LIBS = @LIBS@
NETLIBS = @NETLIBS@
prefix = @prefix@
exec_prefix = @exec_prefix@
KLH10_HOME = ${DESTDIR}@bindir@
# Source definitions
CENVFLAGS = @CENVFLAGS@
MAKEFILE = @MAKEFILE@
#---

View File

@ -13,8 +13,8 @@ devdef mta0 rh1.0 tm03 type=tu45
; Need KLNI to avoid LAPRBF BUGCHKs - use valid address if known
;
; devdef ni0 564 ni20 ipaddr=10.0.0.51
; The (NetBSD/FreeBSD) version with tap(4) and bridge(4) creates the named
; tap device dynamically and bridges it to the default interface.
; The (NetBSD/FreeBSD/Linux) version with tap(4) and bridge(4) creates the
; named tap device dynamically and bridges it to the default interface.
; If you want it differently (for instance routed instead of bridged),
; you can create the tap yourself and it will be used as it is.
devdef ni0 564 ni20 ipaddr=10.0.0.51 ifmeth=tap+bridge ifc=tap0 dedic=true

View File

@ -36,33 +36,37 @@
# Basic default definitions.
# Normally these will be overridden by build-specific make
# invocations, by both or either of:
# (1) concatenation of a platform-specific makefile of the
# invocations, by any of:
# (1) concatenation fragments generated by the configure script
# in front of this Makefile.mk
# (2) concatenation of a platform-specific makefile of the
# form "Mk-<plat>.mk"
# (the most recent defs override these defaults)
# (2) command line definitions, which override those from any files.
# (3) command line definitions, which override those from any files.
# Generic compile/link flags
# Suitable for plain vanilla Unix but normally overridden.
CC = cc
CFLAGS = -c -I. -I$(SRC)
CFLAGS_AUX =
CFLAGS_LINT =
LINKER = $(CC)
LDFLAGS =
LDOUTF = -o
LIBS =
NETLIBS = -lpcap
CC ?= cc
CFLAGS ?= -c -I. -I$(SRC)
CFLAGS_AUX ?=
CFLAGS_LINT ?=
LINKER ?= $(CC)
LDFLAGS ?=
LDOUTF ?= -o
LIBS ?=
NETLIBS ?= -lpcap
# Variables specific to this makefile setup
# SRC and MAKE_CENV are normally overridden.
SRC = ../../src
MAKE_CENV =
CENVFLAGS =
CONFFLAGS =
CONFFLAGS_AUX =
SRC ?= ../../src
MAKE_CENV ?=
CENVFLAGS ?=
CONFFLAGS ?=
CONFFLAGS_AUX ?=
MAKER = make -f $(SRC)/Makefile.mk $(MAKE_CENV)
MAKEFILE ?= $(SRC)/Makefile.mk
MAKER = make -f $(MAKEFILE) $(MAKE_CENV)
BUILDMOD = $(CC) $(CFLAGS) $(CFLAGS_AUX) \
$(CENVFLAGS) $(CONFFLAGS) $(CONFFLAGS_AUX)
@ -95,9 +99,12 @@ usage:
showdefs:
@echo "Showing target defs:"
@echo "SRC = $(SRC)"
@echo "BLDSRC = $(BLDSRC)"
@echo "MAKER = $(MAKER)"
@echo "CFLAGS = $(CFLAGS)"
@echo "CFLAGS_AUX = $(CFLAGS_AUX)"
@echo "LIBS = $(LIBS)"
@echo "NETLIBS = $(NETLIBS)"
@echo "CENVFLAGS = $(CENVFLAGS)"
@echo "CONFFLAGS = $(CONFFLAGS)"
@echo "CONFFLAGS_AUX = $(CONFFLAGS_AUX)"
@ -153,7 +160,7 @@ CONFS = cenv.h klh10.h word10.h wfio.h fecmd.h feload.h \
opcods.h opdefs.h osdsup.h \
dvcty.h dvuba.h dvrh11.h dvlhdh.h dvdz11.h dvch11.h \
dvrh20.h dvrpxx.h dvtm03.h dvni20.h dvhost.h dvlites.h \
vmtape.h vdisk.h
vmtape.h vdisk.h config.h
# Modules needed for KL10 version.
@ -233,13 +240,13 @@ DINTFLAGS = \
##
kn10-ks: $(OFILES_KS)
$(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks $(OFILES_KS) $(NETLIBS) $(LIBS)
$(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks $(OFILES_KS) $(LIBS)
kn10-ks-its: $(OFILES_KS)
$(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks-its $(OFILES_KS) $(NETLIBS) $(LIBS)
$(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks-its $(OFILES_KS) $(LIBS)
kn10-kl: $(OFILES_KL)
$(LINKER) $(LDFLAGS) $(LDOUTF) kn10-kl $(OFILES_KL) $(NETLIBS) $(LIBS)
$(LINKER) $(LDFLAGS) $(LDOUTF) kn10-kl $(OFILES_KL) $(LIBS)
####################################################################
@ -253,7 +260,7 @@ clean:
# Install. This should really use a shell script instead.
#
install-unix:
install:
@echo "Copying binaries into ${KLH10_HOME}"
@-rm -rf ${KLH10_HOME}/flushed
@-mkdir ${KLH10_HOME}/flushed
@ -525,7 +532,7 @@ kl0i-rtmopt:
#
dprpxx.o: $(SRC)/dprpxx.c $(SRC)/dprpxx.h $(SRC)/dpsup.h $(SRC)/vdisk.c \
$(SRC)/klh10.h $(SRC)/rcsid.h $(SRC)/cenv.h $(SRC)/word10.h \
$(SRC)/osdsup.h $(SRC)/vdisk.h
$(SRC)/osdsup.h $(SRC)/vdisk.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dprpxx.c
dprpxx: dprpxx.o dpsup.o
@ -537,7 +544,7 @@ dprpxx: dprpxx.o dpsup.o
dptm03.o: $(SRC)/dptm03.c $(SRC)/dptm03.h $(SRC)/dpsup.h $(SRC)/vmtape.c \
$(SRC)/klh10.h $(SRC)/rcsid.h $(SRC)/cenv.h \
$(SRC)/osdsup.h $(SRC)/word10.h $(SRC)/prmstr.h \
$(SRC)/dptm03.h $(SRC)/vmtape.h $(SRC)/wfio.h
$(SRC)/dptm03.h $(SRC)/vmtape.h $(SRC)/wfio.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dptm03.c
OFILES_DPTM03=dptm03.o dpsup.o wfio.o prmstr.o
@ -551,7 +558,7 @@ dptm03: $(OFILES_DPTM03)
dpni20.o: $(SRC)/dpni20.c $(SRC)/dpni20.h $(SRC)/dpsup.h \
$(SRC)/klh10.h $(SRC)/rcsid.h $(SRC)/cenv.h \
$(SRC)/osdnet.h $(SRC)/osdsup.h $(SRC)/word10.h \
$(SRC)/osdnet.c
$(SRC)/osdnet.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dpni20.c
dpni20: dpni20.o dpsup.o
@ -562,7 +569,7 @@ dpni20: dpni20.o dpsup.o
#
dpimp.o: $(SRC)/dpimp.c $(SRC)/dpimp.h $(SRC)/dpsup.h \
$(SRC)/klh10.h $(SRC)/rcsid.h $(SRC)/cenv.h $(SRC)/osdnet.h \
$(SRC)/dpsup.h $(SRC)/osdsup.h $(SRC)/word10.h $(SRC)/osdnet.c
$(SRC)/dpsup.h $(SRC)/osdsup.h $(SRC)/word10.h $(SRC)/osdnet.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dpimp.c
dpimp: dpimp.o dpsup.o
@ -579,7 +586,7 @@ dpimp: dpimp.o dpsup.o
## TAPEDD - Tape device-to-device copy
## Needs CONFFLAGS just for optional VMTAPE_ITSDUMP.
##
tapedd.o: $(SRC)/tapedd.c $(SRC)/vmtape.c $(SRC)/vmtape.h
tapedd.o: $(SRC)/tapedd.c $(SRC)/vmtape.c $(SRC)/vmtape.h $(BLDSRC)/config.h
$(CC) $(CFLAGS) $(CENVFLAGS) $(CONFFLAGS) $(SRC)/tapedd.c
tapedd: tapedd.o wfio.o prmstr.o
@ -588,7 +595,7 @@ tapedd: tapedd.o wfio.o prmstr.o
## VDKFMT - Virtual Disk Format & copy
##
vdkfmt.o: $(SRC)/vdkfmt.c $(SRC)/vdisk.c $(SRC)/vdisk.h
vdkfmt.o: $(SRC)/vdkfmt.c $(SRC)/vdisk.c $(SRC)/vdisk.h $(BLDSRC)/config.h
$(CC) $(CFLAGS) $(CENVFLAGS) $(SRC)/vdkfmt.c
vdkfmt: vdkfmt.o
@ -597,7 +604,7 @@ vdkfmt: vdkfmt.o
## WXTEST - word10.h tester
##
wxtest.o: $(SRC)/wxtest.c $(SRC)/word10.h
wxtest.o: $(SRC)/wxtest.c $(SRC)/word10.h $(BLDSRC)/config.h
$(CC) $(CFLAGS) $(CENVFLAGS) $(SRC)/wxtest.c
wxtest: wxtest.o
@ -606,7 +613,7 @@ wxtest: wxtest.o
## WFCONV - Word-File Conversion
##
wfconv.o: $(SRC)/wfconv.c $(SRC)/wfio.c $(SRC)/wfio.h $(SRC)/word10.h
wfconv.o: $(SRC)/wfconv.c $(SRC)/wfio.c $(SRC)/wfio.h $(SRC)/word10.h $(BLDSRC)/config.h
$(CC) $(CFLAGS) $(CENVFLAGS) $(SRC)/wfconv.c
wfconv: wfconv.o
@ -615,7 +622,7 @@ wfconv: wfconv.o
## UDLCONV - DIR.LIST Conversion (of ITS interest only)
##
udlconv.o: $(SRC)/udlconv.c
udlconv.o: $(SRC)/udlconv.c $(BLDSRC)/config.h
$(CC) $(CFLAGS) $(CENVFLAGS) $(SRC)/udlconv.c
udlconv: udlconv.o
@ -633,7 +640,7 @@ uexbconv: uexbconv.o
## ENADDR - Ethernet interface test & manipulation
## May require CONFFLAGS to force a particular osdnet config.
enaddr.o: $(SRC)/enaddr.c $(SRC)/osdnet.h $(SRC)/osdnet.c
enaddr.o: $(SRC)/enaddr.c $(SRC)/osdnet.h $(SRC)/osdnet.c $(BLDSRC)/config.h
$(CC) $(CFLAGS) $(CENVFLAGS) $(CONFFLAGS) $(SRC)/enaddr.c
enaddr: enaddr.o
@ -651,118 +658,121 @@ enaddr: enaddr.o
dpsup.o: $(SRC)/dpsup.c $(SRC)/dpsup.h \
$(SRC)/klh10.h $(SRC)/rcsid.h $(SRC)/cenv.h \
$(SRC)/osdsup.h $(SRC)/word10.h
$(SRC)/osdsup.h $(SRC)/word10.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dpsup.c
dvch11.o: $(SRC)/dvch11.c $(SRC)/dvch11.h
dvch11.o: $(SRC)/dvch11.c $(SRC)/dvch11.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvch11.c
dvcty.o: $(SRC)/dvcty.c $(SRC)/dvcty.h
dvcty.o: $(SRC)/dvcty.c $(SRC)/dvcty.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvcty.c
dvdte.o: $(SRC)/dvdte.c $(SRC)/dvdte.h
dvdte.o: $(SRC)/dvdte.c $(SRC)/dvdte.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvdte.c
dvdz11.o: $(SRC)/dvdz11.c $(SRC)/dvdz11.h
dvdz11.o: $(SRC)/dvdz11.c $(SRC)/dvdz11.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvdz11.c
dvhost.o: $(SRC)/dvhost.c $(SRC)/dvhost.h $(SRC)/dvlites.h
dvhost.o: $(SRC)/dvhost.c $(SRC)/dvhost.h $(SRC)/dvlites.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvhost.c
dvlites.o: $(SRC)/dvlites.c $(SRC)/dvlites.h
dvlites.o: $(SRC)/dvlites.c $(SRC)/dvlites.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvlites.c
dvlhdh.o: $(SRC)/dvlhdh.c $(SRC)/dvlhdh.h
dvlhdh.o: $(SRC)/dvlhdh.c $(SRC)/dvlhdh.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvlhdh.c
dvni20.o: $(SRC)/dvni20.c $(SRC)/dvni20.h
dvni20.o: $(SRC)/dvni20.c $(SRC)/dvni20.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvni20.c
dvrh11.o: $(SRC)/dvrh11.c $(SRC)/dvrh11.h
dvrh11.o: $(SRC)/dvrh11.c $(SRC)/dvrh11.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvrh11.c
dvrh20.o: $(SRC)/dvrh20.c $(SRC)/dvrh20.h
dvrh20.o: $(SRC)/dvrh20.c $(SRC)/dvrh20.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvrh20.c
dvrpxx.o: $(SRC)/dvrpxx.c $(SRC)/dvrpxx.h
dvrpxx.o: $(SRC)/dvrpxx.c $(SRC)/dvrpxx.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvrpxx.c
dvtm03.o: $(SRC)/dvtm03.c $(SRC)/dvtm03.h
dvtm03.o: $(SRC)/dvtm03.c $(SRC)/dvtm03.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvtm03.c
dvuba.o: $(SRC)/dvuba.c $(SRC)/dvuba.h
dvuba.o: $(SRC)/dvuba.c $(SRC)/dvuba.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/dvuba.c
fecmd.o: $(SRC)/fecmd.c $(SRC)/fecmd.h
fecmd.o: $(SRC)/fecmd.c $(SRC)/fecmd.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/fecmd.c
feload.o: $(SRC)/feload.c $(SRC)/feload.h
feload.o: $(SRC)/feload.c $(SRC)/feload.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/feload.c
inblsh.o: $(SRC)/inblsh.c
inblsh.o: $(SRC)/inblsh.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inblsh.c
inbyte.o: $(SRC)/inbyte.c
inbyte.o: $(SRC)/inbyte.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inbyte.c
inexts.o: $(SRC)/inexts.c
inexts.o: $(SRC)/inexts.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inexts.c
infix.o: $(SRC)/infix.c
infix.o: $(SRC)/infix.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/infix.c
inflt.o: $(SRC)/inflt.c
inflt.o: $(SRC)/inflt.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inflt.c
inhalf.o: $(SRC)/inhalf.c
inhalf.o: $(SRC)/inhalf.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inhalf.c
inio.o: $(SRC)/inio.c
inio.o: $(SRC)/inio.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inio.c
injrst.o: $(SRC)/injrst.c
injrst.o: $(SRC)/injrst.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/injrst.c
inmove.o: $(SRC)/inmove.c
inmove.o: $(SRC)/inmove.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/inmove.c
intest.o: $(SRC)/intest.c
intest.o: $(SRC)/intest.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/intest.c
kn10clk.o: $(SRC)/kn10clk.c $(SRC)/kn10clk.h
kn10clk.o: $(SRC)/kn10clk.c $(SRC)/kn10clk.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/kn10clk.c
kn10cpu.o: $(SRC)/kn10cpu.c $(SRC)/klh10.h $(SRC)/klh10s.h $(SRC)/klh10.c
kn10cpu.o: $(SRC)/kn10cpu.c $(SRC)/klh10.h $(SRC)/klh10s.h $(SRC)/klh10.c $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/kn10cpu.c
kn10dev.o: $(SRC)/kn10dev.c $(SRC)/kn10dev.h
kn10dev.o: $(SRC)/kn10dev.c $(SRC)/kn10dev.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/kn10dev.c
kn10ops.o: $(SRC)/kn10ops.c $(SRC)/kn10ops.h
kn10ops.o: $(SRC)/kn10ops.c $(SRC)/kn10ops.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/kn10ops.c
kn10pag.o: $(SRC)/kn10pag.c $(SRC)/kn10pag.h
kn10pag.o: $(SRC)/kn10pag.c $(SRC)/kn10pag.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/kn10pag.c
klh10.o: $(SRC)/klh10.c $(SRC)/klh10.h $(SRC)/klh10s.h
klh10.o: $(SRC)/klh10.c $(SRC)/klh10.h $(SRC)/klh10s.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/klh10.c
opdata.o: $(SRC)/opdata.c $(SRC)/kn10def.h $(SRC)/opcods.h
opdata.o: $(SRC)/opdata.c $(SRC)/kn10def.h $(SRC)/opcods.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/opdata.c
osdsup.o: $(SRC)/osdsup.c $(SRC)/osdsup.h
osdsup.o: $(SRC)/osdsup.c $(SRC)/osdsup.h \
$(SRC)/klh10.h $(SRC)/rcsid.h $(SRC)/cenv.h $(SRC)/kn10def.h \
$(SRC)/word10.h $(SRC)/kn10pag.h $(SRC)/opdefs.h \
$(SRC)/opcods.h $(SRC)/kn10clk.h $(SRC)/kn10ops.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/osdsup.c
prmstr.o: $(SRC)/prmstr.c $(SRC)/prmstr.h
prmstr.o: $(SRC)/prmstr.c $(SRC)/prmstr.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/prmstr.c
vdisk.o: $(SRC)/vdisk.c $(SRC)/vdisk.h
vdisk.o: $(SRC)/vdisk.c $(SRC)/vdisk.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/vdisk.c
vmtape.o: $(SRC)/vmtape.c $(SRC)/vmtape.h
vmtape.o: $(SRC)/vmtape.c $(SRC)/vmtape.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/vmtape.c
wfio.o: $(SRC)/wfio.c $(SRC)/wfio.h
wfio.o: $(SRC)/wfio.c $(SRC)/wfio.h $(BLDSRC)/config.h
$(BUILDMOD) $(SRC)/wfio.c

View File

@ -50,6 +50,9 @@
RCSID(cenv_h,"$Id: cenv.h,v 2.6 2002/03/28 16:48:50 klh Exp $")
#endif
/* Include the configure-generated definitions */
#include "config.h"
/* Machine architecture - alpha order */
#ifndef CENV_CPU_ALPHA /* DEC Alpha AXP series */
@ -79,7 +82,7 @@
*/
#if !(CENV_CPU_M68|CENV_CPU_SPARC|CENV_CPU_PDP10|CENV_CPU_I386 \
|CENV_CPU_ALPHA|CENV_CPU_PPC)
# if defined(__alpha) || defined(__alpha__)
# if defined(__alpha) || defined(__alpha__) || defined(__x86_64__) || defined(__amd64__)
# undef CENV_CPU_ALPHA
# define CENV_CPU_ALPHA 1
# elif defined(__arm) || defined(__arm__)
@ -267,7 +270,7 @@
# define CENV_SYSF_LFS 64 /* off_t exists and has 64 bits */
# define CENV_SYSF_FSEEKO 1 /* And have some flavor of fseeko */
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS=64 /* Use 64-bit file ops */
# define _FILE_OFFSET_BITS 64 /* Use 64-bit file ops */
# endif
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE /* Include fseeko, ftello, etc */

View File

@ -202,7 +202,7 @@ void net_init(struct dpni20_s *dpni);
void eth_mcatset(struct dpni20_s *dpni);
void eth_adrset(struct dpni20_s *dpni);
void dumppkt(unsigned char *ucp, int cnt);
int arp_myreply(unsigned char *buf, int cnt);
int arp_myreply(unsigned char *buf, int cnt, struct dpx_s *dpx);
/* Error and diagnostic output */
@ -1054,7 +1054,7 @@ void eth_mcatset(struct dpni20_s *dpni)
#define ARP_PKTSIZ (sizeof(struct ether_header) + sizeof(struct ether_arp))
int arp_myreply(unsigned char *buf, int cnt)
int arp_myreply(unsigned char *buf, int cnt, struct dpx_s *dpx)
{
struct ifent *ife;
unsigned char *ucp;
@ -1138,32 +1138,38 @@ int arp_myreply(unsigned char *buf, int cnt)
eth_adrsprint(ethstr, ife->ife_ea));
}
#if 0
#if 1
/* XXX
* Why is this sent to the packet filter (= host) and not to the -10?????
*/
(void)osn_pfwrite(&pfdata, pktbuf, sizeof(pktbuf));
return FALSE;
#else
/* ARP reply packet, pass to 10 via DPC.
* Can we do that? We're not the process which normally does that...
*/
struct dpx_s *dpx;
unsigned char *buff;
size_t max;
dpx = dp_dpxfr(&dp); /* Get ptr to from-DP comm rgn */
dp_xrdone(dpx); /* First reply to the send command */
buff = dp_xsbuff(dpx, &max); /* Set up buffer ptr & max count */
if (sizeof(pktbuf) <= max &&
dp_xswait(dpx)) { /* Wait until buff free, in case */
dp_xswait(dpx)) { /* Wait until buff free, in case...
* but we can't do that, since we are
* not the process receiving that
* signal...
*/
memcpy(buff, pktbuf, ARP_PKTSIZ);
dp_xsend(dpx, DPNI_RPKT, ARP_PKTSIZ);
if (DP_DBGFLG)
dbprint("sent ARP reply to -10");
}
#endif
return TRUE;
#endif
}
/* ETHTOTEN - Main loop for thread pumping packets from Ethernet to 10.
@ -1280,7 +1286,8 @@ void tentoeth(struct dpni20_s *dpni)
/* Must check for outbound ARP requests if asked to and have
** at least one entry in our table of host's IP interfaces.
*/
doarpchk = (dpni->dpni_doarp & DPNI_ARPF_OCHK) && (osn_nifents() > 0);
/*doarpchk = (dpni->dpni_doarp & DPNI_ARPF_OCHK) && (osn_nifents() > 0);*/
doarpchk = FALSE; /* arp_myreply() is broken anyway... */
dpx = dp_dpxto(&dp); /* Get ptr to "To-DP" xfer stuff */
buff = dp_xrbuff(dpx, &max);
@ -1313,7 +1320,7 @@ void tentoeth(struct dpni20_s *dpni)
}
if (doarpchk /* If must check ARPs */
&& arp_reqcheck(buff, rcnt) /* and this is an ARP req */
&& arp_myreply(buff, rcnt)) { /* and it fits, & is hacked */
&& arp_myreply(buff, rcnt, dpx)) {/* and it fits, & is hacked */
break; /* then drop this req pkt */
}

View File

@ -46,6 +46,11 @@
#ifndef KLH10_INCLUDED
#define KLH10_INCLUDED 1
/* C environment setup definitions.
*/
#include "cenv.h" /* Get CENV_CPU_ and CENV_SYS_ */
#ifndef KLH10_USE_RCSID /* For now, default to always on */
# define KLH10_USE_RCSID 1
#endif
@ -66,18 +71,17 @@
# define KLH10_WARRANTY "This program comes \"AS IS\" with ABSOLUTELY NO WARRANTY."
#endif
#ifndef KLH10_VERSION
# define KLH10_VERSION "V2.0H"
# ifdef PACKAGE_VERSION
# define KLH10_VERSION PACKAGE_VERSION
# else
# define KLH10_VERSION "V2.0i"
# endif
#endif
#ifndef KLH10_CLIENT
# define KLH10_CLIENT "Generic"
#endif
/* C environment setup definitions.
*/
#include "cenv.h" /* Get CENV_CPU_ and CENV_SYS_ */
/* Canonical C true/false values */
#define TRUE 1
#define FALSE 0

View File

@ -42,51 +42,55 @@
** CENV_CPU_x = host CPU architecture
** CENV_SYS_x = host OS
*/
#if CENV_SYS_V7 /* Basic vanilla Unix */
# define KLH10S_CENV_SYS_ "V7"
#elif CENV_SYS_SUN /* SunOS 4.x */
# define KLH10S_CENV_SYS_ "SUN"
#elif CENV_SYS_SOLARIS /* SunOS 5.x */
# define KLH10S_CENV_SYS_ "SOLARIS"
#elif CENV_SYS_NEXT /* NeXT */
# define KLH10S_CENV_SYS_ "NEXT"
#elif CENV_SYS_MAC /* Apple Mac */
# define KLH10S_CENV_SYS_ "MAC"
#elif CENV_SYS_BSDI /* 386 BSDI */
# define KLH10S_CENV_SYS_ "BSDI"
#elif CENV_SYS_NETBSD /* NetBSD */
# define KLH10S_CENV_SYS_ "NETBSD"
#elif CENV_SYS_FREEBSD /* FreeBSD */
# define KLH10S_CENV_SYS_ "FREEBSD"
#elif CENV_SYS_OPENBSD /* FreeBSD */
# define KLH10S_CENV_SYS_ "OPENBSD"
#elif CENV_SYS_LINUX /* Linux */
# define KLH10S_CENV_SYS_ "LINUX"
#elif CENV_SYS_DECOSF /* DEC OSF/1 */
# define KLH10S_CENV_SYS_ "DECOSF"
#elif CENV_SYS_MOONMAC /* Special stuff saved for Dave Moon */
# define KLH10S_CENV_SYS_ "MOONMAC"
#elif CENV_SYS_BSD /* Generic BSD */
# define KLH10S_CENV_SYS_ "BSD"
#endif
#ifndef KLH10S_CENV_SYS_
# if CENV_SYS_V7 /* Basic vanilla Unix */
# define KLH10S_CENV_SYS_ "V7"
# elif CENV_SYS_SUN /* SunOS 4.x */
# define KLH10S_CENV_SYS_ "SUN"
# elif CENV_SYS_SOLARIS /* SunOS 5.x */
# define KLH10S_CENV_SYS_ "SOLARIS"
# elif CENV_SYS_NEXT /* NeXT */
# define KLH10S_CENV_SYS_ "NEXT"
# elif CENV_SYS_MAC /* Apple Mac */
# define KLH10S_CENV_SYS_ "MAC"
# elif CENV_SYS_BSDI /* 386 BSDI */
# define KLH10S_CENV_SYS_ "BSDI"
# elif CENV_SYS_NETBSD /* NetBSD */
# define KLH10S_CENV_SYS_ "NETBSD"
# elif CENV_SYS_FREEBSD /* FreeBSD */
# define KLH10S_CENV_SYS_ "FREEBSD"
# elif CENV_SYS_OPENBSD /* FreeBSD */
# define KLH10S_CENV_SYS_ "OPENBSD"
# elif CENV_SYS_LINUX /* Linux */
# define KLH10S_CENV_SYS_ "LINUX"
# elif CENV_SYS_DECOSF /* DEC OSF/1 */
# define KLH10S_CENV_SYS_ "DECOSF"
# elif CENV_SYS_MOONMAC /* Special stuff saved for Dave Moon */
# define KLH10S_CENV_SYS_ "MOONMAC"
# elif CENV_SYS_BSD /* Generic BSD */
# define KLH10S_CENV_SYS_ "BSD"
# endif /* CENV_SYS_* */
#endif /* KLH10S_CENV_SYS_ */
#if CENV_CPU_ALPHA /* DEC Alpha AXP series */
# define KLH10S_CENV_CPU_ "ALPHA"
#elif CENV_CPU_ARM /* DEC/Intel ARM series */
# define KLH10S_CENV_CPU_ "ARM"
#elif CENV_CPU_I386 /* Intel 386/486 */
# define KLH10S_CENV_CPU_ "I386"
#elif CENV_CPU_M68 /* MC680x0 series */
# define KLH10S_CENV_CPU_ "M68"
#elif CENV_CPU_PDP10 /* DEC PDP10 series */
# define KLH10S_CENV_CPU_ "PDP10"
#elif CENV_CPU_PPC /* IBM/Motorola PowerPC series */
# define KLH10S_CENV_CPU_ "PPC"
#elif CENV_CPU_SPARC /* SUN SPARC series */
# define KLH10S_CENV_CPU_ "SPARC"
#else
# define KLH10S_CENV_CPU_ "unknown"
#endif
#ifndef KLH10S_CENV_CPU_
# if CENV_CPU_ALPHA /* DEC Alpha AXP series */
# define KLH10S_CENV_CPU_ "ALPHA"
# elif CENV_CPU_ARM /* DEC/Intel ARM series */
# define KLH10S_CENV_CPU_ "ARM"
# elif CENV_CPU_I386 /* Intel 386/486 */
# define KLH10S_CENV_CPU_ "I386"
# elif CENV_CPU_M68 /* MC680x0 series */
# define KLH10S_CENV_CPU_ "M68"
# elif CENV_CPU_PDP10 /* DEC PDP10 series */
# define KLH10S_CENV_CPU_ "PDP10"
# elif CENV_CPU_PPC /* IBM/Motorola PowerPC series */
# define KLH10S_CENV_CPU_ "PPC"
# elif CENV_CPU_SPARC /* SUN SPARC series */
# define KLH10S_CENV_CPU_ "SPARC"
# else
# define KLH10S_CENV_CPU_ "unknown"
# endif /* CENV_CPU_* */
#endif /* KLH10S_CENV_CPU_ */
/* Compilation switches defining desired emulation target */

View File

@ -38,8 +38,8 @@
# include "osdnet.h" /* Insurance to make sure our defs are there */
#endif
#if KLH10_NET_TAP && (CENV_SYS_NETBSD || CENV_SYS_FREEBSD)
#include <net/if_tap.h>
#if KLH10_NET_BRIDGE && !KLH10_NET_TAP
# error "A bridge is useless without a TAP device... configuration error!"
#endif
/* Local predeclarations */
@ -59,13 +59,13 @@ static ssize_t osn_pfread_fd(struct pfdata *pfdata, void *buf, size_t nbytes);
static int osn_pfwrite_fd(struct pfdata *pfdata, const void *buf, size_t nbytes);
#endif /* TUN || TAP */
#if KLH10_NET_BRIDGE
struct tuntap_context;
#if KLH10_NET_BRIDGE
void bridge_create(struct tuntap_context *tt_ctx, struct osnpf *osnpf);
void tap_bridge_close(struct tuntap_context *tt_ctx);
#endif
#endif /* KLH10_NET_BRIDGE */
static void osn_iff_up(int s, char *ifname);
static void osn_iff_down(int s, char *ifname);
static int pfopen_create(char *basename, struct tuntap_context *tt_ctx, struct osnpf *osnpf);
/* Get a socket descriptor suitable for general net interface
examination and manipulation; this is not necessarily suitable for
@ -380,22 +380,26 @@ osn_iftab_arpget(struct in_addr ia, unsigned char *eap)
/* OSN_IPDEFAULT - Find a default IP interface entry;
* if the environment variable KLH_NET_DEFAULT_IF is set and an interface
* by that name can be found, return ir,
* otherwise take the first one that's up and isn't a loopback.
* by that name can be found, return it,
* otherwise take the first one that has an IPv4 address,
* is up and isn't a loopback.
*/
struct ifent *
osn_ipdefault(void)
{
int i = 0;
struct ifent *ife;
char *envif = getenv("KLH_NET_DEFAULT_IF");
char *envif = getenv("KLH10_NET_DEFAULT_IF");
if (envif && (ife = osn_iflookup(envif)))
return ife;
for (ife = iftab; i < iftab_nifs; ++i, ++ife)
if ((ife->ife_flags & IFF_UP) && !(ife->ife_flags & IFF_LOOPBACK))
for (ife = iftab; i < iftab_nifs; ++i, ++ife) {
if ( ife->ife_gotip4 &&
(ife->ife_flags & IFF_UP) &&
!(ife->ife_flags & IFF_LOOPBACK))
return ife;
}
return NULL;
}
@ -497,6 +501,27 @@ osn_ifnmlookup(char *ifnam, /* Interface name */
return FALSE;
}
#if CENV_SYS_LINUX
int
set_proc_variable(char *template, char *ifname, char *value)
{
int fd;
char devproc[128];
snprintf(devproc, sizeof(devproc)-1, template, ifname);
fd = open(devproc, O_WRONLY|O_TRUNC);
if (fd >= 0) {
(void)write(fd, value, strlen(value));
close(fd);
return TRUE;
}
return FALSE;
}
#endif /* CENV_SYS_LINUX */
/* OSN_ARP_STUFF - stuff emulated-host ARP entry into kernel.
** Note it isn't necessary to specify an interface!
** Also, the code assumes that if an ARP entry already exists in the
@ -516,7 +541,8 @@ osn_arp_stuff(char *ifname, unsigned char *ipa, unsigned char *eap, int pubf)
(pubf ? "pub" : ""));
}
#if CENV_SYS_LINUX && OSN_USE_IPONLY
#if CENV_SYS_LINUX
# if OSN_USE_IPONLY
/**
* Linux won't do proxy ARP by default. It needs to be turned on.
* This is needed when we use an Ethernet device, not an IP tunnel.
@ -544,17 +570,10 @@ osn_arp_stuff(char *ifname, unsigned char *ipa, unsigned char *eap, int pubf)
* So, that helps with a tunnel device, not with a tap device.
* Why then does linux have ATF_PUBL flags in its ARP table?
*/
int fd;
char devproc[64];
snprintf(devproc, sizeof(devproc)-1, "/proc/sys/net/ipv4/conf/%s/proxy_arp", ifname);
/*
* or sysctl -w net.ipv4.conf.%s.proxy_arp=1
*/
fd = open(devproc, O_WRONLY|O_TRUNC);
if (fd >= 0) {
(void)write(fd, "1\n", 2);
close(fd);
if (set_proc_variable("/proc/sys/net/ipv4/conf/%s/proxy_arp", ifname, "1\n")) {
dbprintln("Enabled net.ipv4.conf.%s.proxy_arp", ifname);
}
/*
@ -568,13 +587,20 @@ osn_arp_stuff(char *ifname, unsigned char *ipa, unsigned char *eap, int pubf)
*
* Or sysctl -w net.ipv4.ip_forward=1
*/
fd = open("/proc/sys/net/ipv4/ip_forward", O_WRONLY|O_TRUNC);
if (fd >= 0) {
(void)write(fd, "1\n", 2);
close(fd);
if (set_proc_variable("/proc/sys/net/ipv4/ip_forward", "", "1\n")) {
dbprintln("Enabled net.ipv4.ip_forward");
}
#endif /* CENV_SYS_LINUX && OSN_USE_IPONLY */
#endif /* OSN_USE_IPONLY */
/*
* It seems that if arp_accept=0, then ARP packets that are received
* are not only ignored by the kernel, but also not passed to
* the packet filter. That is bad: they may be for us!
* Disable this lossage.
*/
if (set_proc_variable("/proc/sys/net/ipv4/conf/%s/arp_accept", ifname, "1\n")) {
dbprintln("Enabled net.ipv4.conf.%s.arp_accept", ifname);
}
#endif /* CENV_SYS_LINUX */
#if NETIF_HAS_ARPIOCTL
struct arpreq arq;
@ -1351,7 +1377,7 @@ osn_pfinit_pcap(struct pfdata *pfdata, struct osnpf *osnpf, void *pfarg)
arrives!
See read loops in osn_pfread_pcap() below for workaround.
*/
#if HAVE_LIBPCAP_SET_IMMEDIATE_MODE
#if HAVE_PCAP_SET_IMMEDIATE_MODE
if (pcap_set_immediate_mode(pc, 1) < 0) {
what = "pcap_set_immediate_mode";
goto error;
@ -1506,10 +1532,12 @@ osn_pfwrite_pcap(struct pfdata *pfdata, const void *buf, size_t nbytes)
struct tuntap_context {
int my_tap;
char saved_ifnam[IFNAM_LEN];
#if KLH10_NET_BRIDGE && (CENV_SYS_NETBSD || CENV_SYS_FREEBSD)
struct ifreq br_ifr;
#if CENV_SYS_XBSD
struct ifreq tap_ifr;
#endif
# if KLH10_NET_BRIDGE
struct ifreq br_ifr;
# endif /* KLH10_NET_BRIDGE */
#endif /* CENV_SYS_XBSD */
};
/*
@ -1577,10 +1605,7 @@ pfopen(char *basename, struct tuntap_context *tt_ctx, struct osnpf *osnpf)
return fd; /* Success! */
}
#endif /* KLH10_NET_TUN || _TAP */
#if KLH10_NET_TUN || KLH10_NET_TAP
# if CENV_SYS_LINUX
# define TUN_BASE "/dev/net/tun"
@ -1657,6 +1682,7 @@ osn_pfinit_tuntap(struct pfdata *pfdata, struct osnpf *osnpf, void *arg)
struct in_addr iplocal; /* TUN ifc address at hardware OS end */
struct in_addr ipremote; /* Address at remote (emulated guest) end */
static unsigned char ipremset[4] = { 192, 168, 0, 44};
int s;
/* Remote address is always that of emulated machine */
ipremote = osnpf->osnpf_ip.ia_addr;
@ -1711,6 +1737,10 @@ osn_pfinit_tuntap(struct pfdata *pfdata, struct osnpf *osnpf, void *arg)
memset(&ifr, 0, sizeof(ifr));
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
esfatal(1, "pf_init: tun socket() failed");
}
#if CENV_SYS_LINUX /* [BV: Linux way] */
if (pfdata->pf_meth == PF_METH_TUN) {
ifr.ifr_flags = IFF_TUN | IFF_NO_PI; /* TUN (no Ethernet headers), no pkt info */
@ -1775,8 +1805,7 @@ osn_pfinit_tuntap(struct pfdata *pfdata, struct osnpf *osnpf, void *arg)
*/
#if CENV_SYS_LINUX /* [BV: Linux tun device] */
if (pfdata->pf_ip4_only) {
/* "Hacky" but simple method */
char cmdbuff[128];
char cmdbuff[128]; /* "Hacky" but simple method */
int res;
/* ifconfig DEV IPLOCAL pointopoint IPREMOTE */
@ -1793,14 +1822,9 @@ osn_pfinit_tuntap(struct pfdata *pfdata, struct osnpf *osnpf, void *arg)
#else /* not CENV_SYS_LINUX */
{
/* Internal method */
int s;
struct ifaliasreq ifra;
struct ifreq ifr;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
esfatal(1, "pf_init: tun socket() failed");
}
/* Delete first (only) IP address for this device, if any.
Ignore errors.
*/
@ -1828,12 +1852,14 @@ osn_pfinit_tuntap(struct pfdata *pfdata, struct osnpf *osnpf, void *arg)
}
}
/* Finally, turn on IFF_UP just in case the above didn't do it.
*/
osn_iff_up(s, ifnam);
}
#endif /* CENV_SYS_LINUX */
/* Finally, turn on IFF_UP just in case the above didn't do it.
*/
osn_iff_up(s, ifnam);
close(s);
/* Now optionally determine ethernet address.
This amounts to what if anything we should put in the native
host's ARP tables.
@ -1964,7 +1990,6 @@ osn_pfwrite_fd(struct pfdata *pfdata, const void *buf, size_t nbytes)
return write(pfdata->pf_fd, buf, nbytes);
}
#endif /* KLH10_NET_TAP || KLH10_NET_TUN */
#if CENV_SYS_NETBSD
@ -1980,6 +2005,7 @@ osn_pfwrite_fd(struct pfdata *pfdata, const void *buf, size_t nbytes)
* and we'll just use it as it is. This is useful for a routed approach,
* for instance.
*/
static
int
pfopen_create(char *basename, struct tuntap_context *tt_ctx, struct osnpf *osnpf)
{
@ -2040,6 +2066,7 @@ pfopen_create(char *basename, struct tuntap_context *tt_ctx, struct osnpf *osnpf
return tapfd;
}
#endif /* CENV_SYS_NETBSD */
#endif /* KLH10_NET_TAP || KLH10_NET_TUN */
#if KLH10_NET_BRIDGE
#if (CENV_SYS_NETBSD || CENV_SYS_FREEBSD)
@ -2124,7 +2151,7 @@ tap_bridge_close(struct tuntap_context *tt_ctx)
* Therefore, we do connect to a bridge if wanted, but we're not creating
* one at all.
*
* The bridge name is given in environment variable KLH_NET_BRIDGE.
* The bridge name is given in environment variable KLH10_NET_BRIDGE.
*
* See: http://www.microhowto.info/troubleshooting/troubleshooting_ethernet_bridging_on_linux.html#idp86992
*
@ -2151,9 +2178,11 @@ bridge_create(struct tuntap_context *tt_ctx, struct osnpf *osnpf)
if (!tt_ctx->my_tap)
return;
br_name = getenv("KLH_NET_BRIDGE");
if (!br_name)
return;
br_name = getenv("KLH10_NET_BRIDGE");
if (!br_name) {
br_name = "bridge0";
error("Can't find name of bridge: $KLH10_NET_BRIDGE is unset. Trying with \"%s\"", br_name);
}
if ((s = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
esfatal(1, "bridge_create: socket() failed");
@ -2176,12 +2205,13 @@ bridge_create(struct tuntap_context *tt_ctx, struct osnpf *osnpf)
ifr.ifr_data = (void *)ifargs;
res = ioctl(s, SIOCDEVPRIVATE, &ifr);
#endif
dbprintln("linux bridge_create: ioctl res=%d", res);
if (res == -1) {
esfatal(1, "bridge_create: can't add interface \"%s\" to bridge \"%s\"?", osnpf->osnpf_ifnam, br_name);
}
if (swstatus) {
dbprintln("Attached \"%s\" to bridge \"%s\"",
dbprintln("Attached \"%s\" to bridge \"%s\"",
osnpf->osnpf_ifnam, br_name);
}
@ -2220,24 +2250,6 @@ static void osn_iff_up(int s, char *ifname)
}
}
static void osn_iff_down(int s, char *ifname)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
esfatal(1, "osn_iff_up SIOCGIFFLAGS %S failed", ifname);
}
if (ifr.ifr_flags & IFF_UP) {
ifr.ifr_flags ^= IFF_UP;
if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
esfatal(1, "osn_iff_up SIOCSIFFLAGS %S failed", ifname);
}
}
}
#if KLH10_NET_DLPI

View File

@ -32,10 +32,6 @@
#ifndef OSDNET_INCLUDED
#define OSDNET_INCLUDED 1
#ifdef RCSID
RCSID(osdnet_h,"$Id: osdnet.h,v 2.5 2001/11/19 10:34:01 klh Exp $")
#endif
#include "klh10.h" /* Ensure have config params */
/* Determine whether only doing IP stuff, or if all ethernet interface
@ -45,64 +41,6 @@
# define OSN_USE_IPONLY 0 /* Default is to include everything */
#endif
/* Determine net ifc to compile for - NIT, DLPI, PFLT, BPF, TUN, LNX
*/
#ifndef KLH10_NET_BPF /* OSF/1 Berkeley Packet Filter */
# define KLH10_NET_BPF 0
#endif
#ifndef KLH10_NET_PFLT /* OSF/1 CMU/Stanford packetfilter */
# define KLH10_NET_PFLT 0
#endif
#ifndef KLH10_NET_NIT /* SunOS Network Interface Tap */
# define KLH10_NET_NIT 0
#endif
#ifndef KLH10_NET_DLPI /* Solaris Data Link Provider Interface */
# define KLH10_NET_DLPI 0
#endif
#ifndef KLH10_NET_TUN /* IP Tunnel device */
# define KLH10_NET_TUN 0
#endif
#ifndef KLH10_NET_TAP /* Ethernet Tunnel device */
# define KLH10_NET_TAP 0
#endif
#ifndef KLH10_NET_BRIDGE /* Bridge (used with an Ethernet tunnel) */
# define KLH10_NET_BRIDGE 0
#endif
#ifndef KLH10_NET_PCAP /* pretty generic libpcap interface */
# define KLH10_NET_PCAP 0
#endif
#if !(KLH10_NET_NIT || KLH10_NET_DLPI || KLH10_NET_BPF || KLH10_NET_PFLT || \
KLH10_NET_LNX || KLH10_NET_PCAP || KLH10_NET_TUN || KLH10_NET_BRIDGE)
/* None explicitly specified, pick a reasonable default */
# undef KLH10_NET_PCAP
# define KLH10_NET_PCAP 1
# if (CENV_SYS_NETBSD || CENV_SYS_FREEBSD || CENV_SYS_LINUX)
# undef KLH10_NET_TUN
# define KLH10_NET_TUN 1
# undef KLH10_NET_TAP
# define KLH10_NET_TAP 1
# undef KLH10_NET_BRIDGE
# define KLH10_NET_BRIDGE 1
# elif CENV_SYS_DECOSF
# undef KLH10_NET_PFLT
# define KLH10_NET_PFLT 1
# elif CENV_SYS_SUN
# undef KLH10_NET_NIT
# define KLH10_NET_NIT 1
# elif CENV_SYS_SOLARIS
# undef KLH10_NET_DLPI
# define KLH10_NET_DLPI 1
# else
# error "Must specify a KLH10_NET_ configuration"
# endif
#endif
/* Ensure this is defined in order to get right stuff for DECOSF */
#define _SOCKADDR_LEN
@ -122,47 +60,80 @@
# define ossock_t int /* No typedef until code revised */
#endif /* CENV_SYS_UNIX */
#if KLH10_NET_NIT
#if HAVE_NET_IF_TUN_H
# include <net/if_tun.h>
# define KLH10_NET_TUN 1
#endif
#if HAVE_NET_IF_TAP_H
# include <net/if_tap.h>
# define KLH10_NET_TAP 1
#endif
#if HAVE_LINUX_IF_TUN_H
# include <linux/if_tun.h>
# define KLH10_NET_TUN 1
# define KLH10_NET_TAP 1
#endif
#if HAVE_LINUX_IF_PACKET_H
# include <linux/if_packet.h> /* For struct sockaddr_ll with AF_PACKET */
#endif
# if HAVE_NET_IF_DL_H
# include <net/if_dl.h> /* For sockaddr_dl with AF_LINK */
# include <net/if_types.h> /* For IFT_ETHER */
#endif
#if HAVE_LIBPCAP
# undef BPF_MAJOR_VERSION /* some stupid linux header defines this:
* <linux_filter.h> included from
* <linux/if_tun,h>; only in SOME versions.
*/
# include <pcap/pcap.h>
# include <pcap/bpf.h>
# define KLH10_NET_PCAP 1
#endif
#if HAVE_GETIFADDRS
# include <ifaddrs.h>
#endif
#if !defined(KLH10_NET_BRIDGE) && KLH10_NET_TAP && (CENV_SYS_XBSD || CENV_SYS_LINUX)
# define KLH10_NET_BRIDGE 1 /* Use bridge if possible, unless disabled */
#endif
#if HAVE_NET_NIT_H
# define KLH10_NET_NIT 1
# include <sys/stropts.h> /* For stream operations */
# include <net/nit.h> /* For NIT */
# include <net/nit_if.h> /* For NIT */
# include <net/nit_pf.h> /* For packet filtering */
# include <net/packetfilt.h> /* For packet filtering */
#elif KLH10_NET_DLPI
#elif HAVE_SYS_DLPI_H
# define KLH10_NET_DLPI 1
# include <sys/sockio.h>
# include <sys/stropts.h>
# include <sys/dlpi.h>
# include <sys/pfmod.h> /* For packet filtering */
# include <arpa/inet.h>
#elif KLH10_NET_PFLT
# include <net/pfilt.h>
#elif KLH10_NET_BPF
# include <sys/uio.h>
# include <net/bpf.h>
# include <net/if_dl.h>
# include <net/if_types.h>
#elif KLH10_NET_LNX
# include <sys/uio.h>
# include <sys/socket.h>
# include <features.h> /* for the glibc version number */
# if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
# include <netpacket/packet.h>
# include <net/ethernet.h> /* the L2 protocols */
# else
# include <asm/types.h>
# 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
/* Set KLH10_NET_* values to default, if not set yet.
*/
#ifndef KLH10_NET_NIT /* SunOS Network Interface Tap */
# define KLH10_NET_NIT 0
#endif
#ifndef KLH10_NET_DLPI /* Solaris Data Link Provider Interface */
# define KLH10_NET_DLPI 0
#endif
#ifndef KLH10_NET_TUN /* IP Tunnel device */
# define KLH10_NET_TUN 0
#endif
#ifndef KLH10_NET_TAP /* Ethernet Tunnel device */
# define KLH10_NET_TAP 0
#endif
#ifndef KLH10_NET_BRIDGE /* Bridge (used with an Ethernet tunnel) */
# define KLH10_NET_BRIDGE 0
#endif
#ifndef KLH10_NET_PCAP /* pretty generic libpcap interface */
# define KLH10_NET_PCAP 0
#endif
#ifndef FALSE
# define FALSE 0
#endif
@ -175,14 +146,6 @@
XXX This location and the names are temporary until the OSDNET API is
made more complete and opaque.
*/
#if KLH10_NET_BPF
# include <net/bpf.h>
/* MTU to use for input, rounded the way BPF wants it. */
# define OSN_BPF_MTU \
(BPF_WORDALIGN(1514) + BPF_WORDALIGN(sizeof(struct bpf_hdr)))
#endif
/* Packet filter definitions */
@ -203,83 +166,12 @@
#define PKSWOFF_IPDEST (7+(IPBOFF_DEST/2)) /* 1st (high) sw of IP dest */
/* Determine whether:
* (1) sockaddr contains sa_len (NETIF_HAS_SALEN)
* (2) ifconf provides physical link addrs (NETIF_HAS_AF_LINK or
* NETIF_HAS_AF_PACKET)
* (3) ARP ioctls exist (NETIF_HAS_ARPIOCTL)
*
* 4.4BSD DECOSF SunOS Solaris Linux
* NETIF_HAS_SALEN yes yes no no no
* NETIF_HAS_AF_LINK yes yes no no no
* NETIF_HAS_AF_PACKET no ? ? ? yes
* NETIF_HAS_ARPIOCTL no yes yes yes yes
*/
#ifndef NETIF_HAS_SALEN /* If not explicitly told, see if known OS */
# if CENV_SYS_XBSD || CENV_SYS_DECOSF
# define NETIF_HAS_SALEN 1
# elif CENV_SYS_SUN || CENV_SYS_SOLARIS || CENV_SYS_LINUX
# define NETIF_HAS_SALEN 0
# endif
#endif
#ifndef NETIF_HAS_SALEN /* If still not defined, try to guess */
# ifdef AF_LINK /* Existence of this implies we can win */
# define NETIF_HAS_SALEN 1
# else
# define NETIF_HAS_SALEN 0
# endif
#endif
#if !defined(NETIF_HAS_AF_PACKET)
#if CENV_SYS_LINUX || defined(AF_PACKET)
#define NETIF_HAS_AF_PACKET 1
#else
#define NETIF_HAS_AF_PACKET 0
#endif
#endif /* !defined(NETIF_HAS_AF_PACKET) */
#if NETIF_HAS_AF_PACKET
#include <linux/if_packet.h> /* For struct sockaddr_ll */
#endif /* NETIF_HAS_AF_PACKET */
#if NETIF_HAS_SALEN
# ifdef AF_LINK
# include <net/if_dl.h> /* For sockaddr_dl */
# include <net/if_types.h> /* For IFT_ETHER */
# endif
# ifdef LLADDR /* Double-check, make sure this is defined */
# define NETIF_HAS_AF_LINK 1
# else
# define NETIF_HAS_AF_LINK 0
# endif
#else
# define NETIF_HAS_AF_LINK 0
#endif
#ifdef SIOCGARP
# define NETIF_HAS_ARPIOCTL 1
#else
# define NETIF_HAS_ARPIOCTL 0
#endif
#define HAVE_GETIFADDRS 1 /* assume this for now */
#define HAVE_LIBPCAP 1 /* assume this for now */
#define HAVE_LIBPCAP_SET_IMMEDIATE_MODE (!CENV_SYS_FREEBSD)
#if HAVE_LIBPCAP
# undef BPF_MAJOR_VERSION /* some stupid linux header defines this:
* <linux_filter.h> included from
* <linux/if_tun,h>; only in SOME versions.
*/
# define USE_LIBPCAP 1
# include <pcap/pcap.h>
# include <pcap/bpf.h>
#endif
#if HAVE_GETIFADDRS
# include <ifaddrs.h>
#endif
#if !HAVE_LIBPCAP && !HAVE_GETIFADDRS
#error "Sorry, can't lookup ethernet interfaces without getifaddrs(3) or libpcap"
#endif
@ -351,14 +243,6 @@ struct ifent {
#define ETHER_PX_DAT 14 /* Data bytes */
/* CRC comes after data, which is variable-length */
#if KLH10_NET_BPF && !(CENV_SYS_SUN || CENV_SYS_NETBSD || CENV_SYS_FREEBSD)
/* For compatibility with SunOS definition.
Needed for BPF, but most BSD-ish systems already define it??
Not really sure why this is here.
*/
struct ether_addr { unsigned char crud[ETHER_ADRSIZ]; };
#endif
/* Ethernet address. Use ETHER_ADRSIZ for actual size. */
struct eth_addr {
unsigned char ea_octets[ETHER_ADRSIZ];

6
src/vaddr-sucks.h Normal file
View File

@ -0,0 +1,6 @@
/* DO NOT EDIT - conditionally used, see configure */
#define vaddr_t _kernel_vaddr_t
#define paddr_t _kernel_paddr_t
#include <sys/types.h>
#undef paddr_t
#undef vaddr_t

View File

@ -399,6 +399,9 @@ the possibility of multiprocess or even multiprocessor operation.
** The default is not to try bitfields even though they might provide
** more efficiency, since the way they are used is non-portable
** and needs to be verified for each platform.
** This has to be thoroughly checked by running the wxtest program;
** the code hasn't even been test-compiled recently, since there were
** compile errors in it.
*/
#ifndef WORD10_BITF /* Unless explicitly requested, */
# define WORD10_BITF 0 /* portable default does without bitfields */
@ -509,7 +512,7 @@ typedef unsigned WORD10_INT32 uint32;
# define WORD10_OVBITS (((sizeof(w10uint_t)/sizeof(char))*CHAR_BIT) - 36)
# define WORD10_OVDEF int ovfl : WORD10_OVBITS;
# endif
struct {
typedef struct {
# if WORD10_BITFBIGEND /* Left-to-right order? */
WORD10_OVDEF
signed int lh : H10BITS;
@ -520,7 +523,7 @@ typedef unsigned WORD10_INT32 uint32;
WORD10_OVDEF
# endif
} w10sbitf_t;
struct {
typedef struct {
# if WORD10_BITFBIGEND /* Left-to-right order? */
WORD10_OVDEF
unsigned int lh : H10BITS;