diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f01aa16..d13ab177 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,24 +127,27 @@ ENDIF() # the following 2 lines should produce a dropdown-box in the cmake-gui # but this will happen only after running the command line version of cmake, # possibly after "clearing the cache" (i.e. starting with a fresh build directory) -SET(MAIKO_NETWORK_TYPE NONE CACHE STRING "Type of networking to use: one of: NONE, SUN_DLPI, SUN_NIT, NETHUB") -SET_PROPERTY(CACHE MAIKO_NETWORK_TYPE PROPERTY STRINGS NONE SUN_DLPI SUN_NIT NETHUB) +SET(MAIKO_NETWORK_TYPE NONE CACHE STRING "Type of network implementation to use: one of: NONE, PCAP, SUN_DLPI, SUN_NIT, NETHUB") +SET_PROPERTY(CACHE MAIKO_NETWORK_TYPE PROPERTY STRINGS NONE PCAP SUN_DLPI SUN_NIT NETHUB) # configure networking implementation to use IF(MAIKO_NETWORK_TYPE STREQUAL "NETHUB") - LIST(APPEND MAIKO_DEFINITIONS "-DMAIKO_ENABLE_NETHUB") - MESSAGE("-- Configured for NETHUB network support") + LIST(APPEND MAIKO_DEFINITIONS "-DMAIKO_ENABLE_ETHERNET -DUSE_NETHUB") + MESSAGE("-- Configured for NETHUB network implementation") ELSEIF(MAIKO_NETWORK_TYPE STREQUAL "SUN_DLPI") LIST(APPEND MAIKO_DEFINITIONS "-DMAIKO_ENABLE_ETHERNET -DUSE_DLPI") - MESSAGE("-- Configured for (SunOS) DLPI networking") + MESSAGE("-- Configured for (SunOS) DLPI network implementation") ELSEIF(MAIKO_NETWORK_TYPE STREQUAL "SUN_NIT") LIST(APPEND MAIKO_DEFINITIONS "-DMAIKO_ENABLE_ETHERNET -DUSE_NIT") - MESSAGE("-- Configured for (SunOS) NIT networking") + MESSAGE("-- Configured for (SunOS) NIT network implementation") +ELSEIF(MAIKO_NETWORK_TYPE STREQUAL "PCAP") + LIST(APPEND MAIKO_DEFINITIONS "-DMAIKO_ENABLE_ETHERNET -DUSE_PCAP") + LIST(APPEND MAIKO_LIBRARIES "pcap") + MESSAGE("-- Configured for PCAP network implementation") ELSEIF(NOT MAIKO_NETWORK_TYPE STREQUAL "NONE") - MESSAGE(WARNING "Invalid option given for MAIKO_NETWORK_TYPE, must be one of:\nNONE, SUN_DLPI, SUN_NIT, NETHUB") + MESSAGE(WARNING "Invalid option given for MAIKO_NETWORK_TYPE, must be one of:\nNONE, PCAP, SUN_DLPI, SUN_NIT, NETHUB") ENDIF() - IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") LIST(APPEND MAIKO_DEFINITIONS "-DOS5" @@ -220,6 +223,7 @@ SET(MAIKO_SRCS src/ether_common.c src/ether_sunos.c src/ether_nethub.c + src/ether_pcap.c src/findkey.c src/foreign.c src/fp.c @@ -469,9 +473,12 @@ IF(MAIKO_DISPLAY_SDL) TARGET_COMPILE_DEFINITIONS(lde PRIVATE ${MAIKO_DISPLAY_SDL_DEFINITIONS}) ENDIF() -ADD_EXECUTABLE(ldeether src/ldeether.c src/dlpi.c) -TARGET_COMPILE_DEFINITIONS(ldeether PRIVATE ${MAIKO_DEFINITIONS}) -TARGET_INCLUDE_DIRECTORIES(ldeether PRIVATE inc) +IF(MAIKO_NETWORK_TYPE STREQUAL "SUN_DLPI" OR MAIKO_NETWORK_TYPE STREQUAL "SUN_NIT") + MESSAGE("-- Adding ldeether") + ADD_EXECUTABLE(ldeether src/ldeether.c src/dlpi.c) + TARGET_COMPILE_DEFINITIONS(ldeether PRIVATE ${MAIKO_DEFINITIONS}) + TARGET_INCLUDE_DIRECTORIES(ldeether PRIVATE inc) +ENDIF() IF(MAIKO_DISPLAY_X11) ADD_EXECUTABLE(ldex diff --git a/bin/compile-flags b/bin/compile-flags index eeac4ab2..ee3a867d 100755 --- a/bin/compile-flags +++ b/bin/compile-flags @@ -124,19 +124,20 @@ BIGATOMS True if this emulator will support 3-byte symbols, instead of NEWBITBLT True if we want to use assembler BITBLT code, rather than have code created inline by macro calls. -USE_DLPI True if the ethernet API is via the SysV Data Link Provider - Interface. Solaris uses DLPI. - -USE_NIT True if the ethernet API is via the Network Interface Tap. - SunOS uses NIT. - +MAIKO_ENABLE_ETHERNET enables support for networking, the flavor of networking + is chosen with a USE_xxx flag as follows + USE_NETHUB - Dodo Nethub networking for Dodo XNS services, see + documentation: Using-Dodo-networking-with-Maiko.md + USE_PCAP - raw ethernet access for XNS and PUP networking using + the libpcap library + USE_DLPI - raw ethernet access for XNS networking using the + data link provider interface (Solaris only) + USE_NIT - raw ethernet access for XNS networking using the + /dev/nit interface (SunOS/Solaris 1 only) + PKTFILTER True if the ethernet packets are to be filtered before being passed to the Lisp ethernet handler. Available on Sun systems - for both the NIT and DLPI cases. - -MAIKO_ENABLE_NETHUB enables the support for Dodo Nethub networking for Dodo - XNS services, see documentation: using-dodo-networking-with-maiko.md - (implicitely disables USE_DLPI and USE_NIT) + for both the USE_NIT and USE_DLPI cases. MAIKO_EMULATE_TIMER_INTERRUPTS enables emulation of recurring timer interrupts for platforms where SIGVTALRM/ITIMER_VIRTUAL or SIGALRM/ITIMER_REAL diff --git a/bin/linux-x.mk b/bin/linux-x.mk index 730eea1a..34b52cbe 100644 --- a/bin/linux-x.mk +++ b/bin/linux-x.mk @@ -2,7 +2,6 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-darwin.386-x b/bin/makefile-darwin.386-x index 8b6f4870..91622868 100644 --- a/bin/makefile-darwin.386-x +++ b/bin/makefile-darwin.386-x @@ -4,7 +4,6 @@ CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-darwin.aarch64-x b/bin/makefile-darwin.aarch64-x index 37da65ef..2f322c3a 100644 --- a/bin/makefile-darwin.aarch64-x +++ b/bin/makefile-darwin.aarch64-x @@ -4,7 +4,6 @@ CC = clang -target aarch64-apple-darwin $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-darwin.ppc-x b/bin/makefile-darwin.ppc-x index 89140761..0a1d4fe4 100644 --- a/bin/makefile-darwin.ppc-x +++ b/bin/makefile-darwin.ppc-x @@ -4,7 +4,6 @@ CC = cc $(GCC_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-darwin.x86_64-x b/bin/makefile-darwin.x86_64-x index 35a6be8a..f789b1fb 100644 --- a/bin/makefile-darwin.x86_64-x +++ b/bin/makefile-darwin.x86_64-x @@ -4,7 +4,6 @@ CC = clang -target x86_64-apple-darwin $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-emscripten.wasm-wasm b/bin/makefile-emscripten.wasm-wasm index 37f213a3..67780b17 100644 --- a/bin/makefile-emscripten.wasm-wasm +++ b/bin/makefile-emscripten.wasm-wasm @@ -14,7 +14,7 @@ XFLAGS = -DSDL=2 -sUSE_SDL=2 # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -DMAIKO_ENABLE_NETHUB +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -DMAIKO_ENABLE_ETHERNET -DUSE_NETHUB MEDLEY?=../../medley SYSOUT?=$(MEDLEY)/loadups/full.sysout diff --git a/bin/makefile-emscripten.wasm_nl-wasm_nl b/bin/makefile-emscripten.wasm_nl-wasm_nl index 3ec7af1e..cca40ed2 100644 --- a/bin/makefile-emscripten.wasm_nl-wasm_nl +++ b/bin/makefile-emscripten.wasm_nl-wasm_nl @@ -14,7 +14,7 @@ XFLAGS = -DSDL=2 -sUSE_SDL=2 # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -DMAIKO_ENABLE_NETHUB +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -DMAIKO_ENABLE_ETHERNET -DUSE_NETHUB MEDLEY?=../../medley SYSOUT?=$(MEDLEY)/loadups/full.sysout diff --git a/bin/makefile-freebsd.386-x b/bin/makefile-freebsd.386-x index bb42820c..712ea982 100644 --- a/bin/makefile-freebsd.386-x +++ b/bin/makefile-freebsd.386-x @@ -4,7 +4,6 @@ CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-freebsd.aarch64-x b/bin/makefile-freebsd.aarch64-x index 699bd2ae..843950c9 100644 --- a/bin/makefile-freebsd.aarch64-x +++ b/bin/makefile-freebsd.aarch64-x @@ -4,7 +4,6 @@ CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-freebsd.x86_64-x b/bin/makefile-freebsd.x86_64-x index 1c17157b..94bd66fc 100644 --- a/bin/makefile-freebsd.x86_64-x +++ b/bin/makefile-freebsd.x86_64-x @@ -4,7 +4,6 @@ CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-header b/bin/makefile-header index 705a7b5a..24aa1dc5 100755 --- a/bin/makefile-header +++ b/bin/makefile-header @@ -16,6 +16,19 @@ CLANG_CFLAGS = -std=gnu99 -fno-strict-aliasing GCC_CFLAGS = -std=gnu99 -fno-strict-aliasing DEVSTUDIO_CFLAGS = -std=gnu99 -fno-strict-aliasing +# Network implementations +NETWORK = NONE # NONE, PCAP, SUN_DLPI, SUN_NIT, NETHUB +NETWORK_CC_NONE = +NETWORK_CC_PCAP = -DMAIKO_ENABLE_ETHERNET -DUSE_PCAP +NETWORK_CC_NETHUB = -DMAIKO_ENABLE_ETHERNET -DUSE_NETHUB +NETWORK_CC_SUN_DLPI = -DMAIKO_ENABLE_ETHERNET -DUSE_DLPI +NETWORK_CC_SUN_NIT = -DMAIKO_ENABLE_ETHERNET -DUSE_NIT +NETWORK_LIB_NONE = +NETWORK_LIB_PCAP = -lpcap +NETWORK_LIB_NETHUB = +NETWORK_LIB_SUN_DLPI = +NETWORK_LIB_SUN_NIT = + DLPIFILES = # for files needed by X windows version diff --git a/bin/makefile-init-darwin.386 b/bin/makefile-init-darwin.386 index 862ab126..fe32ada6 100644 --- a/bin/makefile-init-darwin.386 +++ b/bin/makefile-init-darwin.386 @@ -4,7 +4,6 @@ CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-init-darwin.aarch64 b/bin/makefile-init-darwin.aarch64 index feee4583..d1248839 100644 --- a/bin/makefile-init-darwin.aarch64 +++ b/bin/makefile-init-darwin.aarch64 @@ -4,7 +4,6 @@ CC = clang -target aarch64-apple-darwin $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-init-darwin.x86_64 b/bin/makefile-init-darwin.x86_64 index fa669bc1..a6022f98 100644 --- a/bin/makefile-init-darwin.x86_64 +++ b/bin/makefile-init-darwin.x86_64 @@ -4,7 +4,6 @@ CC = clang -m64 -target x86_64-apple-darwin $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ @@ -16,7 +15,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -I/opt/X11/include -DXWINDOW # OPTFLAGS is normally -O2. -OPTFLAGS = -O0 -g +OPTFLAGS = -O3 -g DEBUGFLAGS = # -DDEBUG -DOPTRACE DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT diff --git a/bin/makefile-init-freebsd.386 b/bin/makefile-init-freebsd.386 index a216d97d..7579ca9a 100644 --- a/bin/makefile-init-freebsd.386 +++ b/bin/makefile-init-freebsd.386 @@ -4,7 +4,6 @@ CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-init-freebsd.aarch64 b/bin/makefile-init-freebsd.aarch64 index 0069df90..98b4d895 100644 --- a/bin/makefile-init-freebsd.aarch64 +++ b/bin/makefile-init-freebsd.aarch64 @@ -4,7 +4,6 @@ CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-init-freebsd.x86_64 b/bin/makefile-init-freebsd.x86_64 index e303dcfc..145eac8a 100644 --- a/bin/makefile-init-freebsd.x86_64 +++ b/bin/makefile-init-freebsd.x86_64 @@ -4,7 +4,6 @@ CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-init-openbsd.x86_64 b/bin/makefile-init-openbsd.x86_64 index facc9a01..3ccd3d05 100644 --- a/bin/makefile-init-openbsd.x86_64 +++ b/bin/makefile-init-openbsd.x86_64 @@ -4,7 +4,6 @@ CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-init-sunos5.sparc b/bin/makefile-init-sunos5.sparc index 60ac765b..84367a2d 100644 --- a/bin/makefile-init-sunos5.sparc +++ b/bin/makefile-init-sunos5.sparc @@ -22,7 +22,6 @@ CC = cc -m32 $(DEVSTUDIO_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-openbsd.x86_64-x b/bin/makefile-openbsd.x86_64-x index 9624f317..fd0a68cc 100644 --- a/bin/makefile-openbsd.x86_64-x +++ b/bin/makefile-openbsd.x86_64-x @@ -4,7 +4,6 @@ CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-sunos5.386-x b/bin/makefile-sunos5.386-x index 108712d8..ec781cb5 100644 --- a/bin/makefile-sunos5.386-x +++ b/bin/makefile-sunos5.386-x @@ -14,7 +14,6 @@ CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-sunos5.i386-x b/bin/makefile-sunos5.i386-x index 40005ea6..5ce714a8 100644 --- a/bin/makefile-sunos5.i386-x +++ b/bin/makefile-sunos5.i386-x @@ -14,7 +14,6 @@ CC = gcc XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-sunos5.sparc-x b/bin/makefile-sunos5.sparc-x index ed266c45..67ab8f76 100644 --- a/bin/makefile-sunos5.sparc-x +++ b/bin/makefile-sunos5.sparc-x @@ -21,7 +21,6 @@ CC = cc -m32 $(DEVSTUDIO_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ @@ -40,7 +39,7 @@ OPTFLAGS = -O2 -g3 DEBUGFLAGS = # -DSTACKCHECK -DFNSTKCHECK -MACHINEFLAGS = -DOS5 -DUSE_DLPI +MACHINEFLAGS = -DOS5 -DMAIKO_ENABLE_ETHERNET -DUSE_DLPI DFLAGS = $(XFLAGS) \ $(DEBUGFLAGS) \ diff --git a/bin/makefile-sunos5.x86_64-x b/bin/makefile-sunos5.x86_64-x index 5cc9cc45..d574a704 100644 --- a/bin/makefile-sunos5.x86_64-x +++ b/bin/makefile-sunos5.x86_64-x @@ -14,7 +14,6 @@ CC = clang $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ $(OBJECTDIR)xinit.o \ $(OBJECTDIR)xscroll.o \ $(OBJECTDIR)xcursor.o \ diff --git a/bin/makefile-tail b/bin/makefile-tail index 80bc2586..62754d35 100644 --- a/bin/makefile-tail +++ b/bin/makefile-tail @@ -35,7 +35,7 @@ REQUIRED-INCS = $(INCDIR)version.h $(INCDIR)maiko/platform.h -CFLAGS = $(OPTFLAGS) $(DFLAGS) +CFLAGS = $(OPTFLAGS) $(DFLAGS) $(NETWORK_CC_$(NETWORK)) RFLAGS = -c $(CFLAGS) -I$(INCDIR) -I$(INCLUDEDIR) OFILES = $(OBJECTDIR)arithops.o \ @@ -83,7 +83,7 @@ OFILES = $(OBJECTDIR)arithops.o \ $(OBJECTDIR)unixcomm.o \ $(OBJECTDIR)uraid.o \ $(OBJECTDIR)rpc.o \ - $(OBJECTDIR)ufn.o \ + $(OBJECTDIR)ufn.o \ $(OBJECTDIR)z2.o \ $(OBJECTDIR)eqf.o \ $(OBJECTDIR)fp.o \ @@ -109,6 +109,7 @@ GCFILES = $(OBJECTDIR)gcscan.o \ $(OBJECTDIR)gcoflow.o DEVICES = $(OBJECTDIR)dspsubrs.o \ + $(OBJECTDIR)dspif.o \ $(OBJECTDIR)initdsp.o \ $(OBJECTDIR)dsk.o \ $(OBJECTDIR)ufs.o \ @@ -118,6 +119,7 @@ DEVICES = $(OBJECTDIR)dspsubrs.o \ $(OBJECTDIR)ether_common.o \ $(OBJECTDIR)ether_sunos.o \ $(OBJECTDIR)ether_nethub.o \ + $(OBJECTDIR)ether_pcap.o \ $(OBJECTDIR)tty.o \ $(OBJECTDIR)initkbd.o @@ -148,7 +150,7 @@ $(OSARCHDIR)lde: $(OBJECTDIR)ldeboot.o $(OBJECTDIR)unixfork.o $(CC) $(OBJECTDIR)ldeboot.o $(OBJECTDIR)unixfork.o $(LDELDFLAGS) -o $(OSARCHDIR)lde $(OSARCHDIR)$(LDENAME): $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o - $(CC) $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o $(LDFLAGS) -o $(OSARCHDIR)$(LDENAME) + $(CC) $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o $(LDFLAGS) $(NETWORK_LIB_$(NETWORK)) -o $(OSARCHDIR)$(LDENAME) @ echo "" @ echo "Executable is now named '$(OSARCHDIR)$(LDENAME)'" @@ -495,6 +497,13 @@ $(OBJECTDIR)ether_nethub.o: $(SRCDIR)ether_nethub.c $(REQUIRED-INCS) \ $(INCDIR)dbprint.h $(INCDIR)etherdefs.h $(CC) $(RFLAGS) $(SRCDIR)ether_nethub.c -o $(OBJECTDIR)ether_nethub.o +$(OBJECTDIR)ether_pcap.o: $(SRCDIR)ether_pcap.c $(REQUIRED-INCS) \ + $(INCDIR)commondefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h $(INCDIR)lsptypes.h $(INCDIR)lspglob.h \ + $(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)miscstat.h $(INCDIR)adr68k.h \ + $(INCDIR)dbprint.h $(INCDIR)etherdefs.h + $(CC) $(RFLAGS) $(SRCDIR)ether_pcap.c -o $(OBJECTDIR)ether_pcap.o + $(OBJECTDIR)findkey.o: $(SRCDIR)findkey.c $(REQUIRED-INCS) \ $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ $(INCDIR)emlglob.h $(INCDIR)stack.h $(INCDIR)lspglob.h $(INCDIR)ifpage.h \ diff --git a/inc/etherdefs.h b/inc/etherdefs.h index 013984df..0d5cb456 100644 --- a/inc/etherdefs.h +++ b/inc/etherdefs.h @@ -1,5 +1,6 @@ #ifndef ETHERDEFS_H #define ETHERDEFS_H 1 +#include /* for u_char */ #include "lispemul.h" /* for LispPTR */ LispPTR ether_suspend(LispPTR args[]); LispPTR ether_resume(LispPTR args[]); @@ -14,7 +15,7 @@ LispPTR check_ether(void); void init_ifpage_ether(void); void init_ether(void); LispPTR check_sum(LispPTR *args); - +int ether_addr_equal(const u_char addr1[6], const u_char addr2[6]); void setNethubHost(char* host); void setNethubPort(int port); void setNethubMac(int m0, int m1, int m2, int m3, int m4, int m5); diff --git a/inc/lispemul.h b/inc/lispemul.h index cbf05598..95a7b1f6 100644 --- a/inc/lispemul.h +++ b/inc/lispemul.h @@ -65,21 +65,28 @@ typedef struct closure_type { #endif /* BIGVM */ typedef struct interrupt_state { /* Interrupt-request mask to communicate with INTERRUPTED */ - unsigned LogFileIO : 1; /* console msg arrived to print */ - unsigned ETHERInterrupt : 1; /* 10MB activity happened */ - unsigned IOInterrupt : 1; /* I/O happened (not used yet) */ - unsigned gcdisabled : 1; - unsigned vmemfull : 1; - unsigned stackoverflow : 1; - unsigned storagefull : 1; - unsigned waitinginterrupt : 1; - unsigned nil : 8; /* mask of ints being processed */ + DLword LogFileIO : 1; /* console msg arrived to print */ + DLword ETHERInterrupt : 1; /* 10MB activity happened */ + DLword IOInterrupt : 1; /* I/O happened (not used yet) */ + DLword gcdisabled : 1; + DLword vmemfull : 1; + DLword stackoverflow : 1; + DLword storagefull : 1; + DLword waitinginterrupt : 1; + DLword P_LogFileIO : 1; /* interrupts awaiting processing, cleared by Lisp */ + DLword P_ETHERInterrupt : 1; + DLword P_IOInterrupt : 1; + DLword P_gcdisabled : 1; + DLword P_vmemfull : 1; + DLword P_stackoverflow : 1; + DLword P_storagefull : 1; + DLword P_waitinginterrupt : 1; DLword intcharcode; } INTSTAT; typedef struct interrupt_state_2 { /* alternate view of the interrupt state */ - unsigned pendingmask : 8; - unsigned handledmask : 8; + DLword pendingmask : 8; + DLword handledmask : 8; DLword nil; } INTSTAT2; @@ -204,21 +211,28 @@ typedef struct closure_type { typedef struct interrupt_state { /* Interrupt-request mask to communicate with INTERRUPTED */ DLword intcharcode; - unsigned nil : 8; - unsigned waitinginterrupt : 1; - unsigned storagefull : 1; - unsigned stackoverflow : 1; - unsigned vmemfull : 1; - unsigned gcdisabled : 1; - unsigned IOInterrupt : 1; /* I/O happened (not used yet) */ - unsigned ETHERInterrupt : 1; /* 10MB activity happened */ - unsigned LogFileIO : 1; /* console msg arrived to print */ + DLword P_waitinginterrupt : 1; /* interrupts awaiting processing, cleared by Lisp */ + DLword P_storagefull : 1; + DLword P_stackoverflow : 1; + DLword P_vmemfull : 1; + DLword P_gcdisabled : 1; + DLword P_IOInterrupt : 1; + DLword P_ETHERInterrupt : 1; + DLword P_LogFileIO : 1; + DLword waitinginterrupt : 1; + DLword storagefull : 1; + DLword stackoverflow : 1; + DLword vmemfull : 1; + DLword gcdisabled : 1; + DLword IOInterrupt : 1; /* I/O happened (not used yet) */ + DLword ETHERInterrupt : 1; /* 10MB activity happened */ + DLword LogFileIO : 1; /* console msg arrived to print */ } INTSTAT; typedef struct interrupt_state_2 { /* alternate view of the interrupt state */ DLword nil; - unsigned handledmask : 8; - unsigned pendingmask : 8; + DLword handledmask : 8; + DLword pendingmask : 8; } INTSTAT2; struct state { diff --git a/inc/locfile.h b/inc/locfile.h index 59de1d69..2e19cf73 100644 --- a/inc/locfile.h +++ b/inc/locfile.h @@ -11,6 +11,7 @@ #include #include /* for NAME_MAX */ #include /* for MAXNAMLEN */ +#include /* for strncpy in non-BYTESWAP case */ #include "lispemul.h" /* for DLword */ #include "commondefs.h" /* for error */ diff --git a/inc/sdldefs.h b/inc/sdldefs.h index e1a0c185..65705f8a 100644 --- a/inc/sdldefs.h +++ b/inc/sdldefs.h @@ -1,11 +1,10 @@ #ifndef SDLDEFS_H #define SDLDEFS_H 1 - void sdl_notify_damage(int x, int y, int w, int h); void sdl_setCursor(int hot_x, int hot_y); void sdl_bitblt_to_screen(int x, int y, int w, int h); void sdl_set_invert(int flag); void sdl_setMousePosition(int x, int y); -void process_SDLevents(); +void process_Display_events(void *dsp); int init_SDL(char *windowtitle, int w, int h, int s); #endif diff --git a/inc/xwinmandefs.h b/inc/xwinmandefs.h index e1f58f25..28e060a8 100644 --- a/inc/xwinmandefs.h +++ b/inc/xwinmandefs.h @@ -7,5 +7,5 @@ void Set_BitGravity(XButtonEvent *event, DspInterface dsp, Window window, int gr void enable_Xkeyboard(DspInterface dsp); void disable_Xkeyboard(DspInterface dsp); void beep_Xkeyboard(DspInterface dsp); -void process_Xevents(DspInterface dsp); +void process_Display_events(DspInterface dsp); #endif diff --git a/src/dir.c b/src/dir.c index 97e9da5e..3bc3a721 100644 --- a/src/dir.c +++ b/src/dir.c @@ -2309,7 +2309,7 @@ LispPTR COM_next_file(LispPTR *args) laddr = gfsp->name; STRING_BASE(laddr, base); #ifndef BYTESWAP - strncpy(base, fp->lname, fp->lname_len); + memcpy(base, fp->lname, fp->lname_len); #else MemCpyToLispFromNative(base, fp->lname, fp->lname_len); #endif /* BYTESWAP */ @@ -2325,7 +2325,7 @@ LispPTR COM_next_file(LispPTR *args) laddr = gfsp->author; STRING_BASE(laddr, base); #ifndef BYTESWAP - strncpy(base, pp->author, pp->au_len); + memcpy(base, pp->author, pp->au_len); #else MemCpyToLispFromNative(base, pp->author, pp->au_len); #endif /* BYTESWAP */ diff --git a/src/dlpi.c b/src/dlpi.c index 61b88abf..2a9be882 100644 --- a/src/dlpi.c +++ b/src/dlpi.c @@ -157,8 +157,8 @@ int setup_dlpi_dev(char *device) */ if ((p = strpbrk(device, "0123456789")) == NULL) return (-1); - strcpy(devname, DLPI_DEVDIR); - strncat(devname, device, p - device); + snprintf(devname, sizeof(devname), "%s%.*s", + DLPI_DEVDIR, (int)(p - device), device); devppa = atoi(p); /* diff --git a/src/dsk.c b/src/dsk.c index 0765a236..2c7fb718 100644 --- a/src/dsk.c +++ b/src/dsk.c @@ -14,7 +14,7 @@ #include // for NULL, snprintf, size_t, rename, SEEK_SET #include // for ptrdiff_t #include // for strtoul, qsort -#include // for strlcpy, strcmp, strlen, strncpy, strchr +#include // for strlcpy, strcmp, strlen, memcpy, strchr #include // for stat, fstat, mkdir, S_ISREG, st_atime, chmod #include // for ino_t, time_t, off_t #include // for unlink, close, link, lseek, access, chdir @@ -1030,7 +1030,7 @@ LispPTR DSK_getfilename(LispPTR *args) len = strlen(lfname); #ifndef BYTESWAP - strncpy(base, lfname, len); + memcpy(base, lfname, len); #else MemCpyToLispFromNative(base, lfname, len); #endif /* BYTESWAP */ @@ -1066,7 +1066,7 @@ LispPTR DSK_getfilename(LispPTR *args) len = strlen(lfname); #ifndef BYTESWAP - strncpy(base, lfname, len); + memcpy(base, lfname, len); #else MemCpyToLispFromNative(base, lfname, len); #endif /* BYTESWAP */ @@ -1504,7 +1504,7 @@ LispPTR DSK_directorynamep(LispPTR *args) STRING_BASE(args[1], base); #ifndef BYTESWAP - strncpy(base, dirname, len); + memcpy(base, dirname, len); #else MemCpyToLispFromNative(base, dirname, len); #endif /* BYTESWAP */ @@ -1667,7 +1667,7 @@ LispPTR COM_getfileinfo(LispPTR *args) STRING_BASE(args[2], base); len = strlen(pwd->pw_name); #ifndef BYTESWAP - strncpy(base, pwd->pw_name, len); + memcpy(base, pwd->pw_name, len); #else MemCpyToLispFromNative(base, pwd->pw_name, len); #endif /* BYTESWAP */ @@ -1714,7 +1714,7 @@ LispPTR COM_getfileinfo(LispPTR *args) STRING_BASE(laddr, base); len = strlen(pwd->pw_name); #ifndef BYTESWAP - strncpy(base, pwd->pw_name, len); + memcpy(base, pwd->pw_name, len); #else MemCpyToLispFromNative(base, pwd->pw_name, len); #endif /* BYTESWAP */ @@ -2335,7 +2335,7 @@ void separate_version(char *name, size_t namesize, char *ver, size_t versize, in { char *start, *end, *cp; unsigned ver_no; - size_t len; + ptrdiff_t len; char ver_buf[VERSIONLEN]; if ((end = (char *)strchr(name, '~')) != (char *)NULL) { @@ -2364,8 +2364,7 @@ void separate_version(char *name, size_t namesize, char *ver, size_t versize, in *ver = '\0'; return; } - strncpy(ver_buf, start + 1, len); - ver_buf[len] = '\0'; + snprintf(ver_buf, sizeof(ver_buf), "%.*s", (int)len, start + 1); if (checkp) { NumericStringP(ver_buf, YES, NO); YES: diff --git a/src/ether_common.c b/src/ether_common.c index 1a80e49a..a43a8ebf 100644 --- a/src/ether_common.c +++ b/src/ether_common.c @@ -10,6 +10,7 @@ #include "version.h" #include +#include #include #include "lsptypes.h" @@ -21,24 +22,22 @@ * global variables exported to ether_*.c and possibly others */ +extern int ether_enabled; extern int ether_fd; extern u_char ether_host[6]; +extern char ether_ifname[32]; extern const u_char broadcast[6]; extern int ether_bsize; extern u_char *ether_buf; -extern int ETHEREventCount; +int ether_enabled = 0; /* ethernet disabled unless we ask for it */ int ether_fd = -1; /* file descriptor for ether socket */ - u_char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address of this node */ +char ether_ifname[32] = "\0"; /* interface name (pcap, perhaps others) */ const u_char broadcast[6] = {255, 255, 255, 255, 255, 255}; - int ether_bsize = 0; /* if nonzero then a receive is pending */ u_char *ether_buf = NULL; /* address of receive buffer */ -int ETHEREventCount = 0; - - /* * public procedures */ @@ -104,14 +103,35 @@ LispPTR check_sum(LispPTR *args) } /*check_sum */ +/********************************************************************** + * ether_addr_equal(add1, add2) + * checks ethernet addresses equality + **********************************************************************/ + +int ether_addr_equal(const u_char addr1[6], const u_char addr2[6]) +{ + return (0 == memcmp(addr1, addr2, 6)); +} + /* * dummy implementation of SUBRs if none of the networking options is compiled in */ -#if !defined(MAIKO_ENABLE_ETHERNET) && !defined(MAIKO_ENABLE_NETHUB) +#if !defined(MAIKO_ENABLE_ETHERNET) + +/************************************************************************/ +/* */ +/* i n i t _ e t h e r */ +/* */ +/* Initialize ethernet implementation specific code */ +/* */ +/************************************************************************/ +void init_ether(void) { + return; +} /************************************************************************/ /* */ diff --git a/src/ether_nethub.c b/src/ether_nethub.c index e9803e26..8314dd51 100644 --- a/src/ether_nethub.c +++ b/src/ether_nethub.c @@ -7,7 +7,7 @@ /* */ /*******************************************************************************/ -#if defined(MAIKO_ENABLE_NETHUB) && !defined(MAIKO_ENABLE_ETHERNET) +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_NETHUB) #include "version.h" @@ -43,6 +43,7 @@ ** --- ether implementation common data ------------------------------------------- */ +extern int ether_enabled; /* 0/1 should ethernet be turned on */ extern int ether_fd; /* file descriptor for ether socket */ extern u_char ether_host[6]; /* 48 bit address of this node */ extern const u_char broadcast[6]; @@ -131,6 +132,12 @@ static void dblwordsSwap(u_char* basePtr, int forBytes) { ** --- connect, disconnect and transmit packets ----------------------------------- */ +void init_ether(void) { + /* because the rest of the system expects it to be called init_ether() */ + if (ether_enabled == 0) return; + connectToHub(); +} + void connectToHub(void) { if (nethubHost == NULL) { return; @@ -297,12 +304,10 @@ static int recvPacket(void) { #if defined(BYTESWAP) log_debug((" recvPacket() :: byte-swapping %d bytes at %p\n", bLen, (void *)ether_buf)); dblwordsSwap(ether_buf, bLen); - IOPage->dlethernet[2] = bLen; #else log_debug((" recvPacket() :: %d bytes at %p\n", bLen, (void *)ether_buf)); - IOPage->dlethernet[3] = bLen; #endif - + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = bLen; ether_bsize = 0; @@ -573,5 +578,5 @@ LispPTR check_ether(void) return (ATOM_T); } -#endif /* MAIKO_ENABLE_NETHUB */ +#endif /* defined(MAIKO_ENABLE_ETHERNET) && defined(USE_NETHUB) */ diff --git a/src/ether_pcap.c b/src/ether_pcap.c new file mode 100644 index 00000000..a4f63bdd --- /dev/null +++ b/src/ether_pcap.c @@ -0,0 +1,485 @@ +/* $Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1996 inclusive Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/************************************************************************/ + +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_PCAP) + +#include "version.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef MAIKO_OS_SOLARIS +#include +#else +#include +#endif +#include +#ifdef MAIKO_OS_LINUX +#include +#else +#include +#endif +#include +#include +#include + +#include +#include + +#include "commondefs.h" +#include "byteswapdefs.h" +#include "lispemul.h" +#include "lispmap.h" +#include "lisp2cdefs.h" +#include "emlglob.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "adr68k.h" +#include "dbprint.h" +#include "etherdefs.h" +#include "ifpage.h" +#include "iopage.h" + +extern int ether_enabled; /* 0/1 should ethernet be turned on */ +extern int ether_fd; /* file descriptor for ether socket */ +extern u_char ether_host[6]; /* 48 bit address of this node */ +extern char ether_ifname[32]; /* name of ethernet interface */ +extern u_char broadcast[6]; +extern int ether_bsize; /* if nonzero then a receive is pending */ +extern u_char *ether_buf; /* address of receive buffer */ + +extern LispPTR *PENDINGINTERRUPT68k; +extern fd_set LispReadFds; + +#ifndef ETHERTYPE_PUP +#define ETHERTYPE_PUP 0x0200 +#endif +#ifndef ETHERTYPE_XNS +#define ETHERTYPE_XNS 0x0600 +#endif +#ifndef ETHERTYPE_3TO10 +#define ETHERTYPE_3TO10 0x0201 +#endif +#ifndef AF_PACKET +#define AF_PACKET (AF_MAX+1) +#endif + +static pcap_t *pcap_handle; + +/* PCAP packet filter for + * "(not arp and not ip) and (ether broadcast or ether dst 11:22:33:44:55:66)" + * into which we will insert our MAC address in place of 11:22:... + * Generate with tcpdump -dd '(...)' + * Could be compiled from the string by pcap_compile(), but then we wouldn't know the + * offset to substitute our ethernet address - if we used pcap_compile() we might want + * to just put our ethernet address into the text before compiling. + * + * Idea: let's not put the interface in promiscuous mode - then we don't have to test + * for broadcast and our mac address and this simplifies the setup by quite a bit. + * We'll still need to get the mac address for use in the interface page. + */ + +static struct bpf_insn bpf_insns_none[] = { + { 0x6, 0, 0, 0x00000000 } +}; + +static struct bpf_program filter_match_xns; + +static struct bpf_program filter_match_none = { + sizeof(bpf_insns_none) / sizeof(struct bpf_insn), + bpf_insns_none +}; + +static int ether_in = 0; /* number of packets received */ +static int ether_out = 0; /* number of packets sent */ + +/********************************************************************** + * recvPacket() + * retrieves an ether packet from the network and deposits it + * in the expected byte order in ether_buf, and sets ether_bsize + * to 0. + * Returns: 0 if no packet was read, + * length in bytes of the packet if one was read. + * + **********************************************************************/ +static int recvPacket(void) { + int pcap_rval = 0; + bpf_u_int32 hlen; + const u_char *packet = NULL; + struct pcap_pkthdr *header = NULL; + + pcap_rval = pcap_next_ex(pcap_handle, &header, &packet); + if (pcap_rval == 0) return(0); + if (pcap_rval != 1) { + pcap_perror(pcap_handle, "recvPacket"); + return (0); + } + + /* ignore packets that are too big, empty, or not captured completely */ + hlen = header->len; + if (hlen > ether_bsize || hlen == 0 || hlen != header->caplen) return (0); + +#ifdef BYTESWAP + for (int i = 0; i < hlen / 2; i++) { + GETBASEWORD((DLword *)ether_buf, i) = packet[2 * i] << 8 | packet[2 * i + 1]; + } + if (hlen % 2) { /* pick up last byte if length was odd (it shouldn't be!) */ + GETBASEWORD((DLword *)ether_buf, hlen / 2) = packet[hlen - 1] << 8; + } +#else + memcpy(ether_buf, packet, hlen); +#endif + + ether_bsize = 0; + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = hlen; + return (hlen); +} + +/************************************************************************/ +/* */ +/* e t h e r _ s u s p e n d */ +/* */ +/* Suspend receiving packets. */ +/* */ +/************************************************************************/ + +LispPTR ether_suspend(LispPTR args[]) +{ + if (ether_fd == -1) return (NIL); + + /* The trick here is to install a packet filter */ + /* that rejects all packets, I think... */ + + pcap_setfilter(pcap_handle, &filter_match_none); + return (ATOM_T); +} /* ether_suspend */ + +/************************************************************************/ +/* */ +/* e t h e r _ r e s u m e */ +/* */ +/* resume receiving packets */ +/* */ +/************************************************************************/ + +LispPTR ether_resume(LispPTR args[]) +{ + if (ether_fd == -1) return (NIL); + + /* Install a packet filter that accepts all packets we want */ + pcap_setfilter(pcap_handle, &filter_match_xns); + return (ATOM_T); +} /* ether_resume */ + +/************************************************************************/ +/* */ +/* e t h e r _ c t r l r */ +/* */ +/* return T if ether controller is available 175/72/0 */ +/* */ +/************************************************************************/ + +LispPTR ether_ctrlr(LispPTR args[]) +{ + if (ether_fd < 0) return (NIL); + return (ATOM_T); +} + +/********************************************************************** + * ether_reset(args) 175/73/0 + * reset ether controller and disable receipt of packets + **********************************************************************/ +LispPTR ether_reset(LispPTR args[]) +{ + if (ether_fd < 0) { return (NIL); } + ether_bsize = 0; /* deactivate receiver */ + return (ATOM_T); +} /* ether_reset */ + +/************************************************************************/ +/* */ +/* e t h e r _ g e t (175/74/2) */ +/* */ +/* Set up the Ethernet driver to receive a packet. The driver */ +/* first tries to read any pending packet from the net, and if */ +/* there is one, ether_get returns T. If there is no pending */ +/* packet, the failing read sets us up to get an interrupt when */ +/* a packet DOES arrive, and ether_get returns NIL. */ +/* */ +/* args[0] Length of the buffer we're passed */ +/* args[1] LISP address of a packet buffer */ +/* */ +/* sets ether_buf to the buffer address, for check_ether's use */ +/* sets ether_bsize to the buffer size. ether_bsize>0 means */ +/* it's OK to read packets from the network on interrupt. */ +/* */ +/************************************************************************/ +LispPTR ether_get(LispPTR args[]) +{ + LispPTR result = NIL; + LispPTR MaxByteCount; + int length; + + DBPRINT(("Ether Get. ")); + if (ether_fd < 0) return (NIL); + MaxByteCount = BYTESPER_DLWORD * LispIntToCInt(args[0]); /* words to bytes */ + if (MaxByteCount == 0) return (NIL); + ether_buf = (u_char *)NativeAligned2FromLAddr(args[1]); + ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ + length = recvPacket(); + if (length == 0) return (NIL); + return (T); +} /* ether_get */ + +/********************************************************************** + * ether_send(args) 175/75/2 max_words,buffer_addr + * send a packet + **********************************************************************/ + +/* We assert than the packets passed to ether_send() will never be + longer than 300 16-bit words. Limit is defined by ETHERPACKET + datatype in Lisp source. +*/ +#define MAXETHERPACKETWORDS 300 + +LispPTR ether_send(LispPTR args[]) +{ + DLword wordCount; + DLword *bufferAddr; /* buffer address pointer(in native address) */ +#ifdef BYTESWAP + DLword networkOrderBuffer[MAXETHERPACKETWORDS]; +#endif + if (ether_fd < 0) return (NIL); + wordCount = LispIntToCInt(args[0]); + bufferAddr = NativeAligned2FromLAddr(args[1]); +#ifdef BYTESWAP + if (wordCount > MAXETHERPACKETWORDS) wordCount = MAXETHERPACKETWORDS; + for (int i = 0; i < wordCount; i++) { + networkOrderBuffer[i] = htons(GETBASEWORD(bufferAddr, i)); + } + bufferAddr = networkOrderBuffer; +#endif + if (pcap_inject(pcap_handle, bufferAddr, 2 * wordCount) < 0) { + pcap_perror(pcap_handle, "ether_send"); + return (NIL); + } + ether_out++; + return (ATOM_T); +} /* ether_send */ + +/********************************************************************** + * ether_setfilter(args) 175/75/1 filterbits + * check whether a packet has come. if does, notify iocb + **********************************************************************/ + +LispPTR ether_setfilter(LispPTR args[]) +{ return (NIL); } +/* ether_setfilter */ + +/********************************************************************** + * ether_debug() + * returns the ethernet statistics. + **********************************************************************/ + +int estat[3]; + +int *ether_debug() { + estat[0] = 0; + if (ether_fd < 0) return (NIL); + printf("fd %d bsize %d buf %p icb %X in %d out %d\n ", ether_fd, ether_bsize, (void *)ether_buf, + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB, ether_in, ether_out); + return (estat); +} /* end ether_debug */ + +/********************************************************************** + * check_ether() + * checks for an incoming packet + **********************************************************************/ + +LispPTR check_ether() { +/* + * If the receiver is active then check if any packets are available + * from the ethernet, with the side-effect of reading a packet + * and setting the length in the ethernet ICB. + * Returns T if a packet was read, otherwise NIL. + */ + + if (ether_fd < 0 || ether_bsize == 0) return (NIL); + + return (0 == recvPacket()) ? NIL : ATOM_T; +} /* end check_ether */ + +/************************************************************************/ +/* i n i t _ e t h e r */ +/* */ +/* open pcap handle, called from main before starting BCE. */ +/* */ +/************************************************************************/ +void init_ether() { + /* Uses the following pcap library routines - + * pcap_create => gets a pcap_t handle + * pcap_findalldevs => list of network devices to capture on + * pcap_freealldevs => free the list of network devices from pcap_findalldevs + * pcap_set_snaplen => set the snapshot length for a not-yet-activated pcap_t handle + * pcap_set_buffer_size => set buffer size for a not-yet-activated pcap_t handle + * pcap_get_selectable_fd => fd to use in select/poll + * pcap_setnonblock => put pcap_t into non-blocking mode + * pcap_compile => compile filter + * pcap_setfilter => set filter on a pcap_t handle + * pcap_inject/pcap_sendpacket => transmit a packet + */ + + static const u_char ether_zero[6] = {0}; + int pcap_rval = 0; + char errbuf[PCAP_ERRBUF_SIZE] = {0}; + char filter_exp[256]; + int find_ifname; + int find_ifaddr; + + /* ethernet may already be initialized - don't do it again */ + if (ether_fd >= 0 || ether_enabled == 0) return; + + /* select an ethernet interface/address if it was not fully specified */ + find_ifname = strlen(ether_ifname) == 0; + find_ifaddr = ether_addr_equal(ether_host, ether_zero); + + /* XXX: should be rewritten so that if given an interface name but no address it finds the address, + if given an address but no interface name it finds the interface name, + if given both, it checks that they're consistent + if given neither it finds the first up, running, non-loopback interface and its address + */ + if (find_ifname || find_ifaddr) { + pcap_if_t *alldevs = NULL; + pcap_if_t *dev = NULL; + pcap_rval = pcap_findalldevs(&alldevs, errbuf); + if (pcap_rval == PCAP_ERROR) { + fprintf(stderr, "%s\n", errbuf); + return; + } + for (pcap_if_t *d = alldevs; d; d = d->next) { + /* if only looking for the address, and not looking for a name */ + if (find_ifaddr && !find_ifname) { + if (strcmp(d->name, ether_ifname) == 0) { + dev = d; + break; + } + } else if ((d->flags & PCAP_IF_UP) && (d->flags & PCAP_IF_RUNNING) && !(d->flags & PCAP_IF_LOOPBACK)) { + dev = d; + break; + } + } + /* did we find one */ + if (dev) { + strlcpy(ether_ifname, dev->name, sizeof(ether_ifname)); + for (pcap_addr_t *a = dev->addresses; a; a = a->next) { +#if defined(MAIKO_OS_SOLARIS) + /* Solaris defines both AF_LINK and AF_PACKET but neither give us + * the desired result + */ +#elif defined(AF_LINK) + /* this is BSD-like, macOS? */ + if (a->addr && a->addr->sa_family == AF_LINK) { + struct sockaddr_dl *sdl = (struct sockaddr_dl *)(a->addr); + if (sdl->sdl_alen == sizeof(ether_host)) { + memcpy(ether_host, LLADDR(sdl), sizeof(ether_host)); + break; + } + } +#elif defined(AF_PACKET) + /* this is Linux-like */ + if (a->addr && a->addr->sa_family == AF_PACKET) { + struct sockaddr_ll *sll = (struct sockaddr_ll*)(a->addr); + if (sll->sll_halen == sizeof(ether_host)) { + memcpy(ether_host, sll->sll_addr, sizeof(ether_host)); + break; + } + } +#else +#warning Neither AF_LINK nor AF_PACKET address families defined +#endif + } + } + pcap_freealldevs(alldevs); + } + if(strlen(ether_ifname) == 0) { + fprintf(stderr, "No suitable network interface found\n"); + return; + } + pcap_handle = pcap_create(ether_ifname, errbuf); + if (pcap_handle == NULL) { + fprintf(stderr, "pcap_create failed: %s\n", errbuf); + return; + } + if (strlen(errbuf) > 0) { + fprintf(stderr, "pcap_create warning: %s\n", errbuf); + } + /* set up properties on the pcap_handle and then activate it */ + pcap_rval = pcap_set_immediate_mode(pcap_handle, 1); + pcap_rval = pcap_set_buffer_size(pcap_handle, 65536); + pcap_rval = pcap_set_snaplen(pcap_handle, 1518); + pcap_rval = pcap_activate(pcap_handle); + if (pcap_rval != 0) { + pcap_perror(pcap_handle, "pcap_activate"); + } + if (pcap_rval < 0) { + pcap_close(pcap_handle); + return; + } + pcap_rval = pcap_setfilter(pcap_handle, &filter_match_none); + if (pcap_rval != 0) { + pcap_perror(pcap_handle, "pcap_setfilter"); + } + /* filter for XNS - may want to do PUP later */ + snprintf(filter_exp, sizeof(filter_exp), "ether proto 0x600 and (ether multicast or ether dst %02x:%02x:%02x:%02x:%02x:%02x)", + ether_host[0], ether_host[1], ether_host[2], ether_host[3], ether_host[4], ether_host[5]); + pcap_rval = pcap_compile(pcap_handle, &filter_match_xns, filter_exp, 0, PCAP_NETMASK_UNKNOWN); + if (pcap_rval == PCAP_ERROR) { + fprintf(stderr, "Couldn't parse filter %s: %s\n", filter_exp, pcap_geterr(pcap_handle)); + pcap_close(pcap_handle); + return; + } + pcap_rval = pcap_setfilter(pcap_handle, &filter_match_xns); + if (pcap_rval == PCAP_ERROR) { + fprintf(stderr, "Couldn't set filter %s: %s\n", filter_exp, pcap_geterr(pcap_handle)); + pcap_freecode(&filter_match_xns); + pcap_close(pcap_handle); + return; + } + pcap_rval = pcap_setnonblock(pcap_handle, 1, errbuf); + if (pcap_rval == PCAP_ERROR) { + fprintf(stderr, "%s\n", errbuf); + pcap_freecode(&filter_match_xns); + pcap_close(pcap_handle); + return; + } + ether_fd = pcap_get_selectable_fd(pcap_handle); + if (ether_fd == -1 || ether_fd >= FD_SETSIZE) { + fprintf(stderr, "Couldn't get valid selectable fd for pcap\n"); + ether_fd = -1; + pcap_freecode(&filter_match_xns); + pcap_close(pcap_handle); + return; + } + FD_SET(ether_fd, &LispReadFds); + + printf("Ethernet starts on interface %s at %02x:%02x:%02x:%02x:%02x:%02x\n", + ether_ifname, ether_host[0], ether_host[1], ether_host[2], + ether_host[3],ether_host[4],ether_host[5]); + DBPRINT(("init_ether: **** Ethernet starts ****\n")); +} +#endif /* defined(MAIKO_ENABLE_ETHERNET) && defined(USE_PCAP) */ diff --git a/src/ether_sunos.c b/src/ether_sunos.c index ba75cf14..33217147 100644 --- a/src/ether_sunos.c +++ b/src/ether_sunos.c @@ -7,10 +7,9 @@ /* */ /************************************************************************/ -#if defined(MAIKO_ENABLE_ETHERNET) && !defined(MAIKO_ENABLE_NETHUB) - #include "version.h" +#if defined(MAIKO_ENABLE_ETHERNET) && defined(MAIKO_OS_SOLARIS) && (defined(USE_DLPI) || defined(USE_NIT)) #if defined(USE_DLPI) #define PKTFILTER 1 #define NIOCSFLAGS SBIOCSFLAGS @@ -30,7 +29,6 @@ #include #include #include -#ifdef MAIKO_ENABLE_ETHERNET #include #include #include @@ -62,7 +60,6 @@ #endif #include #endif /* DOS */ -#endif /* MAIKO_ENABLE_ETHERNET */ #include "commondefs.h" #include "lispemul.h" @@ -79,6 +76,7 @@ #define NIOCSETF PFIOCSETF #endif +extern int ether_enabled; /* 0/1 should ethernet be turned on */ extern int ether_fd; /* file descriptor for ether socket */ static int ether_intf_type = 0; extern u_char ether_host[6]; /* 48 bit address of this node */ @@ -89,8 +87,6 @@ static u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) * extern LispPTR *PENDINGINTERRUPT68k; extern fd_set LispReadFds; -extern int ETHEREventCount; - #define PacketTypeIP 0x0800 #define PacketTypeARP 0x0806 #define PacketTypeRARP 0x8035 @@ -98,7 +94,6 @@ extern int ETHEREventCount; #define PacketTypePUP 0x0200 #define PacketType3TO10 0x0201 -#ifdef MAIKO_ENABLE_ETHERNET #ifdef PKTFILTER /* the receiving packetfilter structure */ /* if this is changed, be sure to get the references to it in init_ether @@ -213,8 +208,6 @@ int ether_out = 0; /* number of packets sent */ static struct nit_ioc nioc; #endif /* PKTFILTER */ -#endif /* MAIKO_ENABLE_ETHERNET */ - /************************************************************************/ /* */ /* e t h e r _ s u s p e n d */ @@ -226,7 +219,6 @@ static struct nit_ioc nioc; LispPTR ether_suspend(LispPTR args[]) { -#ifdef MAIKO_ENABLE_ETHERNET #ifdef PKTFILTER static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; struct strioctl si; @@ -262,8 +254,6 @@ LispPTR ether_suspend(LispPTR args[]) } #endif /* USE_DLPI */ #endif /* PKTFILTER */ -#endif /* MAIKO_ENABLE_ETHERNET */ - return (ATOM_T); } /* ether_suspend */ @@ -277,7 +267,6 @@ LispPTR ether_suspend(LispPTR args[]) LispPTR ether_resume(LispPTR args[]) { -#ifdef MAIKO_ENABLE_ETHERNET struct strioctl si; if (ether_fd == -1) return (NIL); #ifndef PKTFILTER @@ -308,9 +297,6 @@ LispPTR ether_resume(LispPTR args[]) } #endif /* USE_DLPI */ #endif /* PKTFILTER */ - -#endif /* MAIKO_ENABLE_ETHERNET */ - return (ATOM_T); } /* ether_resume */ @@ -362,11 +348,10 @@ LispPTR ether_reset(LispPTR args[]) LispPTR ether_get(LispPTR args[]) { LispPTR result = NIL; -#ifdef MAIKO_ENABLE_ETHERNET LispPTR MaxByteCount; sigset_t signals; - MaxByteCount = BYTERSPER_DLWORD * (0xFFFF & args[0]); /* words to bytes */ + MaxByteCount = BYTESPER_DLWORD * (0xFFFF & args[0]); /* words to bytes */ DBPRINT(("Ether Get. ")); @@ -385,9 +370,6 @@ LispPTR ether_get(LispPTR args[]) /* enable interrupts */ sigprocmask(SIG_UNBLOCK, &signals, NULL); - -#endif /* MAIKO_ENABLE_ETHERNET */ - return (result); } /* ether_get */ @@ -399,7 +381,6 @@ LispPTR ether_get(LispPTR args[]) LispPTR ether_send(LispPTR args[]) { -#ifdef MAIKO_ENABLE_ETHERNET /* * Send a packet. */ @@ -452,8 +433,6 @@ LispPTR ether_send(LispPTR args[]) } #endif /* PKTFILTER */ } -#endif /* MAIKO_ENABLE_ETHERNET */ - return (ATOM_T); } /* ether_send */ @@ -473,30 +452,23 @@ LispPTR ether_setfilter(LispPTR args[]) int estat[3]; int *ether_debug(void) { -#ifdef MAIKO_ENABLE_ETHERNET estat[0] = 0; if (ether_fd < 0) return (NIL); printf("fd %d bsize %d buf %p icb %X in %d out %d\n ", ether_fd, ether_bsize, (void *)ether_buf, - IOPage->dlethernet[3], ether_in, ether_out); -#endif /* MAIKO_ENABLE_ETHERNET */ - + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB, ether_in, ether_out); return (estat); } /* end ether_debug */ -#ifdef MAIKO_ENABLE_ETHERNET static struct timeval EtherTimeout = {0, 0}; -#endif /* MAIKO_ENABLE_ETHERNET */ /********************************************************************** * check_ether() * checks an incoming packet **********************************************************************/ -#ifdef MAIKO_ENABLE_ETHERNET #ifndef PKTFILTER static int nitpos = 0, nitlen = 0; /* for NIT read buffer in OS3 */ #endif -#endif LispPTR check_ether(void) { /* @@ -505,7 +477,6 @@ LispPTR check_ether(void) { * and signal the icb and return T. */ -#ifdef MAIKO_ENABLE_ETHERNET #ifndef PKTFILTER fd_set rfds; int result, fromlen; @@ -520,12 +491,13 @@ LispPTR check_ether(void) { struct strbuf ctl, data; char ctlbuf[2000]; #endif /* PKTFILTER */ - + if (ether_fd < 0) return (NIL); + FD_ZERO(&rfds); FD_SET(ether_fd, &rfds); #ifndef PKTFILTER i = 2; if (/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) { - if ((ether_fd >= 0) && (ether_bsize > 0)) { + if (ether_bsize > 0) { while ((select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) && (i-- > 0)) { if (nitpos >= nitlen) { /* Used up last NIT buffer full; read another. */ nitlen = read(ether_fd, nit_buf, sizeof(nit_buf)); @@ -542,15 +514,13 @@ LispPTR check_ether(void) { memcpy(ðer_buf[0], &nit_buf[nitpos], fromlen); ether_bsize = 0; /* deactivate receiver */ ether_in++; - IOPage->dlethernet[3] = fromlen; + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = fromlen; DBPRINT( ("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); nitpos += fromlen; ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; - ETHEREventCount++; Irq_Stk_Check = Irq_Stk_End = 0; *PENDINGINTERRUPT68k = ATOM_T; - /* return(NIL); */ return (ATOM_T); } nitpos += fromlen; @@ -569,7 +539,7 @@ LispPTR check_ether(void) { } #else /* PKTFILTER */ - if (ether_fd >= 0 && ether_bsize > 0 + if (ether_bsize > 0 /* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 * -- [on '90/02/14: getsignsldata() check this] */ && (FD_ISSET(ether_fd, &rfds))) { @@ -586,21 +556,17 @@ LispPTR check_ether(void) { memcpy(ðer_buf[0], nit_buf, data.len); ether_bsize = 0; ether_in++; - IOPage->dlethernet[3] = data.len; + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = data.len; ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; - ETHEREventCount++; Irq_Stk_Check = Irq_Stk_End = 0; *PENDINGINTERRUPT68k = ATOM_T; - return (NIL); /* return(ATOM_T); */ + return(ATOM_T); } } else if (errno != EWOULDBLOCK) { perror("Check_ether read error:\n"); } } #endif /* PKTFILTER */ - -#endif /* MAIKO_ENABLE_ETHERNET */ - return (NIL); } /* end check_ether */ @@ -614,7 +580,6 @@ LispPTR check_ether(void) { /************************************************************************/ LispPTR get_packet(void) { -#ifdef MAIKO_ENABLE_ETHERNET #ifndef PKTFILTER fd_set rfds; int result, fromlen; @@ -649,7 +614,7 @@ LispPTR get_packet(void) { memcpy(ðer_buf[0], &nit_buf[nitpos], fromlen); ether_bsize = 0; /* deactivate receiver */ ether_in++; - IOPage->dlethernet[3] = fromlen; + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = fromlen; DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); nitpos += fromlen; return (ATOM_T); @@ -683,33 +648,15 @@ LispPTR get_packet(void) { memcpy(ðer_buf[0], nit_buf, data.len); ether_bsize = 0; ether_in++; - IOPage->dlethernet[3] = data.len; + ((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = data.len; return (ATOM_T); } } else if (errno != EWOULDBLOCK) perror("Check_ether read error:\n"); #endif /* PKTFILTER */ - -#endif /* MAIKO_ENABLE_ETHERNET */ - return (NIL); } /* end get_packet */ -#ifdef MAIKO_ENABLE_ETHERNET -/********************************************************************** - * ether_addr_equal(add1, add2) - * checks ethernet addresses equality - * Also believed obsolete - **********************************************************************/ - -static int ether_addr_equal(u_char add1[], u_char add2[]) -{ - int i; - for (i = 0; i < 6; i++) - if (add1[i] != add2[i]) return (0); - return (1); -} - /********************************************************************** * check_filter(buffer) * see if this packet passes the current filter setting @@ -748,7 +695,6 @@ static void init_uid(void) { #if defined(USE_NIT) struct sockaddr_nit snit; #endif /* USE_NIT */ -#endif /* MAIKO_ENABLE_ETHERNET */ /************************************************************************/ /* i n i t _ e t h e r */ @@ -757,8 +703,6 @@ struct sockaddr_nit snit; /* */ /************************************************************************/ void init_ether(void) { -#ifdef MAIKO_ENABLE_ETHERNET - /* JRB - This code will have to be a bit different for SUN 4.0; the probable differences are in commented-out code below (not ifdefed because they're untested...) @@ -770,6 +714,7 @@ void init_ether(void) { ((INTSTAT2 *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->handledmask = 0; */ + if (ether_enabled == 0) return; if (ether_fd < 0) { /* it's not open yet, try and open it; if it's already open here, it was opened by ldeether and @@ -1062,7 +1007,5 @@ void init_ether(void) { DBPRINT(("init_ether: **** Ethernet starts ****\n")); } -#endif /* MAIKO_ENABLE_ETHERNET */ } - -#endif /* defined(MAIKO_ENABLE_ETHERNET) */ +#endif /* defined(MAIKO_ENABLE_ETHERNET) && defined(MAIKO_OS_SOLARIS) && (defined(USE_DLPI) || defined(USE_NIT)) */ diff --git a/src/inet.c b/src/inet.c index 141e75db..986a84f9 100644 --- a/src/inet.c +++ b/src/inet.c @@ -77,6 +77,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li { #ifndef DOS int sock, len, buflen, res; + size_t namelen; unsigned ures; char namestring[100]; char servstring[50]; @@ -252,8 +253,10 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li ures = sizeof(addr); getpeername(sock, (struct sockaddr *)&addr, &ures); host = gethostbyaddr((const char *)&addr, ures, AF_INET); - strcpy((char *)buffer, host->h_name); - return (GetSmallp(strlen(host->h_name))); + if (!host) return (GetSmallp(0)); + namelen = strlen(host->h_name); + memcpy((char *)buffer, host->h_name, namelen); + return (GetSmallp(namelen)); case INETgetname: /* host addr, buffer for name string */ sock = LispNumToCInt(nameConn); @@ -262,8 +265,9 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li addr.sin_addr.s_addr = htonl(sock); host = gethostbyaddr((const char *)&addr, ures, 0); if (!host) return (GetSmallp(0)); - strcpy((char *)buffer, host->h_name); - return (GetSmallp(strlen(host->h_name))); + namelen = strlen(host->h_name); + memcpy((char *)buffer, host->h_name, namelen); + return (GetSmallp(namelen)); case UDPListen: /* socket# to listen on */ sock = LispNumToCInt(nameConn); diff --git a/src/initsout.c b/src/initsout.c index f0f63965..00cc0128 100644 --- a/src/initsout.c +++ b/src/initsout.c @@ -22,7 +22,7 @@ #endif #include // for fprintf, NULL, stderr #include // for malloc, exit -#include // for strlen, strncpy +#include // for strlen, memcpy #include // for time_t #include // for gethostid, getuid #include "adr68k.h" // for NativeAligned2FromLAddr, NativeAligned4FromLAddr @@ -46,7 +46,7 @@ #include "mkcelldefs.h" // for N_OP_createcell #include "testtooldefs.h" // for MakeAtom68k, MAKEATOM -#if defined(MAIKO_ENABLE_ETHERNET) || defined(MAIKO_ENABLE_NETHUB) +#if defined(MAIKO_ENABLE_ETHERNET) #include "etherdefs.h" #endif @@ -117,9 +117,9 @@ void init_ifpage(unsigned sysout_size) { Initialize IFPAGE */ InterfacePage->machinetype = MACHINETYPE_MAIKO; -#if defined(MAIKO_ENABLE_ETHERNET) || defined(MAIKO_ENABLE_NETHUB) +#if defined(MAIKO_ENABLE_ETHERNET) init_ifpage_ether(); /* store ethernet ID in IF page */ -#endif /* MAIKO_ENABLE_ETHERNET or MAIKO_ENABLE_NETHUB */ +#endif /* MAIKO_ENABLE_ETHERNET */ /*InterfacePage->dl24bitaddressable = (sysout_size == 32? 0xffff : 0);*/ InterfacePage->dl24bitaddressable = (sysout_size == 8 ? 0 : 0xffff); new_lastvmem = (sysout_size * PAGES_IN_MBYTE) - 1; @@ -164,7 +164,7 @@ are null terminated instead */ /* Lisp reserves 32 words for the BCPL String */ len = (len < 32 * BYTESPER_DLWORD) ? len : 32 * BYTESPER_DLWORD - 1; *s = (char)len; - strncpy(s + 1, pwd->pw_name, len); + memcpy(s + 1, pwd->pw_name, len); #ifdef BYTESWAP /* we must swap the area we have written into, starting at 0155000 */ /* rounding up to 4-byte words */ diff --git a/src/keyevent.c b/src/keyevent.c index f2b380bd..0f80f089 100644 --- a/src/keyevent.c +++ b/src/keyevent.c @@ -60,9 +60,9 @@ void Mouse_hndlr(void); /* Fields mouse events from driver */ #include "xwinmandefs.h" #endif -#if defined(MAIKO_ENABLE_ETHERNET) || defined(MAIKO_ENABLE_NETHUB) +#if defined(MAIKO_ENABLE_ETHERNET) #include "etherdefs.h" -#endif /* MAIKO_ENABLE_ETHERNET or MAIKO_ENABLE_NETHUB */ +#endif /* MAIKO_ENABLE_ETHERNET */ #include "dbprint.h" #if (defined(DOS) || defined(XWINDOW)) @@ -121,9 +121,9 @@ extern volatile sig_atomic_t XNeedSignal; extern int LogFileFd; -#if defined(MAIKO_ENABLE_ETHERNET) || defined(MAIKO_ENABLE_NETHUB) +#if defined(MAIKO_ENABLE_ETHERNET) extern int ether_fd; -#endif /* MAIKO_ENABLE_ETHERNET or MAIKO_ENABLE_NETHUB */ +#endif /* MAIKO_ENABLE_ETHERNET */ extern DLword *DisplayRegion68k; @@ -231,52 +231,61 @@ void process_io_events(void) fd_set rfds; u_int iflags; int i; - - memcpy(&rfds, &LispReadFds, sizeof(rfds)); - - if (select(32, &rfds, NULL, NULL, &SelectTimeout) > 0) { + INTSTAT *interrupt_state = ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word)); #ifdef MAIKO_ENABLE_ETHERNET - if (ether_fd >= 0 && FD_ISSET(ether_fd, &rfds)) { /* Raw ethernet (NIT) I/O happened, so handle it. */ - DBPRINT(("Handling enet interrupt.\n\n")); - check_ether(); + /* Unfortunately, not all methods of accessing the ethernet will result in an + * fd on which select() will produce a useful result, so we rely on the ethernet + * implementation-specific check_ether() routine to return NIL(0) or T(non-zero) + * depending on whether a packet has been read - in which case an Ethernet + * interrupt will be signalled up to the Lisp code, and the packet will be + * picked up. + * If there is currently an Ethernet interrupt in progress we won't check, + * and check_ether() should return NIL immediately if the Ethernet is + * not active (ether_fd < 0). + */ + if (0 == interrupt_state->P_ETHERInterrupt) { + if (check_ether()) { + /* the in-process bit gets set when xc.c passes it to Lisp */ + interrupt_state->ETHERInterrupt = 1; + Irq_Stk_Check = Irq_Stk_End = 0; + *PENDINGINTERRUPT68k = ATOM_T; } + } #endif /* MAIKO_ENABLE_ETHERNET */ -#ifdef MAIKO_ENABLE_NETHUB - check_ether(); -#endif /* MAIKO_ENABLE_NETHUB */ + memcpy(&rfds, &LispReadFds, sizeof(rfds)); + if (select(FD_SETSIZE, &rfds, NULL, NULL, &SelectTimeout) <= 0) return; #ifdef RS232 - if (RS232C_Fd >= 0 && (FD_ISSET(RS232C_Fd, &rfds) || (RS232C_remain_data && rs232c_lisp_is_ready()))) - rs232c_read(); + if (RS232C_Fd >= 0 && (FD_ISSET(RS232C_Fd, &rfds) || (RS232C_remain_data && rs232c_lisp_is_ready()))) + rs232c_read(); #endif /* RS232 */ #if defined(MAIKO_HANDLE_CONSOLE_MESSAGES) && defined(LOGINT) - if (LogFileFd >= 0 && FD_ISSET(LogFileFd, &rfds)) { /* There's info in the log file. Tell Lisp to print it. */ - flush_pty(); /* move the msg(s) to the log file */ + if (LogFileFd >= 0 && FD_ISSET(LogFileFd, &rfds)) { /* There's info in the log file. Tell Lisp to print it. */ + flush_pty(); /* move the msg(s) to the log file */ - ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->LogFileIO = 1; + ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->LogFileIO = 1; - *PENDINGINTERRUPT68k = ATOM_T; - Irq_Stk_End = Irq_Stk_Check = 0; - } + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End = Irq_Stk_Check = 0; + } #endif - iflags = 0; - for (i = 0; i < 32; i++) - if (FD_ISSET(i, &rfds) & FD_ISSET(i, &LispIOFds)) iflags |= 1 << i; - if (iflags) { /* There's activity on a Lisp-opened FD. Tell Lisp. */ - u_int *flags; - flags = (u_int *)NativeAligned4FromLAddr(*IOINTERRUPTFLAGS_word); - *flags = iflags; - - ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->IOInterrupt = 1; - - *PENDINGINTERRUPT68k = ATOM_T; - Irq_Stk_End = Irq_Stk_Check = 0; - } + iflags = 0; + for (i = 0; i < 32; i++) + if (FD_ISSET(i, &rfds) && FD_ISSET(i, &LispIOFds)) iflags |= 1 << i; + if (iflags) { /* There's activity on a Lisp-opened FD. Tell Lisp. */ + u_int *flags; + flags = (u_int *)NativeAligned4FromLAddr(*IOINTERRUPTFLAGS_word); + *flags = iflags; + + ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->IOInterrupt = 1; + + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End = Irq_Stk_Check = 0; } -/* #endif */ + /* #endif */ #endif /* DOS */ } /* end process_io_events */ diff --git a/src/ldeboot.c b/src/ldeboot.c index e850ee1f..e756b895 100644 --- a/src/ldeboot.c +++ b/src/ldeboot.c @@ -199,11 +199,9 @@ int main(int argc, char *argv[]) { if (dirsepp == NULL) { argv[0] = filetorun; } else { - /* copy up to and including the final "/" in the path */ - dirsepp = stpncpy(filetorunpath, argv[0], dirsepp + 1 - argv[0]); - - /* dirsepp now points to the trailing null in the copy */ - strncpy(dirsepp, filetorun, PATH_MAX - (dirsepp - filetorunpath)); + /* copy directory prefix (up to and including the final "/") then filename */ + snprintf(filetorunpath, PATH_MAX, "%.*s%s", + (int)(dirsepp + 1 - argv[0]), argv[0], filetorun); argv[0] = filetorunpath; } execvp(argv[0], argv); diff --git a/src/ldeether.c b/src/ldeether.c index 998d0a8a..c2daceaf 100644 --- a/src/ldeether.c +++ b/src/ldeether.c @@ -10,7 +10,7 @@ #include "version.h" -#ifndef MAIKO_ENABLE_ETHERNET +#if !defined( MAIKO_ENABLE_ETHERNET) || ! (defined(USE_DLPI) || defined(USE_NIT)) /* No ethernet, so have a dummy here. */ unsigned char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address */ int main(int argc, char *argv[]) { return (0); } @@ -36,7 +36,8 @@ char *devices[] = {"emd0", "emd1", "emd2", "emd3", "emd4", 0}; char *devices[] = {"le0", "le1", "le2", "le3", "le4", "ie0", "ie1", "ie2", "ie3", "ie4", "qe0", "qe1", "qe2", "qe3", "qe4", "qe5", "qe6", "qe7", - "fddi0", "fddi1", "fddi2", "fddi3", "fddi4", "bf0", "bf1", 0}; + "fddi0", "fddi1", "fddi2", "fddi3", "fddi4", "bf0", "bf1", "net0", "net1", + 0}; #endif #endif /* USE_DLPI */ @@ -64,7 +65,6 @@ char *devices[] = {"le0", "le1", "le2", "le3", "le4", "ie0", "ie1", "i #include #include -#include #include int ether_fd = -1; /* file descriptor for ether socket */ @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) { ether_intf_type = dlpi_devtype(ether_fd); printf("opened ldeether fd %d.\n", ether_fd); /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + (used for ether_suspend and ether_resume) */ if (ioctl(ether_fd, I_PUSH, "pfmod") < 0) { perror("IOCTL push of pf lost"); @@ -129,29 +129,29 @@ int main(int argc, char *argv[]) { #elif defined(USE_NIT) #ifndef OS4 - if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { + ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW); #else /* OS4 */ - if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { + ether_fd = open("/dev/nit", O_RDWR); #endif /* OS4 */ - - /* it's open, now query it and find out its name and address */ - /* JRB - must document that LDE uses the first net board as found - by SIOCGIFCONF (see if(4)). Maybe we need an option to specify - which net board (suspect more than one net board on an LDE machine - will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + if (ether_fd >= 0) { + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, abut...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; #ifdef OS4 - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if (ioctl(ether_fd, I_PUSH, "pf") < 0) { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } + if (ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } #endif /* OS4 */ if_data.ifc_len = sizeof(ifbuf); diff --git a/src/llstk.c b/src/llstk.c index 89f79d73..31af4f9f 100644 --- a/src/llstk.c +++ b/src/llstk.c @@ -57,7 +57,7 @@ static DLword *extendstack(void) { if (easp < LOLOC(*LastStackAddr_word)) { if ((easp > LOLOC(*GuardStackAddr_word)) && ((*STACKOVERFLOW_word) == NIL)) { - extended_frame = 1; + extended_frame = TRUE; ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->stackoverflow = 1; *STACKOVERFLOW_word = *PENDINGINTERRUPT_word = ATOM_T; } diff --git a/src/main.c b/src/main.c index 590424a9..d44c1b75 100644 --- a/src/main.c +++ b/src/main.c @@ -208,12 +208,14 @@ LispPTR *LastStackAddr_word; LispPTR *NeedHardreturnCleanup_word; /*** Ethernet stuff (JRB) **/ -#ifdef MAIKO_ENABLE_ETHERNET +extern int ether_enabled; extern int ether_fd; extern u_char ether_host[6]; -#endif /* MAIKO_ENABLE_ETHERNET */ +extern char ether_ifname[32]; +#ifdef USE_NIT extern struct sockaddr_nit snit; +#endif #ifdef INIT int for_makeinit = 1; @@ -303,7 +305,7 @@ const char *helpstring = -help Print this message\n"; #endif /* DOS */ -#if defined(MAIKO_ENABLE_NETHUB) +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_NETHUB) const char *nethubHelpstring = "\ -nh-host dodo-host Hostname for Dodo Nethub (no networking if missing)\n\ @@ -371,7 +373,7 @@ int main(int argc, char *argv[]) // and save it away if it is in case the X windows // arg processing changes argc/argv if (argc > 1 && argv[1][0] != '-') { - strncpy(sysout_name_first_arg, argv[1], MAXPATHLEN); + snprintf(sysout_name_first_arg, MAXPATHLEN, "%s", argv[1]); } @@ -404,7 +406,7 @@ int main(int argc, char *argv[]) /* Check for -sysout arg */ if (!strcmp(argv[i], "-sysout")) { if (argc > ++i) { - strncpy(sysout_name_cl, argv[i], MAXPATHLEN); + snprintf(sysout_name_cl, MAXPATHLEN, "%s", argv[i]); } } @@ -497,21 +499,21 @@ int main(int argc, char *argv[]) } else if ((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "-T") == 0) || (strcmp(argv[i], "-title") == 0) || (strcmp(argv[i], "-TITLE") == 0)) { if (argc > ++i) { - strncpy(windowTitle, argv[i], sizeof(windowTitle) - 1); + snprintf(windowTitle, sizeof(windowTitle), "%s", argv[i]); } else { (void)fprintf(stderr, "Missing argument after -title\n"); exit(1); } } else if (strcmp(argv[i], "-fg") == 0 || strcmp(argv[i], "-foreground") == 0) { if (argc > ++i) { - strncpy(foregroundColorName, argv[i], sizeof(foregroundColorName) - 1); + snprintf(foregroundColorName, sizeof(foregroundColorName), "%s", argv[i]); } else { (void)fprintf(stderr, "Missing argument after -fg/-foreground\n"); exit(1); } } else if (strcmp(argv[i], "-bg") == 0 || strcmp(argv[i], "-background") == 0) { if (argc > ++i) { - strncpy(backgroundColorName, argv[i], sizeof(backgroundColorName) - 1); + snprintf(backgroundColorName, sizeof(backgroundColorName), "%s", argv[i]); } else { (void)fprintf(stderr, "Missing argument after -bg/-background\n"); exit(1); @@ -519,18 +521,19 @@ int main(int argc, char *argv[]) } #endif /* SDL */ /* Can only do this under SUNOs, for now */ +#if defined(MAIKO_OS_SOLARIS) && (defined(USE_DLPI) || defined(USE_NIT)) else if (!strcmp(argv[i], "-E")) { /**** ethernet info ****/ -#ifdef MAIKO_ENABLE_ETHERNET int b0, b1, b2, b3, b4, b5; #if defined(USE_DLPI) if (argc > ++i && sscanf(argv[i], "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7) -#else +#elif defined(USE_NIT) if (argc > ++i && sscanf(argv[i], "%d:%x:%x:%x:%x:%x:%x:%s", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5, snit.snit_ifname) == 8) #endif /* USE_DLPI */ { + ether_enabled = 1; ether_host[0] = b0; ether_host[1] = b1; ether_host[2] = b2; @@ -538,17 +541,17 @@ int main(int argc, char *argv[]) ether_host[4] = b4; ether_host[5] = b5; } else { - (void)fprintf(stderr, "Missing or bogus -E argument\n"); + (void)fprintf(stderr, "Missing or bogus -E argument (dlpi/nit)\n"); ether_fd = -1; exit(1); } -#endif /* MAIKO_ENABLE_ETHERNET */ - } +#endif /* MAIKO_OS_SOLARIS && (defined(USE_DLPI) || defined(USE_NIT)) */ -#ifdef MAIKO_ENABLE_NETHUB +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_NETHUB) else if (!strcmp(argv[i], "-nh-host")) { if (argc > ++i) { + ether_enabled = 1; setNethubHost(argv[i]); } else { (void)fprintf(stderr, "Missing argument after -nh-host\n"); @@ -599,7 +602,35 @@ int main(int argc, char *argv[]) exit(1); } } -#endif /* MAIKO_ENABLE_NETHUB */ +#endif /* defined(MAIKO_ENABLE_ETHERNET) && defined(USE_NETHUB) */ +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_PCAP) + else if (!strcmp(argv[i], "-E")) { + ether_enabled = 1; + if (argc > ++i) { + int fields; + int b[6]; + char ifname[32] = {0}; + if (strchr(argv[i], ':') == NULL && strchr(argv[i], '%') == NULL) { + /* assume it's an interface name for which we do not know the address */ + strlcpy(ether_ifname, argv[i], sizeof(ether_ifname)); + } else { + fields = sscanf(argv[i], "%x:%x:%x:%x:%x:%x%%%31s", &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], ifname); + /* TBD: see comments in xrdopts.c regarding determining ifname and MAC address */ + if (fields == 6 || fields == 7) { + for (int x = 0; x < 6; x++) ether_host[x] = b[x] & 0xFF; + if (fields == 7) + strlcpy(ether_ifname, ifname, sizeof(ether_ifname)); + } else { + (void)fprintf(stderr, "Invalid argument for -E (pcap)\n"); + exit(1); + } + } + } else { + (void)fprintf(stderr, "Missing argument after -E\n"); + exit(1); + } + } +#endif #if defined(MAIKO_EMULATE_TIMER_INTERRUPTS) || defined(MAIKO_EMULATE_ASYNC_INTERRUPTS) else if (!strcmp(argv[i], "-intr-emu-insns")) { @@ -647,18 +678,17 @@ int main(int argc, char *argv[]) // 5. Value as determined by X resource manager, if any // 6. Value of $HOME/lisp.virtualmem (or lisp.vm for DOS) // - if (sysout_name_cl[0] != '\0') { strncpy(sysout_name, sysout_name_cl, MAXPATHLEN); } - else if (sysout_name_first_arg[0] != '\0') { strncpy(sysout_name, sysout_name_first_arg, MAXPATHLEN); } - else if ((envname = getenv("LDESRCESYSOUT")) != NULL) { strncpy(sysout_name, envname, MAXPATHLEN); } - else if ((envname = getenv("LDESOURCESYSOUT")) != NULL) { strncpy(sysout_name, envname, MAXPATHLEN); } - else if (sysout_name_xrm[0] != '\0') { strncpy(sysout_name, sysout_name_xrm, MAXPATHLEN); } + if (sysout_name_cl[0] != '\0') { snprintf(sysout_name, MAXPATHLEN, "%s", sysout_name_cl); } + else if (sysout_name_first_arg[0] != '\0') { snprintf(sysout_name, MAXPATHLEN, "%s", sysout_name_first_arg); } + else if ((envname = getenv("LDESRCESYSOUT")) != NULL) { snprintf(sysout_name, MAXPATHLEN, "%s", envname); } + else if ((envname = getenv("LDESOURCESYSOUT")) != NULL) { snprintf(sysout_name, MAXPATHLEN, "%s", envname); } + else if (sysout_name_xrm[0] != '\0') { snprintf(sysout_name, MAXPATHLEN, "%s", sysout_name_xrm); } else { #ifdef DOS - strncpy(sysout_name, "lisp.vm", MAXPATHLEN); + snprintf(sysout_name, MAXPATHLEN, "%s", "lisp.vm"); #else if ((envname = getenv("HOME")) != NULL) { - strncpy(sysout_name, envname, MAXPATHLEN); - strncat(sysout_name, "/lisp.virtualmem", MAXPATHLEN - 17); + snprintf(sysout_name, MAXPATHLEN, "%s/lisp.virtualmem", envname); } #endif /* DOS */ } @@ -693,13 +723,9 @@ int main(int argc, char *argv[]) FD_ZERO(&LispReadFds); -#ifdef MAIKO_ENABLE_ETHERNET - init_ether(); /* modified by kiuchi Nov. 4 */ -#endif /* MAIKO_ENABLE_ETHERNET */ - -#ifdef MAIKO_ENABLE_NETHUB - connectToHub(); -#endif + /* This must be called before init_ifpage() which will call init_ifpage_ether() */ + /* a dummy stub is compiled in if no ethernet implementation was selected. */ + if (ether_enabled) init_ether(); #ifdef DOS init_host_filesystem(); @@ -810,6 +836,9 @@ void start_lisp(void) { /* entering the bytecode dispatch loop; interrupts get */ /* unblocked here */ int_init(); +#if defined(XWINDOW) + int_io_open(ConnectionNumber(currentdsp->display_id)); +#endif #ifdef DOS _dpmi_lockregion((void *)&dispatch, 32768); #endif /* DOS */ diff --git a/src/sdl.c b/src/sdl.c index 7ef98b4a..572f29a7 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -1393,7 +1393,7 @@ void sdl_update_display() { } #endif int process_events_time = 0; -void process_SDLevents() { +void process_Display_events(void *dsp) { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { diff --git a/src/timer.c b/src/timer.c index fed42f74..e9e8a033 100644 --- a/src/timer.c +++ b/src/timer.c @@ -97,6 +97,9 @@ unsigned int TIMEOUT_TIME = 10; /* For file system timeout, seconds, default 10 extern volatile sig_atomic_t IO_Signalled; volatile sig_atomic_t IO_Signalled = FALSE; +extern volatile sig_atomic_t timer_Signalled; +volatile sig_atomic_t timer_Signalled = FALSE; + static int gettime(int casep); @@ -409,9 +412,10 @@ void update_timer(void) { int_init() should be called before first entering dispatch loop. int_timer_init() is called by int_init() and arms the timer interrupt. int_io_init() is called by int_init() and arms the I/O interrupt. + int_io_service() handles the I/O interrupt set up by int_io_init + and sets IO_Signalled for instruction dispatch loop. int_timer_service() catches the timer signal and sets - Irq_Stk_Check & Irq_Stk_End to 0 - so the rest of the system will see it and respond. + and sets timer_Signalled for instruction dispatch loop. int_block() and int_unblock() block timer interrupts and release them. int_io_open(fd) should be called whenever a file that should interrupt us is opened; it enables the interrupt on that fd. @@ -419,9 +423,10 @@ void update_timer(void) { us is closed; it disables the interrupt on that fd. */ -/* TIMER_INTERVAL usec ~ 20 per second. This should live in some - machine-configuration - file somewhere - it can be changed as the -t parameter to lisp*/ +/* TIMER_INTERVAL usec between ticks - typically ~ 10ms, 100 Hz + This should live in some machine-configuration file somewhere + Value can be changed as the -t parameter to lisp +*/ extern int TIMER_INTERVAL; int TIMER_INTERVAL = 10000; @@ -438,9 +443,8 @@ static void int_timer_service(int sig) { /* this may have to do more in the future, like check for nested interrupts, etc... */ - - Irq_Stk_Check = 0; - Irq_Stk_End = 0; + timer_Signalled = TRUE; + Irq_Stk_End = Irq_Stk_Check = 0; } /************************************************************************/ @@ -543,11 +547,10 @@ void int_io_close(int fd) /* */ /************************************************************************/ -static void int_io_service(int sig) +static void int_io_service(int sig, siginfo_t *siginfo, void *v) { - Irq_Stk_Check = 0; - Irq_Stk_End = 0; IO_Signalled = TRUE; + Irq_Stk_End = Irq_Stk_Check = 0; } /************************************************************************/ @@ -564,9 +567,9 @@ static void int_io_service(int sig) static void int_io_init(void) { #if !defined(DOS) || !defined(MAIKO_OS_HAIKU) struct sigaction io_action; - io_action.sa_handler = int_io_service; + io_action.sa_sigaction = int_io_service; sigemptyset(&io_action.sa_mask); - io_action.sa_flags = 0; + io_action.sa_flags = SA_SIGINFO; #ifndef MAIKO_OS_HAIKU if (sigaction(SIGIO, &io_action, NULL) == -1) { diff --git a/src/ufs.c b/src/ufs.c index c34a1d65..969cfb65 100644 --- a/src/ufs.c +++ b/src/ufs.c @@ -217,7 +217,7 @@ LispPTR UFS_getfilename(LispPTR *args) len = strlen(lfname); #ifndef BYTESWAP - strncpy(base, lfname, len); + memcpy(base, lfname, len); #else MemCpyToLispFromNative(base, lfname, len); #endif /* BYTESWAP */ @@ -421,7 +421,7 @@ LispPTR UFS_directorynamep(LispPTR *args) STRING_BASE(args[1], base); #ifndef BYTESWAP - strncpy(base, dirname, len); + memcpy(base, dirname, len); #else MemCpyToLispFromNative(base, dirname, len); #endif /* BYTESWAP */ diff --git a/src/uutils.c b/src/uutils.c index 3d660de3..67477396 100644 --- a/src/uutils.c +++ b/src/uutils.c @@ -25,7 +25,7 @@ #include // for size_t #include // for printf, NULL, snprintf, size_t #include // for getenv -#include // for strcmp, strcpy, strlen, strncpy +#include // for strcmp, strlen, memcpy #include // for getuid, gethostid, gethostname, getpgrp #include "adr68k.h" // for NativeAligned4FromLAddr #include "keyboard.h" // for KBEVENT, KB_ALLUP, RING, KEYEVENTSIZE, MAXKE... @@ -59,7 +59,7 @@ static int lisp_string_to_c_string(LispPTR Lisp, char *C, size_t length) { case THIN_CHAR_TYPENUMBER: base = ((char *)NativeAligned2FromLAddr(arrayp->base)) + ((int)(arrayp->offset)); #ifndef BYTESWAP - strncpy(C, base, arrayp->fillpointer); + memcpy(C, base, arrayp->fillpointer); #else { size_t l = arrayp->fillpointer; @@ -104,7 +104,7 @@ static int c_string_to_lisp_string(char *C, LispPTR Lisp) { case THIN_CHAR_TYPENUMBER: base = ((char *)NativeAligned2FromLAddr(arrayp->base)) + ((int)(arrayp->offset)); #ifndef BYTESWAP - strcpy(base, C); + memcpy(base, C, length + 1); #else { char *dp = C; diff --git a/src/xc.c b/src/xc.c index bfb1b925..438fbc2c 100644 --- a/src/xc.c +++ b/src/xc.c @@ -98,24 +98,21 @@ #include "ubf3defs.h" #include "unwinddefs.h" #include "vars3defs.h" -#ifdef XWINDOW +#if defined(XWINDOW) #include "xwinmandefs.h" +#elif defined(SDL) +#include "sdldefs.h" #endif #include "z2defs.h" #ifdef DOS -#include "devif.h" extern KbdInterface currentkbd; extern DspInterface currentdsp; extern MouseInterface currentmouse; -#elif defined(XWINDOW) +#else extern DspInterface currentdsp; #endif /* DOS */ -#ifdef SDL -extern void process_SDLevents(); -#endif - typedef struct conspage ConsPage; typedef ByteCode *InstPtr; @@ -154,6 +151,8 @@ LispPTR tscache asm("bx"); /* used by SIGIO signal handler to indicate I/O may be possible */ extern volatile sig_atomic_t IO_Signalled; +/* used by SIGVTALRM signal handler to indicate timer expired */ +extern volatile sig_atomic_t timer_Signalled; #ifdef PCTRACE /* For keeping a trace table (ring buffer) of 100 last PCs */ @@ -164,7 +163,7 @@ int pccounter = 0; /* ring-buffer counter */ #endif /* PCTRACE */ extern int extended_frame; -int extended_frame; /*indicates if soft stack overflow */ +int extended_frame; /* TRUE/FALSE indicates if soft stack overflow */ static const int n_mask_array[16] = { 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, @@ -175,9 +174,9 @@ extern int TIMER_INTERVAL; #if defined(MAIKO_EMULATE_TIMER_INTERRUPTS) || defined(MAIKO_EMULATE_ASYNC_INTERRUPTS) -# if !defined(MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDOWN) -# define MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDOWN 20000 -# endif +#if !defined(MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDOWN) +#define MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDOWN 20000 +#endif int insnsCountdownForTimerAsyncEmulation = MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDOWN; static int pseudoTimerAsyncCountdown = MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDOWN; @@ -285,15 +284,12 @@ op_ufn : { #if defined(MAIKO_EMULATE_TIMER_INTERRUPTS) || defined(MAIKO_EMULATE_ASYNC_INTERRUPTS) if (--pseudoTimerAsyncCountdown <= 0) { - Irq_Stk_Check = 0; - Irq_Stk_End = 0; -#if defined(MAIKO_EMULATE_ASYNC_INTERRUPTS) - IO_Signalled = TRUE; -#endif + /* Request interrupt handling */ + Irq_Stk_End = Irq_Stk_Check = 0; #ifdef MAIKO_OS_EMSCRIPTEN - emscripten_sleep(1); + emscripten_sleep(1); #endif - pseudoTimerAsyncCountdown = insnsCountdownForTimerAsyncEmulation; + pseudoTimerAsyncCountdown = insnsCountdownForTimerAsyncEmulation; } #endif @@ -1101,7 +1097,6 @@ op_ufn : { int need_irq; static int period_cnt = 60; extern int KBDEventFlg; - extern int ETHEREventCount; extern LispPTR *KEYBUFFERING68k; extern LispPTR *PENDINGINTERRUPT68k; extern LispPTR ATOM_STARTED; @@ -1115,15 +1110,15 @@ op_ufn : { odd bugs, ... */ /**** Changed back to > 31 July 97 ****/ re_check_stack: - need_irq = 0; + need_irq = FALSE; if (((UNSIGNED)(CSTKPTR + 1) > Irq_Stk_Check) && (Irq_Stk_End > 0) && (Irq_Stk_Check > 0)) { HARD_PUSH(TOPOFSTACK); EXT; - extended_frame = NIL; + extended_frame = FALSE; if (do_stackoverflow(NIL)) { stackoverflow_help: period_cnt = 60; - need_irq = T; + need_irq = TRUE; error("Stack Overflow, MUST HARDRESET!"); RET; TOPOFSTACK = NIL_PTR; @@ -1131,28 +1126,30 @@ op_ufn : { RET; POP; } - Irq_Stk_Check = (UNSIGNED)EndSTKP - STK_MIN(FuncObj); need_irq = (Irq_Stk_End == 0) || extended_frame; - *PENDINGINTERRUPT68k |= extended_frame; + Irq_Stk_Check = (UNSIGNED)EndSTKP - STK_MIN(FuncObj); Irq_Stk_End = (UNSIGNED)EndSTKP; + if (extended_frame) { + *PENDINGINTERRUPT68k = ATOM_T; + } } - /* This is a good time to process keyboard/mouse and ethernet I/O - * X events are not managed in the async/SIGIO code while - * raw ethernet, serial port, and socket connections are. - * If the system is configured with SIGIO handling we have a hint - * that allows us to cheaply skip if there's nothing to do + /* clear the flags set by the OS interrupt handlers that would + * allow us to distinguish between them. */ -#ifdef XWINDOW - process_Xevents(currentdsp); -#endif -#ifdef SDL - process_SDLevents(); + timer_Signalled = IO_Signalled = FALSE; + /* this is a reasonable time to handle X/SDL display and + * other I/O events. These routines will set Irq_Stk_Check and + * Irq_Stk_End to zero and set interrupt state flags for the + * interrupts to be generated + */ + process_Display_events(currentdsp); +#ifndef INIT + process_io_events(); #endif - if (IO_Signalled) { - IO_Signalled = FALSE; - process_io_events(); - } + /* Irq_Stk_End and Irq_Stk_Check can also have been set to 0 by + * the VTALRM or SIGIO handlers (see timer.c) + */ if ((Irq_Stk_End <= 0) || (Irq_Stk_Check <= 0) || need_irq) { if (StackOffsetFromNative(CSTKPTR) > InterfacePage->stackbase) { @@ -1171,13 +1168,10 @@ op_ufn : { period_cnt = 0; else period_cnt = - (*PERIODIC_INTERRUPT_FREQUENCY68k & 0xffff) * (1000000 / 60) / TIMER_INTERVAL; - /* number of 1/60 second periods between interrupts. - TIMER_INTERVAL is the number of microseconds between - timer interrupts. The calculation here avoids some - overflow errors although there is some roundoff - if the interrupt frequency number is too low, - it will bottom out and just set period_cnt to 0 */ + ((*PERIODIC_INTERRUPT_FREQUENCY68k & 0xffff) * 1000000ULL) / (60 * TIMER_INTERVAL); + /* number of 1/60 second periods between interrupts (really??) + TIMER_INTERVAL is the number of microseconds between timer interrupts. + */ } } @@ -1240,22 +1234,12 @@ op_ufn : { *PENDINGINTERRUPT68k = NIL; cause_interruptcall(INTERRUPTFRAME_index); } - } else if (ETHEREventCount > 0) { - INTSTAT *intstate = ((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word)); - if (!(intstate->ETHERInterrupt) && !(((INTSTAT2 *)intstate)->handledmask & 0x40)) { - intstate->ETHERInterrupt = 1; - ((INTSTAT2 *)intstate)->handledmask |= ((INTSTAT2 *)intstate)->pendingmask; - cause_interruptcall(INTERRUPTFRAME_index); - ETHEREventCount--; - } else - *PENDINGINTERRUPT68k = ATOM_T; } RET; CLR_IRQ; } /* Interrupts not Disabled */ else { - /* Clear out IRQ (loses pending interrupt request - if interrupts are disabled) */ + /* Clear out IRQ (loses pending request if interrupts are disabled) */ CLR_IRQ; goto re_check_stack; } diff --git a/src/xinit.c b/src/xinit.c index 8ad1db78..34697755 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -17,6 +17,7 @@ #include // for false, bool, true #include // for NULL #include // for exit +#include // for getpid #include "adr68k.h" // for NativeAligned4FromLAddr #include "dbprint.h" // for TPRINT #include "devif.h" // for (anonymous), MRegion, DspInterface, OUTER_S... @@ -360,5 +361,6 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, u break; } XInitImage(&dsp->ScreenBitmap); + return (dsp); } diff --git a/src/xrdopt.c b/src/xrdopt.c index 43e3de3a..b4a8ca00 100644 --- a/src/xrdopt.c +++ b/src/xrdopt.c @@ -14,10 +14,11 @@ #include // for XPointer, True, XParseGeometry, XResource... #include // for XrmoptionSepArg, XrmGetResource, Xrmoptio... #include // for errno -#include // for PATH_MAX +// #include // for PATH_MAX +#include // for MAXPATHLEN #include // for fprintf, NULL, stderr, sscanf #include // for getenv, exit, strtol -#include // for strncpy, strlcat, strlcpy, strcmp +#include // for memcpy, strlcpy, strcmp #include // for u_char #include // for access, R_OK #include "xdefs.h" // for WINDOW_NAME @@ -91,17 +92,19 @@ extern char backgroundColorName[64]; extern char windowTitle[255]; -extern char sysout_name_cl[]; -extern char sysout_name_xrm[]; +extern char sysout_name_cl[MAXPATHLEN]; +extern char sysout_name_xrm[MAXPATHLEN]; extern unsigned sysout_size; extern int for_makeinit, please_fork, noscroll; /* diagnostic flag for sysout dumping */ -/* extern unsigned maxpages; */ +extern unsigned maxpages; /*** Ethernet stuff (JRB) **/ #ifdef MAIKO_ENABLE_ETHERNET +extern int ether_enabled; extern int ether_fd; extern u_char ether_host[6]; +extern char ether_ifname[32]; #if defined(USE_NIT) extern struct sockaddr_nit snit; #endif /* USE_NIT */ @@ -135,7 +138,7 @@ void print_Xusage(const char *prog) (void)fprintf(stderr, " -iconbitmap | -ibm -bitmap for the medley icon\n"); (void)fprintf(stderr, " -xsync -turn XSynchronize on. (default is off)\n\n"); -#if defined(MAIKO_ENABLE_NETHUB) +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_NETHUB) (void)fprintf(stderr,"\ -nh-host dodo-host Hostname for Dodo Nethub (no networking if missing)\n\ -nh-port port-number Port for Dodo Nethub (optional, default: 3333)\n\ @@ -146,6 +149,14 @@ void print_Xusage(const char *prog) exit(EXIT_FAILURE); } /* end print_Xusage() */ +static void XrmValueCopy(char *dst, XrmValue value, size_t dstSize) { + size_t len; + if (dst == NULL || dstSize == 0) return; /* placate gemini */ + len = (value.size < dstSize) ? value.size : dstSize - 1; + memcpy(dst, value.addr, len); + dst[len] = '\0'; +} + /************************************************************************/ /* */ /* r e a d _ X o p t i o n */ @@ -193,7 +204,7 @@ void read_Xoption(int *argc, char *argv[]) if (XrmGetResource(commandlineDB, "ldex.sysout", "Ldex.Sysout", str_type, &value) == True) { /* Get Sysout from command line only */ - (void)strncpy(sysout_name_cl, value.addr, value.size); + XrmValueCopy(sysout_name_cl, value, sizeof(sysout_name_cl)); } /* In order to access other DB's we have to open the main display now */ @@ -203,7 +214,7 @@ void read_Xoption(int *argc, char *argv[]) /* protocol. */ if (XrmGetResource(commandlineDB, "ldex.display", "Ldex.Display", str_type, &value) == True) { - (void)strncpy(Display_Name, value.addr, value.size); + XrmValueCopy(Display_Name, value, sizeof(Display_Name)); } else if (getenv("DISPLAY") == (char *)NULL) { (void)fprintf(stderr, "Can't find a display. Either set the shell\n"); (void)fprintf(stderr, "variable DISPLAY to an appropriate display\n"); @@ -216,8 +227,7 @@ void read_Xoption(int *argc, char *argv[]) if ((xdisplay = XOpenDisplay(Display_Name)) != NULL) { /* read the other databases */ /* Start with app-defaults/medley */ - (void)strlcpy(tmp, "/usr/lib/X11/app-defaults/", sizeof(tmp)); - (void)strlcat(tmp, "medley", sizeof(tmp)); + (void)strlcpy(tmp, "/usr/lib/X11/app-defaults/medley", sizeof(tmp)); applicationDB = XrmGetFileDatabase(tmp); if (applicationDB != NULL) { (void)XrmMergeDatabases(applicationDB, &rDB); } /* Then try the displays defaults */ @@ -232,60 +242,60 @@ void read_Xoption(int *argc, char *argv[]) } envname = getenv("HOME"); - (void)strlcpy(tmp, envname, sizeof(tmp)); - (void)strlcat(tmp, "/.Xdefaults", sizeof(tmp)); - if (access(tmp, R_OK) != 0) { - serverDB = XrmGetFileDatabase(tmp); - if (serverDB != NULL) { (void)XrmMergeDatabases(serverDB, &rDB); } + if (envname != NULL) { + snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", envname); + if (access(tmp, R_OK) == 0) { + serverDB = XrmGetFileDatabase(tmp); + if (serverDB != NULL) { (void)XrmMergeDatabases(serverDB, &rDB); } + } } - /* Now for the commandline */ (void)XrmMergeDatabases(commandlineDB, &rDB); if (XrmGetResource(rDB, "ldex.sysout", "Ldex.Sysout", str_type, &value) == True) { /* Get Sysout from x resource manager */ - (void)strncpy(sysout_name_xrm, value.addr, value.size); + XrmValueCopy(sysout_name_xrm, value, sizeof(sysout_name_xrm)); } if (XrmGetResource(rDB, "ldex.title", "Ldex.Title", str_type, &value) == True) { - (void)strncpy(windowTitle, value.addr, sizeof(windowTitle) - 1); + XrmValueCopy(windowTitle, value, sizeof(windowTitle)); } else { - (void)strncpy(windowTitle, WINDOW_NAME, sizeof(windowTitle) - 1); + (void)strlcpy(windowTitle, WINDOW_NAME, sizeof(windowTitle)); } if (XrmGetResource(rDB, "ldex.icontitle", "Ldex.icontitle", str_type, &value) == True) { - (void)strncpy(iconTitle, value.addr, value.size); + XrmValueCopy(iconTitle, value, sizeof(iconTitle)); } else { (void)strlcpy(iconTitle, "Medley", sizeof(iconTitle)); } if (XrmGetResource(rDB, "ldex.iconbitmap", "Ldex.Iconbitmap", str_type, &value) == True) { - (void)strncpy(iconpixmapfile, value.addr, value.size); + XrmValueCopy(iconpixmapfile, value, sizeof(iconpixmapfile)); } /* Old style geometry definition. */ if (XrmGetResource(rDB, "ldex.geometry", "Ldex.geometry", str_type, &value) == True) { /* Get Geometry */ - (void)strncpy(tmp, value.addr, value.size); + XrmValueCopy(tmp, value, sizeof(tmp)); bitmask = XParseGeometry(tmp, &LispWindowRequestedX, &LispWindowRequestedY, &LispWindowRequestedWidth, &LispWindowRequestedHeight); } if (XrmGetResource(rDB, "ldex.screen", "Ldex.screen", str_type, &value) == True) { /* Get Geometry */ - (void)strncpy(tmp, value.addr, value.size); + XrmValueCopy(tmp, value, sizeof(tmp)); bitmask = XParseGeometry(tmp, &LispDisplayRequestedX, &LispDisplayRequestedY, &LispDisplayRequestedWidth, &LispDisplayRequestedHeight); } if (XrmGetResource(rDB, "ldex.cursorColor", "Ldex.cursorColor", str_type, &value) == True) { - (void)strncpy(cursorColor, value.addr, sizeof(cursorColor) - 1); + XrmValueCopy(cursorColor, value, sizeof(cursorColor)); } if (XrmGetResource(rDB, "ldex.foreground", "Ldex.foreground", str_type, &value) == True) { - (void)strncpy(foregroundColorName, value.addr, sizeof(foregroundColorName) - 1); + XrmValueCopy(foregroundColorName, value, sizeof(foregroundColorName)); } if (XrmGetResource(rDB, "ldex.background", "Ldex.background", str_type, &value) == True) { - (void)strncpy(backgroundColorName, value.addr, sizeof(backgroundColorName) - 1); + XrmValueCopy(backgroundColorName, value, sizeof(backgroundColorName)); } if (XrmGetResource(rDB, "ldex.NoFork", "Ldex.NoFork", str_type, &value) == True) { @@ -297,24 +307,23 @@ void read_Xoption(int *argc, char *argv[]) } if (XrmGetResource(rDB, "ldex.timer", "Ldex.timer", str_type, &value) == True) { - (void)strncpy(tmp, value.addr, value.size); + XrmValueCopy(tmp, value, sizeof(tmp)); errno = 0; i = (int)strtol(tmp, (char **)NULL, 10); if (errno == 0 && i > 0) TIMER_INTERVAL = i; } - /* if (XrmGetResource(rDB, - "ldex.maxpages", - "Ldex.maxpages", - str_type, &value) == True) { - (void)strncpy(tmp, value.addr, value.size); - maxpages = (unsigned)strtol((tmp, (char **)NULL, 10); - // should check no error here - } - */ + if (XrmGetResource(rDB, "ldex.maxpages", "Ldex.maxpages", str_type, &value) == True) { + XrmValueCopy(tmp, value, sizeof(tmp)); + errno = 0; + i = (int)strtol(tmp, (char **)NULL, 10); + if (errno == 0 && i > 0) + maxpages = i; + } + if (XrmGetResource(rDB, "ldex.memory", "Ldex.memory", str_type, &value) == True) { - (void)strncpy(tmp, value.addr, value.size); + XrmValueCopy(tmp, value, sizeof(tmp)); errno = 0; i = (int)strtol(tmp, (char **)NULL, 10); if (errno == 0 && i > 0) @@ -324,28 +333,50 @@ void read_Xoption(int *argc, char *argv[]) if (XrmGetResource(rDB, "ldex.Init", "Ldex.Init", str_type, &value) == True) { for_makeinit = 1; } if (XrmGetResource(rDB, "ldex.xsync", "Ldex.xsync", str_type, &value) == True) { xsync = True; } -#ifdef MAIKO_ENABLE_ETHERNET + +#if defined(MAIKO_ENABLE_ETHERNET) && defined(MAIKO_OS_SOLARIS) && (defined(USE_DLPI) || defined(USE_NIT)) if (XrmGetResource(rDB, "ldex.EtherNet", "Ldex.EtherNet", str_type, &value) == True) { - int b0, b1, b2, b3, b4, b5; - (void)strncpy(tmp, value.addr, value.size); + int b[6]; + XrmValueCopy(tmp, value, sizeof(tmp)); #if defined(USE_DLPI) - if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7) + if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5]) == 7) #elif defined(USE_NIT) - if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x:%s", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5, + if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x:%s", ðer_fd, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], snit.snit_ifname) == 8) -#endif /* USE_NIT */ +#endif { - ether_host[0] = b0; - ether_host[1] = b1; - ether_host[2] = b2; - ether_host[3] = b3; - ether_host[4] = b4; - ether_host[5] = b5; + for (int i = 0; i < 6; i++) + ether_host[i] = b[i] & 0xff; } else { - (void)fprintf(stderr, "Missing or bogus -E argument\n"); + (void)fprintf(stderr, "Missing or bogus -E or ldex.EtherNet resource argument\n"); ether_fd = -1; exit(1); } } -#endif /* MAIKO_ENABLE_ETHERNET */ +#endif /* defined(MAIKO_ENABLE_ETHERNET) && defined(MAIKO_OS_SOLARIS) && (defined(USE_DLPI) || defined(USE_NIT)) */ + +#if defined(MAIKO_ENABLE_ETHERNET) && defined(USE_PCAP) + if (XrmGetResource(rDB, "ldex.EtherNet", "Ldex.EtherNet", str_type, &value) == True) { + int b[6], fields; + char ifname[32]; + XrmValueCopy(tmp, value, sizeof(tmp)); + if (strchr(tmp, ':') == NULL && strchr(tmp, '%') == NULL) { + /* assume it's an interface name for which we do not know the address */ + ether_enabled = 1; + strlcpy(ether_ifname, tmp, sizeof(ether_ifname)); + } else { + fields = sscanf(tmp, "%x:%x:%x:%x:%x:%x%%%31s", &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], ifname); + if (fields == 6 || fields == 7) { + ether_enabled = 1; + for (int i = 0; i < 6; i++) + ether_host[i] = b[i] & 0xff; + if (fields == 7) + strlcpy(ether_ifname, ifname, sizeof(ether_ifname)); + } else { + (void)fprintf(stderr, "Invalid argument for -E or ldex.EtherNet resource: %s (X/pcap)\n", tmp); + exit(1); + } + } + } +#endif /* defined(MAIKO_ENABLE_ETHERNET) && defined(USE_PCAP) */ } /* end readXoption */ diff --git a/src/xwinman.c b/src/xwinman.c index 5f5c0f9d..df3f2a5e 100644 --- a/src/xwinman.c +++ b/src/xwinman.c @@ -172,7 +172,7 @@ void beep_Xkeyboard(DspInterface dsp) /************************************************************************/ /* */ -/* p r o c e s s _ X e v e n t s */ +/* p r o c e s s _ D i s p l a y _ e v e n t s */ /* */ /* Take X key/mouse events and turn them into Lisp events */ /* */ @@ -180,7 +180,7 @@ void beep_Xkeyboard(DspInterface dsp) extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ -void process_Xevents(DspInterface dsp) +void process_Display_events(DspInterface dsp) { XEvent report;