New upstream version 6.0.24.67+repack

This commit is contained in:
Hibby 2025-03-22 00:22:09 +00:00
parent f0ac0675f6
commit bdf8a8367e
No known key found for this signature in database
28 changed files with 9717 additions and 99 deletions

View File

@ -10245,7 +10245,7 @@ BOOL GetConfig(char * ConfigName)
GetStringValue(group, "ISPAccountPass", EncryptedISPAccountPass, 100);
sprintf(SignoffMsg, "73 de %s\r", BBSName); // Default
GetStringValue(group, "SignoffMsg", ISPAccountName, 50);
GetStringValue(group, "SignoffMsg", SignoffMsg, 50);
DecryptPass(EncryptedISPAccountPass, ISPAccountPass, (int)strlen(EncryptedISPAccountPass));

View File

@ -1148,6 +1148,7 @@
// Fix bug in WP Message processing (56)
// Fix treating addresses ending in WW as Internet (57)
// Run sending to packetnodes.spots.radio in a separate thread (61)
// Fix loading ISP Account Name from config file (67)
#include "bpqmail.h"
#include "winstdint.h"

View File

@ -1,12 +0,0 @@
main :
{
BPQHostIP = "192.168.1.64";
COM1 = "COM43";
COM2 = "";
COM3 = "";
COM4 = "";
HamLibPort1 = 4534;
HamLibPort2 = 0;
HamLibPort3 = 0;
HamLibPort4 = 0;
};

View File

@ -1255,6 +1255,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Fix bug in RHP socket timeout code (65)
// Fix L4 RTT (66)
// Fix RigConrol with Chanxx but no other settings (66)
// Add option to compress L2 frames (67)
// Sort Routes displays (67)
@ -6153,7 +6155,7 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile)
{
if (len > 76)
{
len += sprintf(RegLine[len], "\\\r\n");
len += sprintf(&RegLine[len], "\\\r\n");
WriteFile(hFile, RegLine, len, &written, NULL);
strcpy(RegLine, " ");
len = 2;
@ -6162,7 +6164,7 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile)
len += sprintf(&RegLine[len], "%02x,", Value[k]);
if (len > 76)
{
len += sprintf(RegLine[len], "\\\r\n");
len += sprintf(&RegLine[len], "\\\r\n");
WriteFile(hFile, RegLine, len, &written, NULL);
strcpy(RegLine, " ");
}

View File

@ -23,7 +23,6 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#ifdef LINBPQ
#include "compatbits.h"
char * strlop(char * buf, char delim);
#define APIENTRY
#define VOID void
@ -32,6 +31,8 @@ char * strlop(char * buf, char delim);
#include <windows.h>
#endif
char * strlop(char * buf, char delim);
VOID APIENTRY md5 (char *arg, unsigned char * checksum);

32
Cmd.c
View File

@ -70,6 +70,10 @@ void GetPortCTEXT(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, st
VOID WriteMiniDump();
int CheckKissInterlock(struct PORTCONTROL * PORT, int Exclusive);
int seeifInterlockneeded(struct PORTCONTROL * PORT);
int CompareNode(const void *a, const void *b);
int CompareAlias(const void *a, const void *b);
int CompareRoutes(const void * a, const void * b);
extern VOID KISSTX(struct KISSINFO * KISS, PMESSAGE Buffer);
@ -1604,6 +1608,8 @@ VOID CMDR00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
int Port = 0;
char AXCALL[7];
BOOL Found;
int count, i, n = 0;
struct ROUTE * List[1000];
ptr = strtok_s(CmdTail, " ", &Context);
@ -1624,14 +1630,31 @@ VOID CMDR00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
Bufferptr = Cmdprintf(Session, Bufferptr, "Routes\r");
while (MaxRoutes--)
// Build and sort list of routes
for (count = 0; count < MaxRoutes; count++)
{
if (Routes->NEIGHBOUR_CALL[0] != 0)
if (Port == 0 || Port == Routes->NEIGHBOUR_PORT)
Bufferptr = DisplayRoute(Session, Bufferptr, Routes, Verbose);
{
List[n++] = Routes;
if (n > 999)
break;
}
Routes++;
}
if (n > 1)
qsort(List, n, sizeof(void *), CompareRoutes);
for (i = 0; i < n; i++)
{
Routes = List[i];
if (Port == 0 || Port == Routes->NEIGHBOUR_PORT)
Bufferptr = DisplayRoute(Session, Bufferptr, Routes, Verbose);
}
goto SendReply;
ROUTEUPDATE:
@ -2817,9 +2840,6 @@ VOID LINKCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
}
int CompareNode(const void *a, const void *b);
int CompareAlias(const void *a, const void *b);
char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST * Dest)
{
char Normcall[10];

View File

@ -1124,6 +1124,11 @@ int CompareNode(struct DEST_LIST ** a, struct DEST_LIST ** b)
return memcmp(a[0]->DEST_CALL, b[0]->DEST_CALL, 7);
}
int CompareRoutes(struct ROUTE ** a, struct ROUTE ** b)
{
return memcmp(a[0]->NEIGHBOUR_CALL, b[0]->NEIGHBOUR_CALL, 7);
}
DllExport int APIENTRY CountFramesQueuedOnStream(int Stream)
{
BPQVECSTRUC * PORTVEC = &BPQHOSTVECTOR[Stream-1]; // API counts from 1

View File

@ -168,6 +168,12 @@ void hookL2SessionDeleted(struct _LINKTABLE * LINK)
LINK->ConnectTime = 0;
}
if (LINK->Sent && LINK->Received && (LINK->SentAfterCompression || LINK->ReceivedAfterExpansion))
Debugprintf("L2 Compression Stats %s %s TX %d %d %d%% RX %d %d %d%%", LINK->callingCall, LINK->receivingCall,
LINK->Sent, LINK->SentAfterCompression, ((LINK->Sent - LINK->SentAfterCompression) * 100) / LINK->Sent,
LINK->Received, LINK->ReceivedAfterExpansion, ((LINK->ReceivedAfterExpansion - LINK->Received) * 100) / LINK->Received);
}
void hookL2SessionAttempt(int Port, char * ourcall, char * remotecall, struct _LINKTABLE * LINK)

3860
FLDigi64.c Normal file

File diff suppressed because it is too large Load Diff

1907
HALDriver64.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1917,7 +1917,7 @@ int standardParams(struct TNCINFO * TNC, char * buf)
TNC->ActiveTXFreq = atof(&buf[13]);
else if (_memicmp(buf, "ActiveRXFreq", 12) == 0) // Set at start of session
TNC->ActiveRXFreq = atof(&buf[13]);
else if (_memicmp(buf, "DisconnectScript", 16) == 0) // Set at start of session
else if (_memicmp(buf, "DisconnectScript", 16) == 0) // Set at end of session
TNC->DisconnectScript = SeparateMultiString(&buf[17]);
else if (_memicmp(buf, "PTTONHEX", 8) == 0)
{

View File

@ -105,9 +105,13 @@ extern int NumberofPorts;
extern UCHAR ConfigDirectory[260];
extern struct AXIPPORTINFO * Portlist[];
VOID sendandcheck(SOCKET sock, const char * Buffer, int Len);
int CompareNode(const void *a, const void *b);
int CompareAlias(const void *a, const void *b);
int CompareRoutes(const void * a, const void * b);
void ProcessMailHTTPMessage(struct HTTPConnectionInfo * Session, char * Method, char * URL, char * input, char * Reply, int * RLen, int InputLen, char * Token);
void ProcessChatHTTPMessage(struct HTTPConnectionInfo * Session, char * Method, char * URL, char * input, char * Reply, int * RLen);
struct PORTCONTROL * APIENTRY GetPortTableEntryFromSlot(int portslot);
@ -3794,12 +3798,88 @@ doHeader:
*/
// AXIP Partners
if (_stricmp(NodeURL, "/Node/AXIP.html") == 0)
{
int i;
char Normcall[10];
int Width = 5;
int x = 0, n = 0, nd = 0;
struct arp_table_entry * List[1000];
struct arp_table_entry * ListD[1000];
char AXIPList[10000] = "";
int ListLen = 0;
struct AXIPPORTINFO * AXPORT = Portlist[0];
struct PORTCONTROL * PORT = PORTTABLE;
struct arp_table_entry * arp;
time_t NOW = time(NULL);
char AXIPHeader[] =
"<table align='center' bgcolor='ffffff' border=2 cellpadding=10 cellspacing=2 style=font-family:monospace>"
"<tr><td align='center'>AXIP Up</td><td align='center'>AXIP Down</td></tr><tr><td valign='top'>%s";
char DownList[] =
"</td><td valign='top'>%s";
char Tail[] =
"</td></tr></table></body></html>";
while (PORT)
{
AXPORT = Portlist[PORT->PORTNUMBER];
if (AXPORT)
{
// Get ARP entries
for (i = 0; i < AXPORT->arp_table_len; i++)
{
arp = &AXPORT->arp_table[i];
if (arp->LastHeard == 0 || (NOW - arp->LastHeard) > 3600) // Considered down
ListD[nd++] = arp;
else
List[n++] = arp;
}
}
PORT = PORT->PORTPOINTER;
}
if (n > 1)
qsort(List, n, sizeof(void *), CompareNode);
if (nd > 1)
qsort(ListD, nd, sizeof(void *), CompareNode);
for (i = 0; i < n; i++)
{
int len = ConvFromAX25(List[i]->callsign, Normcall);
Normcall[len]=0;
ListLen += sprintf(&AXIPList[ListLen], "%02d - %s %d<br>", i + 1, Normcall, (List[i]->LastHeard)?(NOW - List[i]->LastHeard):0);
}
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], AXIPHeader, AXIPList);
ListLen = 0;
for (i = 0; i < nd; i++)
{
int len = ConvFromAX25(ListD[i]->callsign, Normcall);
Normcall[len]=0;
ListLen += sprintf(&AXIPList[ListLen], "%02d - %s %d<br>", i + 1, Normcall, (ListD[i]->LastHeard)?(NOW - ListD[i]->LastHeard):0);
}
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], DownList, AXIPList);
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], Tail);
}
if (_stricmp(NodeURL, "/Node/Routes.html") == 0)
{
struct ROUTE * Routes = NEIGHBOURS;
int MaxRoutes = MAXNEIGHBOURS;
int count;
int count, i;
char Normcall[10];
char locked[4] = " ";
int NodeCount;
@ -3808,11 +3888,33 @@ doHeader:
char Active[10];
int Queued;
int x = 0, n = 0;
struct ROUTE * List[1000];
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", RouteHddr);
for (count=0; count<MaxRoutes; count++)
// Build and sort list of routes
for (count = 0; count < MaxRoutes; count++)
{
if (Routes->NEIGHBOUR_CALL[0] != 0)
{
List[n++] = Routes;
if (n > 999)
break;
}
Routes++;
}
if (n > 1)
qsort(List, n, sizeof(void *), CompareRoutes);
for (i = 0; i < n; i++)
{
Routes = List[i];
{
int len = ConvFromAX25(Routes->NEIGHBOUR_CALL, Normcall);
Normcall[len]=0;

View File

@ -387,7 +387,7 @@ char * FormatIP(uint32_t Addr)
return FormatIPWork;
}
int CompareRoutes (const VOID * a, const VOID * b)
int CompareIPRoutes (const VOID * a, const VOID * b)
{
PROUTEENTRY x;
PROUTEENTRY y;
@ -4972,7 +4972,7 @@ VOID SHOWIPROUTE(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, str
Bufferptr = Cmdprintf(Session, Bufferptr, "%d Entries\r", NumberofRoutes);
if (NumberofRoutes)
qsort(RouteRecords, NumberofRoutes, sizeof(void *), CompareRoutes);
qsort(RouteRecords, NumberofRoutes, sizeof(void *), CompareIPRoutes);
for (i=0; i < NumberofRoutes; i++)
{

396
L2Code.c
View File

@ -33,6 +33,15 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include "cheaders.h"
#include "tncinfo.h"
// This is needed to link with a lib built from source
#ifdef WIN32
#define ZEXPORT __stdcall
#endif
#include <zlib.h>
#define PFBIT 0x10 // POLL/FINAL BIT IN CONTROL BYTE
#define REJSENT 1 // SET WHEN FIRST REJ IS SENT IN REPLY
@ -111,7 +120,7 @@ int CheckKissInterlock(struct PORTCONTROL * MYPORT, int Exclusive);
void hookL2SessionAccepted(int Port, char * fromCall, char * toCall, struct _LINKTABLE * LINK);
void hookL2SessionDeleted(struct _LINKTABLE * LINK);
void hookL2SessionAttempt(int Port, char * fromCall, char * toCall, struct _LINKTABLE * LINK);
int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len);
extern int REALTIMETICKS;
@ -126,7 +135,9 @@ extern int REALTIMETICKS;
#define SDINVC 1 // INVALID COMMAND
#define SDNRER 8 // INVALID N(R)
extern int L2Compress;
extern int L2CompMaxframe;
extern int L2CompPaclen;
UCHAR NO_CTEXT = 0;
UCHAR ALIASMSG = 0;
@ -842,6 +853,7 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
while (xidlen > 0)
{
unsigned char * typeptr = ptr;
Type = *ptr++;
Len = *ptr++;
@ -889,6 +901,23 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
case 8: //RX Window
break;
case 16:
// Compression
if (L2Compress)
{
LINK->AllowCompress = 1;
// return as 17
*typeptr = 17;
}
else
{
ptr = &ADJBUFFER->PID;
ptr[3] -= 2; // Length field - remove compress option
Buffer->LENGTH -=2;
}
}
}
@ -900,6 +929,8 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
LINK->LINKPORT = PORT;
LINK->KILLTIMER = L2KILLTIME - 60*3; // Time out after 60 secs if SABM not received
// save calls so we can match up SABM when it comes
memcpy(LINK->LINKCALL, Buffer->ORIGIN, 7);
@ -999,6 +1030,7 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
// MESSAGE ON AN ACTIVE LINK
int CTLlessPF = CTL & ~PFBIT;
unsigned char * ptr;
PORT->L2FRAMESFORUS++;
@ -1054,7 +1086,7 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
LINK->L2STATE = 2;
LINK->Ver2point2 = FALSE;
LINK->L2TIMER = 1; // USe retry to send SABM
LINK->L2TIMER = 1; // Use retry to send SABM
}
else if (CTLlessPF == XID)
{
@ -1062,7 +1094,49 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
LINK->L2STATE = 2;
LINK->Ver2point2 = TRUE;// Must support 2.2 if responded to XID
LINK->L2TIMER = 1; // USe retry to send SABM
// if Compress enabled set it
ptr = &ADJBUFFER->PID;
if (*ptr++ == 0x82 && *ptr++ == 0x80)
{
int Type;
int Len;
unsigned int value;
int xidlen = *(ptr++) << 8;
xidlen += *ptr++;
// XID is set of Type, Len, Value n-tuples
while (xidlen > 0)
{
Type = *ptr++;
Len = *ptr++;
value = 0;
xidlen -= (Len + 2);
while (Len--)
{
value <<=8;
value += *ptr++;
}
switch(Type)
{
case 17:
// Compression
if (L2Compress)
LINK->AllowCompress = 1;
}
}
}
LINK->L2TIMER = 1; // Use retry to send SABM
}
ReleaseBuffer(Buffer);
@ -1721,9 +1795,9 @@ BOOL InternalL2SETUPCROSSLINK(PROUTE ROUTE, int Retries)
else
LINK->LINKWINDOW = PORT->PORTWINDOW;
// if (SUPPORT2point2)
// LINK->L2STATE = 1; // Send XID
// else
if (SUPPORT2point2)
LINK->L2STATE = 1; // Send XID
else
LINK->L2STATE = 2;
memcpy(LINK->LINKCALL, ROUTE->NEIGHBOUR_CALL, 7);
@ -2018,7 +2092,6 @@ VOID SDUFRM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
SDFRMR(LINK, PORT); // PROCESS FRAME REJECT CONDITION
}
ReleaseBuffer(Buffer);
}
@ -2450,6 +2523,8 @@ CheckPF:
}
int doinflate(unsigned char * source, unsigned char * dest, int Len, int destlen, int * outLen);
VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffer)
{
@ -2479,6 +2554,7 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
Info = &Buffer->PID;
LINK->bytesRXed += Length;
LINK->Received += Length - 1; // Exclude PID
// Adjust for DIGIS
@ -2495,6 +2571,111 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
switch(PID)
{
case 0xf2:
// Intermediate fragment of compressed. Save
// Length and Info include pid
Length--;
Info++;
if (LINK->unCompress == 0)
LINK->unCompress = malloc(8192);
// Save data
memcpy(&LINK->unCompress[LINK->unCompressLen], Info, Length);
LINK->unCompressLen += Length;
ReleaseBuffer(Buffer);
LINK->L2ACKREQ = PORT->PORTT2; // SET RR NEEDED
LINK->KILLTIMER = 0; // RESET IDLE LINK TIMER
return;
case 0xf1:
// Compressed last or only
{
char exBuffer[8192];
int Len;
int outLen;
int sendLen;
char * sendptr = exBuffer;
Length--;
Info++;
// we may have previous fragments
if (LINK->unCompressLen)
{
memcpy(&LINK->unCompress[LINK->unCompressLen], Info, Length);
LINK->unCompressLen += Length;
Len = doinflate(LINK->unCompress, exBuffer, LINK->unCompressLen, 8192, &outLen);
LINK->ReceivedAfterExpansion += outLen - 1;
LINK->unCompressLen = 0;
}
else
{
Len = doinflate(Info, exBuffer, Length, 8192, &outLen);
LINK->ReceivedAfterExpansion += outLen - 1;
}
sendLen = outLen;
// Send first bit in input buffer. If still some left get new buffers for it
if (sendLen > 257)
sendLen = 257;
// First byte is original PID
memcpy(&Msg->PID, exBuffer, sendLen);
Msg->LENGTH = sendLen + MSGHDDRLEN;
C_Q_ADD(&LINK->RX_Q, Msg);
outLen -= sendLen;
sendptr += sendLen;
while (outLen > 0)
{
sendLen = outLen;
if (sendLen > 236)
sendLen = 236;
Msg = GetBuff();
if (Msg)
{
// Just ignore if no buffers - shouldn't happen
Msg->PID = exBuffer[0];
Msg->PORT = LINK->LINKPORT->PORTNUMBER;
memcpy(Msg->L2DATA, sendptr, sendLen);
Length = sendLen + 1;
Msg->LENGTH = Length + MSGHDDRLEN;
C_Q_ADD(&LINK->RX_Q, Msg);
}
outLen -= sendLen;
sendptr += sendLen;
}
LINK->L2ACKREQ = PORT->PORTT2; // SET RR NEEDED
LINK->KILLTIMER = 0; // RESET IDLE LINK TIMER
return;
}
case 0xcc:
case 0xcd:
@ -2544,6 +2725,7 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
// Copy Data back over
memmove(&Msg->PID, Info, Length);
LINK->ReceivedAfterExpansion += Length - 1;
Buffer->LENGTH = Length + MSGHDDRLEN;
@ -2758,7 +2940,7 @@ VOID SDETX(struct _LINKTABLE * LINK)
UCHAR * ptr1, * ptr2;
UCHAR CTL;
int count;
MESSAGE * Msg;
struct DATAMESSAGE * Msg;
MESSAGE * Buffer;
// DONT SEND IF RESEQUENCING RECEIVED FRAMES - CAN CAUSE FRMR PROBLEMS
@ -2766,11 +2948,6 @@ VOID SDETX(struct _LINKTABLE * LINK)
// if (LINK->L2RESEQ_Q)
// return;
if (LINK->LINKPORT->PORTNUMBER == 19)
{
int i = 0;
}
Outstanding = LINK->LINKNS - LINK->LINKOWS; // Was WS not NS
if (Outstanding < 0)
@ -2783,11 +2960,148 @@ VOID SDETX(struct _LINKTABLE * LINK)
while (LINK->TX_Q && LINK->FRAMES[LINK->SDTSLOT] == NULL)
{
// Try compressing here. Only Compress PID 0xF0 frames - NETROM doesn't treat L2 session as a byte stream
Msg = Q_REM(&LINK->TX_Q);
Msg->CHAIN = NULL;
if (LINK->AllowCompress && Msg->LENGTH > 20 && LINK->TX_Q && Msg->PID == 240) // if short and no more not worth trying compression
{
int complen = 0;
int dataLen;
int savePort = Msg->PORT;
int savePID = Msg->PID;
unsigned char Compressed[8192];
unsigned char toCompress[8192];
int toCompressLen = 0;
int slots = 0;
int n = LINK->SDTSLOT;
int maxcompsize;
int PACLEN = LINK->LINKPORT->PORTPACLEN;
unsigned char * compdata;
int sendLen = complen;
int uncompressed = 0;
if (PACLEN == 0)
PACLEN = 256;
// I think I need to know how many slots are available, so I don't compress too much
// Then collect data, compressing after each frame to make sure will fit in available space
while (LINK->FRAMES[n] == NULL && slots < 8)
{
slots++;
n++;
n &= 7;
}
maxcompsize = slots * PACLEN;
// Save first packet, then see if more on TX_Q
toCompressLen = 0;
dataLen = Msg->LENGTH - MSGHDDRLEN;
LINK->Sent += dataLen;
memcpy(&toCompress[toCompressLen], &Msg->PID, dataLen);
toCompressLen += dataLen;
complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
ReleaseBuffer(Msg);
while (LINK->TX_Q)
{
Msg = LINK->TX_Q; // Leave on queue until sure it will fit
dataLen = Msg->LENGTH - MSGHDDRLEN -1; // PID only on 1st fragment
memcpy(&toCompress[toCompressLen], &Msg->L2DATA, dataLen);
toCompressLen += dataLen;
// Need to make sure we don't go over maxcompsize
complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
if (complen > maxcompsize)
{
// Remove last fragment and compress again
toCompressLen -= dataLen;
complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
break;
}
else
{
LINK->Sent += dataLen;
Msg = Q_REM(&LINK->TX_Q);
Msg->CHAIN = NULL;
ReleaseBuffer(Msg);
}
}
if (complen >= toCompressLen)
{
// Won't compress, so just send original data
// May still need to fragment
memcpy(Compressed, toCompress, toCompressLen);
complen = toCompressLen - 1; // Remove leading PID
uncompressed = 1;
compdata = &Compressed[1];
}
else
compdata = Compressed;
// We now need to packetize and add to FRAMES
LINK->SentAfterCompression += complen;
sendLen = PACLEN;
while (complen > 0)
{
int PID = 0xF1;
if (complen > sendLen)
PID = 0xF2; // More to come
else
sendLen = complen;
if (uncompressed)
PID = Compressed[0];
Msg = GetBuff();
if (!Msg)
return;
Msg->PORT = savePort;
Msg->PID = PID;
memcpy(&Msg->L2DATA, compdata, sendLen);
Msg->LENGTH = sendLen + MSGHDDRLEN + 1;
LINK->FRAMES[LINK->SDTSLOT] = Msg;
LINK->SDTSLOT ++;
LINK->SDTSLOT &= 7;
compdata += sendLen;
complen -= sendLen;
}
toCompressLen = 0;
}
else
{
LINK->FRAMES[LINK->SDTSLOT] = Msg;
LINK->SDTSLOT ++;
LINK->SDTSLOT &= 7;
}
}
// dont send while poll outstanding
@ -3000,6 +3314,17 @@ VOID L2TimerProc()
{
// CIRCUIT HAS BEEN IDLE TOO LONG - SHUT IT DOWN
// if in XID received state session was never established so don't send DISC
if (LINK->L2STATE == 1)
{
if (PORT->TNC && PORT->TNC->Hardware == H_KISSHF)
DetachKISSHF(PORT);
CLEAROUTLINK(LINK);
}
else
{
LINK->KILLTIMER = 0;
LINK->L2TIMER = 1; // TO FORCE DISC
LINK->L2STATE = 4; // DISCONNECTING
@ -3008,6 +3333,7 @@ VOID L2TimerProc()
InformPartner(LINK, NORMALCLOSE);
}
}
LINK++;
}
}
@ -3311,6 +3637,9 @@ VOID CLEAROUTLINK(struct _LINKTABLE * LINK)
CLEARL2QUEUES(LINK); // TO RELEASE ANY BUFFERS
if (LINK->unCompress)
free(LINK->unCompress);
memset(LINK, 0, sizeof(struct _LINKTABLE));
}
@ -3345,6 +3674,10 @@ VOID L2SENDXID(struct _LINKTABLE * LINK)
*ptr++ = 0x82; // FI
*ptr++ = 0x80; // GI
*ptr++ = 0x0;
if (L2Compress)
*ptr++ = 0x12; // Length 18
else
*ptr++ = 0x10; // Length 16
*ptr++ = 0x02; // Classes of Procedures
@ -3375,6 +3708,14 @@ VOID L2SENDXID(struct _LINKTABLE * LINK)
*ptr++ = 0x01; // Len
*ptr++ = 0x07; // 7
// if L2Compress Enabled request it
if (L2Compress)
{
*ptr++ = 0x10; // Compress
*ptr++ = 0x00; // Len
}
Buffer->LENGTH = (int)(ptr - (UCHAR *)Buffer); // SET LENGTH
LINK->L2TIMER = ONEMINUTE; // (RE)SET TIMER
@ -4178,6 +4519,33 @@ int seeifUnlockneeded(struct _LINKTABLE * LINK)
return 0;
}
int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len)
{
z_stream defstream;
int maxSize;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
defstream.avail_in = Len; // size of input
defstream.next_in = (Bytef *)In; // input char array
deflateInit(&defstream, Z_BEST_COMPRESSION);
maxSize = deflateBound(&defstream, Len);
if (maxSize > OutSize)
return 0;
defstream.avail_out = maxSize; // size of output
defstream.next_out = (Bytef *)Out; // output char array
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);
return defstream.total_out;
}

121
L4Code.c
View File

@ -67,18 +67,23 @@ VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len
VOID FRAMEFORUS(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG, int ApplMask, UCHAR * ApplCall);
void WriteConnectLog(char * fromCall, char * toCall, UCHAR * Mode);
void SendVARANetromMsg(struct TNCINFO * TNC, PL3MESSAGEBUFFER MSG);
unsigned char * Compressit(unsigned char * In, int Len, int * OutLen);
int doinflate(unsigned char * source, unsigned char * dest, int Len, int destlen, int * outLen);
int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len);
static UINT APPLMASK;
extern BOOL LogL4Connects;
extern BOOL LogAllConnects;
extern int L4Compress;
extern int L4CompMaxframe;
extern int L4CompPaclen;
extern int L2Compress;
extern int L2CompMaxframe;
extern int L2CompPaclen;
// L4 Flags Values
#define DISCPENDING 8 // SEND DISC WHEN ALL DATA ACK'ED
@ -567,6 +572,55 @@ void sendChunk(TRANSPORTENTRY * L4, unsigned char * Compressed, int complen, int
}
}
void sendL2Chunk(struct _LINKTABLE * LINK, unsigned char * Compressed, int complen, int sendPacLen)
{
unsigned char * compdata;
struct DATAMESSAGE * Msg;
int sendLen = complen;
int fragments;
LINK->SentAfterCompression += complen;
if (complen > L2CompPaclen)
{
fragments = (complen / sendPacLen); // Split to roughly equal sized fraagments
if (fragments * sendPacLen != complen)
fragments++;
sendLen = (complen / fragments) + 1;
}
Debugprintf("L2 Chunk %d Bytes %d PACLEN %d Fragments %d FragSize", complen, sendPacLen, fragments, sendLen);
compdata = Compressed;
while (complen > 0)
{
int PID = 0xF1;
if (complen > sendLen)
PID = 0xF2; // More to come
Msg = GetBuff();
if (!Msg)
return;
Msg->PORT = LINK->LINKPORT->PORTNUMBER;
memcpy(Msg->L2DATA, compdata, sendLen);
Msg->LENGTH = sendLen + MSGHDDRLEN + 1; // 1 for pid field
Msg->PID = PID; // Not sent so use as a flag for compressed msg
compdata += sendLen;
complen -= sendLen;
C_Q_ADD(&LINK->TX_Q, Msg);
}
}
VOID L4BG()
{
// PROCESS DATA QUEUED ON SESSIONS
@ -628,7 +682,7 @@ VOID L4BG()
LINK = L4->L4TARGET.LINK;
if (COUNT_AT_L2(LINK) > 8)
if (COUNT_AT_L2(LINK) > 64)
break;
}
@ -666,36 +720,32 @@ VOID L4BG()
if (L4->AllowCompress)
{
int complen = 0;
unsigned char * Compressed;
unsigned char Compressed[8192];
unsigned char toCompress[8192];
int toCompressLen = 0;
int dataLen;
int savePort = Msg->PORT;
int maxCompSendLen;
// Save first packet, then see if more on TX_Q
L4->toCompress = malloc(8192);
L4->toCompressLen = 0;
dataLen = Msg->LENGTH - MSGHDDRLEN - 1; // No header or pid
L4->Sent += dataLen;
memcpy(&L4->toCompress[L4->toCompressLen], Msg->L2DATA, dataLen);
L4->toCompressLen += dataLen;
memcpy(&toCompress[toCompressLen], Msg->L2DATA, dataLen);
toCompressLen += dataLen;
// See if first will compress. If not assume too short or already compressed data and just send
Compressed = Compressit(L4->toCompress, L4->toCompressLen, &complen);
complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
if (complen >= dataLen)
{
free(Compressed);
L4->SentAfterCompression += dataLen;
SENDL4MESSAGE(L4, Msg);
ReleaseBuffer(Msg);
free(L4->toCompress);
L4->toCompress = 0;
L4->toCompressLen = 0;
toCompressLen = 0;
continue;
}
@ -705,7 +755,7 @@ VOID L4BG()
{
// no more, so just send the stuff we've just compressed. Compressed data will fit in input packet
// Debugprintf("%d %d %d%%", L4->toCompressLen, complen, ((L4->toCompressLen - complen) * 100) / L4->toCompressLen);
// Debugprintf("%d %d %d%%", toCompressLen, complen, ((toCompressLen - complen) * 100) / toCompressLen);
memcpy(Msg->L2DATA, Compressed, complen);
@ -716,17 +766,13 @@ VOID L4BG()
SENDL4MESSAGE(L4, Msg);
ReleaseBuffer(Msg);
free(L4->toCompress);
L4->toCompressLen = 0;
L4->toCompress = 0;
free(Compressed);
toCompressLen = 0;
continue;
}
free(Compressed);
ReleaseBuffer(Msg); // Not going to use it
while (L4->L4TX_Q && L4->toCompressLen < (8192 - 256)) // Make sure can't overrin buffer
while (L4->L4TX_Q && toCompressLen < (8192 - 256)) // Make sure can't overrin buffer
{
// Collect the data from L4TX_Q
@ -734,16 +780,17 @@ VOID L4BG()
dataLen = Msg->LENGTH - MSGHDDRLEN - 1; // No header or pid
L4->Sent += dataLen;
memcpy(&L4->toCompress[L4->toCompressLen], Msg->L2DATA, dataLen);
L4->toCompressLen += dataLen;
memcpy(&toCompress[toCompressLen], Msg->L2DATA, dataLen);
toCompressLen += dataLen;
ReleaseBuffer(Msg);
}
L4->toCompress[L4->toCompressLen] = 0;
toCompress[toCompressLen] = 0;
Compressed = Compressit(L4->toCompress, L4->toCompressLen, &complen);
// Debugprintf("%d %d %d%%", L4->toCompressLen, complen, ((L4->toCompressLen - complen) * 100) / L4->toCompressLen);
complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
Debugprintf("%d %d %d%%", toCompressLen, complen, ((toCompressLen - complen) * 100) / toCompressLen);
// Send compressed
@ -762,8 +809,8 @@ VOID L4BG()
int Fragments;
int ChunkSize;
unsigned char * CompressPtr = L4->toCompress;
int bytesleft = L4->toCompressLen;
unsigned char * CompressPtr = toCompress;
int bytesleft = toCompressLen;
// Assume 10% worse compression on smaller input
@ -771,7 +818,7 @@ VOID L4BG()
Fragments = j / maxCompSendLen;
Fragments++;
ChunkSize = (L4->toCompressLen / Fragments) + 1; // 1 for rounding
ChunkSize = (toCompressLen / Fragments) + 1; // 1 for rounding
while (bytesleft > 0)
{
@ -779,9 +826,9 @@ VOID L4BG()
if (Len > ChunkSize)
Len = ChunkSize;
free (Compressed);
Compressed = Compressit(CompressPtr, Len, &complen);
// Debugprintf("Chunked %d %d %d%%", Len, complen, ((Len - complen) * 100) / Len);
complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
Debugprintf("Chunked %d %d %d%%", Len, complen, ((Len - complen) * 100) / Len);
sendChunk(L4, Compressed, complen, savePort);
@ -793,10 +840,7 @@ VOID L4BG()
else
sendChunk(L4, Compressed, complen,savePort);
free(L4->toCompress);
L4->toCompressLen = 0;
L4->toCompress = 0;
free(Compressed);
toCompressLen = 0;
}
else
{
@ -808,6 +852,8 @@ VOID L4BG()
continue;
}
// L2 Link
LINK = L4->L4TARGET.LINK;
// If we want to enforce PACLEN this may be a good place to do it
@ -936,9 +982,6 @@ VOID CLEARSESSIONENTRY(TRANSPORTENTRY * Session)
if (Session->PARTCMDBUFFER)
ReleaseBuffer(Session->PARTCMDBUFFER);
if (Session->toCompress)
free(Session->toCompress);
if (Session->unCompress)
free(Session->unCompress);

View File

1543
MULTIPSK64.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,16 @@ KC6OAR*>ID:
Output += sprintf((char *)Output, " RX Window=%d", value);
break;
case 16:
Output += sprintf((char *)Output, " Can Compress");
break;
case 17:
Output += sprintf((char *)Output, " Compress ok");
break;
}
}
}
@ -551,6 +561,15 @@ KC6OAR*>ID:
switch (ADJBUFFER->PID)
{
case 0xF1:
case 0xF2:
// Compressed L2 Data
Output += sprintf((char *)Output, " <%d Bytes of Compressed L2 Data>", MsgLen - (19 + sizeof(void *)));
break;
case 0xF0: // Normal Data
{
char Infofield[257];

View File

View File

@ -5293,6 +5293,7 @@ BOOL DecodeModePtr(char * Param, double * Dwell, double * Freq, char * Mode,
if (ptr == NULL || strlen(ptr) > 8)
return FALSE; // Mode Missing
// If channel, dont need mode
if (*MemoryNumber == 0)
{

1714
SCSTrackeMulti64.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,14 +10,15 @@
#endif
#define KVers 6,0,24,66
#define KVerstring "6.0.24.66\0"
#define KVers 6,0,24,67
#define KVerstring "6.0.24.67\0"
#ifdef CKernel
#define Vers KVers
#define Verstring KVerstring
#define Datestring "February 2025"
#define Datestring "March 2025"
#define VerComments "G8BPQ Packet Switch (C Version)" KVerstring
#define VerCopyright "Copyright © 2001-2025 John Wiseman G8BPQ\0"
#define VerDesc "BPQ32 Switch\0"

View File

@ -37,6 +37,7 @@ VOID Do_Save_WPRec(HWND hDlg);
VOID SaveInt64Value(config_setting_t * group, char * name, long long value);
VOID SaveIntValue(config_setting_t * group, char * name, int value);
VOID SaveStringValue(config_setting_t * group, char * name, char * value);
BOOL GetStringValue(config_setting_t * group, char * name, char * value, int maxlen);
void MQTTMessageEvent(void* message);
WPRec * AllocateWPRecord()

View File

@ -176,8 +176,6 @@ typedef struct _TRANSPORTENTRY
// We collect as much data as possible before compressing and re-packetizing
int AllowCompress;
unsigned char * toCompress; // Data being saved to compress
int toCompressLen;
unsigned char * unCompress; // Data being saved to uncompress
int unCompressLen;
@ -959,6 +957,21 @@ typedef struct _LINKTABLE
int bytesRXed; // Info bytes only
int bytesTXed;
// Now support compressing L2 Sessions.
// We collect as much data as possible before compressing and re-packetizing
int AllowCompress;
unsigned char * unCompress; // Data being saved to uncompress
int unCompressLen;
int Sent;
int SentAfterCompression;
int Received;
int ReceivedAfterExpansion;
} LINKTABLE;
#pragma pack(1)
@ -1354,6 +1367,7 @@ struct arp_table_entry
// SOCKET SourceSocket;
struct AXIPPORTINFO * PORT;
BOOL noUpdate; // Don't update dest address from incoming packet
time_t LastHeard; // Last Packet received from this ststiom
};

View File

@ -2610,6 +2610,7 @@ BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port,
//arp->port = Port;
}
arp->LastHeard = time(NULL);
return 1; // Ok to process
}
index++;

15
cMain.c
View File

@ -144,6 +144,10 @@ int L4Compress = 0;
int L4CompMaxframe = 3;
int L4CompPaclen = 236;
int L2Compress = 0;
int L2CompMaxframe = 3;
int L2CompPaclen = 236;
BOOL LogL4Connects = FALSE;
BOOL LogAllConnects = FALSE;
BOOL AUTOSAVEMH = TRUE;
@ -837,6 +841,17 @@ BOOL Start()
if (L4CompPaclen < 64 || L4CompPaclen > 236)
L4CompPaclen = 236;
L2Compress = cfg->C_L2Compress;
L2CompMaxframe = cfg->C_L2CompMaxframe;
L2CompPaclen = cfg->C_L2CompPaclen;
if (L2CompMaxframe < 1 || L2CompMaxframe > 16)
L2CompMaxframe = 3;
if (L2CompPaclen < 64 || L2CompPaclen > 236)
L2CompPaclen = 236;
// Get pointers to PASSWORD and APPL1 commands
// int APPL1 = 0;

View File

@ -308,7 +308,7 @@ static char *keywords[] =
"BTEXT:", "NETROMCALL", "C_IS_CHAT", "MAXRTT", "MAXHOPS", // IPGATEWAY= no longer allowed
"LogL4Connects", "LogAllConnects", "SAVEMH", "ENABLEADIFLOG", "ENABLEEVENTS", "SAVEAPRSMSGS",
"EnableM0LTEMap", "MQTT", "MQTT_HOST", "MQTT_PORT", "MQTT_USER", "MQTT_PASS",
"L4Compress", "L4CompMaxframe", "L4CompPaclen"
"L4Compress", "L4CompMaxframe", "L4CompPaclen", "L2Compress", "L2CompMaxframe", "L2CompPaclen"
}; /* parameter keywords */
static void * offset[] =
@ -330,7 +330,7 @@ static void * offset[] =
&xxcfg.C_BTEXT, &xxcfg.C_NETROMCALL, &xxcfg.C_C, &xxcfg.C_MAXRTT, &xxcfg.C_MAXHOPS, // IPGATEWAY= no longer allowed
&xxcfg.C_LogL4Connects, &xxcfg.C_LogAllConnects, &xxcfg.C_SaveMH, &xxcfg.C_ADIF, &xxcfg.C_EVENTS, &xxcfg.C_SaveAPRSMsgs,
&xxcfg.C_M0LTEMap, &xxcfg.C_MQTT, &xxcfg.C_MQTT_HOST, &xxcfg.C_MQTT_PORT, &xxcfg.C_MQTT_USER, &xxcfg.C_MQTT_PASS,
&xxcfg.C_L4Compress, &xxcfg.C_L4CompMaxframe, &xxcfg.C_L4CompPaclen}; /* offset for corresponding data in config file */
&xxcfg.C_L4Compress, &xxcfg.C_L4CompMaxframe, &xxcfg.C_L4CompPaclen, &xxcfg.C_L2Compress, &xxcfg.C_L2CompMaxframe, &xxcfg.C_L2CompPaclen}; /* offset for corresponding data in config file */
static int routine[] =
{
@ -351,7 +351,7 @@ static int routine[] =
15, 0, 2, 9, 9,
2, 2, 1, 2, 2, 2,
2, 2, 0, 1, 20, 20,
1, 1, 1} ; // Routine to process param
1, 1, 1, 1, 1, 1} ; // Routine to process param
int PARAMLIM = sizeof(routine)/sizeof(int);
//int NUMBEROFKEYWORDS = sizeof(routine)/sizeof(int);
@ -621,6 +621,9 @@ BOOL ProcessConfig()
paramok[86]=1; // L4Compress
paramok[87]=1; // L4Compress Maxframe
paramok[88]=1; // L4Compress Paclen
paramok[89]=1; // L2Compress
paramok[90]=1; // L2Compress Maxframe
paramok[91]=1; // L2Compress Paclen
for (i=0; i < PARAMLIM; i++)

View File

@ -173,6 +173,9 @@ struct CONFIGTABLE
int C_L4Compress;
int C_L4CompMaxframe;
int C_L4CompPaclen;
int C_L2Compress;
int C_L2CompMaxframe;
int C_L2CompPaclen;
//#define ApplOffset 80000 // Applications offset in config buffer