From 6b6a238bcf0cd978e1decb37eb3f35dc50e96a2d Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sat, 17 Apr 2021 16:06:57 +0100 Subject: [PATCH 1/2] Make tfe easier to compile in linux. --- AppleWinExpress2008.vcproj | 12 ++++++------ AppleWinExpress2019.vcxproj | 12 ++++++------ AppleWinExpress2019.vcxproj.filters | 12 ++++++------ source/Configuration/PageConfigTfe.cpp | 4 ++-- source/Tfe/{Tfe.cpp => tfe.cpp} | 4 ++-- source/Tfe/{Tfe.h => tfe.h} | 0 source/Tfe/{Tfearch.cpp => tfearch.cpp} | 0 source/Tfe/{Tfearch.h => tfearch.h} | 0 source/Tfe/{Tfesupp.cpp => tfesupp.cpp} | 11 ----------- source/Tfe/{Tfesupp.h => tfesupp.h} | 0 source/Utilities.cpp | 2 +- source/Windows/AppleWin.cpp | 2 +- 12 files changed, 24 insertions(+), 35 deletions(-) rename source/Tfe/{Tfe.cpp => tfe.cpp} (96%) rename source/Tfe/{Tfe.h => tfe.h} (100%) rename source/Tfe/{Tfearch.cpp => tfearch.cpp} (100%) rename source/Tfe/{Tfearch.h => tfearch.h} (100%) rename source/Tfe/{Tfesupp.cpp => tfesupp.cpp} (91%) rename source/Tfe/{Tfesupp.h => tfesupp.h} (100%) diff --git a/AppleWinExpress2008.vcproj b/AppleWinExpress2008.vcproj index c5d8019b..67f9f069 100644 --- a/AppleWinExpress2008.vcproj +++ b/AppleWinExpress2008.vcproj @@ -426,7 +426,7 @@ > - - - + + + @@ -207,7 +207,7 @@ - + NotUsing NotUsing NotUsing @@ -215,7 +215,7 @@ NotUsing NotUsing - + NotUsing NotUsing NotUsing @@ -223,7 +223,7 @@ NotUsing NotUsing - + NotUsing NotUsing NotUsing diff --git a/AppleWinExpress2019.vcxproj.filters b/AppleWinExpress2019.vcxproj.filters index 4e5b5f10..99d361d4 100644 --- a/AppleWinExpress2019.vcxproj.filters +++ b/AppleWinExpress2019.vcxproj.filters @@ -142,13 +142,13 @@ Source Files\Emulator - + Source Files\Uthernet - + Source Files\Uthernet - + Source Files\Uthernet @@ -426,13 +426,13 @@ Source Files\Emulator - + Source Files\Uthernet - + Source Files\Uthernet - + Source Files\Uthernet diff --git a/source/Configuration/PageConfigTfe.cpp b/source/Configuration/PageConfigTfe.cpp index f145efe5..084d9cde 100644 --- a/source/Configuration/PageConfigTfe.cpp +++ b/source/Configuration/PageConfigTfe.cpp @@ -28,8 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../Common.h" #include "../Registry.h" #include "../resource/resource.h" -#include "../Tfe/Tfe.h" -#include "../Tfe/Tfesupp.h" +#include "../Tfe/tfe.h" +#include "../Tfe/tfesupp.h" CPageConfigTfe* CPageConfigTfe::ms_this = 0; // reinit'd in ctor diff --git a/source/Tfe/Tfe.cpp b/source/Tfe/tfe.cpp similarity index 96% rename from source/Tfe/Tfe.cpp rename to source/Tfe/tfe.cpp index 4da7117a..5bb58519 100644 --- a/source/Tfe/Tfe.cpp +++ b/source/Tfe/tfe.cpp @@ -392,8 +392,8 @@ void tfe_debug_output_pp( void ) /* ------------------------------------------------------------------------- */ /* initialization and deinitialization functions */ -BYTE __stdcall TfeIoCxxx (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles); -BYTE __stdcall TfeIo (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles); +static BYTE __stdcall TfeIoCxxx (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles); +static BYTE __stdcall TfeIo (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles); void tfe_reset(void) { diff --git a/source/Tfe/Tfe.h b/source/Tfe/tfe.h similarity index 100% rename from source/Tfe/Tfe.h rename to source/Tfe/tfe.h diff --git a/source/Tfe/Tfearch.cpp b/source/Tfe/tfearch.cpp similarity index 100% rename from source/Tfe/Tfearch.cpp rename to source/Tfe/tfearch.cpp diff --git a/source/Tfe/Tfearch.h b/source/Tfe/tfearch.h similarity index 100% rename from source/Tfe/Tfearch.h rename to source/Tfe/tfearch.h diff --git a/source/Tfe/Tfesupp.cpp b/source/Tfe/tfesupp.cpp similarity index 91% rename from source/Tfe/Tfesupp.cpp rename to source/Tfe/tfesupp.cpp index 0ba63a3f..13097e44 100644 --- a/source/Tfe/Tfesupp.cpp +++ b/source/Tfe/tfesupp.cpp @@ -33,19 +33,8 @@ * */ -#include -#include #include #include -#include -#include -#include -#include -#include -#include - -#include "tfesupp.h" - // Lib Stuff /* #define LIB_DEBUG*/ diff --git a/source/Tfe/Tfesupp.h b/source/Tfe/tfesupp.h similarity index 100% rename from source/Tfe/Tfesupp.h rename to source/Tfe/tfesupp.h diff --git a/source/Utilities.cpp b/source/Utilities.cpp index a37c50aa..2f2890d9 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -49,7 +49,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "SoundCore.h" #include "Configuration/IPropertySheet.h" -#include "Tfe/Tfe.h" +#include "Tfe/tfe.h" #ifdef USE_SPEECH_API #include "Speech.h" diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index 13bbc3ba..00f862d6 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -52,7 +52,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Configuration/About.h" #include "Configuration/PropertySheet.h" -#include "Tfe/Tfe.h" +#include "Tfe/tfe.h" //================================================= From 4c51309e3b9a03deff116562bd58736b8bfa4278 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sat, 17 Apr 2021 18:29:08 +0100 Subject: [PATCH 2/2] libpcap in linux: we can justuse the libpacap provided and link to it directly. Moreover, add a #include to include windows types (only needed in linux). --- source/Tfe/tfearch.cpp | 112 ++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/source/Tfe/tfearch.cpp b/source/Tfe/tfearch.cpp index 9c28c014..8be4178d 100644 --- a/source/Tfe/tfearch.cpp +++ b/source/Tfe/tfearch.cpp @@ -34,12 +34,22 @@ #include #include +#include // this is necessary in linux, but in MSVC windows.h MUST come after winsock2.h (from pcap.h above) #include "tfe.h" #include "tfearch.h" #include "tfesupp.h" #include "../Log.h" +/** #define TFE_DEBUG_ARCH 1 **/ +/** #define TFE_DEBUG_PKTDUMP 1 **/ + +/* #define TFE_DEBUG_FRAMES - might be defined in TFE.H! */ + +#define TFE_DEBUG_WARN 1 /* this should not be deactivated */ + +#ifdef _MSC_VER + typedef pcap_t *(*pcap_open_live_t)(const char *, int, int, int, char *); typedef int (*pcap_dispatch_t)(pcap_t *, int, pcap_handler, u_char *); typedef int (*pcap_setnonblock_t)(pcap_t *, int, char *); @@ -49,13 +59,6 @@ typedef void (*pcap_freealldevs_t)(pcap_if_t *); typedef int (*pcap_sendpacket_t)(pcap_t *p, u_char *buf, int size); typedef const char *(*pcap_lib_version_t)(void); -/** #define TFE_DEBUG_ARCH 1 **/ -/** #define TFE_DEBUG_PKTDUMP 1 **/ - -/* #define TFE_DEBUG_FRAMES - might be defined in TFE.H! */ - -#define TFE_DEBUG_WARN 1 /* this should not be deactivated */ - static pcap_open_live_t p_pcap_open_live; static pcap_dispatch_t p_pcap_dispatch; static pcap_setnonblock_t p_pcap_setnonblock; @@ -67,46 +70,6 @@ static pcap_lib_version_t p_pcap_lib_version; static HINSTANCE pcap_library = NULL; - -/* ------------------------------------------------------------------------- */ -/* variables needed */ - - -//static log_t g_fh = g_fh; - - -static pcap_if_t *TfePcapNextDev = NULL; -static pcap_if_t *TfePcapAlldevs = NULL; -static pcap_t *TfePcapFP = NULL; - -static char TfePcapErrbuf[PCAP_ERRBUF_SIZE]; - -#ifdef TFE_DEBUG_PKTDUMP - -static -void debug_output( const char *text, BYTE *what, int count ) -{ - char buffer[256]; - char *p = buffer; - char *pbuffer1 = what; - int len1 = count; - int i; - - sprintf(buffer, "\n%s: length = %u\n", text, len1); - OutputDebugString(buffer); - do { - p = buffer; - for (i=0; (i<8) && len1>0; len1--, i++) { - sprintf( p, "%02x ", (unsigned int)(unsigned char)*pbuffer1++); - p += 3; - } - *(p-1) = '\n'; *p = 0; - OutputDebugString(buffer); - } while (len1>0); -} -#endif // #ifdef TFE_DEBUG_PKTDUMP - - static void TfePcapFreeLibrary(void) { @@ -171,7 +134,62 @@ BOOL TfePcapLoadLibrary(void) #undef GET_PROC_ADDRESS_AND_TEST +#else +// libpcap is a standard package, just link to it +#define p_pcap_open_live pcap_open_live +#define p_pcap_dispatch pcap_dispatch +#define p_pcap_setnonblock pcap_setnonblock +#define p_pcap_findalldevs pcap_findalldevs +#define p_pcap_freealldevs pcap_freealldevs +#define p_pcap_sendpacket pcap_sendpacket +#define p_pcap_datalink pcap_datalink +#define p_pcap_lib_version pcap_lib_version + +static BOOL TfePcapLoadLibrary(void) +{ + return TRUE; +} + +#endif + +/* ------------------------------------------------------------------------- */ +/* variables needed */ + + +//static log_t g_fh = g_fh; + + +static pcap_if_t *TfePcapNextDev = NULL; +static pcap_if_t *TfePcapAlldevs = NULL; +static pcap_t *TfePcapFP = NULL; + +static char TfePcapErrbuf[PCAP_ERRBUF_SIZE]; + +#ifdef TFE_DEBUG_PKTDUMP + +static +void debug_output( const char *text, BYTE *what, int count ) +{ + char buffer[256]; + char *p = buffer; + char *pbuffer1 = what; + int len1 = count; + int i; + + sprintf(buffer, "\n%s: length = %u\n", text, len1); + OutputDebugString(buffer); + do { + p = buffer; + for (i=0; (i<8) && len1>0; len1--, i++) { + sprintf( p, "%02x ", (unsigned int)(unsigned char)*pbuffer1++); + p += 3; + } + *(p-1) = '\n'; *p = 0; + OutputDebugString(buffer); + } while (len1>0); +} +#endif // #ifdef TFE_DEBUG_PKTDUMP static void TfePcapCloseAdapter(void)