diff --git a/Bpq32.c b/Bpq32.c index b282d88..9ca6ea5 100644 --- a/Bpq32.c +++ b/Bpq32.c @@ -1275,6 +1275,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses // Fix 64 bit compatiblility issues with AGWAPI (73) // Fix KAM Pactor Interlock (73) // Fix Node map reporting, broken in .73 (74) +// Fixes to build on FreeBSD and NetBSD from jg1uaa (77) +// Fix to L4Compress from Stece G7TAJ (77) #define CKernel diff --git a/IPCode.c b/IPCode.c index 54756e3..4d9abca 100644 --- a/IPCode.c +++ b/IPCode.c @@ -100,7 +100,10 @@ TODo ?Multiple Adapters #ifdef WIN32 int pcap_sendpacket(pcap_t *p, u_char *buf, int size); #else - PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int); +#ifndef PCAP_API +#define PCAP_API extern +#endif +PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int); #endif #ifndef LINBPQ diff --git a/L4Code.c b/L4Code.c index 56a0a23..703168a 100644 --- a/L4Code.c +++ b/L4Code.c @@ -797,8 +797,6 @@ VOID L4BG() // Fragment if more than L4CompPaclen - // Entered with original first fragment in saveMsg; - // Check for too big a compressed frame size. Bigger compresses better but adds latency to link maxCompSendLen = L4CompPaclen * L4CompMaxframe; @@ -827,7 +825,7 @@ VOID L4BG() if (Len > ChunkSize) Len = ChunkSize; - complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen); + complen = L2Compressit(Compressed, 8192, toCompress, Len); Debugprintf("Chunked %d %d %d%%", Len, complen, ((Len - complen) * 100) / Len); diff --git a/LinBPQ.c b/LinBPQ.c index 6ba4b1c..689b5f4 100644 --- a/LinBPQ.c +++ b/LinBPQ.c @@ -913,7 +913,10 @@ int main(int argc, char * argv[]) Debugprintf("G8BPQ AX25 Packet Switch System Version %s %s", TextVerstring, Datestring); -#ifndef MACBPQ +#if defined(MACBPQ) || defined(FREEBSD) + time_t dummy; + _MYTIMEZONE = -localtime(&dummy)->tm_gmtoff; +#else _MYTIMEZONE = _timezone; #endif diff --git a/TNCEmulators.c b/TNCEmulators.c index 135d318..7fce453 100644 --- a/TNCEmulators.c +++ b/TNCEmulators.c @@ -241,8 +241,14 @@ typedef struct _SERIAL_STATUS { #ifndef WIN32 -#ifdef MACBPQ +#if defined(MACBPQ) #include +#elif defined(FREEBSD) +#if defined(__FreeBSD__) || defined(__DragonFly__) +#include +#else +#include +#endif #endif extern int posix_openpt (int __oflag); @@ -262,7 +268,7 @@ HANDLE LinuxOpenPTY(char * Name) u_long param=1; struct termios term; -#ifdef MACBPQ +#if defined(MACBPQ) || defined(FREEBSD) // Create a pty pair diff --git a/Versions.h b/Versions.h index 181a6ab..061e9eb 100644 --- a/Versions.h +++ b/Versions.h @@ -10,15 +10,15 @@ #endif -#define KVers 6,0,24,75 -#define KVerstring "6.0.24.75\0" +#define KVers 6,0,24,77 +#define KVerstring "6.0.24.77\0" #ifdef CKernel #define Vers KVers #define Verstring KVerstring -#define Datestring "June 2025" +#define Datestring "July 2025" #define VerComments "G8BPQ Packet Switch (C Version)" KVerstring #define VerCopyright "Copyright © 2001-2025 John Wiseman G8BPQ\0" #define VerDesc "BPQ32 Switch\0" diff --git a/asmstrucs.h b/asmstrucs.h index aa73b93..79e9a26 100644 --- a/asmstrucs.h +++ b/asmstrucs.h @@ -1087,7 +1087,11 @@ struct SEM int Gets; int Rels; DWORD SemProcessID; +#ifdef WIN32 DWORD SemThreadID; +#else + pthread_t SemThreadID; +#endif int Line; // caller file and line char File[MAX_PATH]; }; diff --git a/linether.c b/linether.c index fb3410c..b354465 100644 --- a/linether.c +++ b/linether.c @@ -22,17 +22,29 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses // Normally uses a Raw socket, but that can't send to other apps on same machine. // so can use a TAP device instead (or maybe as well??) + +// Not suported on BSD based systems + +#ifndef FREEBSD #ifndef MACBPQ + +#if !(defined(MACBPQ) || defined(FREEBSD)) + #include - #include "cheaders.h" - #include + +#if !(defined(FREEBSD)) + #include #include #include +#endif +#endif + + extern int tap_fd; typedef struct PCAPStruct @@ -489,5 +501,11 @@ static int ProcessLine(char * buf, int Port, BOOL CheckPort) return (FALSE); } + + +// + +#endif // MACBPQ +#endif // FREEBSD -#endif + diff --git a/lzhuf32.c b/lzhuf32.c index f1ef0a4..c1aea82 100644 --- a/lzhuf32.c +++ b/lzhuf32.c @@ -1406,7 +1406,7 @@ File: 5566 NEWBOAT.HOMEPORT.JPG if (SendBBStoSYSOPCall) if (_stricmp(FullTo, BBSName) == 0) - strcpy(Msg->to, SYSOPCall); + strcpy(FullTo, SYSOPCall); if ((Msg->via[0] == 0 || strcmp(Msg->via, "BPQ") == 0 || strcmp(Msg->via, "BBS") == 0) && (conn->Paclink || conn->RMSExpress)) diff --git a/makefile b/makefile index 6d7c6e4..cdb6298 100644 --- a/makefile +++ b/makefile @@ -17,10 +17,32 @@ OBJS = pngwtran.o pngrtran.o pngset.o pngrio.o pngwio.o pngtrans.o pngrutil.o pn # Configuration: -CC = gcc - -all: CFLAGS = -DLINBPQ -MMD -g -rdynamic -fcommon -fasynchronous-unwind-tables -all: LDFLAGS = -l:libpaho-mqtt3a.a -l:libjansson.a +#Default to Linux + CC = gcc + EXTRA_LDFLAGS = -Xlinker -Map=output.map -lrt -l:libpaho-mqtt3a.a -l:libjansson.a + +#other OS + +OS_NAME = $(shell uname -s) +ifeq ($(OS_NAME),NetBSD) + CC = cc + EXTRA_CFLAGS = -DFREEBSD -DNOMQTT -I/usr/pkg/include + EXTRA_LDFLAGS = -Xlinker -Map=output.map -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lrt -lutil -lexecinfo +endif +ifeq ($(OS_NAME),FreeBSD) + CC = cc + EXTRA_CFLAGS = -DFREEBSD -DNOMQTT -I/usr/local/include + EXTRA_LDFLAGS = -Xlinker -Map=output.map -L/usr/local/lib -lrt -liconv -lutil -lexecinfo +endif +ifeq ($(OS_NAME),Darwin) + CC = gcc + EXTRA_CFLAGS = -DMACBPQ -DNOMQTT + EXTRA_LDFLAGS = -liconv +endif + +$(info OS_NAME is $(OS_NAME)) + +all: CFLAGS = -DLINBPQ -MMD -g -fcommon -fasynchronous-unwind-tables $(EXTRA_CFLAGS) all: linbpq @@ -32,7 +54,7 @@ noi2c: linbpq linbpq: $(OBJS) - gcc $(OBJS) -Xlinker -Map=output.map -l:libminiupnpc.a -lrt -lm -lz $(LDFLAGS) -lpthread -lconfig -lpcap -o linbpq + cc $(OBJS) $(EXTRA_LDFLAGS) -lminiupnpc -lm -lz $(LDFLAGS) -lpthread -lconfig -lpcap -o linbpq sudo setcap "CAP_NET_ADMIN=ep CAP_NET_RAW=ep CAP_NET_BIND_SERVICE=ep" linbpq -include *.d diff --git a/upnp.c b/upnp.c index 8190a62..714e04d 100644 --- a/upnp.c +++ b/upnp.c @@ -134,7 +134,7 @@ int upnpInit() return 0; } -#if MINIUPNPC_API_VERSION == 18 +#if MINIUPNPC_API_VERSION >= 18 i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), wanaddr, sizeof(wanaddr)); #else i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); @@ -168,7 +168,7 @@ int upnpClose() return 0; } -#if MINIUPNPC_API_VERSION == 18 +#if MINIUPNPC_API_VERSION >= 18 i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), wanaddr, sizeof(wanaddr)); #else i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));