6.0.25.12 hacky merge due t it not ffing.

This commit is contained in:
Hibby 2025-11-23 11:51:15 +00:00
parent 85f200a46c
commit d7b0d25ddb
10 changed files with 1331 additions and 75 deletions

View file

@ -35,8 +35,6 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include <fcntl.h>
//#include "vmm.h"
uint64_t INP3timeLoadedMS = 0;
extern int DEBUGINP3;
VOID SendNegativeInfo();
@ -64,11 +62,16 @@ static VOID SendNetFrame(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Frame)
typedef struct _RTTMSG
{
UCHAR ID[7];
UCHAR TXTIME[11];
UCHAR SMOOTHEDRTT[11];
UCHAR LASTRTT[11];
UCHAR POINTER[11];
UCHAR ID[6];
UCHAR Space1;
UCHAR TXTIME[10];
UCHAR Space2;
UCHAR SMOOTHEDRTT[10];
UCHAR Space3;
UCHAR LASTRTT[10];
UCHAR Space4;
UCHAR RTTID[10];
UCHAR Space5;
UCHAR ALIAS[7];
UCHAR VERSION[12];
UCHAR SWVERSION[9];
@ -110,6 +113,8 @@ extern int RTTInterval; // 4 Minutes
int RTTRetries = 2;
int RTTTimeout = 6; // 1 Min (Horizon is 1 min)
uint32_t RTTID = 1;
VOID InitialiseRTT()
{
UCHAR temp[256] = "";
@ -161,6 +166,7 @@ VOID DeleteINP3Routes(struct ROUTE * Route)
Route->BCTimer = 0;
Route->Status = 0;
Route->Timeout = 0;
Route->NeighbourSRTT = 0;
Dest--;
@ -340,8 +346,8 @@ VOID TellINP3LinkSetupFailed(struct ROUTE * Route)
VOID ProcessRTTReply(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff)
{
int RTT;
unsigned int OrigTime;
uint32_t RTT;
uint32_t OrigTime;
char Normcall[10];
@ -349,10 +355,10 @@ VOID ProcessRTTReply(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff)
Route->Timeout = 0; // Got Response
sscanf(&Buff->L4DATA[6], "%d", &OrigTime);
RTT = (int)((GetTickCount() - INP3timeLoadedMS) / 10 - (OrigTime)); // We work internally in mS
sscanf(&Buff->L4DATA[6], "%u", &OrigTime);
RTT = GetTickCountINP3() - OrigTime; // We work internally in mS
if (RTT > 60000)
if (RTT > 60000 || RTT < 0)
return; // Ignore if more than 60 secs (why ??)
Route->RTT = RTT;
@ -890,8 +896,8 @@ VOID UpdateRoute(struct DEST_LIST * Dest, struct INP3_DEST_ROUTE_ENTRY * ROUTEPT
VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len, int Port)
{
int OtherRTT;
int Dummy;
uint32_t OtherRTT;
uint32_t Dummy;
char * ptr;
struct _RTTMSG * RTTMsg = (struct _RTTMSG *)&Buff->L4DATA[0];
char Normcall[10];
@ -920,18 +926,28 @@ VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len
return; // We don't want to use INP3
}
// Extract other end's SRTT
// Basic Validation - look for spaces in the right place
// Get SWVERSION to see if other end is old (Buggy) BPQ
if (memcmp(RTTMsg->SWVERSION, "BPQ32001 ", 9) == 0)
Route->OldBPQ = 1;
if ((RTTMsg->Space1 | RTTMsg->Space2 | RTTMsg->Space3 | RTTMsg->Space4 | RTTMsg->Space5) != ' ')
{
Debugprintf("Corrupt INP3 RTT Message %s", &Buff->L4DATA[0]);
}
else
Route->OldBPQ = 0;
{
// Extract other end's SRTT
sscanf(&Buff->L4DATA[6], "%d %d", &Dummy, &OtherRTT);
// Get SWVERSION to see if other end is old (Buggy) BPQ
Route->NeighbourSRTT = OtherRTT;
if (memcmp(RTTMsg->SWVERSION, "BPQ32001 ", 9) == 0)
Route->OldBPQ = 1;
else
Route->OldBPQ = 0;
sscanf(&Buff->L4DATA[6], "%u %u", &Dummy, &OtherRTT);
if (OtherRTT < 60000) // Don't save suspect values
Route->NeighbourSRTT = OtherRTT;
}
// Look for $M and $H (MAXRTT MAXHOPS)
@ -945,6 +961,8 @@ VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len
if (ptr)
Route->RemoteMAXHOPS = atoi(ptr + 2);
// Echo Back to sender
SendNetFrame(Route, Buff);
@ -965,7 +983,8 @@ VOID SendRTTMsg(struct ROUTE * Route)
char Stamp[50];
char Normcall[10];
unsigned char temp[256];
uint64_t sendTime;
uint32_t sendTime;
int n;
Normcall[ConvFromAX25(Route->NEIGHBOUR_CALL, Normcall)] = 0;
@ -985,14 +1004,21 @@ VOID SendRTTMsg(struct ROUTE * Route)
Msg->L4TXNO = 0;
Msg->L4FLAGS = L4INFO;
// The timestamp can possibly exceed 10 digits. INP3 only works on differece between send and received, so base can be reset safely.
// Windows GetTickCount wraps every 54 days or so. INP3 doesn't care, so long as the edge
// case where timer wraps between sending msg and getting response is ignored
// For platform independence use GetTickCountINP3() and map as appropriate
sendTime = ((uint64_t)GetTickCount() - INP3timeLoadedMS) / 10; // 10mS units
sendTime = GetTickCountINP3(); // 10mS units
if (sendTime > 9999999999)
sendTime = INP3timeLoadedMS = 0;
sprintf(Stamp, "%10u %10d %10d %10d ", sendTime, Route->SRTT, Route->RTT, RTTID++);
sprintf(Stamp, "%10llu %10d %10d %10d ", sendTime, Route->SRTT, Route->RTT, 0);
n = strlen(Stamp);
if (n != 44)
{
Debugprintf("Trying to send corrupt RTT message %s", Stamp);
return;
}
memcpy(RTTMsg.TXTIME, Stamp, 44);
@ -1209,6 +1235,7 @@ int SendRIPTimer()
}
L2SETUPCROSSLINKEX(Route, 2); // Only try SABM twice
Route->NeighbourSRTT = 0; // just in case!
Route->LastConnectAttempt = REALTIMETICKS;

View file

@ -1300,6 +1300,12 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Fix FRMR caused by sending SREJ when no frames outstanding (8)
// Fix some issues with NetromX connects and Route Selection when running INP3 and NODES routing (9)
// Fix connecting to a netrom node with c p node command (10)
<<<<<<< Updated upstream
||||||| Stash base
=======
// Add validation of INP3 RTT messages and various INP3 fixes (12)
// Change NetromX connect syntax to Service@Node to fix passing commands to local applications (12)
>>>>>>> Stashed changes
#define CKernel
@ -1540,7 +1546,6 @@ extern char ReportDest[7];
extern UCHAR ConfigDirectory[260];
extern uint64_t INP3timeLoadedMS;
VOID __cdecl Debugprintf(const char * format, ...);
VOID __cdecl Consoleprintf(const char * format, ...);
@ -2481,8 +2486,6 @@ FirstInit()
EnumProcessesPtr = (FARPROCX)GetProcAddress(ExtDriver,"EnumProcesses");
}
INP3timeLoadedMS = GetTickCount();
srand(time(NULL));
INITIALISEPORTS();

187
Cmd.c
View file

@ -838,13 +838,14 @@ BOOL cATTACHTOBBS(TRANSPORTENTRY * Session, UINT Mask, int Paclen, int * AnySess
return FALSE;
}
void ConnecttoService(TRANSPORTENTRY * Session, char * Bufferptr, int ServiceIndex, char * Node, int Stay)
void ConnecttoService(TRANSPORTENTRY * Session, char * Bufferptr, int Service, char * Node, int Stay)
{
struct DEST_LIST * Dest = DESTS;
int n = MAXDESTS;
int gotDest = 0;
unsigned char axcall[7];
int Service = -1;
char cmdName[80];
int i;
// Make Sure Node is Known
@ -889,9 +890,20 @@ void ConnecttoService(TRANSPORTENTRY * Session, char * Bufferptr, int ServiceInd
Session->STAYFLAG = Stay;
Service = SERVICES[ServiceIndex].ServiceNo;
// Get command name if a named command
Bufferptr = Cmdprintf(Session, Bufferptr, "Connecting to Service %s on Node %s \r", SERVICES[ServiceIndex].ServiceName, Node);
sprintf(cmdName, "%d", Service); // default to number
for (i = 0; i < NUMBEROFSSERVICES; i++)
{
if (SERVICES[i].ServiceNo == Service)
{
strcpy(cmdName, SERVICES[i].ServiceName);
break;
}
}
Bufferptr = Cmdprintf(Session, Bufferptr, "Connecting to Service %s on Node %s \r", cmdName, Node);
DoNetromConnect(Session, Bufferptr, Dest, 0, Service);
@ -930,7 +942,7 @@ int checkifService(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, s
{
if (strcmp(APPName, SERVICES[i].ServiceName) == 0)
{
ConnecttoService(Session, Bufferptr, i, ptr, Stay);
ConnecttoService(Session, Bufferptr, SERVICES[i].ServiceNo, ptr, Stay);
return 1;
}
}
@ -948,7 +960,6 @@ VOID APPLCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
char * ptr1, *ptr2;
int n = 12;
BOOL Stay = FALSE;
char * ptr, *Context;
// Copy Appl and Null Terminate
@ -967,14 +978,17 @@ VOID APPLCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
return;
}
ptr = strtok_s(CmdTail, " ", &Context);
// ptr is first param. Context is rest of string;
if (CmdTail[0] == 'S')
Stay = TRUE;
// could be Node for NETROMX connect or S flag
// We now use service@node, so can't get here
/*
if (ptr)
{
// could be Node for NETROMX connect or S flag
int i;
if (strlen(ptr) > 1)
@ -984,6 +998,8 @@ VOID APPLCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
// See if APPL is one of Paula's service
for (i = 0; i < NUMBEROFSSERVICES; i++)
{
if (strcmp(APPName, SERVICES[i].ServiceName) == 0)
@ -1003,7 +1019,7 @@ VOID APPLCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
else if (ptr[0] == 'S')
Session->STAYFLAG = Stay;
}
*/
memcpy(Session->APPL, CMD->String, 12);
// SEE IF THERE IS AN ALIAS DEFINDED FOR THIS COMMAND
@ -2572,6 +2588,56 @@ VOID CMDC00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
return;
}
// See if NETROMX connect c service@node
if (strchr(ptr, '@'))
{
// We now use service@node, unlike xr
char * Context1;
char * Cmd = strtok_s(ptr, "@", &Context1);
char * Node = strtok_s(NULL, " ", &Context1);
int i;
int Stay = 0;
if (Context1 && Context1[0] == 'S')
Session->STAYFLAG = Stay;
for (i = 0; i < NUMBEROFSSERVICES; i++)
{
if (strcmp(Cmd, SERVICES[i].ServiceName) == 0)
{
if (Node)
{
ConnecttoService(Session, Bufferptr, SERVICES[i].ServiceNo, Node, Stay);
return;
}
}
}
// May be numeric service
for (i = 0; i < strlen(Cmd); i++)
{
if (!isdigit(Cmd[i]))
break;
}
if (i == strlen(Cmd))
{
if (Node)
{
ConnecttoService(Session, Bufferptr, atoi(Cmd), Node, Stay);
return;
}
}
Bufferptr = Cmdprintf(Session, Bufferptr, "Invalid NetromX command\r");
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
return;
}
Port = atoi(ptr);
if (Port)
@ -2671,7 +2737,12 @@ NoPort:
// SEE IF CALL TO ANY OF OUR HOST SESSIONS - UNLESS DIGIS SPECIFIED
<<<<<<< Updated upstream
// if (axcalls[7] == 0 && axcalls[9])
||||||| Stash base
if (axcalls[7] == 0 && axcalls[9] )
=======
>>>>>>> Stashed changes
if (axcalls[7] == 0)
{
// If this connect is as a result of a command alias, don't check appls or we will loop
@ -2723,6 +2794,7 @@ NoPort:
}
}
<<<<<<< Updated upstream
// if no digis see if connect to known node.
// But now could have a single numeric param as a service number (Paula's Netromx)
@ -2750,6 +2822,32 @@ NoPort:
}
if (axcalls[7] == 0 || haveService)
||||||| Stash base
// if no digis see if connect to known node. But now could have a single numeric param as a service number (Paula's Netromx)
// cmdCopy is command tail (after call)
// Make sure field is numeric
i = 0;
while (cmdCopy[i] >= '0' && cmdCopy[i]<= '9')
i++;
if (cmdCopy[i] != ' ')
goto Downlink;
else
{
if (i > 0) // Some digits
{
haveService = 1;
Service = atoi(cmdCopy);
}
}
if (axcalls[7] == 0 || haveService)
=======
if (axcalls[7] == 0)
>>>>>>> Stashed changes
{
// SEE IF CALL TO ANOTHER NODE
@ -2792,9 +2890,6 @@ Downlink:
// L2 NEEDS PORT NUMBER
Bufferptr = Cmdprintf(Session, Bufferptr, "Downlink connect needs port number - C P CALLSIGN\r");
// Send Port List
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
return;
}
@ -5082,6 +5177,7 @@ VOID DoTheCommand(TRANSPORTENTRY * Session)
int n;
int i, Service = -1;
char * Cmd, *Node, *Context;
int Stay = 0;
ptr1 = &COMMANDBUFFER[0]; //
@ -5176,28 +5272,47 @@ VOID DoTheCommand(TRANSPORTENTRY * Session)
// See if a NETROMX Service
Cmd = strtok_s(ptr1, " ", &Context);
Node = strtok_s(NULL, " ", &Context);
// We now use service@node, unlike xr
for (i = 0; i < NUMBEROFSSERVICES; i++)
if (strchr(ptr1, '@'))
{
if (strcmp(Cmd, SERVICES[i].ServiceName) == 0)
{
int Stay = 0;
Cmd = strtok_s(ptr1, "@", &Context);
Node = strtok_s(NULL, " ", &Context);
if (Cmd && Node)
{
if (Context && Context[0] == 'S')
Session->STAYFLAG = Stay;
if (Node)
for (i = 0; i < NUMBEROFSSERVICES; i++)
{
ConnecttoService(Session, ReplyPointer, i, Node, Stay);
return;
if (strcmp(Cmd, SERVICES[i].ServiceName) == 0)
{
ConnecttoService(Session, ReplyPointer, SERVICES[i].ServiceNo, Node, Stay);
return;
}
}
// Connecting to service on local node - msy be possible sometime
}
}
// May be numeric service
for (i = 0; i < strlen(Cmd); i++)
{
if (!isdigit(Cmd[i]))
break;
}
if (i == strlen(Cmd))
{
ConnecttoService(Session, ReplyPointer, atoi(Cmd), Node, Stay);
return;
}
}
ReplyPointer = Cmdprintf(Session, ReplyPointer, "Invalid NetromX command\r");
SendCommandReply(Session, REPLYBUFFER, (int)(ReplyPointer - (char *)REPLYBUFFER));
return;
}
Session->BADCOMMANDS++;
if (Session->BADCOMMANDS > 6) // TOO MANY ERRORS
@ -5214,19 +5329,19 @@ VOID DoTheCommand(TRANSPORTENTRY * Session)
ptr1 += CMDERRLEN;
SendCommandReply(Session, Buffer, (int)(ptr1 - (char *)Buffer));
}
}
VOID StatsTimer()
{
struct PORTCONTROL * PORT = PORTTABLE;
uint64_t sum, sum2;
// Interval is 60 secs
while(PORT)
VOID StatsTimer()
{
int index = PORT->StatsPointer++;
struct PORTCONTROL * PORT = PORTTABLE;
uint64_t sum, sum2;
// Interval is 60 secs
while(PORT)
{
int index = PORT->StatsPointer++;
if (index == 1439)
PORT->StatsPointer = 0; // Cyclic through 24 hours (1440 Mins)

View file

@ -944,9 +944,9 @@ void APIL2Trace(struct _MESSAGE * Message, char * Dirn)
// supervisory
if (PF[0])
udplen += snprintf(&UDPMsg[udplen], 2048 - udplen, ", \"pf\": \"%s\", \"rseq\": %d, \"tseq\": %d", PF, NR, NS);
udplen += snprintf(&UDPMsg[udplen], 2048 - udplen, ", \"pf\": \"%s\", \"rseq\": %d", PF, NR);
else
udplen += snprintf(&UDPMsg[udplen], 2048 - udplen, ", \"rseq\": %d, \"tseq\": %d", NR, NS);
udplen += snprintf(&UDPMsg[udplen], 2048 - udplen, ", \"rseq\": %d", NR);
}

View file

@ -1929,19 +1929,34 @@ void L3SWAPADDRESSES(L3MESSAGEBUFFER * L3MSG)
void SendConNAK(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG)
{
struct TNCINFO * TNC;
L3MSG->L4FLAGS = L4CACK | L4BUSY; // REJECT
L3MSG->L4DATA[0] = 0; // WINDOW
L3SWAPADDRESSES(L3MSG);
L3MSG->L3TTL = L3LIVES;
C_Q_ADD(&LINK->TX_Q, L3MSG);
TNC = LINK->LINKPORT->TNC;
if (LINK->NEIGHBOUR && LINK->NEIGHBOUR->TCPPort)
{
TCPNETROMSend(LINK->NEIGHBOUR, L3MSG);
ReleaseBuffer(L3MSG);
}
else if (TNC && TNC->NetRomMode)
SendVARANetromMsg(TNC, L3MSG);
else
C_Q_ADD(&LINK->TX_Q, L3MSG);
}
VOID SendL4RESET(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG)
{
// Paula's extension
struct TNCINFO * TNC;
L3MSG->L4RXNO = L3MSG->L4ID;
L3MSG->L4TXNO = L3MSG->L4INDEX;
@ -1951,7 +1966,19 @@ VOID SendL4RESET(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG)
L3MSG->L3TTL = L3LIVES;
L3MSG->LENGTH = (int)(&L3MSG->L4DATA[0] - (UCHAR *)L3MSG);
C_Q_ADD(&LINK->TX_Q, L3MSG);
TNC = LINK->LINKPORT->TNC;
if (LINK->NEIGHBOUR && LINK->NEIGHBOUR->TCPPort)
{
TCPNETROMSend(LINK->NEIGHBOUR, L3MSG);
ReleaseBuffer(L3MSG);
}
else if (TNC && TNC->NetRomMode)
SendVARANetromMsg(TNC, L3MSG);
else
C_Q_ADD(&LINK->TX_Q, L3MSG);
}

View file

@ -86,8 +86,14 @@ void SendBBSDataToPktMap();
void CloseAllLinks();
void hookNodeClosing(char * Reason);
void NETROMTCPResolve();
<<<<<<< Updated upstream
extern uint64_t INP3timeLoadedMS;
||||||| Stash base
extern uint64_t INP3timeLoadedMS;
=======
>>>>>>> Stashed changes
BOOL IncludesMail = FALSE;
BOOL IncludesChat = FALSE;
@ -861,8 +867,6 @@ int main(int argc, char * argv[])
if (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO))
Redirected = 1;
INP3timeLoadedMS = GetTickCount();
#endif
printf("G8BPQ AX25 Packet Switch System Version %s %s\n", TextVerstring, Datestring);

File diff suppressed because it is too large Load diff

View file

@ -10,8 +10,16 @@
#endif
<<<<<<< Updated upstream
#define KVers 6,0,25,11
#define KVerstring "6.0.25.11\0"
||||||| Stash base
#define KVers 6,0,25,8
#define KVerstring "6.0.25.8\0"
=======
#define KVers 6,0,25,12
#define KVerstring "6.0.25.12\0"
>>>>>>> Stashed changes
#ifdef CKernel

View file

@ -25,6 +25,8 @@ Stuff to make compiling on WINDOWS and LINUX easier
#ifdef WIN32
#include <windows.h>
typedef unsigned int uint32_t;
#define pthread_t uint32_t
@ -41,6 +43,7 @@ int pthread_equal(pthread_t T1, pthread_t T2)
#include <syslog.h>
#include <stdarg.h>
#include <unistd.h>
#include <stdint.h>
#define BOOL int
@ -188,3 +191,27 @@ void closesocket(int sock)
}
#endif
#ifdef WIN32
uint32_t GetTickCountINP3()
{
// Returns system uptime in 10 mS, lower 20 bits only
return (GetTickCount() / 10) & 0xfffff;
}
#else
uint64_t GetTickCount();
uint32_t GetTickCountINP3()
{
uint64_t Ticks = GetTickCount();
// Returns system uptime in 10 mS, lower 20 bits only
return (Ticks / 10) & 0xfffff;
}
#endif

View file

@ -24,6 +24,7 @@ Stuff to make compiling on WINDOWS and LINUX easier
#define strtoll _strtoi64
#ifdef _WIN64
#include "stdint.h"
#else
@ -219,7 +220,7 @@ typedef struct tagRECT
#endif
uint32_t GetTickCountINP3();
#ifdef LINBPQ