diff options
| author | Dave Hibberd <hibby@debian.org> | 2025-11-09 22:34:20 +0000 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2025-11-09 22:34:20 +0000 |
| commit | 367ab8fb01191ec54c91810b1896c41fdf7de911 (patch) | |
| tree | 8f9ac2b818ebb923b47fce00b28eb127556d96fb /cMain.c | |
| parent | 7c796758d1b65d4d7585c90ba71b1fb339a4d283 (diff) | |
New upstream version 6.0.25.9+repack
Diffstat (limited to 'cMain.c')
| -rw-r--r-- | cMain.c | 101 |
1 files changed, 93 insertions, 8 deletions
@@ -54,13 +54,26 @@ void MQTTTimer(); void SaveMH();
VOID InformPartner(struct _LINKTABLE * LINK, int Reason);
VOID L2SENDCOMMAND(struct _LINKTABLE * LINK, int CMD);
-
+void WritePacketLogThread(void * param);
+void hookNodeStarted();
+void hookNodeRunning();
+void APIL2Trace(struct _MESSAGE * Message, char * Dirn);
#include "configstructs.h"
extern struct CONFIGTABLE xxcfg;
extern BOOL needAIS;
extern int needADSB;
+extern int EnableOARCAPI;
+extern SOCKET NodeAPISocket;
+extern int nodeStartedSent;
+extern SOCKADDR_IN UDPreportdest;
+extern char NodeAPIServer[80];
+extern int NodeAPIPort;
+
+time_t LastNodeStatus = 0;
+
+int nodeStatusTimer = 20 * 60; // 20 mins
struct PORTCONFIG * PortRec;
@@ -181,6 +194,7 @@ extern VOID * ENDPOOL; extern void * APPL_Q; // Queue of frames for APRS Appl
extern BOOL APRSActive;
+extern int DEBUGINP3;
#define BPQHOSTSTREAMS 64
@@ -194,9 +208,12 @@ BPQVECSTRUC * TELNETMONVECPTR = &BPQHOSTVECTOR[BPQHOSTSTREAMS]; BPQVECSTRUC * AGWMONVECPTR = &BPQHOSTVECTOR[BPQHOSTSTREAMS + 1];
BPQVECSTRUC * APRSMONVECPTR = &BPQHOSTVECTOR[BPQHOSTSTREAMS + 2];
BPQVECSTRUC * IPHOSTVECTORPTR = &BPQHOSTVECTOR[BPQHOSTSTREAMS + 3];
+BPQVECSTRUC * FILEMONVECTOR = &BPQHOSTVECTOR[BPQHOSTSTREAMS + 4];
int BPQVECLENGTH = sizeof(BPQVECSTRUC);
+int MONTOFILEFLAG = 0;
+
int NODEORDER = 0;
UCHAR LINKEDFLAG = 0;
@@ -250,6 +267,8 @@ int CFLAG = 0; // C =HOST Command VOID * IDMSG_Q = NULL; // ID/BEACONS WAITING TO BE SENT
int NODESINPROGRESS = 0;
+int NODESToOnePort = 0; // Set to port num to send NODES to only one port.
+
VOID * CURRENTNODE = NULL; // NEXT _NODE TO SEND
VOID * DESTHEADER = NULL; // HEAD OF SORTED NODES CHAIN
@@ -305,8 +324,8 @@ VOID LINKINIT(PEXTPORTDATA PORTVEC) VOID LINKTX(PEXTPORTDATA PORTVEC, PMESSAGE Buffer)
{
// LOOP BACK TO SWITCH
+
struct _LINKTABLE * LINK;
-
LINK = Buffer->Linkptr;
if (LINK)
@@ -862,6 +881,11 @@ BOOL Start() PREFERINP3ROUTES = cfg->C_PREFERINP3ROUTES;
+ if (cfg->C_DEBUGINP3)
+ DEBUGINP3 = 0;
+
+ EnableOARCAPI = cfg->C_OARCAPI;
+
if (cfg->C_OnlyVer2point0)
SUPPORT2point2 = 0;
@@ -992,6 +1016,7 @@ BOOL Start() PORT->IgnoreUnlocked = PortRec->IGNOREUNLOCKED;
PORT->INP3ONLY = PortRec->INP3ONLY;
PORT->ALLOWINP3 = PortRec->AllowINP3;
+ PORT->ENABLEINP3 = PortRec->EnableINP3;
PORT->PORTWINDOW = (UCHAR)PortRec->MAXFRAME;
@@ -1366,13 +1391,13 @@ BOOL Start() PORT = GetPortTableEntryFromPortNum(ROUTE->NEIGHBOUR_PORT);
- if (Rcfg->pwind & 0x40)
+ if (Rcfg->nokeepalives)
ROUTE->NoKeepAlive = 1;
else
if (PORT != NULL)
ROUTE->NoKeepAlive = PORT->PortNoKeepAlive;
- if (Rcfg->pwind & 0x80 || (PORT && PORT->INP3ONLY))
+ if (Rcfg->inp3 || (PORT && PORT->INP3ONLY))
{
ROUTE->INP3Node = 1;
ROUTE->NoKeepAlive = 0; // Cant have INP3 and NOKEEPALIVES
@@ -1386,11 +1411,20 @@ BOOL Start() ROUTE->OtherendsRouteQual = ROUTE->OtherendLocked = Rcfg->farQual;
ROUTE->NEIGHBOUR_FLAG = LOCKEDBYCONFIG; // Locked
+
+ if (Rcfg->tcphost)
+ {
+ ROUTE->TCPHost = Rcfg->tcphost;
+ ROUTE->TCPPort = Rcfg->tcpport;
+
+ ROUTE->TCPAddress = (struct addrinfo *)zalloc(sizeof(struct addrinfo));
+ ROUTE->TCPAddress->ai_addr = (struct sockaddr *) zalloc(sizeof(struct sockaddr));
+ }
Rcfg++;
ROUTE++;
}
-
+
// SET UP INFO MESSAGE
ptr2 = &cfg->C_INFOMSG[0];
@@ -1564,8 +1598,34 @@ BOOL Start() upnpInit();
+ // Start Monitor to file thread
+
+ _beginthread(WritePacketLogThread, 0, NULL);
+
lastSaveSecs = CurrentSecs = lastSlowSecs = time(NULL);
+ // if EnableOARCAPI set try to resolve host here so we can send Node up event before anything else
+
+ if (EnableOARCAPI)
+ {
+ struct hostent * HostEnt3;
+ HostEnt3 = gethostbyname(NodeAPIServer);
+
+ NodeAPISocket = socket(AF_INET, SOCK_DGRAM, 0);
+ UDPreportdest.sin_family = AF_INET;
+ UDPreportdest.sin_port = htons(NodeAPIPort);
+
+ if (HostEnt3)
+ {
+ memcpy(&UDPreportdest.sin_addr.s_addr,HostEnt3->h_addr,4);
+
+ hookNodeStarted();
+ nodeStartedSent = 1;
+ LastNodeStatus = time(NULL);
+ }
+ }
+
+
return 0;
}
@@ -1971,7 +2031,7 @@ VOID ReadNodes() ptr = strtok_s(NULL, seps, &Context); // INP3
if (ptr == NULL) continue;
- if (ROUTE->NEIGHBOUR_FLAG == 0 || ROUTE->OtherendLocked == 0); // Not LOCKED ROUTE
+ if (ROUTE->NEIGHBOUR_FLAG == 0 || ROUTE->OtherendLocked == 0) // Not LOCKED ROUTE
ROUTE->OtherendsRouteQual = atoi(ptr);
ptr = strtok_s(NULL, seps, &Context); // INP3
@@ -2159,6 +2219,12 @@ VOID TIMERINTERRUPT() if (MQTT)
MQTTTimer();
+ if (LastNodeStatus && (time(NULL) - LastNodeStatus) > nodeStatusTimer)
+ {
+ LastNodeStatus = time(NULL);
+ hookNodeRunning();
+ }
+
/*
if (QCOUNT < 200)
{
@@ -2214,6 +2280,10 @@ VOID TIMERINTERRUPT() }
Message = (struct _MESSAGE *)Buffer;
+
+ if(NodeAPISocket)
+ APIL2Trace(Message, "sent");
+
Message->PORT |= 0x80; // Set TX Bit
BPQTRACE(Message, FALSE); // Dont send TX'ed frames to APRS
@@ -2325,6 +2395,9 @@ L2Packet: if (MQTT && PORT->PROTOCOL == 0)
MQTTKISSRX(Buffer);
+
+ if(NodeAPISocket &&PORT->PROTOCOL == 0)
+ APIL2Trace(Message, "rcvd");
// Bridge if requested
@@ -2514,9 +2587,9 @@ ENDOFLIST: {
// Stuck link debug check
- if (LINK->LASTFRAMESENT && (time(NULL) - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
+ if (LINK->LINKWINDOW == 0 || LINK->LASTFRAMESENT == 0 || (time(NULL) - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
{
- if (COUNT_AT_L2(LINK) > 16)
+ if (COUNT_AT_L2(LINK) > 16 || LINK->LINKWINDOW == 0)
{
// Dump Link State
@@ -2675,6 +2748,18 @@ int BPQTRACE(MESSAGE * Msg, BOOL TOAPRS) L4++;
}
+ // And to the Monitor to File system.
+
+ if (MONTOFILEFLAG) // Trace Enabled?
+ {
+ Buffer = GetBuff();
+ if (Buffer)
+ {
+ memcpy(&Buffer->PORT, &Msg->PORT, BUFFLEN - sizeof(void *)); // Dont copy chain word
+ C_Q_ADD(&FILEMONVECTOR->HOSTTRACEQ, Buffer);
+ }
+ }
+
return TRUE;
}
;
|
