mirror of
https://github.com/PDP-10/klh10.git
synced 2026-02-05 16:05:30 +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:
152
src/Makefile.mk
152
src/Makefile.mk
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
25
src/dpni20.c
25
src/dpni20.c
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
16
src/klh10.h
16
src/klh10.h
@@ -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
|
||||
|
||||
92
src/klh10s.h
92
src/klh10s.h
@@ -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 */
|
||||
|
||||
|
||||
142
src/osdnet.c
142
src/osdnet.c
@@ -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
|
||||
|
||||
|
||||
236
src/osdnet.h
236
src/osdnet.h
@@ -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
6
src/vaddr-sucks.h
Normal 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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user