summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-09-29 21:39:24 +0100
committerDave Hibberd <hibby@debian.org>2026-09-29 21:39:24 +0100
commit592e5967b8fcd79423802071319d0c646f2080df (patch)
tree0eef3a28cfe1a939caf9d61e419a56d79b3c38e3
parent23de03a0c8bf8a564cc0442f49d050ed11e372b8 (diff)
New upstream version 6.0.25.41+repackupstream/6.0.25.41+repack
-rw-r--r--6pack.c154
-rw-r--r--AEAPactor.c2
-rw-r--r--AFXRES.H2
-rw-r--r--AGWAPI.c25
-rw-r--r--AISCommon.c13
-rw-r--r--APRSCode.c84
-rw-r--r--ARDOP.c356
-rw-r--r--BBSUtilities.c80
-rw-r--r--BPQChat.rc4
-rw-r--r--BPQINP3.c922
-rw-r--r--BPQMail.apsbin69752 -> 0 bytes
-rw-r--r--BPQMail.c6
-rw-r--r--BPQMail.rc2
-rw-r--r--BPQNRR.c14
-rw-r--r--BPQTermMDI.c16
-rw-r--r--BPQTermTCP.h90
-rw-r--r--BPQTermTCP.ini20
-rw-r--r--BPQTermTCP.rc336
-rw-r--r--BPQTerminal.c2413
-rw-r--r--BPQTerminal.h77
-rw-r--r--BPQTerminal.rc164
-rw-r--r--BPQWinAPP.c178
-rw-r--r--BPQWinAPP.rc8
-rw-r--r--BUILDING.md86
-rw-r--r--Bpq32.c376
-rw-r--r--CBPQ32.sln79
-rw-r--r--CBPQ322026.sln84
-rw-r--r--CMakeLists.txt24
-rw-r--r--Cmd.c146
-rw-r--r--CommonCode.c272
-rw-r--r--DragSize.curbin0 -> 326 bytes
-rw-r--r--Events.c61
-rw-r--r--FLDigi.c256
-rw-r--r--FreeDATA.c110
-rw-r--r--HALDriver.c79
-rw-r--r--HFCommon.c16
-rw-r--r--HSMODEM.c181
-rw-r--r--HTTPcode.c1231
-rw-r--r--HanksRT.c58
-rw-r--r--Housekeeping.c1
-rw-r--r--IPCode.c6
-rw-r--r--KAMPactor.c14
-rw-r--r--KISSHF.c150
-rw-r--r--KernelScript1.rc4
-rw-r--r--L2Code.c36
-rw-r--r--L3Code.c25
-rw-r--r--L4Code.c440
-rw-r--r--LinBPQ.c714
-rw-r--r--MULTIPSK.c94
-rw-r--r--MailTCP.c81
-rw-r--r--Moncode.c6
-rw-r--r--NETROMTCP.c16
-rw-r--r--NNTPRoutines.c1
-rw-r--r--NodeMapTest.c10
-rw-r--r--PG/keps.c493
-rw-r--r--PG/keps.txt2284
-rw-r--r--RHP.c2
-rw-r--r--RTKnown.txt (renamed from MHSave.txt)0
-rw-r--r--RigControl.c105
-rw-r--r--SCSPactor.c33
-rw-r--r--SCSTrackeMulti.c35
-rw-r--r--SCSTracker.c42
-rw-r--r--SerialPort.c21
-rw-r--r--StdVer.inc2
-rw-r--r--TNCEmulators.c46
-rw-r--r--TelnetV6.c156
-rw-r--r--UIARQ.c30
-rw-r--r--UZ7HODrv.c87
-rw-r--r--V4.c177
-rw-r--r--VARA.c215
-rw-r--r--Versions.h7
-rw-r--r--WINMOR.c195
-rw-r--r--WebMail.c14
-rw-r--r--Win32bits/AFXRES.H750
-rw-r--r--Win32bits/StdExcept.c75
-rw-r--r--Win32bits/Strucs.inc572
-rw-r--r--Win32bits/bpq32.expbin0 -> 18680 bytes
-rw-r--r--Win32bits/libconfig.h321
-rw-r--r--Win32bits/pcap-bpf.h697
-rw-r--r--Win32bits/pcap-stdinc.h64
-rw-r--r--Win32bits/winres.h597
-rw-r--r--WinRPR.c52
-rw-r--r--WinmorControl.c14
-rw-r--r--WinmorControl.rc2
-rw-r--r--adif.c4
-rw-r--r--asmstrucs.h56
-rw-r--r--bpq32.h13
-rw-r--r--bpqaxip.c38
-rw-r--r--bpqchat.c6
-rw-r--r--bpqether.c25
-rw-r--r--bpqhdlc.c27
-rw-r--r--bpqmail.h1
-rw-r--r--bpqtermTCP.c4170
-rw-r--r--cMain.c172
-rw-r--r--chatconfig.cfg2
-rw-r--r--cheaders.h16
-rw-r--r--compatbits.c5
-rw-r--r--compatbits.h3
-rw-r--r--config.c23
-rw-r--r--configstructs.h3
-rw-r--r--datadefs.c13
-rw-r--r--httpconnectioninfo.h7
-rw-r--r--kiss.c20
-rw-r--r--mailapi.c4
-rw-r--r--makefile2
-rw-r--r--mqtt.c4
-rw-r--r--nodeapi.c6
-rw-r--r--nodelog.txt0
-rw-r--r--telnetserver.h2
-rw-r--r--tncinfo.h21
-rw-r--r--utf8Routines.c6
111 files changed, 18764 insertions, 2596 deletions
diff --git a/6pack.c b/6pack.c
index 5557827..547f58b 100644
--- a/6pack.c
+++ b/6pack.c
@@ -274,7 +274,7 @@ VOID SixPackProcessReceivedPacket(struct TNCINFO * TNC)
TNC->Streams[0].ReportDISC = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return;
}
@@ -907,105 +907,107 @@ ok:
switch (fn)
{
- case 7:
+ case 1:
- // 100 mS Timer. May now be needed, as Poll can be called more frequently in some circumstances
+ // 10 mS CheckRX and fast poll
- SerialCheckRX(TNC);
- return 0;
+ // See if any frames for this port
- case 1: // poll
+ STREAM = &TNC->Streams[0];
- STREAM = &TNC->Streams[0];
+ if (STREAM->BPQtoPACTOR_Q)
+ {
+ PMSGWITHLEN buffptr = (PMSGWITHLEN)Q_REM(&STREAM->BPQtoPACTOR_Q);
+ UCHAR * data = &buffptr->Data[0];
+ STREAM->FramesQueued--;
+ txlen = (int)buffptr->Len;
+ STREAM->bytesTXed += txlen;
+
+ bytes=SerialSendData(TNC, data, txlen);
+ WritetoTrace(TNC, data, txlen);
+ }
- if (STREAM->NeedDisc)
- {
- STREAM->NeedDisc--;
+ if (STREAM->PACTORtoBPQ_Q != 0)
+ {
+ buffptr = (PMSGWITHLEN)Q_REM(&STREAM->PACTORtoBPQ_Q);
- if (STREAM->NeedDisc == 0)
- {
- // Send the DISCONNECT
+ datalen = (int)buffptr->Len;
- SerialSendCommand(TNC, "DISCONNECT\r");
- }
- }
+ buff->PORT = Stream; // Compatibility with Kam Driver
+ buff->PID = 0xf0;
+ memcpy(&buff->L2DATA, &buffptr->Data[0], datalen); // Data goes to + 7, but we have an extra byte
+ datalen += sizeof(void *) + 4;
- if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
- {
- // New Attach
+ PutLengthinBuffer(buff, datalen);
+
+ ReleaseBuffer(buffptr);
+
+ return (1);
+ }
- int calllen;
- char Msg[80];
+ if (STREAM->ReportDISC) // May need a delay so treat as a counter
+ {
+ STREAM->ReportDISC--;
- STREAM->Attached = TRUE;
+ if (STREAM->ReportDISC == 0)
+ {
+ buff->PORT = Stream;
+ return -1;
+ }
+ }
- calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
- TNC->Streams[Stream].MyCall[calllen] = 0;
+ return (0);
- // Stop other ports in same group
+ case 7: // poll
- SuspendOtherPorts(TNC);
+ SerialCheckRX(TNC);
- sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ STREAM = &TNC->Streams[0];
- // Stop Scanning
+ if (STREAM->NeedDisc)
+ {
+ STREAM->NeedDisc--;
- sprintf(Msg, "%d SCANSTOP", TNC->Port);
+ if (STREAM->NeedDisc == 0)
+ {
+ // Send the DISCONNECT
- Rig_Command( (TRANSPORTENTRY *) -1, Msg);
+ SerialSendCommand(TNC, "DISCONNECT\r");
}
+ }
- if (STREAM->Attached)
- CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
+ {
+ // New Attach
- // See if any frames for this port
+ int calllen;
+ char Msg[80];
- STREAM = &TNC->Streams[0];
+ STREAM->Attached = TRUE;
- if (STREAM->BPQtoPACTOR_Q)
- {
- PMSGWITHLEN buffptr = (PMSGWITHLEN)Q_REM(&STREAM->BPQtoPACTOR_Q);
- UCHAR * data = &buffptr->Data[0];
- STREAM->FramesQueued--;
- txlen = (int)buffptr->Len;
- STREAM->bytesTXed += txlen;
-
- bytes=SerialSendData(TNC, data, txlen);
- WritetoTrace(TNC, data, txlen);
- }
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
+ TNC->Streams[Stream].MyCall[calllen] = 0;
- if (STREAM->PACTORtoBPQ_Q != 0)
- {
- buffptr = (PMSGWITHLEN)Q_REM(&STREAM->PACTORtoBPQ_Q);
- datalen = (int)buffptr->Len;
+ // Stop other ports in same group
- buff->PORT = Stream; // Compatibility with Kam Driver
- buff->PID = 0xf0;
- memcpy(&buff->L2DATA, &buffptr->Data[0], datalen); // Data goes to + 7, but we have an extra byte
- datalen += sizeof(void *) + 4;
+ SuspendOtherPorts(TNC);
- PutLengthinBuffer(buff, datalen);
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
- ReleaseBuffer(buffptr);
+ // Stop Scanning
- return (1);
- }
+ sprintf(Msg, "%d SCANSTOP", TNC->Port);
- if (STREAM->ReportDISC) // May need a delay so treat as a counter
- {
- STREAM->ReportDISC--;
+ Rig_Command( (TRANSPORTENTRY *) -1, Msg);
+ }
- if (STREAM->ReportDISC == 0)
- {
- buff->PORT = Stream;
- return -1;
- }
- }
+ if (STREAM->Attached)
+ CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
- return (0);
+ return 0;
case 2: // send
@@ -1328,7 +1330,7 @@ VOID SIXPACKReleaseTNC(struct TNCINFO * TNC)
Rig_Command( (TRANSPORTENTRY *) -1, TXMsg);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
ReleaseOtherPorts(TNC);
}
@@ -1343,7 +1345,7 @@ VOID SIXPACKReleasePort(struct TNCINFO * TNC)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<script type=\"text/javascript\">\r\n"
"function ScrollOutput()\r\n"
"{var textarea = document.getElementById('textarea');"
@@ -1659,7 +1661,7 @@ VOID SIXPACKProcessReceivedPacket(struct TNCINFO * TNC)
TNC->Streams[0].ReportDISC = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return;
}
@@ -1802,7 +1804,7 @@ void AttachSIXPACK(struct PORTCONTROL * PORT, MESSAGE * Buffer)
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
@@ -1877,7 +1879,7 @@ void SIXPACKConnected(struct PORTCONTROL * PORT, struct _LINKTABLE * LINK)
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
@@ -2019,7 +2021,7 @@ VOID x6PackThead(void * portptr)
i=sprintf(Msg, "Connect Failed for 6Pack socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -2042,7 +2044,7 @@ VOID x6PackThead(void * portptr)
TNC->Alerted = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
@@ -2085,7 +2087,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
diff --git a/AEAPactor.c b/AEAPactor.c
index bb7a8d4..5c70ddc 100644
--- a/AEAPactor.c
+++ b/AEAPactor.c
@@ -1417,7 +1417,7 @@ static VOID ProcessAEAPacket(struct TNCINFO * TNC, UCHAR * Msg, size_t Len)
}
TNC->Streams[Stream].bytesRXed = TNC->Streams[Stream].bytesTXed = TNC->Streams[Stream].BytesAcked = 0;
- TNC->Streams[Stream].ConnectTime = time(NULL);
+ TNC->Streams[Stream].ConnectTime = NOW;
if (Stream == 0)
{
diff --git a/AFXRES.H b/AFXRES.H
index 7c8fe5f..4635434 100644
--- a/AFXRES.H
+++ b/AFXRES.H
@@ -18,7 +18,7 @@
#ifdef RC_INVOKED
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
- #include "..\include\winres.h" // extract from windows header
+ #include "WIn32bits\winres.h" // extract from windows header
#endif
#endif
diff --git a/AGWAPI.c b/AGWAPI.c
index 5dc2f9c..590d62d 100644
--- a/AGWAPI.c
+++ b/AGWAPI.c
@@ -550,16 +550,20 @@ int AGWConnected(struct BPQConnectionInfo * Con, int Stream)
if (ApplCall[i]==32)
ApplCall[i]=0;
-// See if incomming connection
+// See if incoming connection
if (Con->Listening)
{
// Allocate Session and send "c" Message
//
// Find an AGW session
+
+ Debugprintf("Incoming AGW Call for ApplCall %s", ApplCall);
for (sockptr=&Sockets[1]; sockptr <= &Sockets[CurrentSockets]; sockptr++)
{
+ Debugprintf("Trying Socket %d, Calls %s %s", i, sockptr->CallSign1, sockptr->CallSign2);
+
if (sockptr->SocketActive &&
(memcmp(sockptr->CallSign1, ApplCall, 10) == 0) || (memcmp(sockptr->CallSign2, ApplCall, 10) == 0))
{
@@ -572,6 +576,7 @@ int AGWConnected(struct BPQConnectionInfo * Con, int Stream)
int maxframe;
int l4window;
+ Debugprintf("Connection Found, Checking for duplicate calls");
keyptr=(byte *)&Con->CallKey;
@@ -594,13 +599,13 @@ int AGWConnected(struct BPQConnectionInfo * Con, int Stream)
for (i = 0; i < CurrentConnections; i++)
{
- if (Con->BPQStream == Stream)
+ if (AGWConnections[i].BPQStream == Stream)
continue; // Dont Check ourself!
if (AGWConnections[i].SocketIndex == sockptr &&
memcmp(&Con->CallKey, &AGWConnections[i].CallKey,21) == 0)
{
- SendMsg(Stream, "AGWtoBPQ - Callsign is already connected\r", 43);
+ SendMsg(Stream, "AGWAPI - Callsign is already connected\r", 43);
Sleep (500);
Disconnect(Stream);
Con->CallKey[0]=0;
@@ -628,7 +633,7 @@ int AGWConnected(struct BPQConnectionInfo * Con, int Stream)
// Not listening ??
- OutputDebugString("Inbound Connection on Outgoing Stream");
+ Debugprintf("Inbound Connection on Outgoing Stream");
SendMsg(Stream, "AGWtoBPQ - Inbound Connection on Outgoing Stream\r", 49);
Sleep (500);
@@ -1393,12 +1398,12 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
if (sockptr->AGWRXHeader.DataKind == 'V') // Unproto with VIA string
{
Digis = sockptr->MsgData[0]; // Number of digis
-
- if (Digis > 7)
- {
- AGWDataSocket_Disconnect(sockptr);
- return 0;
- }
+
+ if (Digis > 7)
+ {
+ AGWDataSocket_Disconnect(sockptr);
+ return 0;
+ }
for (j = 1; j<= Digis; j++)
{
diff --git a/AISCommon.c b/AISCommon.c
index 2d7bc33..22839d3 100644
--- a/AISCommon.c
+++ b/AISCommon.c
@@ -253,8 +253,6 @@ HANDLE TrackHandle;
HANDLE hTrack;
UINT LastTrackFileTime;
-UINT NOW;
-
char Stack[500];
BOOL Stacked=FALSE;
@@ -899,8 +897,6 @@ int ProcessAISMessage(char * msg, int len)
char Data[256];
float alt=0.0;
- NOW = time(NULL);
-
ptr1 = &msg[7];
//' Looks like first is no of fragments in message, 2nd fragment seq no, 3rd msg seq, 4th port
@@ -1316,9 +1312,7 @@ int DecodeVDM(char *msg)
V_WidthC = val[44];
V_WidthD = val[45];
- // sprintf(TraceMsg,"%s %d %d %d %d %d LenA %d LenB %d\n", V_Name, val[41], val[42], val[43], val[44], val[45], V_LenA, V_LenB);
- // OutputDebugString(TraceMsg);
-
+
//' Type of Fix 4 274 char 46 bits 0-3
FixType = val[46] >>2;
@@ -2472,8 +2466,6 @@ void AISTimer()
{
// Entered every minute
- NOW = time(NULL);
-
CheckAgeofTargets(MaxAge);
if (VessselDBChanged)
@@ -2493,7 +2485,6 @@ void ADSBTimer()
{
// Entered every minute
- NOW = time(NULL);
CheckAgeofPlanes(300);
ProcessADSBJSON(ADSBFN);
@@ -2567,8 +2558,6 @@ int GetAISPageInfo(char * Buffer, int ais, int adsb)
char * p;
char DestBuffer[128] = "";
- NOW = time(NULL);
-
if (adsb)
ProcessADSBJSON(ADSBFN);
diff --git a/APRSCode.c b/APRSCode.c
index e8f6257..cffaa6a 100644
--- a/APRSCode.c
+++ b/APRSCode.c
@@ -103,6 +103,7 @@ void GetSavedAPRSMessages();
static VOID GPSDConnect(void * unused);
int CanPortDigi(int Port);
int FromLOC(char * Locator, double * pLat, double * pLon);
+BOOL CheckExcludeList(UCHAR * Call);
extern int SemHeldByAPI;
extern int APRSMONDECODE();
@@ -456,7 +457,7 @@ int APRSWriteLog(char * msg)
if (strchr(msg, '\n') == 0)
strcat(msg, "\r\n");
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
if (GetLogDirectory()[0] == 0)
@@ -968,11 +969,9 @@ time_t lastSecTimer = 0;
Dll VOID APIENTRY Poll_APRS()
{
- time_t Now = time(NULL);
-
- if (lastSecTimer != Now)
+ if (lastSecTimer != NOW)
{
- lastSecTimer = Now;
+ lastSecTimer = NOW;
DoSecTimer();
@@ -1108,6 +1107,14 @@ Dll VOID APIENTRY Poll_APRS()
monchars = (UCHAR *)monbuff;
AdjBuff = Orig = (MESSAGE *)monchars; // Adjusted for digis
+ // Check Exclude List
+
+ if (CheckExcludeList(Orig->ORIGIN) == 0)
+ {
+ ReleaseBuffer(monbuff);
+ continue;
+ }
+
Port = Orig->PORT;
if (Port & 0x80) // TX
@@ -1210,7 +1217,7 @@ Dll VOID APIENTRY Poll_APRS()
{
// Using Smart ID, but none scheduled
- PORT->SmartIDNeeded = time(NULL) + PORT->SmartIDInterval;
+ PORT->SmartIDNeeded = NOW + PORT->SmartIDInterval;
}
PUT_ON_PORT_Q(PORT, Buffer);
}
@@ -1384,7 +1391,7 @@ Dll VOID APIENTRY Poll_APRS()
ISDELAY * SatISEntry = malloc(sizeof(ISDELAY));
SatISEntry->Next = NULL;
SatISEntry->ISMSG = _strdup(ISMsg);
- SatISEntry->SendTIme = time(NULL) + 10; // Delay 10 seconds
+ SatISEntry->SendTIme = NOW + 10; // Delay 10 seconds
if (SatISQueue)
SatISEntry->Next = SatISQueue; // Chain
@@ -2644,7 +2651,7 @@ void SendBeaconThread(void * Param)
// Station->LastPort = Port;
DecodeAPRSPayload(Msg.L2DATA, Station);
- Station->TimeLastUpdated = time(NULL);
+ Station->TimeLastUpdated = NOW;
if (toPort)
{
@@ -2818,7 +2825,6 @@ VOID DoSecTimer()
if (SatISQueue)
{
- time_t NOW = time(NULL);
ISDELAY * SatISEntry = SatISQueue;
ISDELAY * Prev = NULL;
@@ -3097,7 +3103,7 @@ VOID APRSISThread(void * Report)
//
#ifndef LINBPQ
- MySetWindowText(GetDlgItem(hConsWnd, IGATESTATE), "IGate State: Connect Failed");
+ MySetWindowText(0, GetDlgItem(hConsWnd, IGATESTATE), "IGate State: Connect Failed");
#else
printf("APRS Igate connect failed\n");
#endif
@@ -3114,7 +3120,7 @@ VOID APRSISThread(void * Report)
APRSISOpen = TRUE;
#ifndef LINBPQ
- MySetWindowText(GetDlgItem(hConsWnd, IGATESTATE), "IGate State: Connected");
+ MySetWindowText(0, GetDlgItem(hConsWnd, IGATESTATE), "IGate State: Connected");
#endif
InputLen=recv(sock, Buffer, 500, 0);
@@ -3227,7 +3233,6 @@ VOID ProcessAPRSISMsg(char * APRSMsg)
char * ptr;
char Message[255];
PAPRSHEARDRECORD MH;
- time_t NOW = time(NULL);
char ISCopy[1024];
struct STATIONRECORD * Station = NULL;
#ifdef WIN32
@@ -3304,6 +3309,19 @@ VOID ProcessAPRSISMsg(char * APRSMsg)
return;
*(Dest++) = 0; // Termainate Source
+
+ if (ExcludeList[0])
+ {
+ // Check if excluded. Need to convert to ax.25
+
+ UCHAR AXCall[7];
+
+ ConvToAX25(Source, AXCall);
+
+ if (CheckExcludeList == 0)
+ return;
+ }
+
ptr = strchr(Dest, ',');
if (ptr)
@@ -3443,7 +3461,6 @@ APRSHEARDRECORD * UpdateHeard(UCHAR * Call, int Port)
APRSHEARDRECORD * MH = MHDATA;
APRSHEARDRECORD * MHBASE = MH;
int i;
- time_t NOW = time(NULL);
time_t OLDEST = NOW - MAXAGE;
char CallPadded[10] = " ";
BOOL SaveIGate = FALSE;
@@ -3534,8 +3551,7 @@ BOOL CheckforDups(char * Call, char * Msg, int Len)
{
// Primitive duplicate suppression - see if same call and text reeived in last few seconds
- time_t Now = time(NULL);
- time_t DupCheck = Now - DUPSECONDS;
+ time_t DupCheck = NOW - DUPSECONDS;
int i, saveindex = -1;
char * ptr1;
@@ -3578,7 +3594,7 @@ BOOL CheckforDups(char * Call, char * Msg, int Len)
if (saveindex == -1) // List is full
saveindex = MAXDUPS - 1; // Stick on end
- DupInfo[saveindex].DupTime = Now;
+ DupInfo[saveindex].DupTime = NOW;
memcpy(DupInfo[saveindex].DupUser, Call, 7);
if (Len > 99) Len = 99;
@@ -3597,7 +3613,7 @@ char * FormatAPRSMH(APRSHEARDRECORD * MH)
static char MHLine[50];
time_t szClock = MH->MHTIME;
- szClock = (time(NULL) - szClock);
+ szClock = (NOW - szClock);
TM = gmtime(&szClock);
sprintf(MHLine, "%-10s %d %.2d:%.2d:%.2d:%.2d %s\r",
@@ -3903,8 +3919,6 @@ void DecodeRMC(char * msg, size_t len)
{
if (MobileBeaconInterval)
{
- time_t NOW = time(NULL);
-
if ((NOW - LastMobileBeacon) > MobileBeaconInterval)
{
LastMobileBeacon = NOW;
@@ -4726,7 +4740,7 @@ struct STATIONRECORD * FindStation(char * Call, BOOL AddIfNotFount)
// Debugprintf("APRS Add Stn %s Station Count = %d", Call, StationCount);
strcpy(ptr->Callsign, Call);
- ptr->TimeLastUpdated = ptr->TimeAdded = time(NULL);
+ ptr->TimeLastUpdated = ptr->TimeAdded = NOW;
ptr->Index = i;
ptr->NoTracks = DefaultNoTracks;
@@ -4820,7 +4834,7 @@ struct STATIONRECORD * ProcessRFFrame(char * Msg, int len, int * ourMessage)
Station->LastPort = Port;
*ourMessage = DecodeAPRSPayload(Payload, Station);
- Station->TimeLastUpdated = time(NULL);
+ Station->TimeLastUpdated = NOW;
return Station;
}
@@ -4882,7 +4896,7 @@ struct STATIONRECORD * DecodeAPRSISMsg(char * Msg)
Station->LastPort = 0;
DecodeAPRSPayload(Payload, Station);
- Station->TimeLastUpdated = time(NULL);
+ Station->TimeLastUpdated = NOW;
return Station;
}
@@ -5009,7 +5023,6 @@ BOOL DecodeLocationString(UCHAR * Payload, struct STATIONRECORD * Station)
if (Station->Lat != NewLat || Station->Lon != NewLon)
{
- time_t NOW = time(NULL);
time_t Age = NOW - Station->TimeLastTracked;
if (Age > 15) // Don't update too often
@@ -5116,7 +5129,7 @@ int DecodeAPRSPayload(char * Payload, struct STATIONRECORD * Station)
if (ObjState != '_') // Deleted Objects may have odd positions
DecodeLocationString(ptr, Object);
- Object->TimeLastUpdated = time(NULL);
+ Object->TimeLastUpdated = NOW;
Station->Object = Object;
return 0;
@@ -5150,7 +5163,7 @@ int DecodeAPRSPayload(char * Payload, struct STATIONRECORD * Station)
if (ObjState != '_') // Deleted Objects may have odd positions
DecodeLocationString(Payload + 18, Object);
- Object->TimeLastUpdated = time(NULL);
+ Object->TimeLastUpdated = NOW;
Object->LastPort = Station->LastPort;
Station->Object = Object;
return 0;
@@ -5219,7 +5232,7 @@ int DecodeAPRSPayload(char * Payload, struct STATIONRECORD * Station)
TPStation->LastPort = 0; // Heard on RF, but info is from IS
DecodeAPRSPayload(Payload, TPStation);
- TPStation->TimeLastUpdated = time(NULL);
+ TPStation->TimeLastUpdated = NOW;
return 0;
@@ -5418,7 +5431,6 @@ VOID Decode_MIC_E_Packet(char * Payload, struct STATIONRECORD * Station)
if (Station->Lat != NewLat || Station->Lon != NewLon)
{
- time_t NOW = time(NULL);
time_t Age = NOW - Station->TimeLastUpdated;
if (Age > 15) // Don't update too often
@@ -5911,8 +5923,6 @@ VOID ProcessMessage(char * Payload, struct STATIONRECORD * Station)
strcpy(Message->Text, TextPtr);
- NOW = time(NULL);
-
if (DefaultLocalTime)
TM = localtime(&NOW);
else
@@ -6191,7 +6201,6 @@ VOID SendWeatherBeacon()
char * WXptr;
char * WXend;
time_t WXTime;
- time_t now = time(NULL);
FILE * hFile;
struct tm * TM;
struct stat STAT;
@@ -6211,7 +6220,7 @@ VOID SendWeatherBeacon()
return;
}
- WXTime = (now - STAT.st_mtime) /60; // Minutes
+ WXTime = (NOW - STAT.st_mtime) /60; // Minutes
if (WXTime > (3 * WXInterval))
{
@@ -6789,7 +6798,7 @@ char * APRSLookupKey(struct APRSConnectionInfo * sockptr, char * Key, BOOL KM)
{
char Time[80];
struct tm * TM;
- time_t Age = time(NULL) - stn->TimeLastUpdated;
+ time_t Age = NOW - stn->TimeLastUpdated;
TM = gmtime(&Age);
@@ -7716,7 +7725,6 @@ int ProcessMessage(char * Payload, struct STATIONRECORD * Station)
int n = 0;
char FromCall[10] = " ";
struct tm * TM;
- time_t NOW;
char noSeq[] = "";
int ourMessage = 0;
@@ -7846,8 +7854,6 @@ int ProcessMessage(char * Payload, struct STATIONRECORD * Station)
strcpy(Message->Text, TextPtr);
- NOW = time(NULL);
-
if (DefaultLocalTime)
TM = localtime(&NOW);
else
@@ -7911,7 +7917,6 @@ BOOL InternalSendAPRSMessage(char * Text, char * Call)
size_t len = strlen(Call);
APRSHEARDRECORD * STN;
struct tm * TM;
- time_t NOW;
struct APRSMESSAGE * Message;
struct APRSMESSAGE * ptr = SMEM->OutstandingMsgs;
@@ -7951,8 +7956,6 @@ BOOL InternalSendAPRSMessage(char * Text, char * Call)
Message->Retries = RetryCount;
Message->RetryTimer = RetryTimer;
- NOW = time(NULL);
-
if (DefaultLocalTime)
TM = localtime(&NOW);
else
@@ -7986,7 +7989,7 @@ BOOL InternalSendAPRSMessage(char * Text, char * Call)
STN = FindStationInMH(Message->ToCall);
- if (STN && STN->MHTIME > (time(NULL) - 900)) // Heard in last 15 mins
+ if (STN && STN->MHTIME > (NOW - 900)) // Heard in last 15 mins
SendAPRSMessage(Msg, STN->rfPort);
else
{
@@ -8624,7 +8627,6 @@ int GetAPRSPageInfo(char * Buffer, double N, double S, double W, double E, int a
struct STATIONRECORD * ptr = *StationRecords;
int n = 0, Len = 0;
struct tm * TM;
- time_t NOW = time(NULL);
char popup[65536] = "";
char Msg[2048];
int LocalTime = 0;
@@ -9009,7 +9011,7 @@ void SaveAPRSMessage(struct APRSMESSAGE * ptr)
if ((file = fopen(FN, "a")) == NULL)
return ;
- fprintf(file, "%d %s,%s,%s,%s,%s\n", time(NULL), ptr->FromCall, ptr->ToCall, ptr->Seq, ptr->Time, ptr->Text);
+ fprintf(file, "%d %s,%s,%s,%s,%s\n", NOW, ptr->FromCall, ptr->ToCall, ptr->Seq, ptr->Time, ptr->Text);
fclose(file);
}
diff --git a/ARDOP.c b/ARDOP.c
index ef92fad..c32ecc2 100644
--- a/ARDOP.c
+++ b/ARDOP.c
@@ -104,6 +104,7 @@ int ARDOPProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen);
int ConnecttoARDOP(struct TNCINFO * TNC);
int standardParams(struct TNCINFO * TNC, char * buf);
+
#ifndef LINBPQ
BOOL CALLBACK EnumARDOPWindowsProc(HWND hwnd, LPARAM lParam);
#endif
@@ -170,10 +171,10 @@ BOOL ARDOPStopPort(struct PORTCONTROL * PORT)
}
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Stopped");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
return TRUE;
}
@@ -187,11 +188,11 @@ BOOL ARDOPStartPort(struct PORTCONTROL * PORT)
if (TNC->ARDOPCommsMode == 'T')
{
ConnecttoARDOP(TNC);
- TNC->lasttime = time(NULL);;
+ TNC->lasttime = NOW;;
}
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Restarted");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -304,7 +305,7 @@ BOOL ARDOPOpenLogFiles(struct TNCINFO * TNC)
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
strlop(TNC->LogPath, 13);
@@ -659,7 +660,7 @@ VOID ARDOPSendCommand(struct TNCINFO * TNC, char * Buff, BOOL Queue)
if (memcmp(Buff, "LISTEN ", 7) == 0)
{
strcpy(TNC->WEB_MODE, &Buff[7]);
- MySetWindowText(TNC->xIDC_MODE, &Buff[7]);
+ MySetWindowText(TNC, TNC->xIDC_MODE, &Buff[7]);
}
EncLen = sprintf(Encoded, "%s\r", Buff);
@@ -892,7 +893,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if ((STREAM->Connecting || STREAM->Connected) && !STREAM->Disconnecting)
{
- if (TNC->SessionTimeLimit && STREAM->ConnectTime && time(NULL) > (TNC->SessionTimeLimit + STREAM->ConnectTime))
+ if (TNC->SessionTimeLimit && STREAM->ConnectTime && NOW > (TNC->SessionTimeLimit + STREAM->ConnectTime))
{
Debugprintf("ARDOP closing session on SessionTimelimit");
ARDOPSendCommand(TNC, "DISCONNECT", TRUE);
@@ -905,7 +906,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (STREAM->Attached)
{
- if (STREAM->AttachTime && TNC->AttachTimeLimit && time(NULL) > (TNC->AttachTimeLimit + STREAM->AttachTime))
+ if (STREAM->AttachTime && TNC->AttachTimeLimit && NOW > (TNC->AttachTimeLimit + STREAM->AttachTime))
{
Debugprintf("ARDOP closing session on AttachTimelimit");
STREAM->ReportDISC = 1;
@@ -913,126 +914,24 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
- if (TNC->ARDOPCommsMode != 'T') // S I or E
- {
- ARDOPSCSCheckRX(TNC);
- ARDOPSCSPoll(TNC);
- }
-
- return 0;
-
- case 1: // poll
-
- // If not using serial interface, Rig Contol Frames are sent as
- // ARDOP COmmand Frames. These are hex encoded
-
- if (TNC->ARDOPCommsMode == 'T' && TNC->BPQtoRadio_Q)
+ if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
{
- PMSGWITHLEN buffptr;
-
- buffptr = (PMSGWITHLEN)Q_REM(&TNC->BPQtoRadio_Q);
+ // See if time to reconnect
- if (TNC->CONNECTED)
+ time(&ltime);
+ if (ltime - TNC->lasttime > 9 )
{
- int len = (int)buffptr->Len;
- UCHAR * ptr = &buffptr->Data[0];
- char RigCommand[256] = "RADIOHEX ";
- char * ptr2 = &RigCommand[9] ;
- int i, j;
-
- if (len < 120)
- {
- while (len--)
- {
- i = *(ptr++);
- j = i >>4;
- j += '0'; // ascii
- if (j > '9')
- j += 7;
- *(ptr2++) = j;
-
- j = i & 0xf;
- j += '0'; // ascii
- if (j > '9')
- j += 7;
- *(ptr2++) = j;
- }
- ARDOPSendCommand(TNC, RigCommand, FALSE);
- }
+ if (TNC->ARDOPCommsMode == 'T' && TNC->PortRecord->PORTCONTROL.PortStopped == 0)
+ ConnecttoARDOP(TNC);
+ TNC->lasttime = ltime;
}
- ReleaseBuffer(buffptr);
-
}
- while (TNC->PortRecord->UI_Q)
- {
- int datalen;
- char * Buffer;
- char FECMsg[512];
- char Call[12] = " ";
- struct _MESSAGE * buffptr;
- int CallLen;
- char * ptr = FECMsg;
-
- buffptr = Q_REM(&TNC->PortRecord->UI_Q);
-
- if (TNC->CONNECTED == 0 ||
- TNC->Streams[0].Connecting ||
- TNC->Streams[0].Connected)
- {
- // discard if TNC not connected or session active
-
- ReleaseBuffer(buffptr);
- continue;
- }
-
- datalen = buffptr->LENGTH - MSGHDDRLEN;
- Buffer = &buffptr->DEST[0]; // Raw Frame
- Buffer[datalen] = 0;
- *ptr++ = '^'; // delimit frame with ^
-
- // Frame has ax.25 format header. Convert to Text
-
- CallLen = ConvFromAX25(Buffer + 7, Call); // Origin
- memcpy(ptr, Call, CallLen);
- ptr += CallLen;
-
- *ptr++ = '>';
-
- CallLen = ConvFromAX25(Buffer, Call); // Dest
- memcpy(ptr, Call, CallLen);
- ptr += CallLen;
-
- Buffer += 14; // TO Digis
- datalen -= 14;
-
- while ((Buffer[-1] & 1) == 0)
- {
- *ptr++ = ',';
- CallLen = ConvFromAX25(Buffer, Call);
- memcpy(ptr, Call, CallLen);
- ptr += CallLen;
- Buffer += 7; // End of addr
- datalen -= 7;
- }
-
- *ptr++ = '|'; // delimit calls
-
- if (Buffer[0] == 3) // UI
- {
- Buffer += 2;
- datalen -= 2;
- }
-
- memcpy(ptr, Buffer, datalen);
- ptr += datalen;
- *ptr++ = '^'; // delimit frame with ^
-
- ARDOPSendData(TNC, FECMsg, (int)(ptr - FECMsg));
- TNC->FECPending = 1;
-
- ReleaseBuffer((UINT *)buffptr);
+ if (TNC->ARDOPCommsMode != 'T') // S I or E
+ {
+ ARDOPSCSCheckRX(TNC);
+ ARDOPSCSPoll(TNC);
}
if (TNC->Busy) // Count down to clear
@@ -1042,7 +941,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->Busy--;
if (TNC->Busy == 0)
{
- MySetWindowText(TNC->xIDC_CHANSTATE, "Clear");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Clear");
strcpy(TNC->WEB_CHANSTATE, "Clear");
}
}
@@ -1065,7 +964,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
memcpy(TNC->Streams[0].RemoteCall, &TNC->ConnectCmd[8], (int)strlen(TNC->ConnectCmd)-10);
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
free(TNC->ConnectCmd);
TNC->BusyDelay = 0;
@@ -1091,7 +990,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
free(TNC->ConnectCmd);
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
@@ -1109,7 +1008,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
fn =fn; //ARDOPSendCommand(TNC, "MODE", TRUE);
else
{
-// if (time(NULL) - TNC->WinmorRestartCodecTimer > 300) // 5 mins
+// if (NOW - TNC->WinmorRestartCodecTimer > 300) // 5 mins
// {
// ARDOPSendCommand(TNC, "CODEC FALSE", TRUE);
// ARDOPSendCommand(TNC, "CODEC TRUE", TRUE);
@@ -1171,18 +1070,18 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
char Time[80];
TNC->Restarts++;
- TNC->LastRestart = time(NULL);
+ TNC->LastRestart = NOW;
tm = gmtime(&TNC->LastRestart);
sprintf_s(Time, sizeof(Time),"%04d/%02d/%02d %02d:%02dZ",
tm->tm_year +1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
- MySetWindowText(TNC->xIDC_RESTARTTIME, Time);
+ MySetWindowText(TNC, TNC->xIDC_RESTARTTIME, Time);
strcpy(TNC->WEB_RESTARTTIME, Time);
sprintf_s(Time, sizeof(Time),"%d", TNC->Restarts);
- MySetWindowText(TNC->xIDC_RESTARTS, Time);
+ MySetWindowText(TNC, TNC->xIDC_RESTARTS, Time);
strcpy(TNC->WEB_RESTARTS, Time);
KillTNC(TNC);
@@ -1225,7 +1124,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
Debugprintf("ARDOP New Attach Stream %d DEDStream %d", Stream, STREAM->DEDStream);
STREAM->Attached = TRUE;
- STREAM->AttachTime = time(NULL);
+ STREAM->AttachTime = NOW;
calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
TNC->Streams[Stream].MyCall[calllen] = 0;
@@ -1248,7 +1147,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
SuspendOtherPorts(TNC);
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Stop Scanning
@@ -1262,26 +1161,129 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
-
-
+
if (STREAM->Attached)
CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
}
- if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+
+ return 0;
+
+ case 1: // poll. Called around every 10 mS
+
+ // If not using serial interface, Rig Contol Frames are sent as
+ // ARDOP Command Frames. These are hex encoded
+
+ if (TNC->ARDOPCommsMode == 'T' && TNC->BPQtoRadio_Q)
{
- // See if time to reconnect
+ PMSGWITHLEN buffptr;
+
+ buffptr = (PMSGWITHLEN)Q_REM(&TNC->BPQtoRadio_Q);
- time(&ltime);
- if (ltime - TNC->lasttime > 9 )
+ if (TNC->CONNECTED)
{
- if (TNC->ARDOPCommsMode == 'T' && TNC->PortRecord->PORTCONTROL.PortStopped == 0)
- ConnecttoARDOP(TNC);
- TNC->lasttime = ltime;
+ int len = (int)buffptr->Len;
+ UCHAR * ptr = &buffptr->Data[0];
+ char RigCommand[256] = "RADIOHEX ";
+ char * ptr2 = &RigCommand[9] ;
+ int i, j;
+
+ if (len < 120)
+ {
+ while (len--)
+ {
+ i = *(ptr++);
+ j = i >>4;
+ j += '0'; // ascii
+ if (j > '9')
+ j += 7;
+ *(ptr2++) = j;
+
+ j = i & 0xf;
+ j += '0'; // ascii
+ if (j > '9')
+ j += 7;
+ *(ptr2++) = j;
+ }
+ ARDOPSendCommand(TNC, RigCommand, FALSE);
+ }
}
+ ReleaseBuffer(buffptr);
+
}
+
+ while (TNC->PortRecord->UI_Q)
+ {
+ int datalen;
+ char * Buffer;
+ char FECMsg[512];
+ char Call[12] = " ";
+ struct _MESSAGE * buffptr;
+ int CallLen;
+ char * ptr = FECMsg;
+
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+
+ if (TNC->CONNECTED == 0 ||
+ TNC->Streams[0].Connecting ||
+ TNC->Streams[0].Connected)
+ {
+ // discard if TNC not connected or session active
+
+ ReleaseBuffer(buffptr);
+ continue;
+ }
+
+ datalen = buffptr->LENGTH - MSGHDDRLEN;
+ Buffer = &buffptr->DEST[0]; // Raw Frame
+ Buffer[datalen] = 0;
+
+ *ptr++ = '^'; // delimit frame with ^
+
+ // Frame has ax.25 format header. Convert to Text
+
+ CallLen = ConvFromAX25(Buffer + 7, Call); // Origin
+ memcpy(ptr, Call, CallLen);
+ ptr += CallLen;
+
+ *ptr++ = '>';
+
+ CallLen = ConvFromAX25(Buffer, Call); // Dest
+ memcpy(ptr, Call, CallLen);
+ ptr += CallLen;
+
+ Buffer += 14; // TO Digis
+ datalen -= 14;
+
+ while ((Buffer[-1] & 1) == 0)
+ {
+ *ptr++ = ',';
+ CallLen = ConvFromAX25(Buffer, Call);
+ memcpy(ptr, Call, CallLen);
+ ptr += CallLen;
+ Buffer += 7; // End of addr
+ datalen -= 7;
+ }
+
+ *ptr++ = '|'; // delimit calls
+
+ if (Buffer[0] == 3) // UI
+ {
+ Buffer += 2;
+ datalen -= 2;
+ }
+
+ memcpy(ptr, Buffer, datalen);
+ ptr += datalen;
+ *ptr++ = '^'; // delimit frame with ^
+
+ ARDOPSendData(TNC, FECMsg, (int)(ptr - FECMsg));
+ TNC->FECPending = 1;
+ ReleaseBuffer((UINT *)buffptr);
+ }
+
// See if any frames for this port
for (Stream = 0; Stream <= APMaxStreams; Stream++)
@@ -1667,7 +1669,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Save Command, and wait up to 10 secs
sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->ConnectCmd = _strdup(Connect);
TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
@@ -1684,7 +1686,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", STREAM->MyCall, STREAM->RemoteCall);
ARDOPSendCommand(TNC, Connect, TRUE);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
else
{
@@ -1695,7 +1697,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
STREAM->Connecting = TRUE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
return 0;
}
@@ -1895,7 +1897,7 @@ VOID ARDOPReleaseTNC(struct TNCINFO * TNC)
ARDOPChangeMYC(TNC, TNC->NodeCall);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
ARDOPSendCommand(TNC, "LISTEN TRUE", TRUE);
@@ -1919,7 +1921,7 @@ VOID ARDOPSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
TNC->PortRecord->PORTCONTROL.PortSuspended = TRUE;
ARDOPSendCommand(TNC, "LISTEN FALSE", TRUE);
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
@@ -1928,15 +1930,19 @@ VOID ARDOPReleasePort(struct TNCINFO * TNC)
TNC->PortRecord->PORTCONTROL.PortSuspended = FALSE;
ARDOPSendCommand(TNC, "LISTEN TRUE", TRUE);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
extern char WebProcTemplate[];
+extern char Menubit[];
extern char sliderBit[];
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
-{
- int Len = sprintf(Buff, WebProcTemplate, TNC->Port, TNC->Port, "ARDOP Status", "ARDOP Status");
+{
+ int Len = sprintf(Buff, WebProcTemplate, "ARDOP Status");
+
+ if (LOCAL)
+ Len += sprintf(&Buff[Len], Menubit);
if (TNC->TXFreq)
Len += sprintf(&Buff[Len], sliderBit, TNC->TXOffset, TNC->TXOffset);
@@ -2300,7 +2306,7 @@ VOID TNCLost(struct TNCINFO * TNC)
{
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - STREAM->BytesOutstanding, STREAM->bytesRXed, STREAM->BytesOutstanding);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
}
if (STREAM->Attached)
@@ -2481,7 +2487,7 @@ VOID ARDOPThread(VOID * Param)
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -2511,7 +2517,7 @@ VOID ARDOPThread(VOID * Param)
i=sprintf(Msg, "Connect Failed for ARDOP Data socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -2615,7 +2621,7 @@ VOID ARDOPThread(VOID * Param)
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(Cmd, "DATETIME %02d %02d %02d %02d %02d %02d",
@@ -2638,7 +2644,7 @@ VOID ARDOPThread(VOID * Param)
ARDOPSendCommand(TNC, "LISTEN TRUE", TRUE);
sprintf(TNC->WEB_COMMSSTATE, "Connected to ARDOP TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
@@ -2714,10 +2720,10 @@ VOID ARDOPThread(VOID * Param)
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->CONNECTED = FALSE;
@@ -2757,7 +2763,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -2781,7 +2787,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -2831,7 +2837,7 @@ Lost:
// sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
// GetSemaphore(&Semaphore, 52);
-// MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+// MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
// FreeSemaphore(&Semaphore);
@@ -2956,7 +2962,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
{
sscanf(&Buffer[10], "%i %i", &TNC->InputLevelMin, &TNC->InputLevelMax);
sprintf(TNC->WEB_LEVELS, "Input peaks %s", &Buffer[10]);
- MySetWindowText(TNC->xIDC_LEVELS, TNC->WEB_LEVELS);
+ MySetWindowText(TNC, TNC->xIDC_LEVELS, TNC->WEB_LEVELS);
return; // Response shouldn't go to user
}
@@ -3034,10 +3040,10 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
TNC->BusyonTime = GetTickCount();
- MySetWindowText(TNC->xIDC_CHANSTATE, "Busy");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Busy");
strcpy(TNC->WEB_CHANSTATE, "Busy");
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -3056,8 +3062,8 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
TNC->BusyonTime = 0;
}
- MySetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
- TNC->WinmorRestartCodecTimer = time(NULL);
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -3107,7 +3113,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - STREAM->BytesOutstanding, STREAM->bytesRXed, STREAM->BytesOutstanding);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
return;
}
@@ -3125,7 +3131,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
Debugprintf(Buffer);
WritetoTrace(TNC, Buffer, MsgLen - 1);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
memcpy(Call, &Buffer[10], 10);
@@ -3159,7 +3165,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
// Incoming Connect
TNC->SessionTimeLimit = TNC->DefaultSessionTimeLimit; // Reset Limit
- STREAM->AttachTime = time(NULL);
+ STREAM->AttachTime = NOW;
// Stop other ports in same group
@@ -3190,7 +3196,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Check for ExcludeList
@@ -3335,7 +3341,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
else
sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Outbound", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
UpdateMH(TNC, Call, '+', 'O');
return;
@@ -3387,7 +3393,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
}
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
return;
}
@@ -3420,7 +3426,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (_memicmp(Buffer, "MODE", 4) == 0)
{
strcpy(TNC->WEB_MODE, &Buffer[5]);
- MySetWindowText(TNC->xIDC_MODE, &Buffer[5]);
+ MySetWindowText(TNC, TNC->xIDC_MODE, &Buffer[5]);
return;
}
@@ -3506,9 +3512,9 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (_memicmp(Buffer, "NEWSTATE", 8) == 0)
{
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
- MySetWindowText(TNC->xIDC_PROTOSTATE, &Buffer[9]);
+ MySetWindowText(TNC, TNC->xIDC_PROTOSTATE, &Buffer[9]);
strcpy(TNC->WEB_PROTOSTATE, &Buffer[9]);
if (_memicmp(&Buffer[9], "DISC", 4) == 0)
@@ -3887,7 +3893,7 @@ VOID ARDOPProcessDataPacket(struct TNCINFO * TNC, UCHAR * Type, UCHAR * Data, in
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - STREAM->BytesOutstanding, STREAM->bytesRXed, STREAM->BytesOutstanding);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
if (TNC->FECMode)
@@ -4534,7 +4540,7 @@ VOID ARDOPProcessTermModeResponse(struct TNCINFO * TNC)
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
len = sprintf(Poll, "DATETIME %02d %02d %02d %02d %02d %02d\r",
@@ -5034,7 +5040,7 @@ tcpHostFrame:
Buffer[len-1] = 0;
WritetoTrace(TNC, Buffer, len);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
memcpy(Call, &Buffer[19], 10);
@@ -5866,7 +5872,7 @@ VOID SerialConnecttoTCPThread(VOID * Param)
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
diff --git a/BBSUtilities.c b/BBSUtilities.c
index f56e24f..9a73c9f 100644
--- a/BBSUtilities.c
+++ b/BBSUtilities.c
@@ -452,7 +452,7 @@ void WriteLogLine(CIRCUIT * conn, int Flag, char * Msg, int MsgLen, int Flags)
// Don't close/reopen logs every time
-// if ((LT - LastLogTime[Flags]) > 60)
+ if ((LT - LastLogTime[Flags]) > 30)
{
LastLogTime[Flags] = LT;
fclose(LogHandle[Flags]);
@@ -489,29 +489,6 @@ BOOL CheckForTooManyErrors(ConnectionInfo * conn)
return FALSE;
}
-
-
-
-
-VOID __cdecl Debugprintf(const char * format, ...)
-{
- char Mess[16384];
- va_list(arglist);
- int Len;
-
- va_start(arglist, format);
- Len = vsprintf(Mess, format, arglist);
-#ifndef LINBPQ
- WriteLogLine(NULL, '!',Mess, Len, LOG_DEBUG_X);
-#endif
- // #ifdef _DEBUG
- strcat(Mess, "\r\n");
- OutputDebugString(Mess);
-
-// #endif
- return;
-}
-
VOID __cdecl Logprintf(int LogMode, CIRCUIT * conn, int InOut, const char * format, ...)
{
char Mess[1000];
@@ -519,7 +496,12 @@ VOID __cdecl Logprintf(int LogMode, CIRCUIT * conn, int InOut, const char * form
va_start(arglist, format);
Len = vsprintf(Mess, format, arglist);
- WriteLogLine(conn, InOut, Mess, Len, LogMode);
+ va_end(arglist);
+
+ if (LogMode == LOG_DEBUG_X)
+ Debugprintf(Mess);
+ else
+ WriteLogLine(conn, InOut, Mess, Len, LogMode);
return;
}
@@ -1759,6 +1741,12 @@ VOID SaveBIDDatabase()
Handle = fopen(BIDDatabasePath, "wb");
+ if (Handle == NULL)
+ {
+ Debugprintf("BPQMAIL can't open BID database (WFBID.SYS) for write");
+ return;
+ }
+
BIDRecPtr[0]->u.msgno = NumberofBIDs; // First Record has file size
for (i=0; i <= NumberofBIDs; i++)
@@ -2444,6 +2432,7 @@ VOID __cdecl nodeprintf(ConnectionInfo * conn, const char * format, ...)
va_start(arglist, format);
len = vsprintf(Mess, format, arglist);
+ va_end(arglist);
QueueMsg(conn, Mess, len);
@@ -2463,6 +2452,7 @@ VOID __cdecl nodeprintfEx(ConnectionInfo * conn, const char * format, ...)
va_start(arglist, format);
len = vsprintf(Mess, format, arglist);
+ va_end(arglist);
QueueMsg(conn, Mess, len);
@@ -10897,6 +10887,7 @@ int Connected(int Stream)
user->flags |= F_Temp_B2_BBS;
conn->NewUser = TRUE;
+ user->lastmsg = LatestMsg - 20; // Limit L command for new users
}
user->TimeLastConnected = time(NULL);
@@ -11267,6 +11258,32 @@ int DoReceivedData(int Stream)
if (conn->InputMode == 'P') // Inside PG Server
{
user = conn->UserPointer;
+
+ // check for paging
+
+ if (conn->Paging && (conn->LinesSent >= conn->PageLen))
+ {
+ // Waiting for paging prompt
+
+ if (conn->InputLen > 1)
+ {
+ if (_memicmp(conn->InputBuffer, "Abort", 1) == 0)
+ {
+ ClearQueue(conn);
+ conn->LinesSent = 0;
+
+ nodeprintf(conn, AbortedMsg);
+ conn->InputMode = 0;
+ conn->InputLen = 0;
+ SendPrompt(conn, user);
+ return 0;
+ }
+ }
+
+ conn->InputLen = 0;
+ conn->LinesSent = 0;
+ return 0;
+ }
run_pg(conn, user);
return 0;
}
@@ -12073,11 +12090,11 @@ void run_pg(CIRCUIT * conn, struct UserInfo * user)
// validate command is alphanumberic
- for (i = 0; i < conn->InputLen; i++)
+ for (i = 0; i < strlen(conn->InputBuffer); i++)
{
if (isalnum(conn->InputBuffer[i]) == 0 && conn->InputBuffer[i] != ' ')
{
- BBSputs(conn, "PG commnand string invalid\r");
+ BBSputs(conn, "PG command string invalid\r");
conn->InputMode=0;
SendPrompt(conn, user);
return;
@@ -12092,7 +12109,7 @@ void run_pg(CIRCUIT * conn, struct UserInfo * user)
user->Temp->RUNPGPARAMS->user = user;
user->Temp->RUNPGPARAMS->conn = conn;
strncpy(user->Temp->RUNPGPARAMS->InputBuffer, conn->InputBuffer, 80); // needs to be length of actual input!
- user->Temp->RUNPGPARAMS->Len = conn->InputLen;
+ user->Temp->RUNPGPARAMS->Len = strlen(conn->InputBuffer);
if (conn == 0 || user == 0)
{
@@ -12345,7 +12362,7 @@ void run_pg( CIRCUIT * conn, struct UserInfo * user )
user->Temp->RUNPGPARAMS->user = user;
user->Temp->RUNPGPARAMS->conn = conn;
strncpy(user->Temp->RUNPGPARAMS->InputBuffer, conn->InputBuffer, 80); // needs to be length of actual input!
- user->Temp->RUNPGPARAMS->Len = conn->InputLen;
+ user->Temp->RUNPGPARAMS->Len = strlen(conn->InputBuffer);
index = user->Temp->PG_INDEX;
conn->InputBuffer[conn->InputLen] = 0;
@@ -12357,7 +12374,7 @@ void run_pg( CIRCUIT * conn, struct UserInfo * user )
{
if (isalnum(conn->InputBuffer[i]) == 0 && conn->InputBuffer[i] != ' ')
{
- BBSputs(conn, "PG commnand string invalid\r");
+ BBSputs(conn, "PG command string invalid\r");
conn->InputMode=0;
SendPrompt(conn, user);
return;
@@ -13410,6 +13427,7 @@ VOID __cdecl nprintf(CIRCUIT * conn, const char * format, ...)
va_start(arglist, format);
vsprintf(buff, format, arglist);
+ va_end(arglist);
BBSputs(conn, buff);
}
@@ -13448,7 +13466,6 @@ int DeleteRedundantMessages()
{
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
- OutputDebugString(ffd.cFileName);
}
else
{
@@ -15511,7 +15528,6 @@ int ReformatSyncMessage(CIRCUIT * conn)
conn->MailBuffer[conn->TempMsg->length] = 0;
-// OutputDebugString(conn->MailBuffer);
memcpy(xml, conn->MailBuffer, conn->SyncXMLLen);
xml[conn->SyncXMLLen] = 0;
diff --git a/BPQChat.rc b/BPQChat.rc
index 528e943..e3b82f8 100644
--- a/BPQChat.rc
+++ b/BPQChat.rc
@@ -12,7 +12,7 @@
#undef APSTUDIO_HIDDEN_SYMBOLS
#define CHAT
#define IDC_STATIC -1
-#include "..\CommonSource\Versions.h"
+#include "Versions.h"
/////////////////////////////////////////////////////////////////////////////
@@ -444,7 +444,7 @@ END
//
// Generated from the TEXTINCLUDE 3 resource.
//
-#include "..\StdVer.inc"
+#include "StdVer.inc"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/BPQINP3.c b/BPQINP3.c
index a01767b..eae5979 100644
--- a/BPQINP3.c
+++ b/BPQINP3.c
@@ -43,9 +43,9 @@ int NegativeDelay = 10; // Seconds between checks for negative info - should
int PositiveDelay = 300;
time_t SENDRIFTIME = 0;
-int RIFInterval = 60;
+int RIFInterval = 3600;
-VOID SendNegativeInfo();
+VOID SendNegativeInfo(int sendAlways);
VOID SortRoutes(struct DEST_LIST * Dest);
VOID SendRTTMsg(struct ROUTE * Route);
VOID TCPNETROMSend(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Frame);
@@ -97,7 +97,7 @@ VOID __cdecl Debugprintf(const char * format, ...);
VOID SendINP3RIF(struct ROUTE * Route, UCHAR * Call, UCHAR * Alias, int Hops, int RTT);
VOID SendOurRIF(struct ROUTE * Route);
-VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops, int rtt);
+VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, int hops, int rtt, unsigned char * Options);
VOID UpdateRoute(struct DEST_LIST * Dest, struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR, int hops, int rtt);
VOID KillRoute(struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR);
VOID AddHere(struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR,struct ROUTE * Route , int hops, int rtt);
@@ -112,7 +112,7 @@ struct _RTTMSG RTTMsg = {""};
//struct ROUTE DummyRoute = {"","",""};
-int RIPTimerCount = 0; // 1 sec to 10 sec counter
+int RIPTimerCount = 10; // 1 sec to 10 sec counter
int PosTimerCount = 0;
int NegTimerCount = 0;
@@ -127,16 +127,23 @@ int RTTTimeout = 6; // 1 Min (Horizon is 1 min)
uint32_t RTTID = 1;
+// BPQ32001 - Original. Sends RIF in mS and adds link rtt before sending
+// BPQ32002 - Sends RIF in 10mS and adds link rtt before sending
+// BPQ32003 - Original. RIF in 10mS and doesn't add link rtt before sending (XR compatiblity)
+// BPQ32004 - Original. RIF in 10mS ,doesn't add link rtt before sending and sends full routing table every hour
+
+
+
VOID InitialiseRTT()
{
UCHAR temp[256] = "";
- SENDRIFTIME = time(NULL);
+ SENDRIFTIME = NOW;
memset(&RTTMsg, ' ', sizeof(struct _RTTMSG));
memcpy(RTTMsg.ID, "L3RTT: ", 7);
memcpy(RTTMsg.VERSION, "LEVEL3_V2.1 ", 12);
- memcpy(RTTMsg.SWVERSION, "BPQ32003 ", 9); // Follows XR by not adding route time before sending RIF
+ memcpy(RTTMsg.SWVERSION, "BPQ32004 ", 9); // Follows XR by not adding route time before sending RIF, send Hourly RIF refresh and time out routes
_snprintf(temp, sizeof(temp), "$M%d $N $H%d ", MAXRTT, MaxHops); // trailing spaces extend to ensure padding if the length of characters for MAXRTT changes.
memcpy(RTTMsg.FLAGS, temp, 20); // But still limit the actual characters copied.
memcpy(RTTMsg.ALIAS, &MYALIASTEXT, 6);
@@ -168,6 +175,8 @@ VOID DeleteINP3Routes(struct ROUTE * Route)
struct DEST_LIST * Dest = DESTS;
char Call1[10];
char Call2[10];
+ int deletingFirstRoute = 0;
+
Call1[ConvFromAX25(Route->NEIGHBOUR_CALL, Call1)] = 0;
@@ -210,10 +219,26 @@ VOID DeleteINP3Routes(struct ROUTE * Route)
if (DEBUGINP3) Debugprintf("Deleting First INP3 Route to %s", Call2);
- Dest->INP3ROUTE[0].STT = 60000; // leave hops so we can check if we need to send
+ // Need to make sure it is sent by setting by sendnegative info by setting sendAlways below
+
+ deletingFirstRoute = 1;
- if (DEBUGINP3) Debugprintf("Was the only INP3 route");
+ // I don't think this is right. If it is the only route send 60000 to other neighbours but if there are more
+ // promote them and send the new best, making sure it is sent even if a small change.
+
+ if (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR == 0) // No other INP3 routes
+ {
+ if (DEBUGINP3) Debugprintf("Was the only INP3 route");
+ Dest->INP3ROUTE[0].STT = 60000; // leave hops so we can check if we need to send
+ }
+ else
+ {
+ memcpy(&Dest->INP3ROUTE[0], &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(&Dest->INP3ROUTE[1], &Dest->INP3ROUTE[2], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memset(&Dest->INP3ROUTE[2], 0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ }
+
if (Dest->DEST_ROUTE == 4) // we were using it
Dest->DEST_ROUTE = 0;
@@ -241,8 +266,11 @@ VOID DeleteINP3Routes(struct ROUTE * Route)
// I think we should send Negative info immediately
- NegTimerCount = NegativeDelay;
- SendNegativeInfo();
+ if (deletingFirstRoute)
+ {
+ NegTimerCount = NegativeDelay;
+ SendNegativeInfo(TRUE); // TRUE means always send even if little change
+ }
}
VOID DecayNETROMRoutes(struct ROUTE * Route)
@@ -364,24 +392,32 @@ VOID ProcessRTTReply(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff)
if (RTT > 60000)
return; // Ignore if more than 60 secs (why ??)
- if (RTT == 0)
- RTT = 1; // Don't allow a Node TT of zero
+ if (Route->NPR)
+ {
+ Route->RTTIncrement = Route->SRTT = Route->RTT = Route->NPR;
+ if (DEBUGINP3) Debugprintf("INP3 RTT reply from %s - NPR Set RTT was %d setting to %d", Normcall, RTT, Route->NPR);
+ }
+ else
+ {
+ if (RTT == 0)
+ RTT = 1; // Don't allow a Node TT of zero
- if (DEBUGINP3) Debugprintf("INP3 RTT reply from %s - SRTT was %d, Current RTT %d", Normcall, Route->SRTT, RTT);
+ if (DEBUGINP3) Debugprintf("INP3 RTT reply from %s - SRTT was %d, Current RTT %d", Normcall, Route->SRTT, RTT);
- Route->RTT = RTT;
+ Route->RTT = RTT;
- if (Route->SRTT == 0)
- Route->SRTT = RTT;
- else
- Route->SRTT = ((Route->SRTT * 80)/100) + ((RTT * 20)/100);
+ if (Route->SRTT == 0)
+ Route->SRTT = RTT;
+ else
+ Route->SRTT = ((Route->SRTT * 80)/100) + ((RTT * 20)/100);
- Route->RTTIncrement = Route->SRTT / 2; // Half for one way time.
+ Route->RTTIncrement = Route->SRTT / 2; // Half for one way time.
- if (Route->RTTIncrement == 0)
- Route->RTTIncrement = 1;
+ if (Route->RTTIncrement == 0)
+ Route->RTTIncrement = 1;
+ }
- if (Route->OldBPQ)
+ if (Route->senderaddsRTT)
Route->TXRTTIncrement = Route->RTTIncrement;
else
Route->TXRTTIncrement = 0;
@@ -411,16 +447,20 @@ VOID ProcessRTTReply(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff)
}
}
+UCHAR * SkipOptions(UCHAR * ptr1, int msglen);
+void DecodeRIFOptions(struct DEST_LIST * Dest, UCHAR * Options);
+
VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
{
unsigned char axcall[7];
int hops;
unsigned short rtt;
- int len;
- int opcode;
char alias[6];
UINT Stamp, HH, MM;
char Normcall[10];
+ unsigned char * Options;
+ int i;
+ UCHAR * oldptr1;
if (Route == 0 || Route->NEIGHBOUR_LINK == 0 || Route->NEIGHBOUR_LINK->LINKCALL == 0)
return;
@@ -443,7 +483,7 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
// Update Timestamp on Route
- Stamp = time(NULL) % 86400; // Secs into day
+ Stamp = NOW % 86400; // Secs into day
HH = Stamp / 3600;
Stamp -= HH * 3600;
@@ -462,9 +502,12 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
memset(alias, ' ', 6);
memcpy(axcall, ptr1, 7);
- if (axcall[0] < 0x60 || (axcall[0] & 1)) // Not valid ax25 callsign
+ for (i = 0; i < 6; i++)
+ {
+ if (axcall[i] < 0x40 || (axcall[i] & 1)) // Not valid ax25 callsign
return; // Corrupt RIF
-
+ }
+
ptr1+=7;
hops = *ptr1++;
@@ -475,40 +518,30 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
// if other end is old bpq then value is mS otherwise 10 mS unita
- if (Route->OldBPQ == 1)
+ if (Route->mSRIF == 1)
rtt /= 10;
- if (Route->OldBPQ == 0)
- rtt += Route->RTTIncrement; // Don't do this if OldBPQ set - other end has added it
+ if (Route->senderaddsRTT == 0)
+ rtt += Route->RTTIncrement;
msglen -= 10;
- while (*ptr1 && msglen > 0)
- {
- len = *ptr1;
- opcode = *(ptr1+1);
+ Options = ptr1;
- if (len < 2 || len > msglen)
- return; // Duff RIF
+ oldptr1 = ptr1;
+
+ ptr1 = SkipOptions(ptr1, msglen); // We now extact options here and decode them once we have a Node record
- if (opcode == 0)
- {
- if (len > 1 && len < 9)
- memcpy(alias, ptr1+2, len-2);
- else
- {
- if (DEBUGINP3) Debugprintf("Corrupt INP3 Message");
- return;
- }
- }
- ptr1+=len;
- msglen -=len;
- }
+ if (ptr1 == 0)
+ return; // Corrupt RIF
+
+ msglen -= (ptr1 - oldptr1); // options len
ptr1++;
msglen--; // EOP
- UpdateNode(Route, axcall, alias, hops, rtt);
+ UpdateNode(Route, axcall, hops, rtt, Options);
+
}
return;
@@ -519,7 +552,7 @@ VOID KillRoute(struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR)
}
-VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops, int rtt)
+VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, int hops, int rtt, unsigned char * Options)
{
struct DEST_LIST * Dest;
struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR;
@@ -527,6 +560,9 @@ VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops,
char call[11]="";
APPLCALLS * APPL;
int App;
+ XROptions noOptions;
+ int n = sizeof(noOptions);
+
// SEE IF any of OUR CALLs - DONT WANT TO PUT IT IN LIST!
@@ -616,6 +652,7 @@ VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops,
return;
}
+ memset(&noOptions, 0, sizeof(noOptions));
if (FindDestination(axcall, &Dest))
goto Found;
@@ -631,12 +668,12 @@ VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops,
memset(Dest, 0, sizeof(struct DEST_LIST));
memcpy(Dest->DEST_CALL, axcall, 7);
- memcpy(Dest->DEST_ALIAS, alias, 6);
// Set up First Route
Dest->INP3ROUTE[0].Hops = hops;
Dest->INP3ROUTE[0].STT = rtt;
+ Dest->INP3ROUTE[0].LastRefreshed = NOW;
Dest->INP3FLAGS = NewNode;
@@ -647,6 +684,15 @@ VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops,
ConvFromAX25(Dest->DEST_CALL, call);
if (DEBUGINP3) Debugprintf("INP3 Adding New Node %s Hops %d RTT %d", call, hops, rtt);
+ DecodeRIFOptions(Dest, Options);
+
+// if (memcmp(Options, &noOptions, sizeof(noOptions)) != 0)
+// {
+// Dest->XROptions = malloc(sizeof(noOptions));
+// memcpy(Dest->XROptions, Options, sizeof(noOptions));
+// Options->LOC = Options->QTH = Options->Ver = 0; // So not freed later
+// }
+
return;
Found:
@@ -662,8 +708,7 @@ Found:
ConvFromAX25(Dest->DEST_CALL, call);
if (DEBUGINP3) Debugprintf("INP3 Updating Node %s Hops %d TT %d", call, hops, rtt);
- if (alias[0] > ' ')
- memcpy(Dest->DEST_ALIAS, alias, 6);
+ DecodeRIFOptions(Dest, Options);
// See if we are known to it, it not add
@@ -764,7 +809,7 @@ VOID AddHere(struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR,struct ROUTE * Route , int
ROUTEPTR->Hops = hops;
ROUTEPTR->STT = rtt;
ROUTEPTR->ROUT_NEIGHBOUR = Route;
-
+ ROUTEPTR->LastRefreshed = NOW;
return;
}
@@ -775,6 +820,9 @@ struct INP3_DEST_ROUTE_ENTRY Temp;
VOID SortRoutes(struct DEST_LIST * Dest)
{
char Call1[10], Call2[10], Call3[10];
+ struct INP3_DEST_ROUTE_ENTRY * E0 = &Dest->INP3ROUTE[0];
+ struct INP3_DEST_ROUTE_ENTRY * E1 = &Dest->INP3ROUTE[1];
+ struct INP3_DEST_ROUTE_ENTRY * E2 = &Dest->INP3ROUTE[2];
// force route re-evaluation
@@ -782,101 +830,112 @@ VOID SortRoutes(struct DEST_LIST * Dest)
// May now be out of order
- if (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR == 0)
+ if (E1->ROUT_NEIGHBOUR == 0)
{
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- if (DEBUGINP3) Debugprintf("INP3 1 route %d %s", Dest->INP3ROUTE[0].STT, Call1);
- return; // Only One, so cant be out of order
+ if (DEBUGINP3)
+ {
+ Call1[ConvFromAX25(E0->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Debugprintf("INP3 1 route %d %s", E0->STT, Call1);
+ }
+ return; // Only One, so can't be out of order
}
- if (Dest->INP3ROUTE[2].ROUT_NEIGHBOUR == 0)
+
+ if (E2->ROUT_NEIGHBOUR == 0)
{
// Only 2
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
-
- if (DEBUGINP3) Debugprintf("INP3 2 routes %d %s %d %s", Dest->INP3ROUTE[0].STT, Call1, Dest->INP3ROUTE[1].STT, Call2);
+ if (DEBUGINP3)
+ {
+ Call1[ConvFromAX25(E0->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(E1->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+ Debugprintf("INP3 2 routes %d %s %d %s", E0->STT, Call1, E1->STT, Call2);
+ }
- if (Dest->INP3ROUTE[0].STT <= Dest->INP3ROUTE[1].STT)
+ if (E0->STT < E1->STT || (E0->STT == E1->STT && E0->Hops <= E1->Hops))
return;
// Swap one and two
- memcpy(&Temp, &Dest->INP3ROUTE[0], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[0], &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[1], &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(&Temp, E0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E0, E1, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E1, &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+
+ if (DEBUGINP3) Debugprintf("INP3 2 routes %d %s %d %s", E0->STT, Call2, E1->STT, Call1);
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
-
- if (DEBUGINP3) Debugprintf("INP3 2 routes %d %s %d %s", Dest->INP3ROUTE[0].STT, Call1, Dest->INP3ROUTE[1].STT, Call2);
return;
}
// Have 3 Entries
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
- Call3[ConvFromAX25(Dest->INP3ROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
+ if (DEBUGINP3)
+ {
+ Call1[ConvFromAX25(E0->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(E1->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+ Call3[ConvFromAX25(E2->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
+ Debugprintf("INP3 3 routes %d %s %d %s %d %s", E0->STT, Call1, E1->STT, Call2, E2->STT, Call3);
+ }
- if (DEBUGINP3) Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].STT, Call1, Dest->INP3ROUTE[1].STT, Call2, Dest->INP3ROUTE[2].STT, Call3);
-
// In order?
- if (Dest->INP3ROUTE[0].STT <= Dest->INP3ROUTE[1].STT && Dest->INP3ROUTE[1].STT <= Dest->INP3ROUTE[2].STT)// In order?
+ if ((E0->STT < E1->STT || (E0->STT == E1->STT && E0->Hops <= E1->Hops)) && (E1->STT < E2->STT || (E1->STT == E2->STT && E1->Hops <= E2->Hops)))
return;
// If second is better that first swap
- if (Dest->INP3ROUTE[0].STT > Dest->INP3ROUTE[1].STT)
+ if (E0->STT > E1->STT || (E0->STT == E1->STT && E0->Hops > E1->Hops))
{
- memcpy(&Temp, &Dest->INP3ROUTE[0], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[0], &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[1], &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(&Temp, E0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E0, E1, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E1, &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
}
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
- Call3[ConvFromAX25(Dest->INP3ROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
+ Call1[ConvFromAX25(E0->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(E1->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+ Call3[ConvFromAX25(E2->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
- if (DEBUGINP3) Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].STT, Call1, Dest->INP3ROUTE[1].STT, Call2, Dest->INP3ROUTE[2].STT, Call3);
+ if (DEBUGINP3) Debugprintf("INP3 3 routes %d %s %d %s %d %s", E0->STT, Call1, E1->STT, Call2, E2->STT, Call3);
// if 3 is better than 2 swap them. As two is worse than one. three will then be worst
- if (Dest->INP3ROUTE[1].STT > Dest->INP3ROUTE[2].STT)
+ if (E1->STT > E2->STT || (E1->STT == E2->STT && E1->Hops > E2->Hops))
{
- memcpy(&Temp, &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[1], &Dest->INP3ROUTE[2], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[2], &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(&Temp, E1, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E1, E2, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E2, &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
}
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
- Call3[ConvFromAX25(Dest->INP3ROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
+ Call1[ConvFromAX25(E0->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(E1->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+ Call3[ConvFromAX25(E2->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
- if (DEBUGINP3) Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].STT, Call1, Dest->INP3ROUTE[1].STT, Call2, Dest->INP3ROUTE[2].STT, Call3);
+ if (DEBUGINP3) Debugprintf("INP3 3 routes %d %s %d %s %d %s", E0->STT, Call1, E1->STT, Call2, E2->STT, Call3);
// 3 is now slowest. 2 could still be better than 1
-
- if (Dest->INP3ROUTE[0].STT > Dest->INP3ROUTE[1].STT)
+ if (E0->STT > E1->STT || (E0->STT == E1->STT && E0->Hops > E1->Hops))
{
- memcpy(&Temp, &Dest->INP3ROUTE[0], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[0], &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
- memcpy(&Dest->INP3ROUTE[1], &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(&Temp, E0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E0, E1, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(E1, &Temp, sizeof(struct INP3_DEST_ROUTE_ENTRY));
}
+ if (DEBUGINP3)
+ {
+ E0 = &Dest->INP3ROUTE[0];
+ E1 = &Dest->INP3ROUTE[1];
+ E2 = &Dest->INP3ROUTE[2];
- Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
- Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
- Call3[ConvFromAX25(Dest->INP3ROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
+ Call1[ConvFromAX25(E0->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(E1->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+ Call3[ConvFromAX25(E2->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call3)] = 0;
- if (DEBUGINP3) Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].STT, Call1, Dest->INP3ROUTE[1].STT, Call2, Dest->INP3ROUTE[2].STT, Call3);
+ Debugprintf("INP3 3 routes %d %s %d %s %d %s", E0->STT, Call1, E1->STT, Call2, E2->STT, Call3);
+ }
- if (Dest->INP3ROUTE[0].STT <= Dest->INP3ROUTE[1].STT && Dest->INP3ROUTE[1].STT <= Dest->INP3ROUTE[2].STT)// In order?
+ if (E0->STT <= E1->STT && E1->STT <= E2->STT)// In order?
return;
// Something went wrong
@@ -922,6 +981,7 @@ VOID UpdateRoute(struct DEST_LIST * Dest, struct INP3_DEST_ROUTE_ENTRY * ROUTEPT
ROUTEPTR->Hops = hops;
ROUTEPTR->STT = rtt;
+ ROUTEPTR->LastRefreshed = NOW;
SortRoutes(Dest);
return;
@@ -931,6 +991,7 @@ VOID UpdateRoute(struct DEST_LIST * Dest, struct INP3_DEST_ROUTE_ENTRY * ROUTEPT
{
ROUTEPTR->STT = rtt;
ROUTEPTR->Hops = hops;
+ ROUTEPTR->LastRefreshed = NOW;
SortRoutes(Dest);
return;
@@ -939,6 +1000,7 @@ VOID UpdateRoute(struct DEST_LIST * Dest, struct INP3_DEST_ROUTE_ENTRY * ROUTEPT
ROUTEPTR->STT = rtt;
ROUTEPTR->Hops = hops;
+ ROUTEPTR->LastRefreshed = NOW;
SortRoutes(Dest);
return;
@@ -996,14 +1058,49 @@ VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len
{
// Extract other end's SRTT
- // Get SWVERSION to see if other end is old (Buggy) BPQ
+ // Get SWVERSION to see if other end is old (Buggy) BPQ (000) or not updating RIF before sending (001)
- if (memcmp(RTTMsg->SWVERSION, "BPQ32001 ", 9) == 0)
- Route->OldBPQ = 1;
- else if (memcmp(RTTMsg->SWVERSION, "BPQ32002 ", 9) == 0)
- Route->OldBPQ = 2; // XR mode
+ int inpVer = 0; // Not BPQ
+
+ if (memcmp(RTTMsg->SWVERSION, "BPQ32", 5) == 0)
+ {
+ inpVer = atoi(&RTTMsg->SWVERSION[5]);
+
+ if (inpVer == 1)
+ {
+ Route->mSRIF = 1; // Set if other end is BPQ sending RIF in mS (Ver < 2)
+ Route->senderaddsRTT = 1; // Set if link RTT added before sending (Ver = 1)
+ Route->timeoutRoutes = 0; // Set if other end always sends timed RIF updates (Hourly)
+ }
+ else if (inpVer == 2)
+ {
+ Route->mSRIF = 0; // Set if other end is BPQ sending RIF in mS (Ver < 2)
+ Route->senderaddsRTT = 1; // Set if link RTT added before sending (Ver = 1)
+ Route->timeoutRoutes = 0; // Set if other end always sends timed RIF updates (Hourly)
+ }
+ else if (inpVer == 3)
+ {
+ Route->mSRIF = 0; // Set if other end is BPQ sending RIF in mS (Ver < 2)
+ Route->senderaddsRTT = 0; // Set if link RTT added before sending (Ver = 1)
+ Route->timeoutRoutes = 0; // Set if other end always sends timed RIF updates (Hourly)
+ }
+ else if (inpVer >= 4)
+ {
+ Route->mSRIF = 0; // Set if other end is BPQ sending RIF in mS (Ver < 2)
+ Route->senderaddsRTT = 0; // Set if link RTT added before sending (Ver = 1)
+ Route->timeoutRoutes = 1; // Set if other end always sends timed RIF updates (Hourly)
+ }
+ }
else
- Route->OldBPQ = 0;
+ {
+ // XR or others
+
+ Route->mSRIF = 0; // Set if other end is BPQ sending RIF in mS (Ver < 2)
+ Route->senderaddsRTT = 0; // Set if link RTT added before sending (Ver = 1)
+ Route->timeoutRoutes = 1; // Set if other end always sends timed RIF updates (Hourly)
+
+ Debugprintf(RTTMsg->SWVERSION);
+ }
sscanf(&Buff->L4DATA[6], "%u %u", &Dummy, &OtherRTT);
@@ -1092,6 +1189,13 @@ VOID SendRTTMsg(struct ROUTE * Route)
sprintf(temp, "$M%d $N $H%d ", MAXRTT, MaxHops); // trailing spaces extend to ensure padding if the length of characters for MAXRTT changes.
memcpy(RTTMsg.FLAGS, temp, 20); // But still limit the actual characters copied.
+ // Normally we use Version BPQ32004 but if not using the new standard rif timer refresh (Hourly) switch to BPQ32003 which disables node timeout at other end
+
+ if (RIFInterval == 3600)
+ memcpy(RTTMsg.SWVERSION, "BPQ32004 ", 9);
+ else
+ memcpy(RTTMsg.SWVERSION, "BPQ32003 ", 9);
+
memcpy(Msg->L4DATA, &RTTMsg, 236);
Msg->LENGTH = 256 + 1 + MSGHDDRLEN;
@@ -1134,7 +1238,7 @@ VOID SendKeepAlive(struct ROUTE * Route)
SendNetFrame(Route, Msg);
}
-int BuildRIF(UCHAR * RIF, UCHAR * Call, UCHAR * Alias, int Hops, int RTT, char * Dest)
+int BuildRIF(UCHAR * RIF, UCHAR * Call, UCHAR * Alias, int Hops, int RTT, char * Dest, XROptions * Options)
{
int AliasLen;
int RIFLen;
@@ -1151,6 +1255,18 @@ int BuildRIF(UCHAR * RIF, UCHAR * Call, UCHAR * Alias, int Hops, int RTT, char *
RIF[8] = RTT >> 8;
RIF[9] = RTT & 0xff;
+ if (Options && Options->Optionslist)
+ {
+ // Will include alias
+
+ int optlen = Options->Optionslist[0]; // includes terminalting null
+ memcpy(&RIF[10], &Options->Optionslist[1], optlen);
+ RIFLen = 10 + optlen;
+
+ if (DEBUGINP3) Debugprintf("INP3 sending RIF Entry %s:%s %d %d to %s", AliasCopy, Normcall, Hops, RTT, Dest);
+ return RIFLen;
+ }
+
if (Alias)
{
// Need to null-terminate Alias
@@ -1166,18 +1282,17 @@ int BuildRIF(UCHAR * RIF, UCHAR * Call, UCHAR * Alias, int Hops, int RTT, char *
RIF[10] = AliasLen+2;
RIF[11] = 0;
memcpy(&RIF[12], Alias, AliasLen);
- RIF[12+AliasLen] = 0;
+ RIF[12+AliasLen] = 0;
RIFLen = 13 + AliasLen;
- if (DEBUGINP3) Debugprintf("INP3 sending RIF Entry %s:%s %d %d to %s", AliasCopy, Normcall, Hops, RTT, Dest);
- return RIFLen;
- }
- RIF[10] = 0;
+ if (DEBUGINP3) Debugprintf("INP3 sending RIF Entry %s %d %d to %s", Normcall, Hops, RTT, Dest);
- if (DEBUGINP3) Debugprintf("INP3 sending RIF Entry %s %d %d to %s", Normcall, Hops, RTT, Dest);
+ return RIFLen;
+ }
- return (11);
+ RIF[10] = 0;
+ return 11;
}
@@ -1198,7 +1313,7 @@ VOID SendOurRIF(struct ROUTE * Route)
if (DEBUGINP3) Debugprintf("INP3 Sending Our Call and Applcalls to %s ", Normcall);
- if (Route->OldBPQ == 1) // old bpq bug - send mS not 10 mS units
+ if (Route->mSRIF == 1) // old bpq bug - send mS not 10 mS units
sendTT *= 10;
Msg = GetBuff();
@@ -1209,7 +1324,7 @@ VOID SendOurRIF(struct ROUTE * Route)
// send a RIF for our Node and all our APPLCalls
- RIFLen = BuildRIF(&Msg->L3SRCE[totLen], MYCALL, MYALIASTEXT, 1, sendTT, Normcall);
+ RIFLen = BuildRIF(&Msg->L3SRCE[totLen], MYCALL, MYALIASTEXT, 1, sendTT, Normcall, 0);
totLen += RIFLen;
for (App = 0; App < NumberofAppls; App++)
@@ -1218,7 +1333,7 @@ VOID SendOurRIF(struct ROUTE * Route)
if (APPL->APPLQUAL > 0)
{
- RIFLen = BuildRIF(&Msg->L3SRCE[totLen], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, sendTT, Normcall);
+ RIFLen = BuildRIF(&Msg->L3SRCE[totLen], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, sendTT, Normcall, 0);
totLen += RIFLen;
}
}
@@ -1321,7 +1436,7 @@ int SendRIPTimer()
continue;
}
- if (Route->NEIGHBOUR_LINK->KILLTIMER > ((L4LIMIT - 60) * 3)) // IDLETIME - 1 Minute
+ if (Route->NEIGHBOUR_LINK->KILLTIMER > ((L4LIMIT - 60) * 10)) // IDLETIME - 1 Minute
{
SendKeepAlive(Route);
Route->NEIGHBOUR_LINK->KILLTIMER = 0; // Keep Open
@@ -1447,7 +1562,7 @@ VOID SendRIF(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Msg)
SendNetFrame(Route, Msg);
}
-VOID SendRIFToOtherNeighbours(struct DEST_LIST * Dest, UCHAR * alias, struct INP3_DEST_ROUTE_ENTRY * Entry, int Negative, int portNum)
+VOID SendRIFToOtherNeighbours(struct DEST_LIST * Dest, UCHAR * alias, struct INP3_DEST_ROUTE_ENTRY * Entry, int Negative, int portNum, int includeOptions, int sendAlways)
{
UCHAR * axcall = Dest->DEST_CALL;
struct ROUTE * Routes = NEIGHBOURS;
@@ -1455,8 +1570,9 @@ VOID SendRIFToOtherNeighbours(struct DEST_LIST * Dest, UCHAR * alias, struct INP
int count, MaxRoutes = MAXNEIGHBOURS;
char NodeCall[10];
char destCall[10];
-
- int sendHops, sendTT, lastTT;
+ int rifLen;
+ unsigned char rif[256];
+ int sendHops, sendTT, lastTT, diff;
// if portNum is set sending a periodic refresh. Just sent to this port
@@ -1478,24 +1594,42 @@ VOID SendRIFToOtherNeighbours(struct DEST_LIST * Dest, UCHAR * alias, struct INP
if (!portNum)
{
- if (Negative)
+ // as we can now get very short times need to enforce absolute change as well as percentage
+
+ if (sendAlways == FALSE)
{
- // only send if significantly worse
+ // Send if sufficient change
+
+ diff = sendTT - lastTT;
- if (sendTT < (lastTT * NegativePercent) / 100)
+ if (diff < 0)
+ diff = -diff;
+
+ if (diff < 3) // need more than 20 ms change
{
Routes+=1;
continue;
- }
- }
- else
- {
- // Send if significantly better
+ }
- if (sendTT > (lastTT * PositivePercent) / 100)
+ if (Negative)
{
- Routes+=1;
- continue;
+ // only send if significantly worse
+
+ if (sendTT < (lastTT * NegativePercent) / 100)
+ {
+ Routes+=1;
+ continue;
+ }
+ }
+ else
+ {
+ // Send if significantly better
+
+ if (sendTT > (lastTT * PositivePercent) / 100)
+ {
+ Routes+=1;
+ continue;
+ }
}
}
@@ -1553,16 +1687,22 @@ VOID SendRIFToOtherNeighbours(struct DEST_LIST * Dest, UCHAR * alias, struct INP
if (Msg)
{
- if (Routes->OldBPQ == 1) // old bpq bug - send mS not 10 mS units
+ if (Routes->mSRIF == 1) // old bpq bug - send mS not 10 mS units
sendTT *= 10;
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], axcall, alias, sendHops, sendTT, destCall);
+ if (includeOptions)
+ rifLen = BuildRIF(rif, axcall, alias, sendHops, sendTT, destCall, Dest->XROptions);
+ else
+ rifLen = BuildRIF(rif, axcall, alias, sendHops, sendTT, destCall, 0);
- if (Msg->LENGTH > 250 - 15)
+ if (Msg->LENGTH + rifLen > 250)
{
SendRIF(Routes, Msg);
- Routes->Msg = NULL;
+ Msg = Routes->Msg = CreateRIFHeader(Routes);
}
+
+ memcpy(&Msg->L3SRCE[Msg->LENGTH], rif, rifLen);
+ Msg->LENGTH += rifLen;
}
}
}
@@ -1578,6 +1718,8 @@ VOID SendRIFToNewNeighbour(struct ROUTE * Route)
struct _L3MESSAGEBUFFER * Msg;
int sendHops, sendTT;
char Normcall[10];
+ int rifLen;
+ unsigned char rif[256];
if (Route->NEIGHBOUR_LINK == 0) // shouldn't happen but to be safe..
return;
@@ -1595,9 +1737,16 @@ VOID SendRIFToNewNeighbour(struct ROUTE * Route)
Entry = &Dest->INP3ROUTE[0];
- if (Entry->ROUT_NEIGHBOUR && Entry->Hops && Route != Entry->ROUT_NEIGHBOUR)
+ if (Entry->ROUT_NEIGHBOUR == 0)
+ continue;
+
+ if (Route == Entry->ROUT_NEIGHBOUR)
+ continue;
+
+ // Best Route not via this neighbour - send, but only if within their constraints
+
+ if (Entry->Hops)
{
- // Best Route not via this neighbour - send, but only if within their constraints
sendHops = Entry->Hops + 1;
@@ -1615,16 +1764,18 @@ VOID SendRIFToNewNeighbour(struct ROUTE * Route)
if (Msg == NULL)
return;
- if (Route->OldBPQ == 1) // old bpq bug - send mS not 10 mS units
+ if (Route->mSRIF == 1) // old bpq bug - send mS not 10 mS units
sendTT *= 10;
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], Dest->DEST_CALL, Dest->DEST_ALIAS, sendHops, sendTT, Normcall);
-
- if (Msg->LENGTH > 250 - 15)
+ rifLen = BuildRIF(rif, Dest->DEST_CALL, Dest->DEST_ALIAS, sendHops, sendTT, Normcall, Dest->XROptions);
+
+ if (Msg->LENGTH + rifLen > 250)
{
SendRIF(Route, Msg);
- Route->Msg = NULL;
+ Msg = Route->Msg = CreateRIFHeader(Route);
}
+ memcpy(&Msg->L3SRCE[Msg->LENGTH], rif, rifLen);
+ Msg->LENGTH += rifLen;
}
}
}
@@ -1664,7 +1815,7 @@ VOID FlushRIFs()
}
}
-VOID SendNegativeInfo()
+VOID SendNegativeInfo(int sendAlways)
{
int i;
struct DEST_LIST * Dest = DESTS;
@@ -1693,7 +1844,7 @@ VOID SendNegativeInfo()
if (Entry->ROUT_NEIGHBOUR == 0)
continue;
- SendRIFToOtherNeighbours(Dest, Dest->DEST_ALIAS, Entry, TRUE, FALSE);
+ SendRIFToOtherNeighbours(Dest, 0, Entry, TRUE, FALSE, FALSE, sendAlways);
if (Entry->STT >= 60000)
{
@@ -1703,6 +1854,9 @@ VOID SendNegativeInfo()
// I think I need to set lastTT on all routes.
+ // This should now only happen if there are no more routes but leave oode here in case needed again
+
+
if (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR == 0) // No other INP3 routes
{
if (DEBUGINP3) Debugprintf("Was the only INP3 route");
@@ -1750,7 +1904,7 @@ VOID SendPositiveInfo()
Entry = &Dest->INP3ROUTE[0];
if (Entry->ROUT_NEIGHBOUR)
- SendRIFToOtherNeighbours(Dest, Dest->DEST_ALIAS, Entry, FALSE, FALSE);
+ SendRIFToOtherNeighbours(Dest, 0, Entry, FALSE, FALSE, FALSE, FALSE);
}
}
@@ -1777,7 +1931,7 @@ VOID SendNewInfo()
Entry = &Dest->INP3ROUTE[0];
- SendRIFToOtherNeighbours(Dest, Dest->DEST_ALIAS, Entry, TRUE, FALSE); // Send as negative so will always be worse than zero
+ SendRIFToOtherNeighbours(Dest, Dest->DEST_ALIAS, Entry, TRUE, FALSE, TRUE, TRUE); // Send as negative with sendAlways set so will always be sent
}
}
}
@@ -1813,12 +1967,10 @@ VOID sendAlltoOneNeigbour(struct ROUTE * Route)
if (Msg == 0)
return;
- if (Route->OldBPQ == 1)
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], MYCALL, MYALIASTEXT, 1, Route->TXRTTIncrement * 10, Call);
- else if (Route->OldBPQ == 2)
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], MYCALL, MYALIASTEXT, 1, Route->TXRTTIncrement, Call);
+ if (Route->mSRIF == 1)
+ Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], MYCALL, MYALIASTEXT, 1, Route->TXRTTIncrement * 10, Call, 0);
else
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], MYCALL, MYALIASTEXT, 1, 1, Call);
+ Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], MYCALL, MYALIASTEXT, 1, 1, Call, 0);
for (App = 0; App < NumberofAppls; App++)
{
@@ -1826,12 +1978,10 @@ VOID sendAlltoOneNeigbour(struct ROUTE * Route)
if (APPL->APPLQUAL > 0)
{
- if (Route->OldBPQ == 1)
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, Route->TXRTTIncrement * 10, Call);
- else if (Route->OldBPQ == 2)
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, Route->TXRTTIncrement, Call);
+ if (Route->mSRIF == 1)
+ Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, Route->TXRTTIncrement * 10, Call, 0);
else
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, 1, Call);
+ Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], APPL->APPLCALL, APPL->APPLALIAS_TEXT, 1, 1, Call, 0);
}
}
@@ -1877,10 +2027,10 @@ VOID sendAlltoOneNeigbour(struct ROUTE * Route)
if (Msg)
{
- if (Route->OldBPQ == 1)
+ if (Route->mSRIF == 1)
sendTT *= 10;
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], Dest->DEST_CALL, Dest->DEST_ALIAS, sendHops, sendTT, Call);
+ Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH], Dest->DEST_CALL, Dest->DEST_ALIAS, sendHops, sendTT, Call, 0);
if (Msg->LENGTH > 250 - 15)
{
@@ -1902,11 +2052,9 @@ VOID sendAlltoOneNeigbour(struct ROUTE * Route)
VOID SendAllInfo()
{
- time_t Now = time(NULL);
-
if (routeCount == 0) // Not sending
{
- if (RIFInterval == 0 || (Now - SENDRIFTIME) < RIFInterval) // Time for new send?
+ if (RIFInterval == 0 || (NOW - SENDRIFTIME) < RIFInterval) // Time for new send?
return;
Route = NEIGHBOURS;
@@ -1923,7 +2071,7 @@ VOID SendAllInfo()
{
//cycle finished
- SENDRIFTIME = Now;
+ SENDRIFTIME = NOW;
routeCount = 0;
return;
}
@@ -1938,11 +2086,78 @@ VOID SendAllInfo()
{
//cycle finished
- SENDRIFTIME = Now;
+ SENDRIFTIME = NOW;
routeCount = 0;
}
}
+int INP3NodeTimeout = 3600 * 3; // 3 Hours
+
+void DecayINP3Routes()
+{
+ // Runs every 10 secs
+
+ // Invalidate routes that haven't been refreshed for a while (if neighbour is sending periodic refresh)
+
+ struct DEST_LIST * Dest = DESTS;
+ struct INP3_DEST_ROUTE_ENTRY * Entry;
+ int i, n;
+ time_t xx;
+
+ for (i=0; i < MAXDESTS; i++)
+ {
+ if (Dest->DEST_CALL == 0)
+ {
+ Dest++;
+ continue;
+ }
+
+ for (n = 0; n < 3; n++)
+ {
+ Entry = &Dest->INP3ROUTE[n];
+
+ if (Entry->ROUT_NEIGHBOUR == 0) // Stop on first unused entry
+ break;
+
+ xx = NOW - Entry->LastRefreshed;
+
+ if (Entry->ROUT_NEIGHBOUR->timeoutRoutes && Entry->LastRefreshed && (Entry->LastRefreshed + INP3NodeTimeout) < NOW)
+ {
+ char Call1[10];
+ char Call2[10];
+ Call1[ConvFromAX25(Dest->DEST_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(Entry->ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+
+ if (DEBUGINP3) Debugprintf("Timer Deleting INP3 Route %d to %s via %s", n + 1, Call1, Call2);
+
+ if (n == 0)
+ {
+ // if removing best we need to tell others
+
+ Entry->STT = 60000; // leave hops so we can check if we need to send
+
+ if (Dest->DEST_ROUTE == 4) // we were using it
+ Dest->DEST_ROUTE = 0;
+
+ }
+ else
+ {
+ // If we aren't removing the best, we don't need to tell anyone.
+
+ if (n == 1) // 2nd
+ {
+ memcpy(&Dest->INP3ROUTE[1], &Dest->INP3ROUTE[2], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memset(&Dest->INP3ROUTE[2], 0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ }
+ else
+ memset(&Dest->INP3ROUTE[2], 0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ }
+ }
+ }
+ Dest++;
+ }
+}
+
VOID INP3TIMER()
{
if (RTTMsg.ID[0] == 0)
@@ -1969,7 +2184,7 @@ VOID INP3TIMER()
if (NegTimerCount == 0)
{
NegTimerCount = NegativeDelay;
- SendNegativeInfo();
+ SendNegativeInfo(FALSE); // only if significant change
}
else
NegTimerCount--;
@@ -1977,9 +2192,9 @@ VOID INP3TIMER()
if (RIPTimerCount == 0)
{
RIPTimerCount = 10;
-
SendRIPTimer();
SendAllInfo(); // Timer Driven refresh
+ DecayINP3Routes();
}
else
RIPTimerCount--;
@@ -2040,6 +2255,7 @@ UCHAR * DisplayINP3RIF(UCHAR * ptr1, UCHAR * ptr2, int msglen)
// Process optional fields
+
while (*ptr1 && msglen > 0) // Have an option
{
len = *ptr1;
@@ -2092,3 +2308,369 @@ int inp3_tt2qual (int tt, int hops)
return(qual);
}
+
+/*
+
+5.2 XRouter Extensions
+
+The following identifiers are used in XRouter:
+
+Type 0x01: AMPRNet IP Routing Data
+Value: Exactly 7 bytes total length (Option Length = 0x07).
+Contains a 4-byte IPv4 address within the 44.0.0.0/8 amateur
+network (in network byte order) followed by a 1-byte packed
+hostmask prefix length (e.g., 0x18 for a /24).
+
+Type 0x10: Geographic Position
+Value: Exactly 10 bytes total length. Contains two 32-bit signed
+Big-Endian integers: Latitude followed by Longitude, expressed in
+hundredths of a minute of arc.
+
+Type 0x12: Metadata Timestamp
+Value: Exactly 6 bytes total length. Contains a 32-bit unsigned
+integer tracking standard Unix epoch time.
+
+Type 0x13: TCP Service Port
+Value: Exactly 4 bytes total length. A 16-bit unsigned integer
+defining the active TCP port for user terminal access. Used in
+conjunction with a Type 0x01 option.
+
+Type 0x14: Timezone Offset
+Value: Exactly 4 bytes total length. A 16-bit signed integer
+defining the local timezone offset relative to GMT, measured in
+minutes (e.g., -60).
+
+Type 0x15: Maidenhead Locator
+Value: A variable-length ASCII string representing the station
+locator (e.g., IO83VK) with no null termination.
+
+Type 0x16: QTH (Location Description)
+Value: A variable-length plain ASCII string describing the
+station's physical location (e.g., Niagara Park) with no null
+termination.
+
+Type 0x17: Software Version String
+Value: A variable-length ASCII string representing the node
+application's compile version (e.g., 501w) with no null
+termination.
+
+5.3 Detailed Flags Specification (Option 0x11)
+
+Following the length byte (0x05) and type byte (0x11), this option
+contains three sequential 1-byte fields:
+
++------------+------------+---------+---------+---------+
+| len=0x05 | typ=0x11 | swtype | flags1 | flags_2 |
++------------+------------+---------+---------+---------+
+Figure 4: Structure of the Option 0x11 Payload
+
+5.3.1 Software Type (sw_type)
+
+A 1-byte integer identifying the node software:
+
+0 = Unknown, 1 = BPQ16 (DOS), 2 = XRouter16 (DOS),
+3 = XServ16 (DOS), 4 = XRouter32 (Win GUI), 5 = XR32 (Win TUI),
+6 = XS32 (Win TUI BBS), 7 = XRLin (Linux x86),
+8 = XRouter (Raspberry Pi), 9 = BPQ32 (Windows),
+10 = BPQ32 (Linux).
+
+5.3.2 Capability Flags 1 (flags_1)
+
+A 1-byte bitmask detailing supported network layer features:
+
+0x01 = INP3 Capable
+0x02 = NetRom L3 routing enabled
+0x04 = Capable of Netrom Record Route
+0x08 = Capable of Netrom Control Message Protocol
+0x10 = Capable of NetRomX (CREQX)
+0x20 = Supports NDP (Netrom Datagram Protocol)
+0x40 = Node is a GlobalNet router/host
+0x80 = Supports IP over NetRom
+5.3.3 Capability Flags 2 (flags_2)
+
+A 1-byte bitmask detailing hosted application services:
+
+0x01 = Has general purpose L7 command line
+0x02 = Is/Has PMS (Mailbox)
+0x04 = Is/Has XR Chat
+0x08 = Is/Has BPQ/Roundtable chat
+0x10 = Is/Has BBS
+0x20 = Is/Has DX Cluster
+0x40 = Is/Has RMS gateway
+0x80 = Reserved (extension bit)
+
+G8PZT-1:XRLN64} Knoten:
+Info for: KIDDER:G8PZT (HOST) [XRPi] FR=13203 RTT=0.17 Hop=1 XR {PEER}
+ Pos=52.4000N 2.2500W Loc=IO82VJ Qth=KIDDERMINSTER, UK
+ IP=44.136.16.50/32 TCP=23 v505G OFF
+ Supports: INP3 L3ROUT NRR NCMP L4X NDP
+ BBS XRCHAT RTCHAT
+ Updated: 02/07 13:40 Confirmed: 01/07 14:49
+
+*/
+
+UCHAR * SkipOptions(UCHAR * ptr1, int msglen)
+{
+ int len, opcode;
+
+ // Skip options and return pointer to next entry
+
+ while (*ptr1 && msglen > 0)
+ {
+ len = *ptr1;
+ opcode = *(ptr1+1);
+
+ if (len < 2 || len > msglen)
+ return 0; // Duff RIF
+
+ ptr1+=len;
+ msglen -=len;
+ }
+
+ return ptr1;
+}
+
+/*
+// See if any XR options to add
+
+ if (memcmp(Options, &noOptions, sizeof(noOptions)) != 0)
+ {
+ if (Dest->XROptions == 0) // None yet
+ Dest->XROptions = zalloc(sizeof(noOptions));
+
+ // Have options so copy across any new ones
+
+ if (Options->IPADDR)
+ {
+ Dest->XROptions->IPADDR = Options->IPADDR;
+ Dest->XROptions->Mask = Options->Mask; // Always come togther
+ }
+ if (Options->Lat)
+ Dest->XROptions->Lat = Options->Lat;
+
+ if (Options->Lon)
+ Dest->XROptions->Lon = Options->Lon;
+
+ if (Options->Port)
+ Dest->XROptions->Port = Options->Port;
+
+ if (Options->Time)
+ Dest->XROptions->Time = Options->Time;
+
+ if (Options->TZOffset)
+ Dest->XROptions->TZOffset = Options->TZOffset;
+
+ if (Options->LOC)
+ {
+ if (Dest->XROptions->LOC)
+ free(Dest->XROptions->LOC);
+
+ Dest->XROptions->LOC = _strdup(Options->LOC);
+ }
+
+ if (Options->QTH)
+ {
+ if (Dest->XROptions->QTH)
+ free(Dest->XROptions->QTH);
+
+ Dest->XROptions->QTH = _strdup(Options->QTH);
+ }
+
+ if (Options->Ver)
+ {
+ if (Dest->XROptions->Ver)
+ free(Dest->XROptions->Ver);
+
+ Dest->XROptions->Ver = _strdup(Options->Ver);
+ }
+
+ if (Options->SWType | Options->NetworkFlags | Options->ApplFlags) // All come together
+ {
+ Dest->XROptions->SWType = Options->SWType;
+ Dest->XROptions->NetworkFlags = Options->NetworkFlags;
+ Dest->XROptions->ApplFlags = Options->ApplFlags;
+ }
+ }
+*/
+
+
+
+void DecodeRIFOptions(struct DEST_LIST * Dest, UCHAR * ptr1)
+{
+ int len, opcode;
+
+ // Options should be saved and sent out as received, including any unrecongnised ones
+ // Do we need to worry about getting different subsets of values at different times,
+ // so we need to combine new nodes with any existing ones??
+
+ // We treat alias separately as that is sent by all software
+
+ int rawoptionslen = 0;
+ unsigned char * startoptions = ptr1;
+ int gotOptions = 0;
+ XROptions * Options = Dest->XROptions;
+
+
+ while (*ptr1) // Format already checked above
+ {
+ len = *ptr1;
+ opcode = *(ptr1+1);
+
+ if (len < 2)
+ return; // Duff RIF
+
+ if (opcode)
+ {
+ // Not alias so we need extended options field
+
+ gotOptions = 1;
+
+ if (Options == 0)
+ {
+ Options = Dest->XROptions = zalloc(sizeof(XROptions));
+ }
+ }
+
+ switch (opcode)
+ {
+ case 0: // Alias
+
+ memset(Dest->DEST_ALIAS, ' ', 6);
+
+ if (len > 1 && len < 9)
+ memcpy(Dest->DEST_ALIAS, ptr1+2, len-2);
+ break;
+
+ case 1: // IP Address and Mask
+
+ if (len == 7)
+ {
+ memcpy(&Options->IPADDR, ptr1+2, 4);
+ Options->Mask = (uint8_t)ptr1[6];
+ }
+ break;
+
+ case 0x10: // Geographic Position
+
+ if (len == 10)
+ {
+ uint32_t w1;
+ int32_t w2;
+
+ memcpy(&w1, ptr1+2, 4);
+ w2 = htonl(w1);
+
+ Options->Lat = w2 / 6000.0; // 1/100th minute to degrees
+
+ memcpy(&w1, ptr1+6, 4);
+ w2 = htonl(w1);
+
+ Options->Lon = w2 / 6000.0;
+ break;
+ }
+
+
+ case 0x11: // Various flags
+
+ if (len == 5)
+ {
+ Options->SWType = ptr1[2];
+ Options->NetworkFlags = ptr1[3];
+ Options->ApplFlags = ptr1[4];
+ break;
+ }
+
+ case 0x12: // Metadata Timestamp
+
+ if (len == 6)
+ {
+ uint32_t w1;
+
+ memcpy(&w1, ptr1+2, 4);
+ Options->Time = htonl(w1);
+ }
+
+ break;
+
+ case 0x13: // TCP Service Port
+
+ if (len == 4)
+ {
+ uint16_t w1;
+
+ memcpy(&w1, ptr1+2, 2);
+ Options->Port = htons(w1);
+ }
+
+ case 0x14: // Timezone Offset
+
+ if (len == 4)
+ {
+ uint16_t w1;
+
+ memcpy(&w1, ptr1+2, 2);
+ Options->TZOffset = htons(w1);
+ }
+
+ break;
+
+ case 0x15: // Maidenhead Locator
+
+ if (Options->LOC)
+ free (Options->LOC);
+
+ Options->LOC = zalloc(len);
+ memcpy(Options->LOC, ptr1+2, len-2);
+
+ break;
+
+ case 0x16: // QTH (Location Description)
+
+ if (Options->QTH)
+ free (Options->QTH);
+
+ Options->QTH = zalloc(len);
+ memcpy(Options->QTH, ptr1+2, len-2);
+
+ case 0x17: // Software Version String
+
+ if (Options->Ver)
+ free (Options->Ver);
+
+ Options->Ver = zalloc(len);
+ memcpy(Options->Ver, ptr1+2, len-2);
+
+ }
+
+ ptr1+=len;
+ }
+
+ // ptr1 points to byte beyond end of options. Save the options string. Put length byte on front
+
+
+ if (gotOptions == 0) // Empty
+ return;
+
+ if (Options) // Have other than alias
+ {
+ rawoptionslen = (ptr1 - startoptions) + 1; // include terminating null
+
+ if (Options->Optionslist)
+ {
+ // see if changed (not much use if options include timestamp)
+
+ if (Options->Optionslist[0] == rawoptionslen && memcmp(&Options->Optionslist[1], startoptions, rawoptionslen) == 0)
+ return;
+
+ free(Options->Optionslist);
+ }
+
+ Options->Optionslist = malloc(rawoptionslen + 1);
+ Options->Optionslist[0] = rawoptionslen;
+ memcpy(&Options->Optionslist[1], startoptions, rawoptionslen);
+ }
+
+ return;
+
+}
+
diff --git a/BPQMail.aps b/BPQMail.aps
deleted file mode 100644
index 73fb296..0000000
--- a/BPQMail.aps
+++ /dev/null
Binary files differ
diff --git a/BPQMail.c b/BPQMail.c
index b1e361b..5300836 100644
--- a/BPQMail.c
+++ b/BPQMail.c
@@ -1163,6 +1163,12 @@
// Fix possible crash in SendBBSDataToPktMap
// Remove Uncompressed Blocked forwarding (27)
// Fix mail api returning garbage when deflate isn't requested (27)
+// Fix PG command processing on 64 bit Linux (31)
+// Limit L command output for new users (32)
+// Allow lower case SMTP/POP3 commands (39)
+// Fix Webmail Send Reply with SMTP server messages (39)
+// Fix paging in PG server (39)
+// Fix crash in Webmail display message if message doesn't exist or isn't for you (41)
#include "bpqmail.h"
diff --git a/BPQMail.rc b/BPQMail.rc
index 88d1116..26e48ab 100644
--- a/BPQMail.rc
+++ b/BPQMail.rc
@@ -16,7 +16,7 @@
#include "AFXRES.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#define MAILCHAT
-#include "..\CommonSource\Versions.h"
+#include "Versions.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
diff --git a/BPQNRR.c b/BPQNRR.c
index 2360aa9..2bcab5c 100644
--- a/BPQNRR.c
+++ b/BPQNRR.c
@@ -78,8 +78,8 @@ VOID NRRecordRoute(UCHAR * Buff, int Len)
UCHAR * BUFFER = GetBuff();
UCHAR * ptr1;
struct _MESSAGE * Msg1;
- time_t Now = time(NULL);
int ID = (Msg->L4TXNO << 8) | Msg->L4RXNO;
+ int RTT = (int)GetTickCount() - NRRSession->NRRTicks;
if (BUFFER == NULL)
return;
@@ -96,10 +96,13 @@ VOID NRRecordRoute(UCHAR * Buff, int Len)
*ptr1++ = 0xf0; // PID
- if (ID == NRRSession->NRRID)
- ptr1 += sprintf(ptr1, "NRR Response in %d Secs:", (int)(Now - NRRSession->NRRTime));
+ if (ID == NRRSession->NRRID)
+ if (RTT < 1000)
+ ptr1 += sprintf(ptr1, "NRR Response in %dmS:", RTT);
+ else
+ ptr1 += sprintf(ptr1, "NRR Response in %2.2fs:", RTT / 1000.0f);
else
- ptr1 += sprintf(ptr1, "NRR Response:", (int)(Now - NRRSession->NRRTime));
+ ptr1 += sprintf(ptr1, "NRR Response:");
Buff += 21 + MSGHDDRLEN;
Len -= (21 + MSGHDDRLEN);
@@ -206,8 +209,9 @@ VOID SendNRRecordRoute(struct DEST_LIST * DEST, TRANSPORTENTRY * Session)
Msg->LENGTH = 8 + 21 + MSGHDDRLEN;
- Session->NRRTime = time(NULL);
+ Session->NRRTicks = GetTickCount();
Session->NRRID = NRRID++;
C_Q_ADD(&DEST->DEST_Q, Msg);
}
+
diff --git a/BPQTermMDI.c b/BPQTermMDI.c
index 9f9ba44..9d3049d 100644
--- a/BPQTermMDI.c
+++ b/BPQTermMDI.c
@@ -75,6 +75,9 @@
#include "bpq32.h" // BPQ32 API Defines
#define BPQTermMDI
+extern time_t NOW; // From time()
+
+
#ifndef MDIKERNEL
#include "Versions.h"
@@ -109,17 +112,6 @@ VOID __cdecl Debugprintf(const char * format, ...);
HKEY REGTREE = HKEY_LOCAL_MACHINE; // Default
-VOID __cdecl Debugprintf(const char * format, ...)
-{
- char Mess[1000];
- va_list(arglist);int Len;
-
- va_start(arglist, format);
- Len = vsprintf_s(Mess, sizeof(Mess), format, arglist);
- strcat(Mess, "\r\n");
- OutputDebugString(Mess);
- return;
-}
#else
extern HKEY REGTREE;
extern int OffsetH, OffsetW;
@@ -349,7 +341,6 @@ VOID MonitorAPRSIS(char * Msg, int MsgLen, BOOL TX)
int Len;
struct tm * TM;
- time_t NOW;
if (MonWindow.hConsole == NULL || MonitorAPRS == 0)
return;
@@ -357,7 +348,6 @@ VOID MonitorAPRSIS(char * Msg, int MsgLen, BOOL TX)
if (MsgLen > 250)
return;
- NOW = _time32(NULL);
TM = gmtime(&NOW);
// Mustn't change Msg
diff --git a/BPQTermTCP.h b/BPQTermTCP.h
new file mode 100644
index 0000000..d230864
--- /dev/null
+++ b/BPQTermTCP.h
@@ -0,0 +1,90 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by BPQTermTCP.rc
+//
+#define IDR_MENU1 101
+#define BPQMENU 101
+#define BPQDISCONNECT 103
+#define IDD_CONFIG 104
+#define IDD_FONT 105
+#define IDD_ALERTDLG 106
+#define IDD_LISTEN 107
+
+#define MONITOR_ADDPORT 400
+#define IDC_HOST 1004
+#define IDC_PORT 1005
+#define IDC_USER 1006
+#define IDC_PASS 1007
+#define IDC_FONTWIDTH 1008
+#define IDC_FONTNAME 1009
+#define IDC_CODEPAGE 1010
+#define IDC_CHARSET 1011
+#define IDC_FONTSIZE 1012
+#define IDC_AUTO 1013
+#define IDC_1251 1014
+#define IDC_1252 1015
+#define IDC_437 1016
+#define IDC_UTF8 1017
+#define IDC_Send1251 1018
+#define IDC_Send1252 1019
+#define IDC_ALERTINTERVAL 1020
+#define IDC_RADIO1 1021
+#define IDC_RADIO2 1022
+#define IDC_ALERTFILENAME 1023
+#define IDC_PLAYFILENAME 1023
+#define IDC_FREQ 1024
+#define IDC_DURATION 1025
+#define IDC_USEKEYWORDS 1026
+#define IDC_ALERTKEYNAME 1027
+#define IDC_LISTENPORT 1028
+
+#define BPQMTX 1164
+#define BPQMCOM 1165
+#define BPQCOPYMON 1166
+#define BPQCOPYOUT 1167
+#define BPQCLEARMON 1168
+#define BPQCLEAROUT 1169
+#define BPQBELLS 1170
+#define BPQCHAT 1171
+#define BPQHELP 1172
+#define BPQStripLF 1173
+#define BPQLogOutput 1174
+#define BPQLogMonitor 1175
+#define BPQSendDisconnected 1176
+#define BPQMNODES 1177
+#define MONCOLOUR 1178
+#define CHATTERM 1179
+#define MUIONLY 1180
+#define BPQPORT 1181
+#define BPQENABLE 1182
+#define YAPPSEND 1200
+#define YAPPDIR 1201
+#define BPQAUTOCONNECT 40001
+#define BPQAPPL1 40002
+#define BPQAPPL2 40003
+#define BPQAPPL3 40004
+#define BPQAPPL4 40005
+#define BPQAPPL6 40006
+#define BPQAPPL7 40007
+#define BPQAPPL8 40008
+#define BPQAPPL5 40009
+#define BPQFLAGS1 40010
+#define BPQFLAGS2 40011
+#define BPQFLAGS3 40012
+#define BPQFLAGS4 40013
+#define ID_SETUP_FONT 40025
+#define ID_SETUP_ALERTSETUP 40026
+#define BPQCONNECT1 40101
+#define IDC_HOST1 40201
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_COMMAND_VALUE 40027
+#define _APS_NEXT_CONTROL_VALUE 1027
+#define _APS_NEXT_SYMED_VALUE 104
+#endif
+#endif
diff --git a/BPQTermTCP.ini b/BPQTermTCP.ini
new file mode 100644
index 0000000..3fe4d61
--- /dev/null
+++ b/BPQTermTCP.ini
@@ -0,0 +1,20 @@
+[Session 1]
+PortMask=0
+Bells=0
+StripLF=0
+MTX=1
+MCOM=1
+MUIONLY=0
+Split=50
+MONColour=0
+MonNODES=1
+MonPorts=0
+ChatMode=0
+CurrentHost=0
+Size=34,650,47,669
+FontName=Courier New
+CharSet=0
+CodePage=437
+FontSize=20
+FontWidth=8
+AlertInterval=3600
diff --git a/BPQTermTCP.rc b/BPQTermTCP.rc
new file mode 100644
index 0000000..c44d16a
--- /dev/null
+++ b/BPQTermTCP.rc
@@ -0,0 +1,336 @@
+//Microsoft Developer Studio generated resource script.
+//
+#define TermTCP
+#include "bpqtermTCP.h"
+
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "afxres.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "winver.h"
+#define BPQBASE 1100
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ALERTDLG DIALOG DISCARDABLE 0, 0, 250, 121
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Alert Settings"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,62,100,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,137,100,50,14
+ LTEXT "Alert After Interval",IDC_STATIC,7,9,65,9,
+ SS_CENTERIMAGE
+ EDITTEXT IDC_ALERTINTERVAL,83,8,29,13,ES_AUTOHSCROLL
+ CONTROL "Beep",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,7,27,33,15
+ CONTROL "Play File",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,7,50,
+ 52,14
+ EDITTEXT IDC_ALERTFILENAME,83,49,151,15,ES_AUTOHSCROLL
+ LTEXT "Freq",IDC_STATIC,47,30,15,8
+ LTEXT "Duration",IDC_STATIC,120,30,28,8
+ EDITTEXT IDC_FREQ,83,28,29,13,ES_AUTOHSCROLL
+ EDITTEXT IDC_DURATION,154,28,29,13,ES_AUTOHSCROLL
+ CONTROL "Use Keyword File",IDC_USEKEYWORDS,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,73,71,10
+ EDITTEXT IDC_ALERTKEYNAME,83,72,151,15,ES_AUTOHSCROLL
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_ALERTDLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 243
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 114
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+BPQMAINWINDOW DIALOG DISCARDABLE 17, 25, 300, 300
+STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
+ WS_THICKFRAME
+CAPTION "BPQTerminal Version 1.0.0"
+MENU MENU_1
+CLASS "BPQMAINWINDOW"
+FONT 8, "FixedSys"
+BEGIN
+ LISTBOX 116,5,6,290,134,LBS_MULTIPLESEL | LBS_OWNERDRAWFIXED |
+ LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
+ WS_HSCROLL
+ EDITTEXT 118,5,280,440,15,ES_AUTOHSCROLL | ES_NOHIDESEL
+ CTEXT "",119,0,145,300,5,SS_NOTIFY
+END
+
+IDD_CONFIG DIALOG DISCARDABLE 0, 0, 181, 129
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "TCP Host Config"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "Host",IDC_STATIC,7,15,24,9
+ EDITTEXT IDC_HOST,46,13,114,12,ES_AUTOHSCROLL
+ LTEXT "Port",IDC_STATIC,7,32,24,9
+ EDITTEXT IDC_PORT,46,30,53,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "User",IDC_STATIC,7,49,24,9
+ EDITTEXT IDC_USER,46,47,89,12,ES_AUTOHSCROLL
+ LTEXT "Password",IDC_STATIC,7,66,39,9
+ EDITTEXT IDC_PASS,46,64,90,12,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "Save",IDOK,33,91,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,95,91,50,14
+END
+
+IDD_LISTEN DIALOG DISCARDABLE 0, 0, 181, 129
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "TCP Listen Config"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "Port",IDC_STATIC,7,32,24,9
+ EDITTEXT IDC_LISTENPORT,46,30,53,12,ES_AUTOHSCROLL | ES_NUMBER
+ DEFPUSHBUTTON "Save",IDOK,33,91,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,95,91,50,14
+END
+
+
+IDD_FONT DIALOG DISCARDABLE 0, 0, 187, 206
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Font Setup"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "Save",IDOK,39,182,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,92,182,50,14
+ LTEXT "Font Width",IDC_STATIC,7,166,41,9
+ EDITTEXT IDC_FONTWIDTH,53,164,39,12,ES_AUTOHSCROLL | ES_NUMBER
+ EDITTEXT IDC_FONTSIZE,53,149,38,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "Font Size",IDC_STATIC,7,151,44,9
+ LTEXT "Interpret non-UTF8 input as",IDC_STATIC,7,10,96,11
+ CONTROL "Auto",IDC_AUTO,"Button",BS_AUTORADIOBUTTON,15,25,31,10
+ CONTROL "CP1251 (Cyrillic)",IDC_1251,"Button",BS_AUTORADIOBUTTON,
+ 15,40,67,10
+ CONTROL "CP1252 (Western Europe)",IDC_1252,"Button",
+ BS_AUTORADIOBUTTON,15,55,99,10
+ CONTROL "CP437 (Windows Line Draw)",IDC_437,"Button",
+ BS_AUTORADIOBUTTON,15,70,107,10
+ LTEXT "Send as",IDC_STATIC,7,85,27,8
+ CONTROL "UTF8",IDC_UTF8,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
+ 15,100,34,10
+ CONTROL "CP1251",IDC_Send1251,"Button",BS_AUTORADIOBUTTON,15,115,
+ 41,10
+ CONTROL "CP1252",IDC_Send1252,"Button",BS_AUTORADIOBUTTON,15,130,
+ 41,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_CONFIG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 174
+ TOPMARGIN, 6
+ BOTTOMMARGIN, 122
+ END
+
+ IDD_FONT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 180
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 199
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "bpqtermTCP.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""..\\cinclude\\afxres.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""winver.h""\r\n"
+ "#define BPQBASE 1100\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""..\\CommonSource\\Versions.h""\r\n"
+ "#include ""..\\StdVer.inc""\r\n"
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Cursor
+//
+
+IDC_DRAGSIZE CURSOR DISCARDABLE "DragSize.cur"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+MENU_1 MENU DISCARDABLE
+BEGIN
+ POPUP "Connect"
+ BEGIN
+ MENUITEM "Host 1", BPQCONNECT1
+ MENUITEM "Host 2", 40102
+ MENUITEM "Host 3", 40103
+ MENUITEM "Host 4", 40104
+ MENUITEM "Host 5", 40105
+ MENUITEM "Host 6", 40106
+ MENUITEM "Host 7", 40107
+ MENUITEM "Host 8", 40108
+ MENUITEM "Host 9", 40109
+ MENUITEM "Host 10", 40110
+ MENUITEM "Host 11", 40111
+ MENUITEM "Host 12", 40112
+ MENUITEM "Host 13", 40113
+ MENUITEM "Host 14", 40114
+ MENUITEM "Host 15", 40115
+ MENUITEM "Host 16", 40116
+ END
+ MENUITEM "Disconnect", BPQDISCONNECT
+
+ POPUP "Listen"
+ BEGIN
+ MENUITEM "Enable", BPQENABLE
+ MENUITEM "Port", BPQPORT
+ END
+
+ POPUP "Setup"
+ BEGIN
+ POPUP "TCP Hosts"
+ BEGIN
+ MENUITEM "Host 1", IDC_HOST1
+ MENUITEM "Host 2", 40202
+ MENUITEM "Host 3", 40203
+ MENUITEM "Host 4", 40204
+ MENUITEM "Host 5", 40205
+ MENUITEM "Host 6", 40206
+ MENUITEM "Host 7", 40207
+ MENUITEM "Host 8", 40208
+ MENUITEM "Host 9", 40209
+ MENUITEM "Host 10", 40210
+ MENUITEM "Host 11", 40211
+ MENUITEM "Host 12", 40212
+ MENUITEM "Host 13", 40213
+ MENUITEM "Host 14", 40214
+ MENUITEM "Host 15", 40215
+ MENUITEM "Host 16", 40216
+ END
+ MENUITEM "Font Setup", ID_SETUP_FONT
+ MENUITEM "Enable Bells", BPQBELLS
+ MENUITEM "Strip Linefeeds", BPQStripLF
+ MENUITEM "Log Monitor", BPQLogMonitor
+ MENUITEM "Log Output", BPQLogOutput
+ MENUITEM "Chat Terminal Mode", CHATTERM
+ MENUITEM "Alert Setup", ID_SETUP_ALERTSETUP
+ END
+ POPUP "Monitor"
+ BEGIN
+ MENUITEM "Monitor TX", BPQMTX
+ MENUITEM "Monitor Supervisory", BPQMCOM
+ MENUITEM "Only monitor UI frames", MUIONLY
+ MENUITEM "Monitor NODES", BPQMNODES
+ MENUITEM "Enable Colour", MONCOLOUR
+ MENUITEM "Add Port", MONITOR_ADDPORT
+ END
+ POPUP "Edit"
+ BEGIN
+ MENUITEM "Copy Monitor Window", BPQCOPYMON
+ MENUITEM "Copy Output Window", BPQCOPYOUT
+ MENUITEM "Clear Monitor Window", BPQCLEARMON
+ MENUITEM "Clear Output Window", BPQCLEAROUT
+ END
+ POPUP "YAPP"
+ BEGIN
+ MENUITEM "Send File", YAPPSEND
+ MENUITEM "Set Receive Directory", YAPPDIR
+ END
+END
+
+#endif // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "Versions.h"
+#include "StdVer.inc"
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/BPQTerminal.c b/BPQTerminal.c
new file mode 100644
index 0000000..2b4b3a0
--- /dev/null
+++ b/BPQTerminal.c
@@ -0,0 +1,2413 @@
+
+// Version 2.0.1 November 2007
+
+// Change resizing algorithm
+
+
+// Version 2.0.2 January 2008
+
+// Restore Checked state of Bells and AutoConnect Flags
+// Call CheckTimer on startup (for new Initialisation Scheme for perl)
+
+// Version 2.0.3 July 2008
+
+// Display lines received without a terminaing CR
+
+
+// Version 2.0.4 November 2008
+
+// Add option to remove a Line Feed following a CR
+// Add Logging Option
+
+// Version 2.0.5 January 2009
+
+// Add Start Minimized Option
+
+// Version 2.0.6 June 2009
+
+// Add Option to send *** Disconnnected on disconnect
+// Add line wrap code
+// Add option not to monitor NODES broadcasts
+
+// Version 2.0.7 October 2009
+
+// Add input buffer scrollback.
+// Fix monitoring when PORTNUM specified
+
+// Version 2.0.8 December 2009
+
+// Fix use of numeric keypad 2 and 8 (were treated as up and down)
+
+// Version 2.0.9 March 2010
+
+// Add colour for monitor and BPQ Chat
+
+// Version 2.0.0 October 2010
+
+// Add Chat Terminal Mode (sends keepalives)
+
+// Version 2.1.0 August 2011
+
+// Add Copy/Paste capability to output window.
+// Add Font Selection
+// Get Registry Tree from BPQ32.dll
+// Add Command to reset Monitor/Output window split
+
+// Version 2.1.1 October 2011
+
+// Wrap overlong lines
+
+// Version 2.1.2 Jan 2012
+
+// Call CloseBPQ32 on exit
+// Fix ClearOutputWindow
+// Save MonitorNodes flag
+
+// Version 2.2.1 June 2012
+
+// Add UIOnly Monitor Option
+
+// Version 2.2.2.1 Nov 2014
+// Fix possible crash on processing part line
+
+
+// Version 2.2.3.1 Dec 2014
+// Remove "Enable Chat" option
+
+// Version 2.2.4.1 Dec 2015
+// Add Port Names to Monitor Config Menu
+
+
+// Add Chat Terminal Mode
+
+// Version 2.2.5.1 Sep 2019
+
+// Recompile for change to Port Struct
+
+// Version 2.2.5.2 May 2023
+// Changes for compatibility with 63 port BPQ32
+
+#define _USE_32BIT_TIME_T
+#define _CRT_SECURE_NO_DEPRECATE
+
+#define pthread_t DWORD
+#include "asmstrucs.h"
+
+#include <windows.h>
+#include <winstdint.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <memory.h>
+#include <htmlhelp.h>
+#include <Richedit.h>
+
+#include "bpqterminal.h"
+
+#define BPQBASE WM_USER
+//
+// Port monitoring flags use BPQBASE -> BPQBASE+100
+
+#include "bpq32.h" // BPQ32 API Defines
+#define BPQTerm
+#include "Versions.h"
+#include "GetVersion.h"
+
+#define BGCOLOUR RGB(236,233,216)
+
+HBRUSH bgBrush;
+
+UINT BPQMsg;
+
+HKEY FAR WINAPI GetRegistryKey();
+char * FAR WINAPI GetRegistryKeyText();
+
+HKEY REGTREE = HKEY_LOCAL_MACHINE; // Default
+
+HINSTANCE hInst;
+char AppName[] = "BPQTerm 32";
+char ClassName[] = "BPQMAINWINDOW";
+char Title[80];
+
+// Foward declarations of functions included in this code module:
+
+ATOM MyRegisterClass(CONST WNDCLASS*);
+BOOL InitApplication(HINSTANCE);
+BOOL InitInstance(HINSTANCE, int);
+LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
+int NewLine();
+
+int ProcessBuff(char * readbuff,int len);
+
+int EnableConnectMenu(HWND hWnd);
+int EnableDisconnectMenu(HWND hWnd);
+int DisableConnectMenu(HWND hWnd);
+int DisableDisconnectMenu(HWND hWnd);
+int ToggleAutoConnect(HWND hWnd);
+int DoReceivedData(HWND hWnd);
+int DoStateChange(HWND hWnd);
+int CopyScreentoBuffer(char * buff);
+int DoMonData(HWND hWnd);
+int TogglePort(HWND hWnd, int Item, uint64_t mask);
+int ToggleMTX(HWND hWnd);
+int ToggleMCOM(HWND hWnd);
+int ToggleMUI(HWND hWnd);
+int ToggleParam(HWND hWnd, BOOL * Param, int Item);
+int ToggleChat(HWND hWnd);
+void MoveWindows();
+void CopyListToClipboard(HWND hWnd);
+void CopyRichTextToClipboard(HWND hWnd);
+BOOL OpenMonitorLogfile();
+void WriteMonitorLine(char * Msg, int MsgLen);
+VOID WritetoOutputWindow(struct RTFTerm * OPData, char * Msg, int len);
+VOID DoRefresh(struct RTFTerm * OPData);
+INT_PTR CALLBACK FontConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+
+COLORREF Colours[256] = {0,
+ RGB(0,0,0), RGB(0,0,128), RGB(0,0,192), RGB(0,0,255), // 1 - 4
+ RGB(0,64,0), RGB(0,64,128), RGB(0,64,192), RGB(0,64,255), // 5 - 8
+ RGB(0,128,0), RGB(0,128,128), RGB(0,128,192), RGB(0,128,255), // 9 - 12
+ RGB(0,192,0), RGB(0,192,128), RGB(0,192,192), RGB(0,192,255), // 13 - 16
+ RGB(0,255,0), RGB(0,255,128), RGB(0,255,192), RGB(0,255,255), // 17 - 20
+
+ RGB(64,0,0), RGB(64,0,128), RGB(64,0,192), RGB(0,0,255), // 21
+ RGB(64,64,0), RGB(64,64,128), RGB(64,64,192), RGB(64,64,255),
+ RGB(64,128,0), RGB(64,128,128), RGB(64,128,192), RGB(64,128,255),
+ RGB(64,192,0), RGB(64,192,128), RGB(64,192,192), RGB(64,192,255),
+ RGB(64,255,0), RGB(64,255,128), RGB(64,255,192), RGB(64,255,255),
+
+ RGB(128,0,0), RGB(128,0,128), RGB(128,0,192), RGB(128,0,255), // 41
+ RGB(128,64,0), RGB(128,64,128), RGB(128,64,192), RGB(128,64,255),
+ RGB(128,128,0), RGB(128,128,128), RGB(128,128,192), RGB(128,128,255),
+ RGB(128,192,0), RGB(128,192,128), RGB(128,192,192), RGB(128,192,255),
+ RGB(128,255,0), RGB(128,255,128), RGB(128,255,192), RGB(128,255,255),
+
+ RGB(192,0,0), RGB(192,0,128), RGB(192,0,192), RGB(192,0,255), // 61
+ RGB(192,64,0), RGB(192,64,128), RGB(192,64,192), RGB(192,64,255),
+ RGB(192,128,0), RGB(192,128,128), RGB(192,128,192), RGB(192,128,255),
+ RGB(192,192,0), RGB(192,192,128), RGB(192,192,192), RGB(192,192,255),
+ RGB(192,255,0), RGB(192,255,128), RGB(192,255,192), RGB(192,2552,255),
+
+ RGB(255,0,0), RGB(255,0,128), RGB(255,0,192), RGB(255,0,255), // 81
+ RGB(255,64,0), RGB(255,64,128), RGB(255,64,192), RGB(255,64,255),
+ RGB(255,128,0), RGB(255,128,128), RGB(255,128,192), RGB(255,128,255),
+ RGB(255,192,0), RGB(255,192,128), RGB(255,192,192), RGB(255,192,255),
+ RGB(255,255,0), RGB(255,255,128), RGB(255,255,192), RGB(255,2552,255)
+};
+
+
+
+LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+LRESULT APIENTRY MonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+LRESULT APIENTRY SplitProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+
+
+WNDPROC wpOrigInputProc;
+WNDPROC wpOrigMonProc;
+WNDPROC wpOrigSplitProc;
+
+HWND hwndInput;
+HWND hwndOutput;
+HWND hwndMon;
+HWND hwndSplit;
+
+HMENU trayMenu;
+
+int xsize,ysize; // Screen size at startup
+
+double Split=0.5;
+int SplitPos=300;
+#define SplitBarHeight 5
+#define InputBoxHeight 25
+RECT Rect;
+RECT MonRect;
+RECT OutputRect;
+RECT SplitRect;
+
+int OutputBoxHeight;
+
+int Height, Width, LastY;
+
+int maxlinelen = 80;
+int CharWidth = 8;
+
+int ClientHeight, ClientWidth;
+
+
+#define MAXLINES 1000
+#define LINELEN 200
+
+char RTFHeader[4000];
+
+int RTFHddrLen;
+
+typedef struct RTFTerm
+{
+ int CurrentLine; // Line we are writing to in circular buffer.
+
+ int Index;
+ BOOL SendHeader;
+ BOOL Finished;
+
+ char OutputScreen[MAXLINES][LINELEN];
+
+ int Colourvalue[MAXLINES];
+ int LineLen[MAXLINES];
+ int CharWidth;
+ int CurrentColour;
+ int Thumb;
+ int FirstTime;
+ int RTFHeight; // Height of RTF control in pixels
+ BOOL Scrolled; // Window is scrolled back
+
+};
+
+char FontName[100] = "FixedSys";
+int FontSize = 20;
+int FontWidth = 8;
+int CodePage = 437;
+int CharSet = 0;
+
+
+struct RTFTerm OutputData;
+
+int CurrentHost = 0;
+int CfgNo = 0;
+
+SOCKET sock;
+
+BOOL MonData = FALSE;
+
+char Key[80];
+uint64_t portmask=0;
+int mtxparam=1;
+int mcomparam=1;
+int monUI = 0;
+
+char kbbuf[160];
+int kbptr=0;
+char readbuff[100000]; // for stupid bbs programs
+
+int ptr=0;
+
+int Stream;
+int len,count;
+
+char callsign[10];
+int state;
+int change;
+int applmask = 0;
+int applflags = 2; // Message to Application
+int Sessno = 0;
+
+int PartLinePtr=0;
+int PartLineIndex=0; // Listbox index of (last) incomplete line
+
+BOOL Bells = FALSE;
+BOOL StripLF = FALSE;
+BOOL LogMonitor = FALSE;
+BOOL LogOutput = FALSE;
+BOOL SendDisconnected = TRUE;
+BOOL MonitorNODES = TRUE;
+BOOL MonitorColour = TRUE;
+BOOL ChatMode = FALSE;
+
+HANDLE MonHandle=INVALID_HANDLE_VALUE;
+
+HCURSOR DragCursor;
+HCURSOR Cursor;
+
+CONNECTED=FALSE;
+AUTOCONNECT=TRUE;
+
+LOGFONT LFTTYFONT ;
+
+HFONT hFont ;
+
+BOOL MinimizetoTray=FALSE;
+//BOOL StartMinimized = FALSE;
+
+HWND MainWnd, hWnd;
+
+VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime );
+
+TIMERPROC lpTimerFunc = (TIMERPROC) TimerProc;
+
+int TimerHandle = 0;
+
+int SlowTimer;
+
+BOOL WINE;
+
+VOID __cdecl Debugprintf(const char * format, ...)
+{
+ char Mess[1000];
+ va_list(arglist);int Len;
+
+ va_start(arglist, format);
+ Len = vsprintf_s(Mess, sizeof(Mess), format, arglist);
+ strcat(Mess, "\r\n");
+ OutputDebugString(Mess);
+ return;
+}
+
+
+VOID CALLBACK TimerProc(
+
+ HWND hwnd, // handle of window for timer messages
+ UINT uMsg, // WM_TIMER message
+ UINT idEvent, // timer identifier
+ DWORD dwTime) // current system time
+{
+ // entered every 10 secs
+
+ CheckTimer();
+
+ if (!CONNECTED)
+ return;
+
+ if (!ChatMode)
+ return;
+
+ SlowTimer++;
+
+ if (SlowTimer > 50) // About 9 mins
+ {
+ SlowTimer = 0;
+ SendMsg(Stream, "\0", 1);
+ }
+}
+
+//
+// FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
+//
+// PURPOSE: Entry point for the application.
+//
+// COMMENTS:
+//
+// This function initializes the application and processes the
+// message loop.
+//
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ MSG msg;
+ int retCode, disp;
+ HKEY hKey=0;
+ char Size[80];
+
+/* PCHAR p1, p2, p3;
+
+ p1 = strtok(lpCmdLine, " ,\t\n\r");
+ p2 = strtok(NULL, " ,\t\n\r");
+ p3 = strtok(NULL, " ,\t\n\r");
+
+ if (nCmdShow == SW_SHOWMINIMIZED)
+ StartMinimized = TRUE;
+
+ if (p1)
+ {
+ if (strlen(p1) > 5)
+ {
+ if (_stricmp(p1, "StartMinimized") == 0)
+ StartMinimized = TRUE;
+
+ if (p2) Sessno = atoi(p2);
+ if (p3) sscanf(p3,"%x", &applflags);
+ }
+ else
+ {
+ if (p2)
+ {
+ if (strlen(p2) > 5)
+ {
+ if (_stricmp(p2, "StartMinimized") == 0)
+ StartMinimized = TRUE;
+
+ if (p1) Sessno = atoi(p1);
+ if (p3) sscanf(p3,"%x", &applflags);
+ }
+ }
+ else
+ {
+ if (p3)
+ {
+ if (strlen(p3) > 5)
+ {
+ if (_stricmp(p3, "StartMinimized") == 0)
+ StartMinimized = TRUE;
+
+ if (p1) Sessno = atoi(p1);
+ if (p2) sscanf(p2,"%x", &applflags);
+ }
+ }
+ }
+ }
+ }
+*/
+ sscanf(lpCmdLine,"%d %x",&Sessno, &applflags);
+
+ if (!InitApplication(hInstance))
+ return (FALSE);
+
+ if (!InitInstance(hInstance, nCmdShow))
+ return (FALSE);
+
+ // Main message loop:
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ // Save Config
+
+ retCode = RegCreateKeyEx(REGTREE,
+ Key,
+ 0, // Reserved
+ 0, // Class
+ 0, // Options
+ KEY_ALL_ACCESS,
+ NULL, // Security Attrs
+ &hKey,
+ &disp);
+
+ if (retCode == ERROR_SUCCESS)
+ {
+ retCode = RegSetValueEx(hKey,"AutoConnect",0,REG_DWORD,(BYTE *)&AUTOCONNECT,4);
+ retCode = RegSetValueEx(hKey,"PortMask",0,REG_BINARY,(BYTE *)&portmask, 8);
+ retCode = RegSetValueEx(hKey,"Bells",0,REG_DWORD,(BYTE *)&Bells,4);
+ retCode = RegSetValueEx(hKey,"StripLF",0,REG_DWORD,(BYTE *)&StripLF,4);
+ retCode = RegSetValueEx(hKey,"SendDisconnected",0,REG_DWORD,(BYTE *)&SendDisconnected,4);
+ retCode = RegSetValueEx(hKey,"MTX",0,REG_DWORD,(BYTE *)&mtxparam,4);
+ retCode = RegSetValueEx(hKey,"MCOM",0,REG_DWORD,(BYTE *)&mcomparam,4);
+ retCode = RegSetValueEx(hKey,"MUIONLY",0,REG_DWORD,(BYTE *)&monUI,4);
+ retCode = RegSetValueEx(hKey,"Split",0,REG_BINARY,(BYTE *)&Split,sizeof(Split));
+ retCode = RegSetValueEx(hKey,"MONColour",0,REG_DWORD,(BYTE *)&MonitorColour,4);
+ retCode = RegSetValueEx(hKey,"MonitorNODES",0,REG_DWORD,(BYTE *)&MonitorNODES,4);
+
+ wsprintf(Size,"%d,%d,%d,%d",Rect.left,Rect.right,Rect.top,Rect.bottom);
+ retCode = RegSetValueEx(hKey,"Size",0,REG_SZ,(BYTE *)&Size, strlen(Size));
+
+ RegCloseKey(hKey);
+ }
+
+ KillTimer(NULL, TimerHandle);
+
+ CloseBPQ32(); // Close Ext Drivers if last bpq32 process
+
+ return (msg.wParam);
+}
+
+//
+
+//
+// FUNCTION: InitApplication(HANDLE)
+//
+// PURPOSE: Initializes window data and registers window class
+//
+// COMMENTS:
+//
+// In this function, we initialize a window class by filling out a data
+// structure of type WNDCLASS and calling either RegisterClass or
+// the internal MyRegisterClass.
+//
+BOOL InitApplication(HINSTANCE hInstance)
+{
+ WNDCLASS wc;
+
+ bgBrush = CreateSolidBrush(BGCOLOUR);
+
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = WndProc;
+
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = DLGWINDOWEXTRA;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( BPQICON ) );
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = bgBrush;
+
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = ClassName;
+
+ return (RegisterClass(&wc));
+
+}
+
+HMENU hMenu, hPopMenu1, hPopMenu2, hPopMenu3; // handle of menu
+
+VOID SetupRTFHddr()
+{
+ int i, n;
+ char RTFColours[3000];
+ char Temp[1000];
+
+ // Set up RTF Header, including Colours String;
+
+ memcpy(RTFColours, "{\\colortbl ;", 12);
+ n = 12;
+
+ for (i = 1; i < 100; i++)
+ {
+ COLORREF Colour = Colours[i];
+ n += wsprintf(&RTFColours[n], "\\red%d\\green%d\\blue%d;", GetRValue(Colour), GetGValue(Colour),GetBValue(Colour));
+ }
+
+ RTFColours[n++] = '}';
+ RTFColours[n] = 0;
+
+// strcpy(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset204 ;}}");
+ wsprintf(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fprq1\\cpg%d\\fcharset%d %s;}}", CodePage, CharSet, FontName);
+ strcat(RTFHeader, RTFColours);
+ wsprintf(Temp, "\\viewkind4\\uc1\\pard\\f0\\fs%d", FontSize);
+ strcat(RTFHeader, Temp);
+
+ RTFHddrLen = strlen(RTFHeader);
+}
+
+
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ int i, n;
+ uint64_t tempmask=0x0;
+ char msg[50];
+ int retCode,Type,Vallen;
+ HKEY hKey=0;
+ char Size[80];
+ TEXTMETRIC tm;
+ HDC dc;
+ struct RTFTerm * OPData;
+ struct PORTCONTROL * PORT;
+
+ hInst = hInstance; // Store instance handle in our global variable
+
+ // See if running under WINE
+
+ retCode = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine", 0, KEY_QUERY_VALUE, &hKey);
+
+ if (retCode == ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ WINE = TRUE;
+ Debugprintf("Running under WINE");
+ }
+
+ REGTREE = GetRegistryKey();
+
+ MinimizetoTray=GetMinimizetoTrayFlag();
+
+ // Create a dialog box as the main window
+
+ hWnd=CreateDialog(hInst,ClassName,0,NULL);
+
+ if (!hWnd)
+ return (FALSE);
+
+ MainWnd=hWnd;
+
+ // Retrieve the handlse to the edit controls.
+
+ hwndInput = GetDlgItem(hWnd, 118);
+// hwndOutput = GetDlgItem(hWnd, 117);
+ hwndSplit = GetDlgItem(hWnd, 119);
+ hwndMon = GetDlgItem(hWnd, 116);
+
+ // Set our own WndProcs for the controls.
+
+ wpOrigInputProc = (WNDPROC) SetWindowLong(hwndInput, GWL_WNDPROC, (LONG) InputProc);
+ wpOrigMonProc = (WNDPROC)SetWindowLong(hwndMon, GWL_WNDPROC, (LONG)MonProc);
+ wpOrigSplitProc = (WNDPROC)SetWindowLong(hwndSplit, GWL_WNDPROC, (LONG)SplitProc);
+
+ // Get config from Registry
+
+ wsprintf(Key,"SOFTWARE\\G8BPQ\\BPQ32\\BPQTerminal\\Session%d",Sessno);
+
+ retCode = RegOpenKeyEx (REGTREE,
+ Key,
+ 0,
+ KEY_QUERY_VALUE,
+ &hKey);
+
+ if (retCode == ERROR_SUCCESS)
+ {
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"MTX",0,
+ (ULONG *)&Type,(UCHAR *)&mtxparam,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"MUIONLY",0,
+ (ULONG *)&Type,(UCHAR *)&monUI,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"MCOM",0,
+ (ULONG *)&Type,(UCHAR *)&mcomparam,(ULONG *)&Vallen);
+
+ Vallen=8;
+ retCode = RegQueryValueEx(hKey,"PortMask",0,
+ (ULONG *)&Type,(UCHAR *)&tempmask,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"AutoConnect",0,
+ (ULONG *)&Type,(UCHAR *)&AUTOCONNECT,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"MONColour",0,
+ (ULONG *)&Type,(UCHAR *)&MonitorColour,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"MonitorNODES",0,
+ (ULONG *)&Type,(UCHAR *)&MonitorNODES,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"Bells",0,
+ (ULONG *)&Type,(UCHAR *)&Bells,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey,"StripLF",0,
+ (ULONG *)&Type,(UCHAR *)&StripLF,(ULONG *)&Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey, "SendDisconnected",0,
+ (ULONG *)&Type,(UCHAR *)&StripLF,(ULONG *)&Vallen);
+
+
+
+ Vallen=8;
+ retCode = RegQueryValueEx(hKey,"Split",0,
+ (ULONG *)&Type,(UCHAR *)&Split,(ULONG *)&Vallen);
+
+ Vallen=80;
+ retCode = RegQueryValueEx(hKey,"Size",0,
+ (ULONG *)&Type,(UCHAR *)&Size,(ULONG *)&Vallen);
+
+ sscanf(Size,"%d,%d,%d,%d",&Rect.left,&Rect.right,&Rect.top,&Rect.bottom);
+
+ Vallen=99;
+ retCode = RegQueryValueEx(hKey, "FontName", 0, &Type, FontName, &Vallen);
+
+ if (FontName[0] == 0)
+ strcpy(FontName, "FixedSys");
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey, "CharSet", 0, &Type, (UCHAR *)&CharSet, &Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey, "CodePage", 0, &Type, (UCHAR *)&CodePage, &Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey, "FontSize", 0, &Type, (UCHAR *)&FontSize, &Vallen);
+
+ Vallen=4;
+ retCode = RegQueryValueEx(hKey, "FontWidth", 0, &Type, (UCHAR *)&FontWidth, &Vallen);
+
+ RegCloseKey(hKey);
+ }
+
+ OutputData.CharWidth = FontWidth;
+
+ if (Rect.right < 100 || Rect.bottom < 100)
+ {
+ GetWindowRect(hWnd, &Rect);
+ }
+
+ Height = Rect.bottom-Rect.top;
+ Width = Rect.right-Rect.left;
+
+#pragma warning(push)
+#pragma warning(disable:4244)
+ SplitPos=Height*Split;
+#pragma warning(pop)
+
+ SetupRTFHddr();
+
+ // Create a Rich Text Control
+
+ OPData = &OutputData;
+
+ OPData->SendHeader = TRUE;
+ OPData->Finished = TRUE;
+ OPData->CurrentColour = 1;
+
+ LoadLibrary("riched20.dll");
+
+ hwndOutput = CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, "",
+ WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_NOHIDESEL | WS_VSCROLL | ES_READONLY,
+ 6,145,290,130, MainWnd, NULL, hInstance, NULL);
+
+ // Register for Mouse Events for Copy/Paste
+
+ SendMessage(hwndOutput, EM_SETEVENTMASK, (WPARAM)0, (LPARAM)ENM_MOUSEEVENTS | ENM_SCROLLEVENTS | ENM_KEYEVENTS);
+ SendMessage(hwndOutput, EM_EXLIMITTEXT, 0, MAXLINES * LINELEN);
+
+ trayMenu = CreatePopupMenu();
+
+ AppendMenu(trayMenu,MF_STRING,40000,"Copy");
+
+ MoveWindow(hWnd,Rect.left,Rect.top, Rect.right-Rect.left, Rect.bottom-Rect.top, TRUE);
+
+ MoveWindows();
+
+ Stream=FindFreeStream();
+
+ if (Stream == 255)
+ {
+ MessageBox(NULL,"No free streams available",NULL,MB_OK);
+ return (FALSE);
+ }
+
+ //
+ // Register message for posting by BPQDLL
+ //
+
+ BPQMsg = RegisterWindowMessage(BPQWinMsg);
+
+ //
+ // Enable Async notification
+ //
+
+ BPQSetHandle(Stream, hWnd);
+
+ GetVersionInfo(NULL);
+
+ wsprintf(Title,"BPQTerminal Version %s - using stream %d", VersionString, Stream);
+
+ SetWindowText(hWnd,Title);
+
+
+// Sets Application Flags and Mask for stream. (BPQHOST function 1)
+// AH = 1 Set application mask to value in DL (or even DX if 16
+// applications are ever to be supported).
+//
+// Set application flag(s) to value in CL (or CX).
+// whether user gets connected/disconnected messages issued
+// by the node etc.
+//
+// Top bit of flags controls monitoring
+
+ hMenu=GetMenu(hWnd);
+
+// if (applmask & 0x01) CheckMenuItem(hMenu,BPQAPPL1,MF_CHECKED);
+// if (applmask & 0x02) CheckMenuItem(hMenu,BPQCHAT,MF_CHECKED);
+// if (applmask & 0x04) CheckMenuItem(hMenu,BPQAPPL3,MF_CHECKED);
+// if (applmask & 0x08) CheckMenuItem(hMenu,BPQAPPL4,MF_CHECKED);
+// if (applmask & 0x10) CheckMenuItem(hMenu,BPQAPPL5,MF_CHECKED);
+// if (applmask & 0x20) CheckMenuItem(hMenu,BPQAPPL6,MF_CHECKED);
+// if (applmask & 0x40) CheckMenuItem(hMenu,BPQAPPL7,MF_CHECKED);
+// if (applmask & 0x80) CheckMenuItem(hMenu,BPQAPPL8,MF_CHECKED);
+
+// CMD_TO_APPL EQU 1B ; PASS COMMAND TO APPLICATION
+// MSG_TO_USER EQU 10B ; SEND 'CONNECTED' TO USER
+// MSG_TO_APPL EQU 100B ; SEND 'CONECTED' TO APPL
+// 0x40 = Send Keepalives
+
+// if (applflags & 0x01) CheckMenuItem(hMenu,BPQFLAGS1,MF_CHECKED);
+// if (applflags & 0x02) CheckMenuItem(hMenu,BPQFLAGS2,MF_CHECKED);
+// if (applflags & 0x04) CheckMenuItem(hMenu,BPQFLAGS3,MF_CHECKED);
+// if (applflags & 0x40) CheckMenuItem(hMenu,BPQFLAGS4,MF_CHECKED);
+
+
+ hPopMenu1=GetSubMenu(hMenu,1);
+
+ for (n=1;n <= GetNumberofPorts();n++)
+ {
+ PORT = GetPortTableEntryFromSlot(n);
+
+ i = PORT->PORTNUMBER;
+
+ sprintf(msg,"Port %d %s ",i, PORT->PORTDESCRIPTION);
+
+ if (tempmask & ((uint64_t)1<<(i-1)))
+ {
+ AppendMenu(hPopMenu1,MF_STRING | MF_CHECKED,BPQBASE + i,msg);
+ portmask |= ((uint64_t)1 <<( i-1));
+ }
+ else
+ AppendMenu(hPopMenu1,MF_STRING | MF_UNCHECKED,BPQBASE + i,msg);
+ }
+
+ if (mtxparam & 1)
+ CheckMenuItem(hMenu,BPQMTX,MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,BPQMTX,MF_UNCHECKED);
+
+ CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED);
+
+ if (AUTOCONNECT)
+ CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_UNCHECKED);
+
+ if (Bells & 1)
+ CheckMenuItem(hMenu,BPQBELLS, MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,BPQBELLS, MF_UNCHECKED);
+
+ if (SendDisconnected & 1)
+ CheckMenuItem(hMenu,BPQSendDisconnected, MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,BPQSendDisconnected, MF_UNCHECKED);
+
+ if (StripLF & 1)
+ CheckMenuItem(hMenu,BPQStripLF, MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,BPQStripLF, MF_UNCHECKED);
+
+ CheckMenuItem(hMenu,BPQMNODES, (MonitorNODES) ? MF_CHECKED : MF_UNCHECKED);
+
+ CheckMenuItem(hMenu,MONCOLOUR, (MonitorColour) ? MF_CHECKED : MF_UNCHECKED);
+
+ DrawMenuBar(hWnd);
+
+ if (portmask) applflags |= 0x80;
+
+ SetAppl(Stream, applflags, applmask);
+
+ SetTraceOptions64(portmask, mtxparam, mcomparam, monUI);
+
+ DragCursor = LoadCursor(hInstance, "IDC_DragSize");
+ Cursor = LoadCursor(NULL, IDC_ARROW);
+
+ GetCallsign(Stream, callsign);
+
+ if (MinimizetoTray)
+ {
+ // Set up Tray ICON
+
+ wsprintf(Title,"BPQTerminal Stream %d",Stream);
+ AddTrayMenuItem(hWnd, Title);
+ }
+
+ if ((nCmdShow == SW_SHOWMINIMIZED) || (nCmdShow == SW_SHOWMINNOACTIVE))
+ if (MinimizetoTray)
+ ShowWindow(hWnd, SW_HIDE);
+ else
+ ShowWindow(hWnd, nCmdShow);
+ else
+ ShowWindow(hWnd, nCmdShow);
+
+ UpdateWindow(hWnd);
+
+ CheckTimer();
+
+ TimerHandle = SetTimer(NULL, 0, 10000, lpTimerFunc);
+
+ dc = GetDC(hwndOutput);
+ GetTextMetrics(dc, &tm);
+
+ return (TRUE);
+}
+
+//
+// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// PURPOSE: Processes messages for the main window.
+//
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ LPRECT lprc;
+ UCHAR Buffer[1000];
+ UCHAR * buf = Buffer;
+ TEXTMETRIC tm;
+ int i, y;
+ LPMEASUREITEMSTRUCT lpmis;
+ LPDRAWITEMSTRUCT lpdis;
+
+
+ if (message == BPQMsg)
+ {
+ if (lParam & BPQDataAvail)
+ DoReceivedData(hWnd);
+
+ if (lParam & BPQMonitorAvail)
+ DoMonData(hWnd);
+
+ if (lParam & BPQStateChange)
+ DoStateChange(hWnd);
+
+ return (0);
+ }
+
+ switch (message) {
+
+ case WM_CTLCOLOREDIT:
+
+ if (OutputData.Scrolled)
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetBkMode(hdcStatic, TRANSPARENT);
+
+ return (LONG)GetStockObject(LTGRAY_BRUSH);
+ }
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ case WM_NOTIFY:
+ {
+ const MSGFILTER * pF = (MSGFILTER *)lParam;
+ POINT pos;
+ CHARRANGE Range;
+
+ if(pF->nmhdr.hwndFrom == hwndOutput)
+ {
+ if(pF->msg == WM_VSCROLL)
+ {
+// OutputData.Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+ DoRefresh(&OutputData);
+// return TRUE;
+ }
+
+ if(pF->msg == WM_KEYUP)
+ {
+ if (pF->wParam == VK_PRIOR || pF->wParam == VK_NEXT)
+ {
+// OutputData.Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+ DoRefresh(&OutputData);
+ }
+ }
+
+ if(pF->msg == WM_RBUTTONDOWN)
+ {
+ // Only allow popup if something is selected
+
+ SendMessage(hwndOutput, EM_EXGETSEL , 0, (WPARAM)&Range);
+ if (Range.cpMin == Range.cpMax)
+ return TRUE;
+
+ GetCursorPos(&pos);
+ TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, hWnd, 0);
+ return TRUE;
+ }
+ }
+ break;
+ }
+
+
+
+ case WM_MEASUREITEM:
+
+ lpmis = (LPMEASUREITEMSTRUCT) lParam;
+
+ // Set the height of the list box items.
+
+ // lpmis->itemHeight = 15;
+ return TRUE;
+
+ case WM_DRAWITEM:
+
+ lpdis = (LPDRAWITEMSTRUCT) lParam;
+
+ // If there are no list box items, skip this message.
+
+ if (lpdis->itemID == -1)
+ {
+ return TRUE;
+ }
+
+ switch (lpdis->itemAction)
+ {
+ case ODA_SELECT:
+ case ODA_DRAWENTIRE:
+
+ // if Chat Console, and message has a colour eacape, action it
+
+ SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM) Buffer);
+
+ GetTextMetrics(lpdis->hDC, &tm);
+
+ if (lpdis->hwndItem == hwndOutput)
+ {
+ CharWidth = tm.tmAveCharWidth;
+ maxlinelen = ClientWidth/CharWidth - 1;
+ }
+
+ y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
+
+ if (Buffer[0] == 0x1b)
+ {
+ SetTextColor(lpdis->hDC, Colours[Buffer[1] - 10]);
+ buf += 2;
+ }
+// SetBkColor(lpdis->hDC, 0);
+
+ TextOut(lpdis->hDC,
+ 6,
+ y,
+ buf,
+ strlen(buf));
+
+ // SetTextColor(lpdis->hDC, OldColour);
+
+ break;
+ }
+
+ return TRUE;
+
+ case WM_ACTIVATE:
+
+ //fActive = LOWORD(wParam); // activation flag
+ //fMinimized = (BOOL) HIWORD(wParam); // minimized flag
+ // hwnd = (HWND) lParam; // window handle
+
+ SetFocus(hwndInput);
+ break;
+
+
+
+ case WM_COMMAND:
+
+ wmId = LOWORD(wParam); // Remember, these are...
+ wmEvent = HIWORD(wParam); // ...different for Win32!
+
+ //Parse the menu selections:
+
+ if (wmId > BPQBASE && wmId < BPQBASE + 64)
+ {
+ TogglePort(hWnd,wmId,(uint64_t)1 << (wmId - (BPQBASE + 1)));
+ break;
+ }
+
+ switch (wmId) {
+
+ case 40000:
+ {
+ int len=0;
+ HGLOBAL hMem;
+ char * ptr;
+ CHARRANGE Range;
+
+ // Copy Rich Text Selection to Clipboard
+
+ SendMessage(hwndOutput, EM_EXGETSEL , 0, (WPARAM)&Range);
+
+ hMem=GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, Range.cpMax - Range.cpMin + 1);
+
+ if (hMem != 0)
+ {
+ ptr=GlobalLock(hMem);
+
+ if (OpenClipboard(MainWnd))
+ {
+ len = SendMessage(hwndOutput, EM_GETSELTEXT , 0, (WPARAM)ptr);
+
+ GlobalUnlock(hMem);
+ EmptyClipboard();
+ SetClipboardData(CF_TEXT,hMem);
+ CloseClipboard();
+ }
+ }
+ else
+ GlobalFree(hMem);
+
+ SetFocus(hwndInput);
+ return TRUE;
+ }
+
+ case ID_SETUP_FONT:
+
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_FONT), hWnd, FontConfigWndProc);
+ break;
+
+
+ case BPQMTX:
+
+ ToggleMTX(hWnd);
+ break;
+
+ case BPQMCOM:
+
+ ToggleMCOM(hWnd);
+ break;
+
+ case MUIONLY:
+
+ ToggleMUI(hWnd);
+ break;
+
+ case BPQCONNECT:
+
+ SessionControl(Stream, 1, 0);
+ break;
+
+ case BPQDISCONNECT:
+
+ SessionControl(Stream, 2, 0);
+ break;
+
+
+ case ID_ACTION_RESETWINDOWSPLIT:
+
+ Split = 0.5;
+ SplitPos=Height*Split;
+ MoveWindows();
+
+ break;
+
+ case BPQAUTOCONNECT:
+
+ ToggleAutoConnect(hWnd);
+ break;
+
+ case BPQBELLS:
+
+ ToggleParam(hWnd, &Bells, BPQBELLS);
+ break;
+
+ case BPQStripLF:
+
+ ToggleParam(hWnd, &StripLF, BPQStripLF);
+ break;
+
+ case BPQLogOutput:
+
+ ToggleParam(hWnd, &LogOutput, BPQLogOutput);
+ break;
+
+ case CHATTERM:
+
+ ToggleParam(hWnd, &ChatMode, CHATTERM);
+ break;
+
+
+ case BPQSendDisconnected:
+
+ ToggleParam(hWnd, &SendDisconnected, BPQSendDisconnected);
+ break;
+
+ case BPQMNODES:
+
+ ToggleParam(hWnd, &MonitorNODES, BPQMNODES);
+ break;
+
+ case MONCOLOUR:
+
+ ToggleParam(hWnd, &MonitorColour, MONCOLOUR);
+ break;
+
+ case BPQLogMonitor:
+
+ ToggleParam(hWnd, &LogMonitor, BPQLogMonitor);
+ break;
+
+ case BPQCLEARMON:
+
+ SendMessage(hwndMon,LB_RESETCONTENT, 0, 0);
+ break;
+
+ case BPQCLEAROUT:
+
+ for (i = 0; i < MAXLINES; i++)
+ {
+ OutputData.OutputScreen[i][0] = 0;
+ }
+
+ OutputData.CurrentLine = 0;
+ DoRefresh(&OutputData);
+
+ break;
+
+ case BPQCOPYMON:
+
+ CopyListToClipboard(hwndMon);
+ break;
+
+ case BPQCOPYOUT:
+
+ CopyRichTextToClipboard(hwndOutput);
+ break;
+
+ case BPQHELP:
+
+ ShellExecute(hWnd,"open",
+ "http://www.cantab.net/users/john.wiseman/Documents/BPQTerminal.htm",
+ "", NULL, SW_SHOWNORMAL);
+ break;
+
+ default:
+
+ return 0;
+
+ }
+
+ case WM_SYSCOMMAND:
+
+ wmId = LOWORD(wParam); // Remember, these are...
+ wmEvent = HIWORD(wParam); // ...different for Win32!
+
+ switch (wmId)
+ {
+ case SC_MINIMIZE:
+
+ if (MinimizetoTray)
+ return ShowWindow(hWnd, SW_HIDE);
+
+ default:
+
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+ }
+
+ case WM_SIZING:
+
+ lprc = (LPRECT) lParam;
+
+ Height = lprc->bottom-lprc->top;
+ Width = lprc->right-lprc->left;
+
+ SplitPos=Height*Split;
+
+ MoveWindows();
+
+ return TRUE;
+
+ case WM_SIZE:
+
+ MoveWindows();
+ return TRUE;
+
+ case WM_DESTROY:
+
+ // Remove the subclass from the edit control.
+
+ GetWindowRect(hWnd, &Rect); // For save soutine
+
+ SetWindowLong(hwndInput, GWL_WNDPROC,
+ (LONG) wpOrigInputProc);
+
+ SessionControl(Stream, 2, 0);
+ DeallocateStream(Stream);
+ PostQuitMessage(0);
+
+ if (MinimizetoTray)
+ DeleteTrayMenuItem(hWnd);
+
+ break;
+
+ default:
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ }
+ return (0);
+}
+
+static char * KbdStack[20];
+
+int StackIndex=0;
+
+LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ char DisplayLine[200] = "\x1b\xb";
+
+ if (uMsg == WM_CTLCOLOREDIT)
+ {
+ HBRUSH Brush = CreateSolidBrush(RGB(0, 255, 0));
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+
+ return (LONG)Brush;
+ }
+
+
+ if (uMsg == WM_KEYUP)
+ {
+ unsigned int i;
+
+// Debugprintf("5%x", LOBYTE(HIWORD(lParam)));
+
+ if (LOBYTE(HIWORD(lParam)) == 0x48 && wParam == 0x26)
+ {
+ // Scroll up
+
+ if (KbdStack[StackIndex] == NULL)
+ return TRUE;
+
+ SendMessage(hwndInput, WM_SETTEXT,0,(LPARAM)(LPCSTR) KbdStack[StackIndex]);
+
+ for (i = 0; i < strlen(KbdStack[StackIndex]); i++)
+ {
+ SendMessage(hwndInput, WM_KEYDOWN, VK_RIGHT, 0);
+ SendMessage(hwndInput, WM_KEYUP, VK_RIGHT, 0);
+ }
+
+ StackIndex++;
+ if (StackIndex == 20)
+ StackIndex = 19;
+
+ return TRUE;
+ }
+
+ if (LOBYTE(HIWORD(lParam)) == 0x50 && wParam == 0x28)
+ {
+ // Scroll up
+
+ StackIndex--;
+ if (StackIndex < 0)
+ StackIndex = 0;
+
+ if (KbdStack[StackIndex] == NULL)
+ return TRUE;
+
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) KbdStack[StackIndex]);
+
+ for (i = 0; i < strlen(KbdStack[StackIndex]); i++)
+ {
+ SendMessage(hwndInput, WM_KEYDOWN, VK_RIGHT, 0);
+ SendMessage(hwndInput, WM_KEYUP, VK_RIGHT, 0);
+ }
+
+ return TRUE;
+ }
+ }
+
+
+
+ if (uMsg == WM_CHAR)
+ {
+ if (wParam == 13)
+ {
+ int i;
+
+ //
+ // if not connected, and autoconnect is
+ // enabled, connect now
+
+ if (!CONNECTED && AUTOCONNECT)
+ SessionControl(Stream, 1, 0);
+
+ kbptr=SendMessage(hwndInput,WM_GETTEXT,159,(LPARAM) (LPCSTR) kbbuf);
+
+ // Stack it
+
+ StackIndex = 0;
+
+ if (KbdStack[19])
+ free(KbdStack[19]);
+
+ for (i = 18; i >= 0; i--)
+ {
+ KbdStack[i+1] = KbdStack[i];
+ }
+
+ KbdStack[0] = _strdup(kbbuf);
+
+ kbbuf[kbptr]=13;
+
+ SlowTimer = 0;
+
+ // Echo, with set Black escape
+
+ memcpy(&DisplayLine[2], kbbuf, kbptr+1);
+
+ if (OutputData.Scrolled)
+ {
+ POINT Point;
+ Point.x = 0;
+ Point.y = 25000; // Should be plenty for any font
+
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ OutputData.Scrolled = FALSE;
+ }
+
+ WritetoOutputWindow(&OutputData, DisplayLine, kbptr+3);
+ DoRefresh(&OutputData);
+
+
+ // Replace null with CR, and send to Node
+
+ SendMsg(Stream, &kbbuf[0], kbptr+1);
+
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) "");
+
+ return 0;
+ }
+ if (wParam == 0x1a) // Ctrl/Z
+ {
+ //
+ // if not connected, and autoconnect is
+ // enabled, connect now
+
+ if (!CONNECTED && AUTOCONNECT)
+ SessionControl(Stream, 1, 0);
+
+ kbbuf[0]=0x1a;
+ kbbuf[1]=13;
+
+ SendMsg(Stream, &kbbuf[0], 2);
+
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) "");
+
+ return 0;
+ }
+
+ }
+
+ return CallWindowProc(wpOrigInputProc, hwnd, uMsg, wParam, lParam);
+}
+
+//int FirstItem=-1, LastItem=-1, SELECTING=FALSE, MOVED=FALSE, LastSelected=0;
+
+LRESULT APIENTRY MonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
+ return TRUE;
+
+ return CallWindowProc(wpOrigMonProc, hwnd, uMsg, wParam, lParam);
+}
+
+LRESULT APIENTRY SplitProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ int xPos, yPos;
+
+ switch (uMsg) {
+
+ case WM_LBUTTONDOWN:
+
+ SetCapture(hwnd);
+ return 0;
+
+ case WM_LBUTTONUP:
+
+ xPos = LOWORD(lParam); // horizontal position of cursor
+ yPos = lParam >> 16; // vertical position of cursor
+
+ SplitPos = SplitPos + yPos - 5;
+
+ if (SplitPos < 0) SplitPos = 0;
+
+ Split=SplitPos;
+ Split=Split/Height;
+
+ ReleaseCapture();
+ MoveWindows();
+ DoRefresh(&OutputData);
+ return 0;
+
+ case WM_MOUSEMOVE:
+
+ // Used to size split between Monitor and Output Windows
+
+ SetCursor(DragCursor);
+ break;
+ }
+ return CallWindowProc(wpOrigSplitProc, hwnd, uMsg, wParam, lParam);
+}
+
+
+
+
+DoStateChange(HWND hWnd)
+{
+ int port, sesstype, paclen, maxframe, l4window;
+
+ // Get current Session State. Any state changed is ACK'ed
+ // automatically. See BPQHOST functions 4 and 5.
+
+ SessionState(Stream, &state, &change);
+
+ if (change == 1)
+ {
+ if (state == 1)
+ {
+ // Connected
+
+ CONNECTED = TRUE;
+ SlowTimer = 0;
+
+ // GetCallsign(Stream, callsign);
+
+ GetConnectionInfo(Stream, callsign,
+ &port, &sesstype, &paclen,
+ &maxframe, &l4window);
+
+
+ wsprintf(Title,"BPQTerminal Version %s - using stream %d - Connected to %s",VersionString,Stream,callsign);
+ SetWindowText(hWnd,Title);
+ DisableConnectMenu(hWnd);
+ EnableDisconnectMenu(hWnd);
+
+ }
+ else
+ {
+ CONNECTED=FALSE;
+ wsprintf(Title,"BPQTerminal Version %s - using stream %d - Disconnected",VersionString,Stream);
+ SetWindowText(hWnd,Title);
+ DisableDisconnectMenu(hWnd);
+ EnableConnectMenu(hWnd);
+
+ if (SendDisconnected)
+ {
+ WritetoOutputWindow(&OutputData, "*** Disconnected\r", 17);
+ DoRefresh(&OutputData);
+ }
+ }
+ }
+
+ return (0);
+
+}
+
+DoReceivedData(HWND hWnd)
+{
+ char Msg[300];
+
+ if (RXCount(Stream) > 0)
+ {
+ do {
+
+ GetMsg(Stream, &Msg[0],&len,&count);
+ WritetoOutputWindow(&OutputData, Msg, len);
+ DoRefresh(&OutputData);
+
+ SlowTimer = 0;
+
+ } while (count > 0);
+ }
+ return (0);
+}
+DWORD CALLBACK EditStreamCallback(DWORD_PTR Cookie, LPBYTE lpBuff, LONG cb, PLONG pcb)
+{
+ struct RTFTerm * OPData = (struct RTFTerm *)Cookie;
+ int ReqLen = cb;
+ int i;
+ int Line;
+
+// if (cb != 4092)
+// return 0;
+
+ if (OPData->SendHeader)
+ {
+ // Return header
+
+ memcpy(lpBuff, RTFHeader, RTFHddrLen);
+ *pcb = RTFHddrLen;
+ OPData->SendHeader = FALSE;
+ OPData->Finished = FALSE;
+ OPData->Index = 0;
+ return 0;
+ }
+
+ if (OPData->Finished)
+ {
+ *pcb = 0;
+ return 0;
+ }
+
+/*
+ if (BufferLen > cb)
+ {
+ memcpy(lpBuff, &Buffer[Offset], cb);
+ BufferLen -= cb;
+ Offset += cb;
+ *pcb = cb;
+ return 0;
+ }
+
+ memcpy(lpBuff, &Buffer[Offset], BufferLen);
+
+ *pcb = BufferLen;
+*/
+
+ // Return 10 line at a time
+
+ for (i = 0; i < 10; i++);
+ {
+ Line = OPData->Index++ + OPData->CurrentLine - MAXLINES;
+
+ if (Line <0)
+ Line = Line + MAXLINES;
+
+ wsprintf(lpBuff, "\\cf%d ", OPData->Colourvalue[Line]);
+ strcat(lpBuff, OPData->OutputScreen[Line]);
+ strcat(lpBuff, "\\line");
+
+ if (OPData->Index == MAXLINES)
+ {
+ OPData->Finished = TRUE;
+ strcat(lpBuff, "}");
+ i = 10;
+ }
+ }
+ *pcb = strlen(lpBuff);
+ return 0;
+}
+
+VOID ForceRefresh(struct RTFTerm * OPData)
+{
+ OPData->Thumb = 25000;
+ DoRefresh(OPData);
+ OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+}
+
+VOID DoRefresh(struct RTFTerm * OPData)
+{
+ EDITSTREAM es = {0};
+ int Min, Max, Pos;
+ POINT Point;
+ SCROLLINFO ScrollInfo;
+ int LoopTrap = 0;
+
+ if(WINE)
+ OPData->Thumb = 30000;
+ else
+ OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+
+ Pos = OPData->Thumb + OutputBoxHeight;
+
+ if (Pos > OPData->RTFHeight - 10) // Don't bother writing to screen if scrolled back
+ {
+ es.pfnCallback = EditStreamCallback;
+ es.dwCookie = (DWORD_PTR)OPData;
+ OPData->SendHeader = TRUE;
+ SendMessage(hwndOutput, EM_STREAMIN, SF_RTF, (LPARAM)&es);
+ }
+// else
+// Debugprintf("Pos %d RTFHeight %d - Not refreshing", Pos, OPData->RTFHeight);
+
+ GetScrollRange(hwndOutput, SB_VERT, &Min, &Max);
+ ScrollInfo.cbSize = sizeof(ScrollInfo);
+ ScrollInfo.fMask = SIF_ALL;
+
+ GetScrollInfo(hwndOutput, SB_VERT, &ScrollInfo);
+
+// Debugprintf("Thumb %d Pos %d Min %d Max %d nMax %d ClientH %d RTFHeight %d",
+// OPData->Thumb, Pos, Min, Max, ScrollInfo.nMax, OutputBoxHeight, OPData->RTFHeight);
+
+ if (OPData->FirstTime == FALSE)
+ {
+ // RTF Controls don't immediately scroll to end - don't know why.
+
+ OPData->FirstTime = TRUE;
+ Point.x = 0;
+ Point.y = 25000; // Should be plenty for any font
+
+ while (LoopTrap++ < 20)
+ {
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ }
+
+ GetScrollRange(hwndOutput, SB_VERT, &Min, &Max); // Get Actual Height
+ OPData->RTFHeight = Max;
+ Point.x = 0;
+ Point.y = OPData->RTFHeight - ScrollInfo.nPage;
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+ }
+
+ Point.x = 0;
+ Point.y = OPData->RTFHeight - ScrollInfo.nPage;
+
+ if (OPData->Thumb > (Point.y - 10)) // Don't Scroll if user has scrolled back
+ {
+// Debugprintf("Scrolling to %d", Point.y);
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ if (OPData->Scrolled)
+ {
+ OPData->Scrolled = FALSE;
+ InvalidateRect(hwndInput, NULL, TRUE);
+ }
+ return;
+ }
+
+// Debugprintf("Thumb = %d Point.y = %d - Not Scrolling", OPData->Thumb, Point.y);
+
+ if (!OPData->Scrolled)
+ {
+ OPData->Scrolled = TRUE;
+ InvalidateRect(hwndInput, NULL, TRUE);
+ }
+}
+
+VOID AddLinetoWindow(struct RTFTerm * OPData, char * Line)
+{
+ int Len = strlen(Line);
+ char * ptr1 = Line;
+ char * ptr2;
+ int l, Index;
+ char LineCopy[LINELEN * 2];
+
+ if (Line[0] == 0x1b && Len > 1)
+ {
+ // Save Colour Char
+
+ OPData->CurrentColour = Line[1] - 10;
+ ptr1 +=2;
+ Len -= 2;
+ }
+
+ strcpy(OPData->OutputScreen[OPData->CurrentLine], ptr1);
+
+ // Look for chars we need to escape (\ { })
+
+ ptr1 = OPData->OutputScreen[OPData->CurrentLine];
+ Index = 0;
+ ptr2 = strchr(ptr1, '\\'); // Look for Backslash first, as we may add some later
+
+ if (ptr2)
+ {
+ while (ptr2)
+ {
+ l = ++ptr2 - ptr1;
+ memcpy(&LineCopy[Index], ptr1, l); // Copy Including found char
+ Index += l;
+ LineCopy[Index++] = '\\';
+ Len++;
+ ptr1 = ptr2;
+ ptr2 = strchr(ptr1, '\\');
+ }
+ strcpy(&LineCopy[Index], ptr1); // Copy in rest
+ strcpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy);
+ }
+
+ ptr1 = OPData->OutputScreen[OPData->CurrentLine];
+ Index = 0;
+ ptr2 = strchr(ptr1, '{');
+
+ if (ptr2)
+ {
+ while (ptr2)
+ {
+ l = ptr2 - ptr1;
+ memcpy(&LineCopy[Index], ptr1, l);
+ Index += l;
+ LineCopy[Index++] = '\\';
+ LineCopy[Index++] = '{';
+ Len++;
+ ptr1 = ++ptr2;
+ ptr2 = strchr(ptr1, '{');
+ }
+ strcpy(&LineCopy[Index], ptr1); // Copy in rest
+ strcpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy);
+ }
+
+ ptr1 = OPData->OutputScreen[OPData->CurrentLine];
+ Index = 0;
+ ptr2 = strchr(ptr1, '}'); // Look for Backslash first, as we may add some later
+
+ if (ptr2)
+ {
+ while (ptr2)
+ {
+ l = ptr2 - ptr1;
+ memcpy(&LineCopy[Index], ptr1, l); // Copy
+ Index += l;
+ LineCopy[Index++] = '\\';
+ LineCopy[Index++] = '}';
+ Len++;
+ ptr1 = ++ptr2;
+ ptr2 = strchr(ptr1, '}');
+ }
+ strcpy(&LineCopy[Index], ptr1); // Copy in rest
+ strcpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy);
+ }
+
+
+ OPData->Colourvalue[OPData->CurrentLine] = OPData->CurrentColour;
+ OPData->LineLen[OPData->CurrentLine++] = Len;
+ if (OPData->CurrentLine >= MAXLINES) OPData->CurrentLine = 0;
+}
+
+VOID WritetoOutputWindow(struct RTFTerm * OPData, char * Msg, int len)
+{
+ char * ptr1, * ptr2;
+
+ if (PartLinePtr > LINELEN)
+ Msg[len++] = 13; // Force a newline
+
+ if (PartLinePtr != 0)
+ {
+ OPData->CurrentLine--; // Overwrite part line in buffer
+ if (OPData->CurrentLine < 0)
+ OPData->CurrentLine = MAXLINES - 1;
+
+ if (Msg[0] == 0x1b && len > 1)
+ {
+ Msg += 2; // Remove Colour Escape
+ len -= 2;
+ }
+ }
+
+ memcpy(&readbuff[PartLinePtr], Msg, len);
+
+ len += PartLinePtr;
+
+ ptr1=&readbuff[0];
+ readbuff[len]=0;
+
+ if (Bells)
+ {
+ do {
+ ptr2=memchr(ptr1,7,len);
+
+ if (ptr2)
+ {
+ *(ptr2)=32;
+ Beep(440,250);
+ }
+ } while (ptr2);
+ }
+
+lineloop:
+
+ if (len > 0)
+ {
+ // copy text to buffer a line at a time
+
+ ptr2=memchr(ptr1,13,len);
+
+ if (ptr2 == 0)
+ {
+ // no newline. Move data to start of buffer and Save pointer
+
+ PartLinePtr = len;
+ memmove(readbuff,ptr1,len);
+ AddLinetoWindow(OPData, ptr1);
+ return;
+ }
+
+ *(ptr2++)=0;
+
+ if (LogOutput) WriteMonitorLine(ptr1, ptr2 - ptr1);
+
+ // If len is greater that screen with, fold
+
+ if ((ptr2 - ptr1) > maxlinelen)
+ {
+ char * ptr3;
+ char * saveptr1 = ptr1;
+ int linelen = ptr2 - ptr1;
+ int foldlen;
+ char save;
+
+ foldloop:
+
+ ptr3 = ptr1 + maxlinelen;
+
+ while(*ptr3!= 0x20 && ptr3 > ptr1)
+ {
+ ptr3--;
+ }
+ foldlen = ptr3 - ptr1 ;
+
+ if (foldlen == 0)
+ {
+ // No space before, so split at width
+
+ foldlen = maxlinelen;
+ ptr3 = ptr1 + maxlinelen;
+
+ }
+ else
+ {
+ ptr3++ ; // Omit space
+ linelen--;
+ }
+ save = ptr1[foldlen];
+ ptr1[foldlen] = 0;
+
+ AddLinetoWindow(OPData, ptr1);
+
+ ptr1[foldlen] = save;
+ linelen -= foldlen;
+ ptr1 = ptr3;
+
+ if (linelen > maxlinelen)
+ goto foldloop;
+
+ AddLinetoWindow(OPData, ptr1);
+ ptr1 = saveptr1;
+
+ }
+ else
+ AddLinetoWindow(OPData, ptr1);
+
+
+ PartLinePtr=0;
+
+ len-=(ptr2-ptr1);
+
+ ptr1=ptr2;
+
+ if ((len > 0) && StripLF)
+ {
+ if (*ptr1 == 0x0a) // Line Feed
+ {
+ ptr1++;
+ len--;
+ }
+ }
+ goto lineloop;
+ }
+}
+
+
+DoMonData(HWND hWnd)
+{
+ char * ptr1, * ptr2;
+ int index;
+ time_t stamp;
+ int len;
+ unsigned char buffer[1024] = "\x1b\xb", monbuff[512];
+
+ if (MONCount(Stream) > 0)
+ {
+ do {
+
+ stamp=GetRaw(Stream, monbuff,&len,&count);
+
+ if (MonitorColour)
+ {
+ if (monbuff[4] & 0x80) // TX
+ buffer[1] = 91;
+ else
+ buffer[1] = 17;
+ }
+
+ // See if a NODES
+
+ if (!MonitorNODES && monbuff[21] == 3 && monbuff[22] == 0xcf && monbuff[23] == 0xff)
+ len = 0;
+ else
+ {
+ len=DecodeFrame(monbuff,&buffer[2],stamp);
+ len +=2;
+ }
+
+ ptr1=&buffer[0];
+
+ lineloop:
+
+ if (len > 0)
+ {
+ // copy text to control a line at a time
+
+ ptr2=memchr(ptr1,13,len);
+
+ if (ptr2 == 0)
+ {
+ // no newline. Move data to start of buffer and Save pointer
+
+ memmove(buffer,ptr1,len);
+
+ return (0);
+
+ }
+ else
+ {
+ *(ptr2++)=0;
+
+ index=SendMessage(hwndMon,LB_ADDSTRING,0,(LPARAM)(LPCTSTR) ptr1 );
+
+ if (LogMonitor) WriteMonitorLine(ptr1, ptr2 - ptr1);
+
+ if (index > 1200)
+
+ do{
+
+ index=SendMessage(hwndMon,LB_DELETESTRING, 0, 0);
+
+ } while (index > 1000);
+
+ SendMessage(hwndMon,LB_SETCARETINDEX,(WPARAM) index, MAKELPARAM(FALSE, 0));
+
+ len-=(ptr2-ptr1);
+
+ ptr1=ptr2;
+
+ goto lineloop;
+ }
+ }
+
+ } while (count > 0);
+ }
+ return (0);
+}
+
+
+
+
+
+int DisableConnectMenu(HWND hWnd)
+{
+ HMENU hMenu; // handle of menu
+
+ hMenu=GetMenu(hWnd);
+
+ EnableMenuItem(hMenu,BPQCONNECT,MF_GRAYED);
+
+ return (0);
+}
+int DisableDisconnectMenu(HWND hWnd)
+{
+ HMENU hMenu; // handle of menu
+
+ hMenu=GetMenu(hWnd);
+
+ EnableMenuItem(hMenu,BPQDISCONNECT,MF_GRAYED);
+ return (0);
+}
+
+int EnableConnectMenu(HWND hWnd)
+{
+ HMENU hMenu; // handle of menu
+
+ hMenu=GetMenu(hWnd);
+
+ EnableMenuItem(hMenu,BPQCONNECT,MF_ENABLED);
+ return (0);
+}
+
+int EnableDisconnectMenu(HWND hWnd)
+{
+ HMENU hMenu; // handle of menu
+
+ hMenu=GetMenu(hWnd);
+
+ EnableMenuItem(hMenu,BPQDISCONNECT,MF_ENABLED);
+
+ return (0);
+}
+
+int ToggleAutoConnect(HWND hWnd)
+{
+ HMENU hMenu; // handle of menu
+
+ hMenu=GetMenu(hWnd);
+
+ AUTOCONNECT = !AUTOCONNECT;
+
+ if (AUTOCONNECT)
+
+ CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_CHECKED);
+
+ else
+
+ CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_UNCHECKED);
+
+ return (0);
+
+}
+
+CopyScreentoBuffer(char * buff)
+{
+
+ return (0);
+}
+
+int TogglePort(HWND hWnd, int Item, uint64_t mask)
+{
+ portmask ^= mask;
+
+ if (portmask & mask)
+ CheckMenuItem(hMenu,Item,MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,Item,MF_UNCHECKED);
+
+ if (portmask)
+ applflags |= 0x80;
+ else
+ applflags &= 0x7f;
+
+ SetAppl(Stream,applflags,applmask);
+
+ SetTraceOptions64(portmask, mtxparam, mcomparam, monUI);
+
+ return (0);
+
+}
+int ToggleMTX(HWND hWnd)
+{
+ mtxparam = mtxparam ^ 1;
+
+ if (mtxparam & 1)
+
+ CheckMenuItem(hMenu,BPQMTX,MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,BPQMTX,MF_UNCHECKED);
+
+ SetTraceOptions64(portmask, mtxparam, mcomparam, monUI);
+
+ return (0);
+
+}
+int ToggleMCOM(HWND hWnd)
+{
+ mcomparam = mcomparam ^ 1;
+
+ CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED);
+ SetTraceOptions64(portmask, mtxparam, mcomparam, monUI);
+
+ return (0);
+
+}
+int ToggleMUI(HWND hWnd)
+{
+ monUI = monUI ^ 1;
+
+ CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED);
+ SetTraceOptions64(portmask, mtxparam, mcomparam, monUI);
+
+ return (0);
+
+}
+int ToggleParam(HWND hWnd, BOOL * Param, int Item)
+{
+ *Param = !(*Param);
+
+ CheckMenuItem(hMenu,Item, (*Param) ? MF_CHECKED : MF_UNCHECKED);
+
+ return (0);
+}
+
+void MoveWindows()
+{
+ RECT rcMain, rcClient;
+ int ClientHeight, ClientWidth;
+
+ if (hWnd == 0)
+ return;
+
+ GetWindowRect(hWnd, &rcMain);
+ GetClientRect(hWnd, &rcClient);
+
+ ClientHeight = rcClient.bottom;
+ ClientWidth = rcClient.right;
+
+ if (ClientWidth == 0) // Minimized
+ return;
+
+ OutputBoxHeight = ClientHeight - SplitPos - InputBoxHeight - SplitBarHeight - SplitBarHeight;
+
+ MoveWindow(hwndMon,2, 0, ClientWidth-4, SplitPos, TRUE);
+ MoveWindow(hwndOutput,2, SplitPos+SplitBarHeight, ClientWidth-4, OutputBoxHeight, TRUE);
+ MoveWindow(hwndInput,2, ClientHeight-InputBoxHeight-2, ClientWidth-4, InputBoxHeight, TRUE);
+ MoveWindow(hwndSplit,0, SplitPos, ClientWidth, SplitBarHeight, TRUE);
+
+ GetClientRect(hwndOutput, &rcClient);
+
+ ClientHeight = rcClient.bottom;
+ ClientWidth = rcClient.right;
+
+ if (ClientWidth > 16)
+ maxlinelen = ClientWidth/OutputData.CharWidth - 1;
+
+ InvalidateRect(hWnd, NULL, TRUE);
+}
+
+void CopyRichTextToClipboard(HWND hWnd)
+{
+ int len=0;
+ HGLOBAL hMem;
+ char * ptr;
+
+ // Copy Rich Text to Clipboard
+
+ len = SendMessage(hwndOutput, WM_GETTEXTLENGTH, 0, 0);
+
+ hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, len + 1);
+
+ if (hMem != 0)
+ {
+ ptr=GlobalLock(hMem);
+
+ if (OpenClipboard(MainWnd))
+ {
+ len = SendMessage(hwndOutput, WM_GETTEXT , len, (LPARAM)ptr);
+
+ GlobalUnlock(hMem);
+ EmptyClipboard();
+ SetClipboardData(CF_TEXT,hMem);
+ CloseClipboard();
+ }
+ }
+ else
+ GlobalFree(hMem);
+}
+
+
+void CopyListToClipboard(HWND hWnd)
+{
+ int i,n, len=0;
+ HGLOBAL hMem;
+ char * ptr;
+ //
+ // Copy List Box to clipboard
+ //
+
+ n = SendMessage(hWnd, LB_GETCOUNT, 0, 0);
+
+ for (i=0; i<n; i++)
+ {
+ len+=SendMessage(hWnd, LB_GETTEXTLEN, i, 0);
+ }
+
+ hMem=GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, len+n+n+1);
+
+
+ if (hMem != 0)
+ {
+ ptr=GlobalLock(hMem);
+
+ if (OpenClipboard(MainWnd))
+ {
+ // CopyScreentoBuffer(GlobalLock(hMem));
+
+ for (i=0; i<n; i++)
+ {
+ ptr+=SendMessage(hWnd, LB_GETTEXT, i, (LPARAM) ptr);
+ *(ptr++)=13;
+ *(ptr++)=10;
+ }
+
+ *(ptr)=0; // end of data
+
+ GlobalUnlock(hMem);
+ EmptyClipboard();
+ SetClipboardData(CF_TEXT,hMem);
+ CloseClipboard();
+ }
+ else
+ GlobalFree(hMem);
+ }
+}
+
+BOOL OpenMonitorLogfile()
+{
+ UCHAR * BPQDirectory=GetBPQDirectory();
+ UCHAR FN[MAX_PATH];
+
+ if (BPQDirectory[0] == 0)
+ wsprintf(FN,"BPQTerm_%d.log", Stream);
+ else
+ wsprintf(FN,"%s\\BPQTerm_%d.log", BPQDirectory, Stream);
+
+ MonHandle = CreateFile(FN,
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ SetFilePointer(MonHandle, 0, 0, FILE_END);
+
+ return (MonHandle != INVALID_HANDLE_VALUE);
+}
+
+void WriteMonitorLine(char * Msg, int MsgLen)
+{
+ int cnt;
+ char CRLF[2] = {0x0d,0x0a};
+
+ if (MonHandle == INVALID_HANDLE_VALUE) OpenMonitorLogfile();
+
+ if (MonHandle == INVALID_HANDLE_VALUE) return;
+
+ WriteFile(MonHandle ,Msg , MsgLen, &cnt, NULL);
+ WriteFile(MonHandle ,CRLF , 2, &cnt, NULL);
+}
+
+INT_PTR CALLBACK FontConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ POINT Point;
+ int Min, Max;
+ int retCode, disp;
+ HKEY hKey=0;
+
+
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ SetDlgItemText(hDlg, IDC_FONTNAME, FontName);
+ SetDlgItemInt(hDlg, IDC_CHARSET, CharSet, FALSE);
+ SetDlgItemInt(hDlg, IDC_CODEPAGE, CodePage, FALSE);
+ SetDlgItemInt(hDlg, IDC_FONTSIZE, FontSize, FALSE);
+ SetDlgItemInt(hDlg, IDC_FONTWIDTH, FontWidth, FALSE);
+
+ return (INT_PTR)TRUE;
+
+ case WM_CTLCOLORDLG:
+ return (LONG)bgBrush;
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+ return (LONG)bgBrush;
+ }
+
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+
+ GetDlgItemText(hDlg, IDC_FONTNAME, FontName, 99);
+ CharSet = GetDlgItemInt(hDlg, IDC_CHARSET, NULL, FALSE);
+ CodePage = GetDlgItemInt(hDlg, IDC_CODEPAGE, NULL, FALSE);
+ FontSize = GetDlgItemInt(hDlg, IDC_FONTSIZE, NULL, FALSE);
+ FontWidth = GetDlgItemInt(hDlg, IDC_FONTWIDTH, NULL, FALSE);
+
+// SaveStringValue("FontName", FontName);
+// SaveIntValue("CharSet", CharSet);
+// SaveIntValue("CodePage", CodePage);
+// SaveIntValue("FontSize", FontSize);
+// SaveIntValue("FontWidth", FontWidth);
+
+
+ // Save Config
+
+ retCode = RegCreateKeyEx(REGTREE,
+ Key,
+ 0, // Reserved
+ 0, // Class
+ 0, // Options
+ KEY_ALL_ACCESS,
+ NULL, // Security Attrs
+ &hKey,
+ &disp);
+
+ if (retCode == ERROR_SUCCESS)
+ {
+ retCode = RegSetValueEx(hKey,"FontWidth",0,REG_DWORD,(BYTE *)&FontWidth,4);
+ retCode = RegSetValueEx(hKey,"FontSize",0,REG_DWORD,(BYTE *)&FontSize,4);
+ retCode = RegSetValueEx(hKey,"CodePage",0,REG_DWORD,(BYTE *)&CodePage,4);
+ retCode = RegSetValueEx(hKey,"CharSet",0,REG_DWORD,(BYTE *)&CharSet,4);
+ retCode = RegSetValueEx(hKey,"FontName",0,REG_SZ,(BYTE *)&FontName, strlen(FontName));
+
+ RegCloseKey(hKey);
+ }
+
+ OutputData.CharWidth = FontWidth;
+ OutputData.FirstTime = FALSE;
+
+ SetupRTFHddr();
+
+ Point.x = 0;
+ Point.y = 25000; // Should be plenty for any font
+
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ OutputData.Scrolled = FALSE;
+
+ GetScrollRange(hwndOutput, SB_VERT, &Min, &Max); // Get Actual Height
+ OutputData.RTFHeight = Max;
+
+ DoRefresh(&OutputData);
+ EndDialog(hDlg, LOWORD(wParam));
+
+ case IDCANCEL:
+
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+
+
diff --git a/BPQTerminal.h b/BPQTerminal.h
new file mode 100644
index 0000000..ba3fe57
--- /dev/null
+++ b/BPQTerminal.h
@@ -0,0 +1,77 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by BPQTerminal.rc
+//
+#define BPQICON 2
+#define IDR_MENU1 101
+#define BPQMENU 101
+#define BPQCONNECT 102
+#define BPQDISCONNECT 103
+#define IDD_FONT 105
+#define IDC_FONTWIDTH 1008
+#define IDC_FONTNAME 1009
+#define IDC_CODEPAGE 1010
+#define IDC_CHARSET 1011
+#define IDC_FONTSIZE 1012
+#define BPQMTX 1164
+#define BPQMCOM 1165
+#define BPQCOPYMON 1166
+#define BPQCOPYOUT 1167
+#define BPQCLEARMON 1168
+#define BPQCLEAROUT 1169
+#define BPQBELLS 1170
+#define BPQHELP 1172
+#define BPQStripLF 1173
+#define BPQLogOutput 1174
+#define BPQLogMonitor 1175
+#define BPQSendDisconnected 1176
+#define BPQMNODES 1177
+#define MONCOLOUR 1178
+#define CHATTERM 1179
+#define IDM_CLOSEWINDOW 1180
+#define MUIONLY 1181
+#define RTFCOPY 40000
+#define BPQAUTOCONNECT 40001
+#define BPQAPPL1 40002
+#define BPQAPPL2 40003
+#define BPQAPPL3 40004
+#define BPQAPPL4 40005
+#define BPQAPPL6 40006
+#define BPQAPPL7 40007
+#define BPQAPPL8 40008
+#define BPQAPPL5 40009
+#define BPQFLAGS1 40010
+#define BPQFLAGS2 40011
+#define BPQFLAGS3 40012
+#define BPQFLAGS4 40013
+#define ID_SETUP_FONT 40025
+#define ID_ACTION_RESETWINDOWSPLIT 40026
+#define IDC_STATIC -1
+
+#define IDR_MAINFRAME_MENU 191
+#define TERM_MENU 192
+#define MON_MENU 193
+#define IDI_SIGMA_MAIN_ICON 104
+#define IDI_SYSTEM_INFO 106
+
+
+#define IDI_SYSTEM_INFO 106
+#define ID_INFORMATION_SYSTEMINFORMATION 40001
+#define ID_HELP_ABOUT 40006
+#define ID_WINDOWS_CASCADE 40007
+#define ID_FILE_EXIT 40008
+#define ID_WINDOWS_TILE 40004
+#define ID_NEWWINDOW 40005
+
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_COMMAND_VALUE 40027
+#define _APS_NEXT_CONTROL_VALUE 1004
+#define _APS_NEXT_SYMED_VALUE 104
+#endif
+#endif
diff --git a/BPQTerminal.rc b/BPQTerminal.rc
new file mode 100644
index 0000000..63348cf
--- /dev/null
+++ b/BPQTerminal.rc
@@ -0,0 +1,164 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "bpqterminal.h"
+#define BPQTerm
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "winver.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "bpqterminal.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""winver.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "#include ""..\\CommonSource\\Versions.h""\r\n"
+ "#include ""..\\StdVer.inc""\r\n"
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+BPQMAINWINDOW DIALOG DISCARDABLE 17, 25, 300, 300
+STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
+ WS_THICKFRAME
+CAPTION "BPQTerminal Version 1.0.0"
+MENU MENU_1
+CLASS "BPQMAINWINDOW"
+FONT 8, "Fixedsys"
+BEGIN
+ LISTBOX 116,5,6,290,134,LBS_MULTIPLESEL | LBS_OWNERDRAWFIXED |
+ LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
+ WS_HSCROLL
+ EDITTEXT 118,5,280,440,15,ES_AUTOHSCROLL | ES_NOHIDESEL
+ CTEXT "",119,0,145,300,5,SS_NOTIFY
+END
+
+IDD_FONT DIALOG DISCARDABLE 0, 0, 186, 113
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Font Setup"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "Save",IDOK,39,93,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,92,93,50,14
+ LTEXT "Name",IDC_STATIC,7,10,24,9
+ LTEXT "Code Page",IDC_STATIC,6,70,44,9
+ EDITTEXT IDC_CODEPAGE,53,68,39,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "Font Width",IDC_STATIC,7,40,41,9
+ EDITTEXT IDC_FONTNAME,53,8,89,12,ES_AUTOHSCROLL
+ LTEXT "Char Set",IDC_STATIC,7,55,39,9
+ EDITTEXT IDC_CHARSET,53,53,40,12,ES_AUTOHSCROLL | ES_NUMBER
+ EDITTEXT IDC_FONTWIDTH,53,38,39,12,ES_AUTOHSCROLL | ES_NUMBER
+ EDITTEXT IDC_FONTSIZE,53,23,38,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "Font Size",IDC_STATIC,7,25,44,9
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+MENU_1 MENU DISCARDABLE
+BEGIN
+ POPUP "Action"
+ BEGIN
+ MENUITEM "Connect", BPQCONNECT
+ MENUITEM "Disconnect", BPQDISCONNECT, GRAYED
+ MENUITEM "Reset Window Split", ID_ACTION_RESETWINDOWSPLIT
+ END
+ POPUP "Monitor"
+ BEGIN
+ MENUITEM "Monitor TX", BPQMTX
+ MENUITEM "Monitor Supervisory", BPQMCOM
+ MENUITEM "Only monitor UI frames", MUIONLY
+ MENUITEM "Monitor NODES", BPQMNODES
+ MENUITEM "Enable Colour", MONCOLOUR
+ END
+ POPUP "Config"
+ BEGIN
+ MENUITEM "Font", ID_SETUP_FONT
+ MENUITEM "AutoConnect", BPQAUTOCONNECT, CHECKED
+ MENUITEM "Enable Bells", BPQBELLS
+ MENUITEM "Strip Linefeeds", BPQStripLF
+ MENUITEM "Log Monitor", BPQLogMonitor
+ MENUITEM "Log Output", BPQLogOutput
+ MENUITEM "Chat Terminal Mode", CHATTERM
+ MENUITEM "Send Disconnected", BPQSendDisconnected
+ END
+ POPUP "Edit"
+ BEGIN
+ MENUITEM "Copy Monitor Window", BPQCOPYMON
+ MENUITEM "Copy Output Window", BPQCOPYOUT
+ MENUITEM "Clear Monitor Window", BPQCLEARMON
+ MENUITEM "Clear Output Window", BPQCLEAROUT
+ END
+ MENUITEM "Help", BPQHELP
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Cursor
+//
+
+IDC_DRAGSIZE CURSOR DISCARDABLE "DragSize.cur"
+#endif // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "Versions.h"
+#include "StdVer.inc"
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/BPQWinAPP.c b/BPQWinAPP.c
index f262d08..d70ef68 100644
--- a/BPQWinAPP.c
+++ b/BPQWinAPP.c
@@ -11,6 +11,11 @@
// Add try/except round main loop
+// Version 2.0.1.2 July 2026
+
+// Call RunBPQ32Background() every 10mS
+
+
#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
@@ -21,9 +26,10 @@
#include <memory.h>
#include <time.h>
#include "DbgHelp.h"
+#include "winstdint.h"
//#define DYNLOADBPQ // Dynamically Load BPQ32.dll
-#include "..\Include\bpq32.h"
+#include "bpq32.h"
VOID APIENTRY SetFrameWnd(HWND hWnd);
@@ -45,19 +51,6 @@ LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
HWND FrameWnd;
int TimerHandle = 0;
-
-VOID __cdecl Debugprintf(const char * format, ...)
-{
- char Mess[8192];
- va_list(arglist);int Len;
-
- va_start(arglist, format);
- Len = vsprintf_s(Mess, sizeof(Mess), format, arglist);
- strcat_s(Mess, 999, "\r\n");
- OutputDebugString(Mess);
- return;
-}
-
VOID WriteMiniDump()
{
#ifdef WIN32
@@ -88,6 +81,114 @@ VOID WriteMiniDump()
}
+HANDLE process;
+
+void printStack()
+{
+ unsigned int i, n;
+ void * stack[ 100 ];
+ unsigned short frames;
+
+ DWORD dwDisplacement;
+ IMAGEHLP_LINE64 line;
+ char * fptr;
+
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
+ PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
+
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ symbol->MaxNameLen = MAX_SYM_NAME;
+
+ Debugprintf("Stack Backtrace\r\n");
+
+ process = GetCurrentProcess();
+
+ SymSetOptions(SYMOPT_LOAD_LINES);
+ SymInitialize( process, NULL, TRUE );
+
+ frames = RtlCaptureStackBackTrace(0, 60, stack, NULL );
+
+ for( i = 0; i < frames; i++ )
+ {
+ n = SymGetLineFromAddr64(process, (DWORD64)stack[i], &dwDisplacement, &line);
+ n = SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
+
+ if (line.FileName)
+ {
+ fptr = line.FileName + (int)strlen(line.FileName); // remove path
+ while (*fptr != '\\' && *fptr != '/')
+ fptr--;
+
+ fptr++;
+
+ Debugprintf("%i: %s - %s Line %d Addr %p", frames - i - 1, symbol->Name, fptr, line.LineNumber, symbol->Address );
+ }
+ }
+}
+
+
+int inErrorhandling = 0;
+
+LONG WINAPI UnhandledExcepFilter(PEXCEPTION_POINTERS pExcepPointers)
+{
+ DWORD dwDisplacement;
+ IMAGEHLP_LINE64 line;
+ char * fptr;
+
+
+ time_t T;
+ struct tm * tm;
+
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
+ PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
+
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ symbol->MaxNameLen = MAX_SYM_NAME;
+
+
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ if (inErrorhandling)
+ {
+ MessageBox(NULL,"Program Error in error handler - program closing. See Debug Log for details","BPQ32",MB_ICONSTOP);
+
+ exit(0);
+ }
+
+ inErrorhandling = 1;
+
+ if(pExcepPointers->ExceptionRecord->ExceptionCode == DBG_PRINTEXCEPTION_C)
+ return EXCEPTION_CONTINUE_EXECUTION;
+
+ SymFromAddr( process, ((DWORD)pExcepPointers->ExceptionRecord->ExceptionAddress), 0, symbol );
+
+ Debugprintf("\r\n\r\nProgram error trapped at %02d:%02d:%02d\r\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ SymGetLineFromAddr64(process, (DWORD)pExcepPointers->ExceptionRecord->ExceptionAddress, &dwDisplacement, &line);
+
+ if (line.FileName)
+ {
+ fptr = line.FileName + (int)strlen(line.FileName); // remove path
+ while (*fptr != '\\' && *fptr != '/')
+ fptr--;
+
+ fptr++;
+
+ Debugprintf("In Procedure %s - %s Line %d Addr %p\r\n", symbol->Name, fptr, line.LineNumber, symbol->Address );
+ }
+
+ printStack();
+
+ CloseDebugLog();
+
+
+ MessageBox(NULL,"Program Error - program closing. See Debug Log for details","BPQ32",MB_ICONSTOP);
+ RealCloseAllPrograms();
+ Sleep(1000);
+
+ exit(0);
+}
//
// FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
@@ -102,11 +203,17 @@ VOID WriteMiniDump()
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
- BOOL bRet;
- struct _EXCEPTION_POINTERS exinfo;
+ int Running = 1;
Debugprintf("BPQ32.exe %s Entered", lpCmdLine);
+ process = GetCurrentProcess();
+
+ SymSetOptions(SYMOPT_LOAD_LINES);
+ SymInitialize( process, NULL, TRUE );
+
+ AddVectoredExceptionHandler(1, UnhandledExcepFilter);
+
if (_stricmp(lpCmdLine, "Wait") == 0) // If AutoRestart then Delay 5 Secs
Sleep(5000);
@@ -115,37 +222,40 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
+ RunBPQ32Background();
+
// Main message loop:
- __try
+// __try
{
-
- while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
- {
- if (bRet == -1)
- {
- Debugprintf("GetMessage Returned -1 %d", GetLastError());
- break;
- }
- else
+ while(Running)
{
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
+ Sleep(10);
+
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+
+ if (msg.message == WM_QUIT)
+ Running = 0;
+ }
+ RunBPQ32Background();
+ }
}
- #define EXCEPTMSG "BPQ32.exe Main Loop"
- #include "StdExcept.c"
- }
+// #define EXCEPTMSG "BPQ32.exe Main Loop"
+// #include "StdExcept.c"
+// }
Debugprintf("BPQ32.exe exiting %d", msg.message);
KillTimer(NULL,TimerHandle);
CloseBPQ32(); // Close Ext Drivers if last bpq32 process
-
+ CloseDebugLog();
+
return (msg.wParam);
}
diff --git a/BPQWinAPP.rc b/BPQWinAPP.rc
index 53dd522..915f39d 100644
--- a/BPQWinAPP.rc
+++ b/BPQWinAPP.rc
@@ -25,13 +25,13 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#define BPQICON 400
-BPQICON ICON DISCARDABLE "..\\bpqicon.ico"
+BPQICON ICON DISCARDABLE "bpqicon.ico"
//
// Version
//
-#define TEXTVER "2. 0. 1. 1\0"
-#define BINVER 2, 0, 1, 1
+#define TEXTVER "2. 0. 1. 2\0"
+#define BINVER 2, 0, 1, 2
VS_VERSION_INFO VERSIONINFO
FILEVERSION BINVER
@@ -55,7 +55,7 @@ BEGIN
VALUE "FileDescription", "bpq32\0"
VALUE "FileVersion", TEXTVER
VALUE "InternalName", "bpq32\0"
- VALUE "LegalCopyright", "Copyright © 2006-2011 G8BPQ\0"
+ VALUE "LegalCopyright", "Copyright © 2006-2026 G8BPQ\0"
VALUE "OriginalFilename", "bpq32.exe\0"
VALUE "ProductName", " bpq32\0"
VALUE "ProductVersion", TEXTVER
diff --git a/BUILDING.md b/BUILDING.md
new file mode 100644
index 0000000..4c6b206
--- /dev/null
+++ b/BUILDING.md
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+
+<meta http-equiv="content-type" content="text/sgml;charset=utf-8">
+
+<style type="text/css">
+
+body {background: white;color: black}
+h1 {color: #c33;background: none;font-weight: bold;text-align: center}
+h2 {color: #00008b;background: none;font-weight: bold}
+h3 {color: #006400;background: none;margin-left: 4%;margin-right: 4%;font-weight: bold}
+h4 {margin-left: 8%;margin-right: 8%;font-weight: bold}
+h5 {margin-left: 6%;margin-right: 6%;font-weight: bold}
+div {margin-left: 10%;margin-right: 10%;}
+ul, ol, dl, p {margin-left: 6%;margin-right: 6%}
+pre {margin-left: 10%;white-space: pre}
+
+</style><title>Building LinBPQ from source</title>
+
+</head>
+<body alink="#ff0000" bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#800080">
+<a href="index.html">BPQ Home</a>&nbsp;&nbsp;&nbsp;<a href="BPQ32.html">BPQ32 Home</a>
+
+<h1>Building LinBPQ from source.</h1>
+
+<p>
+I provide binaries for Linux on 32 and 64 bit ARM and Intel x86 processors but if you want to run on other Unix like operating systems you can build it from source. You will need to install some dependencies and download the source. The instructions below are for a Debian like system using apt as its package manager - you may need to alter the command for other systems.
+<br><br>
+To download dependencies run:
+<br>
+<pre>sudo apt install build-essential git libminiupnpc-dev libconfig-dev libpcap-dev zlib1g-dev libcap2-bin libjansson-dev libpaho-mqtt-dev libbacktrace-dev
+</pre>
+<p>
+Some distributions may not include libpaho-mqtt-dev and/or libbacktrace-dev. The former is used for the MQTT reporting interface. If you don't need that you can build without MQTT support. If you do you can build libpaho-mqtt-dev from source:
+<pre>
+sudo apt install cmake
+git clone https://github.com/eclipse/paho.mqtt.c.git
+cd paho.mqtt.c
+cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_STATIC=ON -DPAHO_WITH_SSL=OFF -DPAHO_HIGH_PERFORMANCE=ON -DCMAKE_INSTALL_PREFIX=../install
+cd build
+cmake --build . --target install
+
+You need to copy libpaho-mqtt3a.a to your lib directory.
+The commands below work on my ARM and Intel systems but you may need to change if your lib is in a different place.
+
+sudo cp src/libpaho-mqtt3a.a /usr/lib/arm-linux-gnueabihf
+or
+sudo cp src/libpaho-mqtt3a.a /usr/lib/i386-linux-gnu/
+</pre><p>
+If libbacktrace isn't available you can build it:
+<pre>
+git clone https://github.com/ianlancetaylor/libbacktrace.git
+cd libbacktrace
+mkdir build
+cd build
+../configure
+make
+sudo make install
+</pre><p>
+
+To download the LinBPQ source run:
+<pre>
+git clone https://github.com/g8bpq/linbpq.git
+cd linbpq</pre>
+<p>
+To build with MQTT support enter:
+<pre>
+make
+</pre>
+<p>
+To build without MQTT support enter:
+<pre>
+make nomqtt
+</pre><p>
+This should create linbpq in the current directory.
+<br><br>
+</P>
+
+
+John Wiseman G8BPQ<br>
+April 2025<br>
+Updated September 2026<br>
+
+</body>
+</html> \ No newline at end of file
diff --git a/Bpq32.c b/Bpq32.c
index 3b5121f..5652e1f 100644
--- a/Bpq32.c
+++ b/Bpq32.c
@@ -1322,7 +1322,29 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Change INP3 to XR 'standard' (29)
// Swap L4INDEX and L4ID in Packet Trace API (30)
// More INP3 fixes (30)
-
+// Starting NCMP implementation
+// Fix AGWAPI inbound connect for APPL Numbers above 1 (31)
+// More INP3 changes (enforce RIF refresh at hourly intervals and time out nodes (31)
+// Save, forward and display XR extended INP3 Options (31)
+// Check packets from APRS-IS against Exclude list (32)
+// Fix authorisation of Web Save Config File (32)
+// Add missing calls to va_end() (32)
+// Apply EXCLUDE to APRS and Digi (32)
+// Move background processing on Linux from the 100mS timer loop and run more frequently (33)
+// Fix sorting INP3 routes when TT is the same and hops differ (34)
+// Fix flawed calculation of inp3 TT percentage change on very low values to fix repeated sending of unchanged routes (34)
+// Change Web Driver windows to use Winsocks to give quicker refresh when changed (35)
+// Fix timer problem introduced in v33 (36)
+// Add LOCALNOTSECURE config param to require signin for web access from 127.0.0.1 (36)
+// Convert Web Terminal to winsocks (37)
+// More fixes for timer problem introduced in v33 (38)
+// Changes to INP3 poison reverse and alias reporting (39)
+// L4 Connect Ack now sent via routing table (39)
+// Debug info is now written to a log file rather than syslog (Linux) or Debugview (Windows) (40)
+// Backtrace now includes source file info and is written to Debug log (40)
+// Add Telnet Server config option "noWebSocks" to disable use of Websocks for Terminal and Driver windows (41)
+// Log outpur from running disconnect script (41)
+// Prevent Rigcontrol scan from changing frequency when PTT is active (41)
#define CKernel
@@ -1334,7 +1356,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include "time.h"
#include "stdio.h"
-#include <fcntl.h>
+#include <fcntl.h>
#include "compatbits.h"
#include "AsmStrucs.h"
@@ -1417,8 +1439,6 @@ void * HSMODEMExtInit(EXTPORTDATA * PortEntry);
void * FreeDataExtInit(EXTPORTDATA * PortEntry);
void * SIXPACKExtInit(EXTPORTDATA * PortEntry);
-VOID RealCloseAllPrograms();
-
extern char * ConfigBuffer; // Config Area
VOID REMOVENODE(dest_list * DEST);
DllExport int ConvFromAX25(unsigned char * incall,unsigned char * outcall);
@@ -1431,6 +1451,7 @@ void initADSB();
int CloseAllSessions();
int CloseAllLinks();
void NETROMTCPResolve();
+DllExport VOID APIENTRY CloseDebugLog();
extern BOOL ADIFLogEnabled;
@@ -1538,7 +1559,7 @@ int _C_Q_ADD(VOID *PQ, VOID *PBUFF, char * File, int Line);
VOID SetWindowTextSupport();
int WritetoConsoleSupport(char * buff);
VOID PMClose();
-VOID MySetWindowText(HWND hWnd, char * Msg);
+VOID MySetWindowText(struct TNCINFO * TNC, HWND hWnd, char * Msg);
BOOL CreateMonitorWindow(char * MonSize);
VOID FormatTime3(char * Time, time_t cTime);
void * zalloc(int len);
@@ -1563,8 +1584,8 @@ extern char ReportDest[7];
extern UCHAR ConfigDirectory[260];
+DllExport VOID __cdecl Debugprintf(const char * format, ...);
-VOID __cdecl Debugprintf(const char * format, ...);
VOID __cdecl Consoleprintf(const char * format, ...);
DllExport int APIENTRY CloseBPQ32();
@@ -1701,15 +1722,13 @@ VOID * _Q_REM(VOID *Q, char * File, int Line);
UINT ReleaseBuffer(UINT *BUFF);
-VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime );
-
DllExport int APIENTRY DeallocateStream(int stream);
int VECTORLENGTH = sizeof (struct _BPQVECSTRUC);
int FirstEntry = 1;
BOOL CloseLast = TRUE; // If the user started BPQ32.exe, don't close it when other programs close
-BOOL Closing = FALSE; // Set if Close All called - prevents respawning bpq32.exe
+extern BOOL Closing = FALSE; // Set if Close All called - prevents respawning bpq32.exe
BOOL BPQ32_EXE; // Set if Process is running BPQ32.exe. Not initialised.
// Used to Kill surplus BPQ32.exe processes
@@ -1775,8 +1794,6 @@ int interval;
VOID CALLBACK SetupTermSessions(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
-
-TIMERPROC lpTimerFunc = (TIMERPROC) TimerProc;
TIMERPROC lpSetupTermSessions = (TIMERPROC) SetupTermSessions;
@@ -1813,6 +1830,9 @@ int needADSB = 0;
extern int AGWPort;
+extern time_t NOW; // From time()
+
+
Tell_Sessions();
@@ -1826,15 +1846,13 @@ void LoadToolHelperRoutines()
{
HINSTANCE ExtDriver=0;
int err;
- char msg[100];
ExtDriver=LoadLibrary("kernel32.dll");
if (ExtDriver == NULL)
{
err=GetLastError();
- sprintf(msg,"BPQ32 Error loading kernel32.dll - Error code %d\n", err);
- OutputDebugString(msg);
+ Debugprintf("BPQ32 Error loading kernel32.dll - Error code %d", err);
return;
}
@@ -1845,8 +1863,7 @@ void LoadToolHelperRoutines()
if (CreateToolHelp32SnapShotPtr == 0)
{
err=GetLastError();
- sprintf(msg,"BPQ32 Error getting CreateToolhelp32Snapshot entry point - Error code %d\n", err);
- OutputDebugString(msg);
+ Debugprintf("BPQ32 Error getting CreateToolhelp32Snapshot entry point - Error code %d\n", err);
return;
}
}
@@ -1865,8 +1882,8 @@ BOOL GetProcess(int ProcessID, char * Program)
hProcessSnap = (HANDLE)CreateToolHelp32SnapShotPtr(TH32CS_SNAPPROCESS, 0);
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
- OutputDebugString( "CreateToolhelp32Snapshot (of processes) Failed\n" );
- return( FALSE );
+ Debugprintf("CreateToolhelp32Snapshot (of processes) Failed\n" );
+ return( FALSE );
}
// Set the size of the structure before using it.
@@ -1876,7 +1893,7 @@ BOOL GetProcess(int ProcessID, char * Program)
// and exit if unsuccessful
if( !Process32Firstptr( hProcessSnap, &pe32 ) )
{
- OutputDebugString( "Process32First Failed\n" ); // Show cause of failure
+ Debugprintf( "Process32First Failed" ); // Show cause of failure
CloseHandle( hProcessSnap ); // Must clean up the snapshot object!
return( FALSE );
}
@@ -1924,7 +1941,7 @@ BOOL IsProcess(int ProcessID)
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
- OutputDebugString( "CreateToolhelp32Snapshot (of processes) Failed\n" );
+ Debugprintf( "CreateToolhelp32Snapshot (of processes) Failed" );
return(TRUE); // Don't know, so assume ok
}
@@ -1932,7 +1949,7 @@ BOOL IsProcess(int ProcessID)
if( !Process32Firstptr( hProcessSnap, &pe32 ) )
{
- OutputDebugString( "Process32First Failed\n" ); // Show cause of failure
+ Debugprintf( "Process32First Failed" ); // Show cause of failure
CloseHandle( hProcessSnap ); // Must clean up the snapshot object!
return(TRUE); // Don't know, so assume ok
}
@@ -1997,8 +2014,8 @@ VOID CheckforLostProcesses()
{
// Process has died - Treat as a detach
- sprintf(Log,"BPQ32 Process %d Died\n", ProcessID);
- OutputDebugString(Log);
+ sprintf(Log,"BPQ32 Process %d Died", ProcessID);
+ Debugprintf(Log);
// Remove Tray Icon Entry
@@ -2007,8 +2024,7 @@ VOID CheckforLostProcesses()
if (PIDArray[i] == ProcessID)
{
hWndArray[i] = 0;
- sprintf(Log,"BPQ32 Removing Tray Item %s\n", PopupText[i]);
- OutputDebugString(Log);
+ Debugprintf(Log,"BPQ32 Removing Tray Item %s", PopupText[i]);
DeleteMenu(trayMenu,TRAYBASEID+i,MF_BYCOMMAND);
}
}
@@ -2017,7 +2033,7 @@ VOID CheckforLostProcesses()
if (Semaphore.Flag == 1 && ProcessID == Semaphore.SemProcessID)
{
- OutputDebugString("BPQ32 Process was holding Semaphore - attempting recovery\r\n");
+ Debugprintf("BPQ32 Process was holding Semaphore - attempting recovery");
Debugprintf("Last Sem Call %d %x %x %x %x %x %x", SemHeldByAPI,
Sem_eax, Sem_ebx, Sem_ecx, Sem_edx, Sem_esi, Sem_edi);
@@ -2039,7 +2055,7 @@ VOID CheckforLostProcesses()
TimerHandle=0;
TimerInst=0xffffffff;
// Tell_Sessions();
- OutputDebugString("BPQ32 Process was running timer \n");
+ Debugprintf("BPQ32 Process was running timer");
if (MinimizetoTray)
Shell_NotifyIcon(NIM_DELETE,&niData);
@@ -2079,7 +2095,7 @@ VOID MonitorTimerThread(int x)
if (Semaphore.Flag == 1 && TimerInst == Semaphore.SemProcessID)
{
- OutputDebugString("BPQ32 Process was holding Semaphore - attempting recovery\r\n");
+ Debugprintf("BPQ32 Process was holding Semaphore - attempting recovery");
Debugprintf("Last Sem Call %d %x %x %x %x %x %x", SemHeldByAPI,
Sem_eax, Sem_ebx, Sem_ecx, Sem_edx, Sem_esi, Sem_edi);
Semaphore.Flag = 0;
@@ -2100,7 +2116,7 @@ VOID MonitorTimerThread(int x)
if (Closing == FALSE && AttachingProcess == FALSE)
{
- OutputDebugString("BPQ32 Reloading BPQ32.exe\n");
+ Debugprintf("BPQ32 Reloading BPQ32.exe");
StartBPQ32();
}
@@ -2113,38 +2129,24 @@ VOID MonitorTimerThread(int x)
VOID WritetoTraceSupport(struct TNCINFO * TNC, char * Msg, int Len);
-VOID TimerProcX();
+VOID * _Q_REM_NP(VOID *PQ, char * File, int Line);
-VOID CALLBACK TimerProc(
- HWND hwnd, // handle of window for timer messages
- UINT uMsg, // WM_TIMER message
- UINT idEvent, // timer identifier
- DWORD dwTime) // current system time
-{
- KillTimer(NULL,TimerHandle);
- TimerProcX();
- TimerHandle = SetTimer(NULL,0,100,lpTimerFunc);
-}
-VOID TimerProcX()
-{
- struct _EXCEPTION_POINTERS exinfo;
+#define Q_REM_NP(s) _Q_REM_NP(s, __FILE__, __LINE__)
- //
- // Get semaphore before proceeeding
- //
-
- GetSemaphore(&Semaphore, 2);
+void Semaphored100msCode()
+{
+ // code that doesn't need to run every tick - run every 100 mS
+ // Runs under semaphore
- // Get time since last run
+ if (IPActive) Poll_IP();
+ if (PMActive) Poll_PM();
+ if (RigActive) Rig_Poll();
+ if (APRSActive)Poll_APRS();
- QueryPerformanceCounter(&currentTime);
+ if (NeedWebMailRefresh)
+ DoRefreshWebMailIndex();
- interval = (int)(currentTime.QuadPart - lastRunTime.QuadPart) / ticksPerMillisec;
- lastRunTime.QuadPart = currentTime.QuadPart;
-
- //Debugprintf("%d", interval);
-
- // Process WINMORTraceQ
+ CheckWL2KReportTimer();
while (WINMORTraceQ)
{
@@ -2162,15 +2164,11 @@ VOID TimerProcX()
while (WritetoConsoleQ)
{
- UINT * Buffer = Q_REM(&WritetoConsoleQ);
+ UINT * Buffer = Q_REM_NP(&WritetoConsoleQ);
WritetoConsoleSupport((char *)&Buffer[2]);
- RelBuff(Buffer);
+ free(Buffer);
}
- strcpy(EXCEPTMSG, "Timer ReconfigProcessing");
-
- __try
- {
if (trayMenu == NULL)
SetupTrayIcon();
@@ -2200,7 +2198,7 @@ VOID TimerProcX()
SetupBPQDirectory();
WritetoConsole("Reconfiguring ...\n\n");
- OutputDebugString("BPQ32 Reconfiguring ...\n");
+ Debugprintf("BPQ32 Reconfiguring ...");
GetWindowRect(FrameWnd, &FRect);
@@ -2240,7 +2238,7 @@ VOID TimerProcX()
Consoleprintf("G8BPQ AX25 Packet Switch System Version %s %s", TextVerstring, Datestring);
Consoleprintf(VerCopyright);
-
+
Start();
NETROMTCPResolve();
@@ -2260,10 +2258,10 @@ VOID TimerProcX()
if (HOSTVEC->HOSTSESSION !=0)
{
// Had a connection
-
+
HOSTVEC->HOSTSESSION=0;
HOSTVEC->HOSTFLAGS |=3; // Disconnected
-
+
PostMessage(HOSTVEC->HOSTHANDLE, BPQMsg, i, 4);
}
}
@@ -2273,7 +2271,7 @@ VOID TimerProcX()
APPL_Q = 0;
OpenReportingSockets();
-
+
WritetoConsole("\n\nReconfiguration Complete\n");
if (IPRequired) IPActive = Init_IP();
@@ -2298,7 +2296,7 @@ VOID TimerProcX()
InvalidateRect(hConsWnd, NULL, TRUE);
RigActive = Rig_Init();
-
+
if (NUMBEROFTNCPORTS)
{
FreeSemaphore(&Semaphore);
@@ -2309,8 +2307,8 @@ VOID TimerProcX()
FreeSemaphore(&Semaphore);
AGWActive = AGWAPIInit();
GetSemaphore(&Semaphore, 0);
-
- OutputDebugString("BPQ32 Reconfiguration Complete\n");
+
+ Debugprintf("BPQ32 Reconfiguration Complete");
}
}
@@ -2326,7 +2324,7 @@ VOID TimerProcX()
Rig_Close();
Sleep(6000); // Allow any CATPTT, HAMLIB and FLRIG threads to close
RigActive = Rig_Init();
-
+
WritetoConsole("Rigcontrol Reconfiguration Complete\n");
}
}
@@ -2340,87 +2338,49 @@ VOID TimerProcX()
APRSReconfigFlag = FALSE;
APRSClose();
APRSActive = Init_APRS();
-
+
WritetoConsole("APRS Reconfiguration Complete\n");
}
}
+}
- }
- #include "StdExcept.c"
-
- if (Semaphore.Flag && Semaphore.SemProcessID == GetCurrentProcessId())
- FreeSemaphore(&Semaphore);
-
- }
-
- strcpy(EXCEPTMSG, "Timer Processing");
-
- __try
- {
- if (IPActive) Poll_IP();
- if (PMActive) Poll_PM();
- if (RigActive) Rig_Poll();
-
- if (NeedWebMailRefresh)
- DoRefreshWebMailIndex();
-
- CheckGuardZone();
-
- if (APRSActive)
- {
- Poll_APRS();
- CheckGuardZone();
- }
-
- CheckWL2KReportTimer();
+DllExport VOID APIENTRY RealCloseAllPrograms();
- CheckGuardZone();
-
- TIMERINTERRUPT();
- CheckGuardZone();
+VOID UnSemaphored100msCode()
+{
+ // code that doesn't need to run every tick - run every 100 mS
+ // Runs without semaphore
- FreeSemaphore(&Semaphore); // SendLocation needs to get the semaphore
+ if (NUMBEROFTNCPORTS)
+ TNCTimer();
- if (NUMBEROFTNCPORTS)
- TNCTimer();
+ if (AGWActive)
+ Poll_AGW();
- if (AGWActive)
- Poll_AGW();
+ DRATSPoll();
+ RHPPoll();
- DRATSPoll();
- RHPPoll();
+ CheckGuardZone();
- CheckGuardZone();
+ strcpy(EXCEPTMSG, "HTTP Timer Processing");
- strcpy(EXCEPTMSG, "HTTP Timer Processing");
+ HTTPTimer();
- HTTPTimer();
+ CheckGuardZone();
- CheckGuardZone();
+ strcpy(EXCEPTMSG, "WL2K Report Timer Processing");
- strcpy(EXCEPTMSG, "WL2K Report Timer Processing");
+ if (ReportTimer)
+ {
+ ReportTimer--;
- if (ReportTimer)
- {
- ReportTimer--;
-
- if (ReportTimer == 0)
- {
- ReportTimer = REPORTINTERVAL;
- SendLocation();
- }
+ if (ReportTimer == 0)
+ {
+ ReportTimer = REPORTINTERVAL;
+ SendLocation();
}
}
-
- #include "StdExcept.c"
-
- if (Semaphore.Flag && Semaphore.SemProcessID == GetCurrentProcessId())
- FreeSemaphore(&Semaphore);
-
- }
-
- CheckGuardZone();
if (CloseAllTimer == 50) // First entry
{
@@ -2435,7 +2395,7 @@ VOID TimerProcX()
if (CloseAllTimer == 40) // First entry
CloseAllLinks(); // No sessions closed so close links now
-
+
if (CloseAllTimer)
{
// See if any links left
@@ -2468,9 +2428,9 @@ VOID TimerProcX()
if(CloseAllTimer == 0)
RealCloseAllPrograms();
}
- return;
}
+
HANDLE NPHandle;
int (WINAPI FAR *GetModuleFileNameExPtr)() = NULL;
@@ -2557,7 +2517,7 @@ FirstInit()
_beginthread(MonitorThread,0,0);
- TimerHandle=SetTimer(NULL,0,100,lpTimerFunc);
+// TimerHandle=SetTimer(NULL,0,100,lpTimerFunc);
TimerInst=GetCurrentProcessId();
SessHandle = SetTimer(NULL, 0, 5000, lpSetupTermSessions);
@@ -2566,7 +2526,7 @@ FirstInit()
if (ADIFLogEnabled)
ADIFWriteFreqList();
- OutputDebugString("BPQ32 Port Initialisation Complete\n");
+ Debugprintf("BPQ32 Port Initialisation Complete");
if (needAIS)
initAIS();
@@ -2579,6 +2539,30 @@ FirstInit()
int Check_Timer()
{
+ if (FirstInitDone == 0)
+ {
+ GetSemaphore(&Semaphore, 3);
+
+ if (_stricmp(pgm, "bpq32.exe") == 0)
+ {
+ FirstInit();
+ FreeSemaphore(&Semaphore);
+ if (NUMBEROFTNCPORTS)
+ InitializeTNCEmulator();
+
+ AGWActive = AGWAPIInit();
+ FirstInitDone=1; // Only init in BPQ32.exe
+ return 0;
+ }
+ else
+ {
+ FreeSemaphore(&Semaphore);
+ return 0;
+ }
+ }
+
+ return 0;
+
if (Closing)
return 0;
@@ -2629,7 +2613,7 @@ int Check_Timer()
}
GetSemaphore(&Semaphore, 3);
- OutputDebugString("BPQ32 Reinitialising External Ports and Attaching Timer\n");
+ Debugprintf("BPQ32 Reinitialising External Ports and Attaching Timer");
if (!ProcessConfig())
{
@@ -2740,7 +2724,6 @@ int Check_Timer()
else
ShowWindow(FrameWnd, SW_RESTORE);
- TimerHandle=SetTimer(NULL,0,100,lpTimerFunc);
TimerInst=GetCurrentProcessId();
SessHandle = SetTimer(NULL, 0, 5000, lpSetupTermSessions);
@@ -2778,9 +2761,6 @@ Tell_Sessions()
BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved)
{
- DWORD n;
- char buf[350];
-
int i;
unsigned int ProcessID;
@@ -2946,7 +2926,7 @@ BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReser
if (Mutex != NULL)
{
- OutputDebugString("Another BPQ32.dll is loaded\n");
+ Debugprintf("Another BPQ32.dll is loaded");
i=MessageBox(NULL,"BPQ32 DLL already loaded from another directory\nIf you REALLY want this, hit OK, else hit Cancel","BPQ32",MB_OKCANCEL);
FreeSemaphore(&Semaphore);
@@ -3020,7 +3000,7 @@ BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReser
if (Mutex != NULL)
{
- OutputDebugString("Another BPQ32.dll is loaded\n");
+ Debugprintf("Another BPQ32.dll is loaded");
MessageBox(NULL,"BPQ32 DLL already loaded from another directory","BPQ32",MB_ICONSTOP);
FreeSemaphore(&Semaphore);
return (0);
@@ -3080,15 +3060,15 @@ SkipInit:
_beginthread(MonitorTimerThread,0,0);
- FreeSemaphore(&Semaphore);
-
AttachedPIDList[AttachedProcesses++] = GetCurrentProcessId();
if (_stricmp(pgm,"bpq32.exe") == 0 && AttachingProcess == 1) AttachingProcess = 0;
GetProcess(GetCurrentProcessId(),pgm);
- n=sprintf(buf,"BPQ32 DLL Attach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
- OutputDebugString(buf);
+ Debugprintf("BPQ32 DLL Attach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
+
+ FreeSemaphore(&Semaphore);
+
// Set up local variables
@@ -3145,10 +3125,7 @@ SkipInit:
{
if (PIDArray[i] == ProcessID)
{
- char Log[80];
hWndArray[i] = 0;
- sprintf(Log,"BPQ32 Removing Tray Item %s\n", PopupText[i]);
- OutputDebugString(Log);
DeleteMenu(trayMenu,TRAYBASEID+i,MF_BYCOMMAND);
}
}
@@ -3172,7 +3149,7 @@ SkipInit:
{
PEXTPORTDATA PORTVEC=(PEXTPORTDATA)PORTTABLE;
- OutputDebugString("BPQ32 Process with Timer closing\n");
+ Debugprintf("BPQ32 Process with Timer closing\n");
// Call Port Close Routines
@@ -3218,7 +3195,7 @@ SkipInit:
if (AttachedProcesses && Closing == FALSE && AttachingProcess == 0) // Other processes
{
- OutputDebugString("BPQ32 Reloading BPQ32.exe\n");
+ Debugprintf("BPQ32 Reloading BPQ32.exe\n");
StartBPQ32();
}
}
@@ -3267,13 +3244,42 @@ SkipInit:
}
GetProcess(GetCurrentProcessId(),pgm);
- n=sprintf(buf,"BPQ32 DLL Detach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
- OutputDebugString(buf);
+ Debugprintf("BPQ32 DLL Detach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
return 1;
}
return 1;
}
+DllExport int APIENTRY RunBPQ32Background()
+{
+ // Called every 10 Ms or so from BPQ32.EXE
+
+ // Get time since last run
+
+ QueryPerformanceCounter(&currentTime);
+
+ interval = (int)(currentTime.QuadPart - lastRunTime.QuadPart) / ticksPerMillisec;
+ lastRunTime.QuadPart = currentTime.QuadPart;
+
+
+ GetSemaphore(&Semaphore, 2);
+
+ if (TIMERINTERRUPT()) // Calls BG code and slower timer routines
+ {
+ // 100 mS has elapsed
+
+ NOW = time(NULL);
+
+ Semaphored100msCode();
+ FreeSemaphore(&Semaphore);
+ UnSemaphored100msCode();
+ }
+ else
+ FreeSemaphore(&Semaphore);
+
+
+ return 1;
+}
DllExport int APIENTRY CloseBPQ32()
{
@@ -3285,7 +3291,7 @@ DllExport int APIENTRY CloseBPQ32()
if (Semaphore.Flag == 1 && ProcessID == Semaphore.SemProcessID)
{
- OutputDebugString("BPQ32 Process holding Semaphore called CloseBPQ32 - attempting recovery\r\n");
+ Debugprintf("BPQ32 Process holding Semaphore called CloseBPQ32 - attempting recovery\r\n");
Debugprintf("Last Sem Call %d %x %x %x %x %x %x", SemHeldByAPI,
Sem_eax, Sem_ebx, Sem_ecx, Sem_edx, Sem_esi, Sem_edi);
@@ -3295,7 +3301,7 @@ DllExport int APIENTRY CloseBPQ32()
if (TimerInst == ProcessID)
{
- OutputDebugString("BPQ32 Process with Timer called CloseBPQ32\n");
+ Debugprintf("BPQ32 Process with Timer called CloseBPQ32\n");
if (MinimizetoTray)
Shell_NotifyIcon(NIM_DELETE,&niData);
@@ -3336,7 +3342,7 @@ DllExport int APIENTRY CloseBPQ32()
if (AttachedProcesses > 1 && Closing == FALSE && AttachingProcess == 0) // Other processes
{
- OutputDebugString("BPQ32 Reloading BPQ32.exe\n");
+ Debugprintf("BPQ32 Reloading BPQ32.exe\n");
StartBPQ32();
}
}
@@ -3505,11 +3511,11 @@ if (_winver < 0x0600)
sprintf(msg,"BPQ32 Ver %s Loaded from: %s by %s\n", VersionString, DLLName, pgm);
WritetoConsole(msg);
- OutputDebugString(msg);
- FormatTime3(Time, time(NULL));
+ Debugprintf(msg);
+ FormatTime3(Time, NOW);
sprintf(msg,"Loaded %s\n", Time);
WritetoConsole(msg);
- OutputDebugString(msg);
+ Debugprintf(msg);
#pragma warning(push)
#pragma warning(disable : 4996)
@@ -3526,12 +3532,12 @@ if (_winver < 0x0600)
#pragma warning(pop)
WritetoConsole(msg);
- OutputDebugString(msg);
+ Debugprintf(msg);
i=sprintf(msg,"BPQ32 Using config from: %s\n\n",BPQDirectory);
WritetoConsole(&msg[6]);
msg[i-1]=0;
- OutputDebugString(msg);
+ Debugprintf(msg);
// Don't write the Version Key if loaded by regsvr32.exe (Installer is running with Admin rights,
// so will write the wrong tree on )
@@ -3565,8 +3571,6 @@ HANDLE OpenConfigFile(char *fn)
UCHAR Value[MAX_PATH];
FILETIME LastWriteTime;
SYSTEMTIME Time;
- char Msg[256];
-
// If no directory, use current
if (BPQDirectory[0] == 0)
@@ -3591,11 +3595,9 @@ HANDLE OpenConfigFile(char *fn)
GetFileTime(handle, NULL, NULL, &LastWriteTime);
FileTimeToSystemTime(&LastWriteTime, &Time);
- sprintf(Msg,"BPQ32 Config File %s Created %.2d:%.2d %d/%.2d/%.2d\n", Value,
+ Debugprintf("BPQ32 Config File %s Created %.2d:%.2d %d/%.2d/%.2d\n", Value,
Time.wHour, Time.wMinute, Time.wYear, Time.wMonth, Time.wDay);
- OutputDebugString(Msg);
-
return(handle);
}
@@ -4652,7 +4654,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
}
wsprintf(Title,"BPQ32 Beacon Configuration");
- MySetWindowText(UIhWnd, Title);
+ MySetWindowText(0, UIhWnd, Title);
ShowWindow(UIhWnd, SW_NORMAL);
OnTabbedDialogInit(UIhWnd); // Set up pages
@@ -5347,7 +5349,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
wsprintf(Title,"BPQ32 Beacon Utility Version");
- MySetWindowText(UIhWnd, Title);
+ MySetWindowText(0, UIhWnd, Title);
return 0;
}
@@ -5546,24 +5548,23 @@ DllExport int APIENTRY WritetoConsole(char * buff)
DllExport VOID * APIENTRY GetBuff();
+int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF);
+
int WritetoConsoleLocal(char * buff)
{
int len=strlen(buff);
UINT * buffptr;
- if (Semaphore.Flag == 0)
- return WritetoConsoleSupport(buff);
-
- buffptr = GetBuff();
+ buffptr = (UINT *)zalloc(512);
if (buffptr == 0) // No buffers, so send direct
- return WritetoConsoleSupport(buff);
+ return 0;
if (len > 300)
len = 300;
memcpy(&buffptr[2], buff, len + 1);
- C_Q_ADD(&WritetoConsoleQ, buffptr);
+ C_Q_ADD_NP(&WritetoConsoleQ, buffptr);
return 0;
}
@@ -5600,7 +5601,7 @@ int WritetoConsoleSupport(char * buff)
DllExport VOID APIENTRY BPQOutputDebugString(char * String)
{
- OutputDebugString(String);
+ Debugprintf(String);
return;
}
@@ -5667,7 +5668,7 @@ BOOLEAN CheckifBPQ32isLoaded()
{
if (AttachingProcess == 0) // Already starting BPQ32
{
- OutputDebugString("BPQ32 No other bpq32 programs running - Loading BPQ32.exe\n");
+ Debugprintf("BPQ32 No other bpq32 programs running - Loading BPQ32.exe");
StartBPQ32();
}
return FALSE;
@@ -5764,7 +5765,7 @@ BOOLEAN StartBPQ32()
strcat(Errbuff,Value);
strcat(Errbuff," failed ");
strcat(Errbuff,buff);
- OutputDebugString(Errbuff);
+ Debugprintf(Errbuff);
AttachingProcess = 0;
return FALSE;
}
@@ -5822,18 +5823,6 @@ DllExport VOID * APIENTRY GetBuff()
}
-VOID __cdecl Debugprintf(const char * format, ...)
-{
- char Mess[10000];
- va_list(arglist);
-
- va_start(arglist, format);
- vsprintf(Mess, format, arglist);
- strcat(Mess, "\r\n");
- OutputDebugString(Mess);
-
- return;
-}
unsigned short int compute_crc(unsigned char *buf, int txlen);
@@ -6096,7 +6085,7 @@ DllExport VOID APIENTRY CloseAllPrograms()
ShowWindow(hwndClosing, SW_SHOW);
}
-VOID RealCloseAllPrograms()
+DllExport VOID APIENTRY RealCloseAllPrograms()
{
hookNodeClosing("Shutdown");
Sleep(500);
@@ -6349,7 +6338,6 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile)
{
if (len > 76)
{
- len += sprintf(&RegLine[len], "\\\r\n", RegLine);
strcat(RegLine, "\\\r\n");
WriteFile(hFile, RegLine, len, &written, NULL);
strcpy(RegLine, " ");
diff --git a/CBPQ32.sln b/CBPQ32.sln
new file mode 100644
index 0000000..d9b2153
--- /dev/null
+++ b/CBPQ32.sln
@@ -0,0 +1,79 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQWinAPP", "BPQWinAPP.vcproj", "{005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinmorControl", "WinmorControl.vcproj", "{005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQMail", "BPQMail.vcproj", "{3766AA10-C777-4ED8-A83D-F1452DE9B665}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LinBPQ", "MailNode.vcproj", "{3766AA10-C777-4ED8-A83D-F1452DE9B666}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CBPQ32", "CBPQ32.vcproj", "{8EFA1E59-8654-4A23-8102-AA77A074D57C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQChat", "BPQChat.vcproj", "{2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTerminal", "BPQTerminal.vcproj", "{04F2B9AD-4369-49EA-82EC-3C701C97C6D8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTermTCP", "BPQTermTCP.vcproj", "{99625C77-CABA-469A-A5A7-ECB4EE354225}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Relase Static|Win32 = Relase Static|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.ActiveCfg = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.Build.0 = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.Build.0 = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.Build.0 = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.ActiveCfg = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.Build.0 = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.Build.0 = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.Build.0 = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.Build.0 = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.Build.0 = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.Build.0 = Debug|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.Build.0 = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.ActiveCfg = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.Build.0 = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.Build.0 = Debug|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.Build.0 = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.ActiveCfg = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.Build.0 = Release|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.Build.0 = Debug|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.ActiveCfg = Relase Static|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.Build.0 = Relase Static|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.ActiveCfg = Release|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.Build.0 = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.ActiveCfg = Debug|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.Build.0 = Debug|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.Build.0 = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.ActiveCfg = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/CBPQ322026.sln b/CBPQ322026.sln
new file mode 100644
index 0000000..ad64694
--- /dev/null
+++ b/CBPQ322026.sln
@@ -0,0 +1,84 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 18
+VisualStudioVersion = 18.10.12201.205 stable
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQ32.EXE", "BPQWinAPP.vcxproj", "{005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinmorControl", "WinmorControl.vcxproj", "{005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQMail", "BPQMail.vcxproj", "{3766AA10-C777-4ED8-A83D-F1452DE9B665}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LinBPQ", "MailNode.vcxproj", "{3766AA10-C777-4ED8-A83D-F1452DE9B666}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQ32.DLL", "CBPQ32.vcxproj", "{8EFA1E59-8654-4A23-8102-AA77A074D57C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQChat", "BPQChat.vcxproj", "{2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTerminal", "BPQTerminal.vcxproj", "{04F2B9AD-4369-49EA-82EC-3C701C97C6D8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTermTCP", "BPQTermTCP.vcxproj", "{99625C77-CABA-469A-A5A7-ECB4EE354225}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Relase Static|Win32 = Relase Static|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.ActiveCfg = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.Build.0 = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.Build.0 = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.Build.0 = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.ActiveCfg = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.Build.0 = Debug|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.Build.0 = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.ActiveCfg = Release|Win32
+ {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.Build.0 = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.Build.0 = Debug|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.Build.0 = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.ActiveCfg = Release|Win32
+ {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.Build.0 = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.Build.0 = Debug|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.Build.0 = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.ActiveCfg = Release|Win32
+ {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.Build.0 = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.Build.0 = Debug|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.Build.0 = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.ActiveCfg = Release|Win32
+ {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.Build.0 = Release|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.Build.0 = Debug|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.ActiveCfg = Relase Static|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.Build.0 = Relase Static|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.ActiveCfg = Release|Win32
+ {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.Build.0 = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.ActiveCfg = Debug|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.Build.0 = Debug|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.ActiveCfg = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.Build.0 = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.ActiveCfg = Release|Win32
+ {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {FB815A29-A2DD-470A-B0AF-7188AA0F4C7F}
+ EndGlobalSection
+EndGlobal
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..9dcfb88
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.18)
+
+project(LinBPQ)
+
+# Our Project
+
+set(CMAKE_C_FLAGS "-DLINBPQ -g -fcommon -fasynchronous-unwind-tables")
+
+set(SOURCE_FILES
+pngwtran.c pngrtran.c pngset.c pngrio.c pngwio.c pngtrans.c pngrutil.c pngwutil.c
+ pngread.c pngwrite.c png.c pngerror.c pngget.c pngmem.c APRSIconData.c AISCommon.c
+ upnp.c APRSStdPages.c HSMODEM.c WinRPR.c KISSHF.c TNCEmulators.c bpqhdlc.c SerialPort.c
+ adif.c WebMail.c utf8Routines.c VARA.c LzFind.c Alloc.c LzmaDec.c LzmaEnc.c LzmaLib.c
+ Multicast.c ARDOP.c IPCode.c FLDigi.c linether.c CMSAuth.c APRSCode.c BPQtoAGW.c KAMPactor.c
+ AEAPactor.c HALDriver.c MULTIPSK.c BBSHTMLConfig.c ChatHTMLConfig.c BBSUtilities.c bpqaxip.c
+ BPQINP3.c BPQNRR.c cMain.c Cmd.c CommonCode.c HTMLCommonCode.c compatbits.c config.c datadefs.c
+ FBBRoutines.c HFCommon.c Housekeeping.c HTTPcode.c kiss.c L2Code.c L3Code.c L4Code.c lzhuf32.c
+ MailCommands.c MailDataDefs.c LinBPQ.c MailRouting.c MailTCP.c MBLRoutines.c md5.c Moncode.c
+ NNTPRoutines.c RigControl.c TelnetV6.c WINMOR.c TNCCode.c UZ7HODrv.c WPRoutines.c
+ SCSTrackeMulti.c SCSPactor.c SCSTracker.c HanksRT.c UIRoutines.c AGWAPI.c AGWMoncode.c
+ DRATS.c FreeDATA.c base64.c Events.c nodeapi.c mailapi.c mqtt.c RHP.c NETROMTCP.c)
+
+add_executable(${PROJECT_NAME} ${SOURCE_FILES})
+
diff --git a/Cmd.c b/Cmd.c
index 36fc09d..a4d8c02 100644
--- a/Cmd.c
+++ b/Cmd.c
@@ -73,6 +73,7 @@ void SendVARANetromNodes(struct TNCINFO * TNC, MESSAGE *Buffer);
VOID DoNetromConnect(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST * Dest, BOOL Spy, int Service);
VOID sendAlltoOneNeigbour(struct ROUTE * Route);
VOID CMDSTREAMS(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CMDX * CMD);
+char * FormatIP(uint32_t Addr);
extern VOID KISSTX(struct KISSINFO * KISS, PMESSAGE Buffer);
@@ -263,8 +264,8 @@ char * __cdecl Cmdprintf(TRANSPORTENTRY * Session, char * Bufferptr, const char
Paclen = 255;
va_start(arglist, format);
-
MsgLen = vsprintf(Mess, format, arglist);
+ va_end(arglist);
OldLen = (int)(Bufferptr - (char *)REPLYBUFFER->L2DATA);
@@ -467,6 +468,11 @@ VOID RIGRECONFIG(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, str
VOID REBOOT(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CMDX * CMD)
{
+ char * ptr = 0;
+
+ *(ptr) = 0;
+
+
if (Reboot())
{
strcpy(Bufferptr, REBOOTOK);
@@ -849,10 +855,10 @@ BOOL cATTACHTOBBS(TRANSPORTENTRY * Session, UINT Mask, int Paclen, int * AnySess
ApplNum = 1;
- while (APPLMASK && (APPLMASK & 1) == 0)
+ while (Mask && (Mask & 1) == 0)
{
ApplNum++;
- APPLMASK >>= 1;
+ Mask >>= 1;
}
HOSTSESS->HOSTAPPLNUM = ApplNum;
@@ -1618,7 +1624,7 @@ VOID CMDL00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
{
// Dump Link State
- int secs = time(NULL) - LINK->LASTFRAMESENT;
+ int secs = NOW - LINK->LASTFRAMESENT;
Bufferptr = Cmdprintf(Session, Bufferptr, " Debug Info: LINK->LINKNS %d LINK->LINKOWS %d SDTSLOT %d LINKWINDOW %d L2FLAGS %d\r", LINK->LINKNS, LINK->LINKOWS, LINK->SDTSLOT, LINK->LINKWINDOW, LINK->L2FLAGS);
Bufferptr = Cmdprintf(Session, Bufferptr, " Debug Info: Slots %x %x %x %x %x %x %x %x\r", LINK->FRAMES[0], LINK->FRAMES[1], LINK->FRAMES[2], LINK->FRAMES[3],
@@ -3292,6 +3298,17 @@ VOID LINKCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
}
+const char SwVers[12][23] = {
+ "Unknown", "BPQ16 (DOS)", "XRouter16 (DOS)", "XServ16 (DOS)",
+ "XRouter32 (Win GUI)",
+ "XR32 (Win TUI)",
+ "XS32 (Win TUI BBS)", "XRLin (Linux x86)",
+ "XRouter (Raspberry Pi)",
+ "BPQ32 (Windows)", "BPQ32 (Linux)"
+};
+
+
+
char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST * Dest)
{
char Normcall[10];
@@ -3300,6 +3317,7 @@ char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST *
struct INP3_DEST_ROUTE_ENTRY * Route;
struct ROUTE * Neighbour;
int i, Active, len;
+ struct tm * TM;
Alias[6] = 0;
@@ -3308,15 +3326,67 @@ char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST *
Normcall[ConvFromAX25(Dest->DEST_CALL, Normcall)] = 0;
- Bufferptr = Cmdprintf(Session, Bufferptr, "Routes to: %s:%s", Alias, Normcall);
+ if (Dest->XROptions)
+ {
+ XROptions * Options = Dest->XROptions;
+
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Nodes:\rInfo for: %s:%s [%s] ", Alias, Normcall, SwVers[Options->SWType]);
+ if (Options->Ver)
+ Bufferptr = Cmdprintf(Session, Bufferptr, "v%s ", Options->Ver);
+
+ if (Dest->DEST_COUNT)
+ Bufferptr = Cmdprintf(Session, Bufferptr, " RTT=%4.2f FR=%d %c %.1d",
+ Dest->DEST_RTT /1000.0, Dest->DEST_COUNT, (Dest->DEST_STATE & 0x40)? 'B':' ', (Dest->DEST_STATE & 63));
- if (Dest->DEST_COUNT)
- Bufferptr = Cmdprintf(Session, Bufferptr, " RTT=%4.2f FR=%d %c %.1d\r",
- Dest->DEST_RTT /1000.0, Dest->DEST_COUNT,
- (Dest->DEST_STATE & 0x40)? 'B':' ', (Dest->DEST_STATE & 63));
- else
Bufferptr = Cmdprintf(Session, Bufferptr, "\r");
+
+ if (Options->Lat)
+ {
+ if (Options->Lat > 0)
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Pos=%3.4fN ", Options->Lat);
+ else
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Pos=%3.4fS ", -Options->Lat);
+
+ if (Options->Lon > 0)
+ Bufferptr = Cmdprintf(Session, Bufferptr, "%3.4fE ", Options->Lon);
+ else
+ Bufferptr = Cmdprintf(Session, Bufferptr, "%3.4fW ", -Options->Lon);
+ }
+ if (Options->LOC)
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Loc=%s ", Options->LOC);
+
+ if (Options->QTH)
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Qth=%s", Options->QTH);
+
+ if (Options->IPADDR)
+ Bufferptr = Cmdprintf(Session, Bufferptr, "\rIP=%s/%d", FormatIP(Options->IPADDR), Options->Mask);
+
+ Bufferptr = Cmdprintf(Session, Bufferptr, "\r\rRoutes:\r");
+
+
+
+/*
+G7TAJ-1:TANK2} Nodes:
+Info for: XRLN64:G8PZT-1 (HOST) [XRLin]
+ Pos=50.1458N 5.1250W Loc=IO70KD Qth=LAMANVA
+ IP=44.135.49.90/32 v505i OFF
+ Supports: INP3 L3ROUT NRR NCMP L4X NDP
+ BBS XRCHAT
+ Updated: 09/07 06:07
+*/
+ }
+ else
+ {
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Routes to: %s:%s", Alias, Normcall);
+
+ if (Dest->DEST_COUNT)
+ Bufferptr = Cmdprintf(Session, Bufferptr, " RTT=%4.2f FR=%d %c %.1d\r",
+ Dest->DEST_RTT /1000.0, Dest->DEST_COUNT,
+ (Dest->DEST_STATE & 0x40)? 'B':' ', (Dest->DEST_STATE & 63));
+ else
+ Bufferptr = Cmdprintf(Session, Bufferptr, "\r");
+ }
NRRoute = &Dest->NRROUTE[0];
Active = Dest->DEST_ROUTE;
@@ -3349,12 +3419,18 @@ char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST *
if (Neighbour)
{
double srtt = Route->STT/100.0;
+ TM = gmtime(&Route->LastRefreshed);
+
+
+// TM->tm_yday, , TM->tm_sec, MH->MHFreq, LOC);
+
+
len = ConvFromAX25(Neighbour->NEIGHBOUR_CALL, Normcall);
Normcall[len] = 0;
- Bufferptr = Cmdprintf(Session, Bufferptr, "%c %d %4.2fs %d %s\r",
- (Active == i + 3)?'>':' ',Route->Hops, srtt, Neighbour->NEIGHBOUR_PORT, Normcall);
+ Bufferptr = Cmdprintf(Session, Bufferptr, "%c %d %4.2fs %d %s %02d:%02d\r",
+ (Active == i + 3)?'>':' ',Route->Hops, srtt, Neighbour->NEIGHBOUR_PORT, Normcall, TM->tm_hour, TM->tm_min);
}
Route++;
}
@@ -4250,6 +4326,45 @@ VOID NRRCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
return;
}
+VOID SendNRPing(struct DEST_LIST * DEST, TRANSPORTENTRY * Session);
+
+VOID NRPING(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CMDX * UserCMD)
+{
+ // Send Paula's NCMP PING command = Netrom Ping
+
+ char * ptr, *Context;
+ struct DEST_LIST * Dest = DESTS;
+ int count = MAXDESTS;
+
+ ptr = strtok_s(CmdTail, " ", &Context);
+
+ if (ptr)
+ {
+ UCHAR AXCall[8];
+ int count;
+
+ ConvToAX25(ptr, AXCall);
+ strcat(ptr, " ");
+
+ for (count = 0; count < MAXDESTS; count++)
+ {
+ if (memcmp(Dest->DEST_ALIAS, ptr, 6) == 0 || CompareCalls(Dest->DEST_CALL, AXCall))
+ {
+ SendNRPing(Dest, Session);
+ memcpy(Bufferptr, OKMSG, 3);
+ Bufferptr += 3;
+ SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
+
+ return;
+ }
+ Dest++;
+ }
+ }
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Not found\r");
+ SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
+ return;
+}
+
int CHECKINTERLOCK(struct PORTCONTROL * OURPORT)
{
// See if any Interlocked ports are Busy
@@ -4808,6 +4923,7 @@ struct CMDX COMMANDS[] =
"AXMHEARD ",3,AXMHEARD,0,
"TELSTATUS ",3,SHOWTELNET,0,
"NRR ",1,NRRCMD,0,
+ "NPING ",1,NRPING,0,
"PING ",2,PING,0,
"AGWSTATUS ",3,SHOWAGW,0,
"ARP ",3,SHOWARP,0,
@@ -6197,7 +6313,7 @@ VOID KISSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
// Send Command
PORT->Session = Session;
- PORT->LastKISSCmdTime = time(NULL);
+ PORT->LastKISSCmdTime = NOW;
PORT = (struct PORTCONTROL *)KISS->FIRSTPORT; // ALL FRAMES GO ON SAME Q
KissLen = KissEncode(KissString, ENCBUFF, KissLen);
@@ -6270,7 +6386,7 @@ VOID LORACMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
KissLen = KissEncode(KissString, ENCBUFF, KissLen);
PORT->Session = Session;
- PORT->LastKISSCmdTime = time(NULL);
+ PORT->LastKISSCmdTime = NOW;
ASYSEND(PORT, ENCBUFF, KissLen);
@@ -6761,7 +6877,7 @@ VOID QTSMCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
// Send Command
PORT->Session = Session;
- PORT->LastKISSCmdTime = time(NULL);
+ PORT->LastKISSCmdTime = NOW;
KissString[0] |= KISS->OURCTRL;
PORT = (struct PORTCONTROL *)KISS->FIRSTPORT; // ALL FRAMES GO ON SAME Q
diff --git a/CommonCode.c b/CommonCode.c
index 2c01b7c..3559135 100644
--- a/CommonCode.c
+++ b/CommonCode.c
@@ -89,6 +89,113 @@ extern int PoolBuilt;
extern int EnableOARCAPI;
+DllExport UCHAR * APIENTRY GetLogDirectory();
+
+
+FILE * DebugHandle = NULL;
+
+DllExport VOID APIENTRY OpenDebugLog()
+{
+ time_t T;
+ struct tm * tm;
+ char FN[256];
+
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ if (DebugHandle == 0)
+ {
+ sprintf(FN,"%s/logs/NodeDebuglog_%02d%02d%02d.log", GetLogDirectory(), tm->tm_year - 100, tm->tm_mon + 1, tm->tm_mday);
+ DebugHandle = fopen(FN, "ab");
+ }
+}
+
+DllExport VOID APIENTRY CloseDebugLog()
+{
+ if (DebugHandle)
+ fclose(DebugHandle);
+ DebugHandle = 0;
+}
+
+
+DllExport VOID __cdecl Debugprintf(const char * format, ...)
+{
+ char Mess[8192];
+ time_t T;
+ struct tm * tm;
+ int Len;
+ char LogMsg[256];
+
+ va_list(arglist);
+
+ va_start(arglist, format);
+ Len = vsnprintf(Mess, sizeof(Mess), format, arglist);
+
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ if (DebugHandle == 0)
+ {
+ char FN[256];
+
+ sprintf(FN,"%s/logs/NodeDebuglog_%02d%02d%02d.log", GetLogDirectory(), tm->tm_year - 100, tm->tm_mon + 1, tm->tm_mday);
+ DebugHandle = fopen(FN, "ab");
+
+ if (DebugHandle == 0)
+ return;
+ }
+
+
+ Len = sprintf(LogMsg, "%02d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec);
+ fwrite(LogMsg, Len, 1, DebugHandle);
+
+ if (DebugHandle == 0)
+ return;
+
+ fwrite(Mess, strlen(Mess), 1, DebugHandle);
+ fwrite("\r\n", 2, 1, DebugHandle);
+
+ return;
+}
+
+DllExport VOID __cdecl DebugprintNOLF(const char * format, ...)
+{
+ char Mess[8192];
+ time_t T;
+ struct tm * tm;
+ int Len;
+ char LogMsg[256];
+
+ va_list(arglist);
+
+ va_start(arglist, format);
+ Len = vsnprintf(Mess, sizeof(Mess), format, arglist);
+
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ if (DebugHandle == 0)
+ {
+ char FN[256];
+
+ sprintf(FN,"%s/logs/NodeDebuglog_%02d%02d%02d.log", GetLogDirectory(), tm->tm_year - 100, tm->tm_mon + 1, tm->tm_mday);
+ DebugHandle = fopen(FN, "ab");
+
+ if (DebugHandle == 0)
+ return;
+ }
+
+
+ Len = sprintf(LogMsg, "%02d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec);
+ fwrite(LogMsg, Len, 1, DebugHandle);
+
+ if (DebugHandle == 0)
+ return;
+
+ fwrite(Mess, strlen(Mess), 1, DebugHandle);
+ return;
+}
+
// Read/Write length field in a buffer header
// Needed for Big/LittleEndian and ARM5 (unaligned operation problem) portability
@@ -395,6 +502,23 @@ BOK1:
return 0;
}
+UINT ReleaseBufferQuick(VOID *pBUFF)
+{
+ void ** pointer, ** BUFF = pBUFF;
+
+ if (Semaphore.Flag == 0)
+ Debugprintf("ReleaseBufferQuick called without semaphore");
+
+ pointer = FREE_Q;
+
+ *BUFF = pointer;
+
+ FREE_Q = BUFF;
+
+ QCOUNT++;
+ return 0;
+}
+
void CheckFreeQueue(char * File, int Line)
{
@@ -570,7 +694,7 @@ VOID * _GetBuff(char * File, int Line)
char * fptr = 0;
unsigned char * byteaddr;
- CheckFreeQueue(File, Line);
+// CheckFreeQueue(File, Line);
Temp = Q_REM(&FREE_Q);
@@ -621,6 +745,46 @@ VOID * _GetBuff(char * File, int Line)
return Temp;
}
+VOID * GetBuffQuick()
+{
+ UINT * Temp;
+ MESSAGE * Msg;
+ char * fptr = 0;
+
+ Temp = Q_REM(&FREE_Q);
+
+ if (Semaphore.Flag == 0)
+ Debugprintf("GetBuff called without semaphore");
+
+ if (Temp)
+ {
+ QCOUNT--;
+
+ if (QCOUNT < MINBUFFCOUNT)
+ MINBUFFCOUNT = QCOUNT;
+
+ Msg = (MESSAGE *)Temp;
+
+ Msg->Process = (short)GetCurrentProcessId();
+ Msg->Linkptr = NULL;
+ Msg->Padding[0] = 0; // Used for modem status info
+ }
+ else if (QCOUNT != 0)
+ {
+ // Queue must be corrupt
+
+ Debugprintf("Fatal - Getbuff returned NULL and Q not empty - exit");
+ FindLostBuffers();
+ WriteMiniDump();
+ Restart();
+ }
+ else
+ Debugprintf("Warning - Getbuff returned NULL");
+
+ return Temp;
+}
+
+
void * zalloc(int len)
{
// malloc and clear
@@ -1508,6 +1672,42 @@ DllExport int APIENTRY SessionState(int stream, int * state, int * change)
return 0;
}
+int SessionStateNoSem(int stream, int * state, int * change)
+{
+ // Get current Session State. Any state changed is ACK'ed
+ // automatically. See BPQHOST functions 4 and 5.
+
+ BPQVECSTRUC * HOST = &BPQHOSTVECTOR[stream -1]; // API counts from 1
+
+ Check_Timer(); // In case Appl doesnt call it often ehough
+
+ // CX = 0 if stream disconnected or CX = 1 if stream connected
+ // DX = 0 if no change of state since last read, or DX = 1 if
+ // the connected/disconnected state has changed since
+ // last read (ie. delta-stream status).
+
+ // HOSTFLAGS = Bit 80 = Allocated
+ // Bit 40 = Disc Request
+ // Bit 20 = Stay Flag
+ // Bit 02 and 01 State Change Bits
+
+ if ((HOST->HOSTFLAGS & 3) == 0)
+ // No Chaange
+ *change = 0;
+ else
+ *change = 1;
+
+ if (HOST->HOSTSESSION) // LOCAL SESSION
+ // Connected
+ *state = 1;
+ else
+ *state = 0;
+
+ HOST->HOSTFLAGS &= 0xFC; // Clear Change Bitd
+ return 0;
+}
+
+
DllExport int APIENTRY SessionStateNoAck(int stream, int * state)
{
// Get current Session State. Dont ACK any change
@@ -2384,7 +2584,6 @@ HANDLE OpenCOMPort(char * pPort, int speed, BOOL SetDTR, BOOL SetRTS, BOOL Quiet
sprintf(buf,"%s Setup Failed %d ", pPort, GetLastError());
WritetoConsoleLocal(buf);
- OutputDebugString(buf);
CloseHandle(fd);
return 0;
}
@@ -3135,7 +3334,7 @@ char * FormatMH(PMHSTRUC MH, char Format)
if (Format == 'U' || Format =='L')
szClock = MH->MHTIME;
else
- szClock = time(NULL) - MH->MHTIME;
+ szClock = NOW - MH->MHTIME;
if (Format == 'L')
TM = localtime(&szClock);
@@ -3159,7 +3358,6 @@ Dll VOID APIENTRY CreateOneTimePassword(char * Password, char * KeyPhrase, int T
// Create a time dependent One Time Password from the KeyPhrase
// TimeOffset is used when checking to allow for slight variation in clocks
- time_t NOW = time(NULL);
UCHAR Hash[16];
char Key[1000];
int i, chr;
@@ -3505,7 +3703,6 @@ VOID SendNETROMRoute(struct PORTCONTROL * PORT, unsigned char * axcall)
int Len;
char Call[10];
char Report[16];
- time_t Now = time(NULL);
int NeedSend = FALSE;
@@ -3516,7 +3713,7 @@ VOID SendNETROMRoute(struct PORTCONTROL * PORT, unsigned char * axcall)
sprintf(Report, "%s,%d,", Call, PORT->PORTTYPE);
- if (Now - TimeLastNRRouteSent > 60)
+ if (NOW - TimeLastNRRouteSent > 60)
NeedSend = TRUE;
if (strstr(NRRouteMessage, Report) == 0) // reported recently
@@ -3540,7 +3737,7 @@ VOID SendNETROMRoute(struct PORTCONTROL * PORT, unsigned char * axcall)
SendReportMsg((char *)&AXMSG.DEST, Len + 16) ;
- TimeLastNRRouteSent = Now;
+ TimeLastNRRouteSent = NOW;
NRRouteMessage[0] = 0;
}
@@ -3632,6 +3829,7 @@ int __sync_lock_test_and_set(int * ptr, int val)
#define GetSemaphore(Semaphore,ID) _GetSemaphore(Semaphore, ID, __FILE__, __LINE__)
+BOOL Closing;
void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line)
{
@@ -3646,7 +3844,7 @@ void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line)
loop1:
- while (Semaphore->Flag != 0)
+ while (Semaphore->Flag != 0 && Closing == 0)
{
Sleep(10);
}
@@ -3707,41 +3905,54 @@ USHORT WINAPI RtlCaptureStackBackTrace(
*/
#endif
-void printStack(void)
+void printStack()
{
-#ifdef WIN32
-#ifdef _DEBUG // So we can use on 98/2K
+#ifdef BPQ32
+ unsigned int i, n;
+ void * stack[ 100 ];
+ unsigned short frames;
+
+ DWORD dwDisplacement;
+ IMAGEHLP_LINE64 line;
+ char * fptr;
+ HANDLE process;
- unsigned int i;
- void * stack[ 100 ];
- unsigned short frames;
- SYMBOL_INFO * symbol;
- HANDLE process;
- Debugprintf("Stack Backtrace");
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
+ PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
+
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ symbol->MaxNameLen = MAX_SYM_NAME;
+
+ Debugprintf("Stack Backtrace\r\n");
process = GetCurrentProcess();
+ SymSetOptions(SYMOPT_LOAD_LINES);
SymInitialize( process, NULL, TRUE );
- frames = RtlCaptureStackBackTrace( 0, 60, stack, NULL );
- symbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 );
- symbol->MaxNameLen = 255;
- symbol->SizeOfStruct = sizeof( SYMBOL_INFO );
+ frames = RtlCaptureStackBackTrace(0, 60, stack, NULL );
for( i = 0; i < frames; i++ )
{
- SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
+ n = SymGetLineFromAddr64(process, (DWORD64)stack[i], &dwDisplacement, &line);
+ n = SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
- Debugprintf( "%i: %s - %p", frames - i - 1, symbol->Name, symbol->Address );
- }
+ if (line.FileName)
+ {
+ fptr = line.FileName + (int)strlen(line.FileName); // remove path
+ while (*fptr != '\\' && *fptr != '/')
+ fptr--;
- free(symbol);
+ fptr++;
-#endif
+ Debugprintf("%i: %s - %s Line %d Addr %p", frames - i - 1, symbol->Name, fptr, line.LineNumber, symbol->Address );
+ }
+ }
#endif
}
+
pthread_t ResolveUpdateThreadId = 0;
char NodeMapServer[80] = "update.g8bpq.net";
@@ -3801,7 +4012,7 @@ VOID ResolveUpdateThread(void * Unused)
{
hookNodeStarted();
nodeStartedSent = 1;
- LastNodeStatus = time(NULL);
+ LastNodeStatus = NOW;
}
}
@@ -3880,17 +4091,16 @@ VOID WriteMiniDumpThread()
BOOL ret;
char FN[256];
struct tm * TM;
- time_t Now = time(NULL);
- if (lastMiniDump == Now) // Not more than one per second
+ if (lastMiniDump == NOW) // Not more than one per second
{
Debugprintf("minidump suppressed");
return;
}
- lastMiniDump = Now;
+ lastMiniDump = NOW;
- TM = gmtime(&Now);
+ TM = gmtime(&NOW);
sprintf(FN, "%s/Logs/MiniDump%d%02d%02d%02d%02d%02d.dmp", BPQDirectory,
TM->tm_year + 1900, TM->tm_mon +1, TM->tm_mday, TM->tm_hour, TM->tm_min, TM->tm_sec);
diff --git a/DragSize.cur b/DragSize.cur
new file mode 100644
index 0000000..a33158a
--- /dev/null
+++ b/DragSize.cur
Binary files differ
diff --git a/Events.c b/Events.c
index 5d8d1be..0b4773e 100644
--- a/Events.c
+++ b/Events.c
@@ -154,7 +154,7 @@ void hookL2SessionAccepted(int Port, char * remotecall, char * ourcall, struct _
L2CONNECTSIN++;
LINK->apiSeq = linkSeq++;
- LINK->lastStatusSentTime = LINK->ConnectTime = time(NULL);
+ LINK->lastStatusSentTime = LINK->ConnectTime = NOW;
LINK->bytesTXed = LINK->bytesRXed = LINK->framesResent = LINK->framesRXed = LINK->framesTXed = 0;
LINK->LastStatusbytesTXed = LINK->LastStatusbytesRXed = 0;
strcpy(LINK->callingCall, remotecall);
@@ -163,7 +163,7 @@ void hookL2SessionAccepted(int Port, char * remotecall, char * ourcall, struct _
if (NodeAPISocket)
{
- LINK->lastStatusSentTime = time(NULL);
+ LINK->lastStatusSentTime = NOW;
udplen = sprintf(UDPMsg, "{\"@type\":\"LinkUpEvent\", \"node\": \"%s\", \"id\": %d, \"direction\": \"incoming\", \"port\": \"%d\", \"remote\": \"%s\", \"local\": \"%s\", \"isRF\": %s}",
NODECALLLOPPED, LINK->apiSeq, LINK->LINKPORT->PORTNUMBER, LINK->callingCall, LINK->receivingCall, (LINK->LINKPORT->isRF)?"true":"false");
@@ -190,11 +190,10 @@ void hookL2SessionDeleted(struct _LINKTABLE * LINK)
{
char Msg[256];
char timestamp[64];
- time_t sessionTime = time(NULL) - LINK->ConnectTime;
+ time_t sessionTime = NOW - LINK->ConnectTime;
double avBytesSent = LINK->bytesTXed / (sessionTime / 60.0);
double avBytesRXed = LINK->bytesRXed / (sessionTime / 60.0);
- time_t Now = time(NULL);
- struct tm * TM = localtime(&Now);
+ struct tm * TM = localtime(&NOW);
sprintf(timestamp, "%02d:%02d:%02d", TM->tm_hour, TM->tm_min, TM->tm_sec);
@@ -226,7 +225,7 @@ void hookL2SessionDeleted(struct _LINKTABLE * LINK)
void hookL2SessionAttempt(int Port, char * ourcall, char * remotecall, struct _LINKTABLE * LINK)
{
- LINK->lastStatusSentTime = LINK->ConnectTime = time(NULL);
+ LINK->lastStatusSentTime = LINK->ConnectTime = NOW;
LINK->bytesTXed = LINK->bytesRXed = LINK->framesResent = LINK->framesRXed = LINK->framesTXed = 0;
LINK->LastStatusbytesTXed = LINK->LastStatusbytesRXed = 0;
strcpy(LINK->callingCall, ourcall);
@@ -246,7 +245,7 @@ void hookL2SessionConnected(struct _LINKTABLE * LINK)
if (NodeAPISocket)
{
- LINK->lastStatusSentTime = time(NULL);
+ LINK->lastStatusSentTime = NOW;
udplen = sprintf(UDPMsg, "{\"@type\":\"LinkUpEvent\", \"node\": \"%s\", \"id\": %d, \"direction\": \"outgoing\", \"port\": \"%d\", \"remote\": \"%s\", \"local\": \"%s\", \"isRF\": %s}",
NODECALLLOPPED, LINK->apiSeq, LINK->LINKPORT->PORTNUMBER, LINK->callingCall, LINK->receivingCall, (LINK->LINKPORT->isRF)?"true":"false");
@@ -263,7 +262,6 @@ void hookL2SessionClosed(struct _LINKTABLE * LINK, char * Reason, char * Directi
char UDPMsg[1024];
int udplen;
- time_t Now = time(NULL);
if (NodeAPISocket)
{
@@ -276,14 +274,14 @@ void hookL2SessionClosed(struct _LINKTABLE * LINK, char * Reason, char * Directi
" \"time\": %d, \"upForSecs\": %d, \"frmsQdPeak\": %d, \"isRF\": %s}",
NODECALLLOPPED, LINK->apiSeq, LINK->LINKPORT->PORTNUMBER, LINK->receivingCall, LINK->callingCall,
LINK->bytesTXed , LINK->bytesRXed, LINK->framesTXed, LINK->framesRXed, COUNT_AT_L2(LINK), LINK->framesResent, Reason,
- (int)Now, (int)Now - LINK->ConnectTime, LINK->maxQueued, (LINK->LINKPORT->isRF)?"true":"false");
+ (int)NOW, (int)NOW - LINK->ConnectTime, LINK->maxQueued, (LINK->LINKPORT->isRF)?"true":"false");
else
udplen = sprintf(UDPMsg, "{\"@type\":\"LinkDownEvent\", \"node\": \"%s\", \"id\": %d, \"direction\": \"incoming\", \"port\": \"%d\", \"remote\": \"%s\", \"local\": \"%s\","
"\"bytesSent\": %d, \"bytesRcvd\": %d, \"frmsSent\": %d, \"frmsRcvd\": %d, \"frmsQueued\": %d, \"frmsResent\": %d, \"reason\": \"%s\","
" \"time\": %d, \"upForSecs\": %d, \"frmsQdPeak\": %d, \"isRF\": %s}",
NODECALLLOPPED, LINK->apiSeq, LINK->LINKPORT->PORTNUMBER, LINK->callingCall, LINK->receivingCall,
LINK->bytesTXed , LINK->bytesRXed, LINK->framesTXed, LINK->framesRXed, COUNT_AT_L2(LINK), LINK->framesResent, Reason,
- (int)Now, (int)Now - LINK->ConnectTime, LINK->maxQueued, (LINK->LINKPORT->isRF)?"true":"false");
+ (int)NOW, (int)NOW - LINK->ConnectTime, LINK->maxQueued, (LINK->LINKPORT->isRF)?"true":"false");
// Debugprintf(UDPMsg);
@@ -297,16 +295,15 @@ void hookL2SessionStatus(struct _LINKTABLE * LINK)
char UDPMsg[1024];
int udplen;
- time_t Now = time(NULL);
int bpsTx, bpsRx, interval;
if (NodeAPISocket)
{
- interval = Now - (int)LINK->lastStatusSentTime;
+ interval = NOW - (int)LINK->lastStatusSentTime;
bpsTx = (LINK->bytesTXed - LINK->LastStatusbytesTXed) / interval;
bpsRx = (LINK->bytesRXed - LINK->LastStatusbytesRXed) / interval;
- LINK->lastStatusSentTime = Now;
+ LINK->lastStatusSentTime = NOW;
LINK->LastStatusbytesTXed = LINK->bytesTXed;
LINK->LastStatusbytesRXed = LINK->bytesRXed;
@@ -316,14 +313,14 @@ void hookL2SessionStatus(struct _LINKTABLE * LINK)
"\"upForSecs\": %d, \"frmsQdPeak\": %d, \"bpsTxMean\": %d, \"bpsRxMean\": %d, \"frmQMax\": %d, \"l2rttMs\": %d, \"isRF\": %s}",
NODECALLLOPPED, LINK->apiSeq, LINK->LINKPORT->PORTNUMBER, LINK->receivingCall, LINK->callingCall,
LINK->bytesTXed, LINK->bytesRXed, LINK->framesTXed, LINK->framesRXed, 0, LINK->framesResent,
- (int)Now - LINK->ConnectTime, LINK->maxQueued, bpsTx, bpsRx, LINK->intervalMaxQueued, LINK->RTT, (LINK->LINKPORT->isRF)?"true":"false");
+ (int)NOW - LINK->ConnectTime, LINK->maxQueued, bpsTx, bpsRx, LINK->intervalMaxQueued, LINK->RTT, (LINK->LINKPORT->isRF)?"true":"false");
else
udplen = sprintf(UDPMsg, "{\"@type\":\"LinkStatus\", \"node\": \"%s\", \"id\": %d, \"direction\": \"incoming\", \"port\": \"%d\", \"remote\": \"%s\", \"local\": \"%s\","
"\"bytesSent\": %d, \"bytesRcvd\": %d, \"frmsSent\": %d, \"frmsRcvd\": %d, \"frmsQueued\": %d, \"frmsResent\": %d,"
"\"upForSecs\": %d, \"frmsQdPeak\": %d, \"bpsTxMean\": %d, \"bpsRxMean\": %d, \"frmQMax\": %d, \"l2rttMs\": %d, \"isRF\": %s}",
NODECALLLOPPED, LINK->apiSeq, LINK->LINKPORT->PORTNUMBER, LINK->callingCall, LINK->receivingCall,
LINK->bytesTXed, LINK->bytesRXed, LINK->framesTXed, LINK->framesRXed, 0, LINK->framesResent,
- (int)Now - LINK->ConnectTime, LINK->maxQueued, bpsTx, bpsRx, LINK->intervalMaxQueued, LINK->RTT, (LINK->LINKPORT->isRF)?"true":"false");
+ (int)NOW - LINK->ConnectTime, LINK->maxQueued, bpsTx, bpsRx, LINK->intervalMaxQueued, LINK->RTT, (LINK->LINKPORT->isRF)?"true":"false");
LINK->intervalMaxQueued = 0;
@@ -339,7 +336,7 @@ void hookL4SessionAttempt(struct STREAMINFO * STREAM, char * remotecall, char *
{
// Outgoing Connect
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesTXed = STREAM->bytesRXed = 0;
strcpy(STREAM->callingCall, ourcall);
@@ -351,7 +348,7 @@ void hookL4SessionAccepted(struct STREAMINFO * STREAM, char * remotecall, char *
{
// Incoming Connect
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesTXed = STREAM->bytesRXed = 0;
strcpy(STREAM->callingCall, remotecall);
@@ -381,11 +378,10 @@ void hookL4SessionDeleted(struct TNCINFO * TNC, struct STREAMINFO * STREAM)
if (STREAM->ConnectTime)
{
- time_t sessionTime = time(NULL) - STREAM->ConnectTime;
+ time_t sessionTime = NOW - STREAM->ConnectTime;
double avBytesRXed = STREAM->bytesRXed / (sessionTime / 60.0);
double avBytesSent = STREAM->bytesTXed / (sessionTime / 60.0);
- time_t Now = time(NULL);
- struct tm * TM = localtime(&Now);
+ struct tm * TM = localtime(&NOW);
sprintf(timestamp, "%02d:%02d:%02d", TM->tm_hour, TM->tm_min, TM->tm_sec);
if (sessionTime == 0)
@@ -444,7 +440,7 @@ void hookNodeClosing(char * Reason)
{
udplen = sprintf(UDPMsg, "{\"@type\": \"NodeDownEvent\", \"nodeCall\": \"%s\", \"nodeAlias\": \"%s\", \"reason\": \"%s\", \"uptimeSecs\": %d,"
"\"linksIn\": %d, \"linksOut\": %d, \"cctsIn\": %d, \"cctsOut\": %d, \"l3Relayed\": %d}",
- NODECALLLOPPED, MYALIASLOPPED, Reason, time(NULL) - TimeLoaded, L2CONNECTSIN, L2CONNECTSOUT, L4CONNECTSIN, L4CONNECTSOUT, L3FRAMES);
+ NODECALLLOPPED, MYALIASLOPPED, Reason, NOW - TimeLoaded, L2CONNECTSIN, L2CONNECTSOUT, L4CONNECTSIN, L4CONNECTSOUT, L3FRAMES);
// Debugprintf(UDPMsg);
@@ -471,7 +467,7 @@ void hookNodeRunning()
udplen = sprintf(UDPMsg, "{\"@type\": \"NodeStatus\", \"nodeCall\": \"%s\", \"nodeAlias\": \"%s\", \"locator\": \"%s\","
"\"latitude\": %f, \"longitude\": %f, \"software\": \"%s\", \"version\": \"%s\", \"uptimeSecs\": %d,"
"\"linksIn\": %d, \"linksOut\": %d, \"cctsIn\": %d, \"cctsOut\": %d, \"l3Relayed\": %d}",
- NODECALLLOPPED, MYALIASLOPPED, LOC, LatFromLOC, LonFromLOC, Software, VersionString, time(NULL) - TimeLoaded,
+ NODECALLLOPPED, MYALIASLOPPED, LOC, LatFromLOC, LonFromLOC, Software, VersionString, NOW - TimeLoaded,
L2CONNECTSIN, L2CONNECTSOUT, L4CONNECTSIN, L4CONNECTSOUT, L3FRAMES);
// Debugprintf(UDPMsg);
@@ -497,7 +493,7 @@ void IncomingL4ConnectionEvent(TRANSPORTENTRY * L4)
if (NodeAPISocket)
{
- L4->lastStatusSentTime = time(NULL);
+ L4->lastStatusSentTime = NOW;
remotecall[ConvFromAX25(L4->L4TARGET.DEST->DEST_CALL, remotecall)] = 0;
// remotecall[ConvFromAX25(L4->L4USER, remotecall)] = 0;
@@ -542,7 +538,7 @@ void OutgoingL4ConnectionEvent(TRANSPORTENTRY * L4)
if (NodeAPISocket)
{
- L4->lastStatusSentTime = time(NULL);
+ L4->lastStatusSentTime = NOW;
remotecall[ConvFromAX25(L4->L4TARGET.DEST->DEST_CALL, remotecall)] = 0;
// remotecall[ConvFromAX25(L4->L4USER, remotecall)] = 0;
@@ -635,7 +631,6 @@ void L4StatusSeport(TRANSPORTENTRY * L4)
char nodecall[16];
char circuitinfo[32];
int Count;
- time_t Now = time(NULL);
int Service = L4->Service;
@@ -644,7 +639,7 @@ void L4StatusSeport(TRANSPORTENTRY * L4)
if (NodeAPISocket)
{
- L4->lastStatusSentTime = Now;
+ L4->lastStatusSentTime = NOW;
nodecall[ConvFromAX25(L4->L4TARGET.DEST->DEST_CALL, nodecall)] = 0;
remotecall[ConvFromAX25(L4->L4USER, remotecall)] = 0;
ourcall[ConvFromAX25(L4->L4MYCALL, ourcall)] = 0;
@@ -664,11 +659,11 @@ void L4StatusSeport(TRANSPORTENTRY * L4)
if (Service == -1)
udplen = sprintf(UDPMsg, "{\"@type\": \"CircuitStatus\", \"node\": \"%s\", \"id\": %d, \"direction\": \"%s\","
"\"upForSecs\": %d,\"remote\": \"%s\", \"local\": \"%s\", \"segsSent\": %d, \"segsRcvd\": %d, \"segsResent\": %d, \"segsQueued\": %d}",
- NODECALLLOPPED, L4->apiSeq, L4->Direction, Now - L4->ConnectTime, remotecall, ourcall,L4->segsSent, L4->segsRcvd, L4->segsResent, Count);
+ NODECALLLOPPED, L4->apiSeq, L4->Direction, NOW - L4->ConnectTime, remotecall, ourcall,L4->segsSent, L4->segsRcvd, L4->segsResent, Count);
else
udplen = sprintf(UDPMsg, "{\"@type\": \"CircuitStatus\", \"node\": \"%s\", \"id\": %d, \"direction\": \"%s\","
"\"upForSecs\": %d, \"service\": %d, \"remote\": \"%s\", \"local\": \"%s\", \"segsSent\": %d, \"segsRcvd\": %d, \"segsResent\": %d, \"segsQueued\": %d}",
- NODECALLLOPPED, L4->apiSeq, L4->Direction, Now - L4->ConnectTime, Service, remotecall, ourcall,L4->segsSent, L4->segsRcvd, L4->segsResent, Count);
+ NODECALLLOPPED, L4->apiSeq, L4->Direction, NOW - L4->ConnectTime, Service, remotecall, ourcall,L4->segsSent, L4->segsRcvd, L4->segsResent, Count);
// Debugprintf(UDPMsg);
sendto(NodeAPISocket, UDPMsg, udplen, 0, (struct sockaddr *)&UDPreportdest, sizeof(UDPreportdest));
@@ -751,8 +746,7 @@ void APIL2Trace(struct _MESSAGE * Message, char * Dirn)
int NS;
int NR;
struct PORTCONTROL * PORT = GetPortTableEntryFromPortNum(Message->PORT);
- time_t Now = time(NULL);
-#ifdef LINBPQ
+#ifndef WIN32
struct timespec ts;
#else
FILETIME SystemTimeAsFileTime;
@@ -782,10 +776,10 @@ void APIL2Trace(struct _MESSAGE * Message, char * Dirn)
if ((Message->ORIGIN[6] & 1) == 0) // Digis - ignore for now
return;
-#ifdef LINBPQ
+#ifndef WIN32
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
- NowMs = Now;
+ NowMs = NOW;
else
NowMs = ts.tv_sec + ts.tv_nsec / 1000000000.0;
#else
@@ -982,14 +976,13 @@ void NetromTCPTrace(struct _MESSAGE * Message, char * Dirn)
{
char UDPMsg[2048];
int udplen;
- time_t Now = time(NULL);
int iLen = Message->LENGTH - (15 + MSGHDDRLEN);
int isRF = 0;
udplen = snprintf(UDPMsg, 2048,
"{\"@type\": \"L3Trace\", \"serial\": %d, \"time\": %d, \"dirn\": \"%s\", \"isRF\": %s, \"reportFrom\": \"%s\", \"port\": %d",
- UDPSeq++, (int)Now, Dirn, (isRF)?"true":"false", NODECALLLOPPED, Message->PORT);
+ UDPSeq++, (int)NOW, Dirn, (isRF)?"true":"false", NODECALLLOPPED, Message->PORT);
udplen += snprintf(&UDPMsg[udplen], 2048 - udplen,
diff --git a/FLDigi.c b/FLDigi.c
index d0ec34c..28155a8 100644
--- a/FLDigi.c
+++ b/FLDigi.c
@@ -224,7 +224,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// 100 mS Timer.
// G7TAJ's code to record activity for stats display
-
+
if ( TNC->BusyFlags && CDBusy )
TNC->PortRecord->PORTCONTROL.ACTIVE += 2;
@@ -246,7 +246,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
char Reply[80];
SendLen = sprintf(Reply, "c%s:42 %s:24 %c 7 T60R5W10",
- STREAM->MyCall, STREAM->RemoteCall, ARQ->OurStream);
+ STREAM->MyCall, STREAM->RemoteCall, ARQ->OurStream);
strcpy(TNC->WEB_PROTOSTATE, "Connecting");
SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
@@ -317,105 +317,142 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->SlowTimer = 100;
FLSlowTimer(TNC); // 10 Secs
}
-
+
return 0;
- case 1: // poll
+ if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE && TNC->FLInfo->KISSMODE == FALSE)
+ {
+ // See if time to reconnect
- if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE && TNC->FLInfo->KISSMODE == FALSE)
+ time( &ltime );
+ if (ltime-lasttime[port] >9 )
{
- // See if time to reconnect
-
- time( &ltime );
- if (ltime-lasttime[port] >9 )
- {
- ConnecttoFLDigi(port);
- lasttime[port]=ltime;
- }
+ ConnecttoFLDigi(port);
+ lasttime[port]=ltime;
}
+ }
pollloop:
- FD_ZERO(&readfs);
-
- if (TNC->CONNECTED)
- if (TNC->TCPSock)
- FD_SET(TNC->TCPSock,&readfs);
+ FD_ZERO(&readfs);
- if (TNC->CONNECTED || TNC->FLInfo->KISSMODE)
- FD_SET(TNC->TCPDataSock,&readfs);
-
-
-// FD_ZERO(&writefs);
+ if (TNC->CONNECTED)
+ if (TNC->TCPSock)
+ FD_SET(TNC->TCPSock,&readfs);
-// if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+ if (TNC->CONNECTED || TNC->FLInfo->KISSMODE)
+ FD_SET(TNC->TCPDataSock,&readfs);
- FD_ZERO(&errorfs);
-
- if (TNC->CONNECTED)
- if (TNC->TCPSock)
- FD_SET(TNC->TCPSock,&errorfs);
-
- if (TNC->CONNECTED || TNC->FLInfo->KISSMODE)
- FD_SET(TNC->TCPDataSock,&errorfs);
-
- if (select((int)TNC->TCPDataSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ // FD_ZERO(&writefs);
+
+ // if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+
+ FD_ZERO(&errorfs);
+
+ if (TNC->CONNECTED)
+ if (TNC->TCPSock)
+ FD_SET(TNC->TCPSock,&errorfs);
+
+ if (TNC->CONNECTED || TNC->FLInfo->KISSMODE)
+ FD_SET(TNC->TCPDataSock,&errorfs);
+
+
+ if (select((int)TNC->TCPDataSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ {
+ // See what happened
+
+ if (FD_ISSET(TNC->TCPDataSock,&readfs))
{
- // See what happened
+ // data available
- if (FD_ISSET(TNC->TCPDataSock,&readfs))
- {
- // data available
-
- ProcessReceivedData(port);
- goto pollloop;
- }
+ ProcessReceivedData(port);
+ goto pollloop;
+ }
- if (FD_ISSET(TNC->TCPSock,&readfs))
- {
- // data available
-
- ProcessXMLData(port);
- }
+ if (FD_ISSET(TNC->TCPSock,&readfs))
+ {
+ // data available
+ ProcessXMLData(port);
+ }
- if (FD_ISSET(TNC->TCPDataSock,&writefs))
- {
- // Connect success
- TNC->CONNECTED = TRUE;
- TNC->CONNECTING = FALSE;
+ if (FD_ISSET(TNC->TCPDataSock,&writefs))
+ {
+ // Connect success
- sprintf(TNC->WEB_COMMSSTATE, "Connected to FLDIGI");
- SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ TNC->CONNECTED = TRUE;
+ TNC->CONNECTING = FALSE;
- // If required, send signon
-
-// SendPacket(TNC->TCPDataSock,"\x1a", 1, 0);
-// SendPacket(TNC->TCPDataSock,"DIGITAL MODE ?", 14, 0);
-// SendPacket(TNC->TCPDataSock,"\x1b", 1, 0);
+ sprintf(TNC->WEB_COMMSSTATE, "Connected to FLDIGI");
+ SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
-// EnumWindows(EnumTNCWindowsProc, (LPARAM)TNC);
- }
-
- if (FD_ISSET(TNC->TCPDataSock,&errorfs) || FD_ISSET(TNC->TCPSock,&errorfs))
- {
- // if connecting, then failed, if connected then has just disconnected
+ // If required, send signon
-// if (CONNECTED[port])
-// if (!CONNECTING[port])
-// {
-// i=sprintf(ErrMsg, "MPSK Connection lost for BPQ Port %d\r\n", port);
-// WritetoConsole(ErrMsg);
-// }
+ // SendPacket(TNC->TCPDataSock,"\x1a", 1, 0);
+ // SendPacket(TNC->TCPDataSock,"DIGITAL MODE ?", 14, 0);
+ // SendPacket(TNC->TCPDataSock,"\x1b", 1, 0);
- CONNECTING[port]=FALSE;
- CONNECTED[port]=FALSE;
-
- }
+ // EnumWindows(EnumTNCWindowsProc, (LPARAM)TNC);
+ }
+
+ if (FD_ISSET(TNC->TCPDataSock,&errorfs) || FD_ISSET(TNC->TCPSock,&errorfs))
+ {
+ // if connecting, then failed, if connected then has just disconnected
+
+ // if (CONNECTED[port])
+ // if (!CONNECTING[port])
+ // {
+ // i=sprintf(ErrMsg, "MPSK Connection lost for BPQ Port %d\r\n", port);
+ // WritetoConsole(ErrMsg);
+ // }
+
+ CONNECTING[port]=FALSE;
+ CONNECTED[port]=FALSE;
}
+ }
+ if (TNC->PortRecord->UI_Q)
+ {
+ struct _MESSAGE * buffptr;
+ int SendLen;
+ char Reply[256];
+ int UILen;
+ char * UIMsg;
+
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+
+ UILen = buffptr->LENGTH;
+ UILen -= 23;
+ UIMsg = buffptr->L2DATA;
+
+ UIMsg[UILen] = 0;
+
+ if (UILen < 129 && TNC->Streams[0].Attached == FALSE) // Be sensible!
+ {
+ // >00uG8BPQ:72 TestA
+ SendLen = sprintf(Reply, "u%s:72 %s", TNC->NodeCall, UIMsg);
+ SendPacket(TNC, Reply, SendLen);
+ }
+ ReleaseBuffer(buffptr);
+ }
+
+
+ if (STREAM->PACTORtoBPQ_Q == 0)
+ {
+ if (STREAM->DiscWhenAllSent)
+ {
+ STREAM->DiscWhenAllSent--;
+ if (STREAM->DiscWhenAllSent == 0)
+ STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
+ }
+ }
+
+ return 0;
+
+
+ case 1: // poll
// See if any frames for this port
@@ -437,16 +474,7 @@ pollloop:
// if Busy, send buffer status poll
- if (STREAM->PACTORtoBPQ_Q == 0)
- {
- if (STREAM->DiscWhenAllSent)
- {
- STREAM->DiscWhenAllSent--;
- if (STREAM->DiscWhenAllSent == 0)
- STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
- }
- }
- else
+ if (STREAM->PACTORtoBPQ_Q)
{
int datalen;
@@ -464,36 +492,12 @@ pollloop:
WritetoTrace(TNC, &buffptr->Data[0], datalen - (MSGHDDRLEN + 1));
ReleaseBuffer(buffptr);
- return (1);
+ return 1;
}
}
- if (TNC->PortRecord->UI_Q)
- {
- struct _MESSAGE * buffptr;
- int SendLen;
- char Reply[256];
- int UILen;
- char * UIMsg;
-
- buffptr = Q_REM(&TNC->PortRecord->UI_Q);
-
- UILen = buffptr->LENGTH;
- UILen -= 23;
- UIMsg = buffptr->L2DATA;
-
- UIMsg[UILen] = 0;
+ return 0;
- if (UILen < 129 && TNC->Streams[0].Attached == FALSE) // Be sensible!
- {
- // >00uG8BPQ:72 TestA
- SendLen = sprintf(Reply, "u%s:72 %s", TNC->NodeCall, UIMsg);
- SendPacket(TNC, Reply, SendLen);
- }
- ReleaseBuffer(buffptr);
- }
-
- return (0);
case 2: // send
@@ -1113,7 +1117,7 @@ static int RestartTNC(struct TNCINFO * TNC)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<script type=\"text/javascript\">\r\n"
"function ScrollOutput()\r\n"
"{var textarea = document.getElementById('textarea');"
@@ -1171,7 +1175,7 @@ VOID * FLDigiExtInit(EXTPORTDATA * PortEntry)
// The Socket to connect to is in IOBASE
//
- srand((unsigned int)time(NULL));
+ srand((unsigned int)NOW);
port = PortEntry->PORTCONTROL.PORTNUMBER;
@@ -1565,7 +1569,7 @@ VOID ConnecttoFLDigiThread(void * portptr)
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -2538,7 +2542,7 @@ VOID ProcessFLDigiData(struct TNCINFO * TNC, UCHAR * Input, int Len, char Channe
SESS = TNC->PortRecord->ATTACHEDSESSIONS[0];
strcpy(STREAM->MyCall, call2);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->BytesAcked = STREAM->BytesResent = 0;
if (TNC->RIG && TNC->RIG != &TNC->DummyRig && strcmp(TNC->RIG->RigName, "PTT"))
@@ -2697,7 +2701,7 @@ AckConnectRequest:
if (STREAM->Connected)
goto SendKReply; // Repeated ACK
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->BytesAcked = STREAM->BytesResent = 0;
STREAM->Connected = TRUE;
@@ -3682,15 +3686,17 @@ VOID FLSlowTimer(struct TNCINFO * TNC)
if (FL->KISSMODE)
{
if (FL->Responding)
+ {
FL->Responding--;
- if (FL->Responding == 0)
- {
- TNC->TNCOK = FALSE;
- TNC->CONNECTED = FALSE;
+ if (FL->Responding == 0)
+ {
+ TNC->TNCOK = FALSE;
+ TNC->CONNECTED = FALSE;
- sprintf(TNC->WEB_COMMSSTATE, "Connection to FLDIGI lost");
- SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ sprintf(TNC->WEB_COMMSSTATE, "Connection to FLDIGI lost");
+ SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ }
// Set basic params till it responds
}
@@ -3838,7 +3844,7 @@ static int ProcessXMLData(int port)
SetWindowText(TNC->xIDC_CHANSTATE, "Busy");
strcpy(TNC->WEB_CHANSTATE, "Busy");
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
*/
return 0;
}
@@ -3852,7 +3858,7 @@ static int ProcessXMLData(int port)
strcpy(TNC->WEB_CHANSTATE, "Clear");
SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
*/
diff --git a/FreeDATA.c b/FreeDATA.c
index 846de0f..6a01aa2 100644
--- a/FreeDATA.c
+++ b/FreeDATA.c
@@ -418,32 +418,28 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
switch (fn)
{
- case 7:
+ case 7:
// 100 mS Timer. May now be needed, as Poll can be called more frequently in some circumstances
// G7TAJ's code to record activity for stats display
-
+
if ( TNC->BusyFlags && CDBusy )
TNC->PortRecord->PORTCONTROL.ACTIVE += 2;
if ( TNC->PTTState )
TNC->PortRecord->PORTCONTROL.SENDING += 2;
-
- SendPoll(TNC);
-
- // Check for buffered data to send
- if (TNC->FreeDataInfo->toSendTimeout)
- {
- TNC->FreeDataInfo->toSendTimeout--;
- if (TNC->FreeDataInfo->toSendTimeout <= 0)
- FlushData(TNC);
- }
+ SendPoll(TNC);
- return 0;
+ // Check for buffered data to send
- case 1: // poll
+ if (TNC->FreeDataInfo->toSendTimeout)
+ {
+ TNC->FreeDataInfo->toSendTimeout--;
+ if (TNC->FreeDataInfo->toSendTimeout <= 0)
+ FlushData(TNC);
+ }
// FreeDataCheckRX(TNC);
@@ -557,7 +553,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
FreeDataDisconnect(TNC);
strcpy(TNC->WEB_TNCSTATE, "Disconnecting");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
@@ -587,7 +583,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->SessionTimeLimit = TNC->DefaultSessionTimeLimit; // Reset Limit
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Stop Scanning
@@ -600,7 +596,12 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
}
-
+
+ return 0;
+
+ case 1: // poll
+
+
// See if any frames for this port
for (Stream = 0; Stream <= 2; Stream++)
@@ -632,7 +633,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
ReleaseBuffer(buffptr);
- return (1);
+ return 1;
}
if (STREAM->ReportDISC) // May need a delay so treat as a counter
@@ -647,7 +648,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
}
- return (0);
+ return 0;
case 2: // send
@@ -936,7 +937,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Save Command, and wait up to 10 secs
sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->ConnectCmd = _strdup(Connect);
TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
@@ -948,11 +949,11 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
memset(STREAM->RemoteCall, 0, 10);
strcpy(STREAM->RemoteCall, &buff->L2DATA[2]);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", STREAM->MyCall, STREAM->RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// FreeDataSendCommand(TNC, Connect);
FreeDataConnect(TNC, STREAM->RemoteCall);
@@ -1098,12 +1099,7 @@ VOID FreeDataReleasePort(struct TNCINFO * TNC)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
- "<script type=\"text/javascript\">\r\n"
- "function ScrollOutput()\r\n"
- "{var textarea = document.getElementById('textarea');"
- "textarea.scrollTop = textarea.scrollHeight;}</script>"
- "</head><title>FreDATA Status</title></head><body id=Text onload=\"ScrollOutput()\">"
+ int Len = sprintf(Buff,
"<h2><form method=post target=\"POPUPW\" onsubmit=\"POPUPW = window.open('about:blank','POPUPW',"
"'width=440,height=150');\" action=ARDOPAbort?%d>FreeData Status"
"<input name=Save value=\"Abort Session\" type=submit style=\"position: absolute; right: 20;\"></form></h2>",
@@ -1364,7 +1360,7 @@ VOID * FreeDataExtInit(EXTPORTDATA * PortEntry)
int i;
int n = 0;
- srand(time(NULL));
+ srand(NOW);
port = PortEntry->PORTCONTROL.PORTNUMBER;
@@ -1925,9 +1921,9 @@ VOID FreeDataProcessTNCMessage(struct TNCINFO * TNC, char * Call, unsigned char
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
STREAM->Connected = TRUE;
@@ -1941,7 +1937,7 @@ VOID FreeDataProcessTNCMessage(struct TNCINFO * TNC, char * Call, unsigned char
// Connect ACK
sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s", STREAM->MyCall, STREAM->RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connected = TRUE;
STREAM->Connecting = FALSE;
@@ -1974,7 +1970,7 @@ VOID FreeDataProcessTNCMessage(struct TNCINFO * TNC, char * Call, unsigned char
// Connection Refused - If there is a message, pass to appl
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connecting = FALSE;
buffptr = (PMSGWITHLEN)GetBuff();
@@ -2005,7 +2001,7 @@ VOID FreeDataProcessTNCMessage(struct TNCINFO * TNC, char * Call, unsigned char
STREAM->Disconnecting = FALSE;
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
return;
@@ -2039,7 +2035,7 @@ VOID FreeDataProcessTNCMessage(struct TNCINFO * TNC, char * Call, unsigned char
STREAM->bytesRXed += Len;
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - TNC->FreeDataInfo->toSendCount, STREAM->bytesRXed, TNC->FreeDataInfo->toSendCount);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
return;
@@ -2288,9 +2284,9 @@ VOID FreeDataProcessNewConnect(struct TNCINFO * TNC, char * fromCall, char * toC
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
STREAM->Connected = TRUE;
@@ -2305,7 +2301,7 @@ VOID FreeDataProcessConnectAck(struct TNCINFO * TNC, char * Call, unsigned char
struct FreeDataINFO * Modem = TNC->FreeDataInfo;
sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s", STREAM->MyCall, STREAM->RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connected = TRUE;
STREAM->Connecting = FALSE;
@@ -2392,7 +2388,7 @@ void FlushData(struct TNCINFO * TNC)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - TNC->FreeDataInfo->toSendCount, STREAM->bytesRXed, TNC->FreeDataInfo->toSendCount);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
}
@@ -2418,7 +2414,7 @@ static int SendAsFile(struct TNCINFO * TNC, char * Call, char * Msg, int Len)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - TNC->FreeDataInfo->toSendCount, STREAM->bytesRXed, TNC->FreeDataInfo->toSendCount);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
return Len;
}
@@ -2443,7 +2439,7 @@ static void SendPing(struct TNCINFO * TNC, char * Call)
char Message[256];
int Len, ret;
- Len = sprintf(Message, Ping, Call, time(NULL));
+ Len = sprintf(Message, Ping, Call, NOW);
ret = send(TNC->TCPDataSock, (char *)&Message, Len, 0);
}
@@ -2698,7 +2694,7 @@ void ProcessMessageObject(struct TNCINFO * TNC, char * This)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - TNC->FreeDataInfo->toSendCount, STREAM->bytesRXed, TNC->FreeDataInfo->toSendCount);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
}
return;
}
@@ -2792,7 +2788,7 @@ void ProcessMessageObject(struct TNCINFO * TNC, char * This)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed - TNC->FreeDataInfo->toSendCount, STREAM->bytesRXed, TNC->FreeDataInfo->toSendCount);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
}
}
else
@@ -2958,7 +2954,7 @@ void processJSONINFO(struct TNCINFO * TNC, char * Info, char * Call, double snr)
if (STREAM->Connecting)
{
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connecting = FALSE;
buffptr = (PMSGWITHLEN)GetBuff();
@@ -3131,7 +3127,7 @@ void ProcessTNCJSON(struct TNCINFO * TNC, char * Msg, int Len)
STREAM->Disconnecting = FALSE;
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
else if (memcmp(ptr, "connecting", 10) == 0)
@@ -3186,7 +3182,7 @@ void ProcessTNCJSON(struct TNCINFO * TNC, char * Msg, int Len)
if (STREAM->Connecting)
{
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connecting = FALSE;
buffptr = (PMSGWITHLEN)GetBuff();
@@ -3309,7 +3305,7 @@ void ProcessTNCJSON(struct TNCINFO * TNC, char * Msg, int Len)
STREAM->Disconnecting = FALSE;
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
else if (memcmp(ptr, "connecting", 10) == 0)
@@ -3364,7 +3360,7 @@ void ProcessTNCJSON(struct TNCINFO * TNC, char * Msg, int Len)
if (STREAM->Connecting)
{
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connecting = FALSE;
buffptr = (PMSGWITHLEN)GetBuff();
@@ -3725,10 +3721,10 @@ void FreeDataProcessTNCMsg(struct TNCINFO * TNC)
STREAM->Disconnecting = FALSE;
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return;
}
@@ -3895,7 +3891,7 @@ TNCRunning:
if (TNC->Alerted == FALSE)
{
sprintf(TNC->WEB_COMMSSTATE, "Connecting to TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
}
TNC->Datadestaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
@@ -3947,7 +3943,7 @@ TNCRunning:
i=sprintf(Msg, "Connect Failed for FreeData TNC socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -3971,7 +3967,7 @@ TNCRunning:
TNC->Alerted = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to FreeData TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
sprintf(Msg, "Connected to FreeData TNC Port %d\r\n", TNC->Port);
WritetoConsole(Msg);
@@ -4027,7 +4023,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->TNCCONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -4056,7 +4052,7 @@ closeThread:
}
sprintf(Msg, "FreeData Thread Terminated Port %d\r\n", TNC->Port);
- TNC->lasttime = time(NULL); // Prevent immediate restart
+ TNC->lasttime = NOW; // Prevent immediate restart
WritetoConsole(Msg);
}
@@ -4088,7 +4084,7 @@ void ConnectTNCPort(struct TNCINFO * TNC)
// Connected successful
sprintf(TNC->WEB_COMMSSTATE, "Connected to FreeData TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->TNCCONNECTING = FALSE;
TNC->TNCCONNECTED = TRUE;
TNC->Alerted = FALSE;
@@ -4106,7 +4102,7 @@ void ConnectTNCPort(struct TNCINFO * TNC)
TNC->TNCCONNECTING = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
}
closesocket(TNC->TCPDataSock);
diff --git a/HALDriver.c b/HALDriver.c
index 408ff97..d8e5ffe 100644
--- a/HALDriver.c
+++ b/HALDriver.c
@@ -82,6 +82,7 @@ VOID DoMonitor(struct TNCINFO * TNC, UCHAR * Msg, int Len);
BOOL HALConnected(struct TNCINFO * TNC, char * Call);
VOID HALDisconnected(struct TNCINFO * TNC);
+VOID halSetWindowText(struct TNCINFO * TNC, char * Msg);
static VOID EncodeAndSend(struct TNCINFO * TNC, UCHAR * txbuffer, int Len);
VOID SendCmd(struct TNCINFO * TNC, UCHAR * txbuffer, int Len);
@@ -113,7 +114,7 @@ UCHAR FN[MAX_PATH];
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(FN,"%s\\HALLog_%02d%02d%02d_%s.bin", BaseDir, tm->tm_mday, tm->tm_hour, tm->tm_min, Logs[Flags]);
@@ -443,7 +444,7 @@ static size_t ExtProc(int fn, int port , PDATAMESSAGE buff)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<head><title>HAL Status</title></head><body><h3>HAL Status</h3>");
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 480px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
@@ -718,7 +719,7 @@ VOID HALPoll(int Port)
TNC->HostMode = 0;
sprintf(TNC->WEB_COMMSSTATE,"%s Open but TNC not responding", TNC->PortRecord->PORTCONTROL.SerialPortName);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
//for (Stream = 0; Stream <= MaxStreams; Stream++)
{
@@ -758,7 +759,7 @@ VOID HALPoll(int Port)
SendCmd(TNC, TXMsg, datalen + 1); // Send the NULL
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Stop Scanning
@@ -911,7 +912,7 @@ VOID HALPoll(int Port)
buffptr->Len = sprintf((UCHAR *)buffptr->Data,"HAL} Ok\r");
C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
- MySetWindowText(TNC->xIDC_MODE, "Clover");
+ MySetWindowText(TNC, TNC->xIDC_MODE, "Clover");
strcpy(TNC->WEB_MODE, "Clover");
SendCmd(TNC, "\x80", 1); // Clover
@@ -972,7 +973,7 @@ VOID HALPoll(int Port)
break;
}
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
SendCmd(TNC, TXMsg, datalen + 1); // Include NULL
ReleaseBuffer(buffptr);
@@ -992,7 +993,7 @@ VOID HALPoll(int Port)
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s - CLOVER",
STREAM->MyCall, STREAM->RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
ReleaseBuffer(buffptr);
@@ -1253,9 +1254,9 @@ NotData:
ProcessHALCmd(TNC);
}
-VOID mySetWindowText(struct TNCINFO * TNC, char * Msg)
+VOID halSetWindowText(struct TNCINFO * TNC, char * Msg)
{
- MySetWindowText(TNC->xIDC_STATE, Msg);
+ MySetWindowText(TNC, TNC->xIDC_STATE, Msg);
strcpy(TNC->WEB_STATE, Msg);
}
@@ -1282,7 +1283,7 @@ CmdLoop:
TNC->Timeout = 0;
sprintf(TNC->WEB_COMMSSTATE,"%s TNC link OK", TNC->PortRecord->PORTCONTROL.SerialPortName);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
// We may have more than one response in the buffer, and only each cmd/response decoder knows how many it needs
@@ -1319,7 +1320,7 @@ CmdLoop:
// Diaplay Linke Status
- MySetWindowText(TNC->xIDC_MODE, status[StatusByte]);
+ MySetWindowText(TNC, TNC->xIDC_MODE, status[StatusByte]);
strcpy(TNC->WEB_MODE, status[StatusByte]);
break;
@@ -1329,7 +1330,7 @@ CmdLoop:
// if we were connecting, this means connect failed.
- MySetWindowText(TNC->xIDC_MODE, status[StatusByte]);
+ MySetWindowText(TNC, TNC->xIDC_MODE, status[StatusByte]);
strcpy(TNC->WEB_MODE, status[StatusByte]);
if (STREAM->Connecting)
@@ -1339,14 +1340,14 @@ CmdLoop:
case 0x0E: // ISS (AMTOR/P-MODE)
- MySetWindowText(TNC->xIDC_TXRX,"ISS");
+ MySetWindowText(TNC, TNC->xIDC_TXRX,"ISS");
strcpy(TNC->WEB_TXRX, "ISS");
TNC->TXRXState = 'S';
break;
case 0x0F: // IRS (AMTOR/P-MODE)
- MySetWindowText(TNC->xIDC_TXRX,"IRS");
+ MySetWindowText(TNC, TNC->xIDC_TXRX,"IRS");
strcpy(TNC->WEB_TXRX, "IRS");
TNC->TXRXState = 'R';
break;
@@ -1358,7 +1359,7 @@ CmdLoop:
case 0x04: // PHS (AMTOR/P-MODE)
case 0x05: // OVER (AMTOR/P-MODE) (not implemented)
- MySetWindowText(TNC->xIDC_STATE, status[StatusByte]);
+ MySetWindowText(TNC, TNC->xIDC_STATE, status[StatusByte]);
strcpy(TNC->WEB_MODE, status[StatusByte]);
@@ -1389,7 +1390,7 @@ CmdLoop:
(Leds & 0x01)? 'X' : ' ');
// STBY CALL LINK ERROR TX RX
- MySetWindowText(TNC->xIDC_LEDS, TNC->WEB_LEDS);
+ MySetWindowText(TNC, TNC->xIDC_LEDS, TNC->WEB_LEDS);
Used = 2;
break;
@@ -1525,25 +1526,25 @@ CmdLoop:
switch (StatusByte)
{
- case 0x00: mySetWindowText(TNC, "Channel idle"); break;
- case 0x01: mySetWindowText(TNC, "Channel occupied with non-Clover signal"); break;
- case 0x42: mySetWindowText(TNC, "Linked stations monitored"); break;
- case 0x64: mySetWindowText(TNC, "Attempting normal link"); break;
- case 0x65: mySetWindowText(TNC, "Attempting robust link"); break;
- case 0x66: mySetWindowText(TNC, "Calling ARQ CQ"); break;
- case 0x78: mySetWindowText(TNC, "Clover Control Block (CCB) send retry"); break;
- case 0x79: mySetWindowText(TNC, "Clover Control Block (CCB) receive retry"); break;
- case 0x7D: mySetWindowText(TNC, "Clover Control Block (CCB) received successfully"); break;
- case 0x8A: mySetWindowText(TNC, "TX data block sent"); break;
- case 0x8B: mySetWindowText(TNC, "RX data block received ok (precedes data block)"); break;
- case 0x8C: mySetWindowText(TNC, "TX data block re-sent"); break;
- case 0x8D: mySetWindowText(TNC, "RX data block decode failed (precedes data block)"); break;
- case 0x8E: mySetWindowText(TNC, "TX idle"); break;
- case 0x8F: mySetWindowText(TNC, "RX idle"); break;
- case 0x9C: mySetWindowText(TNC, "Link failed: CCB send retries exceeded"); break;
- case 0x9D: mySetWindowText(TNC, "Link failed: CCB receive retries exceeded"); break;
- case 0x9E: mySetWindowText(TNC, "Link failed: protocol error"); break;
- case 0xA0: mySetWindowText(TNC, "Receiving FEC SYNC sequence"); break;
+ case 0x00: halSetWindowText(TNC, "Channel idle"); break;
+ case 0x01: halSetWindowText(TNC, "Channel occupied with non-Clover signal"); break;
+ case 0x42: halSetWindowText(TNC, "Linked stations monitored"); break;
+ case 0x64: halSetWindowText(TNC, "Attempting normal link"); break;
+ case 0x65: halSetWindowText(TNC, "Attempting robust link"); break;
+ case 0x66: halSetWindowText(TNC, "Calling ARQ CQ"); break;
+ case 0x78: halSetWindowText(TNC, "Clover Control Block (CCB) send retry"); break;
+ case 0x79: halSetWindowText(TNC, "Clover Control Block (CCB) receive retry"); break;
+ case 0x7D: halSetWindowText(TNC, "Clover Control Block (CCB) received successfully"); break;
+ case 0x8A: halSetWindowText(TNC, "TX data block sent"); break;
+ case 0x8B: halSetWindowText(TNC, "RX data block received ok (precedes data block)"); break;
+ case 0x8C: halSetWindowText(TNC, "TX data block re-sent"); break;
+ case 0x8D: halSetWindowText(TNC, "RX data block decode failed (precedes data block)"); break;
+ case 0x8E: halSetWindowText(TNC, "TX idle"); break;
+ case 0x8F: halSetWindowText(TNC, "RX idle"); break;
+ case 0x9C: halSetWindowText(TNC, "Link failed: CCB send retries exceeded"); break;
+ case 0x9D: halSetWindowText(TNC, "Link failed: CCB receive retries exceeded"); break;
+ case 0x9E: halSetWindowText(TNC, "Link failed: protocol error"); break;
+ case 0xA0: halSetWindowText(TNC, "Receiving FEC SYNC sequence"); break;
}
Used = 2;
@@ -1725,7 +1726,7 @@ VOID HALDisconnected(struct TNCINFO * TNC)
STREAM->FramesQueued = 0;
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
return;
}
@@ -1757,7 +1758,7 @@ BOOL HALConnected(struct TNCINFO * TNC, char * Call)
strcat(CallCopy, " "); // Some routines expect 10 char calls
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->BytesAcked = 0;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
// Stop Scanner
@@ -1780,7 +1781,7 @@ BOOL HALConnected(struct TNCINFO * TNC, char * Call)
ProcessIncommingConnect(TNC, CallCopy, 0, TRUE);
sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Inbound", STREAM->RemoteCall, TNC->NodeCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
if (TNC->CurrentMode != Clover)
SendCmd(TNC, "\x87", 1); // Changeover to ISS
@@ -1822,7 +1823,7 @@ BOOL HALConnected(struct TNCINFO * TNC, char * Call)
STREAM->Connected = TRUE; // Subsequent data to data channel
sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Outbound", TNC->NodeCall, STREAM->RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
UpdateMH(TNC, CallCopy, '+', 'O');
diff --git a/HFCommon.c b/HFCommon.c
index 7aa274c..71bf5ed 100644
--- a/HFCommon.c
+++ b/HFCommon.c
@@ -320,7 +320,7 @@ LRESULT CALLBACK PacWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
TNC->TXOffset = SendMessage(TNC->xIDC_TXTUNE, TBM_GETPOS, 0, 0);
sprintf(value, "%d", TNC->TXOffset);
- MySetWindowText(TNC->xIDC_TXTUNEVAL, value);
+ MySetWindowText(TNC, TNC->xIDC_TXTUNEVAL, value);
break;
}
@@ -644,7 +644,7 @@ VOID SendWL2KRegisterHybrid(struct TNCINFO * TNC)
strcpy(Call, TCP->GatewayCall);
strlop(Call, '-');
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
//2021-10-31-14=35=29
@@ -771,7 +771,7 @@ IdTag (random alphanumeric, 12 chars)
if (ADIF->StartTime == 0 || ADIF->ServerSID[0] == 0 || ADIF->CMSCall[0] == 0)
return TRUE;
- T = time(NULL);
+ T = NOW;
// Extract Info we need
@@ -1506,7 +1506,7 @@ DoMove:
// memcpy (MHBASE->MHCALL, Buffer->ORIGIN, 7 * 9);
memcpy (MHBASE->MHCALL, AXCall, 7 * 9); // Save Digis
MHBASE->MHDIGI = Mode;
- MHBASE->MHTIME = time(NULL);
+ MHBASE->MHTIME = NOW;
MHBASE->MHCOUNT = ++OldCount;
memcpy(MHBASE->MHLocator, LOC, 6);
@@ -2032,10 +2032,10 @@ void sendModeReport()
char Msg[300] = "MODE ";
int i, Len = 5;
- if ((CurrentSecs - LastModeReportTime) < 900) // Every 15 Mins
+ if ((NOW - LastModeReportTime) < 900) // Every 15 Mins
return;
- LastModeReportTime = CurrentSecs;
+ LastModeReportTime = NOW;
for (i = 0; i < NUMBEROFPORTS; i++)
{
@@ -2099,10 +2099,10 @@ void sendFreqReport(char * From)
struct PORTCONTROL * PORT = PORTTABLE;
struct TNCINFO * TNC;
- if ((CurrentSecs - LastFreqReportTime) < 7200) // Every 2 Hours
+ if ((NOW - LastFreqReportTime) < 7200) // Every 2 Hours
return;
- LastFreqReportTime = CurrentSecs;
+ LastFreqReportTime = NOW;
for (p = 0; p < NumberofPorts; p++)
{
diff --git a/HSMODEM.c b/HSMODEM.c
index 7b44895..3636104 100644
--- a/HSMODEM.c
+++ b/HSMODEM.c
@@ -372,12 +372,12 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
switch (fn)
{
- case 7:
+ case 7:
- // 100 mS Timer. May now be needed, as Poll can be called more frequently in some circumstances
+ // 100 mS Timer. May now be needed, as Poll can be called more frequently in some circumstances
// G7TAJ's code to record activity for stats display
-
+
if ( TNC->BusyFlags && CDBusy )
TNC->PortRecord->PORTCONTROL.ACTIVE += 2;
@@ -385,28 +385,109 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->PortRecord->PORTCONTROL.SENDING += 2;
if (TNC->CONNECTED)
+ {
+ TNC->CONNECTED--;
+
+ if (TNC->CONNECTED == 0)
{
- TNC->CONNECTED--;
+ sprintf(TNC->WEB_COMMSSTATE, "Connection to HSMODEM lost");
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ }
+ }
+
+ TNC->PollDelay++;
- if (TNC->CONNECTED == 0)
+ if (TNC->PollDelay > 20)
+ {
+ TNC->PollDelay = 0;
+
+ SendPoll(TNC);
+ }
+
+ if (TNC->DiscPending)
+ {
+ TNC->DiscPending--;
+
+ if (TNC->DiscPending == 0)
+ {
+ // Too long in Disc Pending - Kill and Restart TNC
+ }
+ }
+
+ for (Stream = 0; Stream <= 2; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (STREAM->NeedDisc)
+ {
+ STREAM->NeedDisc--;
+
+ if (STREAM->NeedDisc == 0)
{
- sprintf(TNC->WEB_COMMSSTATE, "Connection to HSMODEM lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ // Send the DISCONNECT
+
+ HSMODEMSendCommand(TNC, "DISCONNECT\r");
}
}
+ }
+
+ for (Stream = 0; Stream <= 2; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (STREAM->NeedDisc)
+ {
+ STREAM->NeedDisc--;
- TNC->PollDelay++;
+ if (STREAM->NeedDisc == 0)
+ {
+ // Send the DISCONNECT
- if (TNC->PollDelay > 20)
+ HSMODEMSendCommand(TNC, "DISCONNECT\r");
+ }
+ }
+
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
{
- TNC->PollDelay = 0;
+ // New Attach
+
+ int calllen;
+ char Msg[80];
+
+ Debugprintf("HSMODEM New Attach Stream %d", Stream);
+
+ STREAM->Attached = TRUE;
+
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
+ TNC->Streams[Stream].MyCall[calllen] = 0;
+
- SendPoll(TNC);
- }
+ HSMODEMChangeMYC(TNC, TNC->Streams[0].MyCall);
- return 0;
+ // Stop other ports in same group
- case 1: // poll
+ SuspendOtherPorts(TNC);
+
+ //sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ //MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ // Stop Scanning
+
+ sprintf(Msg, "%d SCANSTOP", TNC->Port);
+
+ Rig_Command( (TRANSPORTENTRY *) -1, Msg);
+ }
+
+ if (STREAM->Attached)
+ CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+
+ }
+
+
+
+ return 0;
+
+ case 1: // poll
HSMODEMCheckRX(TNC);
@@ -476,69 +557,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
ReleaseBuffer(buffptr);
}
-
- if (TNC->DiscPending)
- {
- TNC->DiscPending--;
- if (TNC->DiscPending == 0)
- {
- // Too long in Disc Pending - Kill and Restart TNC
- }
- }
-
-
- for (Stream = 0; Stream <= 2; Stream++)
- {
- STREAM = &TNC->Streams[Stream];
-
- if (STREAM->NeedDisc)
- {
- STREAM->NeedDisc--;
-
- if (STREAM->NeedDisc == 0)
- {
- // Send the DISCONNECT
-
- HSMODEMSendCommand(TNC, "DISCONNECT\r");
- }
- }
-
- if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
- {
- // New Attach
-
- int calllen;
- char Msg[80];
-
- Debugprintf("HSMODEM New Attach Stream %d", Stream);
-
- STREAM->Attached = TRUE;
-
- calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
- TNC->Streams[Stream].MyCall[calllen] = 0;
-
-
- HSMODEMChangeMYC(TNC, TNC->Streams[0].MyCall);
-
- // Stop other ports in same group
-
- SuspendOtherPorts(TNC);
-
- //sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- //MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
-
- // Stop Scanning
-
- sprintf(Msg, "%d SCANSTOP", TNC->Port);
-
- Rig_Command( (TRANSPORTENTRY *) -1, Msg);
- }
-
- if (STREAM->Attached)
- CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
-
- }
// See if any frames for this port
@@ -734,7 +753,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Save Command, and wait up to 10 secs
sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->ConnectCmd = _strdup(Connect);
TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
@@ -749,7 +768,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", STREAM->MyCall, STREAM->RemoteCall);
HSMODEMSendCommand(TNC, Connect);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connecting = TRUE;
return 0;
@@ -878,7 +897,7 @@ VOID HSMODEMReleasePort(struct TNCINFO * TNC)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<script type=\"text/javascript\">\r\n"
"function ScrollOutput()\r\n"
"{var textarea = document.getElementById('textarea');"
@@ -1420,7 +1439,7 @@ VOID HSMODEMProcessTNCMessage(struct TNCINFO * TNC, unsigned char * Msg, int Len
// Just come up
sprintf(TNC->WEB_COMMSSTATE, "Connected to HSMODEM");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
SendMode(TNC);
}
@@ -1507,7 +1526,7 @@ VOID HSMODEMProcessTNCMessage(struct TNCINFO * TNC, unsigned char * Msg, int Len
Info->lastBlock = 0;
Info->lostBlocks = 0;
- Info->LastRX = time(NULL);
+ Info->LastRX = NOW;
Debugprintf("%d %d %04X %02x %s %d %s", Msg[1], Seq, FH->CRC, Msg[4],
FH->filename, fileLen, FH->Data);
diff --git a/HTTPcode.c b/HTTPcode.c
index 2d4415c..1a50fed 100644
--- a/HTTPcode.c
+++ b/HTTPcode.c
@@ -73,6 +73,10 @@ int APIProcessHTTPMessage(char * response, char * Method, char * URL, char * req
int RHPProcessHTTPMessage(struct ConnectionInfo * conn, char * response, char * Method, char * URL, char * request, BOOL LOCAL, BOOL COOKIE);
unsigned char * Compressit(unsigned char * In, int Len, int * OutLen);
int doinflate(unsigned char * source, unsigned char * dest, int Len, int destlen, int * outLen);
+void SendDeviceWebPage(int Port);
+int SendMsgNoSem(int stream, char * msg, int len);
+int SessionStateNoSem(int stream, int * state, int * change);
+int DoWebSockTerm(struct HTTPConnectionInfo * Session, struct ConnectionInfo * conn, char * _REPLYBUFFER, int LOCAL, int COOKIE, char * Context, SOCKET sock);
extern struct ROUTE * NEIGHBOURS;
extern int ROUTE_LEN;
@@ -107,7 +111,7 @@ extern UCHAR ConfigDirectory[260];
extern struct AXIPPORTINFO * Portlist[];
-VOID sendandcheck(SOCKET sock, const char * Buffer, int Len);
+int 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);
@@ -121,7 +125,7 @@ int ProcessMailSignon(struct TCPINFO * TCP, char * MsgPtr, char * Appl, char * R
int ProcessMailAPISignon(struct TCPINFO * TCP, char * MsgPtr, char * Appl, char * Reply, struct HTTPConnectionInfo ** Session, BOOL WebMail, int LOCAL);
int ProcessChatSignon(struct TCPINFO * TCP, char * MsgPtr, char * Appl, char * Reply, struct HTTPConnectionInfo ** Session, int LOCAL);
VOID APRSProcessHTTPMessage(SOCKET sock, char * MsgPtr, BOOL LOCAL, BOOL COOKIE);
-
+int FindFreeStreamNoSem();
static struct HTTPConnectionInfo * SessionList; // active term mode sessions
@@ -212,7 +216,7 @@ char TermSignon[] = "<html><head><title>BPQ32 Node %s Terminal Access</title></h
"<tr><td>User</td><td><input type=text name=user tabindex=1 size=20 maxlength=50 /></td></tr>"
"<tr><td>Password</td><td><input type=password name=password tabindex=2 size=20 maxlength=50 /></td></tr></table>"
"<p align=center><input type=submit class='btn' value=Submit><input type=submit class='btn' value=Cancel name=Cancel>"
-"<input type=hidden name=Appl value=\"%s\" id=Pass></form>";
+"<input type=hidden name=Appl value=\"%s\" id=Appl><input type=hidden name=Flag value=\"%s\" id=flag></form>";
char PassError[] = "<p align=center>Sorry, User or Password is invalid - please try again</p>";
@@ -319,7 +323,6 @@ static char ConfigEditPage[] = "<html><head><meta content=\"text/html; charset=I
static char EXCEPTMSG[80] = "";
-
void UndoTransparency(char * input)
{
char * ptr1, * ptr2;
@@ -480,7 +483,7 @@ VOID PollSession(struct HTTPConnectionInfo * Session)
// Make sure line isn't too long
// but beware of spaces expanded to &nbsp; - count chars in line
- if ((realLen) > 100)
+ if ((realLen) > 250)
{
strcpy(ptr2, "<br>\r\n");
@@ -538,6 +541,186 @@ VOID PollSession(struct HTTPConnectionInfo * Session)
}
+
+
+
+VOID PollWebSockSession(struct HTTPConnectionInfo * Session, char * Formatted)
+{
+ int state, change;
+ int count, len;
+ char Line[8192];
+ char Msg[400];
+ char * ptr1, * ptr2;
+ byte c;
+ int totalLen = 0;
+ int needSpan = 0;
+ int realLen = 0;
+ int LineLen;
+
+ Formatted[0] = 0;
+
+ // Poll Node
+
+ SessionState(Session->Stream, &state, &change);
+
+ if (change == 1)
+ {
+ if (state == 1) // Connected
+ strcpy(Formatted, "*** Connected\r\n");
+ else
+ strcpy(Formatted, "*** Disconnected\r\n");
+
+ Session->Changed = TRUE;
+ }
+
+ if (RXCount(Session->Stream) > 0)
+ {
+
+ char * lasteol = 0;
+
+ do
+ {
+ GetMsg(Session->Stream, &Msg[0], &len, &count);
+
+ // replace cr with <br> and space with &nbsp;
+
+ ptr1 = Msg;
+ ptr2 = Line;
+ *(ptr2) = 0;
+
+ Msg[len] = 0;
+
+/* if (Session->PartLine)
+ {
+ // Last line was incomplete - append to it
+
+ realLen = Session->PartLine;
+
+ strcpy(Line, Session->ScreenLines[0]);
+ ptr2 += strlen(Line);
+
+ Session->PartLine = FALSE;
+ }
+*/
+ while (len--)
+ {
+ c = *(ptr1++);
+ realLen++;
+
+ if (c == 13 || c == 10)
+ {
+
+
+ // Write to screen
+
+ lasteol = ptr2;
+
+ *ptr2 = 0;
+ LineLen = (int)strlen(Line);
+ totalLen += LineLen;
+
+ strcat(Formatted, Line);
+
+ strcat(Formatted, "\r\n");
+
+ if (*ptr1 == 10)
+ ptr1++;
+
+ ptr2 = Line;
+ realLen = 0;
+
+ continue;
+
+ }
+
+ if (c == 0x1b && len > 2)
+ {
+ // colour code, process it
+
+ // Now we are using textContent text isn't formatted so just ignore colour escapes
+
+/*
+ int ColourCode = Line[1] - 10;
+ COLORREF Colour = Colours[ColourCode];
+
+ // Send in a <span> so we can apply formatting
+
+ ptr2 += sprintf(ptr2, "<span><font color=#%02X%02X%02X>", GetRValue(Colour), GetGValue(Colour), GetBValue(Colour));
+ needSpan = 1;
+*/
+ len --;
+ ptr1++;
+
+ continue;
+ }
+
+ if (c != 9 && c < 32)
+ c = '.';
+
+ /* if (c == 255)
+ {
+ memcpy(ptr2, "&nbsp;", 6);
+ ptr2 += 6;
+ }
+ else if (c == '>')
+ {
+ memcpy(ptr2, "&gt;", 4);
+ ptr2 += 4;
+ }
+ else if (c == '<')
+ {
+ memcpy(ptr2, "&lt;", 4);
+ ptr2 += 4;
+ }
+ */ else
+ *(ptr2++) = c;
+
+ // Make sure line isn't too long
+ // but beware of spaces expanded to &nbsp; - count chars in line
+ // Ideally we should look for multichar sequences
+
+ if ((realLen) > 120)
+ {
+ strcpy(ptr2, "\r\n");
+
+ strcat(Formatted, Line);
+
+ ptr2 = Line;
+ realLen = 0;
+ }
+
+ }
+
+ *(ptr2) = 0;
+
+ if (realLen)
+ {
+ // Incomplete line Add to output
+
+ // Save to screen
+
+//// if (Session->ScreenLines[0])
+// free(Session->ScreenLines[0]);
+
+// Session->ScreenLines[0] = _strdup(Line);
+// Session->PartLine = realLen;
+
+ LineLen = (int)strlen(Line);
+ totalLen += LineLen;
+ strcat(Formatted, Line);
+ }
+
+ Session->Changed = TRUE;
+
+ if (totalLen > 2000)
+ return;
+
+ } while (count > 0);
+ }
+}
+
+
+
VOID HTTPTimer()
{
// Run every tick. Check for status change and data available
@@ -545,8 +728,6 @@ VOID HTTPTimer()
struct HTTPConnectionInfo * Session = SessionList; // active term mode sessions
struct HTTPConnectionInfo * PreviousSession = NULL;
-// inf();
-
while (Session)
{
Session->KillTimer++;
@@ -558,86 +739,233 @@ VOID HTTPTimer()
continue;
}
- if (Session->KillTimer > 3000) // Around 5 mins
+ if (Session->KillTimer > 864000 || Session->KillTimer < 0) // Day or corrupt
+ {
+ if (Session->Stream == 0)
+ {
+ if (PreviousSession)
+ PreviousSession->Next = Session->Next; // Remove from chain
+ else
+ SessionList = Session->Next;
+
+ free(Session);
+ }
+ continue;
+ }
+
+ if (Session->KillTimer > 9000) // Around 15 mins
{
int i;
int Stream = Session->Stream;
- for (i = 0; i < 100; i++)
+
+ if (!Session->WebsockTerm)
{
- free(Session->ScreenLines[i]);
+ for (i = 0; i < 100; i++)
+ {
+ free(Session->ScreenLines[i]);
+ }
}
SessionControl(Stream, 2, 0);
SessionState(Stream, &i, &i);
DeallocateStream(Stream);
+ Session->Stream = 0;
- if (PreviousSession)
- PreviousSession->Next = Session->Next; // Remove from chain
- else
- SessionList = Session->Next;
- free(Session);
+ if (Session->WebsockTerm && Session->sockptr)
+ {
+ char Msg[256];
+ char Text[] = "Session Timeout";
+
+ Msg[0] = 0x88; // Fin, Close
+ Msg[1] = strlen(Text);
+ strcpy(&Msg[2], Text);
+
+ if (send(Session->sockptr->socket, Msg, Msg[1] + 2, 0) == -1)
+ {
+ // Send has failed - ? socket error
+
+ if (PreviousSession)
+ PreviousSession->Next = Session->Next; // Remove from chain
+ else
+ SessionList = Session->Next;
+
+ free(Session);
+ }
+
+ }
+
+ else
+ {
+ if (PreviousSession)
+ PreviousSession->Next = Session->Next; // Remove from chain
+ else
+ SessionList = Session->Next;
+
+ free(Session);
+ }
break;
}
- PollSession(Session);
+ if (Session->WebsockTerm)
+ {
+ char Formatted[8192];
- // if (Session->ResponseTimer == 0 && Session->Changed)
- // Debugprintf("Data to send but no outstanding GET");
+ if (Session->sockptr == 0) // Websock not connected - wait
+ {
+ PreviousSession = Session;
+ Session = Session->Next;
+ continue;
+ }
- if (Session->ResponseTimer)
- {
- Session->ResponseTimer--;
+ PollWebSockSession(Session, Formatted);
- if (Session->ResponseTimer == 0 || Session->Changed)
+ if (Session->Changed)
{
- SOCKET sock = Session->sock;
- char _REPLYBUFFER[100000];
- int ReplyLen;
- char Header[256];
- int HeaderLen;
+ struct ConnectionInfo * sock = Session->sockptr;
+
int Last = Session->LastLine;
- int n;
- struct TNCINFO * TNC = Session->TNC;
- struct TCPINFO * TCP = 0;
-
- if (TNC)
- TCP = TNC->TCPInfo;
- if (TCP && TCP->WebTermCSS)
- sprintf(_REPLYBUFFER, TermOutput, TCP->WebTermCSS);
- else
- sprintf(_REPLYBUFFER, TermOutput, "");
+ // Make sure still websocks
- for (n = Last;;)
+ if (sock->HTTPMode && sock->WebSocks && strcmp(sock->WebURL, "WEBTERM") == 0)
{
- if ((strlen(Session->ScreenLines[n]) + strlen(_REPLYBUFFER)) < 99999)
- strcat(_REPLYBUFFER, Session->ScreenLines[n]);
+ char Msg[65536];
+ int MsgLen = strlen(Formatted);
+ char * ptr;
+ char * OutBuffer;
+ int TxLen;
- if (n == 99)
- n = -1;
+ // Websocks must be UTF8
+
+ if (IsUTF8(Formatted, MsgLen) == FALSE)
+ {
+ unsigned char UTF[16384];
+ int code;
+
+ // Try to guess encoding
+
+ code = TrytoGuessCode(Formatted, MsgLen);
+
+ if (code == 437)
+ MsgLen = Convert437toUTF8(Formatted, MsgLen, UTF);
+ else if (code == 1251)
+ MsgLen = Convert1251toUTF8(Formatted, MsgLen, UTF);
+ else
+ MsgLen = Convert1252toUTF8(Formatted, MsgLen, UTF);
+
+ UTF[MsgLen] = 0;
+
+ strcpy(Formatted, UTF);
+ }
+
+ strcpy(&Msg[4], Formatted);
+
+ // WebSock Encode. Buffer has 4 bytes on front for header but header len depends on Msg len
+
+ if (MsgLen < 126)
+ {
+ // Two Byte Header
+
+ Msg[2] = 0x81; // Fin, Data
+ Msg[3] = MsgLen;
+
+ TxLen = MsgLen + 2;
+ OutBuffer = &Msg[2];
+ }
+ else // We don't allow more than65535 if (Len < 65536)
+ {
+ Msg[0] = 0x81; // Fin, Data
+ Msg[1] = 126; // Unmasked, Extended Len
+ Msg[2] = MsgLen >> 8;
+ Msg[3] = MsgLen & 0xff;
+ TxLen = MsgLen + 4;
+ OutBuffer = &Msg[0];
+ }
+
+ // If secure session enable any hidden controls
+
+ if (sock->WebSecure)
+ {
+ while (ptr = strstr(&Msg[4], "hidden"))
+ memcpy(ptr, " ", 6);
+ }
+
+ sendandcheck(sock->socket, OutBuffer, TxLen);
+ Session->ResponseTimer = Session->Changed = 0;
+ Session->KillTimer = 0;
- if (++n == Last)
- break;
}
+ else
+ {
+ // Session messaed up??
+ }
+ }
+ PreviousSession = Session;
+ Session = Session->Next;
+ }
+ else
+ {
+ PollSession(Session);
- ReplyLen = (int)strlen(_REPLYBUFFER);
- ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", TermOutputTail);
+ // if (Session->ResponseTimer == 0 && Session->Changed)
+ // Debugprintf("Data to send but no outstanding GET");
- HeaderLen = sprintf(Header, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\nContent-Type: text/html\r\n\r\n", ReplyLen);
- sendandcheck(sock, Header, HeaderLen);
- sendandcheck(sock, _REPLYBUFFER, ReplyLen);
+ if (Session->ResponseTimer)
+ {
+ Session->ResponseTimer--;
+
+ if (Session->ResponseTimer == 0 || Session->Changed)
+ {
+ SOCKET sock = Session->sock;
+ char _REPLYBUFFER[100000];
+ int ReplyLen;
+ char Header[256];
+ int HeaderLen;
+ int Last = Session->LastLine;
+ int n;
+ struct TNCINFO * TNC = Session->TNC;
+ struct TCPINFO * TCP = 0;
+
+ if (TNC)
+ TCP = TNC->TCPInfo;
+
+ if (TCP && TCP->WebTermCSS)
+ sprintf(_REPLYBUFFER, TermOutput, TCP->WebTermCSS);
+ else
+ sprintf(_REPLYBUFFER, TermOutput, "");
+
+ for (n = Last;;)
+ {
+ if ((strlen(Session->ScreenLines[n]) + strlen(_REPLYBUFFER)) < 99999)
+ strcat(_REPLYBUFFER, Session->ScreenLines[n]);
- Session->ResponseTimer = Session->Changed = 0;
+ if (n == 99)
+ n = -1;
+
+ if (++n == Last)
+ break;
+ }
+
+ ReplyLen = (int)strlen(_REPLYBUFFER);
+ ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", TermOutputTail);
+
+ HeaderLen = sprintf(Header, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\nContent-Type: text/html\r\n\r\n", ReplyLen);
+ sendandcheck(sock, Header, HeaderLen);
+ sendandcheck(sock, _REPLYBUFFER, ReplyLen);
+
+ Session->ResponseTimer = Session->Changed = 0;
+ }
}
+ PreviousSession = Session;
+ Session = Session->Next;
}
- PreviousSession = Session;
- Session = Session->Next;
}
}
+
struct HTTPConnectionInfo * AllocateSession(SOCKET sock, char Mode)
{
time_t KeyVal;
@@ -657,7 +985,7 @@ struct HTTPConnectionInfo * AllocateSession(SOCKET sock, char Mode)
for (i = 20; i < 100; i++)
Session->ScreenLines[i] = _strdup("<br>\r\n");
- Session->Stream = FindFreeStream();
+ Session->Stream = FindFreeStreamNoSem();
if (Session->Stream == 0)
return NULL;
@@ -665,7 +993,7 @@ struct HTTPConnectionInfo * AllocateSession(SOCKET sock, char Mode)
SessionControl(Session->Stream, 1, 0);
}
- KeyVal = (int)sock * time(NULL);
+ KeyVal = (int)sock * NOW;
sprintf(Session->Key, "%c%012X", Mode, (int)KeyVal);
@@ -701,7 +1029,7 @@ void ProcessTermInput(SOCKET sock, char * MsgPtr, int MsgLen, char * Key)
int State;
struct HTTPConnectionInfo * Session = FindSession(Key);
int Stream;
- int maxlen = 1000;
+ int maxlen = 2000;
if (Session == NULL)
@@ -779,12 +1107,15 @@ void ProcessTermInput(SOCKET sock, char * MsgPtr, int MsgLen, char * Key)
strcat(input, "<br>\r\n");
- free(Session->ScreenLines[Line]);
-
- Session->ScreenLines[Line] = _strdup(input);
+
+ if (!Session->WebsockTerm)
+ {
+ free(Session->ScreenLines[Line]);
+ Session->ScreenLines[Line] = _strdup(input);
- if (Line == 99)
- Session->LastLine = 0;
+ if (Line == 99)
+ Session->LastLine = 0;
+ }
*end++ = 13;
*end = 0;
@@ -849,15 +1180,18 @@ void ProcessTermClose(SOCKET sock, char * MsgPtr, int MsgLen, char * Key, int LO
send(sock, Tail, (int)strlen(Tail), 0);
}
-int ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgLen, int LOCAL)
+struct HTTPConnectionInfo * ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgLen, int LOCAL)
{
char _REPLYBUFFER[8192];
- int ReplyLen;
+ int ReplyLen = 0;
char Header[256];
int HeaderLen;
char * input = strstr(MsgPtr, "\r\n\r\n"); // End of headers
char * user, * password, * Context, * Appl;
char NoApp[] = "";
+ char Flag[16] = "";
+ int Websocks = 0;
+
struct TCPINFO * TCP = TNC->TCPInfo;
if (input)
@@ -872,6 +1206,12 @@ int ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgL
ReplyLen = SetupNodeMenu(_REPLYBUFFER, LOCAL);
goto Sendit;
}
+
+ if (strstr(input, "Flag=Websocks"))
+ {
+ Websocks = 1;
+ strcpy(Flag, "Websocks");
+ }
user = strtok_s(&input[9], "&", &Context);
password = strtok_s(NULL, "=", &Context);
password = strtok_s(NULL, "&", &Context);
@@ -884,7 +1224,7 @@ int ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgL
if (password == NULL)
{
- ReplyLen = sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Appl);
+ ReplyLen = sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Appl, Flag);
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", PassError);
goto Sendit;
}
@@ -903,7 +1243,6 @@ int ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgL
if (Session)
{
char AXCall[10];
- ReplyLen = sprintf(_REPLYBUFFER, TermPage, Mycall, Mycall, Session->Key, Session->Key, Session->Key);
if (_stricmp(USER->UserName, "ANON") == 0)
strcpy(Session->HTTPCall, _strupr(user));
else
@@ -915,6 +1254,14 @@ int ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgL
if (USER->Appl[0])
SendMsg(Session->Stream, USER->Appl, (int)strlen(USER->Appl));
+
+ if (Websocks)
+ return Session;
+
+ // Old Style Terminal
+
+ ReplyLen = sprintf(_REPLYBUFFER, TermPage, Mycall, Mycall, Session->Key, Session->Key, Session->Key);
+
}
else
{
@@ -930,10 +1277,9 @@ int ProcessTermSignon(struct TNCINFO * TNC, SOCKET sock, char * MsgPtr, int MsgL
{
// Not found
- ReplyLen = sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Appl);
+ ReplyLen = sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Appl, Flag);
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", PassError);
}
-
}
Sendit:
@@ -943,7 +1289,7 @@ Sendit:
send(sock, _REPLYBUFFER, ReplyLen, 0);
send(sock, Tail, (int)strlen(Tail), 0);
- return 1;
+ return 0;
}
char * LookupKey(char * Key)
@@ -1163,11 +1509,11 @@ int SendMessageFile(SOCKET sock, char * FN, BOOL OnlyifExists, int allowDeflate)
if ((strcmp(FN, "/") == 0 || strstr(FN, "htm" ) || strstr(FN, "HTM")) && strstr(MsgBytes, "##" ))
{
FileSize = ProcessSpecialPage(MsgBytes, FileSize);
- FormatTime3(FileTimeString, time(NULL));
+ FormatTime3(FileTimeString, NOW);
}
- FormatTime3(TimeString, time(NULL));
+ FormatTime3(TimeString, NOW);
ptr = FN;
@@ -1240,12 +1586,15 @@ int SendMessageFile(SOCKET sock, char * FN, BOOL OnlyifExists, int allowDeflate)
return 0;
}
-VOID sendandcheck(SOCKET sock, const char * Buffer, int Len)
+int sendandcheck(SOCKET sock, const char * Buffer, int Len)
{
int Loops = 0;
int Sent = send(sock, Buffer, Len, 0);
char * Copy = NULL;
+ if (Sent == -1)
+ return 0;
+
while (Sent != Len && Loops++ < 300) // 10 secs max
{
// Debugprintf("%d out of %d sent %d Loops", Sent, Len, Loops);
@@ -1269,7 +1618,7 @@ VOID sendandcheck(SOCKET sock, const char * Buffer, int Len)
if (Copy)
free(Copy);
- return;
+ return 1;
}
int RefreshTermWindow(struct TCPINFO * TCP, struct HTTPConnectionInfo * Session, char * _REPLYBUFFER)
@@ -1382,7 +1731,7 @@ int SetupNodeMenu(char * Buff, int LOCAL)
"<td><a href=/Node/Links.html>Links</a></td>"
"<td><a href=/Node/Users.html>Users</a></td>"
"<td><a href=/Node/Stats.html>Stats</a></td>"
- "<td><a href=/Node/Terminal.html>Terminal</a></td>%s%s%s%s%s%s";
+ "<td><a href=javascript:dev_win(\"/Node/WebSockTerm.html\",800,600,200,200)>Terminal</a></td>%s%s%s%s%s%s";
char DriverBit[] = "<td><a href=\"javascript:open_win();\">Driver Windows</a></td>"
"<td><a href=javascript:dev_win(\"/Node/Streams\",820,700,200,200);>Stream Status</a></td>";
@@ -1405,6 +1754,7 @@ int SetupNodeMenu(char * Buff, int LOCAL)
<script>\
document.getElementById('e').value = new Date().toISOString().substring(0, 10);\
</script></label>\
+ <input type=submit class='btn' name='NodeDebug' value='Node Debug Log'></br>\
<input type=submit class='btn' name='BBS' value='BBS Log'></br>\
<input type=submit class='btn' name='Debug' value='BBS Debug Log'></br>\
<input type=submit class='btn' name='Telnet' value='Telnet Log'></br>\
@@ -1649,12 +1999,12 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn)
"<td> </td><td>%s</td></tr>\r\n";
char PortLineWithDriver[] = "<tr><td>%d</td><td>%s</td><td>%s</td><td> </td>"
- "<td><a href=\"javascript:dev_win('/Node/Port?%d',%d,%d,%d,%d);\">Driver Window</a></td><td>%s</td></tr>\r\n";
+ "<td><a href=\"javascript:dev_win('/Node/DevicePage?%d',%d,%d,%d,%d);\">Driver Window</a></td><td>%s</td></tr>\r\n";
char PortLineWithBeaconAndDriver[] = "<tr><td>%d</td><td>%s</td><td>%s</td>"
"<td><a href=PortBeacons?%d>&nbsp;Beacons</a></td>"
- "<td><a href=\"javascript:dev_win('/Node/Port?%d',%d,%d,%d,%d);\">Driver Window</a></td><td>%s</td></tr>\r\n";
+ "<td><a href=\"javascript:dev_win('/Node/DevicePage?%d',%d,%d,%d,%d);\">Driver Window</a></td><td>%s</td></tr>\r\n";
char RigControlLine[] = "<tr><td>%d</td><td>%s</td><td>%s</td><td> </td>"
"<td><a href=\"javascript:dev_win('/Node/RigControl.html',%d,%d,%d,%d);\">Rig Control</a></td></tr>\r\n";
@@ -1676,7 +2026,7 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn)
strcpy(URL, MsgPtr);
- WebSock = strstr(MsgPtr, "Upgrade: websocket");
+ WebSock = stristr(MsgPtr, "Upgrade: websocket");
encPtr = stristr(MsgPtr, "Accept-Encoding:");
@@ -1685,7 +2035,7 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn)
else
Encoding[0] = 0;
- ptr = strstr(MsgPtr, "BPQSessionCookie=N");
+ ptr = stristr(MsgPtr, "BPQSessionCookie=N");
if (ptr)
{
@@ -1730,7 +2080,7 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn)
// "Sec-WebSocket-Protocol: chat\r\n"
"\r\n";
- ptr = strstr(MsgPtr, "Sec-WebSocket-Key:");
+ ptr = stristr(MsgPtr, "Sec-WebSocket-Key:");
if (ptr)
{
@@ -1818,8 +2168,10 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn)
"Content-Type: application/json\r\n"
"Connection: close\r\n"
"Access-Control-Allow-Origin: *\r\n"
+ "Cache-Control: no-cache\r\n"
"%s\r\n", ReplyLen, Encoding);
+
sendandcheck(sock, Header, HeaderLen);
sendandcheck(sock, Compressed, ReplyLen);
@@ -2455,7 +2807,7 @@ doHeader:
TNC->TXOffset = atoi(input);
#ifdef WIN32
sprintf(value, "%d", TNC->TXOffset);
- MySetWindowText(TNC->xIDC_TXTUNEVAL, value);
+ MySetWindowText(TNC, TNC->xIDC_TXTUNEVAL, value);
SendMessage(TNC->xIDC_TXTUNE, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) TNC->TXOffset); // min. & max. positions
#endif
@@ -2510,9 +2862,50 @@ doHeader:
return 0;
}
+
+ else if (_stricmp(NodeURL, "/Node/TermAction") == 0)
+ {
+ char * input = strstr(MsgPtr, "\r\n\r\n"); // End of headers
+
+ if (input == 0)
+ return 1;
+
+ input += 4;
+
+ Session = FindSession(Context);
+
+ if (strcmp(input, "Disconnect") == 0)
+ {
+ if (Session && Session->Stream)
+ {
+ SessionControl(Session->Stream, 2, 0);
+ }
+ }
+ return 1;
+ }
+
if (_stricmp(NodeURL, "/Node/TermSignon") == 0)
{
- ProcessTermSignon(conn->TNC, sock, MsgPtr, MsgLen, LOCAL);
+ Session = ProcessTermSignon(conn->TNC, sock, MsgPtr, MsgLen, LOCAL);
+
+ if (Session)
+ {
+ char Header[256];
+ int HeaderLen;
+ int ReplyLen;
+
+ ReplyLen = DoWebSockTerm(Session, conn, _REPLYBUFFER, LOCAL, COOKIE, Context, sock);
+
+ HeaderLen = sprintf(Header, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\nContent-Type: text/html\r\n"
+ "\r\n", (int)(ReplyLen + strlen(Tail)));
+
+ send(sock, Header, HeaderLen, 0);
+ sendandcheck(sock, _REPLYBUFFER, ReplyLen);
+ send(sock, Tail, (int)strlen(Tail), 0);
+
+
+ return 0;
+ }
}
if (_stricmp(NodeURL, "/Node/Signon") == 0)
@@ -2643,7 +3036,7 @@ doHeader:
{
// Save Config File
- if (conn->LOCALAuth)
+ if (conn->LOCALAuth || COOKIE)
SaveConfigFile(sock, MsgPtr, Key, LOCAL);
else
{
@@ -3005,19 +3398,18 @@ doHeader:
" if (\"WebSocket\" in window)"
" {"
" // Let us open a web socket. Get address from URL\r\n"
- " var text = window.location.href;"
- " var result = text.substring(7);"
- " var myArray = result.split('/', 1);"
- " ws = new WebSocket('ws://' + myArray[0] + '/RIGCTL');\r\n"
-
+
+ " var proto = (window.location.protocol === 'https:') ? 'wss://' : 'ws://';\r\n"
+ " ws = new WebSocket(proto + window.location.host + '/RIGCTL');\r\n"
+
" ws.onopen = function() {\r\n"
-
+
" // Web Socket is connected\r\n"
" const div = document.getElementById('div');\r\n"
" div.innerHTML = 'Websock Connected'\r\n"
" };\r\n"
-
+
" ws.onmessage = function (evt)"
" {"
" var received_msg = evt.data;\r\n"
@@ -3050,7 +3442,7 @@ doHeader:
"<div id = 'div'>Waiting for data...</div>\r\n"
"</body></html>\r\n";
-
+
char NoRigCtl[] =
"<html><meta http-equiv=expires content=0>\r\n"
"<head><title>Rigcontrol</title></head>\r\n"
@@ -3065,6 +3457,91 @@ doHeader:
ReplyLen = sprintf(_REPLYBUFFER, "%s", NoRigCtl);
}
+ else if (_stricmp(NodeURL, "/Node/DevicePage") == 0)
+ {
+ if (TCP->noWebSocks == 0)
+ {
+ char Part1[] =
+ "<html><meta http-equiv=expires content=0>\r\n"
+ "<head><title>Device</title></head>\r\n"
+ "<script type = \"text/javascript\">\r\n"
+ "var ws;"
+
+ "function Action(data){\r\n"
+ "req = new XMLHttpRequest();\r\n"
+ "req.open('POST', 'PortAction?%d', true);\r\n"
+ "req.send(data);alert(data + ' Sent');}\r\n"
+
+ "function freqOffset(data){\r\n"
+ "req = new XMLHttpRequest();\r\n"
+ "req.open('POST', 'freqOffset?%d', true);\r\n"
+ "req.send(data);}\r\n"
+
+ "function OpenWebSocket()"
+ "{"
+ " if (\"WebSocket\" in window)"
+ " {"
+ " // open a web socket. Get address from URL\r\n"
+
+ " var proto = (window.location.protocol === 'https:') ? 'wss://' : 'ws://';\r\n"
+ " ws = new WebSocket(proto + window.location.host + '/DEVICE%d');\r\n"
+ " ws.onopen = function() {\r\n"
+
+ " // Web Socket is connected\r\n"
+
+ " const div = document.getElementById('div');\r\n"
+ " div.innerHTML = 'Websock Connected'\r\n};\r\n"
+
+ " ws.onmessage = function (evt)"
+ " {"
+ " var received_msg = evt.data;\r\n"
+ " const div = document.getElementById('div');\r\n"
+ " div.innerHTML = received_msg\r\n"
+ " const text = document.getElementById('textarea');\r\n"
+ " text.scrollTop = text.scrollHeight;\r\n"
+ " };\r\n"
+
+ " ws.onclose = function()"
+ " {"
+
+ " // websocket is closed.\r\n"
+ " const div = document.getElementById('div');\r\n"
+ " div.innerHTML = 'Websock Connection Lost'\r\n"
+ " };"
+ " }"
+ " else"
+ " {"
+ " // The browser doesn't support WebSocket\r\n"
+ " const div = document.getElementById('div');\r\n"
+ " div.innerHTML = 'WebSocket not supported by your Browser - Device Page not availible'\r\n"
+ " }"
+ "}"
+ "</script>\r\n"
+ "</head>\r\n"
+ "<body height: 600px; onload=OpenWebSocket()>\r\n"
+ "<div id = 'div'>Waiting for data...</div>\r\n"
+ "</body></html>\r\n";
+
+ int Port = atoi(Context);
+ int xxx;
+
+ ReplyLen = sprintf(_REPLYBUFFER, Part1, Port, Port, Port);
+ xxx = ReplyLen;
+ }
+ else
+ {
+ int port = atoi(Context);
+
+ if (port > 0 && port <= MaxBPQPortNo)
+ {
+ struct TNCINFO * TNC = TNCInfo[port];
+
+ if (TNC && TNC->WebWindowProc)
+ ReplyLen = TNC->WebWindowProc(TNC, _REPLYBUFFER, LOCAL);
+ }
+ }
+ }
+
else if (_stricmp(NodeURL, "/Node/ShowLog.html") == 0)
{
char ShowLogPage[] =
@@ -3098,7 +3575,7 @@ doHeader:
struct tm * tm;
char Name[64] = "";
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
if (LOCAL == FALSE && COOKIE == FALSE)
@@ -3149,6 +3626,7 @@ doHeader:
strcat(inputname, "/logs/");
}
+
if (strstr(Context, "CMS"))
{
sprintf(Name, "CMSAccess_%04d%02d%02d.log",
@@ -3175,6 +3653,13 @@ doHeader:
tm->tm_year - 100, tm->tm_mon+1, tm->tm_mday);
}
+ if (strstr(Context, "NodeDebug"))
+ {
+ sprintf(Name, "NodeDebugLog_%02d%02d%02d.log",
+ tm->tm_year - 100, tm->tm_mon+1, tm->tm_mday);
+
+ CloseDebugLog();
+ }
strcat(inputname, Name);
if (stat(inputname, &STAT) == -1)
@@ -3780,7 +4265,6 @@ doHeader:
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>"
@@ -4081,7 +4565,12 @@ CMDS60:
}}}
*/
- else if (_stricmp(NodeURL, "/Node/Terminal.html") == 0)
+ else if (_stricmp(NodeURL, "/Node/WebSockTerm.html") == 0 && TCP->noWebSocks == 0)
+ {
+ ReplyLen = DoWebSockTerm(Session, conn, _REPLYBUFFER, LOCAL, COOKIE, Context, sock);
+ }
+
+ else if (_stricmp(NodeURL, "/Node/Terminal.html" ) == 0 || (_stricmp(NodeURL, "/Node/WebSockTerm.html") == 0 && TCP->noWebSocks))
{
if (COOKIE && Session)
{
@@ -4132,7 +4621,7 @@ CMDS60:
}
}
else
- ReplyLen = sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Context);
+ ReplyLen = sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Context, "");
}
else if (_stricmp(NodeURL, "/Node/Signon.html") == 0)
@@ -4201,7 +4690,7 @@ CMDS60:
SendResp:
- FormatTime3(TimeString, time(NULL));
+ FormatTime3(TimeString, NOW);
strcpy(&_REPLYBUFFER[ReplyLen], Tail);
ReplyLen += (int)strlen(Tail);
@@ -4739,6 +5228,27 @@ int BuildRigCtlPage(char * _REPLYBUFFER)
}
+void BuildDevicePage(struct TNCINFO * TNC)
+{
+ int Len;
+ char Page[65536];
+
+ Len = TNC->WebWindowProc(TNC, Page, 1);
+
+ if (TNC->WebPage)
+ {
+ if (strcmp(TNC->WebPage, Page) == 0)
+ return; // No change
+ else
+ free(TNC->WebPage);
+ }
+
+ TNC->WebPage = _strdup(Page);
+
+ SendDeviceWebPage(TNC->Port);
+
+}
+
void SendRigWebPage()
{
int i, n;
@@ -4791,6 +5301,68 @@ void SendRigWebPage()
}
}
+void SendDeviceWebPage(int Port)
+{
+ int i, n;
+ struct ConnectionInfo * sockptr;
+ struct TNCINFO * TNC = TNCInfo[Port];
+ struct TCPINFO * TCP;
+ char DevString[16];
+
+ char Msg[65536];
+ int MsgLen;
+
+ if (TNC->WebPage == 0)
+ return;
+
+ strcpy(&Msg[4], TNC->WebPage);
+ MsgLen = strlen(&TNC->WebPage[4]);
+
+ sprintf(DevString, "DEVICE%d", Port);
+
+ for (i = 0; i < 33; i++)
+ {
+ TNC = TNCInfo[i];
+
+ if (TNC && TNC->Hardware == H_TELNET)
+ {
+ TCP = TNC->TCPInfo;
+
+ if (TCP)
+ {
+ for (n = 0; n <= TCP->MaxSessions; n++)
+ {
+ sockptr = TNC->Streams[n].ConnectionInfo;
+
+ if (sockptr->SocketActive)
+ {
+ if (sockptr->HTTPMode && sockptr->WebSocks && strcmp(sockptr->WebURL, DevString) == 0)
+ {
+ char* ptr;
+
+ Msg[0] = 0x81; // Fin, Data
+ Msg[1] = 126; // Unmasked, Extended Len
+ Msg[2] = MsgLen >> 8;
+ Msg[3] = MsgLen & 0xff;
+
+ // If secure session enable PTT button
+
+ if (sockptr->WebSecure)
+ {
+ while (ptr = strstr(&Msg[4], "hidden"))
+ memcpy(ptr, " ", 6);
+ }
+
+ send(sockptr->socket, Msg, MsgLen + 4, 0);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
// Webmail web socket code
int ProcessWebmailWebSock(char * MsgPtr, char * OutBuffer);
@@ -5267,4 +5839,477 @@ void SHA1PadMessage(SHA1Context *context)
SHA1ProcessMessageBlock(context);
}
+struct UserRec SYSOPUSER = {"", "", "", "", 1}; // Set Secure Flag
+
+int ProcessNewTermWebSock(struct ConnectionInfo * sockptr, char * Key)
+{
+ char * User = strlop(Key, '&');
+ char * Pass = strlop(User, '&');
+ char * Secure = strlop(Pass, '&');
+ struct UserRec * USER = 0;
+ int i;
+
+ char Msg[256];
+ char AXCall[10];
+
+ struct HTTPConnectionInfo * Session = SessionList;
+
+ USER = sockptr->USER;
+
+ while (Session)
+ {
+ if (strcmp(Session->Key, Key) == 0)
+ {
+ USER = sockptr->USER = Session->USER;
+ break;
+ }
+
+ Session = Session->Next;
+ }
+
+ if (USER == 0)
+ {
+ // Look for record in TelnetServere
+
+ for (i = 0; i < sockptr->TNC->TCPInfo->NumberofUsers; i++)
+ {
+ USER = sockptr->TNC->TCPInfo->UserRecPtr[i];
+ if ((_stricmp(User, USER->Callsign) == 0 ) && (strcmp(Pass, USER->Password) == 0))
+ break;
+ }
+
+ if (i == sockptr->TNC->TCPInfo->NumberofUsers)
+ {
+ // Not Found
+
+ if (sockptr->LOCALAuth)
+ {
+ // Sign in as sysop
+
+ USER = &SYSOPUSER;
+ USER->Callsign = MYNODECALL;
+ }
+ }
+
+ if (USER == 0)
+ return 0;
+
+ sockptr->USER = USER;
+ }
+
+ if (Session == 0)
+ Session = AllocateSession(sockptr->socket, 'T');
+
+ if (Session == 0)
+ {
+ Msg[0] = 0x81; // Fin, Data
+ strcpy(&Msg[2], "No Session. Reload Page to reconnect<br>");
+ Msg[1] = strlen(&Msg[2]);
+ send(sockptr->socket, Msg, Msg[1] + 2, 0);
+
+ Msg[0] = 0x88; // Fin, Close
+ send(sockptr->socket, Msg, Msg[1] + 2, 0);
+ return 1;
+ }
+
+ Session->USER = USER;
+ strcpy(Session->HTTPCall, USER->Callsign);
+
+ ConvToAX25(Session->HTTPCall, AXCall);
+ ChangeSessionCallsign(Session->Stream, AXCall);
+
+ BPQHOSTVECTOR[Session->Stream -1].HOSTSESSION->Secure_Session = USER->Secure;
+
+ Session->TNC = sockptr->TNC;
+ Session->sockptr = sockptr;
+ Session->WebsockTerm = 1;
+ return 0;
+}
+
+void ProcessWebTermInput(struct ConnectionInfo * sockptr, char * Payload)
+{
+ struct HTTPConnectionInfo * Session = SessionList;
+ char Msg[256];
+ char AXCall[10];
+
+ // Echo CRLF
+
+ Msg[0] = 0x81; // Fin, Data
+ strcpy(&Msg[2], "\r\n");
+ Msg[1] = 2;
+ send(sockptr->socket, Msg, 4, 0);
+
+ while (Session)
+ {
+ if (Session->sockptr == sockptr)
+ {
+ int Stream = Session->Stream;
+ char InputMsg[512];
+ char c, hex;
+ char * ptr1, * ptr2;
+ int State;
+
+ if (Stream == 0)
+ {
+ Session->Stream = FindFreeStreamNoSem();
+
+ if (Stream == 0)
+ continue;
+ }
+
+
+ // if (MsgLen > maxlen)
+ // {
+ // Session->KillTimer = 99999; // close session
+ // return;
+ // }
+
+
+ ptr1 = Payload;
+ ptr2 = InputMsg;
+
+ // Convert any %xx constructs
+
+ while (1)
+ {
+ c = *(ptr1++);
+
+ if (c == 0)
+ break;
+
+ if (c == '%')
+ {
+ c = *(ptr1++);
+ if(isdigit(c))
+ hex = (c - '0') << 4;
+ else
+ hex = (tolower(c) - 'a' + 10) << 4;
+
+ c = *(ptr1++);
+ if(isdigit(c))
+ hex += (c - '0');
+ else
+ hex += (tolower(c) - 'a' + 10);
+
+ *(ptr2++) = hex;
+ }
+ else if (c == '+')
+ *(ptr2++) = 32;
+ else
+ *(ptr2++) = c;
+ }
+
+ *ptr2 = 0;
+
+ SessionStateNoAck(Stream, &State);
+
+ if (State == 0)
+ {
+ char AXCall[10];
+ int SaveAuthProg = AuthorisedProgram;
+
+ AuthorisedProgram = 0;
+ SessionControl(Stream, 1, 0);
+ AuthorisedProgram = SaveAuthProg;
+
+ if (BPQHOSTVECTOR[Session->Stream -1].HOSTSESSION == NULL)
+ {
+ //No L4 sessions free
+
+ char Msg[256];
+
+ Msg[0] = 0x81; // Fin, Data
+ strcpy(&Msg[2], "No Free Host Sessions\r\n");
+ Msg[1] = strlen(&Msg[2]);
+
+ send(sockptr->socket, Msg, Msg[2] + 2, 0);
+ return;
+ }
+
+ ConvToAX25(Session->HTTPCall, AXCall);
+ ChangeSessionCallsign(Stream, AXCall);
+ if (Session->USER)
+ BPQHOSTVECTOR[Session->Stream -1].HOSTSESSION->Secure_Session = Session->USER->Secure;
+ else
+ Debugprintf("HTTP Term Session->USER is NULL");
+
+ }
+
+ SendMsgNoSem(Stream, InputMsg, strlen(InputMsg));
+ Session->Changed = TRUE;
+ Session->KillTimer = 0;
+
+ return;
+ }
+
+ Session = Session->Next;
+ }
+
+ // Input with no session create another
+
+ Session = AllocateSession(sockptr->socket, 'T');
+
+ if (Session == 0)
+ {
+ Msg[0] = 0x81; // Fin, Data
+ strcpy(&Msg[2], "No Session. Reload Page to reconnect\r\n");
+ Msg[1] = strlen(&Msg[2]);
+ send(sockptr->socket, Msg, Msg[1] + 2, 0);
+
+ Msg[0] = 0x88; // Fin, Close
+ send(sockptr->socket, Msg, Msg[1] + 2, 0);
+ return;
+ }
+
+ if (sockptr->USER)
+ {
+ Session->USER = sockptr->USER;
+ strcpy(Session->HTTPCall, sockptr->USER->Callsign);
+
+ ConvToAX25(Session->HTTPCall, AXCall);
+ ChangeSessionCallsign(Session->Stream, AXCall);
+
+ BPQHOSTVECTOR[Session->Stream -1].HOSTSESSION->Secure_Session = Session->USER->Secure;
+ }
+
+ Session->TNC = sockptr->TNC;
+ Session->sockptr = sockptr;
+ Session->WebsockTerm = 1;
+
+ ProcessWebTermInput(sockptr, Payload); // Reenter
+}
+
+void ProcessWebTermClosed(struct ConnectionInfo * sockptr)
+{
+ struct HTTPConnectionInfo * Session = SessionList;
+ struct HTTPConnectionInfo * PreviousSession = NULL;
+ int i;
+
+ while (Session)
+ {
+ if (Session->sockptr == sockptr)
+ {
+ int Stream = Session->Stream;
+
+ SessionControl(Stream, 2, 0);
+ SessionStateNoSem(Stream, &i, &i);
+ DeallocateStream(Stream);
+ Session->Stream = 0;
+
+/*
+ if (PreviousSession)
+ PreviousSession->Next = Session->Next; // Remove from chain
+ else
+ SessionList = Session->Next;
+
+ free(Session);
+*/
+ return;
+
+ }
+ Session = Session->Next;
+ }
+}
+
+ //var text = window.location.href;"
+ //var result = text.substring(7);"
+ //var myArray = result.split('/', 1);"
+ //ws = new WebSocket('ws://' + myArray[0] + '/WEBTERM?%s&%s&%s&%d');\r\n"
+
+
+
+int DoWebSockTerm(struct HTTPConnectionInfo * Session, struct ConnectionInfo * conn, char * _REPLYBUFFER, int LOCAL, int COOKIE, char * Context, SOCKET sock)
+{
+ char TermPage[] =
+ "<html><meta http-equiv=expires content=0>\r\n"
+ "<head><title>Web Terminal</title></head>\r\n"
+ "<link rel='stylesheet' href='webproc.css'>\r\n"
+ "<script type = \"text/javascript\">\r\n"
+
+ "var div, recon, ws;\r\n"
+ "var CRLF = \"\\r\\n\";"
+
+
+ "function doWindowSize()\r\n"
+ "{\r\n"
+ " div = document.getElementById('div');\r\n"
+ " div.style.height = window.innerHeight - 125;"
+ "}\r\n"
+ "window.onresize = doWindowSize;\r\n"
+ // "window.onunload = function(){ws.close()};"
+
+ "function Action(data){\r\n"
+ "req = new XMLHttpRequest();\r\n"
+ "req.open('POST', 'TermAction?%s', true);\r\n"
+ "req.send(data);"
+// "alert(data + ' Sent');"
+ "}\r\n"
+
+ "function doWindowClose(){window.close();}"
+
+ "function onLoad()"
+ "{"
+ " doWindowSize();"
+ " recon = document.getElementById('recon');\r\n"
+
+ " OpenWebSocket();"
+ " history.pushState({}, '', '/Node/WebSockTerm.html');"
+ "}"
+
+ "function OpenWebSocket()"
+ "{"
+ " if (\"WebSocket\" in window)"
+ " {"
+ " // open a web socket. Get address from URL - changes to allow for https\r\n"
+
+ " var proto = (window.location.protocol === 'https:') ? 'wss://' : 'ws://';\r\n"
+ " ws = new WebSocket(proto + window.location.host + '/WEBTERM?%s&%s&%s&%d');\r\n"
+
+// " alert(window.location.href);"
+// " alert(proto + window.location.host);"
+ " ws.onopen = function() // Web Socket is connected\r\n"
+ " {\r\n"
+ " const div = document.getElementById('div');\r\n"
+ " div.textContent += 'Websock Connected' + CRLF\r\n"
+ " recon.style.display = 'none';"
+ " div.scrollTop = div.scrollHeight;\r\n"
+ " };\r\n"
+
+ " ws.onmessage = function (evt)"
+ " {"
+ " var received_msg = evt.data;\r\n"
+ " const div = document.getElementById('div');\r\n"
+ " div.textContent += received_msg\r\n"
+ " div.scrollTop = div.scrollHeight;\r\n"
+ " };\r\n"
+
+ " ws.onclose = function() // websocket is closed.\r\n"
+ " {"
+ " const div = document.getElementById('div');\r\n"
+ " div.textContent += 'Websock Connection Lost' + CRLF;\r\n"
+ " div.scrollTop = div.scrollHeight;\r\n"
+ " recon.style.display = 'inline';"
+ " };"
+
+ " const form = document.getElementById('form');\r\n"
+ " const input = document.getElementById('input');\r\n"
+ " form.addEventListener('submit', function (e)\r\n"
+ " {\r\n"
+ " e.preventDefault(); // Stop normal HTTP submit\r\n"
+ " var inp = input.value + '\\r'\r\n;"
+ " input.value = ''; // Clear the input\r\n"
+ " ws.send(inp);\r\n"
+ " div.textContent += inp;\r\n"
+ " div.scrollTop = div.scrollHeight;\r\n"
+ " })\r\n"
+ " }\r\n"
+ " else\r\n"
+ " {\r\n"
+ " // The browser doesn't support WebSocket\r\n"
+ " const div = document.getElementById('div');\r\n"
+ " div.textContent = 'WebSocket not supported by your Browser - Websock Terminal not availible'\r\n"
+ " }"
+ "}"
+ "</script>\r\n"
+ "</head>\r\n"
+ "<body height: 600px; onload=onLoad()>\r\n"
+ "<h3 align=center>BPQ32 Node %s</h3>"
+ "<p align=center><input type=submit class='btn' value='Close Window' onclick='doWindowClose()'> "
+ "<input id=recon type=submit class='btn' value='Reconnect' onclick='OpenWebSocket()'> "
+
+ "<span class='dropdown'>"
+ "<button class='dropbtn'>Actions</button>\r\n"
+ "<span class='dropdown-content'>"
+// "<a href='/Node/Disconnect?%s'>Disconnect from Node</a>"
+ "<a href='javascript:Action(\"Disconnect\");'>Disconnect from Node</a>"
+// "<a href='javascript:Action(\"KillRestart\");'>Kill and Restart TNC</a>"
+ "</span></span>"
+
+ "<div id='div' style=\"%s;overflow:auto; white-space: pre-wrap; border: 1px solid\">Waiting for connection...<br>\r\n"
+ "</div>\r\n"
+
+ "<div style='width:100%%; height: 25px;'>"
+ "<form id='form' style=\"width: 100%%;\"><input autofocus type='text' style=\"%s ;width: 100%%;\" id='input'></form>\r\n"
+ "</div>\r\n";
+
+ struct TNCINFO * TNC = conn->TNC;
+ struct TCPINFO * TCP = 0;
+ struct HTTPConnectionInfo * NewSession;
+ int ReplyLen;
+ char Key = 0;
+ struct UserRec * USER;
+
+ if (Session)
+ Key = Session->Key[0];
+
+ if (TNC)
+ TCP = TNC->TCPInfo;
+
+ // See if we need to send login page
+
+ if (LOCAL == 0 && Key != 'T' && Key != 'N')
+ {
+ // Not signed in as Term or Node and not local connection - send login page
+
+ return sprintf(_REPLYBUFFER, TermSignon, Mycall, Mycall, Context, "Websocks");
+ }
+
+ if (Key != 'T')
+ {
+ // Either logged into node or Local Session - Create Sessiob
+
+ char AXCall[10];
+
+ NewSession = AllocateSession(sock, 'T');
+
+ if (NewSession == 0) // No Memory - Give up!
+ return 0;
+
+ if (Key == 'N' && Session->USER)
+ {
+ // signed into node - use call from signin
+
+ strcpy(NewSession->HTTPCall, Session->USER->Callsign);
+ NewSession->USER = Session->USER;
+ }
+ else
+ {
+ strcpy(NewSession->HTTPCall, MYNODECALL);
+ USER = NewSession->USER = &SYSOPUSER;
+ USER->Callsign = MYNODECALL;
+ }
+
+ ConvToAX25(NewSession->HTTPCall, AXCall);
+ ChangeSessionCallsign(NewSession->Stream, AXCall);
+
+ BPQHOSTVECTOR[NewSession->Stream -1].HOSTSESSION->Secure_Session = NewSession->USER->Secure;
+ }
+ else
+ {
+ // Already have session from
+ NewSession = Session;
+ }
+
+ NewSession->TNC = conn->TNC;
+ NewSession->sockptr = 0;
+ NewSession->WebsockTerm = 1;
+
+ USER = NewSession->USER;
+
+ if (TCP && TCP->WebTermCSS)
+ ReplyLen = sprintf(_REPLYBUFFER, TermPage,NewSession->Key, NewSession->Key, USER->Callsign, USER->Password, USER->Secure, NewSession->HTTPCall,
+ TCP->WebTermCSS, TCP->WebTermCSS);
+ else
+ ReplyLen = sprintf(_REPLYBUFFER, TermPage, NewSession->Key, NewSession->Key, USER->Callsign, USER->Password, USER->Secure, NewSession->HTTPCall,
+ "font-family:monospace", "font-family:monospace");
+
+ // if (Appl[0])
+ // {
+ // strcat(Appl, "\r");
+ // SendMsg(Session->Stream, Appl, strlen(Appl));
+ // }
+
+ return ReplyLen;
+}
+
diff --git a/HanksRT.c b/HanksRT.c
index c828fd5..3645ff9 100644
--- a/HanksRT.c
+++ b/HanksRT.c
@@ -125,6 +125,10 @@ time_t RunningConnectScript = 0;
struct HistoryRec * History = NULL;
int HistoryCount = 0;
+static FILE * LogHandle[4] = {NULL, NULL, NULL, NULL};
+
+static time_t LastLogTime[4] = {0, 0, 0, 0};
+
typedef int (WINAPI FAR *FARPROCX)();
extern FARPROCX pRunEventProgram;
@@ -299,6 +303,7 @@ VOID __cdecl nprintf(ChatCIRCUIT * conn, const char * format, ...)
va_start(arglist, format);
vsnprintf(buff, sizeof(buff), format, arglist);
+ va_end(arglist);
nputs(conn, buff);
}
@@ -332,8 +337,9 @@ int ChatQueueMsg(ChatCIRCUIT * conn, char * msg, int len)
conn->u.link->lastMsgReceived = time(NULL);
// UCHAR * OutputQueue; // Messages to user
- // int OutputQueueLength; // Total Malloc'ed size. Also Put Pointer for next Message
- // int OutputGetPointer; // Next byte to send. When Getpointer = Queue Length all is sent - free the buffer and start again.
+ // int OutputQueueSize; // Total Malloc'ed size
+ // int OutputQueueLength; // Bytes queued. Also Put Pointer for next Message
+ // int OutputGetPointer; // Next byte to send. When Getpointer = QueueLength all is sent - free the buffer and start again.
// Create or extend buffer
@@ -819,7 +825,7 @@ VOID ProcessChatLine(ChatCIRCUIT * conn, struct UserInfo * user, char* OrigBuffe
while (ptr)
{
- nprintf(conn, ptr->Message);
+ nputs(conn, ptr->Message);
ptr = ptr->next;
}
@@ -3290,6 +3296,7 @@ VOID ChatTimer()
int i = 0;
ChatCIRCUIT *c;
+ int n;
#ifndef LINBPQ
int len;
@@ -3477,6 +3484,22 @@ VOID ChatTimer()
node_keepalive();
}
+ // Flush logs
+
+ for (n = 0; n < 4; n++)
+ {
+ if (LogHandle[n])
+ {
+ time_t LT = time(NULL);
+ if ((LT - LastLogTime[n]) > 30)
+ {
+ LastLogTime[n] = LT;
+ fclose(LogHandle[n]);
+ LogHandle[n] = NULL;
+ }
+ }
+ }
+
FreeSemaphore(&ChatSemaphore);
if (NeedINFO)
@@ -4430,15 +4453,6 @@ VOID SendChatReport(SOCKET ChatReportSocket, char * buff, int txlen)
#endif
-
-#ifndef WIN32
-#define INVALID_HANDLE_VALUE (void *)-1
-#endif
-
-static FILE * LogHandle[4] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE};
-
-static time_t LastLogTime[4] = {0, 0, 0, 0};
-
static char FilesNames[4][100] = {"", "", "", ""};
static char * Logs[4] = {"BBS", "CHAT", "TCP", "DEBUG"};
@@ -4479,7 +4493,7 @@ void ChatWriteLogLine(ChatCIRCUIT * conn, int Flag, char * Msg, int MsgLen, int
char CRLF[2] = {0x0d,0x0a};
struct tm * tm;
char Stamp[20];
- time_t T;
+ time_t LT;
#ifndef LINBPQ
@@ -4516,12 +4530,12 @@ void ChatWriteLogLine(ChatCIRCUIT * conn, int Flag, char * Msg, int MsgLen, int
if (Flags == LOG_CHAT && !LogCHAT)
return;
- if (LogHandle[Flags] == INVALID_HANDLE_VALUE) ChatOpenLogfile(Flags);
+ if (LogHandle[Flags] == NULL) ChatOpenLogfile(Flags);
- if (LogHandle[Flags] == INVALID_HANDLE_VALUE) return;
+ if (LogHandle[Flags] == NULL) return;
- T = time(NULL);
- tm = gmtime(&T);
+ LT = time(NULL);
+ tm = gmtime(&LT);
sprintf(Stamp,"%02d%02d%02d %02d:%02d:%02d %c",
tm->tm_year-100, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, Flag);
@@ -4544,8 +4558,14 @@ void ChatWriteLogLine(ChatCIRCUIT * conn, int Flag, char * Msg, int MsgLen, int
else
fwrite(CRLF, 1, 2, LogHandle[Flags]);
- fclose(LogHandle[Flags]);
- LogHandle[Flags] = INVALID_HANDLE_VALUE;
+ // Don't close/reopen logs every time
+
+ if ((LT - LastLogTime[Flags]) > 30)
+ {
+ LastLogTime[Flags] = LT;
+ fclose(LogHandle[Flags]);
+ LogHandle[Flags] = NULL;
+ }
}
diff --git a/Housekeeping.c b/Housekeeping.c
index 319126f..7636317 100644
--- a/Housekeeping.c
+++ b/Housekeeping.c
@@ -836,7 +836,6 @@ int DeleteBBSLogFiles()
{
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
- OutputDebugString(ffd.cFileName);
}
else
{
diff --git a/IPCode.c b/IPCode.c
index 4d9abca..6783d14 100644
--- a/IPCode.c
+++ b/IPCode.c
@@ -2472,7 +2472,7 @@ VOID ProcessRIP44Message(PIPMSG IPptr)
SaveIPRoutes();
qsort(RouteRecords, NumberofRoutes, sizeof(void *), CompareMasks);
- LastRIP44Msg = time(NULL);
+ LastRIP44Msg = NOW;
}
@@ -3639,7 +3639,6 @@ VOID DoRouteTimer()
{
int i;
PROUTEENTRY Route;
- time_t NOW = time(NULL);
for (i=0; i < NumberofRoutes; i++)
{
@@ -4746,7 +4745,6 @@ VOID PING(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CMD
UCHAR Msg[120] = "";
PIPMSG IPptr = (PIPMSG)&Msg[40]; // Space for frame header (not used)
PICMPMSG ICMPptr = (PICMPMSG)&IPptr->Data;
- time_t NOW = time(NULL);
Bufferptr = Cmdprintf(Session, Bufferptr, "\r");
@@ -5362,7 +5360,7 @@ int ProcessSNMPPayload(UCHAR * Msg, int Len, UCHAR * Reply, int * OffPtr)
else if (memcmp(OID, sysUpTime, sysUpTimeLen) == 0)
{
int ValOffset = 10;
- ValLen = ASNPutInt(Value, ValOffset, (int)((time(NULL) - TimeLoaded) * 100), TimeTicks);
+ ValLen = ASNPutInt(Value, ValOffset, (int)((NOW - TimeLoaded) * 100), TimeTicks);
ValOffset -= ValLen;
PDULen = BuildReply(Reply, Offset, sysUpTime, sysUpTimeLen, &Value[ValOffset], ReqID);
diff --git a/KAMPactor.c b/KAMPactor.c
index 239b183..6991987 100644
--- a/KAMPactor.c
+++ b/KAMPactor.c
@@ -102,7 +102,7 @@ BOOL KAMStopPort(struct PORTCONTROL * PORT)
TNC->HostMode = FALSE;
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Stopped");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -117,7 +117,7 @@ BOOL KAMStartPort(struct PORTCONTROL * PORT)
TNC->ReinitState = 0;
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Restarted");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -142,7 +142,7 @@ static BOOL OpenLogFile(int Flags)
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(FN,"%s/logs/KAMLog_%02d%02d_%d.txt", LogDirectory, tm->tm_mon + 1, tm->tm_mday, Flags);
@@ -524,7 +524,7 @@ VOID KAMSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
struct STREAMINFO * STREAM = &TNC->Streams[0];
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
// sprintf(STREAM->CmdSet, "I%s\r", "SCSPTC"); // Should prevent connects
@@ -536,14 +536,14 @@ VOID KAMReleasePort(struct TNCINFO * TNC)
struct STREAMINFO * STREAM = &TNC->Streams[0];
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<head><title>KAM Pactor Status</title></head><body><h3>KAM Pactor Status</h3>");
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 480px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
@@ -1940,7 +1940,7 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len)
}
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->BytesAcked = 0;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
if (Stream == 0)
{
diff --git a/KISSHF.c b/KISSHF.c
index 59fd3ec..7851024 100644
--- a/KISSHF.c
+++ b/KISSHF.c
@@ -295,106 +295,106 @@ ok:
switch (fn)
{
- case 7:
+ case 7:
// 100 mS Timer. May now be needed, as Poll can be called more frequently in some circumstances
SerialCheckRX(TNC);
- return 0;
- case 1: // poll
+ STREAM = &TNC->Streams[0];
- STREAM = &TNC->Streams[0];
+ if (STREAM->NeedDisc)
+ {
+ STREAM->NeedDisc--;
- if (STREAM->NeedDisc)
+ if (STREAM->NeedDisc == 0)
{
- STREAM->NeedDisc--;
-
- if (STREAM->NeedDisc == 0)
- {
- // Send the DISCONNECT
+ // Send the DISCONNECT
- SerialSendCommand(TNC, "DISCONNECT\r");
- }
+ SerialSendCommand(TNC, "DISCONNECT\r");
}
+ }
- if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
- {
- // New Attach
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
+ {
+ // New Attach
- int calllen;
- char Msg[80];
+ int calllen;
+ char Msg[80];
- STREAM->Attached = TRUE;
+ STREAM->Attached = TRUE;
- calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
- TNC->Streams[Stream].MyCall[calllen] = 0;
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
+ TNC->Streams[Stream].MyCall[calllen] = 0;
- // Stop other ports in same group
+ // Stop other ports in same group
- SuspendOtherPorts(TNC);
+ SuspendOtherPorts(TNC);
- sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
- // Stop Scanning
+ // Stop Scanning
- sprintf(Msg, "%d SCANSTOP", TNC->Port);
+ sprintf(Msg, "%d SCANSTOP", TNC->Port);
- Rig_Command( (TRANSPORTENTRY *) -1, Msg);
- }
+ Rig_Command( (TRANSPORTENTRY *) -1, Msg);
+ }
- if (STREAM->Attached)
- CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+ if (STREAM->Attached)
+ CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+ return 0;
- // See if any frames for this port
+ case 1: // poll
+ // See if any frames for this port
- STREAM = &TNC->Streams[0];
- if (STREAM->BPQtoPACTOR_Q)
- {
- PMSGWITHLEN buffptr = (PMSGWITHLEN)Q_REM(&STREAM->BPQtoPACTOR_Q);
- UCHAR * data = &buffptr->Data[0];
- STREAM->FramesQueued--;
- txlen = (int)buffptr->Len;
- STREAM->bytesTXed += txlen;
-
- bytes=SerialSendData(TNC, data, txlen);
- WritetoTrace(TNC, data, txlen);
- }
+ STREAM = &TNC->Streams[0];
- if (STREAM->PACTORtoBPQ_Q != 0)
- {
- buffptr = (PMSGWITHLEN)Q_REM(&STREAM->PACTORtoBPQ_Q);
+ if (STREAM->BPQtoPACTOR_Q)
+ {
+ PMSGWITHLEN buffptr = (PMSGWITHLEN)Q_REM(&STREAM->BPQtoPACTOR_Q);
+ UCHAR * data = &buffptr->Data[0];
+ STREAM->FramesQueued--;
+ txlen = (int)buffptr->Len;
+ STREAM->bytesTXed += txlen;
+
+ bytes=SerialSendData(TNC, data, txlen);
+ WritetoTrace(TNC, data, txlen);
+ }
- datalen = (int)buffptr->Len;
+ if (STREAM->PACTORtoBPQ_Q != 0)
+ {
+ buffptr = (PMSGWITHLEN)Q_REM(&STREAM->PACTORtoBPQ_Q);
- buff->PORT = Stream; // Compatibility with Kam Driver
- buff->PID = 0xf0;
- memcpy(&buff->L2DATA, &buffptr->Data[0], datalen); // Data goes to + 7, but we have an extra byte
- datalen += sizeof(void *) + 4;
+ datalen = (int)buffptr->Len;
- PutLengthinBuffer(buff, datalen);
+ buff->PORT = Stream; // Compatibility with Kam Driver
+ buff->PID = 0xf0;
+ memcpy(&buff->L2DATA, &buffptr->Data[0], datalen); // Data goes to + 7, but we have an extra byte
+ datalen += sizeof(void *) + 4;
- ReleaseBuffer(buffptr);
+ PutLengthinBuffer(buff, datalen);
- return (1);
- }
+ ReleaseBuffer(buffptr);
- if (STREAM->ReportDISC) // May need a delay so treat as a counter
- {
- STREAM->ReportDISC--;
+ return (1);
+ }
- if (STREAM->ReportDISC == 0)
- {
- buff->PORT = Stream;
- return -1;
- }
+ if (STREAM->ReportDISC) // May need a delay so treat as a counter
+ {
+ STREAM->ReportDISC--;
+
+ if (STREAM->ReportDISC == 0)
+ {
+ buff->PORT = Stream;
+ return -1;
}
+ }
- return (0);
+ return (0);
case 2: // send
@@ -725,7 +725,7 @@ VOID KISSHFReleaseTNC(struct TNCINFO * TNC)
Rig_Command( (TRANSPORTENTRY *) -1, TXMsg);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
ReleaseOtherPorts(TNC);
}
@@ -734,19 +734,19 @@ VOID KISSHFSuspendPort(struct TNCINFO * TNC, struct TNCINFO * THISTNC)
{
TNC->PortRecord->PORTCONTROL.PortSuspended = 1;
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
VOID KISSHFReleasePort(struct TNCINFO * TNC)
{
TNC->PortRecord->PORTCONTROL.PortSuspended = 0;
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<script type=\"text/javascript\">\r\n"
"function ScrollOutput()\r\n"
"{var textarea = document.getElementById('textarea');"
@@ -1099,7 +1099,7 @@ VOID KISSThread(void * portptr)
i=sprintf(Msg, "Connect Failed for KISSHF socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -1160,7 +1160,7 @@ VOID KISSThread(void * portptr)
TNC->Alerted = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to KISS TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
@@ -1212,7 +1212,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -1262,7 +1262,7 @@ static int KissDecode(UCHAR * inbuff, UCHAR * outbuff, int len)
#define ACKMODE 4 // CAN USE ACK REQURED FRAMES
#define MSGHDDRLEN (USHORT)(sizeof(VOID *) + sizeof(UCHAR) + sizeof(USHORT))
-#define ONEMINUTE 60*3
+#define ONEMINUTE 60*10
static int KissEncode(struct TNCINFO * TNC, UCHAR * inbuff, UCHAR * outbuff, int len, int Channel)
{
@@ -1352,7 +1352,7 @@ VOID KISSHFProcessReceivedPacket(struct TNCINFO * TNC, int Channel)
TNC->Streams[0].ReportDISC = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return;
}
@@ -1529,7 +1529,7 @@ void AttachKISSHF(struct PORTCONTROL * PORT, MESSAGE * Buffer)
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
@@ -1604,7 +1604,7 @@ void KISSHFConnected(struct PORTCONTROL * PORT, struct _LINKTABLE * LINK)
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
diff --git a/KernelScript1.rc b/KernelScript1.rc
index b230ace..a845146 100644
--- a/KernelScript1.rc
+++ b/KernelScript1.rc
@@ -344,8 +344,8 @@ END
//
// Generated from the TEXTINCLUDE 3 resource.
//
-#include "..\CommonSource\Versions.h"
-#include "..\StdVer.inc"
+#include "Versions.h"
+#include "StdVer.inc"
/////////////////////////////////////////////////////////////////////////////
diff --git a/L2Code.c b/L2Code.c
index c2953f4..b6b54d9 100644
--- a/L2Code.c
+++ b/L2Code.c
@@ -54,9 +54,9 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#define RNRSENT 0x10 // WE HAVE SEND RNR
#define POLLSENT 0x20 // POLL BIT OUTSTANDING
-#define ONEMINUTE 60*3
-#define TENSECS 10*3
-#define THREESECS 3*3
+#define ONEMINUTE 60*10
+#define TENSECS 10*10
+#define THREESECS 3*10
VOID L2Routine(struct PORTCONTROL * PORT, PMESSAGE Buffer);
@@ -283,6 +283,8 @@ VOID L2Routine(struct PORTCONTROL * PORT, PMESSAGE Buffer)
}
}
+
+
BPQTRACE(Buffer, TRUE); // TRACE - RX frames to APRS
if (PORT->PORTMHEARD)
@@ -293,6 +295,14 @@ VOID L2Routine(struct PORTCONTROL * PORT, PMESSAGE Buffer)
InOctets[PORT->PORTNUMBER] += Buffer->LENGTH - MSGHDDRLEN;
+ // Check Exclude List
+
+ if (CheckExcludeList(Buffer->ORIGIN) == 0)
+ {
+ ReleaseBuffer(Buffer);
+ return;
+ }
+
// CHECK THAT ALL DIGIS HAVE BEEN ACTIONED,
// AND ADJUST FOR DIGIPEATERS IF PRESENT
@@ -565,7 +575,7 @@ DoMove:
memcpy (MHBASE->MHCALL, Buffer->ORIGIN, 7 * 9); // Save Digis
MHBASE->MHDIGI = DIGI;
- MHBASE->MHTIME = time(NULL);
+ MHBASE->MHTIME = NOW;
MHBASE->MHCOUNT = ++OldCount;
strcpy(MHBASE->MHFreq, Freq);
MHBASE->MHLocator[0] = 0;
@@ -955,7 +965,7 @@ 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
+ LINK->KILLTIMER = L2KILLTIME - 60*10; // Time out after 60 secs if SABM not received
// save calls so we can match up SABM when it comes
@@ -3147,7 +3157,7 @@ VOID SDETX(struct _LINKTABLE * LINK)
// **** Debug code **** look for stuck links
- if (LINK->LINKWINDOW == 0 || LINK->LASTFRAMESENT == 0 || (time(NULL) - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
+ if (LINK->LINKWINDOW == 0 || LINK->LASTFRAMESENT == 0 || (NOW - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
{
if (COUNT_AT_L2(LINK) > 16 || LINK->LINKWINDOW == 0)
{
@@ -3157,7 +3167,7 @@ VOID SDETX(struct _LINKTABLE * LINK)
char Normcall2[11] = "";
int Count = COUNT_AT_L2(LINK);
- int secs = time(NULL) - LINK->LASTFRAMESENT;
+ int secs = NOW - LINK->LASTFRAMESENT;
ConvFromAX25(LINK->LINKCALL, Normcall);
ConvFromAX25(LINK->OURCALL, Normcall2);
@@ -3199,7 +3209,7 @@ VOID SDETX(struct _LINKTABLE * LINK)
Msg = Q_REM(&LINK->TX_Q);
Msg->CHAIN = NULL;
- LINK->LASTFRAMESENT = time(NULL);
+ LINK->LASTFRAMESENT = NOW;
LINK->LASTSENTQCOUNT = COUNT_AT_L2(LINK);
if (LINK->LASTSENTQCOUNT > LINK->maxQueued)
@@ -3451,7 +3461,9 @@ VOID L2TimerProc()
int i = MAXLINKS;
struct _LINKTABLE * LINK = LINKS;
struct PORTCONTROL * PORT = PORTTABLE;
- time_t Now = time(NULL);
+ time_t Now = NOW;
+
+ // Now 100 mS
while (i--)
{
@@ -3929,7 +3941,7 @@ VOID L2SENDXID(struct _LINKTABLE * LINK)
{
// NO BUFFERS - SET TIMER TO FORCE RETRY
- LINK->L2TIMER = 10*3; // SET TIMER
+ LINK->L2TIMER = 10*10; // SET TIMER
return;
}
@@ -4029,7 +4041,7 @@ VOID L2SENDCOMMAND(struct _LINKTABLE * LINK, int CMD)
// NO BUFFERS - SET TIMER TO FORCE RETRY
if (CMD & PFBIT) // RESPONSE EXPECTED?
- LINK->L2TIMER = 10*3; // SET TIMER
+ LINK->L2TIMER = 10*10; // SET TIMER
return;
}
@@ -4078,7 +4090,7 @@ VOID L2SENDRESPONSE(struct _LINKTABLE * LINK, int CMD)
// NO BUFFERS - SET TIMER TO FORCE RETRY
if (CMD & PFBIT) // RESPONSE EXPECTED?
- LINK->L2TIMER = 10*3; // SET TIMER
+ LINK->L2TIMER = 10*10; // SET TIMER
return;
}
diff --git a/L3Code.c b/L3Code.c
index 2ca3d93..48e3c47 100644
--- a/L3Code.c
+++ b/L3Code.c
@@ -1028,7 +1028,7 @@ VOID CLEARACTIVEROUTE(struct ROUTE * ROUTE, int Reason)
}
-VOID L3TimerProc()
+VOID L3MinuteTimerProc()
{
int i;
struct PORTCONTROL * PORT = PORTTABLE;
@@ -1127,7 +1127,7 @@ VOID L3TimerProc()
}
}
-VOID L3FastTimer()
+VOID L3SecTimer()
{
// CALLED ONCE PER SECOND - USED ONLY TO SEND NEXT PART OF A NODES OR
// ID MESSAGE SEQUENCE
@@ -1370,6 +1370,27 @@ VOID REMOVENODE(dest_list * DEST)
}
L4++;
}
+
+ if (DEST->XROptions)
+ {
+ XROptions * Options = DEST->XROptions;
+
+ if (Options->LOC)
+ free(Options->LOC);
+
+ if (Options->QTH)
+ free(Options->QTH);
+
+ if (Options->Ver)
+ free(Options->Ver);
+
+ if (Options->Optionslist)
+ free(Options->Optionslist);
+
+
+ free(DEST->XROptions);
+ }
+
memset(DEST, 0, sizeof(struct DEST_LIST));
NUMBEROFNODES--;
diff --git a/L4Code.c b/L4Code.c
index e146218..76f66de 100644
--- a/L4Code.c
+++ b/L4Code.c
@@ -59,7 +59,7 @@ int CHECKIFBUSYL4(TRANSPORTENTRY * L4);
VOID AUTOTIMER(TRANSPORTENTRY * L4);
VOID NRRecordRoute(UCHAR * Buff, int Len);
VOID REFRESHROUTE(TRANSPORTENTRY * Session);
-VOID ACKFRAMES(L3MESSAGEBUFFER * L3MSG, TRANSPORTENTRY * L4, int NR);
+VOID ACKFRAMES(L3MESSAGEBUFFER * L3MSG, TRANSPORTENTRY * L4, int NR, int UPDATERTT);
VOID SENDL4IACK(TRANSPORTENTRY * Session);
VOID CHECKNEIGHBOUR(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * Msg);
VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port);
@@ -74,6 +74,7 @@ void IncomingL4ConnectionEvent(TRANSPORTENTRY * L4);
void L4DisconnectEvent(TRANSPORTENTRY * L4, char * Direction, char * Reason);
VOID TCPNETROMSend(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Frame);
void L4StatusSeport(TRANSPORTENTRY * L4);
+void ProcessNCMPMsg(L3MESSAGEBUFFER * L3MSG);
static UINT APPLMASK;
@@ -98,13 +99,43 @@ int sessionStatusInterval = 300; // 5 mins
extern APPLCALLS * APPL;
+void SendNCMPDestunreachable(L3MESSAGEBUFFER * L3MSG, int Code)
+{
+ // Return NCMP Dest Unreachable TTL Exceeded
+
+ struct DEST_LIST * DEST = 0;
+
+ UCHAR ORIG[28];
+
+ memcpy(ORIG, L3MSG->L3SRCE, 28); // First 28 bytes of unrouteable message
+ L3MSG->L3TTL = L3LIVES;
+ L3MSG->LENGTH = MSGHDDRLEN + 21 + 28; // Include PID 20 L3/4 Header 28 Orig Datagram
+ memcpy(L3MSG->L3DEST, L3MSG->L3SRCE, 7);
+ memcpy(L3MSG->L3SRCE, MYCALL, 7);
+ L3MSG->L4INDEX = 0x0f;
+ L3MSG->L4ID = 0x00;
+ L3MSG->L4TXNO = 5; // Unreachable
+ L3MSG->L4RXNO = Code;
+ L3MSG->L4FLAGS = 0;
+ memcpy(L3MSG->L4DATA, ORIG, 28); // PID + L3 Header
+
+ if (FindDestination(L3MSG->L3DEST, &DEST))
+ {
+ C_Q_ADD(&DEST->DEST_Q, (UINT *)L3MSG);
+ return;
+ }
+
+ ReleaseBuffer(L3MSG);
+ return;
+}
+
+
VOID NETROMMSG(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG)
{
// MAKE SURE PID IS 0CF - IN CASE SOMEONE IS SENDING L2 STUFF ON WHAT
// WE THINK IS A _NODE-_NODE LINK
- struct DEST_LIST * DEST;
-
+ struct DEST_LIST * DEST = 0;
int n;
if (L3MSG->L3PID != 0xCF)
@@ -187,7 +218,9 @@ VOID NETROMMSG(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG)
if (L3MSG->L3TTL == 0)
{
- ReleaseBuffer(L3MSG);
+ // Return NCMP Dest Unreachable TTL Exceeded (5)
+
+ SendNCMPDestunreachable(L3MSG, 5);
return;
}
@@ -225,10 +258,14 @@ VOID NETROMMSG(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG)
if (FindDestination(L3MSG->L3DEST, &DEST) == 0)
{
- ReleaseBuffer(L3MSG); // CANT FIND DESTINATION
+ // Return NCMP Dest Unreachable Host Ubknown (0)
+
+ SendNCMPDestunreachable(L3MSG, 0);
return;
}
+
+
// IF MESSAGE ORIGINTED HERE, THERE MUST BE A ROUTING LOOP -
// THERE IS LITTLE POINT SENDING IT OVER THE SAME ROUTE AGAIN,
// SO SET ANOTHER ROUTE ACTIVE IF POSSIBLE
@@ -284,7 +321,6 @@ NO_PROBLEM:
// EVEN IF WE CANT PUT ORIGINATING NODE INTO OUR TABLES, PASS MSG ON
// ANYWAY - THE FINAL TARGET MAY HAVE ANOTHER WAY BACK
-
C_Q_ADD(&DEST->DEST_Q, L3MSG);
L3FRAMES++;
@@ -1123,7 +1159,7 @@ VOID CLOSECURRENTSESSION(TRANSPORTENTRY * Session)
}
-VOID L4TimerProc()
+VOID L4SecTimer()
{
// CHECK FOR TIMER EXPIRY
@@ -1131,7 +1167,7 @@ VOID L4TimerProc()
TRANSPORTENTRY * L4 = L4TABLE;
TRANSPORTENTRY * Partner;
int MaxLinks = MAXLINKS;
- time_t Now = time(NULL);
+ time_t Now = NOW;
while (n--)
{
@@ -1576,7 +1612,7 @@ void WriteL4LogLine(UCHAR * mycall, UCHAR * call, UCHAR * node)
Call3[ConvFromAX25(node, Call3)] = 0;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(FN,"%s/L4Log_%02d%02d.txt", BPQDirectory, tm->tm_mon + 1, tm->tm_mday);
@@ -1758,8 +1794,6 @@ VOID SendConACK(struct _LINKTABLE * LINK, TRANSPORTENTRY * L4, L3MESSAGEBUFFER *
{
// SEND CONNECT ACK
- struct TNCINFO * TNC;
-
L4CONNECTSIN++;
L3MSG->L4TXNO = L4->CIRCUITINDEX;
@@ -1785,6 +1819,39 @@ VOID SendConACK(struct _LINKTABLE * LINK, TRANSPORTENTRY * L4, L3MESSAGEBUFFER *
WriteConnectLog(From, toCall, "NETROM");
}
+ L3SWAPADDRESSES(L3MSG);
+
+ L3MSG->L3TTL = L3LIVES;
+
+ L3MSG->LENGTH = MSGHDDRLEN + 22; // CTL 20 BYTE Header Window
+
+ if (BPQNODE)
+ {
+ L3MSG->L4DATA[1] = L3LIVES; // Our TTL
+ if (L4->AllowCompress)
+ L3MSG->L4DATA[1] |= 0x80;
+
+ L3MSG->LENGTH++;
+ }
+
+ C_Q_ADD(&L4->L4TARGET.DEST->DEST_Q, (UINT *)L3MSG);
+
+/*
+
+ // This sends to neighbour. Now we queue to normal L4 Q
+
+ 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);
+*/
if (CTEXTLEN && Applmask == 0) // Connects to Node (not application)
{
@@ -1818,33 +1885,6 @@ VOID SendConACK(struct _LINKTABLE * LINK, TRANSPORTENTRY * L4, L3MESSAGEBUFFER *
}
}
- L3SWAPADDRESSES(L3MSG);
-
- L3MSG->L3TTL = L3LIVES;
-
- L3MSG->LENGTH = MSGHDDRLEN + 22; // CTL 20 BYTE Header Window
-
- if (BPQNODE)
- {
- L3MSG->L4DATA[1] = L3LIVES; // Our TTL
- if (L4->AllowCompress)
- L3MSG->L4DATA[1] |= 0x80;
-
- L3MSG->LENGTH++;
- }
-
- 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);
-
IncomingL4ConnectionEvent(L4);
}
@@ -2172,6 +2212,12 @@ VOID FRAMEFORUS(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG, int ApplMask,
return;
}
+ if (L3MSG->L4ID == 0x00 && L3MSG->L4INDEX == 0x0f) // Paula's NCMP
+ {
+ ProcessNCMPMsg(L3MSG);
+ return;
+ }
+
ReleaseBuffer(L3MSG);
return;
@@ -2382,7 +2428,7 @@ VOID FRAMEFORUS(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG, int ApplMask,
}
*/
- ACKFRAMES(L3MSG, L4, L3MSG->L4RXNO);
+ ACKFRAMES(L3MSG, L4, L3MSG->L4RXNO, 1);
// If DISCPENDING or STATE IS 4, THEN SESSION IS CLOSING - IGNORE ANY I FRAMES
@@ -2620,7 +2666,7 @@ checkReseq:
case L4IACK:
- ACKFRAMES(L3MSG, L4, L3MSG->L4RXNO);
+ ACKFRAMES(L3MSG, L4, L3MSG->L4RXNO, 0);
REFRESHROUTE(L4);
ReleaseBuffer(L3MSG);
@@ -2635,7 +2681,7 @@ checkReseq:
}
-VOID ACKFRAMES(L3MESSAGEBUFFER * L3MSG, TRANSPORTENTRY * L4, int NR)
+VOID ACKFRAMES(L3MESSAGEBUFFER * L3MSG, TRANSPORTENTRY * L4, int NR, int UPDATERTT)
{
// SEE HOW MANY FRAMES ARE ACKED - IF NEGATIVE, THAN THIS MUST BE A
// DELAYED REPEAT OF AN ACK ALREADY PROCESSED
@@ -2675,18 +2721,21 @@ VOID ACKFRAMES(L3MESSAGEBUFFER * L3MSG, TRANSPORTENTRY * L4, int NR)
{
if (L4->RTT_TIMER)
{
- // FRAME BEING TIMED HAS BEEN ACKED - UPDATE DEST RTT TIMER
+ // FRAME BEING TIMED HAS BEEN ACKED - UPDATE DEST RTT TIMER unless INFO ACK
- DEST = L4->L4TARGET.DEST;
+ if (UPDATERTT)
+ {
+ DEST = L4->L4TARGET.DEST;
- RTT = GetTickCount() - L4->RTT_TIMER;
+ RTT = GetTickCount() - L4->RTT_TIMER;
- if (RTT < 180000) // Sanity Check
- {
- if (DEST->DEST_RTT == 0)
- DEST->DEST_RTT = RTT;
- else
- DEST->DEST_RTT = ((DEST->DEST_RTT * 9) + RTT) /10; // 90% Old + New
+ if (RTT < 180000) // Sanity Check
+ {
+ if (DEST->DEST_RTT == 0)
+ DEST->DEST_RTT = RTT;
+ else
+ DEST->DEST_RTT = ((DEST->DEST_RTT * 9) + RTT) /10; // 90% Old + New
+ }
}
L4->RTT_TIMER = 0;
}
@@ -2820,3 +2869,294 @@ int CloseAllSessions()
}
return Closed;
}
+
+// NCMP Code
+
+/*
+|<--------------- NCMP Header ------------->
+| --------------------------------------------------------------
+| L3hdr | Fam | Prot | Type | Code | 00 | (options) | (Payload)
+|--------------------------------------------------------------
+Field Bytes Description-------------------------------------------------------
+L3hdr 15 NET/ROM Layer 3 Header
+Fam 1 Protocol Family = NET/ROM = 0x0f
+Prot 1 Protocol = NCMP = 0x00
+Type 1 Type of NCMP packet (see below)
+Code 1 Usage depends on "type".
+Options var Additional fields present in some types only
+Payload var Optional payload present in some types only
+
+The upper 4 bits of the TYPE are reserved for future expansion, and
+are set to zero in this version. The lower 4 bits are the packet type
+as follows:
+Type Purpose
+-----------------------------------
+0 Probe Request
+1 Probe Reply
+2 Echo Request
+3 Echo Reply
+4 Routing Information Unicast
+5 Destination Unreachable
+
+ 0 Host Unknown The router does not know the destination
+ node.
+
+ 1 Host Unreachable The destination node is known, but there
+ are no viable routes at this time, due to
+obsolescence or link failure.
+ 2 Net Unreachable The number of hops to the target system is
+ more than the remaining Time To Live.
+ 3 Proto Unreachable The destination host does not know how to
+ handle the requested protocol.
+
+ 4 Service Unreach The requested service is not implemented at
+ the destination host.
+
+ 5 TTL Exceeded The datagram could not be routed any
+ further because the Layer 3 Time to Live
+has reached zero.
+
+ 6 Frag Required The datagram is too large for the outgoing
+ link, and the link does not support
+fragmentation.
+ 7 Source Quench The datagram could not be handled at this
+ time due to insufficient resources. This
+situation is temporary. Upon receipt of
+this message, the sender should reduce the
+sending rate.
+*/
+
+char NCMPTypes[6][28] = {
+ "Probe Request",
+ "Probe Reply",
+ "Echo Request",
+ "Echo Reply",
+ "Routing Information Unicast",
+ "Destination Unreachable"};
+
+char Reasons[8][24] = {
+ "Host Unknown",
+ "Host Unreachable",
+ "Net Unreachable",
+ "Proto Unreachabl",
+ "Service Unreachable",
+ "TTL Exceeded",
+ "Fragmentation Required",
+ "Source Quench"};
+
+void ProcessNCMPMsg(L3MESSAGEBUFFER * L3MSG)
+{
+ struct DEST_LIST * DEST;
+ L3MESSAGEBUFFER OLDMSG;
+ TRANSPORTENTRY * L4;
+ TRANSPORTENTRY * Partner;
+ char Nodename[20];
+ int n;
+ struct DATAMESSAGE * Msg;
+ UCHAR * ptr1;
+ uint16_t NOW = (uint16_t)GetTickCount() & 0xffff;
+ uint16_t RTT;
+ int Hops;
+
+ switch(L3MSG->L4TXNO & 15)
+ {
+ case 0:
+
+ n = 1;
+ break;
+
+ case 1:
+
+ n = 1;
+ break;
+
+ case 2: // Echo
+
+ // Return an Echo Response
+
+ L3MSG->L4TXNO = 3;
+
+ L3SWAPADDRESSES(L3MSG);
+
+ // L3RXNO has originator's TTL
+
+ // We return the TTL from the originating message in L3RXNO
+
+ L3MSG->L4RXNO = L3MSG->L3TTL;
+
+ L3MSG->L3TTL = L3LIVES;
+
+ if (FindDestination(L3MSG->L3DEST, &DEST))
+ {
+ C_Q_ADD(&DEST->DEST_Q, (UINT *)L3MSG);
+ return;
+ }
+ break;
+
+ case 3: // Echo Reply
+
+ RTT = NOW - ((L3MSG->L4DATA[2] << 8) + L3MSG->L4DATA[3]);
+ Hops = L3LIVES + 1 - L3MSG->L4RXNO;
+
+ L4 = L4TABLE + (L3MSG->L4DATA[0] << + 8) + L3MSG->L4DATA[1];
+
+ Nodename[DecodeNodeName(L3MSG->L3SRCE, Nodename)] = 0; // null terminate
+
+ Msg = (PDATAMESSAGE)L3MSG; // reuse input buffer
+
+ Msg->PID = 0xf0;
+ ptr1 = SetupNodeHeader(Msg);
+
+ ptr1 += sprintf(ptr1, "Echo reply from %s: rtt %d msec, %d hop(s)\r", Nodename, RTT, Hops);
+
+ Msg->LENGTH = (int)(ptr1 - (UCHAR *)Msg);
+
+ C_Q_ADD(&L4->L4TX_Q, Msg);
+
+ PostDataAvailable(L4);
+ return;
+
+
+ case 4: // Routing info
+
+ break;
+
+ case 5: // Destination Unreachable
+
+ // Most useful in response to a connect request to tell user of a problem
+ // Maybe also on an established session, perhaps to select another route or tell user
+
+ // Pick out the unrouted datagram (in the INFO field) Should be 28 bytes. Use an L3MESSAGEBUFFER struct
+
+ memcpy(OLDMSG.L3SRCE, L3MSG->L4DATA, 28);
+
+ // if the original message is an NCMP Probe or Echo, processs Unreachables
+
+ if (OLDMSG.L4INDEX == 15 && OLDMSG.L4ID ==0 && OLDMSG.L4TXNO == 2)
+ {
+ // Process like Ping Response but with different message
+
+ L4 = L4TABLE + (OLDMSG.L4DATA[0] << + 8) + OLDMSG.L4DATA[1];
+
+ Nodename[DecodeNodeName(L3MSG->L3SRCE, Nodename)] = 0; // null terminate
+
+ Msg = (PDATAMESSAGE)L3MSG; // reuse input buffer
+
+ Msg->PID = 0xf0;
+ ptr1 = SetupNodeHeader(Msg);
+
+ ptr1 += sprintf(ptr1, "Destination Unreachable(%s) returned from %s to Echo Request\r", Reasons[L3MSG->L4RXNO], Nodename);
+
+ Msg->LENGTH = (int)(ptr1 - (UCHAR *)Msg);
+
+ C_Q_ADD(&L4->L4TX_Q, Msg);
+
+ PostDataAvailable(L4);
+ return;
+ }
+ // Find the connection
+
+ n = MAXCIRCUITS;
+ L4 = L4TABLE;
+
+ while (n--)
+ {
+ // if ((L4->L4USER[0] && L4->FARID == OLDMSG.L4RXNO && L4->FARINDEX == OLDMSG.L4TXNO) || // Paula returns session in RX/TXNO, I sent in ID/INDEX
+ if (L4->L4USER[0] && L4->CIRCUITID == OLDMSG.L4ID && L4->CIRCUITINDEX == OLDMSG.L4INDEX)
+ {
+ // Check calls as well
+
+ if (memcmp(L4->L4TARGET.DEST->DEST_CALL, &OLDMSG.L3DEST, 7) == 0)
+ {
+ if ((OLDMSG.L4FLAGS & 15) != L4CREQ) // for now only on Connect Request
+ {
+ ReleaseBuffer(L3MSG);
+ return;
+ }
+
+ Partner = L4->L4CROSSLINK;
+ DEST = L4->L4TARGET.DEST;
+
+ CLEARSESSIONENTRY(L4);
+
+ if (Partner)
+ Partner->L4CROSSLINK = NULL; // CLEAR CROSSLINK
+
+ if (Partner == 0)
+ {
+ ReleaseBuffer(L3MSG);
+ return;
+ }
+
+ Nodename[DecodeNodeName(L3MSG->L3SRCE, Nodename)] = 0; // null terminate
+
+ Msg = (PDATAMESSAGE)L3MSG; // reuse input buffer
+
+ Msg->PID = 0xf0;
+ ptr1 = SetupNodeHeader(Msg);
+ ptr1 += sprintf(ptr1, "Destination Unreachable(%s) from %s\r", Reasons[L3MSG->L4RXNO], Nodename);
+
+ Msg->LENGTH = (int)(ptr1 - (UCHAR *)Msg);
+
+ C_Q_ADD(&Partner->L4TX_Q, Msg);
+
+ PostDataAvailable(Partner);
+ return;
+ }
+ }
+ L4++;
+ }
+ break;
+ }
+
+ ReleaseBuffer(L3MSG);
+ return;
+}
+
+VOID SendNRPing(struct DEST_LIST * DEST, TRANSPORTENTRY * Session)
+{
+ L3MESSAGEBUFFER * Msg = GetBuff();
+ int SessID;
+ uint16_t NOW = (uint16_t)GetTickCount() & 0xffff;
+
+ if (Msg == NULL)
+ return;
+
+ SessID = (Session - L4TABLE); // Save Session Pointer for reply
+
+ Msg->Port = 0;
+ Msg->L3PID = NRPID;
+
+ memcpy(Msg->L3DEST, DEST->DEST_CALL, 7);
+ memcpy(Msg->L3SRCE, MYCALL, 7);
+/*
+ -----------------------------------------------------------
+ | 0F | 00 | Type=2 | TTL | 00 | ID | Seq | Optional payload |
+ -----------------------------------------------------------
+ "TTL" is the initial Layer 3 TTL
+ "ID" is a unique 16 bit identifier, sent high octet first,
+ allowing the originator to match responses with the requests.
+ "Seq" is a 16 bit sequence number, sent high octet first.
+ Usually carries a timestamp, allowing the RTT to be computed.
+ if (L3MSG->L4ID == 0x00 && L3MSG->L4INDEX == 0x0f) // Paula's NCMP
+
+*/
+
+ Msg->L3TTL = L3LIVES;
+ Msg->L4INDEX = 0x0f;
+ Msg->L4ID = 0;
+ Msg->L4TXNO = 2;
+ Msg->L4RXNO = L3LIVES;
+ Msg->L4FLAGS = 0;
+ Msg->L4DATA[0] = SessID >> 8;
+ Msg->L4DATA[1] = SessID & 0xff;
+ Msg->L4DATA[2] = NOW >> 8;
+ Msg->L4DATA[3] = NOW & 0xff;
+
+ Msg->LENGTH = 25 + MSGHDDRLEN;
+
+ C_Q_ADD(&DEST->DEST_Q, Msg);
+}
+
+
+
diff --git a/LinBPQ.c b/LinBPQ.c
index df0e334..8515119 100644
--- a/LinBPQ.c
+++ b/LinBPQ.c
@@ -29,6 +29,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#else
#include <iconv.h>
#include <errno.h>
+
#ifndef MACBPQ
#ifndef FREEBSD
#include <sys/prctl.h>
@@ -273,7 +274,7 @@ BOOL CLOSING = FALSE;
int ProgramErrors;
int Slowtimer = 0;
-#define REPORTINTERVAL 15 * 549; // Magic Ticks Per Minute for PC's nominal 100 ms timer
+#define REPORTINTERVAL 15 * 600; // 15 mins
int ReportTimer = 0;
// Console Terminal Support
@@ -384,26 +385,88 @@ BOOL CtrlHandler(DWORD fdwCtrlType)
#include <execinfo.h>
#include <signal.h>
+#include <backtrace.h>
+
+static struct backtrace_state *state;
+static char ** lines;
+static char * line;
+
+
+// Callback to print a niely formatted bsack tracre
+
+static int full_callback (void *data, uintptr_t pc, const char *pathname, int line_number, const char *function)
+{
+ if (pathname == NULL || function == NULL || line_number == 0)
+ Debugprintf(line);
+ else
+ {
+ const char *filename = rindex(pathname, '/');
+ if (filename) filename++; else filename = pathname;
+ Debugprintf("%s %s:%d -- %s", line, filename, line_number, function);
+ }
+ return 0;
+};
+
+static void error_callback (void *data, const char *message, int error_number)
+{
+ if (error_number == -1)
+ {
+ fprintf(stderr, "If you want backtraces, you have to compile with -g\n\n");
+ _Exit(1);
+ }
+ else
+ {
+ fprintf(stderr, "Backtrace error %d: %s\n", error_number, message);
+ }
+};
// Linux Signal Handlers
+
+VOID __cdecl DebugprintNOLF(const char * format, ...);
+
static void segvhandler(int sig)
{
- void *array[10];
+ void *array[50];
+
size_t size;
- char msg[] = "\nSIGSEGV Received\n";
+ char msg[] = "\nSIGSEGV Received\n\nBacktrace\n\n";
+ char msg2[] = "\nThere should be a better Backtrace in the Debug Log with source filenames and line numbers\n\n";
+ int n;
- write(STDERR_FILENO, msg, strlen(msg));
+ // Write the basic backtrace() first as this is meant to be signal safe
+
+ // Then try a libbacktrace(), which gives source info may use non-signal safe functions so may not work
+
+ write(STDOUT_FILENO, msg, strlen(msg));
// get void*'s for all entries on the stack
- size = backtrace(array, 10);
+
+ size = backtrace(array, 50);
- // print out all the frames to stderr
+ // normal print
+
+ backtrace_symbols_fd(array, size, STDOUT_FILENO);
- backtrace_symbols_fd(array, size, STDERR_FILENO);
+// if source info for the address is available we want to print it but otherwise print the old style back trace.
- write(STDOUT_FILENO, msg, strlen(msg));
- backtrace_symbols_fd(array, size, STDOUT_FILENO);
+ printf("\n");
+ printf("\n");
+
+ write(STDOUT_FILENO, msg2, strlen(msg2));
+
+ // backtrace_symbols produces an array of the old style records but isn't signal safe.
+ // Easiest probably to always print that and add source info if possible
+ lines = backtrace_symbols(array, size);
+
+ Debugprintf(msg);
+
+ for (n = 0; n < size; n++)
+ {
+ line = lines[n];
+ backtrace_pcinfo(state, (uintptr_t)array[n], full_callback, error_callback, NULL);
+ }
+
hookNodeClosing("sigsegv");
Sleep(500);
@@ -427,6 +490,12 @@ static void abrthandler(int sig)
write(STDOUT_FILENO, msg, strlen(msg));
backtrace_symbols_fd(array, size, STDOUT_FILENO);
+ printf("\n");
+ printf("\n");
+ backtrace_print(state, 0, stdout);
+
+ backtrace_print(state, 0, stderr);
+
hookNodeClosing("sigabrt");
Sleep(500);
@@ -543,7 +612,7 @@ VOID MonitorThread(void * x)
-VOID TIMERINTERRUPT();
+int TIMERINTERRUPT();
BOOL Start();
VOID INITIALISEPORTS();
@@ -672,6 +741,7 @@ void ConTermInput(char * Msg)
if (!ConTerm.CONNECTED)
SessionControl(ConTerm.BPQStream, 1, 0);
+
ConTerm.StackIndex = 0;
// Stack it
@@ -709,8 +779,18 @@ void ConTermPoll()
{
// Connected
+ BPQVECSTRUC * SESS;
+ TRANSPORTENTRY * L4;
+
ConTerm.CONNECTED = TRUE;
ConTerm.SlowTimer = 0;
+
+ SESS = &BPQHOSTVECTOR[ConTerm.BPQStream - 1];
+ if (SESS)
+ {
+ L4 = SESS->HOSTSESSION;
+ L4->Secure_Session = 1;
+ }
}
else
{
@@ -809,6 +889,340 @@ static void abrthandler(int sig);
void GetRestartData();
+void Semaphored100msCode()
+{
+ // code that doesn't need to run every tick - run every 100 mS
+
+ // Runs under semaphore
+
+ if (IPActive) Poll_IP();
+ if (RigActive) Rig_Poll();
+ if (APRSActive) Poll_APRS();
+ CheckWL2KReportTimer();
+
+ if (QCOUNT < 10)
+ {
+ if (CLOSING == FALSE)
+ FindLostBuffers();
+ CLOSING = TRUE;
+ }
+
+ if (CLOSING)
+ {
+ if (RunChat)
+ {
+ CloseChat();
+ RunChat = FALSE;
+ }
+
+ if (RunMail)
+ {
+ int BPQStream, n;
+
+ RunMail = FALSE;
+
+ for (n = 0; n < NumberofStreams; n++)
+ {
+ BPQStream = Connections[n].BPQStream;
+
+ if (BPQStream)
+ {
+ SetAppl(BPQStream, 0, 0);
+ Disconnect(BPQStream);
+ DeallocateStream(BPQStream);
+ }
+ }
+
+ // SaveUserDatabase();
+ SaveMessageDatabase();
+ SaveBIDDatabase();
+ SaveConfig(ConfigName);
+ SaveRestartData();
+ }
+
+ KEEPGOING--; // Give time for links to close
+ setbuf(stdout, NULL);
+ printf("Closing... %d \r", KEEPGOING);
+ }
+
+
+ if (RigReconfigFlag)
+ {
+ RigReconfigFlag = FALSE;
+ Rig_Close();
+ Sleep(2000); // Allow CATPTT threads to close
+ RigActive = Rig_Init();
+
+ Consoleprintf("Rigcontrol Reconfiguration Complete");
+ }
+
+ if (APRSReconfigFlag)
+ {
+ APRSReconfigFlag = FALSE;
+ APRSClose();
+ APRSActive = Init_APRS();
+
+ Consoleprintf("APRS Reconfiguration Complete");
+ }
+
+ if (ReconfigFlag)
+ {
+ int i;
+ BPQVECSTRUC * HOSTVEC;
+ PEXTPORTDATA PORTVEC=(PEXTPORTDATA)PORTTABLE;
+
+ ReconfigFlag = FALSE;
+
+ // SetupBPQDirectory();
+
+ WritetoConsoleLocal("Reconfiguring ...\n\n");
+
+ for (i=0;i<NUMBEROFPORTS;i++)
+ {
+ if (PORTVEC->PORTCONTROL.PORTTYPE == 0x10) // External
+ {
+ if (PORTVEC->PORT_EXT_ADDR)
+ {
+ // SaveWindowPos(PORTVEC->PORTCONTROL.PORTNUMBER);
+ // SaveAXIPWindowPos(PORTVEC->PORTCONTROL.PORTNUMBER);
+ // CloseDriverWindow(PORTVEC->PORTCONTROL.PORTNUMBER);
+ PORTVEC->PORT_EXT_ADDR(5,PORTVEC->PORTCONTROL.PORTNUMBER, NULL); // Close External Ports
+ }
+ }
+ PORTVEC->PORTCONTROL.PORTCLOSECODE(&PORTVEC->PORTCONTROL);
+ PORTVEC=(PEXTPORTDATA)PORTVEC->PORTCONTROL.PORTPOINTER;
+ }
+
+ IPClose();
+ APRSClose();
+ Rig_Close();
+ CloseTNCEmulator();
+
+ if (AGWActive)
+ AGWAPITerminate();
+
+ WL2KReports = NULL;
+
+ // Sleep(2000);
+
+ Consoleprintf("G8BPQ AX25 Packet Switch System Version %s %s", TextVerstring, Datestring);
+ Consoleprintf(VerCopyright);
+
+ Start();
+
+ NETROMTCPResolve();
+
+ INITIALISEPORTS();
+
+ SetApplPorts();
+
+ GetUIConfig();
+
+ FreeConfig();
+
+ for (i=1; i<68; i++) // Include Telnet, APRS, IP Vec
+ {
+ HOSTVEC=&BPQHOSTVECTOR[i-1];
+
+ HOSTVEC->HOSTTRACEQ=0;
+
+ if (HOSTVEC->HOSTSESSION !=0)
+ {
+ // Had a connection
+
+ HOSTVEC->HOSTSESSION=0;
+ HOSTVEC->HOSTFLAGS |=3; // Disconnected
+
+ // PostMessage(HOSTVEC->HOSTHANDLE, BPQMsg, i, 4);
+ }
+ }
+
+ OpenReportingSockets();
+
+ WritetoConsoleLocal("\n\nReconfiguration Complete\n");
+
+ if (IPRequired) IPActive = Init_IP();
+
+ APRSActive = Init_APRS();
+
+ if (ISPort == 0)
+ IGateEnabled = 0;
+
+ RigActive = Rig_Init();
+
+ if (NUMBEROFTNCPORTS)
+ {
+ FreeSemaphore(&Semaphore);
+ InitializeTNCEmulator();
+ GetSemaphore(&Semaphore, 2);
+ }
+
+ FreeSemaphore(&Semaphore);
+ AGWActive = AGWAPIInit();
+ GetSemaphore(&Semaphore, 2);
+
+ WritetoConsoleLocal("BPQ32 Reconfiguration Complete\n");
+ }
+}
+
+void UnSemaphored100msCode()
+{
+
+ if (Redirected == 0)
+ ConTermPoll();
+
+ if (NUMBEROFTNCPORTS)
+ TNCTimer();
+
+ if (AGWActive)
+ Poll_AGW();
+
+ DRATSPoll();
+ RHPPoll();
+
+ if (ReportTimer)
+ {
+ ReportTimer--;
+
+ if (ReportTimer == 0)
+ {
+ ReportTimer = REPORTINTERVAL;
+ SendLocation();
+ }
+ }
+
+ HTTPTimer();
+
+ if (RunChat)
+ {
+ ChatPollStreams();
+ ChatTrytoSend();
+
+ if (Slowtimer > 100) // 10 secs
+ {
+ ChatTimer();
+ }
+ }
+
+ if (RunMail)
+ {
+ PollStreams();
+
+ if ((Slowtimer % 20) == 0)
+ FWDTimerProc();
+
+ if (Slowtimer > 100) // 10 secs
+ {
+ struct tm * tm;
+
+ TCPTimer();
+ BBSSlowTimer();
+
+ if (MaintClock < NOW)
+ {
+ while (MaintClock < NOW) // in case large time step
+ MaintClock += MaintInterval * 3600;
+
+ Debugprintf("|Enter HouseKeeping");
+ DoHouseKeeping(FALSE);
+ }
+
+ if (APIClock < NOW)
+ {
+ SendBBSDataToPktMap();
+ APIClock = NOW + 7200; // Every 2 hours
+ }
+
+
+ tm = gmtime(&NOW);
+
+ if (tm->tm_wday == 0) // Sunday
+ {
+ if (GenerateTrafficReport && (LastTrafficTime + 86400) < NOW)
+ {
+ CreateBBSTrafficReport();
+ LastTrafficTime = NOW;
+ }
+ }
+ }
+
+ TCPFastTimer();
+ TrytoSend();
+ }
+ if (Slowtimer > 100)
+ Slowtimer = 0;
+}
+
+#ifdef WIN32
+
+#include "DbgHelp.h"
+
+HANDLE process;
+
+
+
+
+int inErrorhandling = 0;
+
+LONG WINAPI UnhandledExcepFilter(PEXCEPTION_POINTERS pExcepPointers)
+{
+ DWORD dwDisplacement;
+ IMAGEHLP_LINE64 line;
+ char * fptr;
+
+
+ time_t T;
+ struct tm * tm;
+
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
+ PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
+
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ symbol->MaxNameLen = MAX_SYM_NAME;
+
+
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ if (inErrorhandling)
+ {
+ MessageBox(NULL,"Program Error in error handler - program closing. See Debug Log for details","BPQ32",MB_ICONSTOP);
+
+ exit(0);
+ }
+
+ inErrorhandling = 1;
+
+ if(pExcepPointers->ExceptionRecord->ExceptionCode == DBG_PRINTEXCEPTION_C)
+ return EXCEPTION_CONTINUE_EXECUTION;
+
+ SymFromAddr( process, ((DWORD)pExcepPointers->ExceptionRecord->ExceptionAddress), 0, symbol );
+
+ Debugprintf("\r\n\r\nProgram error trapped at %02d:%02d:%02d\r\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ SymGetLineFromAddr64(process, (DWORD)pExcepPointers->ExceptionRecord->ExceptionAddress, &dwDisplacement, &line);
+
+ if (line.FileName)
+ {
+ fptr = line.FileName + (int)strlen(line.FileName); // remove path
+ while (*fptr != '\\' && *fptr != '/')
+ fptr--;
+
+ fptr++;
+
+ Debugprintf("In Procedure %s - %s Line %d Addr %p\r\n", symbol->Name, fptr, line.LineNumber, symbol->Address );
+ }
+
+ printStack();
+
+ CloseDebugLog();
+ MessageBox(NULL,"Program Error - program closing. See Debug Log for details","BPQ32",MB_ICONSTOP);
+
+ exit(0);
+}
+
+
+#endif
int main(int argc, char * argv[])
{
@@ -838,8 +1252,18 @@ int main(int argc, char * argv[])
}
}
+ process = GetCurrentProcess();
+
+ SymSetOptions(SYMOPT_LOAD_LINES);
+ SymInitialize(process, NULL, TRUE );
+
+ AddVectoredExceptionHandler(1, UnhandledExcepFilter);
+
+
#else
+ state = backtrace_create_state(argv[0], 0, error_callback, NULL);
+
signal(SIGSEGV, segvhandler);
signal(SIGABRT, abrthandler);
@@ -866,7 +1290,8 @@ int main(int argc, char * argv[])
printf("%d", sizeof(struct DEST_LIST));
- srand(time(NULL));
+ NOW = time(NULL);
+ srand(NOW);
// look for optarg format parameters
@@ -1432,270 +1857,25 @@ int main(int argc, char * argv[])
while (KEEPGOING)
{
- Sleep(100);
- GetSemaphore(&Semaphore, 2);
-
- if (QCOUNT < 10)
- {
- if (CLOSING == FALSE)
- FindLostBuffers();
- CLOSING = TRUE;
- }
-
- if (CLOSING)
- {
- if (RunChat)
- {
- CloseChat();
- RunChat = FALSE;
- }
-
- if (RunMail)
- {
- int BPQStream, n;
-
- RunMail = FALSE;
+ Sleep(10);
- for (n = 0; n < NumberofStreams; n++)
- {
- BPQStream = Connections[n].BPQStream;
-
- if (BPQStream)
- {
- SetAppl(BPQStream, 0, 0);
- Disconnect(BPQStream);
- DeallocateStream(BPQStream);
- }
- }
-
-// SaveUserDatabase();
- SaveMessageDatabase();
- SaveBIDDatabase();
- SaveConfig(ConfigName);
- SaveRestartData();
- }
-
- KEEPGOING--; // Give time for links to close
- setbuf(stdout, NULL);
- printf("Closing... %d \r", KEEPGOING);
- }
-
-
- if (RigReconfigFlag)
- {
- RigReconfigFlag = FALSE;
- Rig_Close();
- Sleep(2000); // Allow CATPTT threads to close
- RigActive = Rig_Init();
-
- Consoleprintf("Rigcontrol Reconfiguration Complete");
- }
+ NOW = time(NULL);
- if (APRSReconfigFlag)
- {
- APRSReconfigFlag = FALSE;
- APRSClose();
- APRSActive = Init_APRS();
-
- Consoleprintf("APRS Reconfiguration Complete");
- }
+ GetSemaphore(&Semaphore, 2);
- if (ReconfigFlag)
+ if (TIMERINTERRUPT()) // Run background code
{
- int i;
- BPQVECSTRUC * HOSTVEC;
- PEXTPORTDATA PORTVEC=(PEXTPORTDATA)PORTTABLE;
-
- ReconfigFlag = FALSE;
-
-// SetupBPQDirectory();
-
- WritetoConsoleLocal("Reconfiguring ...\n\n");
- OutputDebugString("BPQ32 Reconfiguring ...\n");
-
-
- for (i=0;i<NUMBEROFPORTS;i++)
- {
- if (PORTVEC->PORTCONTROL.PORTTYPE == 0x10) // External
- {
- if (PORTVEC->PORT_EXT_ADDR)
- {
-// SaveWindowPos(PORTVEC->PORTCONTROL.PORTNUMBER);
-// SaveAXIPWindowPos(PORTVEC->PORTCONTROL.PORTNUMBER);
-// CloseDriverWindow(PORTVEC->PORTCONTROL.PORTNUMBER);
- PORTVEC->PORT_EXT_ADDR(5,PORTVEC->PORTCONTROL.PORTNUMBER, NULL); // Close External Ports
- }
- }
- PORTVEC->PORTCONTROL.PORTCLOSECODE(&PORTVEC->PORTCONTROL);
- PORTVEC=(PEXTPORTDATA)PORTVEC->PORTCONTROL.PORTPOINTER;
- }
-
- IPClose();
- APRSClose();
- Rig_Close();
- CloseTNCEmulator();
-
- if (AGWActive)
- AGWAPITerminate();
-
- WL2KReports = NULL;
-
-// Sleep(2000);
-
- Consoleprintf("G8BPQ AX25 Packet Switch System Version %s %s", TextVerstring, Datestring);
- Consoleprintf(VerCopyright);
-
- Start();
-
- NETROMTCPResolve();
-
- INITIALISEPORTS();
-
- SetApplPorts();
-
- GetUIConfig();
-
- FreeConfig();
-
- for (i=1; i<68; i++) // Include Telnet, APRS, IP Vec
- {
- HOSTVEC=&BPQHOSTVECTOR[i-1];
-
- HOSTVEC->HOSTTRACEQ=0;
-
- if (HOSTVEC->HOSTSESSION !=0)
- {
- // Had a connection
-
- HOSTVEC->HOSTSESSION=0;
- HOSTVEC->HOSTFLAGS |=3; // Disconnected
-
-// PostMessage(HOSTVEC->HOSTHANDLE, BPQMsg, i, 4);
- }
- }
-
- OpenReportingSockets();
-
- WritetoConsoleLocal("\n\nReconfiguration Complete\n");
-
- if (IPRequired) IPActive = Init_IP();
-
- APRSActive = Init_APRS();
-
- if (ISPort == 0)
- IGateEnabled = 0;
-
- RigActive = Rig_Init();
-
- if (NUMBEROFTNCPORTS)
- {
- FreeSemaphore(&Semaphore);
- InitializeTNCEmulator();
- GetSemaphore(&Semaphore, 2);
- }
+ // 100mS has elapsed
+ Semaphored100msCode();
+ Slowtimer++;
+
FreeSemaphore(&Semaphore);
- AGWActive = AGWAPIInit();
- GetSemaphore(&Semaphore, 2);
-
- OutputDebugString("BPQ32 Reconfiguration Complete\n");
- }
-
- if (IPActive) Poll_IP();
- if (RigActive) Rig_Poll();
- if (APRSActive) Poll_APRS();
- CheckWL2KReportTimer();
-
- TIMERINTERRUPT();
-
- FreeSemaphore(&Semaphore);
-
- if (Redirected == 0)
- ConTermPoll();
-
- if (NUMBEROFTNCPORTS)
- TNCTimer();
-
- if (AGWActive)
- Poll_AGW();
-
- DRATSPoll();
- RHPPoll();
-
- HTTPTimer();
-
- if (ReportTimer)
- {
- ReportTimer--;
-
- if (ReportTimer == 0)
- {
- ReportTimer = REPORTINTERVAL;
- SendLocation();
- }
- }
-
- Slowtimer++;
-
- if (RunChat)
- {
- ChatPollStreams();
- ChatTrytoSend();
-
- if (Slowtimer > 100) // 10 secs
- {
- ChatTimer();
- }
- }
-
- if (RunMail)
- {
- PollStreams();
-
- if ((Slowtimer % 20) == 0)
- FWDTimerProc();
-
- if (Slowtimer > 100) // 10 secs
- {
- time_t NOW = time(NULL);
- struct tm * tm;
-
- TCPTimer();
- BBSSlowTimer();
- if (MaintClock < NOW)
- {
- while (MaintClock < NOW) // in case large time step
- MaintClock += MaintInterval * 3600;
-
- Debugprintf("|Enter HouseKeeping");
- DoHouseKeeping(FALSE);
- }
-
- if (APIClock < NOW)
- {
- SendBBSDataToPktMap();
- APIClock = NOW + 7200; // Every 2 hours
- }
-
-
- tm = gmtime(&NOW);
-
- if (tm->tm_wday == 0) // Sunday
- {
- if (GenerateTrafficReport && (LastTrafficTime + 86400) < NOW)
- {
- CreateBBSTrafficReport();
- LastTrafficTime = NOW;
- }
- }
- }
- TCPFastTimer();
- TrytoSend();
+ UnSemaphored100msCode();
}
-
- if (Slowtimer > 100)
- Slowtimer = 0;
+ else
+ FreeSemaphore(&Semaphore);
}
hookNodeClosing("Shutdown");
diff --git a/MULTIPSK.c b/MULTIPSK.c
index 59e389f..236b81f 100644
--- a/MULTIPSK.c
+++ b/MULTIPSK.c
@@ -195,7 +195,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
switch (fn)
{
- case 1: // poll
+ case 7: // poll
if (MasterPort[port] == port)
{
@@ -204,7 +204,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
{
// See if time to reconnect
-
+
time( &ltime );
if (ltime-lasttime[port] >9 )
{
@@ -212,12 +212,12 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
lasttime[port]=ltime;
}
}
-
+
FD_ZERO(&readfs);
-
+
if (TNC->CONNECTED) FD_SET(TNC->TCPSock,&readfs);
-
+
FD_ZERO(&writefs);
if (TNC->CONNECTING) FD_SET(TNC->TCPSock,&writefs); // Need notification of Connect
@@ -227,7 +227,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
FD_ZERO(&errorfs);
-
+
if (TNC->CONNECTING ||TNC->CONNECTED) FD_SET(TNC->TCPSock,&errorfs);
if (select((int)TNC->TCPSock+ 1, &readfs, &writefs, &errorfs, &timeout) > 0)
@@ -237,7 +237,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (FD_ISSET(TNC->TCPSock,&readfs))
{
// data available
-
+
ProcessReceivedData(port);
}
@@ -249,47 +249,55 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->CONNECTING = FALSE;
// If required, send signon
-
+
send(TNC->TCPSock,"\x1a", 1, 0);
send(TNC->TCPSock,"DIGITAL MODE ?", 14, 0);
send(TNC->TCPSock,"\x1b", 1, 0);
-// EnumWindows(EnumTNCWindowsProc, (LPARAM)TNC);
+ // EnumWindows(EnumTNCWindowsProc, (LPARAM)TNC);
}
-
+
if (FD_ISSET(TNC->TCPSock,&errorfs))
{
// if connecting, then failed, if connected then has just disconnected
-// if (CONNECTED[port])
-// if (!CONNECTING[port])
-// {
-// i=sprintf(ErrMsg, "MPSK Connection lost for BPQ Port %d\r\n", port);
-// WritetoConsole(ErrMsg);
-// }
+ // if (CONNECTED[port])
+ // if (!CONNECTING[port])
+ // {
+ // i=sprintf(ErrMsg, "MPSK Connection lost for BPQ Port %d\r\n", port);
+ // WritetoConsole(ErrMsg);
+ // }
CONNECTING[port]=FALSE;
CONNECTED[port]=FALSE;
-
+
}
}
}
- // See if any frames for this port
for (Stream = 0; Stream <= TNC->MPSKInfo->MaxSessions; Stream++)
{
STREAM = &TNC->Streams[Stream];
- // Have to time out connects, as TNC doesn't report failure
+ if (STREAM->PACTORtoBPQ_Q == 0)
+ {
+ if (STREAM->DiscWhenAllSent)
+ {
+ STREAM->DiscWhenAllSent--;
+ if (STREAM->DiscWhenAllSent == 0)
+ STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
+ }
+ }
+ // Have to time out connects, as TNC doesn't report failure
if (STREAM->Connecting)
{
STREAM->Connecting--;
-
+
if (STREAM->Connecting == 0)
{
// Report Connect Failed, and drop back to command mode
@@ -301,7 +309,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
buffptr->Len = sprintf(buffptr->Data, "MPSK} Failure with %s\r", STREAM->RemoteCall);
C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
}
-
+
STREAM->Connected = FALSE; // Back to Command Mode
STREAM->DiscWhenAllSent = 10;
@@ -310,9 +318,18 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TidyClose(TNC, Stream);
}
}
-
+
if (STREAM->Attached)
CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+ }
+
+ return 0;
+
+ case 1:
+
+ for (Stream = 0; Stream <= TNC->MPSKInfo->MaxSessions; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
if (STREAM->ReportDISC)
{
@@ -322,21 +339,10 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
return -1;
}
- // if Busy, send buffer status poll
-
- if (STREAM->PACTORtoBPQ_Q == 0)
- {
- if (STREAM->DiscWhenAllSent)
- {
- STREAM->DiscWhenAllSent--;
- if (STREAM->DiscWhenAllSent == 0)
- STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
- }
- }
- else
+ if (STREAM->PACTORtoBPQ_Q)
{
int datalen;
-
+
buffptr = Q_REM(&STREAM->PACTORtoBPQ_Q);
datalen = (int)buffptr->Len;
@@ -348,7 +354,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
PutLengthinBuffer(buff, datalen);
ReleaseBuffer(buffptr);
-
+
return (1);
}
}
@@ -361,15 +367,13 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
buffptr = Q_REM(&TNC->PortRecord->UI_Q);
Sock = TNCInfo[MasterPort[port]]->TCPSock;
-
+
ReleaseBuffer((UINT *)buffptr);
}
-
-
+
return (0);
-
case 2: // send
@@ -503,7 +507,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (buffptr)
{
buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0],
- "MPSK} Error - Call missing from C command\r", STREAM->MyCall, STREAM->RemoteCall);
+ "MPSK} Error - Call missing from C command\r");
C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
}
@@ -940,7 +944,7 @@ VOID ConnecttoMPSKThread(void * portptr)
err=WSAGetLastError();
i=sprintf(Msg, "Connect Failed for MPSK socket - error code = %d\n", err);
WritetoConsole(Msg);
- MySetWindowText(TNC->xIDC_COMMSSTATE, "Connection to TNC failed");
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, "Connection to TNC failed");
TNC->Alerted = TRUE;
}
@@ -951,7 +955,7 @@ VOID ConnecttoMPSKThread(void * portptr)
TNC->LastFreq = 0; // so V4 display will be updated
- MySetWindowText(TNC->xIDC_COMMSSTATE, "Connected to MPSK TNC");
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, "Connected to MPSK TNC");
return;
@@ -1387,7 +1391,7 @@ DataLoop:
STREAM->Connected = TRUE;
STREAM->Connecting = FALSE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = 0;
buffptr = GetBuff();
@@ -1402,7 +1406,7 @@ DataLoop:
// Incoming. Look for a free Stream
STREAM->Connected = TRUE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = 0;
UpdateMH(TNC, CallFrom, '+', 'I');
diff --git a/MailTCP.c b/MailTCP.c
index 37c7cf9..15a84c8 100644
--- a/MailTCP.c
+++ b/MailTCP.c
@@ -161,6 +161,7 @@ VOID __cdecl sockprintf(SocketConn * sockptr, const char * format, ...)
va_start(arglist, format);
vsprintf(buff, format, arglist);
+ va_end(arglist);
SendSock(sockptr, buff);
}
@@ -1430,7 +1431,7 @@ VOID ProcessSMTPServerMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->Flags == GETTINGMESSAGE)
{
- if(memcmp(Buffer, ".\r\n", 3) == 0)
+ if (_memicmp(Buffer, ".\r\n", 3) == 0)
{
char * ptr1, * ptr2;
int linelen, MsgLen;
@@ -1781,14 +1782,14 @@ ZvVx9G1hcg==
*/
- if(memcmp(Buffer, "AUTH LOGIN", 10) == 0)
+ if (_memicmp(Buffer, "AUTH LOGIN", 10) == 0)
{
sockptr->State = GettingUser;
SendSock(sockptr, "334 VXNlcm5hbWU6");
return;
}
- if(memcmp(Buffer, "EHLO",4) == 0)
+ if (_memicmp(Buffer, "EHLO",4) == 0)
{
SendSock(sockptr, "250-BPQ Mail Server");
SendSock(sockptr, "250 AUTH LOGIN");
@@ -1798,7 +1799,7 @@ ZvVx9G1hcg==
return;
}
- if(memcmp(Buffer, "AUTH LOGIN", 10) == 0)
+ if (_memicmp(Buffer, "AUTH LOGIN", 10) == 0)
{
sockptr->State = GettingUser;
SendSock(sockptr, "334 VXNlcm5hbWU6");
@@ -1806,7 +1807,7 @@ ZvVx9G1hcg==
}
- if(memcmp(Buffer, "HELO",4) == 0)
+ if (_memicmp(Buffer, "HELO",4) == 0)
{
SendSock(sockptr, "250 Ok");
return;
@@ -1865,7 +1866,7 @@ ZvVx9G1hcg==
return;
}
- if(memcmp(Buffer, "DATA\r\n", 6) == 0)
+ if (_memicmp(Buffer, "DATA\r\n", 6) == 0)
{
sockptr->MailBuffer=malloc(10000);
sockptr->MailBufferSize=10000;
@@ -1885,7 +1886,7 @@ ZvVx9G1hcg==
return;
}
- if(memcmp(Buffer, "QUIT\r\n", 6) == 0)
+ if (_memicmp(Buffer, "QUIT\r\n", 6) == 0)
{
SendSock(sockptr, "221 OK");
Sleep(500);
@@ -1893,7 +1894,7 @@ ZvVx9G1hcg==
return;
}
- if(memcmp(Buffer, "RSET\r\n", 6) == 0)
+ if (_memicmp(Buffer, "RSET\r\n", 6) == 0)
{
SendSock(sockptr, "250 Ok");
@@ -2070,7 +2071,7 @@ int CreateSMTPMessage(SocketConn * sockptr, int i, char * MsgTitle, time_t Date,
// If NTS message (TO is numeric and AT is NTSxx or NTSxx.NTS - Outlook won't accept x@y)
- if (isdigits(Msg->to) && memcmp(Msg->via, "NTS", 3) == 0)
+ if (isdigits(Msg->to) && _memicmp(Msg->via, "NTS", 3) == 0)
{
if (Msg->via[5] == 0 || strcmp(&Msg->via[5], ".NTS") == 0)
{
@@ -2320,7 +2321,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
WriteLogLine(NULL, '<',Buffer, Len-2, LOG_TCP);
- if(memcmp(Buffer, "CAPA",4) == 0)
+ if (_memicmp(Buffer, "CAPA",4) == 0)
{
SendSock(sockptr, "+OK Capability list follows");
SendSock(sockptr, "UIDL");
@@ -2330,7 +2331,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if(memcmp(Buffer, "AUTH",4) == 0)
+ if (_memicmp(Buffer, "AUTH",4) == 0)
{
SendSock(sockptr, "-ERR");
return;
@@ -2398,7 +2399,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if (memcmp(Buffer, "QUIT",4) == 0)
+ if (_memicmp(Buffer, "QUIT",4) == 0)
{
SendSock(sockptr, "+OK Finished");
@@ -2408,13 +2409,13 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if (memcmp(Buffer, "NOOP",4) == 0)
+ if (_memicmp(Buffer, "NOOP",4) == 0)
{
SendSock(sockptr, "+OK ");
return;
}
-// if (memcmp(Buffer, "LAST",4) == 0)
+// if (_memicmp(Buffer, "LAST",4) == 0)
// {
// SendSock(sockptr, "+OK 0");
// return;
@@ -2427,7 +2428,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if (memcmp(Buffer, "STAT",4) == 0)
+ if (_memicmp(Buffer, "STAT",4) == 0)
{
char reply[40];
int i, size=0;
@@ -2443,7 +2444,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if (memcmp(Buffer, "UIDL",4) == 0)
+ if (_memicmp(Buffer, "UIDL",4) == 0)
{
char reply[40];
int i, count=0, size=0;
@@ -2461,7 +2462,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if (memcmp(Buffer, "LIST", 4) == 0)
+ if (_memicmp(Buffer, "LIST", 4) == 0)
{
char reply[40];
int i, count=0, size=0;
@@ -2495,7 +2496,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
- if (memcmp(Buffer, "RETR", 4) == 0 || memcmp(Buffer, "TOP", 3) == 0)
+ if (_memicmp(Buffer, "RETR", 4) == 0 || memcmp(Buffer, "TOP", 3) == 0)
{
char * ptr;
char Header[120];
@@ -2509,7 +2510,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
BOOL TOP = FALSE;
int Len;
- if (memcmp(Buffer, "TOP", 3) == 0)
+ if (_memicmp(Buffer, "TOP", 3) == 0)
TOP = TRUE;
ptr=strlop(Buffer, ' '); // Get Number
@@ -2694,7 +2695,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
}
- if (memcmp(Buffer, "DELE",4) == 0)
+ if (_memicmp(Buffer, "DELE",4) == 0)
{
char * ptr;
int i;
@@ -2719,7 +2720,7 @@ VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len)
}
- if (memcmp(Buffer, "QUIT",4) == 0)
+ if (_memicmp(Buffer, "QUIT",4) == 0)
{
SendSock(sockptr, "+OK Finished");
@@ -2961,7 +2962,7 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForGreeting)
{
- if (memcmp(Buffer, "220 ",4) == 0)
+ if (_memicmp(Buffer, "220 ",4) == 0)
{
TryHELO = 0;
@@ -2986,7 +2987,7 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForHELOResponse)
{
/*
- if (memcmp(Buffer, "500 ",4) == 0 && TryHELO == 0)
+ if (_memicmp(Buffer, "500 ",4) == 0 && TryHELO == 0)
{
TryHELO = 1;
@@ -3000,10 +3001,10 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
return;
}
*/
- if (memcmp(Buffer, "250-",4) == 0)
+ if (_memicmp(Buffer, "250-",4) == 0)
return;
- if (memcmp(Buffer, "250 ",4) == 0)
+ if (_memicmp(Buffer, "250 ",4) == 0)
{
if (SMTPAuthNeeded && sockptr->AMPR == FALSE)
{
@@ -3029,21 +3030,21 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForAUTHResponse)
{
- if (memcmp(Buffer, "334 VXN", 7) == 0)
+ if (_memicmp(Buffer, "334 VXN", 7) == 0)
{
char * Msg = str_base64_encode(ISPAccountName);
SendSock(sockptr, Msg);
free(Msg);
return;
}
- else if (memcmp(Buffer, "334 UGF", 7) == 0)
+ else if (_memicmp(Buffer, "334 UGF", 7) == 0)
{
char * Msg = str_base64_encode(ISPAccountPass);
SendSock(sockptr, Msg);
free(Msg);
return;
}
- else if (memcmp(Buffer, "235 ", 4) == 0)
+ else if (_memicmp(Buffer, "235 ", 4) == 0)
{
sockprintf(sockptr, "MAIL FROM: <%s@%s>", sockptr->SMTPMsg->from, sockptr->FromDomain);
// sockprintf(sockptr, "MAIL FROM: <%s@%s.%s>", sockptr->SMTPMsg->from, BBSName, HRoute);
@@ -3064,7 +3065,7 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForFROMResponse)
{
- if (memcmp(Buffer, "250 ",4) == 0)
+ if (_memicmp(Buffer, "250 ",4) == 0)
{
sockprintf(sockptr, "RCPT TO: <%s>", sockptr->SMTPMsg->via);
sockptr->State = WaitingForTOResponse;
@@ -3082,7 +3083,7 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForTOResponse)
{
- if (memcmp(Buffer, "250 ",4) == 0)
+ if (_memicmp(Buffer, "250 ",4) == 0)
{
SendSock(sockptr, "DATA");
sockptr->State = WaitingForDATAResponse;
@@ -3103,13 +3104,13 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
int Len;
UCHAR * UTF;
- if (memcmp(Buffer, "354 ",4) == 0)
+ if (_memicmp(Buffer, "354 ",4) == 0)
{
sockprintf(sockptr, "To: %s", sockptr->SMTPMsg->via);
sockprintf(sockptr, "From: %s <%s@%s>", sockptr->SMTPMsg->from, sockptr->SMTPMsg->from, sockptr->FromDomain);
sockprintf(sockptr, "Sender: %s@%s", sockptr->SMTPMsg->from, sockptr->FromDomain);
if (GMailMode && sockptr->AMPR == FALSE)
- sockprintf(sockptr, "Reply-To: %s+%s@%s", GMailName, sockptr->SMTPMsg->from, sockptr->FromDomain);
+ sockprintf(sockptr, "Reply-To: %s+%s@gmail.com", GMailName, sockptr->SMTPMsg->from);
else
sockprintf(sockptr, "Reply-To: %s@%s", sockptr->SMTPMsg->from, sockptr->FromDomain);
@@ -3186,7 +3187,7 @@ VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len)
{
struct MsgInfo * Msg = sockptr->SMTPMsg;
- if (memcmp(Buffer, "250 ", 4) == 0)
+ if (_memicmp(Buffer, "250 ", 4) == 0)
{
// if AMPR, clear forwarding bitmap
@@ -3452,7 +3453,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->Flags == GETTINGMESSAGE)
{
- if(memcmp(Buffer, ".\r\n", 3) == 0)
+ if (_memicmp(Buffer, ".\r\n", 3) == 0)
{
// File Message
@@ -3624,7 +3625,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForGreeting)
{
- if (memcmp(Buffer, "+OK", 3) == 0)
+ if (_memicmp(Buffer, "+OK", 3) == 0)
{
sockprintf(sockptr, "USER %s", ISPAccountName);
sockptr->State = WaitingForUSERResponse;
@@ -3640,7 +3641,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForUSERResponse)
{
- if (memcmp(Buffer, "+OK", 3) == 0)
+ if (_memicmp(Buffer, "+OK", 3) == 0)
{
sockprintf(sockptr, "PASS %s", ISPAccountPass);
sockptr->State = WaitingForPASSResponse;
@@ -3656,7 +3657,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForPASSResponse)
{
- if (memcmp(Buffer, "+OK", 3) == 0)
+ if (_memicmp(Buffer, "+OK", 3) == 0)
{
SendSock(sockptr, "STAT");
sockptr->State = WaitingForSTATResponse;
@@ -3672,7 +3673,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForSTATResponse)
{
- if (memcmp(Buffer, "+OK", 3) == 0)
+ if (_memicmp(Buffer, "+OK", 3) == 0)
{
int Msgs = atoi(&Buffer[3]);
@@ -3702,7 +3703,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->State == WaitingForRETRResponse)
{
- if (memcmp(Buffer, "+OK", 3) == 0)
+ if (_memicmp(Buffer, "+OK", 3) == 0)
{
sockptr->MailBuffer=malloc(10000);
sockptr->MailBufferSize=10000;
@@ -3730,7 +3731,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
}
if (sockptr->State == WaitingForDELEResponse)
{
- if (memcmp(Buffer, "+OK", 3) == 0)
+ if (_memicmp(Buffer, "+OK", 3) == 0)
{
if (sockptr->POP3MsgCount > sockptr->POP3MsgNum++)
{
diff --git a/Moncode.c b/Moncode.c
index 7e50701..b967615 100644
--- a/Moncode.c
+++ b/Moncode.c
@@ -34,6 +34,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include "cheaders.h"
#include "tncinfo.h"
+extern char NCMPTypes[6][28];
+
// MSGFLAG contains CMD/RESPONSE BITS
#define CMDBIT 4 // CURRENT MESSAGE IS A COMMAND
@@ -869,7 +871,7 @@ char * DISPLAY_NETROM(MESSAGE * ADJBUFFER, UCHAR * Output, int MsgLen)
if (Index == 0x0F) // NCMP
{
- Output += sprintf((char *)Output, " NCMP %x %x Type %x Code %x", Index, ID, TXNO, RXNO);
+ Output += sprintf((char *)Output, " NCMP Type %s Code %x", NCMPTypes[TXNO & 15], RXNO);
MsgLen = MsgLen - (19 + sizeof(void *));
@@ -1057,7 +1059,7 @@ void WritePacketLogThread(void * param)
// Open log file and write decoded packets
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
if (LogDirectory[0] == 0)
diff --git a/NETROMTCP.c b/NETROMTCP.c
index 47f5b57..d6e03e4 100644
--- a/NETROMTCP.c
+++ b/NETROMTCP.c
@@ -66,8 +66,8 @@ extern SOCKET NodeAPISocket;
struct NRTCPMsg
{
- short Length;
- char Call[10];
+ short Length; // Including header
+ char Call[10]; // of sending Node
unsigned char PID;
char Packet[1024];
};
@@ -109,7 +109,7 @@ struct ConnectionInfo * AllocateNRTCPRec()
if (sockptr->SocketActive == FALSE)
{
sockptr->SocketActive = TRUE;
- sockptr->ConnectTime = sockptr->LastSendTime = time(NULL);
+ sockptr->ConnectTime = sockptr->LastSendTime = NOW;
Debugprintf("NRTCP Allocated %d", i);
return sockptr;
@@ -125,7 +125,7 @@ void checkNRTCPSockets(int portNo)
SOCKET maxsock;
int retval;
int i;
- time_t Now = time(NULL);
+ time_t Now = NOW;
struct timeval timeout;
fd_set readfd, writefd, exceptfd;
@@ -345,7 +345,7 @@ int NETROMTCPConnect(struct ROUTE * Route, struct ConnectionInfo * sockptr)
//
sockptr->Connected = TRUE;
- sockptr->LastReceiveTime = time(NULL);
+ sockptr->LastReceiveTime = NOW;
return TRUE;
}
else
@@ -397,7 +397,7 @@ void NETROMConnectionAccepted(struct ConnectionInfo * sockptr)
Debugprintf("INP3 Accept() Local port %d", htons(sockptr->sin.sin_port));
sockptr->Connected = TRUE;
- sockptr->LastReceiveTime = time(NULL);
+ sockptr->LastReceiveTime = NOW;
// Debugprintf("NRTCP Connection Accepted");
}
@@ -411,7 +411,7 @@ void NETROMConnected(struct ConnectionInfo * sockptr, SOCKET sock, struct NRTCPS
sockptr->Connecting = FALSE;
sockptr->Connected = TRUE;
- sockptr->LastReceiveTime = time(NULL);
+ sockptr->LastReceiveTime = NOW;
Info->LINK->L2STATE = 5;
@@ -444,7 +444,7 @@ int DataSocket_ReadNETROM(struct ConnectionInfo * sockptr, SOCKET sock, struct N
return 0;
}
- sockptr->LastReceiveTime = time(NULL);
+ sockptr->LastReceiveTime = NOW;
sockptr->InputLen += len;
diff --git a/NNTPRoutines.c b/NNTPRoutines.c
index 1ceea42..87ba8f9 100644
--- a/NNTPRoutines.c
+++ b/NNTPRoutines.c
@@ -122,6 +122,7 @@ VOID __cdecl NNTPsockprintf(SocketConn * sockptr, const char * format, ...)
va_start(arglist, format);
vsprintf(buff, format, arglist);
+ va_end(arglist);
NNTPSendSock(sockptr, buff);
}
diff --git a/NodeMapTest.c b/NodeMapTest.c
index 7b0b735..26fb86f 100644
--- a/NodeMapTest.c
+++ b/NodeMapTest.c
@@ -965,7 +965,7 @@ int main(int argc, char * argv[])
restartTime = time(NULL) + 120; // Restart in 2 mins
}
- HostEnt2 = gethostbyname ("10.8.0.38");
+ HostEnt2 = gethostbyname ("192.168.193.142");
if (HostEnt2)
memcpy(&txaddr2.sin_addr.s_addr,HostEnt2->h_addr,4);
@@ -1043,6 +1043,8 @@ int main(int argc, char * argv[])
continue;
ret = sendto(sock, RXBUFFER, nLength, 0, (struct sockaddr *)&txaddr, sizeof(txaddr));
+
+// ret = sendto(sock, RXBUFFER, nLength, 0, (struct sockaddr *)&txaddr2, sizeof(txaddr2));
if (ret == -1)
perror("sendto 1");
@@ -1709,16 +1711,18 @@ void GenerateOutputFiles(time_t Now)
// We need unheard nodes in the file for the MH list. Display on main map in blue
- if (Age < 3600)
+ if (Age < 3600 * 6)
Colour = 'G';
else if (Age < 86400)
+ Colour ='Y';
+ else if (Age < 2 * 86400)
Colour ='R';
else
{
if (Node->Lat != 0.0 && Node->Lon != 0.0 && Node->LastHeard == 0)
Colour = 'B';
else
- Colour ='0';
+ continue; //Colour ='0';
}
HeardString[0] = 0;
diff --git a/PG/keps.c b/PG/keps.c
new file mode 100644
index 0000000..0d3f05b
--- /dev/null
+++ b/PG/keps.c
@@ -0,0 +1,493 @@
+/*
+ * SATPG.C
+ *
+ * Compile:
+ * gcc satpg.c -o satpg -lm
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define _USE_MATH_DEFINES
+#include <math.h>
+#include <time.h>
+
+#define MAXSATS 256
+#define MAXNAME 64
+
+#define KEPFILE "d:\keps.txt"
+
+typedef struct
+{
+ char name[MAXNAME];
+ char l1[128];
+ char l2[128];
+
+ double inc;
+ double mm;
+
+} SAT;
+
+SAT sats[MAXSATS];
+int satcount = 0;
+
+/* ------------------------------------------------ */
+
+void trim(char *s)
+{
+ int l = strlen(s);
+
+ while(l > 0 &&
+ (s[l-1] == '\n' || s[l-1] == '\r'))
+ {
+ s[l-1] = 0;
+ l--;
+ }
+}
+
+/* ------------------------------------------------ */
+void load_tles(void)
+{
+ FILE *fp;
+ char name[256];
+ char l1[256];
+ char l2[256];
+
+ int i;
+ int dup;
+
+ fp = fopen(KEPFILE, "r");
+
+ if(!fp)
+ {
+ printf("Cannot open %s\n", KEPFILE);
+ exit(127);
+ return;
+ }
+
+ while(fgets(name, sizeof(name), fp))
+ {
+ trim(name);
+
+ /*
+ * Skip blank lines
+ */
+
+ if(strlen(name) < 1)
+ continue;
+
+ /*
+ * Ignore lines beginning with:
+ * 1
+ * 2
+ * #
+ */
+
+ if(name[0] == '1' ||
+ name[0] == '2' ||
+ name[0] == '#')
+ continue;
+
+ /*
+ * Try reading TLE pair
+ */
+
+ if(!fgets(l1, sizeof(l1), fp))
+ break;
+
+ if(!fgets(l2, sizeof(l2), fp))
+ break;
+
+ trim(l1);
+ trim(l2);
+
+ /*
+ * Validate TLE lines
+ */
+
+ if(strncmp(l1, "1 ", 2) != 0)
+ continue;
+
+ if(strncmp(l2, "2 ", 2) != 0)
+ continue;
+
+ /*
+ * Duplicate filter
+ */
+
+ dup = 0;
+
+ for(i=0;i<satcount;i++)
+ {
+ if(stricmp(name,
+ sats[i].name) == 0)
+ {
+ dup = 1;
+ break;
+ }
+ }
+
+ if(dup)
+ continue;
+
+ /*
+ * Store
+ */
+
+ strncpy(sats[satcount].name,
+ name,
+ MAXNAME-1);
+
+ strcpy(sats[satcount].l1, l1);
+ strcpy(sats[satcount].l2, l2);
+
+ sscanf(l2,
+ "2 %*d %lf %*f %*s %*f %*f %lf",
+ &sats[satcount].inc,
+ &sats[satcount].mm);
+
+ satcount++;
+
+ if(satcount >= MAXSATS)
+ break;
+ }
+
+ fclose(fp);
+}
+
+/* ------------------------------------------------ */
+
+char *az_to_text(double az)
+{
+ if(az < 22.5) return "N";
+ if(az < 67.5) return "NE";
+ if(az < 112.5) return "E";
+ if(az < 157.5) return "SE";
+ if(az < 202.5) return "S";
+ if(az < 247.5) return "SW";
+ if(az < 292.5) return "W";
+ if(az < 337.5) return "NW";
+
+ return "N";
+}
+
+#include <math.h>
+
+#define DEG2RAD (M_PI / 180.0)
+#define RAD2DEG (180.0 / M_PI)
+
+/*
+ * Observer location
+ * Mitcham UK example
+ */
+
+#define OBS_LAT 51.40
+#define OBS_LON -0.16
+
+/*
+ * Earth / GEO constants
+ */
+
+#define EARTH_RADIUS 6378.137
+#define GEO_RADIUS 42164.0
+
+/*
+ * Extract sub-satellite longitude
+ *
+ * For GEO satellites:
+ * longitude ≈ RAAN + Mean Anomaly
+ */
+
+double get_geo_longitude(SAT *s)
+{
+ double raan;
+ double mean_anom;
+ double lon;
+ /*
+ * TLE line 2 fields:
+ *
+ * 2 NNNNN INC RAAN ECC ARGP MA MM
+ */
+
+ sscanf(s->l2,
+ "2 %*d %*lf %lf %*s %*lf %lf",
+ &raan,
+ &mean_anom);
+
+ lon = raan + mean_anom;
+
+ while(lon > 180.0)
+ lon -= 360.0;
+
+ while(lon < -180.0)
+ lon += 360.0;
+
+ return lon;
+}
+
+/*
+ * Real GEO az/el calculation
+ */
+
+void fake_track(SAT *s,
+ double *az,
+ double *el,
+ double *rng)
+{
+ double sat_lon = get_geo_longitude(s);
+
+ double obs_lat = OBS_LAT * DEG2RAD;
+ double obs_lon = OBS_LON * DEG2RAD;
+
+ double sat_lon_rad = sat_lon * DEG2RAD;
+
+ /*
+ * GEO satellite position
+ */
+
+ double xs = GEO_RADIUS * cos(sat_lon_rad);
+ double ys = GEO_RADIUS * sin(sat_lon_rad);
+ double zs = 0.0;
+
+ /*
+ * Observer position
+ */
+
+ double xo = EARTH_RADIUS *
+ cos(obs_lat) *
+ cos(obs_lon);
+
+ double yo = EARTH_RADIUS *
+ cos(obs_lat) *
+ sin(obs_lon);
+
+ double zo = EARTH_RADIUS *
+ sin(obs_lat);
+
+ /*
+ * Vector observer -> satellite
+ */
+
+ double dx = xs - xo;
+ double dy = ys - yo;
+ double dz = zs - zo;
+
+ *rng = sqrt(dx*dx + dy*dy + dz*dz);
+
+ /*
+ * ENU conversion
+ */
+
+ double east =
+ -sin(obs_lon)*dx +
+ cos(obs_lon)*dy;
+
+ double north =
+ -sin(obs_lat)*cos(obs_lon)*dx
+ -sin(obs_lat)*sin(obs_lon)*dy
+ +cos(obs_lat)*dz;
+
+ double up =
+ cos(obs_lat)*cos(obs_lon)*dx
+ +cos(obs_lat)*sin(obs_lon)*dy
+ +sin(obs_lat)*dz;
+
+ *az = atan2(east, north) * RAD2DEG;
+
+ if(*az < 0)
+ *az += 360.0;
+
+ *el = atan2(up,
+ sqrt(east*east + north*north))
+ * RAD2DEG;
+}
+
+
+
+
+void draw_plot(double az, double el)
+{
+ char g[9][34];
+ int r,c;
+
+ int x,y;
+
+ for(r=0;r<9;r++)
+ {
+ for(c=0;c<33;c++)
+ g[r][c] = ' ';
+
+ g[r][33] = 0;
+ }
+
+ strcpy(g[0], " N");
+ strcpy(g[4], "W --------------+-------------- E");
+ strcpy(g[8], " S");
+
+ double radius = (90.0 - el) / 90.0;
+
+ double ang = (az - 90.0) * M_PI / 180.0;
+
+ x = 16 + (int)(radius * 12 * cos(ang));
+ y = 4 + (int)(radius * 4 * sin(ang));
+
+ if(x >=0 && x < 33 && y >=0 && y < 9)
+ g[y][x] = '*';
+
+ putchar('\r');
+ putchar('\n');
+
+ for(r=0;r<9;r++)
+ printf("%s\r\n", g[r]);
+
+ putchar('\r');
+ putchar('\n');
+}
+
+/* ------------------------------------------------ */
+
+void show_sat(SAT *s)
+{
+ double az,el,rng;
+
+ fake_track(s, &az, &el, &rng);
+
+ if(el > 0)
+ printf("%s GOOD\r\n", s->name);
+ else
+ printf("%s NOT VISIBLE\r\n", s->name);
+
+ printf("AZ %.0f (%s)\r\n",
+ az,
+ az_to_text(az));
+
+ if(el > 0)
+ printf("EL %.0f deg\r\n", el);
+ else
+ printf("EL BELOW HORIZON\r\n");
+
+ printf("RNG %.0f km\r\n", rng);
+
+ putchar('\r');
+ putchar('\n');
+
+
+ if(el > 0)
+ {
+ printf("Aim antenna: %s ",
+ az_to_text(az));
+
+ if(el < 15)
+ printf("low.\r\n");
+ else if(el < 45)
+ printf("mid sky.\r\n");
+ else
+ printf("high.\r\n");
+ }
+ else
+ {
+ printf("Satellite below horizon.\r\n");
+ }
+
+ draw_plot(az, el);
+
+ if(s->inc > 95 && s->inc < 100)
+ printf("Sun-synchronous polar LEO\r\n");
+
+ printf("%.2f orbits/day\r\n", s->mm);
+}
+
+/* ------------------------------------------------ */
+
+SAT *find_sat(char *s)
+{
+ int i;
+
+ for(i=0;i<satcount;i++)
+ {
+ if(stricmp(s, sats[i].name) == 0)
+ return &sats[i];
+
+ if(atoi(s) == (i+1))
+ return &sats[i];
+ }
+
+ return NULL;
+}
+
+/* ------------------------------------------------ */
+
+int main(int argc, char **argv)
+{
+ int level;
+ int i;
+
+ load_tles();
+
+ if(argc < 3)
+ {
+ printf("Bad PG invocation\r\n");
+ return 0;
+ }
+
+ level = atoi(argv[2]);
+
+ /*
+ * FIRST INVOCATION
+ */
+
+ if(level == 0)
+ {
+ printf("Satellite tracker\r\n");
+ printf("-----------------\r\n\r\n");
+
+ for(i=0;i<satcount;i++)
+ {
+ printf("%2d: %s\r\n",
+ i+1,
+ sats[i].name);
+ }
+
+ printf("\r\n");
+ printf("Enter sat number or name (0=Exit):\r\n");
+
+ return 1;
+ }
+
+ /*
+ * SECOND + INVOCATION
+ */
+
+ if(argc < 6)
+ {
+ printf("No satellite specified.\r\n");
+ return 0;
+ }
+
+
+ if(atoi(argv[5])==0 && strlen(argv[5])==1 )
+ {
+ printf("Bye!\r\n");
+ return 0;
+ }
+
+ SAT *s = find_sat(argv[5]);
+
+ if(!s)
+ {
+ printf("Satellite not found.\r\n");
+ printf("\r\nEnter sat number or name (0=Exit):\r\n");
+ return 1;
+ }
+
+ putchar('\r');
+ putchar('\n');
+
+
+ show_sat(s);
+
+ printf("\r\nEnter sat number or name (0=Exit):\r\n");
+
+ return 1;
+}
diff --git a/PG/keps.txt b/PG/keps.txt
new file mode 100644
index 0000000..ecfe3e9
--- /dev/null
+++ b/PG/keps.txt
@@ -0,0 +1,2284 @@
+SB KEPS @ AMSAT < KQ6UP $ORB26131.1
+2Line Orbital Elements 26131.AMSAT
+R:260511/1545Z 4252@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260511/1518Z 9170@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260511/1457Z @:GB7CIP.#32.GBR.EURO #:59446 [Caterham Surrey GBR] $:ORB26131.1
+R:260511/1453z @:N2NOV.#RICH.NY.USA.NOAM $:ORB26131.1
+R:260511/1439Z 6882@KQ6UP.#SCA.CA.USA.NOAM BPQ6.0.24
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA May 11, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26131.02828537 -.00000034 00000-0 74901-4 0 9994
+2 07530 101.9918 143.8856 0012125 200.3561 181.7211 12.53697443355861
+UO-11
+1 14781U 84021B 26131.16982026 .00000814 00000-0 88631-4 0 9996
+2 14781 97.8036 97.1668 0006433 315.7966 44.2738 14.90694568251611
+AO-27
+1 22825U 93061C 26131.14983863 .00000053 00000-0 37296-4 0 9992
+2 22825 98.6892 198.5733 0007951 201.7057 158.3790 14.30931926701709
+FO-29
+1 24278U 96046B 26131.19510852 -.00000039 00000-0 -39487-5 0 9992
+2 24278 98.5281 345.1264 0349635 192.2765 166.9689 13.53272291468160
+GO-32
+1 25397U 98043D 26130.97598956 .00000047 00000-0 40585-4 0 9997
+2 25397 99.0063 122.7983 0001113 16.9991 343.1224 14.24421003446035
+ISS
+1 25544U 98067A 26131.16675675 .00005444 00000-0 10622-3 0 9997
+2 25544 51.6310 123.3566 0007470 46.3627 313.7980 15.49181925566014
+NO-44
+1 26931U 01043C 26131.00137205 .00000080 00000-0 60839-4 0 9998
+2 26931 67.0514 340.4519 0006302 263.6567 96.3818 14.31941390285126
+SO-50
+1 27607U 02058C 26130.72927866 .00000748 00000-0 10595-3 0 9998
+2 27607 64.5524 244.8702 0075633 269.3097 89.9342 14.82966856258901
+CO-55
+1 27844U 03031E 26131.01616769 .00000204 00000-0 10731-3 0 9992
+2 27844 98.6748 140.0418 0008393 297.0013 63.0309 14.24312209186387
+RS-22
+1 27939U 03042A 26131.21083887 .00000216 00000-0 41663-4 0 9992
+2 27939 98.3476 314.5273 0011983 31.7180 78.9279 14.73399817210104
+CO-65
+1 32785U 08021C 26131.18755762 .00002730 00000-0 17633-3 0 9995
+2 32785 97.8261 111.8524 0009927 145.2461 214.9417 15.09096632979613
+CO-66
+1 32791U 08021J 26130.97235940 .00011027 00000-0 36525-3 0 9999
+2 32791 97.7530 127.1344 0005072 88.5832 271.5989 15.31474077981597
+RS-30
+1 32953U 08025A 26131.15903073 .00000054 00000-0 31835-3 0 9990
+2 32953 82.5069 18.4727 0020382 34.2439 325.9951 12.43178165815098
+SRMSAT
+1 37841U 11058D 26131.13066574 .00000368 00000-0 55753-4 0 9999
+2 37841 19.9728 283.7690 0011716 156.0441 18.8473 14.11567394752571
+ZACUBE-1
+1 39417U 13066B 26131.14341808 .00003157 00000-0 24836-3 0 9994
+2 39417 97.8120 93.2797 0042131 17.8518 342.4174 15.00898646675179
+Delfi-N3xt
+1 39428U 13066N 26131.02786888 .00004744 00000-0 41984-3 0 9990
+2 39428 97.8338 51.3844 0074392 331.6894 28.0292 14.94656030669079
+GOMX-1
+1 39430U 13066Q 26131.14073843 .00001400 00000-0 21676-3 0 9998
+2 39430 97.6512 333.9391 0128259 195.8918 163.8248 14.69313597664477
+LO-74
+1 39440U 13066AA 26131.14980934 .00002328 00000-0 21960-3 0 9993
+2 39440 97.8888 79.9863 0058762 148.6845 211.7896 14.93485032671463
+AO-73
+1 39444U 13066AE 26131.19361385 .00005682 00000-0 35839-3 0 9991
+2 39444 97.8258 101.8861 0035647 332.4449 27.4889 15.09004761674080
+DTUSAT-2
+1 40030U 14033W 26130.98092610 .00004624 00000-0 25480-3 0 9993
+2 40030 98.0872 126.3629 0008117 15.8774 344.2709 15.14529000647059
+LILACSAT-2
+1 40908U 15049K 26131.17016306 .00011634 00000-0 20748-3 0 9996
+2 40908 97.4702 166.6320 0007792 43.1441 317.0419 15.50216690590013
+Horyu-4
+1 41340U 16012D 26130.90637118 .00131902 00000-0 74753-3 0 9994
+2 41340 30.9896 348.4205 0005704 6.7696 353.3037 15.77528373564899
+Lapan A3
+1 41603U 16040E 26131.24557346 .00002464 00000-0 79828-4 0 9998
+2 41603 97.1491 128.6139 0011542 140.0792 220.1302 15.32870423549152
+CAS-2T
+1 41847U 16066G 26131.18412439 .00000509 00000-0 81632-4 0 9996
+2 41847 98.3824 207.3390 0341016 241.7460 114.8921 14.44588827499451
+TechnoSat
+1 42829U 17042E 26131.01233461 .00001411 00000-0 10409-3 0 9996
+2 42829 97.4239 290.1013 0016826 216.9132 143.0938 15.04724250481117
+AO-91
+1 43017U 17073E 26131.09060397 .00005996 00000-0 26415-3 0 9990
+2 43017 97.4765 359.0772 0154222 96.6340 265.2471 15.12032600459782
+S-Net D
+1 43186U 18014G 26131.11497268 .00002740 00000-0 14474-3 0 9993
+2 43186 97.5389 36.1420 0009430 137.7075 222.4887 15.16318970453148
+S-Net B
+1 43187U 18014H 26131.19169547 .00002761 00000-0 14591-3 0 9991
+2 43187 97.5394 36.2040 0010151 134.0553 226.1518 15.16289962453158
+S-Net A
+1 43188U 18014J 26131.18002576 .00002596 00000-0 13728-3 0 9996
+2 43188 97.5404 36.3942 0010040 134.5870 225.6183 15.16325838453152
+S-Net C
+1 43189U 18014K 26131.19537149 .00002851 00000-0 15054-3 0 9995
+2 43189 97.5421 36.4784 0011550 129.0934 231.1328 15.16281125451706
+Ten-Koh
+1 43677U 18084G 26131.10435024 .00000760 00000-0 61802-4 0 9994
+2 43677 98.0772 321.9114 0008001 238.0924 121.9521 15.02773723410597
+PO-101
+1 43678U 18084H 26131.15579828 .00001902 00000-0 15692-3 0 9995
+2 43678 98.1100 325.7784 0012111 299.1757 60.8253 15.00266531410661
+QO-100
+1 43700U 18090A 26131.11564321 .00000155 00000-0 00000-0 0 9999
+2 43700 0.0033 75.2010 0001627 8.7258 212.4418 1.00273235 27300
+MinXSS-2
+1 43758U 18099A 26131.18881920 .00022285 00000-0 48164-3 0 9999
+2 43758 97.4545 206.4613 0007687 49.9798 310.2123 15.44489493408419
+AO-95
+1 43770U 18099N 26131.10130148 .00007590 00000-0 29846-3 0 9992
+2 43770 97.4408 191.5040 0010413 116.7346 243.4959 15.25898855407566
+SNUSat 2
+1 43782U 18099AA 26131.11021086 .00005455 00000-0 24677-3 0 9991
+2 43782 97.4089 185.0750 0011797 70.9847 289.2666 15.21262664407396
+SnugLite
+1 43784U 18099AC 26131.11290757 .00007562 00000-0 29362-3 0 9993
+2 43784 97.3899 185.7766 0004280 76.8149 283.3567 15.26360439407668
+ITASat 1
+1 43786U 18099AE 26131.12685726 .00004158 00000-0 20392-3 0 9992
+2 43786 97.4060 183.3865 0014282 119.5348 240.7313 15.18571210407280
+EAGLET 1
+1 43790U 18099AJ 26131.07765206 .00002933 00000-0 17114-3 0 9990
+2 43790 97.4260 181.7317 0012814 112.1030 248.1562 15.12650734406726
+ESEO
+1 43792U 18099AL 26131.06045373 .00001673 00000-0 12464-3 0 9990
+2 43792 97.3995 170.0352 0013322 99.6548 260.6184 15.04126416406220
+JO-97
+1 43803U 18099AX 26131.15127351 .00010391 00000-0 33361-3 0 9996
+2 43803 97.4154 193.8880 0006563 56.1584 304.0282 15.32471929407953
+Suomi 100
+1 43804U 18099AY 26131.13954280 .00007164 00000-0 26810-3 0 9999
+2 43804 97.4213 191.6912 0011151 58.7267 301.5063 15.27555792407760
+ISAT
+1 43879U 18111D 26130.74947674 .00048674 00000-0 61630-3 0 9991
+2 43879 97.5895 63.2824 0008440 88.2362 271.9860 15.59311726405323
+UWE-4
+1 43880U 18111E 26131.03648958 .00020592 00000-0 45454-3 0 9994
+2 43880 97.5851 57.7861 0010721 97.9534 262.2930 15.43852796405049
+Sparrow
+1 43881U 18111F 26131.08640255 .00076251 00000-0 75641-3 0 9996
+2 43881 97.6118 68.6977 0007664 110.2677 249.9406 15.65516907405556
+Prox-1
+1 44339U 19036A 26130.95960472 .00008466 00000-0 83345-3 0 9996
+2 44339 23.9966 2.7467 0006462 323.1483 36.8572 14.89731402367914
+Taurus 1
+1 44530U 19059C 26131.19338833 .00002738 00000-0 44797-3 0 9995
+2 44530 98.6391 293.7450 0009485 73.1672 287.0573 14.71688993353207
+TO-108
+1 44881U 19093C 26131.15656832 .00000724 00000-0 87928-4 0 9997
+2 44881 97.7533 204.2903 0012857 203.2455 156.8181 14.86457625345915
+RS-44
+1 44909U 19096E 26131.10347560 .00000010 00000-0 -10444-5 0 9990
+2 44909 82.5243 4.3509 0216605 230.9343 127.2311 12.79748087297601
+SALSAT
+1 46495U 20068K 26130.98568909 .00005135 00000-0 18361-3 0 9996
+2 46495 97.8863 131.8035 0011580 76.8104 283.4426 15.29246502309673
+CSS (TIANHE-1)
+1 48274U 21035A 26131.17664318 .00014757 00000-0 16684-3 0 9997
+2 48274 41.4670 187.1184 0004323 286.6334 73.4031 15.62137381287386
+CUTE
+1 49263U 21088D 26131.19481488 .00135544 00000-0 78838-3 0 9998
+2 49263 97.4193 227.3703 0001335 277.9495 82.1620 15.78091657256694
+TeikyoSat 4
+1 49396U 21102B 26131.06353934 .00000998 00000-0 66173-4 0 9996
+2 49396 97.3700 161.9887 0013588 64.8246 295.4391 15.09373351247120
+Z-Sat
+1 49399U 21102E 26131.15472941 .00002509 00000-0 12629-3 0 9995
+2 49399 97.3360 167.6038 0017235 22.6619 337.5373 15.17981670247828
+KOSEN 1
+1 49402U 21102H 26131.04088000 .00004594 00000-0 17937-3 0 9990
+2 49402 97.3222 173.9286 0012998 346.2844 13.8039 15.26320628248353
+HO-113
+1 50466U 21131B 26131.19252443 .00000212 00000-0 79252-4 0 9996
+2 50466 98.4951 223.7863 0003730 192.3468 167.7630 14.41321109229780
+SNUGLITE 2
+1 52899U 22065F 26131.13163480 .00000636 00000-0 12980-3 0 9995
+2 52899 98.2152 276.0399 0008471 134.2292 225.9607 14.64276471205573
+UmKA 1 (RS40S)
+1 57172U 23091G 26131.17665898 .00003876 00000-0 18088-3 0 9992
+2 57172 97.5075 190.0238 0011429 244.8930 115.1119 15.20390618158386
+CubeBel-2 (EU11S)
+1 57175U 23091K 26131.20005564 .00007318 00000-0 26808-3 0 9991
+2 57175 97.5073 194.1091 0008792 239.5277 120.5094 15.28283727158655
+RS-38S
+1 57189U 23091Z 26131.19498866 .00010571 00000-0 31497-3 0 9990
+2 57189 97.5109 199.9714 0007487 190.9899 169.1182 15.34845194159012
+SONATE-2
+1 59112U 24043Q 26131.12679378 .00026625 00000-0 38211-3 0 9996
+2 59112 97.5494 279.3411 0006062 339.5693 20.5318 15.56091583122127
+GRBBeta
+1 60237U 24128C 26130.91713484 .00002522 00000-0 18156-3 0 9999
+2 60237 61.9910 346.9978 0045504 126.9629 233.5644 15.06330418100655
+Curium One
+1 60242U 24128H 26131.14068698 .00005464 00000-0 32270-3 0 9992
+2 60242 61.9799 336.9263 0045175 123.1924 237.3516 15.11910084100854
+ROBUSTA-3A
+1 60243U 24128J 26131.15129132 .00004784 00000-0 29043-3 0 9993
+2 60243 61.9875 339.1574 0046325 120.7932 239.7735 15.11089418100824
+CatSat
+1 60246U 24125J 26130.65834471 .00032801 00000-0 48984-3 0 9992
+2 60246 97.2134 342.7865 0021671 323.1152 36.8611 15.54702145101556
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26131.18910102 .00070537 00000-0 64140-3 0 9993
+2 61772 97.2951 9.2799 0007750 68.0159 292.1925 15.67708392128865
+AO-123
+1 61781U 24199AY 26131.14701627 .00005061 00000-0 15024-3 0 9996
+2 61781 97.3054 0.1577 0015895 83.3073 276.9979 15.35126490128247
+JINJUSat 1B
+1 63210U 25052A 26131.13283679 .00010563 00000-0 34056-3 0 9994
+2 63210 97.4039 27.8649 0002743 176.6079 183.5182 15.32348291 64426
+NUSHSAT 1
+1 63211U 25052B 26131.16717502 .00012102 00000-0 36395-3 0 9994
+2 63211 97.4020 28.3464 0002418 174.1836 185.9435 15.34531535 64469
+TEVEL2-4
+1 63213U 25052D 26131.19399235 .00011427 00000-0 35724-3 0 9992
+2 63213 97.3944 27.5551 0001369 179.2477 180.8768 15.33315562 64444
+TEVEL2-5
+1 63214U 25052E 26130.94950516 .00010812 00000-0 33989-3 0 9998
+2 63214 97.3942 27.2685 0001337 177.4534 182.6716 15.33154657 64402
+TEVEL2-6
+1 63215U 25052F 26130.69985694 .00010998 00000-0 34614-3 0 9997
+2 63215 97.3944 27.0038 0001361 185.8938 174.2288 15.33112431 64363
+TEVEL2-1
+1 63217U 25052H 26131.17351758 .00010799 00000-0 34505-3 0 9999
+2 63217 97.3915 27.1439 0000874 207.6246 152.4950 15.32634673 64429
+TEVEL2-3
+1 63218U 25052J 26131.16939257 .00010761 00000-0 34333-3 0 9993
+2 63218 97.3918 27.1573 0000842 209.9970 150.1224 15.32682225 64421
+TEVEL2-2
+1 63219U 25052K 26131.17400360 .00011085 00000-0 35402-3 0 9991
+2 63219 97.3917 27.1462 0000871 212.1904 147.9285 15.32641148 64423
+TEVEL2-9
+1 63237U 25052AD 26130.64737083 .00010342 00000-0 35029-3 0 9997
+2 63237 97.3979 26.0735 0004018 277.0962 82.9822 15.30756771 64289
+TEVEL2-7
+1 63238U 25052AE 26131.20450175 .00009633 00000-0 32908-3 0 9999
+2 63238 97.3983 26.5593 0004126 273.8598 86.2171 15.30500428 64360
+TEVEL2-8
+1 63239U 25052AF 26130.95081800 .00009476 00000-0 32399-3 0 9995
+2 63239 97.3982 26.2849 0004099 276.5700 83.5075 15.30477477 64321
+HYDRA-W
+1 63490U 25052BL 26113.93882235 .05662091 24406-5 29537-2 0 9997
+2 63490 97.3690 18.2798 0008685 203.5899 156.4993 16.20186780 62336
+HADES-ICM (SO-125)
+1 63492U 25052BN 26130.71186245 .00582006 13575-3 17880-2 0 9995
+2 63492 97.3752 34.6178 0008453 168.0198 192.1279 15.91770935 64874
+SPIRONE
+1 66657U 25274H 26131.20400206 .00001421 00000-0 14060-3 0 9999
+2 66657 97.7477 61.0302 0013275 132.2234 228.0115 14.93390226 24701
+K-HERO
+1 66660U 25274L 26130.75014592 .00001609 00000-0 15676-3 0 9993
+2 66660 97.7484 60.7163 0015020 138.3573 221.8794 14.93816999 24644
+SNUGLITE-III DURI
+1 66661U 25274M 26130.80610814 .00001200 00000-0 11812-3 0 9994
+2 66661 97.7479 60.7906 0015607 139.4574 220.7812 14.93870292 24654
+SilverSat
+1 66909U 98067XV 26113.44966717 .07226154 12288-4 11979-2 0 9998
+2 66909 51.6027 190.0749 0007952 333.4666 26.5949 16.32457272 22308
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26130.68176839 .00006594 00000-0 27315-3 0 9993
+2 67290 97.3936 206.2042 0010846 124.8732 235.3527 15.24193958 20269
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26131.15979301 .00009386 00000-0 37484-3 0 9992
+2 67291 97.3937 206.7831 0010564 123.0824 237.1430 15.25307641 20341
+Ten-Koh2
+1 68261U 25241B 26131.02320169 .00004301 00000-0 19201-3 0 9997
+2 68261 51.6530 136.4472 0006189 27.6825 332.4482 15.23411345 9246
+JACK-002
+1 68417U 26067B 26130.87978863 .00004513 00000-0 21937-3 0 9993
+2 68417 97.4540 89.9518 0003823 70.3588 289.8059 15.18925136 6282
+DISCO 2
+1 68431U 26067R 26131.15543764 .00004682 00000-0 23006-3 0 9995
+2 68431 97.4579 90.2163 0004201 108.4262 251.7429 15.18527090 6325
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26130.85561726 .00010054 00000-0 49990-3 0 9995
+2 68446 97.4386 89.7549 0006654 183.6763 176.4423 15.17813078 6266
+PARUS-6U1
+1 68456U 26067AS 26130.86167129 .00003315 00000-0 17050-3 0 9990
+2 68456 97.4528 89.8177 0005599 173.6121 186.5185 15.17124485 6272
+SAL-E
+1 68458U 26067AU 26131.12495887 .00004338 00000-0 22143-3 0 9992
+2 68458 97.4453 90.0397 0005556 181.6692 178.4524 15.17227047 6314
+FSI-SAT 2
+1 68792U 26088A 26131.16059718 .00003319 00000-0 22821-3 0 9990
+2 68792 97.5023 281.3688 0013603 230.4942 129.5084 15.06525503 2714
+OrigamiSat 2
+1 68795U 26088D 26131.14301078 .00002157 00000-0 14396-3 0 9997
+2 68795 97.5033 281.3946 0015254 201.8928 158.1650 15.07988141 2714
+ARICA 2
+1 68796U 26088E 26131.20807513 .00002756 00000-0 18220-3 0 9995
+2 68796 97.5018 281.4561 0015325 199.9200 160.1431 15.08113805 2720
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26131.14104507 .00003803 00000-0 24928-3 0 9998
+2 68797 97.5017 281.3920 0015280 199.8384 160.2253 15.08201180 2716
+MANGARO-II-Piscus
+1 68798U 26088G 26131.13703227 .00002346 00000-0 15388-3 0 9993
+2 68798 97.5024 281.3998 0018610 203.9200 156.1166 15.08499209 2712
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+
+/EX
+SB KEPS @ WW < CX2SA $ORB26121.1
+2Line Orbital Elements 26121.AMSAT
+R:260511/0338Z 4228@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260511/0319Z 9146@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260511/0258Z 53957@EI2GYB.DGL.IRL.EURO LinBPQ6.0.25
+R:260508/0137Z 25437@CT1EBQ.CTLX.PRT.EU LinBPQ6.0.25
+R:260508/0039Z 1768@K4WOF.FL.USA.NOAM LinBPQ6.0.24
+R:260508/0029Z 49569@KD4WLE.#SFL.FL.USA.NOAM LinBPQ6.0.23
+R:260508/0029Z 30999@N2MH4.#SENC.NC.USA.NOAM LinBPQ6.0.24
+R:260508/0028Z 4114@N3HYM.#FRDK.MD.USA.NOAM BPQ6.0.25
+R:260508/0024Z @:CX2SA.SAL.URY.SOAM #:64816 [Salto] FBB7.00e $:ORB26121.1
+
+From: CX2SA@CX2SA.SAL.URY.SOAM
+To : KEPS@AMSAT
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA May 01, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26120.59626755 -.00000031 00000-0 96085-4 0 9996
+2 07530 101.9926 133.3432 0011994 220.6153 258.4322 12.53697390354550
+UO-11
+1 14781U 84021B 26120.63125062 .00001359 00000-0 14431-3 0 9996
+2 14781 97.8024 86.7520 0007351 353.7891 6.3235 14.90668042250043
+AO-27
+1 22825U 93061C 26120.59124487 .00000109 00000-0 58602-4 0 9994
+2 22825 98.6901 188.0163 0007443 235.3832 124.6649 14.30928987700195
+FO-29
+1 24278U 96046B 26120.47426956 .00000013 00000-0 50669-4 0 9996
+2 24278 98.5296 335.8670 0349180 220.1294 137.3578 13.53271984466712
+GO-32
+1 25397U 98043D 26120.43948020 .00000063 00000-0 47326-4 0 9996
+2 25397 99.0062 111.9975 0001611 35.8621 324.2665 14.24418789444537
+ISS
+1 25544U 98067A 26120.52250176 .00006189 00000-0 12023-3 0 9994
+2 25544 51.6315 176.0292 0007158 7.8188 352.2911 15.49033593564362
+NO-44
+1 26931U 01043C 26120.38474986 .00000155 00000-0 88631-4 0 9990
+2 26931 67.0526 7.9102 0006454 264.0053 96.0313 14.31937124283603
+SO-50
+1 27607U 02058C 26120.61380811 .00001265 00000-0 16633-3 0 9992
+2 27607 64.5517 276.1629 0075618 271.1171 88.1272 14.82940590257400
+CO-55
+1 27844U 03031E 26120.61928520 .00000312 00000-0 15395-3 0 9998
+2 27844 98.6753 129.7745 0008876 330.4565 29.6111 14.24305462184908
+RS-22
+1 27939U 03042A 26120.61250030 .00000739 00000-0 12220-3 0 9996
+2 27939 98.3465 303.6310 0012451 62.4503 25.9615 14.73379983208547
+CO-65
+1 32785U 08021C 26120.57822720 .00004835 00000-0 30988-3 0 9991
+2 32785 97.8249 101.0318 0008844 179.6083 180.5154 15.08992068978015
+CO-66
+1 32791U 08021J 26120.45175439 .00020092 00000-0 67012-3 0 9994
+2 32791 97.7523 116.1352 0005105 108.3124 251.8672 15.31103491979987
+RS-30
+1 32953U 08025A 26120.53591584 .00000028 00000-0 12623-3 0 9995
+2 32953 82.5081 25.0777 0020601 56.2206 304.0833 12.43177720813777
+SRMSAT
+1 37841U 11058D 26120.64063082 .00000431 00000-0 90343-4 0 9999
+2 37841 19.9736 347.2598 0011744 41.3226 351.6382 14.11564464751099
+ZACUBE-1
+1 39417U 13066B 26120.40955899 .00005584 00000-0 43585-3 0 9990
+2 39417 97.8125 82.4893 0043675 53.2749 307.2473 15.00793807673560
+Delfi-N3xt
+1 39428U 13066N 26120.51689157 .00009440 00000-0 83129-3 0 9998
+2 39428 97.8353 40.8915 0075595 6.9012 353.3230 14.94487301667503
+GOMX-1
+1 39430U 13066Q 26120.51682591 .00001486 00000-0 23032-3 0 9995
+2 39430 97.6519 323.9831 0127688 230.2625 128.7276 14.69275071662918
+LO-74
+1 39440U 13066AA 26120.42970364 .00002755 00000-0 25964-3 0 9990
+2 39440 97.8881 69.2303 0057709 184.2052 175.8690 14.93419487669867
+AO-73
+1 39444U 13066AE 26120.45083755 .00009895 00000-0 62276-3 0 9995
+2 39444 97.8252 90.9324 0037047 9.4409 350.7507 15.08828815672461
+DTUSAT-2
+1 40030U 14033W 26120.47559618 .00007927 00000-0 43552-3 0 9991
+2 40030 98.0858 115.2001 0009109 47.4202 312.7795 15.14375567645468
+LILACSAT-2
+1 40908U 15049K 26120.58300029 .00017927 00000-0 32241-3 0 9999
+2 40908 97.4716 155.6566 0008657 73.9776 286.2428 15.49864518588370
+Horyu-4
+1 41340U 16012D 26120.52098681 .00145472 00000-0 94490-3 0 9994
+2 41340 30.9895 62.4942 0006347 279.9281 80.0658 15.74401799563258
+Lapan A3
+1 41603U 16040E 26120.60475993 .00003919 00000-0 12595-3 0 9996
+2 41603 97.1486 118.3273 0010337 175.3397 184.7944 15.32791975547524
+CAS-2T
+1 41847U 16066G 26120.44803345 .00000652 00000-0 10193-3 0 9995
+2 41847 98.3830 196.7230 0340924 274.4340 81.7982 14.44572896497905
+TechnoSat
+1 42829U 17042E 26120.50527841 .00003377 00000-0 24373-3 0 9994
+2 42829 97.4236 280.0028 0016074 254.9274 105.0174 15.04665469479531
+AO-91
+1 43017U 17073E 26120.56760982 .00009642 00000-0 42505-3 0 9997
+2 43017 97.4776 348.7762 0154191 132.5723 228.8640 15.11842589458199
+S-Net D
+1 43186U 18014G 26120.62208442 .00005397 00000-0 28254-3 0 9993
+2 43186 97.5403 25.7182 0008374 171.0906 189.0477 15.16218583451559
+S-Net B
+1 43187U 18014H 26120.30262479 .00005079 00000-0 26629-3 0 9990
+2 43187 97.5408 25.3861 0009103 168.5071 191.6371 15.16186010451506
+S-Net A
+1 43188U 18014J 26120.62119372 .00005622 00000-0 29407-3 0 9990
+2 43188 97.5417 25.9026 0009011 168.1712 191.9734 15.16225280451556
+S-Net C
+1 43189U 18014K 26120.30623640 .00004941 00000-0 25913-3 0 9995
+2 43189 97.5435 25.6569 0010559 163.4871 196.6708 15.16177368450059
+Ten-Koh
+1 43677U 18084G 26120.51726923 .00002211 00000-0 17038-3 0 9992
+2 43677 98.0790 310.8788 0007393 279.4851 80.5537 15.02737140409006
+PO-101
+1 43678U 18084H 26120.61768073 .00002281 00000-0 18741-3 0 9995
+2 43678 98.1069 314.7988 0012905 334.2272 25.8306 15.00213077409084
+QO-100
+1 43700U 18090A 26120.49191795 .00000147 00000-0 00000-0 0 9990
+2 43700 0.0137 266.9736 0001700 165.7205 348.6817 1.00277015 27199
+MinXSS-2
+1 43758U 18099A 26120.17251933 .00037732 00000-0 83193-3 0 9995
+2 43758 97.4564 195.1661 0008699 86.6211 273.6032 15.43781740406710
+AO-95
+1 43770U 18099N 26120.14912640 .00011872 00000-0 46841-3 0 9991
+2 43770 97.4423 180.6034 0009975 149.6725 210.5092 15.25656511405890
+SNUSat 2
+1 43782U 18099AA 26120.58539330 .00008411 00000-0 38053-3 0 9994
+2 43782 97.4102 174.7178 0012112 102.8902 257.3688 15.21092225405796
+SnugLite
+1 43784U 18099AC 26120.62301173 .00012502 00000-0 48672-3 0 9997
+2 43784 97.3910 175.3995 0004544 100.4524 259.7227 15.26124840406062
+ITASat 1
+1 43786U 18099AE 26120.58347617 .00006702 00000-0 32799-3 0 9995
+2 43786 97.4069 173.0576 0013689 152.7861 207.4093 15.18431286405688
+EAGLET 1
+1 43790U 18099AJ 26120.55936735 .00004708 00000-0 27311-3 0 9990
+2 43790 97.4273 171.4926 0012265 144.7087 215.4959 15.12566969405132
+ESEO
+1 43792U 18099AL 26120.61579705 .00001029 00000-0 78379-4 0 9993
+2 43792 97.4011 160.0364 0013386 130.1813 230.0587 15.04094766404653
+JO-97
+1 43803U 18099AX 26120.44163872 .00018306 00000-0 59148-3 0 9999
+2 43803 97.4165 183.1590 0007243 87.0718 273.1353 15.32125843406318
+Suomi 100
+1 43804U 18099AY 26120.13373230 .00012858 00000-0 48218-3 0 9999
+2 43804 97.4227 180.7383 0011754 92.7798 267.4787 15.27309788406081
+ISAT
+1 43879U 18111D 26120.34894173 .00079102 00000-0 10536-2 0 9999
+2 43879 97.5909 52.1910 0008783 107.0035 253.2183 15.57836101403707
+UWE-4
+1 43880U 18111E 26120.27520350 .00033104 00000-0 74416-3 0 9996
+2 43880 97.5865 46.5727 0010273 127.1071 233.1116 15.43217639403384
+Sparrow
+1 43881U 18111F 26120.59753454 .00099918 00000-0 10698-2 0 9991
+2 43881 97.6130 57.3785 0007214 124.0858 236.1086 15.63499996403913
+Prox-1
+1 44339U 19036A 26120.10770695 .00015990 00000-0 16095-2 0 9995
+2 44339 23.9953 75.1193 0006557 194.7556 165.2752 14.89453634366293
+Taurus 1
+1 44530U 19059C 26120.51868634 .00006853 00000-0 11100-2 0 9999
+2 44530 98.6370 282.4197 0009795 103.7836 256.4460 14.71565351351635
+TO-108
+1 44881U 19093C 26120.52066606 .00000444 00000-0 56246-4 0 9998
+2 44881 97.7552 193.9138 0012137 241.5791 118.4202 14.86439991344338
+RS-44
+1 44909U 19096E 26120.62724622 .00000020 00000-0 41717-4 0 9999
+2 44909 82.5258 11.3107 0216386 255.5417 102.1587 12.79747949296264
+SALSAT
+1 46495U 20068K 26120.45042489 .00008489 00000-0 30299-3 0 9996
+2 46495 97.8854 120.6367 0011665 107.7663 252.4849 15.29083608308068
+CSS (TIANHE-1)
+1 48274U 21035A 26120.31498218 .00029313 00000-0 31348-3 0 9993
+2 48274 41.4672 253.4465 0006644 301.0493 58.9694 15.63205886285684
+CUTE
+1 49263U 21088D 26120.53091714 .00069674 00000-0 46542-3 0 9990
+2 49263 97.4199 215.9528 0000987 140.2514 219.8823 15.75129279255012
+TeikyoSat 4
+1 49396U 21102B 26120.58887221 .00001607 00000-0 10437-3 0 9991
+2 49396 97.3707 151.9191 0013791 96.7285 263.5514 15.09333694245540
+Z-Sat
+1 49399U 21102E 26120.60743559 .00003184 00000-0 15971-3 0 9992
+2 49399 97.3371 157.3769 0018284 57.0424 303.2565 15.17894011246226
+KOSEN 1
+1 49402U 21102H 26120.35427331 .00007974 00000-0 31043-3 0 9995
+2 49402 97.3231 163.4537 0014218 24.4601 335.7309 15.26167390246729
+HO-113
+1 50466U 21131B 26120.64050645 .00000611 00000-0 20260-3 0 9991
+2 50466 98.4957 213.2950 0003091 229.5193 130.5727 14.41311187228267
+SNUGLITE 2
+1 52899U 22065F 26120.40315336 .00001130 00000-0 22348-3 0 9991
+2 52899 98.2133 265.3385 0007852 164.8498 195.2941 14.64255007204006
+UmKA 1 (RS40S)
+1 57172U 23091G 26120.58016625 .00006350 00000-0 29519-3 0 9994
+2 57172 97.5088 179.4714 0011251 287.0872 72.9131 15.20274303156774
+CubeBel-2 (EU11S)
+1 57175U 23091K 26120.52691763 .00013004 00000-0 47745-3 0 9998
+2 57175 97.5087 183.3529 0008427 283.7278 76.3023 15.28041078157024
+RS-38S
+1 57189U 23091Z 26120.63236377 .00016695 00000-0 50090-3 0 9997
+2 57189 97.5120 189.2157 0006493 229.9986 130.0687 15.34517994157394
+SONATE-2
+1 59112U 24043Q 26120.38537620 .00040443 00000-0 59507-3 0 9990
+2 59112 97.5479 267.9964 0006534 23.0616 337.0930 15.55323705120453
+GRBBeta
+1 60237U 24128C 26120.16300868 .00004275 00000-0 29747-3 0 9998
+2 60237 61.9921 24.7077 0046692 124.5499 236.0014 15.06246315 99036
+Curium One
+1 60242U 24128H 26120.29369250 .00008622 00000-0 50299-3 0 9994
+2 60242 61.9807 15.3042 0046210 121.0787 239.4856 15.11735121 99216
+ROBUSTA-3A
+1 60243U 24128J 26120.43079215 .00008504 00000-0 50698-3 0 9992
+2 60243 61.9886 17.0301 0047317 118.5531 242.0339 15.10923460 99207
+CatSat
+1 60246U 24125J 26120.61478375 .00050071 00000-0 77163-3 0 9994
+2 60246 97.2135 332.6735 0023070 2.7620 357.3757 15.53715587 99995
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26120.58751286 .00086956 00000-0 84989-3 0 9996
+2 61772 97.2978 358.2776 0009065 96.0705 264.1588 15.65839180127204
+AO-123
+1 61781U 24199AY 26120.58680085 .00008300 00000-0 24609-3 0 9994
+2 61781 97.3069 349.6955 0015733 116.8757 243.4097 15.34966487126623
+JINJUSat 1B
+1 63210U 25052A 26120.22642149 .00017291 00000-0 56137-3 0 9992
+2 63210 97.4060 16.9607 0001350 231.0785 129.0337 15.32008456 62753
+NUSHSAT 1
+1 63211U 25052B 26120.60214753 .00021160 00000-0 64215-3 0 9997
+2 63211 97.4041 17.7521 0001015 230.4217 129.6936 15.34123011 62846
+TEVEL2-4
+1 63213U 25052D 26120.62070811 .00018444 00000-0 58131-3 0 9997
+2 63213 97.3962 16.9829 0000347 316.1175 44.0040 15.32945027 62824
+TEVEL2-5
+1 63214U 25052E 26120.44039566 .00019688 00000-0 62327-3 0 9993
+2 63214 97.3960 16.7632 0000428 311.7824 48.3381 15.32791045 62795
+TEVEL2-6
+1 63215U 25052F 26120.64742009 .00019145 00000-0 60679-3 0 9995
+2 63215 97.3962 16.9554 0000497 308.8887 51.2311 15.32759360 62829
+TEVEL2-1
+1 63217U 25052H 26120.46497484 .00019231 00000-0 61874-3 0 9995
+2 63217 97.3936 16.4513 0001070 345.5359 14.5852 15.32275390 62785
+TEVEL2-3
+1 63218U 25052J 26120.65708406 .00018565 00000-0 59650-3 0 9994
+2 63218 97.3940 16.6597 0001080 343.6471 16.4736 15.32327642 62814
+TEVEL2-2
+1 63219U 25052K 26120.66141397 .00018724 00000-0 60232-3 0 9991
+2 63219 97.3937 16.6490 0001079 344.9311 15.1898 15.32287401 62811
+TEVEL2-9
+1 63237U 25052AD 26120.44881295 .00017886 00000-0 60935-3 0 9993
+2 63237 97.4000 15.9099 0004769 328.4859 31.6096 15.30434540 62722
+TEVEL2-7
+1 63238U 25052AE 26120.21958078 .00016618 00000-0 57106-3 0 9991
+2 63238 97.4003 15.6165 0004923 329.3629 30.7323 15.30168799 62682
+TEVEL2-8
+1 63239U 25052AF 26120.61966130 .00016204 00000-0 55704-3 0 9997
+2 63239 97.3999 15.9936 0004839 329.1455 30.9500 15.30162602 62749
+HYDRA-W
+1 63490U 25052BL 26113.93882235 .05662091 24406-5 29537-2 0 9997
+2 63490 97.3690 18.2798 0008685 203.5899 156.4993 16.20186780 62336
+HADES-ICM (SO-125)
+1 63492U 25052BN 26120.17329350 .00491395 00000-0 25041-2 0 9994
+2 63492 97.3820 23.2455 0004471 153.3500 206.7998 15.80099034 63200
+SPIRONE
+1 66657U 25274H 26120.34934002 .00002844 00000-0 27630-3 0 9995
+2 66657 97.7475 50.3354 0012444 165.8106 194.3466 14.93345709 23084
+K-HERO
+1 66660U 25274L 26120.36747734 .00002099 00000-0 20302-3 0 9996
+2 66660 97.7485 50.4787 0014087 171.0409 189.1065 14.93779785 23093
+SNUGLITE-III DURI
+1 66661U 25274M 26120.35685624 .00002143 00000-0 20688-3 0 9992
+2 66661 97.7479 50.4870 0014695 172.7075 187.4361 14.93838391 23091
+SilverSat
+1 66909U 98067XV 26113.44966717 .07226154 12288-4 11979-2 0 9998
+2 66909 51.6027 190.0749 0007952 333.4666 26.5949 16.32457272 22308
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26120.43968107 .00010040 00000-0 41674-3 0 9997
+2 67290 97.3951 196.1010 0010296 156.8142 203.3562 15.23992200 18703
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26120.20320033 .00015023 00000-0 60321-3 0 9999
+2 67291 97.3951 195.9575 0010147 156.6625 203.5076 15.25010223 18672
+Ten-Koh2
+1 68261U 25241B 26120.39561297 .00006717 00000-0 29306-3 0 9994
+2 68261 51.6489 187.0004 0005788 350.6255 9.4613 15.23280865 7620
+JACK-002
+1 68417U 26067B 26120.60240878 .00006891 00000-0 33446-3 0 9990
+2 68417 97.4536 79.8143 0004160 88.1169 272.0541 15.18786870 4723
+DISCO 2
+1 68431U 26067R 26120.61171038 .00009311 00000-0 45617-3 0 9991
+2 68431 97.4573 79.8175 0003643 127.1484 233.0084 15.18362870 4723
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26120.57008563 .00020045 00000-0 10023-2 0 9993
+2 68446 97.4381 79.6489 0005169 226.6246 133.4558 15.17460741 4700
+PARUS-6U1
+1 68456U 26067AS 26120.57217281 .00006302 00000-0 32207-3 0 9992
+2 68456 97.4522 79.6979 0004404 212.8364 147.2597 15.17010219 4719
+SAL-E
+1 68458U 26067AU 26120.57221831 .00008539 00000-0 43438-3 0 9992
+2 68458 97.4447 79.6698 0004323 225.0140 135.0744 15.17068978 4717
+FSI-SAT 2
+1 68792U 26088A 26115.68414791 .00000849 00000-0 61705-4 0 9995
+2 68792 97.4990 266.2992 0012809 287.5176 72.4651 15.06389719 389
+OrigamiSat 2
+1 68795U 26088D 26113.82356135 .00001590 00000-0 10758-3 0 9994
+2 68795 97.5008 264.4888 0014430 266.4157 93.5420 15.07861282 103
+ARICA 2
+1 68796U 26088E 26113.82352201 .00001593 00000-0 10752-3 0 9992
+2 68796 97.4989 264.4863 0014541 264.6248 95.3321 15.07951070 103
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26113.82350997 .00001596 00000-0 10767-3 0 9992
+2 68797 97.5012 264.4822 0014814 262.4592 97.4954 15.07975758 102
+MANGARO-II-Piscus
+1 68798U 26088G 26113.82334568 .00001591 00000-0 10611-3 0 9992
+2 68798 97.4999 264.4888 0017891 266.9056 93.0125 15.08353756 101
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+
+
+/EX
+SB KEPS @ AMSAT < CX2SA $ORB26135.1
+2Line Orbital Elements 26135.AMSAT
+R:260522/0052Z 4549@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260522/0035Z 9490@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260522/0030Z 54405@EI2GYB.DGL.IRL.EURO LinBPQ6.0.25
+R:260522/0026Z 43865@PY2BIL.SP.BRA.SOAM LinBPQ6.0.25
+R:260522/0025Z @:PI8ZTM.#ZH1.NLD.EURO #:54808 [Den Haag] $:ORB26135.1
+R:260522/0024Z @:CX2SA.SAL.URY.SOAM #:65323 [Salto] FBB7.00e $:ORB26135.1
+
+From: CX2SA@CX2SA.SAL.URY.SOAM
+To : KEPS@AMSAT
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA May 15, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26133.98839295 -.00000029 00000-0 11198-3 0 9996
+2 07530 101.9916 146.8769 0012162 194.6235 221.6905 12.53697521356232
+UO-11
+1 14781U 84021B 26133.45203940 .00000849 00000-0 92245-4 0 9995
+2 14781 97.8037 99.4225 0006305 306.6451 53.4187 14.90698287251951
+AO-27
+1 22825U 93061C 26134.15658796 .00000052 00000-0 36628-4 0 9997
+2 22825 98.6891 201.5796 0008118 192.5267 167.5715 14.30932491702133
+FO-29
+1 24278U 96046B 26134.30046802 -.00000004 00000-0 30803-4 0 9990
+2 24278 98.5276 347.8080 0349782 184.2162 175.6010 13.53272399468584
+GO-32
+1 25397U 98043D 26133.50474968 .00000028 00000-0 32496-4 0 9996
+2 25397 99.0065 125.3907 0000980 12.1123 348.0079 14.24421378446394
+ISS
+1 25544U 98067A 26134.19858747 .00005122 00000-0 10032-3 0 9994
+2 25544 51.6312 108.3512 0007536 56.9254 303.2457 15.49211692566485
+NO-44
+1 26931U 01043C 26133.93490749 .00000059 00000-0 52955-4 0 9993
+2 26931 67.0511 332.8642 0006272 263.6520 96.3868 14.31942229285543
+SO-50
+1 27607U 02058C 26134.23594171 .00000640 00000-0 93285-4 0 9996
+2 27607 64.5522 234.0223 0075638 268.6719 90.5721 14.82972548259428
+CO-55
+1 27844U 03031E 26134.31787272 .00000206 00000-0 10816-3 0 9992
+2 27844 98.6747 143.3023 0008318 286.1175 73.9088 14.24313873186853
+RS-22
+1 27939U 03042A 26134.33663374 .00000002 00000-0 86089-5 0 9998
+2 27939 98.3472 317.7414 0011794 22.4638 98.2678 14.73402987210568
+CO-65
+1 32785U 08021C 26134.23763764 .00003466 00000-0 22257-3 0 9990
+2 32785 97.8259 114.9634 0010094 136.5210 223.6816 15.09113918980077
+CO-66
+1 32791U 08021J 26133.97786064 .00012151 00000-0 40134-3 0 9990
+2 32791 97.7520 130.2774 0004981 82.4291 277.7515 15.31540490982056
+RS-30
+1 32953U 08025A 26134.29767731 .00000034 00000-0 17279-3 0 9991
+2 32953 82.5074 16.5212 0020288 27.6935 332.5221 12.43177971815485
+SRMSAT
+1 37841U 11058D 26134.09968181 .00000362 00000-0 52346-4 0 9991
+2 37841 19.9722 265.7987 0011653 188.7625 346.2641 14.11567924752990
+ZACUBE-1
+1 39417U 13066B 26134.14345633 .00003059 00000-0 24077-3 0 9995
+2 39417 97.8119 96.2956 0041717 7.6658 352.5194 15.00915790675622
+Delfi-N3xt
+1 39428U 13066N 26134.30818915 .00004810 00000-0 42554-3 0 9999
+2 39428 97.8346 54.6598 0073953 320.6626 38.9235 14.94684418669565
+GOMX-1
+1 39430U 13066Q 26134.27339645 .00001039 00000-0 16277-3 0 9999
+2 39430 97.6514 336.8752 0128534 185.7789 174.1943 14.69319713664936
+LO-74
+1 39440U 13066AA 26134.29875776 .00001615 00000-0 15402-3 0 9991
+2 39440 97.8892 83.1463 0058903 138.5094 222.0619 14.93496311671934
+AO-73
+1 39444U 13066AE 26134.24384963 .00004978 00000-0 31443-3 0 9991
+2 39444 97.8260 104.9971 0035212 321.9795 37.8948 15.09034476674542
+DTUSAT-2
+1 40030U 14033W 26134.21824912 .00004516 00000-0 24883-3 0 9997
+2 40030 98.0863 129.8030 0007782 4.8197 355.3107 15.14554811647544
+LILACSAT-2
+1 40908U 15049K 26134.26846532 .00012366 00000-0 21992-3 0 9996
+2 40908 97.4693 169.8442 0007493 33.2688 326.9033 15.50284138590498
+Horyu-4
+1 41340U 16012D 26133.68948449 .00132750 00000-0 72995-3 0 9992
+2 41340 30.9895 328.5167 0005336 30.7718 329.3251 15.78201025565331
+Lapan A3
+1 41603U 16040E 26134.31370172 .00002365 00000-0 76693-4 0 9996
+2 41603 97.1485 131.5800 0011807 130.3018 229.9259 15.32884089549623
+CAS-2T
+1 41847U 16066G 26134.23181294 .00000570 00000-0 90011-4 0 9996
+2 41847 98.3825 210.3525 0341118 232.4686 124.5057 14.44592529499896
+TechnoSat
+1 42829U 17042E 26134.00479889 .00001804 00000-0 13188-3 0 9997
+2 42829 97.4240 292.9770 0017106 206.8425 153.1918 15.04734717481562
+AO-91
+1 43017U 17073E 26133.14210923 .00005670 00000-0 24989-3 0 9993
+2 43017 97.4759 1.0860 0154122 89.6523 272.2366 15.12056379460097
+S-Net D
+1 43186U 18014G 26134.28253071 .00003444 00000-0 18094-3 0 9990
+2 43186 97.5393 39.2895 0009663 128.1975 232.0130 15.16337653453624
+S-Net B
+1 43187U 18014H 26134.29332240 .00003280 00000-0 17260-3 0 9990
+2 43187 97.5399 39.2857 0010383 124.5559 235.6655 15.16307702453621
+S-Net A
+1 43188U 18014J 26134.28157859 .00003445 00000-0 18093-3 0 9999
+2 43188 97.5408 39.4765 0010272 125.2685 234.9510 15.16344520453629
+S-Net C
+1 43189U 18014K 26134.23102415 .00003190 00000-0 16798-3 0 9990
+2 43189 97.5426 39.4957 0011761 119.8182 240.4222 15.16298311452164
+Ten-Koh
+1 43677U 18084G 26134.10066264 .00000667 00000-0 54802-4 0 9991
+2 43677 98.0761 325.0332 0008350 227.6253 132.4264 15.02778496411042
+PO-101
+1 43678U 18084H 26134.29049394 .00001658 00000-0 13746-3 0 9999
+2 43678 98.1106 329.0456 0011918 288.1786 71.8138 15.00277600411130
+QO-100
+1 43700U 18090A 26134.25271515 .00000158 00000-0 00000-0 0 9990
+2 43700 0.0139 274.4063 0001542 173.6669 260.7626 1.00274771 27338
+MinXSS-2
+1 43758U 18099A 26134.16897497 .00024708 00000-0 53149-3 0 9997
+2 43758 97.4553 209.5181 0007363 39.8460 320.3328 15.44611401408872
+AO-95
+1 43770U 18099N 26134.11781633 .00008247 00000-0 32363-3 0 9995
+2 43770 97.4409 194.5063 0010477 107.6536 252.5847 15.25940468408022
+SNUSat 2
+1 43782U 18099AA 26134.13592128 .00005327 00000-0 24086-3 0 9998
+2 43782 97.4087 188.0526 0011635 61.7034 298.5374 15.21292362407853
+SnugLite
+1 43784U 18099AC 26134.12851138 .00007239 00000-0 28086-3 0 9996
+2 43784 97.3899 188.7598 0004133 70.1415 290.0268 15.26401246408121
+ITASat 1
+1 43786U 18099AE 26134.09204254 .00004905 00000-0 23980-3 0 9990
+2 43786 97.4058 186.2914 0014368 110.4835 249.7944 15.18595661407735
+EAGLET 1
+1 43790U 18099AJ 26134.12058776 .00002334 00000-0 13688-3 0 9993
+2 43790 97.4260 184.6939 0012892 102.7823 257.4849 15.12665712407183
+ESEO
+1 43792U 18099AL 26134.05410037 .00001637 00000-0 12207-3 0 9990
+2 43792 97.3998 172.9013 0013404 90.5694 269.7068 15.04136573406676
+JO-97
+1 43803U 18099AX 26134.15484223 .00010782 00000-0 34544-3 0 9991
+2 43803 97.4156 196.8973 0006276 47.2093 312.9676 15.32531303408418
+Suomi 100
+1 43804U 18099AY 26134.15278514 .00007203 00000-0 26925-3 0 9994
+2 43804 97.4216 194.6902 0010903 49.1800 311.0383 15.27596799408221
+ISAT
+1 43879U 18111D 26134.27860950 .00056210 00000-0 70169-3 0 9996
+2 43879 97.5900 67.0511 0008131 79.9769 280.2404 15.59657906405870
+UWE-4
+1 43880U 18111E 26134.27711341 .00021932 00000-0 48184-3 0 9992
+2 43880 97.5862 61.1649 0010663 88.7366 271.5103 15.43979830405549
+Sparrow
+1 43881U 18111F 26134.28189242 .00083407 00000-0 81206-3 0 9990
+2 43881 97.6124 72.1523 0007667 104.6129 255.5981 15.65962548406055
+Prox-1
+1 44339U 19036A 26133.90675889 .00008940 00000-0 88071-3 0 9997
+2 44339 23.9965 343.0870 0006559 357.6910 2.3558 14.89775846368357
+Taurus 1
+1 44530U 19059C 26134.32086882 .00002167 00000-0 35626-3 0 9994
+2 44530 98.6384 297.0637 0009370 64.5135 295.7038 14.71710768353662
+TO-108
+1 44881U 19093C 26134.25307692 .00000011 00000-0 73020-5 0 9996
+2 44881 97.7540 207.3118 0013076 192.4072 167.6824 14.86460090346378
+RS-44
+1 44909U 19096E 26134.15254353 .00000027 00000-0 69631-4 0 9993
+2 44909 82.5239 2.3248 0216682 223.7721 134.6028 12.79748134297991
+SALSAT
+1 46495U 20068K 26133.99559253 .00005344 00000-0 19079-3 0 9991
+2 46495 97.8855 134.9940 0011457 67.8052 292.4401 15.29276426310132
+CSS (TIANHE-1)
+1 48274U 21035A 26133.47815923 .00012315 00000-0 13972-3 0 9997
+2 48274 41.4670 173.0841 0004122 296.9881 63.0537 15.62173368287749
+CUTE
+1 49263U 21088D 26134.23778351 .00131280 00000-0 73961-3 0 9999
+2 49263 97.4194 230.6379 0001701 276.2054 83.9019 15.78818867257176
+TeikyoSat 4
+1 49396U 21102B 26134.04679020 .00001172 00000-0 77045-4 0 9999
+2 49396 97.3697 164.8564 0013457 55.7579 304.4923 15.09380746247579
+Z-Sat
+1 49399U 21102E 26134.31882510 .00002516 00000-0 12662-3 0 9998
+2 49399 97.3357 170.6723 0016941 11.9378 348.2254 15.17994705248309
+KOSEN 1
+1 49402U 21102H 26134.05657551 .00005025 00000-0 19577-3 0 9999
+2 49402 97.3217 176.8844 0012668 335.0334 25.0290 15.26347695248811
+HO-113
+1 50466U 21131B 26134.31646506 .00000130 00000-0 53898-4 0 9997
+2 50466 98.4958 226.8927 0003949 182.5581 177.5588 14.41322913230238
+SNUGLITE 2
+1 52899U 22065F 26134.27498682 .00000614 00000-0 12551-3 0 9998
+2 52899 98.2156 279.1757 0008599 125.6699 234.5305 14.64280683206038
+UmKA 1 (RS40S)
+1 57172U 23091G 26134.26992365 .00003795 00000-0 17706-3 0 9993
+2 57172 97.5075 193.1041 0011627 232.9896 127.0276 15.20412499158851
+CubeBel-2 (EU11S)
+1 57175U 23091K 26134.27733789 .00007675 00000-0 28065-3 0 9991
+2 57175 97.5074 197.2104 0009036 227.1006 132.9476 15.28326108159125
+RS-38S
+1 57189U 23091Z 26134.25911095 .00011170 00000-0 33198-3 0 9990
+2 57189 97.5111 203.0920 0007787 180.5665 179.5571 15.34905076159484
+SONATE-2
+1 59112U 24043Q 26133.37741957 .00025296 00000-0 36180-3 0 9994
+2 59112 97.5493 281.7198 0005913 330.7378 29.3544 15.56195234122476
+GRBBeta
+1 60237U 24128C 26133.90430372 .00002765 00000-0 19753-3 0 9996
+2 60237 61.9905 336.5219 0045211 127.6054 232.9156 15.06346661101106
+Curium One
+1 60242U 24128H 26134.24908623 .00005651 00000-0 33316-3 0 9997
+2 60242 61.9790 325.9266 0044666 124.0363 236.4986 15.11941919101322
+ROBUSTA-3A
+1 60243U 24128J 26134.12903920 .00005248 00000-0 31713-3 0 9991
+2 60243 61.9867 328.6362 0045854 121.4904 239.0684 15.11118441101271
+CatSat
+1 60246U 24125J 26134.19807845 .00037481 00000-0 55474-3 0 9991
+2 60246 97.2123 346.3542 0021333 309.0135 50.9220 15.54930068102107
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26134.25255325 .00077649 00000-0 69426-3 0 9996
+2 61772 97.2949 12.4640 0007234 59.6934 300.5042 15.68105068129347
+AO-123
+1 61781U 24199AY 26134.27579381 .00005429 00000-0 16085-3 0 9999
+2 61781 97.3050 3.2580 0015805 73.3731 286.9247 15.35157471128727
+JINJUSat 1B
+1 63210U 25052A 26134.20195039 .00010748 00000-0 34582-3 0 9996
+2 63210 97.4049 30.9349 0003120 167.0393 193.0929 15.32407586 64891
+NUSHSAT 1
+1 63211U 25052B 26134.23191203 .00013241 00000-0 39701-3 0 9998
+2 63211 97.4027 31.4212 0002801 165.0419 195.0907 15.34604895 64932
+TEVEL2-4
+1 63213U 25052D 26133.21703508 .00010651 00000-0 33272-3 0 9993
+2 63213 97.3947 29.5787 0001655 172.7980 187.3286 15.33358313 64757
+TEVEL2-5
+1 63214U 25052E 26134.27805638 .00012159 00000-0 38099-3 0 9995
+2 63214 97.3949 30.5973 0001748 170.1471 189.9805 15.33225860 64912
+TEVEL2-6
+1 63215U 25052F 26134.22429804 .00011655 00000-0 36578-3 0 9998
+2 63215 97.3950 30.5284 0001820 174.0630 186.0634 15.33187265 64904
+TEVEL2-1
+1 63217U 25052H 26134.24205557 .00011401 00000-0 36339-3 0 9993
+2 63217 97.3923 30.2093 0001265 189.7444 170.3773 15.32696559 64898
+TEVEL2-3
+1 63218U 25052J 26134.23783428 .00011527 00000-0 36683-3 0 9992
+2 63218 97.3926 30.2230 0001233 191.3858 168.7356 15.32745490 64895
+TEVEL2-2
+1 63219U 25052K 26134.24252871 .00011801 00000-0 37595-3 0 9995
+2 63219 97.3924 30.2115 0001231 193.1651 166.9559 15.32703860 64895
+TEVEL2-9
+1 63237U 25052AD 26134.24260618 .00010629 00000-0 35918-3 0 9997
+2 63237 97.3986 29.6576 0004079 257.4982 102.5802 15.30825002 64832
+TEVEL2-7
+1 63238U 25052AE 26134.27731913 .00010189 00000-0 34729-3 0 9992
+2 63238 97.3988 29.6220 0004148 257.6092 102.4684 15.30557285 64834
+TEVEL2-8
+1 63239U 25052AF 26134.21981734 .00010041 00000-0 34249-3 0 9999
+2 63239 97.3988 29.5426 0004130 259.1655 100.9121 15.30538178 64823
+HYDRA-W
+1 63490U 25052BL 26113.93882235 .05662091 24406-5 29537-2 0 9997
+2 63490 97.3690 18.2798 0008685 203.5899 156.4993 16.20186780 62336
+HADES-ICM (SO-125)
+1 63492U 25052BN 26134.22731092 .00894338 36510-3 21295-2 0 9994
+2 63492 97.3786 38.4565 0009731 172.8007 187.3411 15.96627123 65437
+SPIRONE
+1 66657U 25274H 26134.28614331 .00001661 00000-0 16335-3 0 9999
+2 66657 97.7480 64.0672 0013470 122.8851 237.3666 14.93400298 25161
+K-HERO
+1 66660U 25274L 26134.30029229 .00001265 00000-0 12437-3 0 9991
+2 66660 97.7488 64.2171 0015251 127.2445 233.0169 14.93827014 25177
+SNUGLITE-III DURI
+1 66661U 25274M 26133.35141050 .00001359 00000-0 13299-3 0 9994
+2 66661 97.7483 63.3007 0015802 131.5001 228.7578 14.93877191 25030
+SilverSat
+1 66909U 98067XV 26113.44966717 .07226154 12288-4 11979-2 0 9998
+2 66909 51.6027 190.0749 0007952 333.4666 26.5949 16.32457272 22308
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26134.16120560 .00006484 00000-0 26831-3 0 9990
+2 67290 97.3944 209.6371 0010962 114.2650 245.9734 15.24234273 20792
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26134.17747033 .00008964 00000-0 35761-3 0 9999
+2 67291 97.3943 209.7651 0010639 113.9992 246.2361 15.25356671 20800
+Ten-Koh2
+1 68261U 25241B 26134.17196803 .00004641 00000-0 20593-3 0 9995
+2 68261 51.6540 121.4680 0006314 37.7598 322.3822 15.23440018 9729
+JACK-002
+1 68417U 26067B 26134.10778649 .00004521 00000-0 21958-3 0 9995
+2 68417 97.4544 93.1367 0003691 64.8169 295.3448 15.18950457 6773
+DISCO 2
+1 68431U 26067R 26133.39586232 .00004607 00000-0 22628-3 0 9996
+2 68431 97.4580 92.4264 0004328 104.5015 255.6699 15.18547839 6668
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26132.83338234 .00011232 00000-0 55731-3 0 9990
+2 68446 97.4387 91.6989 0006910 177.1746 182.9529 15.17853429 6567
+PARUS-6U1
+1 68456U 26067AS 26133.43395027 .00003618 00000-0 18567-3 0 9996
+2 68456 97.4530 92.3479 0005913 164.9165 195.2246 15.17141812 6661
+SAL-E
+1 68458U 26067AU 26133.43325588 .00004975 00000-0 25328-3 0 9993
+2 68458 97.4457 92.3084 0005845 173.7308 186.4000 15.17248037 6661
+FSI-SAT 2
+1 68792U 26088A 26133.95021350 .00002906 00000-0 20030-3 0 9991
+2 68792 97.5027 284.0858 0013677 219.6814 140.3414 15.06542473 3135
+OrigamiSat 2
+1 68795U 26088D 26134.06264150 .00001721 00000-0 11566-3 0 9992
+2 68795 97.5031 284.2449 0015520 191.7012 168.3858 15.07998810 3155
+ARICA 2
+1 68796U 26088E 26134.32650801 .00002463 00000-0 16318-3 0 9998
+2 68796 97.5015 284.5004 0015609 189.1844 170.9101 15.08128984 3192
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26134.32563710 .00003549 00000-0 23269-3 0 9990
+2 68797 97.5013 284.5015 0015607 189.0364 171.0586 15.08222475 3196
+MANGARO-II-Piscus
+1 68798U 26088G 26134.12200801 .00002137 00000-0 14050-3 0 9998
+2 68798 97.5020 284.3159 0018894 193.6770 166.3949 15.08511423 3166
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+/EX
+SB KEPS @ AMSAT < CX2SA $ORB26142.1
+2Line Orbital Elements 26142.AMSAT
+R:260529/0106Z 4782@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260529/0046Z 9734@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260529/0023Z @:GB7CIP.#32.GBR.EURO #:60974 [Caterham Surrey GBR] $:ORB26142.1
+R:260529/0023Z @:CX2SA.SAL.URY.SOAM #:73 [Salto] FBB7.00e $:ORB26142.1
+
+From: CX2SA@CX2SA.SAL.URY.SOAM
+To : KEPS@AMSAT
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA May 22, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26141.89152713 -.00000052 00000-0 -34210-4 0 9996
+2 07530 101.9910 154.8634 0012275 179.5275 251.0103 12.53697583357222
+UO-11
+1 14781U 84021B 26141.84250610 .00000862 00000-0 93497-4 0 9998
+2 14781 97.8043 107.7160 0006032 272.5141 87.5386 14.90711392253205
+AO-27
+1 22825U 93061C 26141.70841809 .00000058 00000-0 38881-4 0 9994
+2 22825 98.6889 209.1299 0008588 170.4927 189.6419 14.30934102703218
+FO-29
+1 24278U 96046B 26141.54630569 .00000000 00000-0 34558-4 0 9999
+2 24278 98.5266 354.0642 0350132 165.4220 195.7337 13.53272944469564
+GO-32
+1 25397U 98043D 26141.86370265 .00000023 00000-0 30169-4 0 9999
+2 25397 99.0063 133.9598 0000518 348.9287 11.1880 14.24422513447583
+ISS
+1 25544U 98067A 26141.81013264 .00006598 00000-0 12646-3 0 9999
+2 25544 51.6330 70.6788 0007525 83.9033 276.2813 15.49301514567663
+NO-44
+1 26931U 01043C 26141.75766036 .00000073 00000-0 58109-4 0 9990
+2 26931 67.0507 312.6302 0006208 263.6699 96.3696 14.31944512286663
+SO-50
+1 27607U 02058C 26141.45153604 .00000579 00000-0 86191-4 0 9999
+2 27607 64.5520 211.7006 0075614 267.3643 91.8806 14.82983376260491
+CO-55
+1 27844U 03031E 26141.48326484 .00000173 00000-0 93673-4 0 9998
+2 27844 98.6743 150.3782 0008295 262.0752 97.9485 14.24317125187871
+RS-22
+1 27939U 03042A 26141.87761664 .00000548 00000-0 92749-4 0 9990
+2 27939 98.3469 325.4944 0011251 359.2209 137.0326 14.73413921211676
+CO-65
+1 32785U 08021C 26141.86265625 .00003248 00000-0 20851-3 0 9996
+2 32785 97.8271 122.7423 0010717 113.7944 246.4409 15.09165957981226
+CO-66
+1 32791U 08021J 26141.88297742 .00013533 00000-0 44391-3 0 9993
+2 32791 97.7528 138.5465 0004568 66.6536 293.5185 15.31736775983265
+RS-30
+1 32953U 08025A 26141.78213934 -.00000018 00000-0 -20207-3 0 9993
+2 32953 82.5057 11.8666 0019992 11.9172 348.2377 12.43178180816419
+SRMSAT
+1 37841U 11058D 26141.58428440 .00000353 00000-0 47856-4 0 9992
+2 37841 19.9710 220.4956 0011598 271.8763 219.5780 14.11569257754052
+ZACUBE-1
+1 39417U 13066B 26141.87673122 .00003291 00000-0 25856-3 0 9994
+2 39417 97.8118 104.0711 0040705 341.0100 18.9603 15.00961986676785
+Delfi-N3xt
+1 39428U 13066N 26141.73888310 .00004497 00000-0 39801-3 0 9992
+2 39428 97.8348 62.0799 0073127 295.6932 63.6749 14.94757646670670
+GOMX-1
+1 39430U 13066Q 26141.83256690 .00001545 00000-0 23766-3 0 9990
+2 39430 97.6495 343.9577 0129155 161.5031 199.0936 14.69341216666045
+LO-74
+1 39440U 13066AA 26141.80253712 .00002832 00000-0 26539-3 0 9991
+2 39440 97.8896 90.6771 0059474 114.1782 246.5670 14.93527149673058
+AO-73
+1 39444U 13066AE 26141.86919839 .00005987 00000-0 37656-3 0 9996
+2 39444 97.8267 112.7754 0034817 294.6838 65.0766 15.09108611675690
+DTUSAT-2
+1 40030U 14033W 26140.95697010 .00004456 00000-0 24518-3 0 9990
+2 40030 98.0869 136.9651 0007072 341.0623 19.0343 15.14617068648563
+LILACSAT-2
+1 40908U 15049K 26141.81995208 .00013073 00000-0 23086-3 0 9992
+2 40908 97.4676 177.6742 0006586 7.0571 353.0772 15.50476276591668
+Horyu-4
+1 41340U 16012D 26141.39941902 .00152227 00000-0 75460-3 0 9997
+2 41340 30.9883 273.2630 0004037 95.4050 264.7068 15.80437185566557
+Lapan A3
+1 41603U 16040E 26141.88598591 .00002428 00000-0 78581-4 0 9991
+2 41603 97.1490 138.9011 0012205 107.0499 253.2082 15.32918160550782
+CAS-2T
+1 41847U 16066G 26141.78179894 .00000702 00000-0 10806-3 0 9997
+2 41847 98.3826 217.8178 0341518 209.5069 148.6462 14.44603131500989
+TechnoSat
+1 42829U 17042E 26141.38610641 .00002891 00000-0 20850-3 0 9990
+2 42829 97.4262 300.0717 0017801 181.5124 178.6051 15.04771569482674
+AO-91
+1 43017U 17073E 26141.54623661 .00006694 00000-0 29382-3 0 9992
+2 43017 97.4738 9.3125 0153649 60.9980 300.6551 15.12173908461362
+S-Net D
+1 43186U 18014G 26141.67333441 .00003457 00000-0 18134-3 0 9990
+2 43186 97.5379 46.6323 0010015 106.7482 253.4851 15.16385485454741
+S-Net B
+1 43187U 18014H 26141.61828139 .00003519 00000-0 18463-3 0 9992
+2 43187 97.5386 46.5632 0010719 103.2638 256.9791 15.16355227454739
+S-Net A
+1 43188U 18014J 26141.73833551 .00003474 00000-0 18216-3 0 9996
+2 43188 97.5396 46.8859 0010611 103.6735 256.5680 15.16393215454752
+S-Net C
+1 43189U 18014K 26141.68800722 .00003442 00000-0 18066-3 0 9993
+2 43189 97.5413 46.9069 0012057 97.7770 262.4832 15.16346650453299
+Ten-Koh
+1 43677U 18084G 26141.49153061 .00001539 00000-0 11988-3 0 9999
+2 43677 98.0751 332.7324 0009135 203.4589 156.6219 15.02795007412151
+PO-101
+1 43678U 18084H 26141.82700002 .00002360 00000-0 19327-3 0 9998
+2 43678 98.1118 336.9011 0011627 261.1148 98.8758 15.00309933412264
+QO-100
+1 43700U 18090A 26141.73891693 .00000136 00000-0 00000+0 0 9991
+2 43700 0.0119 347.9404 0001349 100.4780 82.7575 1.00271059 27418
+MinXSS-2
+1 43758U 18099A 26141.74775839 .00023125 00000-0 49168-3 0 9992
+2 43758 97.4540 217.2957 0006547 11.5602 348.5796 15.44974995410046
+AO-95
+1 43770U 18099N 26141.59313666 .00007731 00000-0 30248-3 0 9999
+2 43770 97.4396 201.9481 0010395 85.8622 274.3805 15.26058773409168
+SNUSat 2
+1 43782U 18099AA 26141.56836654 .00005832 00000-0 26281-3 0 9998
+2 43782 97.4073 195.3675 0010967 38.4282 321.7733 15.21375889408986
+SnugLite
+1 43784U 18099AC 26141.60157704 .00007547 00000-0 29165-3 0 9996
+2 43784 97.3882 196.1536 0003612 53.2641 306.8929 15.26520754409264
+ITASat 1
+1 43786U 18099AE 26141.73538553 .00004558 00000-0 22259-3 0 9993
+2 43786 97.4045 193.7797 0014358 86.9902 273.2975 15.18667175408898
+EAGLET 1
+1 43790U 18099AJ 26141.13245321 .00002627 00000-0 15344-3 0 9992
+2 43790 97.4247 191.5196 0012850 81.8339 278.4349 15.12703873408240
+ESEO
+1 43792U 18099AL 26141.10572414 .00001059 00000-0 80377-4 0 9994
+2 43792 97.4000 179.6526 0013701 69.9510 290.3190 15.04156075407734
+JO-97
+1 43803U 18099AX 26141.72848380 .00011251 00000-0 35840-3 0 9992
+2 43803 97.4140 204.4876 0005467 22.6895 337.4587 15.32706710409574
+Suomi 100
+1 43804U 18099AY 26141.81647368 .00008719 00000-0 32407-3 0 9997
+2 43804 97.4200 202.3189 0010122 23.9931 336.1778 15.27729140409399
+ISAT
+1 43879U 18111D 26141.78319963 .00057382 00000-0 69351-3 0 9995
+2 43879 97.5897 75.0721 0007053 65.3868 294.8123 15.60515348407043
+UWE-4
+1 43880U 18111E 26141.72946507 .00021785 00000-0 47342-3 0 9995
+2 43880 97.5858 68.9379 0010233 68.3750 291.8587 15.44310525406692
+Sparrow
+1 43881U 18111F 26141.81929056 .00086100 00000-0 79727-3 0 9990
+2 43881 97.6126 80.3102 0007210 94.7597 265.4487 15.67209694407233
+Prox-1
+1 44339U 19036A 26141.54213877 .00009146 00000-0 89870-3 0 9998
+2 44339 23.9960 292.1475 0006798 81.8956 278.2314 14.89902593369499
+Taurus 1
+1 44530U 19059C 26141.86741959 .00003500 00000-0 56900-3 0 9994
+2 44530 98.6406 305.0718 0008930 42.8814 317.3085 14.71769982354779
+TO-108
+1 44881U 19093C 26141.85969586 -.00000232 00000-0 -20224-4 0 9990
+2 44881 97.7532 214.7332 0013733 167.3742 192.7820 14.86466872347509
+RS-44
+1 44909U 19096E 26141.57978244 .00000020 00000-0 37434-4 0 9998
+2 44909 82.5229 357.3892 0216970 206.3471 152.6467 12.79748401298947
+SALSAT
+1 46495U 20068K 26141.45465465 .00005535 00000-0 19705-3 0 9990
+2 46495 97.8859 142.9019 0010937 45.0571 315.1553 15.29356447311277
+CSS (TIANHE-1)
+1 48274U 21035A 26141.86139679 .00009577 00000-0 11571-3 0 9995
+2 48274 41.4679 122.0798 0007426 275.1763 84.8228 15.60726635289054
+CUTE
+1 49263U 21088D 26141.77701957 .00104987 00000-0 55473-3 0 9996
+2 49263 97.4176 238.7459 0002517 261.7104 98.3878 15.80314088258369
+TeikyoSat 4
+1 49396U 21102B 26141.07393993 .00001072 00000-0 70775-4 0 9994
+2 49396 97.3690 171.6111 0012889 33.7440 326.4607 15.09398905248634
+Z-Sat
+1 49399U 21102E 26141.83340809 .00002899 00000-0 14527-3 0 9999
+2 49399 97.3339 177.9580 0016065 345.5214 14.5557 15.18038034249442
+KOSEN 1
+1 49402U 21102H 26141.85779153 .00005354 00000-0 20798-3 0 9990
+2 49402 97.3205 184.5316 0012043 304.3232 55.6867 15.26424129250002
+HO-113
+1 50466U 21131B 26141.88332479 .00000115 00000-0 49326-4 0 9992
+2 50466 98.4966 234.4170 0004419 160.9363 199.1992 14.41328020231328
+SNUGLITE 2
+1 52899U 22065F 26141.85999623 .00000631 00000-0 12885-3 0 9990
+2 52899 98.2171 286.7433 0008793 105.1519 255.0657 14.64290315207144
+UmKA 1 (RS40S)
+1 57172U 23091G 26141.83835531 .00004599 00000-0 21342-3 0 9999
+2 57172 97.5061 200.6414 0012270 204.4014 155.6641 15.20472652160005
+CubeBel-2 (EU11S)
+1 57175U 23091K 26141.87192961 .00008857 00000-0 32211-3 0 9997
+2 57175 97.5060 204.8660 0009734 198.6703 161.4181 15.28450630160280
+RS-38S
+1 57189U 23091Z 26141.82106138 .00012237 00000-0 36136-3 0 9995
+2 57189 97.5098 210.7952 0008418 156.3405 203.8227 15.35078461160642
+SONATE-2
+1 59112U 24043Q 26141.86405082 .00026703 00000-0 37559-3 0 9998
+2 59112 97.5516 290.6923 0005753 293.3199 66.7449 15.56638828123790
+GRBBeta
+1 60237U 24128C 26141.80354678 .00003354 00000-0 23629-3 0 9990
+2 60237 61.9903 308.8177 0044286 129.2550 231.2486 15.06394080102296
+Curium One
+1 60242U 24128H 26141.85443346 .00006924 00000-0 40435-3 0 9992
+2 60242 61.9792 299.0105 0043832 125.6330 234.8861 15.12038990102470
+ROBUSTA-3A
+1 60243U 24128J 26141.87088968 .00006530 00000-0 39048-3 0 9991
+2 60243 61.9870 301.2784 0045146 122.9128 237.6322 15.11209692102440
+CatSat
+1 60246U 24125J 26141.53317328 .00035477 00000-0 51485-3 0 9990
+2 60246 97.2111 353.7482 0021099 279.4556 80.4314 15.55483221103248
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26141.84364228 .00082311 00000-0 70146-3 0 9995
+2 61772 97.2925 20.3602 0005651 37.2681 322.8973 15.69279437130535
+AO-123
+1 61781U 24199AY 26141.83672274 .00005885 00000-0 17373-3 0 9991
+2 61781 97.3031 10.7481 0015304 49.0240 311.2325 15.35242025129885
+JINJUSat 1B
+1 63210U 25052A 26141.64564802 .00010985 00000-0 35152-3 0 9997
+2 63210 97.4028 38.3793 0004023 146.4632 213.6865 15.32573634 66037
+NUSHSAT 1
+1 63211U 25052B 26141.73005961 .00013995 00000-0 41664-3 0 9993
+2 63211 97.4003 38.9429 0003768 145.3109 214.8381 15.34814142 66080
+TEVEL2-4
+1 63213U 25052D 26141.70008453 .00012425 00000-0 38506-3 0 9999
+2 63213 97.3928 38.0639 0002747 152.6877 207.4511 15.33570225 66050
+TEVEL2-5
+1 63214U 25052E 26141.65247975 .00012280 00000-0 38252-3 0 9995
+2 63214 97.3927 37.9715 0002665 152.7100 207.4282 15.33409785 66048
+TEVEL2-6
+1 63215U 25052F 26141.59890998 .00012324 00000-0 38436-3 0 9991
+2 63215 97.3928 37.9026 0002776 153.8216 206.3167 15.33369876 66033
+TEVEL2-1
+1 63217U 25052H 26141.42319646 .00011240 00000-0 35637-3 0 9997
+2 63217 97.3904 37.3820 0002251 164.9944 195.1365 15.32869635 65990
+TEVEL2-3
+1 63218U 25052J 26141.22291692 .00011634 00000-0 36824-3 0 9992
+2 63218 97.3903 37.2007 0002198 167.5509 192.5788 15.32914108 65965
+TEVEL2-2
+1 63219U 25052K 26141.42364117 .00011935 00000-0 37813-3 0 9991
+2 63219 97.3905 37.3842 0002173 166.3510 193.7791 15.32876877 65998
+TEVEL2-9
+1 63237U 25052AD 26141.69399681 .00010037 00000-0 33761-3 0 9994
+2 63237 97.3962 37.0853 0004554 220.1881 139.9024 15.30988116 65972
+TEVEL2-7
+1 63238U 25052AE 26141.66464890 .00010491 00000-0 35574-3 0 9995
+2 63238 97.3967 36.9830 0004687 220.4803 139.6090 15.30715220 65968
+TEVEL2-8
+1 63239U 25052AF 26140.95351763 .00010564 00000-0 35857-3 0 9996
+2 63239 97.3969 36.2522 0004539 224.9979 135.0895 15.30681443 65851
+HYDRA-W
+1 63490U 25052BL 26113.93882235 .05662091 24406-5 29537-2 0 9997
+2 63490 97.3690 18.2798 0008685 203.5899 156.4993 16.20186780 62336
+HADES-ICM (SO-125)
+1 63492U 25052BN 26141.26653903 .06532167 24596-5 20834-2 0 9996
+2 63492 97.3646 46.2798 0012082 212.8267 147.2275 16.26141053 66568
+SPIRONE
+1 66657U 25274H 26141.79040404 .00001052 00000-0 10537-3 0 9999
+2 66657 97.7480 71.4620 0013729 100.5421 259.7346 14.93419495 26285
+K-HERO
+1 66660U 25274L 26141.80242635 .00001206 00000-0 11874-3 0 9991
+2 66660 97.7487 71.6153 0015561 104.7426 255.5519 14.93842995 26298
+SNUGLITE-III DURI
+1 66661U 25274M 26141.79101138 .00000814 00000-0 81764-4 0 9992
+2 66661 97.7484 71.6237 0016141 105.7130 254.5871 14.93895840 26294
+SilverSat
+1 66909U 98067XV 26113.44966717 .07226154 12288-4 11979-2 0 9998
+2 66909 51.6027 190.0749 0007952 333.4666 26.5949 16.32457272 22308
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26141.84186571 .00007108 00000-0 29292-3 0 9995
+2 67290 97.3934 217.2158 0010944 91.5192 268.7299 15.24338989 21965
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26141.85237523 .00010095 00000-0 40054-3 0 9999
+2 67291 97.3934 217.3513 0010543 91.2168 269.0277 15.25506329 21974
+Ten-Koh2
+1 68261U 25241B 26141.12527701 .00004925 00000-0 21723-3 0 9994
+2 68261 51.6590 88.3906 0006535 60.8298 299.3333 15.23508494 10786
+JACK-002
+1 68417U 26067B 26141.81522266 .00004908 00000-0 23765-3 0 9990
+2 68417 97.4556 100.7423 0003163 50.4395 309.7119 15.19019063 7945
+DISCO 2
+1 68431U 26067R 26141.10534248 .00003864 00000-0 19000-3 0 9998
+2 68431 97.4593 100.0329 0004419 89.6647 270.5094 15.18609810 7838
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26140.67798287 .00011372 00000-0 56129-3 0 9996
+2 68446 97.4403 99.4112 0008038 151.4172 208.7504 15.18027540 7751
+PARUS-6U1
+1 68456U 26067AS 26141.87608873 .00003921 00000-0 20057-3 0 9993
+2 68456 97.4542 100.6536 0006757 140.1256 220.0474 15.17203197 7942
+SAL-E
+1 68458U 26067AU 26141.87474542 .00005282 00000-0 26802-3 0 9995
+2 68458 97.4468 100.6069 0006783 147.4956 212.6697 15.17331417 7949
+FSI-SAT 2
+1 68792U 26088A 26141.38906227 .00002320 00000-0 16051-3 0 9990
+2 68792 97.5040 291.3318 0014293 193.2995 166.7857 15.06579140 4252
+OrigamiSat 2
+1 68795U 26088D 26141.82610571 .00003064 00000-0 20247-3 0 9994
+2 68795 97.5052 291.8243 0016239 165.9427 194.2256 15.08035037 4329
+ARICA 2
+1 68796U 26088E 26141.35945580 .00003487 00000-0 22903-3 0 9994
+2 68796 97.5034 291.3665 0016243 165.9205 194.2479 15.08169624 4251
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26141.82250461 .00004979 00000-0 32419-3 0 9994
+2 68797 97.5038 291.8216 0016237 164.2395 195.9342 15.08287059 4326
+MANGARO-II-Piscus
+1 68798U 26088G 26141.81648167 .00003064 00000-0 19936-3 0 9991
+2 68798 97.5044 291.8334 0019636 167.4894 192.6826 15.08555862 4321
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+/EX
+SB KEPS @ AMSAT < CX2SA $ORB26149.1
+2Line Orbital Elements 26149.AMSAT
+R:260529/0106Z 4783@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260529/0052Z 9735@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260529/0023Z @:GB7CIP.#32.GBR.EURO #:60975 [Caterham Surrey GBR] $:ORB26149.1
+R:260529/0023Z @:CX2SA.SAL.URY.SOAM #:74 [Salto] FBB7.00e $:ORB26149.1
+
+From: CX2SA@CX2SA.SAL.URY.SOAM
+To : KEPS@AMSAT
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA May 29, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26148.68365646 -.00000025 00000-0 13174-3 0 9995
+2 07530 101.9904 161.7267 0012369 166.6777 305.8931 12.53697774358075
+UO-11
+1 14781U 84021B 26148.82330466 .00001297 00000-0 13772-3 0 9991
+2 14781 97.8046 114.6166 0006142 243.2950 116.7639 14.90729732254244
+AO-27
+1 22825U 93061C 26148.77076877 .00000123 00000-0 63944-4 0 9994
+2 22825 98.6886 216.1905 0008965 150.9812 209.1870 14.30936282704224
+FO-29
+1 24278U 96046B 26148.57030653 -.00000005 00000-0 28278-4 0 9995
+2 24278 98.5259 0.1280 0350429 147.2181 215.1239 13.53273393470510
+GO-32
+1 25397U 98043D 26148.53681058 .00000081 00000-0 55113-4 0 9995
+2 25397 99.0064 140.8007 0000236 298.0925 62.0229 14.24424102448531
+ISS
+1 25544U 98067A 26148.77610718 .00012346 00000-0 22817-3 0 9997
+2 25544 51.6335 36.1959 0007359 108.4856 251.6933 15.49449908568746
+NO-44
+1 26931U 01043C 26148.81209367 .00000169 00000-0 93778-4 0 9990
+2 26931 67.0511 294.3837 0006149 263.8462 96.1940 14.31947852287673
+SO-50
+1 27607U 02058C 26148.53219867 .00001100 00000-0 14688-3 0 9991
+2 27607 64.5510 189.7958 0075580 266.0702 93.1761 14.82999121261541
+CO-55
+1 27844U 03031E 26148.01640198 .00000320 00000-0 15756-3 0 9994
+2 27844 98.6738 156.8292 0008429 240.4784 119.5555 14.24321573188801
+RS-22
+1 27939U 03042A 26148.86682975 .00001040 00000-0 16855-3 0 9994
+2 27939 98.3468 332.6813 0010777 336.6026 130.4585 14.73427763212706
+CO-65
+1 32785U 08021C 26148.89066185 .00007421 00000-0 46976-3 0 9999
+2 32785 97.8263 129.9120 0010674 94.1173 266.1275 15.09240418982281
+CO-66
+1 32791U 08021J 26148.54585692 .00023250 00000-0 75397-3 0 9994
+2 32791 97.7513 145.5173 0003780 53.4425 306.7163 15.31983522984289
+RS-30
+1 32953U 08025A 26148.78373154 -.00000054 00000-0 -45884-3 0 9999
+2 32953 82.5060 7.5120 0019700 356.9226 3.1729 12.43177991817282
+SRMSAT
+1 37841U 11058D 26148.42092105 .00000400 00000-0 73149-4 0 9994
+2 37841 19.9700 179.1124 0011731 347.7094 40.3515 14.11570911755020
+ZACUBE-1
+1 39417U 13066B 26148.87642683 .00005972 00000-0 46440-3 0 9999
+2 39417 97.8103 111.1083 0040101 316.2311 43.5736 15.01029548677836
+Delfi-N3xt
+1 39428U 13066N 26148.76757691 .00007990 00000-0 70069-3 0 9991
+2 39428 97.8344 69.0996 0073199 271.6037 87.6800 14.94844521671721
+GOMX-1
+1 39430U 13066Q 26148.84680012 .00003215 00000-0 48530-3 0 9999
+2 39430 97.6495 350.5304 0129712 139.1167 221.9857 14.69373058667077
+LO-74
+1 39440U 13066AA 26148.83709315 .00004620 00000-0 42866-3 0 9994
+2 39440 97.8895 97.7376 0059393 91.4996 269.3028 14.93584719674103
+AO-73
+1 39444U 13066AE 26148.43326745 .00008280 00000-0 51776-3 0 9992
+2 39444 97.8263 119.4718 0034371 271.1115 88.6176 15.09206063676689
+DTUSAT-2
+1 40030U 14033W 26148.22384446 .00008619 00000-0 46890-3 0 9996
+2 40030 98.0859 144.6884 0006395 311.5464 48.5217 15.14718184649668
+LILACSAT-2
+1 40908U 15049K 26148.85412546 .00022151 00000-0 38618-3 0 9996
+2 40908 97.4669 184.9687 0005796 338.1119 21.9884 15.50727940592750
+Horyu-4
+1 41340U 16012D 26148.34021308 .00240730 00000-0 10388-2 0 9992
+2 41340 30.9866 223.3388 0002740 145.1105 214.9733 15.83201679567655
+Lapan A3
+1 41603U 16040E 26148.87057921 .00004216 00000-0 13447-3 0 9990
+2 41603 97.1481 145.6537 0012231 86.1537 274.1104 15.32966610551858
+CAS-2T
+1 41847U 16066G 26148.77764153 .00001733 00000-0 25161-3 0 9996
+2 41847 98.3824 224.7347 0341901 188.2677 171.2793 14.44624693501993
+TechnoSat
+1 42829U 17042E 26148.70069044 .00004191 00000-0 29983-3 0 9999
+2 42829 97.4267 307.1053 0018546 155.3709 204.8408 15.04824864483772
+AO-91
+1 43017U 17073E 26148.56006240 .00012922 00000-0 56294-3 0 9992
+2 43017 97.4742 16.1803 0152762 37.0143 324.1509 15.12320639462424
+S-Net D
+1 43186U 18014G 26148.66793147 .00006686 00000-0 34659-3 0 9996
+2 43186 97.5387 53.5818 0010111 87.0654 273.1736 15.16459202455803
+S-Net B
+1 43187U 18014H 26148.67900475 .00006998 00000-0 36286-3 0 9996
+2 43187 97.5391 53.5788 0010681 83.1149 277.1299 15.16428966455804
+S-Net A
+1 43188U 18014J 26148.66691087 .00006680 00000-0 34619-3 0 9998
+2 43188 97.5403 53.7719 0010628 83.8253 276.4190 15.16466597455803
+S-Net C
+1 43189U 18014K 26148.68277963 .00007111 00000-0 36860-3 0 9994
+2 43189 97.5418 53.8593 0011927 77.4704 282.7862 15.16420368454355
+Ten-Koh
+1 43677U 18084G 26148.74909503 .00003648 00000-0 27699-3 0 9993
+2 43677 98.0760 340.2933 0009591 179.6897 180.4334 15.02836920413247
+PO-101
+1 43678U 18084H 26148.82979715 .00003523 00000-0 28557-3 0 9991
+2 43678 98.1141 344.2034 0011678 235.9932 124.0181 15.00347986413312
+QO-100
+1 43700U 18090A 26148.51188272 .00000154 00000-0 00000+0 0 9996
+2 43700 0.0155 298.2229 0001907 160.0872 357.8371 1.00274787 27483
+MinXSS-2
+1 43758U 18099A 26148.67697507 .00042524 00000-0 88596-3 0 9998
+2 43758 97.4547 224.4097 0006137 341.9445 18.1584 15.45450503411117
+AO-95
+1 43770U 18099N 26148.41212235 .00014430 00000-0 55904-3 0 9997
+2 43770 97.4401 208.7367 0009949 65.0064 295.2206 15.26219774410200
+SNUSat 2
+1 43782U 18099AA 26148.67148074 .00010482 00000-0 46802-3 0 9997
+2 43782 97.4076 202.3582 0010258 14.4388 345.7139 15.21497847410066
+SnugLite
+1 43784U 18099AC 26148.68068441 .00015114 00000-0 57784-3 0 9997
+2 43784 97.3887 203.1578 0002910 33.4447 326.6975 15.26690104410347
+ITASat 1
+1 43786U 18099AE 26148.65354541 .00008478 00000-0 40994-3 0 9995
+2 43786 97.4043 200.5573 0014008 65.5105 294.7588 15.18767796409940
+EAGLET 1
+1 43790U 18099AJ 26148.40868609 .00005424 00000-0 31233-3 0 9992
+2 43790 97.4248 198.6021 0012501 59.6601 300.5864 15.12764837409342
+ESEO
+1 43792U 18099AL 26148.55639080 .00001516 00000-0 11324-3 0 9996
+2 43792 97.3987 186.7856 0013479 47.4437 312.7925 15.04179490408858
+JO-97
+1 43803U 18099AX 26148.45249796 .00021394 00000-0 67363-3 0 9999
+2 43803 97.4144 211.2270 0004799 356.8750 3.2461 15.32936130410607
+Suomi 100
+1 43804U 18099AY 26148.69347025 .00015570 00000-0 57304-3 0 9993
+2 43804 97.4202 209.1644 0009384 358.7874 1.3340 15.27907126410441
+ISAT
+1 43879U 18111D 26148.77033215 .00099392 00000-0 11437-2 0 9992
+2 43879 97.5897 82.5500 0005278 54.4708 305.7041 15.61655786408134
+UWE-4
+1 43880U 18111E 26148.53214294 .00041738 00000-0 88982-3 0 9997
+2 43880 97.5861 76.0364 0009322 49.7202 310.4860 15.44751526407741
+Sparrow
+1 43881U 18111F 26148.77566278 .00140372 00000-0 12093-2 0 9999
+2 43881 97.6129 87.8561 0006122 91.5091 268.6871 15.68825146408322
+Prox-1
+1 44339U 19036A 26148.57398135 .00017006 00000-0 16864-2 0 9995
+2 44339 23.9951 245.2202 0006156 159.0032 201.0721 14.90088160370548
+Taurus 1
+1 44530U 19059C 26148.86974652 .00009760 00000-0 15662-2 0 9992
+2 44530 98.6396 312.5048 0008388 21.7580 338.3980 14.71859694355801
+TO-108
+1 44881U 19093C 26148.86042750 .00000286 00000-0 38372-4 0 9993
+2 44881 97.7538 221.5637 0014282 145.3370 214.8780 14.86479729348543
+RS-44
+1 44909U 19096E 26148.61613539 .00000037 00000-0 10244-3 0 9990
+2 44909 82.5224 352.7128 0217275 189.8719 169.8081 12.79748512299847
+SALSAT
+1 46495U 20068K 26148.52069951 .00009688 00000-0 34141-3 0 9999
+2 46495 97.8848 150.3933 0010184 22.3559 337.8122 15.29469861312359
+CSS (TIANHE-1)
+1 48274U 21035A 26148.77594543 .00021900 00000-0 26673-3 0 9990
+2 48274 41.4691 80.0564 0010822 299.1255 60.8500 15.59924596290130
+CUTE
+1 49263U 21088D 26148.79840676 .00368502 00000-0 15907-2 0 9999
+2 49263 97.4180 246.3233 0004727 262.7661 97.3071 15.84008468259476
+TeikyoSat 4
+1 49396U 21102B 26148.63132855 .00002398 00000-0 15353-3 0 9993
+2 49396 97.3682 178.8750 0012174 8.8859 351.2583 15.09428445249775
+Z-Sat
+1 49399U 21102E 26148.88634389 .00005721 00000-0 28299-3 0 9998
+2 49399 97.3342 184.7954 0015306 319.5392 40.4703 15.18099327250515
+KOSEN 1
+1 49402U 21102H 26148.67528051 .00009321 00000-0 35879-3 0 9990
+2 49402 97.3202 191.2142 0011881 276.6683 83.3203 15.26525652251041
+HO-113
+1 50466U 21131B 26148.82536716 .00000634 00000-0 20949-3 0 9998
+2 50466 98.4969 241.3208 0004823 143.2126 216.9395 14.41336393232328
+SNUGLITE 2
+1 52899U 22065F 26148.35161759 .00001144 00000-0 22588-3 0 9994
+2 52899 98.2176 293.2207 0008783 87.7163 272.5045 14.64304338208091
+UmKA 1 (RS40S)
+1 57172U 23091G 26148.81414992 .00007663 00000-0 35239-3 0 9993
+2 57172 97.5065 207.5880 0012940 179.9643 180.1595 15.20560608161067
+CubeBel-2 (EU11S)
+1 57175U 23091K 26148.81116044 .00016305 00000-0 58680-3 0 9991
+2 57175 97.5066 211.8613 0010370 175.2112 184.9228 15.28627391161345
+RS-38S
+1 57189U 23091Z 26148.79540465 .00022191 00000-0 64748-3 0 9993
+2 57189 97.5106 217.9009 0008742 135.2065 224.9886 15.35319597161714
+SONATE-2
+1 59112U 24043Q 26148.67707366 .00043489 00000-0 59844-3 0 9995
+2 59112 97.5509 297.9020 0006022 265.6576 94.3991 15.57131288124857
+GRBBeta
+1 60237U 24128C 26148.77319951 .00006129 00000-0 41875-3 0 9994
+2 60237 61.9905 284.3720 0043256 130.6766 229.8099 15.06464472103344
+Curium One
+1 60242U 24128H 26148.79791903 .00011939 00000-0 68509-3 0 9991
+2 60242 61.9791 274.4322 0042578 126.8997 233.6012 15.12176846103520
+ROBUSTA-3A
+1 60243U 24128J 26148.68586595 .00012229 00000-0 71683-3 0 9999
+2 60243 61.9868 277.1927 0043922 124.4610 236.0647 15.11344265103473
+CatSat
+1 60246U 24125J 26148.67236620 .00065667 00000-0 92216-3 0 9998
+2 60246 97.2108 0.9523 0021270 250.7778 109.1176 15.56236887104353
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26148.85483175 .00138195 00000-0 10991-2 0 9999
+2 61772 97.2921 27.6674 0003687 10.2238 349.9099 15.70790228131635
+AO-123
+1 61781U 24199AY 26148.81059139 .00009970 00000-0 29163-3 0 9994
+2 61781 97.3031 17.6583 0014548 25.6249 334.5713 15.35355248130953
+JINJUSat 1B
+1 63210U 25052A 26148.69668487 .00020242 00000-0 64015-3 0 9990
+2 63210 97.4034 45.4333 0004665 131.9188 228.2452 15.32808610 67119
+NUSHSAT 1
+1 63211U 25052B 26148.70550888 .00026274 00000-0 77167-3 0 9991
+2 63211 97.4011 45.9434 0004495 130.8260 229.3374 15.35104999 67153
+TEVEL2-4
+1 63213U 25052D 26148.68124973 .00023968 00000-0 73335-3 0 9992
+2 63213 97.3938 45.0491 0003528 140.3779 219.7722 15.33831159 67123
+TEVEL2-5
+1 63214U 25052E 26148.69962565 .00023580 00000-0 72521-3 0 9997
+2 63214 97.3928 45.0208 0003471 140.3980 219.7517 15.33670851 67122
+TEVEL2-6
+1 63215U 25052F 26148.64624072 .00023559 00000-0 72551-3 0 9990
+2 63215 97.3933 44.9521 0003570 139.8705 220.2801 15.33629270 67114
+TEVEL2-1
+1 63217U 25052H 26148.66865836 .00022715 00000-0 71086-3 0 9994
+2 63217 97.3909 44.6216 0003165 150.6260 209.5161 15.33125593 67101
+TEVEL2-3
+1 63218U 25052J 26148.66397624 .00023680 00000-0 73967-3 0 9992
+2 63218 97.3912 44.6365 0003202 151.4818 208.6600 15.33176175 67101
+TEVEL2-2
+1 63219U 25052K 26148.66907352 .00022982 00000-0 71899-3 0 9994
+2 63219 97.3907 44.6240 0003131 150.8682 209.2735 15.33132523 67106
+TEVEL2-9
+1 63237U 25052AD 26148.68699082 .00020217 00000-0 67173-3 0 9993
+2 63237 97.3970 44.0585 0005423 191.1044 169.0079 15.31217216 67046
+TEVEL2-7
+1 63238U 25052AE 26148.65890152 .00020539 00000-0 68825-3 0 9994
+2 63238 97.3974 43.9544 0005553 192.3174 167.7932 15.30937887 67039
+TEVEL2-8
+1 63239U 25052AF 26148.66694315 .00020842 00000-0 69869-3 0 9995
+2 63239 97.3975 43.9402 0005569 192.5059 167.6045 15.30922045 67039
+SPIRONE
+1 66657U 25274H 26148.75853310 .00003185 00000-0 30779-3 0 9999
+2 66657 97.7484 78.3288 0013900 80.3676 279.9113 14.93453945 27323
+K-HERO
+1 66660U 25274L 26148.76857758 .00002432 00000-0 23371-3 0 9998
+2 66660 97.7491 78.4855 0015654 83.7336 276.5666 14.93875998 27337
+SNUGLITE-III DURI
+1 66661U 25274M 26148.75693051 .00002556 00000-0 24503-3 0 9997
+2 66661 97.7488 78.4940 0016261 84.8421 275.4655 14.93925849 27338
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26148.66858785 .00013001 00000-0 53080-3 0 9996
+2 67290 97.3943 223.9520 0010528 70.6399 289.5976 15.24480882 23007
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26148.67375939 .00018440 00000-0 72421-3 0 9995
+2 67291 97.3942 224.0945 0010122 70.1259 290.1069 15.25706480 23018
+Ten-Koh2
+1 68261U 25241B 26148.47171900 .00009225 00000-0 39303-3 0 9996
+2 68261 51.6638 53.4412 0006592 83.8236 276.3493 15.23628586 11906
+JACK-002
+1 68417U 26067B 26148.86353296 .00008552 00000-0 41038-3 0 9999
+2 68417 97.4553 107.6980 0002512 39.0818 321.0597 15.19116562 9015
+DISCO 2
+1 68431U 26067R 26148.81438544 .00010749 00000-0 52041-3 0 9997
+2 68431 97.4589 107.6397 0004230 76.7993 283.3713 15.18736327 9008
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26148.45558498 .00022066 00000-0 10761-2 0 9991
+2 68446 97.4395 107.0599 0008859 130.8185 229.3819 15.18292837 8934
+PARUS-6U1
+1 68456U 26067AS 26148.86691810 .00006822 00000-0 34553-3 0 9991
+2 68456 97.4539 107.5323 0007297 121.3380 238.8569 15.17283855 9007
+SAL-E
+1 68458U 26067AU 26148.66709854 .00009547 00000-0 47993-3 0 9998
+2 68458 97.4466 107.2851 0007446 128.4198 231.7705 15.17436598 8975
+FSI-SAT 2
+1 68792U 26088A 26148.36277436 .00006323 00000-0 42937-3 0 9997
+2 68792 97.5038 298.1253 0014845 170.5781 189.5728 15.06643966 5301
+OrigamiSat 2
+1 68795U 26088D 26147.93040222 .00003942 00000-0 25836-3 0 9996
+2 68795 97.5091 297.7874 0016567 145.3253 214.9059 15.08166526 5241
+ARICA 2
+1 68796U 26088E 26148.85656116 .00005383 00000-0 35052-3 0 9996
+2 68796 97.5031 298.6883 0016816 141.1790 219.0650 15.08239362 5380
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26148.85459716 .00007882 00000-0 50925-3 0 9996
+2 68797 97.5028 298.6905 0016700 141.1913 219.0518 15.08378637 5383
+MANGARO-II-Piscus
+1 68798U 26088G 26148.84740205 .00005232 00000-0 33690-3 0 9999
+2 68798 97.5036 298.7042 0020094 144.5869 215.6698 15.08612429 5385
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+/EX
+SB KEPS @ AMSAT < CX2SA $ORB26156.1
+2Line Orbital Elements 26156.AMSAT
+R:260612/0151Z 5215@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260612/0119Z 10175@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260612/0110Z 55206@EI2GYB.DGL.IRL.EURO LinBPQ6.0.25
+R:260612/0026Z 45022@PY2BIL.SP.BRA.SOAM LinBPQ6.0.25
+R:260612/0025Z @:PI8ZTM.#ZH1.NLD.EURO #:55606 [Den Haag] $:ORB26156.1
+R:260612/0024Z @:CX2SA.SAL.URY.SOAM #:600 [Salto] FBB7.00e $:ORB26156.1
+
+From: CX2SA@CX2SA.SAL.URY.SOAM
+To : KEPS@AMSAT
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA June 05, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26155.29739884 -.00000046 00000-0 32849-5 0 9994
+2 07530 101.9902 168.4095 0012424 154.1272 275.7064 12.53697884358906
+UO-11
+1 14781U 84021B 26155.73688471 .00001488 00000-0 15713-3 0 9990
+2 14781 97.8050 121.4515 0006538 216.3990 143.6784 14.90752353255276
+AO-27
+1 22825U 93061C 26155.13386559 .00000145 00000-0 72223-4 0 9997
+2 22825 98.6882 222.5517 0009250 133.7828 226.4121 14.30938744705131
+FO-29
+1 24278U 96046B 26155.07670467 -.00000029 00000-0 38850-5 0 9995
+2 24278 98.5251 5.7442 0350656 130.3680 232.8639 13.53273623471395
+GO-32
+1 25397U 98043D 26154.57772251 .00000069 00000-0 49972-4 0 9994
+2 25397 99.0064 146.9934 0000319 213.6137 146.5021 14.24425649449397
+ISS
+1 25544U 98067A 26155.74133726 .00008168 00000-0 15298-3 0 9993
+2 25544 51.6329 1.7083 0007031 132.5880 227.5702 15.49603626569822
+NO-44
+1 26931U 01043C 26154.60928777 .00000163 00000-0 91734-4 0 9991
+2 26931 67.0512 279.3895 0006115 263.9670 96.0735 14.31950876288500
+SO-50
+1 27607U 02058C 26154.26409835 .00001126 00000-0 14986-3 0 9993
+2 27607 64.5505 172.0623 0075520 265.0164 94.2317 14.83015002262395
+CO-55
+1 27844U 03031E 26154.54951729 .00000336 00000-0 16425-3 0 9995
+2 27844 98.6736 163.2800 0008691 219.4250 140.6297 14.24327019189733
+RS-22
+1 27939U 03042A 26155.86215742 .00000987 00000-0 16033-3 0 9993
+2 27939 98.3466 339.8730 0010362 313.4523 157.2500 14.73444993213738
+CO-65
+1 32785U 08021C 26155.71935219 .00005395 00000-0 34197-3 0 9991
+2 32785 97.8272 136.8804 0010637 75.2124 285.0282 15.09326445983310
+CO-66
+1 32791U 08021J 26154.55442507 .00020146 00000-0 64842-3 0 9993
+2 32791 97.7515 151.8069 0002991 42.0128 318.1342 15.32257900985206
+RS-30
+1 32953U 08025A 26155.86579933 .00000003 00000-0 -50526-4 0 9992
+2 32953 82.5044 3.1063 0019385 341.4331 18.6039 12.43178729818160
+SRMSAT
+1 37841U 11058D 26155.28992140 .00000393 00000-0 69540-4 0 9995
+2 37841 19.9702 137.5332 0011914 62.8275 26.7062 14.11572942755997
+ZACUBE-1
+1 39417U 13066B 26154.94254392 .00004510 00000-0 35148-3 0 9990
+2 39417 97.8107 117.2078 0039904 294.5657 65.1411 15.01095965678748
+Delfi-N3xt
+1 39428U 13066N 26155.66193727 .00007558 00000-0 66179-3 0 9999
+2 39428 97.8344 75.9859 0072712 247.8716 111.4775 14.94953338672752
+GOMX-1
+1 39430U 13066Q 26155.79272571 .00002314 00000-0 35095-3 0 9999
+2 39430 97.6487 357.0374 0130016 116.8977 244.5586 14.69410700668096
+LO-74
+1 39440U 13066AA 26154.33051700 .00005093 00000-0 47123-3 0 9990
+2 39440 97.8904 103.2522 0059453 73.9566 286.8190 14.93641817674922
+AO-73
+1 39444U 13066AE 26155.59353272 .00008112 00000-0 50553-3 0 9998
+2 39444 97.8278 126.7780 0034647 245.3456 114.4162 15.09331350677763
+DTUSAT-2
+1 40030U 14033W 26155.22591472 .00007774 00000-0 42187-3 0 9999
+2 40030 98.0864 152.1319 0006144 280.7902 79.2636 15.14842658650726
+LILACSAT-2
+1 40908U 15049K 26155.88698627 .00020496 00000-0 35383-3 0 9999
+2 40908 97.4655 192.2640 0005377 304.9654 55.1092 15.51024001593846
+Horyu-4
+1 41340U 16012D 26152.43486084 .00260233 00000-0 10081-2 0 9993
+2 41340 30.9850 193.7734 0002293 171.6706 188.3991 15.85409012568303
+Lapan A3
+1 41603U 16040E 26155.85491032 .00003928 00000-0 12525-3 0 9996
+2 41603 97.1488 152.4070 0012007 65.0358 295.2131 15.33024305552921
+CAS-2T
+1 41847U 16066G 26155.63484800 .00001982 00000-0 28545-3 0 9992
+2 41847 98.3817 231.5141 0342302 167.4688 193.5290 14.44651724502984
+TechnoSat
+1 42829U 17042E 26155.74901354 .00003302 00000-0 23673-3 0 9993
+2 42829 97.4275 313.8827 0018977 132.9648 227.3174 15.04880149484831
+AO-91
+1 43017U 17073E 26155.17612321 .00011345 00000-0 49455-3 0 9999
+2 43017 97.4712 22.6585 0151546 14.2510 346.2924 15.12484658463423
+S-Net D
+1 43186U 18014G 26155.66212135 .00006020 00000-0 31164-3 0 9997
+2 43186 97.5370 60.5316 0009887 67.6528 292.5751 15.16549973456862
+S-Net B
+1 43187U 18014H 26155.67333097 .00006432 00000-0 33300-3 0 9991
+2 43187 97.5376 60.5288 0010426 63.4642 296.7659 15.16520086456866
+S-Net A
+1 43188U 18014J 26155.66106520 .00005895 00000-0 30517-3 0 9999
+2 43188 97.5386 60.7233 0010391 63.8079 296.4221 15.16557400456861
+S-Net C
+1 43189U 18014K 26155.67714317 .00006393 00000-0 33099-3 0 9992
+2 43189 97.5402 60.8120 0011555 56.9894 303.2448 15.16511330455418
+Ten-Koh
+1 43677U 18084G 26155.07429095 .00003243 00000-0 24650-3 0 9995
+2 43677 98.0775 346.8839 0010121 157.1972 202.9703 15.02883262414192
+PO-101
+1 43678U 18084H 26155.83239527 .00003226 00000-0 26166-3 0 9994
+2 43678 98.1154 351.5061 0011792 211.4547 148.5971 15.00391997414360
+QO-100
+1 43700U 18090A 26155.74019446 .00000156 00000-0 00000+0 0 9997
+2 43700 0.0177 0.9674 0001949 105.4242 79.0501 1.00272777 27552
+MinXSS-2
+1 43758U 18099A 26155.66838664 .00035252 00000-0 72088-3 0 9995
+2 43758 97.4538 231.5943 0006038 309.7758 50.2959 15.46039247412196
+AO-95
+1 43770U 18099N 26154.64024448 .00013080 00000-0 50433-3 0 9998
+2 43770 97.4392 214.9391 0009397 44.7441 315.4554 15.26406805411154
+SNUSat 2
+1 43782U 18099AA 26155.64240016 .00009596 00000-0 42708-3 0 9996
+2 43782 97.4061 209.2201 0009512 348.7388 11.3634 15.21642813411127
+SnugLite
+1 43784U 18099AC 26155.10350941 .00013539 00000-0 51508-3 0 9998
+2 43784 97.3871 209.5144 0002220 11.0960 349.0328 15.26879137411320
+ITASat 1
+1 43786U 18099AE 26155.63704000 .00008140 00000-0 39246-3 0 9994
+2 43786 97.4030 207.4001 0013392 43.0227 317.2052 15.18890618411006
+EAGLET 1
+1 43790U 18099AJ 26155.35384480 .00005478 00000-0 31483-3 0 9990
+2 43790 97.4233 205.3626 0011918 37.5450 322.6611 15.12838404410395
+ESEO
+1 43792U 18099AL 26155.67432023 .00001308 00000-0 98217-4 0 9991
+2 43792 97.3961 193.5989 0012511 23.3849 336.7944 15.04201533409929
+JO-97
+1 43803U 18099AX 26155.63215683 .00018538 00000-0 57877-3 0 9990
+2 43803 97.4135 218.4269 0004292 324.7580 35.3378 15.33239560411706
+Suomi 100
+1 43804U 18099AY 26155.63499492 .00013743 00000-0 50298-3 0 9996
+2 43804 97.4190 216.0775 0008768 331.5428 28.5331 15.28124804411502
+ISAT
+1 43879U 18111D 26155.43138794 .00095893 00000-0 10486-2 0 9996
+2 43879 97.5898 89.6933 0003290 47.8179 312.3358 15.62995150409176
+UWE-4
+1 43880U 18111E 26154.36119365 .00034900 00000-0 73362-3 0 9997
+2 43880 97.5860 82.1246 0008243 33.3192 326.8573 15.45215882408648
+Sparrow
+1 43881U 18111F 26155.59610858 .00151593 00000-0 11997-2 0 9990
+2 43881 97.6128 95.2751 0005059 99.0146 261.1689 15.70860609409396
+Prox-1
+1 44339U 19036A 26153.39522389 .00013271 00000-0 13054-2 0 9999
+2 44339 23.9937 213.0381 0005645 216.2369 143.7749 14.90241213371266
+Taurus 1
+1 44530U 19059C 26155.80361750 .00006517 00000-0 10468-2 0 9999
+2 44530 98.6410 319.8652 0008196 358.9323 1.1863 14.71959265356829
+TO-108
+1 44881U 19093C 26155.86108184 .00000338 00000-0 44129-4 0 9990
+2 44881 97.7533 228.3934 0014691 123.5586 236.7035 14.86496517349589
+RS-44
+1 44909U 19096E 26155.02704110 .00000001 00000-0 -44333-4 0 9998
+2 44909 82.5219 348.4520 0217591 174.8762 185.4640 12.79748573300667
+SALSAT
+1 46495U 20068K 26154.99736177 .00008555 00000-0 30076-3 0 9993
+2 46495 97.8850 157.2614 0009364 359.9507 0.1729 15.29597840313346
+CSS (TIANHE-1)
+1 48274U 21035A 26155.68961053 .00024475 00000-0 29392-3 0 9993
+2 48274 41.4693 38.0294 0009579 342.1781 17.8720 15.60257338291216
+CUTE
+1 49263U 21088D 26155.23260345 .00391134 58145-4 13985-2 0 9993
+2 49263 97.4162 253.3120 0006992 259.2007 100.8478 15.88777469260493
+TeikyoSat 4
+1 49396U 21102B 26155.65820756 .00001857 00000-0 11967-3 0 9993
+2 49396 97.3670 185.6288 0011415 344.5234 15.5644 15.09462831250832
+Z-Sat
+1 49399U 21102E 26155.80713624 .00003285 00000-0 16366-3 0 9993
+2 49399 97.3329 191.5059 0014871 293.4135 66.5535 15.18166518251568
+KOSEN 1
+1 49402U 21102H 26155.68886447 .00007530 00000-0 28928-3 0 9992
+2 49402 97.3189 198.0899 0012103 248.4486 111.5463 15.26654226252116
+HO-113
+1 50466U 21131B 26155.83678505 .00000562 00000-0 18718-3 0 9991
+2 50466 98.4978 248.2934 0005055 125.0726 235.0938 14.41345974233334
+SNUGLITE 2
+1 52899U 22065F 26153.81818698 .00001149 00000-0 22678-3 0 9997
+2 52899 98.2186 298.6759 0008699 72.9663 287.2492 14.64318814208891
+UmKA 1 (RS40S)
+1 57172U 23091G 26155.72365924 .00007244 00000-0 33222-3 0 9996
+2 57172 97.5051 214.4699 0013525 157.1943 202.9895 15.20667787162117
+CubeBel-2 (EU11S)
+1 57175U 23091K 26155.22582525 .00014019 00000-0 50188-3 0 9990
+2 57175 97.5053 218.3297 0010812 154.4980 205.6795 15.28829416162325
+RS-38S
+1 57189U 23091Z 26155.11681252 .00018692 00000-0 54136-3 0 9998
+2 57189 97.5093 224.3441 0008752 116.2926 243.9218 15.35589021162685
+SONATE-2
+1 59112U 24043Q 26154.97364330 .00039146 00000-0 52779-3 0 9990
+2 59112 97.5529 304.5700 0006326 241.9322 118.1294 15.57700323125834
+GRBBeta
+1 60237U 24128C 26155.74246985 .00004952 00000-0 34080-3 0 9997
+2 60237 61.9904 259.9266 0042354 132.1755 228.2947 15.06546882104396
+Curium One
+1 60242U 24128H 26155.74067412 .00009406 00000-0 54094-3 0 9995
+2 60242 61.9788 249.8530 0041552 128.1960 232.2890 15.12335101104575
+ROBUSTA-3A
+1 60243U 24128J 26154.83857688 .00009406 00000-0 55287-3 0 9992
+2 60243 61.9869 255.4438 0043220 125.2822 235.2328 15.11490826104401
+CatSat
+1 60246U 24125J 26154.65070750 .00056678 00000-0 77347-3 0 9993
+2 60246 97.2095 6.9905 0021582 228.0597 131.8820 15.57035250105284
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26155.73086128 .00115729 00000-0 85499-3 0 9995
+2 61772 97.2892 34.8492 0002185 319.5385 40.5716 15.72624267132711
+AO-123
+1 61781U 24199AY 26155.26251198 .00008936 00000-0 26072-3 0 9997
+2 61781 97.3011 24.0505 0013741 3.1440 356.9888 15.35480458131948
+JINJUSat 1B
+1 63210U 25052A 26155.68116339 .00018500 00000-0 58015-3 0 9998
+2 63210 97.4021 52.4231 0005273 119.5972 240.5796 15.33094184 68189
+NUSHSAT 1
+1 63211U 25052B 26155.67938850 .00023227 00000-0 67502-3 0 9991
+2 63211 97.3992 52.9449 0005054 119.3104 240.8645 15.35459375 68224
+TEVEL2-4
+1 63213U 25052D 26153.24759932 .00019833 00000-0 60334-3 0 9990
+2 63213 97.3927 49.6197 0004091 133.0862 227.0724 15.34050425 67823
+TEVEL2-5
+1 63214U 25052E 26155.68011441 .00020387 00000-0 62137-3 0 9996
+2 63214 97.3911 52.0060 0004070 127.8276 232.3335 15.33985737 68191
+TEVEL2-6
+1 63215U 25052F 26154.64839894 .00020133 00000-0 61519-3 0 9994
+2 63215 97.3918 50.9581 0004181 130.1242 230.0368 15.33906822 68039
+TEVEL2-1
+1 63217U 25052H 26153.69393788 .00019888 00000-0 61840-3 0 9999
+2 63217 97.3886 49.6443 0003899 141.0246 219.1278 15.33355434 67873
+TEVEL2-3
+1 63218U 25052J 26154.21113612 .00019661 00000-0 61001-3 0 9993
+2 63218 97.3892 50.1814 0003877 141.5958 218.5561 15.33427572 67951
+TEVEL2-2
+1 63219U 25052K 26154.60793555 .00020300 00000-0 63028-3 0 9990
+2 63219 97.3889 50.5598 0003813 141.3409 218.8107 15.33398099 68018
+TEVEL2-9
+1 63237U 25052AD 26155.67873848 .00017126 00000-0 56461-3 0 9997
+2 63237 97.3945 51.0324 0006594 167.3372 192.8036 15.31497239 68117
+TEVEL2-7
+1 63238U 25052AE 26154.60632626 .00017541 00000-0 58397-3 0 9998
+2 63238 97.3955 49.8841 0006418 171.2563 188.8791 15.31176236 67943
+TEVEL2-8
+1 63239U 25052AF 26154.94119385 .00017135 00000-0 57066-3 0 9999
+2 63239 97.3952 50.1954 0006473 170.8239 189.3121 15.31169698 67999
+SPIRONE
+1 66657U 25274H 26155.05647992 .00002114 00000-0 20596-3 0 9994
+2 66657 97.7483 84.5358 0013495 61.9371 298.3212 14.93487417 28265
+K-HERO
+1 66660U 25274L 26154.32797628 .00002230 00000-0 21467-3 0 9996
+2 66660 97.7488 83.9690 0015391 67.4158 292.8689 14.93903672 28169
+SNUGLITE-III DURI
+1 66661U 25274M 26155.58872358 .00001878 00000-0 18134-3 0 9994
+2 66661 97.7484 85.2328 0015973 64.2020 296.0846 14.93956633 28355
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26154.18192812 .00010577 00000-0 43076-3 0 9991
+2 67290 97.3924 229.3926 0010172 52.3667 307.8492 15.24621972 23842
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26155.16619895 .00016254 00000-0 63454-3 0 9996
+2 67291 97.3930 230.5150 0009516 48.8222 311.3836 15.25939873 24004
+Ten-Koh2
+1 68261U 25241B 26153.84997429 .00006883 00000-0 29609-3 0 9990
+2 68261 51.6660 27.8529 0006535 101.1658 259.0055 15.23719437 12723
+JACK-002
+1 68417U 26067B 26155.12092779 .00007221 00000-0 34601-3 0 9992
+2 68417 97.4567 113.8754 0001764 27.3197 332.8130 15.19221851 9961
+DISCO 2
+1 68431U 26067R 26155.73210874 .00008768 00000-0 42354-3 0 9994
+2 68431 97.4600 114.4682 0003870 65.1833 294.9803 15.18875510 10052
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26153.33220636 .00018852 00000-0 91402-3 0 9994
+2 68446 97.4412 111.8588 0009424 119.3546 240.8630 15.18523368 9674
+PARUS-6U1
+1 68456U 26067AS 26155.13190689 .00005685 00000-0 28781-3 0 9999
+2 68456 97.4553 113.6985 0007643 105.1613 255.0466 15.17371761 9954
+SAL-E
+1 68458U 26067AU 26155.12919632 .00008056 00000-0 40412-3 0 9997
+2 68458 97.4479 113.6404 0007870 112.3057 247.9012 15.17561784 9956
+FSI-SAT 2
+1 68792U 26088A 26153.34376270 .00004963 00000-0 33735-3 0 9991
+2 68792 97.5061 302.9786 0015366 152.9612 207.2419 15.06706036 6054
+OrigamiSat 2
+1 68795U 26088D 26154.03393240 .00004950 00000-0 32153-3 0 9996
+2 68795 97.5061 303.7468 0016403 126.4469 233.8274 15.08375608 6167
+ARICA 2
+1 68796U 26088E 26155.02644113 .00005617 00000-0 36479-3 0 9991
+2 68796 97.5055 304.7138 0016935 121.8076 238.4804 15.08313250 6311
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26152.37045560 .00007830 00000-0 50514-3 0 9993
+2 68797 97.5037 302.1246 0016669 130.5005 229.7679 15.08438851 5910
+MANGARO-II-Piscus
+1 68798U 26088G 26153.29130287 .00005214 00000-0 33523-3 0 9992
+2 68798 97.5055 303.0466 0020297 130.0536 230.2477 15.08665251 6056
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+/EX
+SB KEPS @ AMSAT < CX2SA $ORB26163.1
+2Line Orbital Elements 26163.AMSAT
+R:260612/0151Z 5216@GB7BWR.#45.GBR.EURO LinBPQ6.0.25
+R:260612/0119Z 10176@GB7BEX.#38.GBR.EURO LinBPQ6.0.25
+R:260612/0110Z 55207@EI2GYB.DGL.IRL.EURO LinBPQ6.0.25
+R:260612/0027Z 45023@PY2BIL.SP.BRA.SOAM LinBPQ6.0.25
+R:260612/0025Z @:PI8ZTM.#ZH1.NLD.EURO #:55607 [Den Haag] $:ORB26163.1
+R:260612/0024Z @:CX2SA.SAL.URY.SOAM #:601 [Salto] FBB7.00e $:ORB26163.1
+
+From: CX2SA@CX2SA.SAL.URY.SOAM
+To : KEPS@AMSAT
+
+
+QST de W1STR
+
+AMSAT Orbital Elements for Amateur Satellites in TLE Format
+>From Orbital Analysis Office
+New England Sci-Tech STEM Education Center
+Natick MA June 12, 2026
+To all radio amateurs
+
+
+These element sets describe the orbits of various satellites
+in use by the amateur radio community. For details see:
+www.amsat.org/keplerian-elements-formats/
+
+A daily update of element sets is available at:
+www.amsat.org/tle/daily-bulletin.txt
+or without bulletin text:
+www.amsat.org/tle/dailytle.txt
+
+
+AO-07
+1 07530U 74089B 26162.65147906 -.00000028 00000-0 11383-3 0 9998
+2 07530 101.9901 175.8403 0012513 140.4231 346.6371 12.53697989359829
+UO-11
+1 14781U 84021B 26162.71749374 .00001229 00000-0 13072-3 0 9995
+2 14781 97.8055 128.3534 0007126 190.9158 169.1907 14.90769946256317
+LO-19
+1 20442U 90005G 26162.53069412 .00000105 00000-0 54261-4 0 9991
+2 20442 98.8852 184.1803 0010820 218.5501 141.4911 14.34121495901580
+AO-27
+1 22825U 93061C 26162.68565860 .00000075 00000-0 45342-4 0 9993
+2 22825 98.6880 230.1011 0009459 113.9652 246.2522 14.30940798706216
+FO-29
+1 24278U 96046B 26162.54420303 .00000014 00000-0 46335-4 0 9996
+2 24278 98.5245 12.1894 0350827 111.0367 252.8667 13.53273928472403
+GO-32
+1 25397U 98043D 26162.58543429 .00000048 00000-0 41012-4 0 9991
+2 25397 99.0065 155.2028 0000734 176.4907 183.6276 14.24427354450534
+ISS
+1 25544U 98067A 26162.83551936 .00007284 00000-0 13937-3 0 9994
+2 25544 51.6334 326.5798 0004934 175.2433 184.8603 15.49179015570924
+NO-44
+1 26931U 01043C 26162.64152601 .00000072 00000-0 57659-4 0 9996
+2 26931 67.0509 258.6152 0006100 264.4327 95.6080 14.31954152289657
+SO-50
+1 27607U 02058C 26162.55839360 .00000916 00000-0 12536-3 0 9999
+2 27607 64.5506 146.4007 0075403 263.5157 95.7360 14.83034770263626
+CO-55
+1 27844U 03031E 26162.55782411 .00000255 00000-0 12921-3 0 9992
+2 27844 98.6735 171.1873 0009139 194.6488 165.4428 14.24332340190876
+RS-22
+1 27939U 03042A 26162.85688567 .00001166 00000-0 18781-3 0 9991
+2 27939 98.3473 347.0658 0010045 288.8379 182.7006 14.73459418214764
+CO-65
+1 32785U 08021C 26162.87915317 .00004765 00000-0 30197-3 0 9999
+2 32785 97.8271 144.1871 0010285 55.0183 305.2009 15.09404107984398
+CO-66
+1 32791U 08021J 26162.25964503 .00015274 00000-0 48820-3 0 9998
+2 32791 97.7517 159.8749 0001967 23.1856 336.9473 15.32546772986382
+RS-30
+1 32953U 08025A 26162.86738984 -.00000003 00000-0 -93499-4 0 9990
+2 32953 82.5050 358.7505 0019066 325.8599 34.1253 12.43178812819036
+SRMSAT
+1 37841U 11058D 26162.51581192 .00000355 00000-0 48954-4 0 9994
+2 37841 19.9715 93.7945 0011909 141.4141 27.1536 14.11574372757019
+ZACUBE-1
+1 39417U 13066B 26162.80818086 .00003114 00000-0 24384-3 0 9999
+2 39417 97.8084 125.1158 0040240 266.5236 93.1385 15.01156095679920
+Delfi-N3xt
+1 39428U 13066N 26162.68974664 .00004026 00000-0 35436-3 0 9995
+2 39428 97.8343 83.0068 0073188 224.2839 135.2512 14.95029108673806
+GOMX-1
+1 39430U 13066Q 26162.80655015 .00002336 00000-0 35370-3 0 9997
+2 39430 97.6494 3.6098 0130200 94.6175 266.9916 14.69441735669121
+LO-74
+1 39440U 13066AA 26162.77121377 .00003584 00000-0 33291-3 0 9999
+2 39440 97.8899 111.7263 0058871 46.5267 314.0826 14.93717789676180
+AO-73
+1 39444U 13066AE 26162.55441071 .00005554 00000-0 34659-3 0 9993
+2 39444 97.8262 133.8824 0035145 220.5848 139.2760 15.09420112678819
+DTUSAT-2
+1 40030U 14033W 26162.55772759 .00006319 00000-0 34274-3 0 9994
+2 40030 98.0858 159.9274 0006276 248.7752 111.2808 15.14945636651838
+LILACSAT-2
+1 40908U 15049K 26162.85412267 .00016370 00000-0 28065-3 0 9993
+2 40908 97.4658 199.4931 0005266 270.7018 89.3630 15.51269609594924
+Horyu-4
+1 41340U 16012D 26161.10844880 .00337518 00000-0 10043-2 0 9998
+2 41340 30.9844 130.8123 0003461 226.4757 133.5616 15.90526809569681
+Lapan A3
+1 41603U 16040E 26162.90427465 .00003154 00000-0 10090-3 0 9995
+2 41603 97.1484 159.2235 0011468 43.2034 317.0107 15.33071180554004
+CAS-2T
+1 41847U 16066G 26162.69969390 .00001523 00000-0 22073-3 0 9999
+2 41847 98.3821 238.4986 0342615 146.0770 216.2856 14.44676189504002
+TechnoSat
+1 42829U 17042E 26162.39817513 .00003079 00000-0 22080-3 0 9997
+2 42829 97.4263 320.2771 0018777 112.5016 247.8201 15.04918472485839
+AO-91
+1 43017U 17073E 26162.58534500 .00008698 00000-0 38005-3 0 9990
+2 43017 97.4718 29.9151 0150450 348.6412 11.1435 15.12626564464549
+S-Net D
+1 43186U 18014G 26162.72191544 .00004416 00000-0 22915-3 0 9993
+2 43186 97.5371 67.5470 0009451 46.9082 313.2940 15.16621821457936
+S-Net B
+1 43187U 18014H 26162.73326255 .00004765 00000-0 24717-3 0 9993
+2 43187 97.5378 67.5446 0009958 42.2656 317.9343 15.16592344457930
+S-Net A
+1 43188U 18014J 26162.72082205 .00004327 00000-0 22453-3 0 9996
+2 43188 97.5388 67.7398 0009847 43.1427 317.0576 15.16629419457936
+S-Net C
+1 43189U 18014K 26162.67113179 .00004973 00000-0 25777-3 0 9995
+2 43189 97.5404 67.7643 0011029 35.4781 324.7183 15.16583570456475
+Ten-Koh
+1 43677U 18084G 26162.53115580 .00002116 00000-0 16240-3 0 9999
+2 43677 98.0781 354.6565 0010975 131.3558 228.8611 15.02920830415316
+PO-101
+1 43678U 18084H 26162.83481030 .00002667 00000-0 21701-3 0 9998
+2 43678 98.1180 358.8112 0012215 187.4845 172.6197 15.00428066415413
+QO-100
+1 43700U 18090A 26162.62828442 .00000161 00000-0 00000+0 0 9992
+2 43700 0.0167 320.3790 0001431 157.1033 34.4948 1.00269967 27622
+MinXSS-2
+1 43758U 18099A 26162.72209756 .00031185 00000-0 62752-3 0 9992
+2 43758 97.4547 238.8477 0006295 277.9918 82.0617 15.46533045413287
+AO-95
+1 43770U 18099N 26162.11310128 .00010727 00000-0 41211-3 0 9991
+2 43770 97.4393 222.3819 0008614 20.0469 340.1107 15.26583130412293
+SNUSat 2
+1 43782U 18099AA 26162.61273932 .00007491 00000-0 33310-3 0 9995
+2 43782 97.4071 216.0820 0008897 321.3467 38.7132 15.21755815412181
+SnugLite
+1 43784U 18099AC 26162.11537671 .00010460 00000-0 39674-3 0 9994
+2 43784 97.3877 216.4553 0001521 337.6782 22.4390 15.27045448412399
+ITASat 1
+1 43786U 18099AE 26162.68590565 .00006612 00000-0 31860-3 0 9992
+2 43786 97.4034 214.3073 0012715 19.6048 340.5673 15.18988570412075
+EAGLET 1
+1 43790U 18099AJ 26162.62940266 .00003955 00000-0 22801-3 0 9990
+2 43790 97.4235 212.4449 0011224 13.4989 346.6540 15.12897029411496
+ESEO
+1 43792U 18099AL 26162.65911051 .00001966 00000-0 14545-3 0 9991
+2 43792 97.3966 200.2837 0011896 358.5401 1.5789 15.04225493410976
+JO-97
+1 43803U 18099AX 26162.41903211 .00013576 00000-0 42176-3 0 9998
+2 43803 97.4135 225.2337 0004121 290.5933 69.4867 15.33467542412740
+Suomi 100
+1 43804U 18099AY 26162.70662642 .00011026 00000-0 40226-3 0 9993
+2 43804 97.4194 223.1205 0008408 302.3070 57.7355 15.28290236412585
+ISAT
+1 43879U 18111D 26162.79070485 .00088429 00000-0 91873-3 0 9992
+2 43879 97.5882 97.5998 0001251 59.2219 300.9163 15.64337273410329
+UWE-4
+1 43880U 18111E 26162.77811529 .00033079 00000-0 68244-3 0 9991
+2 43880 97.5852 90.9210 0006520 5.5235 354.6084 15.45791225409942
+Sparrow
+1 43881U 18111F 26162.08988774 .00138135 00000-0 10146-2 0 9999
+2 43881 97.6115 102.3584 0004611 103.2888 256.8889 15.72684748410418
+Prox-1
+1 44339U 19036A 26162.63473251 .00012207 00000-0 11914-2 0 9990
+2 44339 23.9924 151.3410 0005369 331.4108 28.6097 14.90479846372648
+Taurus 1
+1 44530U 19059C 26162.80502664 .00005025 00000-0 80794-3 0 9991
+2 44530 98.6408 327.2998 0007654 335.2748 24.8090 14.72040742357859
+TO-108
+1 44881U 19093C 26162.86166634 .00000118 00000-0 19364-4 0 9991
+2 44881 97.7532 235.2236 0014977 102.4587 257.8305 14.86508603350625
+RS-44
+1 44909U 19096E 26162.61066808 .00000028 00000-0 60927-4 0 9991
+2 44909 82.5217 343.4113 0217927 157.1662 203.9312 12.79748751301632
+SALSAT
+1 46495U 20068K 26162.58556220 .00006923 00000-0 24314-3 0 9991
+2 46495 97.8849 165.3093 0008526 331.4069 28.6701 15.29719030314503
+CSS (TIANHE-1)
+1 48274U 21035A 26162.53781053 .00016554 00000-0 19807-3 0 9994
+2 48274 41.4693 356.3768 0008209 31.5834 328.5496 15.60566891292282
+CUTE
+1 49263U 21088D 26162.21741475 .00170126 12795-4 53187-3 0 9993
+2 49263 97.4171 260.9418 0007805 241.5311 118.5177 15.91463951261601
+TeikyoSat 4
+1 49396U 21102B 26162.61866576 .00001857 00000-0 11958-3 0 9997
+2 49396 97.3672 192.3186 0010836 318.3974 41.6430 15.09489641251889
+Z-Sat
+1 49399U 21102E 26162.85947080 .00002630 00000-0 13147-3 0 9998
+2 49399 97.3332 198.3438 0014802 265.7820 94.1723 15.18221160252635
+KOSEN 1
+1 49402U 21102H 26162.63638323 .00006530 00000-0 25045-3 0 9999
+2 49402 97.3194 204.9014 0012634 221.0806 138.9483 15.26758585253175
+HO-113
+1 50466U 21131B 26162.84816355 .00000475 00000-0 16045-3 0 9991
+2 50466 98.4973 255.2667 0005293 108.7025 251.4738 14.41352794234344
+SNUGLITE 2
+1 52899U 22065F 26162.63292372 .00000834 00000-0 16702-3 0 9993
+2 52899 98.2195 307.4736 0008329 48.8269 311.3650 14.64337670210180
+UmKA 1 (RS40S)
+1 57172U 23091G 26162.69853169 .00005909 00000-0 27090-3 0 9995
+2 57172 97.5058 221.4167 0014017 134.8199 225.4178 15.20754474163175
+CubeBel-2 (EU11S)
+1 57175U 23091K 26162.81772562 .00011356 00000-0 40481-3 0 9991
+2 57175 97.5060 225.9868 0011185 130.9539 229.2671 15.29019879163482
+RS-38S
+1 57189U 23091Z 26162.80543860 .00015937 00000-0 45823-3 0 9996
+2 57189 97.5099 232.1829 0008561 93.8965 266.3257 15.35853733163866
+SONATE-2
+1 59112U 24043Q 26162.68083809 .00036244 00000-0 47794-3 0 9993
+2 59112 97.5519 312.7414 0006785 214.2461 145.8357 15.58306667127037
+GRBBeta
+1 60237U 24128C 26162.57868025 .00003203 00000-0 22564-3 0 9993
+2 60237 61.9897 235.9431 0041389 133.4300 227.0250 15.06603237105429
+Curium One
+1 60242U 24128H 26162.55059273 .00006356 00000-0 36934-3 0 9992
+2 60242 61.9783 225.7373 0040666 129.3155 231.1557 15.12441491105605
+ROBUSTA-3A
+1 60243U 24128J 26162.51224362 .00006273 00000-0 37269-3 0 9992
+2 60243 61.9859 228.3117 0041955 127.1025 233.3917 15.11611105105568
+CatSat
+1 60246U 24125J 26162.55312640 .00057615 00000-0 75817-3 0 9990
+2 60246 97.2095 14.9841 0022213 199.2504 160.7915 15.57988127106514
+HYPERVIEW-1G (RS66S)
+1 61772U 24199AP 26162.85331163 .00120653 00000-0 82449-3 0 9992
+2 61772 97.2894 42.3086 0002612 249.1519 110.9466 15.74440956133839
+AO-123
+1 61781U 24199AY 26162.88690534 .00006895 00000-0 20107-3 0 9999
+2 61781 97.3015 31.6060 0012833 334.9444 25.1175 15.35599579133112
+JINJUSat 1B
+1 63210U 25052A 26162.66446414 .00016024 00000-0 49924-3 0 9992
+2 63210 97.4020 59.4127 0005433 103.0743 257.1106 15.33330613 69259
+NUSHSAT 1
+1 63211U 25052B 26162.65180502 .00019890 00000-0 57318-3 0 9995
+2 63211 97.3997 59.9468 0005183 104.6380 255.5439 15.35755437 69293
+TEVEL2-4
+1 63213U 25052D 26162.70463612 .00017902 00000-0 53861-3 0 9990
+2 63213 97.3917 59.0886 0004732 113.7416 246.4323 15.34420215 69273
+TEVEL2-5
+1 63214U 25052E 26162.65930424 .00017637 00000-0 53362-3 0 9996
+2 63214 97.3921 58.9918 0004616 115.2111 244.9611 15.34247244 69264
+TEVEL2-6
+1 63215U 25052F 26162.67150742 .00017453 00000-0 52870-3 0 9995
+2 63215 97.3921 58.9890 0004506 114.2026 245.9689 15.34210437 69266
+TEVEL2-1
+1 63217U 25052H 26162.69862928 .00016389 00000-0 50495-3 0 9993
+2 63217 97.3892 58.6467 0004481 124.0183 236.1485 15.33685523 69253
+TEVEL2-3
+1 63218U 25052J 26162.69346801 .00016740 00000-0 51483-3 0 9990
+2 63218 97.3895 58.6628 0004465 124.0241 236.1426 15.33739822 69250
+TEVEL2-2
+1 63219U 25052K 26162.63372872 .00016607 00000-0 51153-3 0 9998
+2 63219 97.3892 58.5842 0004438 124.7997 235.3663 15.33691849 69249
+TEVEL2-9
+1 63237U 25052AD 26162.66933140 .00015595 00000-0 51070-3 0 9995
+2 63237 97.3955 58.0067 0007180 145.2035 214.9678 15.31729289 69181
+TEVEL2-7
+1 63238U 25052AE 26162.64384617 .00015266 00000-0 50453-3 0 9992
+2 63238 97.3956 57.8996 0007384 146.6025 213.5683 15.31438085 69172
+TEVEL2-8
+1 63239U 25052AF 26162.65204074 .00015443 00000-0 51057-3 0 9990
+2 63239 97.3954 57.8849 0007385 147.5513 212.6184 15.31421974 69176
+SPIRONE
+1 66657U 25274H 26162.69424747 .00002371 00000-0 23018-3 0 9990
+2 66657 97.7482 92.0640 0013186 39.3964 320.8212 14.93524701 29402
+K-HERO
+1 66660U 25274L 26162.70037605 .00001907 00000-0 18412-3 0 9995
+2 66660 97.7491 92.2272 0015174 42.4511 317.7880 14.93943998 29411
+SNUGLITE-III DURI
+1 66661U 25274M 26162.35342095 .00001834 00000-0 17716-3 0 9994
+2 66661 97.7488 91.9052 0015727 43.9860 316.2609 14.93981607 29363
+SAKHACUBE-CHOLBON
+1 67290U 25313AU 26162.71359684 .00008400 00000-0 34113-3 0 9995
+2 67290 97.3936 237.8168 0009403 24.6626 335.5060 15.24792040 25148
+RS95S (QMR-KWT-2)
+1 67291U 25313AV 26162.70682690 .00012644 00000-0 49145-3 0 9997
+2 67291 97.3938 237.9744 0008769 23.1674 336.9958 15.26151310 25156
+Ten-Koh2
+1 68261U 25241B 26161.72007287 .00005667 00000-0 24553-3 0 9992
+2 68261 51.6686 350.4048 0006326 123.3884 236.7700 15.23827135 13924
+JACK-002
+1 68417U 26067B 26162.62928412 .00006536 00000-0 31259-3 0 9991
+2 68417 97.4561 121.2887 0000844 15.6757 344.4503 15.19326237 11101
+DISCO 2
+1 68431U 26067R 26162.84688025 .00007458 00000-0 35960-3 0 9991
+2 68431 97.4592 121.4922 0003298 52.2838 307.8695 15.18991676 11138
+HADES-SA (SpinnyONE)
+1 68446U 26067AG 26162.62235870 .00017480 00000-0 83941-3 0 9997
+2 68446 97.4395 121.0022 0009569 96.0146 264.2179 15.18872260 11081
+PARUS-6U1
+1 68456U 26067AS 26162.38569289 .00004479 00000-0 22698-3 0 9991
+2 68456 97.4543 120.8384 0007638 86.8057 273.4050 15.17454121 11056
+SAL-E
+1 68458U 26067AU 26162.38200311 .00005894 00000-0 29572-3 0 9991
+2 68458 97.4466 120.7745 0007993 93.8966 266.3182 15.17671197 11054
+FSI-SAT 2
+1 68792U 26088A 26162.37552808 .00003914 00000-0 26635-3 0 9993
+2 68792 97.5046 311.7813 0015567 125.1417 235.1272 15.06783507 7410
+OrigamiSat 2
+1 68795U 26088D 26162.12657880 .00002823 00000-0 18400-3 0 9994
+2 68795 97.5007 311.6580 0016405 100.0294 260.2787 15.08593796 7384
+ARICA 2
+1 68796U 26088E 26162.65547728 .00003522 00000-0 22986-3 0 9993
+2 68796 97.5045 312.1677 0017187 97.6089 262.7092 15.08382175 7463
+WASEDA-SAT-ZERO-II
+1 68797U 26088F 26162.65195126 .00005254 00000-0 33909-3 0 9996
+2 68797 97.5044 312.1717 0016925 97.5686 262.7465 15.08578017 7465
+MANGARO-II-Piscus
+1 68798U 26088G 26162.37767603 .00003385 00000-0 21864-3 0 9991
+2 68798 97.5053 311.9302 0020461 101.0235 259.3297 15.08739077 7420
+IO-86
+1 40931U 25360.30710720 .00000000 00000-0 12800-3 0 00
+2 40931 6.0006 332.5373 0012733 338.8432 8.1437 14.79075515 01
+LILIUM-4
+1 71922C 26067AC 26089.50133053 -.00014632 00000+0 -74472-3 0 04
+2 71922 97.4497 49.1617 0004341 5.9603 355.7042 15.16896692 16
+/EX
diff --git a/RHP.c b/RHP.c
index 3142e39..6bdc3b4 100644
--- a/RHP.c
+++ b/RHP.c
@@ -681,7 +681,7 @@ void RHPPoll()
Buffer[pktlen] = 0;
- RHPSession->sockptr->LastSendTime = time(NULL);
+ RHPSession->sockptr->LastSendTime = NOW;
// Message is JSON so Convert CR to \r, \ to \\ " to \"
diff --git a/MHSave.txt b/RTKnown.txt
index e69de29..e69de29 100644
--- a/MHSave.txt
+++ b/RTKnown.txt
diff --git a/RigControl.c b/RigControl.c
index 773547d..c485792 100644
--- a/RigControl.c
+++ b/RigControl.c
@@ -222,13 +222,13 @@ struct TimeScan * AllocateTimeRec(struct RIGINFO * RIG)
struct ScanEntry ** CheckTimeBands(struct RIGINFO * RIG)
{
int i = 0;
- time_t NOW = time(NULL) % 86400;
+ time_t Now = NOW % 86400;
// Find TimeBand
while (i < RIG->NumberofBands)
{
- if (RIG->TimeBands[i + 1]->Start > NOW)
+ if (RIG->TimeBands[i + 1]->Start > Now)
{
break;
}
@@ -275,7 +275,7 @@ VOID Rig_PTTEx(struct RIGINFO * RIG, BOOL PTTState, struct TNCINFO * TNC)
if (PTTState)
{
- MySetWindowText(RIG->hPTT, "T");
+ MySetWindowText(TNC, RIG->hPTT, "T");
RIG->WEB_PTT = 'T';
RIG->PTTTimer = PTTLimit;
RIG->repeatPTTOFFTimer = 0; // Cancel repeated off command
@@ -420,7 +420,7 @@ VOID Rig_PTTEx(struct RIGINFO * RIG, BOOL PTTState, struct TNCINFO * TNC)
{
// Drop PTT
- MySetWindowText(RIG->hPTT, " ");
+ MySetWindowText(TNC, RIG->hPTT, " ");
RIG->WEB_PTT = ' ';
RIG->PTTTimer = 0;
if (PORT->PortType == ICOM)
@@ -684,13 +684,13 @@ void saveNewFreq(struct RIGINFO * RIG, double Freq, char * Mode)
{
_gcvt((Freq + RIG->rxOffset) / 1000000.0, 9, RIG->Valchar);
strcpy(RIG->WEB_FREQ, RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(0, RIG->hFREQ, RIG->WEB_FREQ);
}
if (Mode[0])
{
strcpy(RIG->ModeString, Mode);
- MySetWindowText(RIG->hMODE, Mode);
+ MySetWindowText(0, RIG->hMODE, Mode);
}
}
@@ -905,7 +905,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTR
PORT->Closed = 1;
RigCloseConnection(PORT);
- MySetWindowText(RIG->hSCAN, "C");
+ MySetWindowText(0, RIG->hSCAN, "C");
RIG->WEB_SCAN = 'C';
sprintf(Command, "Ok\r");
@@ -917,7 +917,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTR
PORT->ReopenDelay = 300;
PORT->Closed = 0;
- MySetWindowText(RIG->hSCAN, "");
+ MySetWindowText(0, RIG->hSCAN, "");
RIG->WEB_SCAN = ' ';
sprintf(Command, "Ok\r");
@@ -965,7 +965,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTR
if (Session != (TRANSPORTENTRY *) -1) // Used for internal Stop/Start
RIG->ScanStopped |= 1; // Set Manual Stopped Bit
- MySetWindowText(RIG->hSCAN, "");
+ MySetWindowText(0, RIG->hSCAN, "");
RIG->WEB_SCAN = ' ';
sprintf(Command, "Ok\r");
@@ -2470,10 +2470,9 @@ DllExport BOOL APIENTRY Rig_Init()
if (RIG->NumberofBands)
CheckTimeBands(RIG); // Set initial timeband
-#ifdef WIN32
if (RIG->PTTCATPort[0]) // Serial port RTS to CAT
_beginthread(PTTCATThread,0,RIG);
-#endif
+
if (RIG->HAMLIBPORT)
{
// Open listening socket
@@ -3218,6 +3217,14 @@ int GetPermissionToChange(struct RIGPORTINFO * PORT, struct RIGINFO *RIG)
// Get Permission to change
+ if (RIG->PTTTimer) // Dont allow change if PTT ia active
+ {
+ if (RIG->RIG_DEBUG)
+ Debugprintf("GetPermissionToChange - Blocked by active PTT");
+
+ return 0;
+ }
+
if (RIG->RIG_DEBUG)
Debugprintf("GetPermissionToChange - WaitingForPermission = %d", RIG->WaitingForPermission);
@@ -3309,7 +3316,7 @@ CheckOtherPorts:
PortRecord->PORT_DLL_NAME, PORT->FreqPtr->Dwell);
RIG->WaitingForPermission = FALSE;
- MySetWindowText(RIG->hSCAN, "-");
+ MySetWindowText(0, RIG->hSCAN, "-");
RIG->WEB_SCAN = '-';
if (PORT->FreqPtr)
@@ -3364,7 +3371,7 @@ CheckOtherPorts:
if (RIG->ScanCounter == 0) // ? After manual change
RIG->ScanCounter = 150;
- MySetWindowText(RIG->hSCAN, "S");
+ MySetWindowText(0, RIG->hSCAN, "S");
RIG->WEB_SCAN = 'S';
// Do Bandwidth and antenna switches (if needed)
@@ -6075,6 +6082,8 @@ CheckOtherParams:
ptr = strtok_s(NULL, " \t\n\r", &Context);
+#ifdef WIN32
+
while (memcmp(ptr, "COM", 3) == 0)
{
char * tncport = strlop(ptr, '/');
@@ -6092,6 +6101,14 @@ CheckOtherParams:
if (ptr == NULL)
break;
}
+
+#else
+
+ strcpy(RIG->PTTCATPort[0], _strlwr(ptr));
+ ptr = strtok_s(NULL, " \t\n\r", &Context);
+
+#endif
+
if (ptr == NULL)
break;
else
@@ -7710,6 +7727,56 @@ WaitAgain:
}
}
*/
+#else
+
+// Linux Version. Use with tty0tty Kernel Module. Only supports one device for now
+
+VOID PTTCATThread(void * Param)
+{
+ struct RIGINFO * RIG = (struct RIGINFO *)Param;
+ EndPTTCATThread = FALSE;
+
+ Debugprintf("RigControl Opening %s for RTS PTT\n", RIG->PTTCATPort[0]);
+
+ int fd = open(RIG->PTTCATPort[0], O_RDWR | O_NOCTTY);
+ if (fd < 0)
+ {
+ perror("Error opening serial port");
+ return;
+ }
+
+ while (1)
+ {
+ // 2. Block until the CTS line changes status
+ // The hardware interrupt wakes the driver, which wakes this ioctl
+ if (ioctl(fd, TIOCMIWAIT, TIOCM_CTS) < 0)
+ {
+ perror("ioctl TIOCMIWAIT failed");
+ close(fd);
+ return;
+ }
+
+ // 3. Determine if it went HIGH or LOW
+ int status;
+ ioctl(fd, TIOCMGET, &status);
+
+ if (status & TIOCM_CTS)
+ {
+ Rig_PTTEx(RIG, TRUE, RIG->PTTCATTNC[0]);
+ }
+ else
+ {
+ Rig_PTTEx(RIG, FALSE, RIG->PTTCATTNC[0]);
+ }
+ }
+
+ close(fd);
+ EndPTTCATThread = FALSE;
+ return;
+
+}
+
+
#endif
// HAMLIB Support Code
@@ -7992,7 +8059,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT)
else
sprintf(RIG->WEB_MODE, "%s/%d", RIG->ModeString, b1);
- MySetWindowText(RIG->hMODE, RIG->WEB_MODE);
+ MySetWindowText(0, RIG->hMODE, RIG->WEB_MODE);
}
}
else
@@ -8011,7 +8078,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT)
_gcvt(RIG->RigFreq, 9, RIG->Valchar);
sprintf(RIG->WEB_FREQ,"%s", RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(0, RIG->hFREQ, RIG->WEB_FREQ);
// Read Mode
@@ -8036,7 +8103,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT)
else
SetWindowText(RIG->hMODE, RIG->WEB_MODE);
- MySetWindowText(RIG->hMODE, RIG->WEB_MODE);
+ MySetWindowText(0, RIG->hMODE, RIG->WEB_MODE);
Len = sprintf(ReqBuf, Req, "rig.get_bw", "");
Len = sprintf(SendBuff, MsgHddr, Len, ReqBuf);
@@ -8106,7 +8173,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT)
_gcvt(RIG->RigFreq, 9, RIG->Valchar);
sprintf(RIG->WEB_FREQ,"%s", RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(TNC, RIG->hFREQ, RIG->WEB_FREQ);
strcpy(PORT->TXBuffer, "rig.get_mode");
Len = sprintf(ReqBuf, Req, "rig.get_mode", "");
@@ -8123,7 +8190,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT)
{
strlop(val, '<');
sprintf(RIG->WEB_MODE, "%s", val);
- MySetWindowText(RIG->hMODE, RIG->WEB_MODE);
+ MySetWindowText(TNC, RIG->hMODE, RIG->WEB_MODE);
}
}
@@ -8843,7 +8910,7 @@ VOID FLRIGPoll(struct RIGPORTINFO * PORT)
_gcvt(RIG->RigFreq, 9, RIG->Valchar);
sprintf(RIG->WEB_FREQ,"%s", RIG->Valchar);
- MySetWindowText(RIG->hFREQ, RIG->WEB_FREQ);
+ MySetWindowText(0, RIG->hFREQ, RIG->WEB_FREQ);
}
diff --git a/SCSPactor.c b/SCSPactor.c
index 5a6de7a..036cd54 100644
--- a/SCSPactor.c
+++ b/SCSPactor.c
@@ -158,7 +158,7 @@ BOOL SCSStopPort(struct PORTCONTROL * PORT)
TNC->HostMode = FALSE;
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Stopped");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -172,7 +172,7 @@ BOOL SCSStartPort(struct PORTCONTROL * PORT)
TNC->ReopenTimer = 999; // Reopen immediately
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Restarted");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -197,7 +197,7 @@ static BOOL OpenLogFile(int Flags)
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(FN,"%s/logs/SCSLog_%02d%02d_%d.txt", LogDirectory, tm->tm_mon + 1, tm->tm_mday, Flags);
@@ -327,7 +327,7 @@ ConfigLine:
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(Cmd,"DATE %02d%02d%02d\r", tm->tm_mday, tm->tm_mon + 1, tm->tm_year - 100);
@@ -340,7 +340,7 @@ ConfigLine:
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(Cmd,"TIME %02d%02d%02d\r", tm->tm_hour, tm->tm_min, tm->tm_sec);
@@ -487,7 +487,7 @@ ok:
if ((STREAM->Connecting || STREAM->Connected) && !STREAM->Disconnecting)
{
- if (TNC->SessionTimeLimit && STREAM->ConnectTime && time(NULL) > (TNC->SessionTimeLimit + STREAM->ConnectTime))
+ if (TNC->SessionTimeLimit && STREAM->ConnectTime && NOW > (TNC->SessionTimeLimit + STREAM->ConnectTime))
{
STREAM->CmdSet = STREAM->CmdSave = malloc(100);
sprintf(STREAM->CmdSet, "D\r");
@@ -658,7 +658,7 @@ ok:
{
if (TNC->PTCStatus == 6) // Sync
{
- int insync = (int)(time(NULL) - TNC->TimeEnteredSYNCMode);
+ int insync = (int)(NOW - TNC->TimeEnteredSYNCMode);
if (insync > 4)
{
Debugprintf("SCS Scan - in SYNC for %d Secs - allow change regardless", insync);
@@ -667,7 +667,7 @@ ok:
}
else if (TNC->TimeScanLocked)
{
- time_t timeLocked = time(NULL) - TNC->TimeScanLocked;
+ time_t timeLocked = NOW - TNC->TimeScanLocked;
if (timeLocked > 4)
{
Debugprintf("SCS Scan - Scan Locked for %d Secs - allow change regardless", timeLocked);
@@ -695,7 +695,7 @@ ok:
{
TNC->DontReleasePermission = FALSE;
if (TNC->SyncSupported == FALSE)
- TNC->TimeScanLocked = time(NULL) + 100; // Make sure doesnt time out
+ TNC->TimeScanLocked = NOW + 100; // Make sure doesnt time out
return 0;
}
@@ -797,8 +797,7 @@ int DoScanLine(struct TNCINFO * TNC, char * Buff, int Len)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
- "<head><title>SCS Pactor Status</title></head><body><h3>SCS Pactor Status</h3>");
+ int Len = sprintf(Buff, "<h3>SCS Pactor Status</h3>");
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 480px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
@@ -1523,7 +1522,7 @@ VOID SCSPoll(int Port)
TNC->Streams[0].CmdSet = TNC->ConnectCmd;
TNC->Streams[0].Connecting = TRUE;
- TNC->Streams[0].ConnectTime = time(NULL);
+ TNC->Streams[0].ConnectTime = NOW;
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
@@ -3419,7 +3418,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen)
{
TNC->OKToChangeFreq = -1;
if (TNC->SyncSupported == FALSE && TNC->UseAPPLCallsforPactor && TNC->TimeScanLocked == 0)
- TNC->TimeScanLocked = time(NULL);
+ TNC->TimeScanLocked = NOW;
if (TNC->RIG->RIG_DEBUG)
Debugprintf("Scan Debug SCS Pactor TNC refused permission");
@@ -3499,7 +3498,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen)
STREAM->Connected = TRUE; // Subsequent data to data channel
STREAM->Connecting = FALSE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = 0;
// Stop Scanner
@@ -3790,7 +3789,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen)
if (TNC->RIG->RIG_DEBUG)
Debugprintf("SCS New SYNC Detected");
- TNC->TimeEnteredSYNCMode = time(NULL);
+ TNC->TimeEnteredSYNCMode = NOW;
TNC->SyncSupported = TRUE;
}
else
@@ -4297,7 +4296,7 @@ VOID PTCSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
struct STREAMINFO * STREAM = &TNC->Streams[0];
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
sprintf(STREAM->CmdSet, "I%s\r", "SCSPTC"); // Should prevent connects
@@ -4310,7 +4309,7 @@ VOID PTCReleasePort(struct TNCINFO * TNC)
struct STREAMINFO * STREAM = &TNC->Streams[0];
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
diff --git a/SCSTrackeMulti.c b/SCSTrackeMulti.c
index 110a4e3..5425812 100644
--- a/SCSTrackeMulti.c
+++ b/SCSTrackeMulti.c
@@ -203,18 +203,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
ok:
switch (fn)
{
- case 1: // poll
-
- for (Stream = 0; Stream <= MaxStreams; Stream++)
- {
- if (TNC->Streams[Stream].ReportDISC)
- {
- TNC->Streams[Stream].ReportDISC = FALSE;
- buff->PORT = Stream;
-
- return -1;
- }
- }
+ case 7: // poll
DEDCheckRX(TNC);
DEDPoll(port);
@@ -233,7 +222,27 @@ ok:
STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
}
}
- else
+
+
+ }
+
+ return 0;
+
+ case 1:
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (STREAM->ReportDISC)
+ {
+ STREAM->ReportDISC = FALSE;
+ buff->PORT = Stream;
+
+ return -1;
+ }
+
+ if (STREAM->PACTORtoBPQ_Q)
{
int datalen;
diff --git a/SCSTracker.c b/SCSTracker.c
index 41d26a9..1c7218b 100644
--- a/SCSTracker.c
+++ b/SCSTracker.c
@@ -109,7 +109,7 @@ VOID TRKSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
struct STREAMINFO * STREAM = &TNC->Streams[0];
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
sprintf(STREAM->CmdSet, "\1\1\1IDSPTNC");
@@ -120,7 +120,7 @@ VOID TRKReleasePort(struct TNCINFO * TNC)
struct STREAMINFO * STREAM = &TNC->Streams[0];
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
sprintf(STREAM->CmdSet, "\1\1\1I%s", TNC->NodeCall);
@@ -147,7 +147,7 @@ BOOL OpenDebugLogFile(int Port)
if (LogHandle[Port])
return TRUE; // already open
- T = LogTime[Port] = time(NULL);
+ T = LogTime[Port] = NOW;
tm = gmtime(&T);
sprintf(FN,"%s/logs/Port%02dDebugLog_%02d%02d.txt", LogDirectory, Port, tm->tm_mon + 1, tm->tm_mday);
@@ -172,7 +172,7 @@ void WriteDebugLogLine(int Port, char Dirn, char * Msg, int MsgLen)
UCHAR c;
char textbit[33] = " ";
int i;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
len = sprintf(hddr,"%02d:%02d:%02d %c Len %3d ", tm->tm_hour, tm->tm_min, tm->tm_sec, Dirn, MsgLen);
@@ -372,6 +372,10 @@ ok:
// 100 mS Timer.
+ DEDCheckRX(TNC);
+ DEDPoll(port);
+ DEDCheckRX(TNC);
+
// G7TAJ's code to record activity for stats display
if ( TNC->BusyFlags && CDBusy )
@@ -408,9 +412,6 @@ ok:
}
}
- DEDCheckRX(TNC);
- DEDPoll(port);
- DEDCheckRX(TNC);
for (Stream = 0; Stream <= MaxStreams; Stream++)
{
@@ -590,30 +591,7 @@ int TrkWebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
int Interval = 15;
int Len;
- if (LOCAL)
- {
- if (TNC->WEB_CHANGED)
- Interval = 1;
- else
- Interval = 4;
- }
- else
- {
- if (TNC->WEB_CHANGED)
- Interval = 4;
- else
- Interval = 15;
- }
-
- if (TNC->WEB_CHANGED)
- {
- TNC->WEB_CHANGED -= Interval;
- if (TNC->WEB_CHANGED < 0)
- TNC->WEB_CHANGED = 0;
- }
-
- Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=%d>"
- "<head><title>SCSTracker Status</title></head><body><h2>SCSTracker Status</h2>", Interval);
+ Len = sprintf(Buff, "<h2>SCSTracker Status</h2>");
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 480px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
@@ -2024,7 +2002,7 @@ VOID TrkProcessDEDFrame(struct TNCINFO * TNC)
STREAM->Connected = TRUE; // Subsequent data to data channel
STREAM->Connecting = FALSE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = 0;
if (TNC->SlowTimer)
diff --git a/SerialPort.c b/SerialPort.c
index d3b045b..a79475e 100644
--- a/SerialPort.c
+++ b/SerialPort.c
@@ -308,10 +308,6 @@ ok:
// 100 mS Timer. May now be needed, as Poll can be called more frequently in some circumstances
- SerialCheckRX(TNC);
- return 0;
-
- case 1: // poll
while (TNC->PortRecord->UI_Q)
{
@@ -353,6 +349,17 @@ ok:
SerialSendCommand(TNC, "DISCONNECT\r");
}
}
+ }
+
+ return 0;
+
+ case 1: // poll
+
+ SerialCheckRX(TNC);
+
+ for (Stream = 0; Stream <= 2; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && STREAM->Attached == 0)
{
@@ -376,7 +383,7 @@ ok:
SuspendOtherPorts(TNC);
//sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- //MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ //MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Stop Scanning
@@ -574,7 +581,7 @@ ok:
// Save Command, and wait up to 10 secs
sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->ConnectCmd = _strdup(Connect);
TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
@@ -589,7 +596,7 @@ ok:
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", STREAM->MyCall, STREAM->RemoteCall);
SerialSendCommand(TNC, Connect);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
STREAM->Connecting = TRUE;
return 0;
diff --git a/StdVer.inc b/StdVer.inc
index c7d86c7..868e0b0 100644
--- a/StdVer.inc
+++ b/StdVer.inc
@@ -36,7 +36,7 @@ END
#define BPQICON 2
-BPQICON ICON DISCARDABLE "..\\bpqicon.ico"
+BPQICON ICON DISCARDABLE "bpqicon.ico"
#ifdef MAILCHAT
diff --git a/TNCEmulators.c b/TNCEmulators.c
index 7fce453..353456b 100644
--- a/TNCEmulators.c
+++ b/TNCEmulators.c
@@ -1776,7 +1776,7 @@ VOID TNCTimer()
while (TNC)
{
- if (TNC->LastDEDPollTime && (time(NULL) > TNC->LastDEDPollTime + 30)) // No polls for 30 secs
+ if (TNC->LastDEDPollTime && (NOW > TNC->LastDEDPollTime + 30)) // No polls for 30 secs
{
int Len = 0;
int Count;
@@ -3403,30 +3403,12 @@ NOTDATA:
if (TNC->DEDTXBUFFER[0] == 1)
{
// recovering
-
-// if (!TNC->Recovering)
-// {
-// sprintf(msg, "Port %d DED Recovery started\n", TNC->ComPort);
-// OutputDebugString(msg);
-// TNC->Recovering = TRUE;
-// }
}
else
{
// Not recovery
-
-// if (TNC->Recovering)
-// {
-// sprintf(msg, "Port %d DED Recovery completed\n", TNC->ComPort);
-// OutputDebugString(msg);
-// TNC->Recovering = FALSE;
-// }
-
}
-// sprintf(msg,"DED CMD: Port %d CMD %c MSGCHANNEL %d\n", TNC->ComPort, TNC->TONODEBUFFER[0], MSGCHANNEL);
-// OutputDebugString(msg);
-
if (_memicmp(TNC->DEDTXBUFFER, "QRES", 4 == 0))
return SendHostOK(TNC);
@@ -3529,7 +3511,7 @@ NOTDATA:
{
//SEE IF MONITORED FRAMES AVAILABLE
- TNC->LastDEDPollTime = time(NULL);
+ TNC->LastDEDPollTime = NOW;
if (MONCount(TNC->Channels[0]->BPQStream))
Work = 0x31;
@@ -3809,32 +3791,8 @@ REALCALL:
HOSTDATAPACKET:
-// }
-// {
-// UCHAR msg[100];
-
-// sprintf(msg,"Host Data Packet: Port %d\n", TNC->ComPort);
-// OutputDebugString(msg);
-// }
-//
-
-
// IF WE ALREADY HAVE DATA QUEUED, ADD THIS IT QUEUE
-// if (Channel->Chan_TXQ)
-// {
-
-// // COPY MESSAGE TO A CHAIN OF BUFFERS
-
-// if (QCOUNT < 10)
-// goto CANTSEND; // NO SPACE - RETURN ERROR (?)
-
-//QUEUEFRAME:
-
-// C_Q_ADD(Channel->Chan_TXQ, COPYMSGTOBUFFERS()); // RETURNS EDI = FIRST (OR ONLY) FRAGMENT
-
-// return SendHostOK(TNC);
-
// MAKE SURE NODE ISNT BUSY
if (TNC->MSGCHANNEL == 0) // UNPROTO Channel
diff --git a/TelnetV6.c b/TelnetV6.c
index abe5878..f261716 100644
--- a/TelnetV6.c
+++ b/TelnetV6.c
@@ -57,6 +57,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
extern UCHAR LogDirectory[];
extern int MONTOFILEFLAG;
+
+extern int LOCALNOTSECURE;
static char ClassName[]="TELNETSERVER";
static char WindowTitle[] = "Telnet Server";
@@ -92,6 +94,9 @@ void ProcessRHPWebSockClosed(SOCKET socket);
int ProcessSNMPPayload(UCHAR * Msg, int Len, UCHAR * Reply, int * OffPtr);
int RHPProcessHTTPMessage(struct ConnectionInfo * conn, char * response, char * Method, char * URL, char * request, BOOL LOCAL, BOOL COOKIE);
void checkNRTCPSockets(int portNo);
+int ProcessNewTermWebSock(struct ConnectionInfo * sockptr, char * Key);
+void ProcessWebTermInput(struct ConnectionInfo * sockptr, char * Payload);
+void ProcessWebTermClosed(struct ConnectionInfo * sockptr);
#ifndef LINBPQ
extern HKEY REGTREE;
@@ -182,6 +187,7 @@ int DeleteLogFile(char * Log, int KeepDays);
void DeleteLogFiles(int Age)
{
+ DeleteLogFile("NodeDebug", Age);
DeleteLogFile("Telnet", Age);
DeleteLogFile("CMSAccess_", Age);
DeleteLogFile("ConnectLog_",Age);
@@ -221,7 +227,6 @@ int DeleteLogFile(char * Log, int KeepDays)
{
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
- OutputDebugString(ffd.cFileName);
}
else
{
@@ -261,7 +266,7 @@ int DeleteLogFile(char * Log, int KeepDays)
struct dirent **namelist;
int n;
struct stat STAT;
- time_t now = time(NULL);
+ time_t now = NOW;
int Age = 0, res;
char FN[256];
@@ -527,6 +532,9 @@ int ProcessLine(char * buf, int Port)
else if (_stricmp(param,"SecureTelnet") == 0)
TCP->SecureTelnet = atoi(value);
+ else if (_stricmp(param,"noWebSocks") == 0)
+ TCP->noWebSocks = atoi(value);
+
else if (_stricmp(param,"CloseOnDisconnect") == 0)
TCP->DisconnectOnClose = atoi(value);
@@ -542,6 +550,8 @@ int ProcessLine(char * buf, int Port)
else if (_stricmp(param,"HTTPPORT") == 0)
HTTPPort = TCP->HTTPPort = atoi(value);
+
+
else if (_stricmp(param,"NETROMPORT") == 0)
TCP->NETROMPort = atoi(value);
@@ -957,7 +967,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
{
if (sockptr->WebSocks == 0)
{
- if (sockptr->LastSendTime && (time(NULL) - sockptr->LastSendTime) > 150) // ~ 2.5 mins
+ if (sockptr->LastSendTime && (NOW - sockptr->LastSendTime) > 150) // ~ 2.5 mins
{
closesocket(sockptr->socket);
sockptr->SocketActive = FALSE;
@@ -970,7 +980,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Normally keepalives are sent each way around every 9 mins
// Keepalives aren't sent when connecting so may need a bit longer
- if (sockptr->LastSendTime && (time(NULL) - sockptr->LastSendTime) > 20 * 60) // 20mins
+ if (sockptr->LastSendTime && (NOW - sockptr->LastSendTime) > 20 * 60) // 20mins
{
ProcessRHPWebSockClosed(sockptr->socket);
closesocket(sockptr->socket);
@@ -983,7 +993,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
{
// Time out Login
- if (sockptr->LoginState < 2 && (time(NULL) - sockptr->ConnectTime) > 30)
+ if (sockptr->LoginState < 2 && (NOW - sockptr->ConnectTime) > 30)
{
closesocket(sockptr->socket);
sockptr->SocketActive = FALSE;
@@ -992,12 +1002,11 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
}
-
-
-
- return 0;
-
- case 1: // poll
+ if (TNC->PageChanged)
+ {
+ BuildDevicePage(TNC);
+ TNC->PageChanged = FALSE;
+ }
for (Stream = 0; Stream <= MaxStreams; Stream++)
{
@@ -1034,7 +1043,17 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
STREAM->ReportDISC = TRUE;
}
}
+ }
+
+ return 0;
+ case 1:
+
+ TelnetPoll(port);
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
if (STREAM->ReportDISC)
{
STREAM->ReportDISC = FALSE;
@@ -1042,13 +1061,6 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
return -1;
}
- }
-
- TelnetPoll(port);
-
- for (Stream = 0; Stream <= MaxStreams; Stream++)
- {
- STREAM = &TNC->Streams[Stream];
if (STREAM->PACTORtoBPQ_Q !=0)
{
@@ -1312,8 +1324,7 @@ static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
strcpy(CMSStatus, "No CMS");
}
- Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
- "<head><title>Telnet Status</title></head><body><b>Telnet Status &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%s</b>", CMSStatus);
+ Len = sprintf(Buff, "<b>Telnet Status &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%s</b>", CMSStatus);
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 250px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
@@ -1337,9 +1348,9 @@ static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
char Addr[100];
Tel_Format_Addr(sockptr, Addr);
if (sockptr->WebSocks)
- sprintf(msg,"<tr><td>Websock<%s</td><td>&nbsp;</td><td>&nbsp;</td></tr>", Addr);
+ sprintf(msg,"<tr><td>Websock&lt;%s</td><td>&nbsp;</td><td>&nbsp;</td></tr>", Addr);
else
- sprintf(msg,"<tr><td>HTTP<%s</td><td>&nbsp;</td><td>&nbsp;</td></tr>", Addr);
+ sprintf(msg,"<tr><td>HTTP&lt;%s</td><td>&nbsp;</td><td>&nbsp;</td></tr>", Addr);
}
else if (sockptr->DRATSMode)
{
@@ -2470,7 +2481,7 @@ nosocks:
{
char logmsg[120];
sprintf(logmsg,"%d Disconnected. Bytes Sent = %d Bytes Received %d Time %d Seconds\r\n",
- sockptr->Number, STREAM->bytesTXed, STREAM->bytesRXed, (int)(time(NULL) - sockptr->ConnectTime));
+ sockptr->Number, STREAM->bytesTXed, STREAM->bytesRXed, (int)(NOW - sockptr->ConnectTime));
WriteCMSLog (logmsg);
}
@@ -2531,11 +2542,11 @@ nosocks:
if (sockptr->SocketActive && sockptr->Keepalive && L4LIMIT)
{
- if ((time(NULL) - sockptr->LastSendTime) > (L4LIMIT - 60)) // PC Ticks are about 10% slow
+ if ((NOW - sockptr->LastSendTime) > (L4LIMIT - 60)) // PC Ticks are about 10% slow
{
// Send Keepalive
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
BuffertoNode(sockptr, "Keepalive\r", 10);
}
}
@@ -2665,7 +2676,7 @@ nosocks:
if (P3[0] == 'K' || P4[0] == 'K' || P5[0] == 'K' || P6[0] == 'K')
{
sockptr->Keepalive = TRUE;
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
}
if (P3[0] == 'S' || P4[0] == 'S' || P5[0] == 'S' || P6[0] == 'S')
@@ -2857,7 +2868,7 @@ nosocks:
Msglen = sockptr->FromHostBuffPutptr - sockptr->FromHostBuffGetptr;
- if (Msglen)
+ if (Msglen > 0)
{
int Paclen = 0;
int Queued = 0;
@@ -2887,7 +2898,7 @@ nosocks:
if (Paclen == 0)
Paclen = 256;
- ShowConnections(TNC);
+// ShowConnections(TNC);
if (Msglen > Paclen)
Msglen = Paclen;
@@ -2897,7 +2908,7 @@ nosocks:
SendtoNode(TNC, Stream, &sockptr->FromHostBuffer[sockptr->FromHostBuffGetptr], Msglen);
sockptr->FromHostBuffGetptr += Msglen;
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
}
}
}
@@ -3366,7 +3377,7 @@ int Socket_Accept(struct TNCINFO * TNC, SOCKET SocketId, int Port)
if (sockptr->sin.sin_family != AF_INET6)
{
- if (sockptr->sin.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) // 127.0.0.1?
+ if (!LOCALNOTSECURE && sockptr->sin.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) // 127.0.0.1?
LOCAL = TRUE;
else
{
@@ -3396,7 +3407,7 @@ int Socket_Accept(struct TNCINFO * TNC, SOCKET SocketId, int Port)
sockptr->UserPointer = 0;
sockptr->DoEcho = FALSE;
sockptr->BPQTermMode = FALSE;
- sockptr->ConnectTime = time(NULL);
+ sockptr->ConnectTime = NOW;
sockptr->Keepalive = FALSE;
sockptr->UTF8 = 0;
@@ -5090,6 +5101,8 @@ MsgLoop:
extern char * RigWebPage;
+
+
struct RHPParamBlock
{
unsigned char * Msg;
@@ -5217,11 +5230,28 @@ int DataSocket_ReadHTTP(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, S
if (Opcode == 8)
{
- Debugprintf("WebSock Close");
+ char Msg[256];
+
+ if (strcmp(sockptr->WebURL, "WEBTERM") == 0)
+ {
+ ProcessWebTermClosed(sockptr);
+ }
+
+ // Msg[0] = 0x88; // Fin, Close
+ // Msg[1] = 9;
+ // strcpy(&Msg[2], "Close ACK");
+
+ // send(sockptr->socket, Msg, 11, 0);
}
else if (Opcode == 1)
{
- if (strcmp(sockptr->WebURL, "RIGCTL") == 0)
+ if (strcmp(sockptr->WebURL, "WEBTERM") == 0)
+ {
+ Payload[Len] = 0;
+ ProcessWebTermInput(sockptr, Payload);
+ }
+
+ else if (strcmp(sockptr->WebURL, "RIGCTL") == 0)
{
// PTT Message
@@ -5237,7 +5267,7 @@ int DataSocket_ReadHTTP(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, S
{
sockcopy = malloc(sizeof(struct ConnectionInfo));
sockptr->TNC = TNC;
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
memcpy(sockcopy, sockptr, sizeof(struct ConnectionInfo));
@@ -5255,7 +5285,7 @@ int DataSocket_ReadHTTP(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, S
ParamBlock->Len = Len;
ParamBlock->Msg = malloc(Len + 10);
memcpy(ParamBlock->Msg, Payload, Len);
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
_beginthread(RHPThread, 0, (VOID *)ParamBlock);
@@ -5297,7 +5327,7 @@ int DataSocket_ReadHTTP(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, S
sockcopy = malloc(sizeof(struct ConnectionInfo));
sockptr->TNC = TNC;
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
memcpy(sockcopy, sockptr, sizeof(struct ConnectionInfo));
@@ -5310,9 +5340,41 @@ int DataSocket_ReadHTTP(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, S
ShowConnections(TNC);
memcpy(sockptr->WebURL, &MsgPtr[5], 31);
+ strlop(sockptr->WebURL, '?');
strlop(sockptr->WebURL, ' ');
- if (RigWebPage)
- RigWebPage[0] = 0;
+
+ if (strcmp(sockptr->WebURL, "RIGCTL") == 0)
+ {
+ if (RigWebPage)
+ RigWebPage[0] = 0;
+ }
+ else if (memcmp(sockptr->WebURL, "DEVICE", 6) == 0)
+ {
+ int Port = atoi(&sockptr->WebURL[6]);
+
+ if (Port > 0 && Port <= MaxBPQPortNo)
+ {
+ struct TNCINFO * PTNC = TNCInfo[Port];
+
+ if (PTNC)
+ {
+ if (PTNC->WebPage)
+ PTNC->WebPage[0] = 0;
+
+ PTNC->WebSockUsed = 1;
+ PTNC->PageChanged = 1;
+ }
+ }
+ }
+ else if (memcmp(sockptr->WebURL, "WEBTERM", 7) == 0)
+ {
+ // We have to hook this socket to the Terminal Session
+ char * Key = strlop(&MsgPtr[5], '?');
+
+ strlop(Key, ' ');
+ ProcessNewTermWebSock(sockptr, Key);
+ }
+
ptr = strstr(MsgPtr, "BPQSessionCookie=N");
@@ -5426,6 +5488,8 @@ int ShowConnections(struct TNCINFO * TNC)
SendMessage(TNC->hMonitor, LB_ADDSTRING ,0, (LPARAM)msg);
}
#endif
+
+ TNC->PageChanged = TNC->WebSockUsed;
return 0;
}
byte * EncodeCall(byte * Call)
@@ -5545,7 +5609,7 @@ int WriteLog(char * msg)
time_t T;
struct tm * tm;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
if (LogDirectory[0] == 0)
@@ -5600,7 +5664,7 @@ VOID WriteCMSLog(char * msg)
if (CMSLogEnabled == FALSE)
return;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
if (LogDirectory[0] == 0)
@@ -5791,7 +5855,7 @@ int Telnet_Connected(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, SOCK
sockptr->InputLen = 0;
// sockptr->Number = Stream;
sockptr->RelayMode = FALSE;
- sockptr->ConnectTime = time(NULL);
+ sockptr->ConnectTime = NOW;
TNC->Streams[Stream].Connecting = FALSE;
TNC->Streams[Stream].Connected = TRUE;
@@ -6031,9 +6095,9 @@ CheckServers:
#ifndef LINBPQ
if (TCP->CMSOK)
- MySetWindowText(TCP->hCMSWnd, "CMS OK");
+ MySetWindowText(TNC, TCP->hCMSWnd, "CMS OK");
else
- MySetWindowText(TCP->hCMSWnd, "NO CMS");
+ MySetWindowText(TNC, TCP->hCMSWnd, "NO CMS");
#endif
return;
}
@@ -6360,7 +6424,7 @@ VOID SaveCMSHostInfo(int port, struct TCPINFO * TCP, int CMSNo)
memcpy(work, &TCP->CMSAddr[CMSNo].s_addr, 4);
- sprintf(Info,"%s %d %d.%d.%d.%d\n", TCP->CMSName[CMSNo], (int)time(NULL),
+ sprintf(Info,"%s %d %d.%d.%d.%d\n", TCP->CMSName[CMSNo], (int)NOW,
work[0], work[1], work[2], work[3]);
@@ -6400,7 +6464,7 @@ VOID SaveCMSHostInfo(int port, struct TCPINFO * TCP, int CMSNo)
if (n == 3)
{
- time_t age = time(NULL) - t;
+ time_t age = NOW - t;
// if not current server and not too old, copy across
@@ -7283,7 +7347,7 @@ int DoRefreshWebMailIndex()
{
sockcopy = malloc(sizeof(struct ConnectionInfo));
sockptr->TNC = TNC;
- sockptr->LastSendTime = time(NULL);
+ sockptr->LastSendTime = NOW;
memcpy(sockcopy, sockptr, sizeof(struct ConnectionInfo));
diff --git a/UIARQ.c b/UIARQ.c
index dca1431..02549d3 100644
--- a/UIARQ.c
+++ b/UIARQ.c
@@ -158,6 +158,17 @@ static int ExtProc(int fn, int port,unsigned char * buff)
TidyClose(TNC, Stream);
}
}
+
+ if (STREAM->PACTORtoBPQ_Q == 0)
+ {
+ if (STREAM->DiscWhenAllSent)
+ {
+ STREAM->DiscWhenAllSent--;
+ if (STREAM->DiscWhenAllSent == 0)
+ STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
+ }
+ }
+
}
ARQTimer(TNC);
@@ -183,16 +194,7 @@ static int ExtProc(int fn, int port,unsigned char * buff)
return -1;
}
- if (STREAM->PACTORtoBPQ_Q == 0)
- {
- if (STREAM->DiscWhenAllSent)
- {
- STREAM->DiscWhenAllSent--;
- if (STREAM->DiscWhenAllSent == 0)
- STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
- }
- }
- else
+ if (STREAM->PACTORtoBPQ_Q)
{
int datalen;
@@ -387,7 +389,7 @@ static VOID UpdateStatsLine(struct TNCINFO * TNC, struct STREAMINFO * STREAM)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0>"
"<script type=\"text/javascript\">\r\n"
"function ScrollOutput()\r\n"
"{var textarea = document.getElementById('textarea');"
@@ -421,7 +423,7 @@ UINT UIARQExtInit(EXTPORTDATA * PortEntry)
struct PORTCONTROL * PORT;
struct STREAMINFO * STREAM;
- srand((unsigned int)time(NULL));
+ srand((unsigned int)NOW);
port = PortEntry->PORTCONTROL.PORTNUMBER;
@@ -853,7 +855,7 @@ static VOID ProcessFLDigiData(struct TNCINFO * TNC, UCHAR * Input, int Len, int
SESS = TNC->PortRecord->ATTACHEDSESSIONS[Stream];
strcpy(STREAM->MyCall, call2);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->BytesAcked = STREAM->BytesResent = 0;
if (WL2K)
@@ -1005,7 +1007,7 @@ AckConnectRequest:
if (STREAM->Connected)
goto SendKReply; // Repeated ACK
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->BytesAcked = STREAM->BytesResent = 0;
STREAM->Connected = TRUE;
diff --git a/UZ7HODrv.c b/UZ7HODrv.c
index 42e1fc3..c5e0368 100644
--- a/UZ7HODrv.c
+++ b/UZ7HODrv.c
@@ -321,7 +321,7 @@ BOOL UZ7HOStopPort(struct PORTCONTROL * PORT)
KillTNC(TNC);
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Stopped");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -335,10 +335,10 @@ BOOL UZ7HOStartPort(struct PORTCONTROL * PORT)
struct TNCINFO * TNC = PORT->TNC;
ConnecttoUZ7HO(TNC->Port);
- TNC->lasttime = time(NULL);;
+ TNC->lasttime = NOW;;
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Restarted");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -356,7 +356,7 @@ VOID UZ7HOSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
TNC->PortRecord->PORTCONTROL.PortSuspended = TRUE;
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
RegisterAPPLCalls(TNC, TRUE);
}
@@ -364,7 +364,7 @@ VOID UZ7HOReleasePort(struct TNCINFO * TNC)
{
TNC->PortRecord->PORTCONTROL.PortSuspended = FALSE;
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
RegisterAPPLCalls(TNC, FALSE);
}
@@ -673,7 +673,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
switch (fn)
{
- case 1: // poll
+ case 7: // poll
if (MasterPort[port] == port)
{
@@ -763,7 +763,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->CONNECTING = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
// If required, send signon
@@ -856,8 +856,6 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
- // See if any frames for this port
-
for (Stream = 0; Stream <= TNC->AGWInfo->MaxSessions; Stream++)
{
STREAM = &TNC->Streams[Stream];
@@ -892,16 +890,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (STREAM->Attached)
CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
- if (STREAM->ReportDISC)
- {
- hookL4SessionDeleted(TNC, STREAM);
- STREAM->ReportDISC = FALSE;
- buff->PORT = Stream;
-
- return -1;
- }
-
- // if Busy, send buffer status poll
+ // if Busy, send buffer status poll
if (STREAM->Connected && STREAM->FramesOutstanding)
{
@@ -934,7 +923,26 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
STREAM->ReportDISC = TRUE; // Dont want to leave session attached. Causes too much confusion
}
}
- else
+ }
+
+ return 0;
+
+ case 1:
+
+ for (Stream = 0; Stream <= TNC->AGWInfo->MaxSessions; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (STREAM->ReportDISC)
+ {
+ hookL4SessionDeleted(TNC, STREAM);
+ STREAM->ReportDISC = FALSE;
+ buff->PORT = Stream;
+
+ return -1;
+ }
+
+ if (STREAM->PACTORtoBPQ_Q)
{
int datalen;
@@ -1158,7 +1166,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (buffptr)
{
buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0],
- "UZ7HO} Error - Call missing from C command\r", STREAM->MyCall, STREAM->RemoteCall);
+ "UZ7HO} Error - Call missing from C command\r");
C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
}
@@ -1284,7 +1292,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->Alerted = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Disconnected from TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
if (TNC->WeStartedTNC)
{
@@ -1317,24 +1325,7 @@ extern char WebProcTemplate[];
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
-/*
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
- "<script type=\"text/javascript\">\r\n"
- "function ScrollOutput()\r\n"
- "{var textarea = document.getElementById('textarea');"
- "textarea.scrollTop = textarea.scrollHeight;}"
- "myInt = setInterval('Refresh()', 15000 );\n"
- "function Refresh( )\n"
- "{location.reload()}\n"
- "</script>"
- "</head><title>UZ7HO Status</title></head><body id=Text onload=\"ScrollOutput()\">"
- "<h2><form method=post target=\"POPUPW\" onsubmit=\"POPUPW = window.open('about:blank','POPUPW',"
- "'width=440,height=150');\" action=ARDOPAbort?%d>UZ7HO Status"
- "<input name=Save value=\"Abort Session\" type=submit style=\"position: absolute; right: 10;top:10;\"></form></h2>",
- TNC->Port);
-*/
- int Len = sprintf(Buff, WebProcTemplate, TNC->Port, TNC->Port, "UZ7HO Status", "UZ7HO Status");
-
+ int Len = sprintf(Buff, WebProcTemplate, "UZ7HO Status");
if (TNC->TXFreq)
Len += sprintf(&Buff[Len], sliderBit, TNC->TXOffset, TNC->TXOffset);
@@ -1507,7 +1498,7 @@ void * UZ7HOExtInit(EXTPORTDATA * PortEntry)
// Slave Port
sprintf(TNC->WEB_COMMSSTATE, "Slave to Port %d", MasterPort[port] );
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
}
time(&lasttime[port]); // Get initial time value
@@ -1933,7 +1924,7 @@ VOID ConnecttoUZ7HOThread(void * portptr)
TNC->CONNECTED = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
ioctl(TNC->TCPSock, FIONBIO, &param);
}
@@ -1948,7 +1939,7 @@ VOID ConnecttoUZ7HOThread(void * portptr)
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -1994,7 +1985,7 @@ static int ProcessReceivedData(int port)
TNC->Alerted = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Disconnected from TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return (0);
@@ -2011,7 +2002,7 @@ static int ProcessReceivedData(int port)
TNC->Alerted = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Disconnected from TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
closesocket(TNC->TCPSock);
@@ -2042,7 +2033,7 @@ static int ProcessReceivedData(int port)
TNC->Alerted = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Disconnected from TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return 0;
}
@@ -2389,7 +2380,7 @@ GotStream:
STREAM = &TNC->Streams[Stream];
memcpy(STREAM->AGWKey, Key, 21);
STREAM->Connected = TRUE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = 0;
SuspendOtherPorts(TNC);
@@ -2550,7 +2541,7 @@ GotStream:
STREAM->Connected = TRUE;
STREAM->Connecting = FALSE;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = 0;
buffptr = GetBuff();
diff --git a/V4.c b/V4.c
index d9815af..7951b76 100644
--- a/V4.c
+++ b/V4.c
@@ -258,7 +258,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
switch (fn)
{
- case 1: // poll
+ case 7: // poll
while (TNC->PortRecord->UI_Q) // Release anything accidentally put on UI_Q
{
@@ -281,7 +281,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
memcpy(TNC->Streams[0].RemoteCall, &TNC->ConnectCmd[11], strlen(TNC->ConnectCmd)-13);
sprintf(Status, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, Status);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, Status);
strcpy(TNC->WEB_TNCSTATE, Status);
free(TNC->ConnectCmd);
@@ -373,26 +373,26 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
}
-/*
+ /*
if (TNC->UpdateWL2K)
{
- TNC->UpdateWL2KTimer--;
+ TNC->UpdateWL2KTimer--;
- if (TNC->UpdateWL2KTimer == 0)
- {
- TNC->UpdateWL2KTimer = 32910/2; // Every Hour
- if (CheckAppl(TNC, "RMS ")) // Is RMS Available?
- SendReporttoWL2K(TNC);
- }
+ if (TNC->UpdateWL2KTimer == 0)
+ {
+ TNC->UpdateWL2KTimer = 32910/2; // Every Hour
+ if (CheckAppl(TNC, "RMS ")) // Is RMS Available?
+ SendReporttoWL2K(TNC);
}
-*/
+ }
+ */
if (TNC->RIG)
{
if (TNC->RIG->RigFreq != TNC->LastFreq)
{
char FREQMsg[80];
int Len;
-
+
TNC->LastFreq = TNC->RIG->RigFreq;
Len = sprintf(FREQMsg, "DISPLAY CF:%1.4f\r\n", TNC->LastFreq + .0015);
send(TNC->TCPSock,FREQMsg, Len, 0);
@@ -402,27 +402,27 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (TNC->TimeSinceLast++ > 700) // Allow 10 secs for Keepalive
{
// Restart TNC
-
+
if (TNC->ProgramPath)
{
if (strstr(TNC->ProgramPath, "V4 TNC"))
{
struct tm * tm;
char Time[80];
-
+
TNC->Restarts++;
- TNC->LastRestart = time(NULL);
+ TNC->LastRestart = NOW;
tm = gmtime(&TNC->LastRestart);
-
+
sprintf_s(Time, sizeof(Time),"%04d/%02d/%02d %02d:%02dZ",
tm->tm_year +1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
- MySetWindowText(TNC->xIDC_RESTARTTIME, Time);
+ MySetWindowText(TNC, TNC->xIDC_RESTARTTIME, Time);
strcpy(TNC->WEB_RESTARTTIME, Time);
sprintf_s(Time, sizeof(Time),"%d", TNC->Restarts);
- MySetWindowText(TNC->xIDC_RESTARTS, Time);
+ MySetWindowText(TNC, TNC->xIDC_RESTARTS, Time);
strcpy(TNC->WEB_RESTARTS, Time);
KillTNC(TNC);
@@ -448,7 +448,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Stop Listening, and set MYCALL to user's call
-// send(TNC->TCPSock, "LISTEN FALSE\r\n", 14, 0);
+ // send(TNC->TCPSock, "LISTEN FALSE\r\n", 14, 0);
ChangeMYC(TNC, TNC->Streams[0].MyCall);
// Stop other ports in same group
@@ -456,13 +456,13 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
SuspendOtherPorts(TNC);
sprintf(Status, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, Status);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, Status);
strcpy(TNC->WEB_TNCSTATE, Status);
// Stop Scanning
sprintf(Msg, "%d SCANSTOP", TNC->Port);
-
+
Rig_Command( (TRANSPORTENTRY *) -1, Msg);
}
@@ -470,70 +470,75 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (TNC->Streams[0].Attached)
CheckForDetach(TNC, 0, &TNC->Streams[0], TidyClose, ForcedClose, CloseComplete);
- if (TNC->Streams[0].ReportDISC)
+
+ if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
{
- TNC->Streams[0].ReportDISC = FALSE;
- buff->PORT = 0;
- return -1;
- }
+ // See if time to reconnect
- if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+ time(&ltime);
+ if (ltime - TNC->lasttime >9 )
{
- // See if time to reconnect
-
- time(&ltime);
- if (ltime - TNC->lasttime >9 )
- {
- TNC->LastFreq = 0; // so display will be updated
- ConnecttoWINMOR(port);
- TNC->lasttime = ltime;
- }
+ TNC->LastFreq = 0; // so display will be updated
+ ConnecttoWINMOR(port);
+ TNC->lasttime = ltime;
}
-
- FD_ZERO(&readfs);
-
- if (TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&readfs);
-
- FD_ZERO(&writefs);
+ }
- if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+ FD_ZERO(&readfs);
- FD_ZERO(&errorfs);
-
- if (TNC->CONNECTING || TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&errorfs);
+ if (TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&readfs);
+
+ FD_ZERO(&writefs);
+
+ if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+
+ FD_ZERO(&errorfs);
+
+ if (TNC->CONNECTING || TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&errorfs);
+
+ if (select((int)TNC->TCPSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ {
+ // See what happened
+
+ if (readfs.fd_count == 1)
+ V4ProcessDataSocketData(port);
- if (select((int)TNC->TCPSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ if (writefs.fd_count == 1)
{
- // See what happened
+ // Write block has cleared. Send rest of packet
- if (readfs.fd_count == 1)
- V4ProcessDataSocketData(port);
-
- if (writefs.fd_count == 1)
- {
- // Write block has cleared. Send rest of packet
+ buffptr=Q_REM(&TNC->BPQtoWINMOR_Q);
+ txlen = (unsigned int)buffptr->Len;
- buffptr=Q_REM(&TNC->BPQtoWINMOR_Q);
- txlen = (unsigned int)buffptr->Len;
+ memcpy(txbuff,buffptr->Data, txlen);
+ bytes=send(TNC->TCPSock,(const char FAR *)&txbuff,txlen,0);
+ ReleaseBuffer(buffptr);
+ }
- memcpy(txbuff,buffptr->Data, txlen);
- bytes=send(TNC->TCPSock,(const char FAR *)&txbuff,txlen,0);
- ReleaseBuffer(buffptr);
- }
-
- if (errorfs.fd_count == 1)
- {
- i=sprintf(ErrMsg, "V4 Data Connection lost for BPQ Port %d\n", port);
- WritetoConsole(ErrMsg);
- TNC->CONNECTING = FALSE;
- TNC->CONNECTED = FALSE;
- TNC->Streams[0].ReportDISC = TRUE;
- }
+ if (errorfs.fd_count == 1)
+ {
+ i=sprintf(ErrMsg, "V4 Data Connection lost for BPQ Port %d\n", port);
+ WritetoConsole(ErrMsg);
+ TNC->CONNECTING = FALSE;
+ TNC->CONNECTED = FALSE;
+ TNC->Streams[0].ReportDISC = TRUE;
}
-
+ }
+
+ return 0;
+
+ case 1:
+
+ if (TNC->Streams[0].ReportDISC)
+ {
+ TNC->Streams[0].ReportDISC = FALSE;
+ buff->PORT = 0;
+ return -1;
+ }
+
// See if any frames for this port
- if (TNC->WINMORtoBPQ_Q != 0)
+ if (TNC->WINMORtoBPQ_Q)
{
buffptr = Q_REM(&TNC->WINMORtoBPQ_Q);
@@ -657,7 +662,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->FECIDTimer = 0;
send(TNC->TCPSock,"MODE FEC\r\n", 10, 0);
strcpy(TNC->WEB_MODE, "FEC");
- MySetWindowText(TNC->xIDC_MODE, TNC->WEB_MODE);
+ MySetWindowText(TNC, TNC->xIDC_MODE, TNC->WEB_MODE);
return 0;
}
@@ -700,7 +705,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
memcpy(TNC->Streams[0].RemoteCall, &Connect[11], txlen-13);
sprintf(Status, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, Status);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, Status);
strcpy(TNC->WEB_TNCSTATE, Status);
}
@@ -836,7 +841,7 @@ loop:
// Does this mean closed?
strcpy(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTING = FALSE;
@@ -910,7 +915,7 @@ static VOID ReleaseTNC(struct TNCINFO * TNC)
// send(TNC->TCPSock, "LISTEN TRUE\r\nMAXCONREQ 4\r\n", 26, 0);
- MySetWindowText(TNC->xIDC_TNCSTATE, "Free");
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, "Free");
strcpy(TNC->WEB_TNCSTATE, "Free");
// Start Scanner
@@ -921,7 +926,7 @@ static VOID ReleaseTNC(struct TNCINFO * TNC)
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
+ int Len = sprintf(Buff, "<html>"
"<script type=\"text/javascript\">\r\n"
"function ScrollOutput()\r\n"
"{var textarea = document.getElementById('textarea');"
@@ -1115,7 +1120,7 @@ void * V4ExtInit(EXTPORTDATA * PortEntry)
WritetoConsole(Msg);
strcpy(TNC->WEB_MODE, "ARQ");
- MySetWindowText(TNC->xIDC_MODE, TNC->WEB_MODE);
+ MySetWindowText(TNC, TNC->xIDC_MODE, TNC->WEB_MODE);
ConnecttoWINMOR(port);
time(&TNC->lasttime); // Get initial time value
@@ -1147,7 +1152,7 @@ static BOOL CALLBACK EnumTNCWindowsProc(HWND hwnd, LPARAM lParam)
// Our Process
sprintf (wtext, "V4 Sound Card TNC - BPQ %s", TNC->PortRecord->PORTCONTROL.PORTDESCRIPTION);
- MySetWindowText(hwnd, wtext);
+ MySetWindowText(TNC, hwnd, wtext);
// return FALSE;
}
}
@@ -1197,7 +1202,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (_memicmp(Buffer, "BUSY TRUE", 9) == 0)
{
TNC->Busy |= CDBusy;
- MySetWindowText(TNC->xIDC_CHANSTATE, "Busy");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Busy");
strcpy(TNC->WEB_CHANSTATE, "Busy");
return;
@@ -1206,7 +1211,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (_memicmp(Buffer, "BUSY FALSE", 10) == 0)
{
TNC->Busy &= ~CDBusy;
- MySetWindowText(TNC->xIDC_CHANSTATE, "Clear");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Clear");
strcpy(TNC->WEB_CHANSTATE, "Clear");
return;
}
@@ -1229,7 +1234,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
WritetoTrace(TNC, Buffer, MsgLen - 2);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
memcpy(Call, &Buffer[10], 10);
@@ -1254,7 +1259,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
else
sprintf(Status, "%s Connected to %s Inbound", TNC->Streams[0].RemoteCall, TNC->TargetCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, Status);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, Status);
strcpy(TNC->WEB_TNCSTATE, Status);
// See which application the connect is for
@@ -1343,7 +1348,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
else
sprintf(Status, "%s Connected to %s Outbound", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, Status);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, Status);
strcpy(TNC->WEB_TNCSTATE, Status);
UpdateMH(TNC, Call, '+', 'O');
@@ -1377,7 +1382,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
C_Q_ADD(&TNC->WINMORtoBPQ_Q, buffptr);
sprintf(Status, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, Status);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, Status);
strcpy(TNC->WEB_TNCSTATE, Status);
return;
@@ -1463,7 +1468,7 @@ static VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
}
}
- MySetWindowText(TNC->xIDC_TRAFFIC, &Buffer[7]);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, &Buffer[7]);
strcpy(TNC->WEB_TRAFFIC, &Buffer[7]);
return;
@@ -1760,6 +1765,6 @@ VOID CloseComplete(struct TNCINFO * TNC, int Stream)
TNC->FECMode = FALSE;
send(TNC->TCPSock,"MODE ARQ\r\n", 10, 0);
strcpy(TNC->WEB_MODE, "ARQ");
- MySetWindowText(TNC->xIDC_MODE, TNC->WEB_MODE);
+ MySetWindowText(TNC, TNC->xIDC_MODE, TNC->WEB_MODE);
}
}
diff --git a/VARA.c b/VARA.c
index f913fe8..6db58ef 100644
--- a/VARA.c
+++ b/VARA.c
@@ -136,7 +136,7 @@ BOOL VARAStopPort(struct PORTCONTROL * PORT)
KillTNC(TNC);
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Stopped");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -150,10 +150,10 @@ BOOL VARAStartPort(struct PORTCONTROL * PORT)
struct TNCINFO * TNC = PORT->TNC;
ConnecttoVARA(TNC->Port);
- TNC->lasttime = time(NULL);;
+ TNC->lasttime = NOW;;
sprintf(PORT->TNC->WEB_COMMSSTATE, "%s", "Port Restarted");
- MySetWindowText(PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, PORT->TNC->xIDC_COMMSSTATE, PORT->TNC->WEB_COMMSSTATE);
return TRUE;
}
@@ -364,6 +364,8 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
{
case 8:
+ // 60 sec timer
+
return 0;
case 7:
@@ -390,7 +392,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if ((STREAM->Connecting || STREAM->Connected) && !STREAM->Disconnecting)
{
- if (TNC->SessionTimeLimit && STREAM->ConnectTime && time(NULL) > (TNC->SessionTimeLimit + STREAM->ConnectTime))
+ if (TNC->SessionTimeLimit && STREAM->ConnectTime && NOW > (TNC->SessionTimeLimit + STREAM->ConnectTime))
{
VARASendCommand(TNC, "CLEANTXBUFFER\r", TRUE);
VARASendCommand(TNC, "DISCONNECT\r", TRUE);
@@ -403,13 +405,25 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (STREAM->Attached)
{
- if (STREAM->AttachTime && TNC->AttachTimeLimit && time(NULL) > (TNC->AttachTimeLimit + STREAM->AttachTime))
+ if (STREAM->AttachTime && TNC->AttachTimeLimit && NOW > (TNC->AttachTimeLimit + STREAM->AttachTime))
{
STREAM->ReportDISC = 1;
STREAM->AttachTime = 0;
}
}
+ if (STREAM->NeedDisc)
+ {
+ STREAM->NeedDisc--;
+
+ if (STREAM->NeedDisc == 0)
+ {
+ // Send the DISCONNECT
+
+ VARASendCommand(TNC, "DISCONNECT\r", TRUE);
+ }
+ }
+
while (TNC->PortRecord->UI_Q)
{
@@ -439,7 +453,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
VARASendCommand(TNC, TNC->ConnectCmd, TRUE);
TNC->Streams[0].Connecting = TRUE;
- TNC->Streams[0].ConnectTime = time(NULL);
+ TNC->Streams[0].ConnectTime = NOW;
memset(TNC->Streams[0].RemoteCall, 0, 10);
memcpy(TNC->Streams[0].RemoteCall, &TNC->ConnectCmd[8], strlen(TNC->ConnectCmd)-10);
@@ -463,7 +477,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
PMSGWITHLEN buffptr = GetBuff();
TNC->Streams[0].Connecting = FALSE;
- TNC->Streams[0].ConnectTime = time(NULL);
+ TNC->Streams[0].ConnectTime = NOW;
if (buffptr == 0) return (0); // No buffers, so ignore
@@ -480,42 +494,12 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
- return 0;
-
- case 1: // poll
-
- if (STREAM->NeedDisc)
+ if (TNC->PageChanged)
{
- STREAM->NeedDisc--;
-
- if (STREAM->NeedDisc == 0)
- {
- // Send the DISCONNECT
-
- VARASendCommand(TNC, "DISCONNECT\r", TRUE);
- }
+ BuildDevicePage(TNC);
+ TNC->PageChanged = FALSE;
}
- /*
- {
- struct tm * tm;
- char Time[80];
-
- TNC->Restarts++;
- TNC->LastRestart = time(NULL);
-
- tm = gmtime(&TNC->LastRestart);
-
- sprintf_s(Time, sizeof(Time),"%04d/%02d/%02d %02d:%02dZ",
- tm->tm_year +1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
-
- MySetWindowText(TNC->xIDC_RESTARTTIME, Time);
- strcpy(TNC->WEB_RESTARTTIME, Time);
-
- sprintf_s(Time, sizeof(Time),"%d", TNC->Restarts);
- MySetWindowText(TNC->xIDC_RESTARTS, Time);
- strcpy(TNC->WEB_RESTARTS, Time);
-*/
if (TNC->PortRecord->ATTACHEDSESSIONS[0] && TNC->Streams[0].Attached == 0)
{
@@ -536,14 +520,14 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
VARASendCommand(TNC, "LISTEN OFF\r", TRUE);
TNC->SessionTimeLimit = TNC->DefaultSessionTimeLimit; // Reset Limit
- STREAM->AttachTime = time(NULL);
+ STREAM->AttachTime = NOW;
// Stop other ports in same group
SuspendOtherPorts(TNC);
sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Stop Scanning
@@ -552,16 +536,6 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
Rig_Command( (TRANSPORTENTRY *) -1, Msg);
}
- if (TNC->Streams[0].Attached)
- CheckForDetach(TNC, 0, &TNC->Streams[0], TidyClose, ForcedClose, CloseComplete);
-
- if (TNC->Streams[0].ReportDISC)
- {
- TNC->Streams[0].ReportDISC = FALSE;
- buff->PORT = 0;
- return -1;
- }
-
if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
{
// See if time to reconnect
@@ -574,6 +548,20 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
}
}
+ if (TNC->Streams[0].Attached)
+ CheckForDetach(TNC, 0, &TNC->Streams[0], TidyClose, ForcedClose, CloseComplete);
+
+ return 0;
+
+ case 1: // poll
+
+ if (TNC->Streams[0].ReportDISC)
+ {
+ TNC->Streams[0].ReportDISC = FALSE;
+ buff->PORT = 0;
+ return -1;
+ }
+
// See if any frames for this port
if (TNC->Streams[0].BPQtoPACTOR_Q) //Used for CTEXT
@@ -850,7 +838,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Save Command, and wait up to 10 secs
sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->ConnectCmd = _strdup(Connect);
TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
@@ -861,14 +849,14 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->OverrideBusy = FALSE;
VARASendCommand(TNC, Connect, TRUE);
- TNC->Streams[0].ConnectTime = time(NULL);
+ TNC->Streams[0].ConnectTime = NOW;
memset(TNC->Streams[0].RemoteCall, 0, 10);
strcpy(TNC->Streams[0].RemoteCall, &buff->L2DATA[2]);
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
else
{
@@ -1011,68 +999,33 @@ void CountRestarts(struct TNCINFO * TNC)
char Time[80];
TNC->Restarts++;
- TNC->LastRestart = time(NULL);
+ TNC->LastRestart = NOW;
tm = gmtime(&TNC->LastRestart);
sprintf_s(Time, sizeof(Time),"%04d/%02d/%02d %02d:%02dZ",
tm->tm_year +1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
- //MySetWindowText(TNC->xIDC_RESTARTTIME, Time);
+ //MySetWindowText(TNC, TNC->xIDC_RESTARTTIME, Time);
//strcpy(TNC->WEB_RESTARTTIME, Time);
sprintf_s(Time, sizeof(Time),"%d", TNC->Restarts);
- MySetWindowText(TNC->xIDC_RESTARTS, Time);
+ MySetWindowText(TNC, TNC->xIDC_RESTARTS, Time);
strcpy(TNC->WEB_RESTARTS, Time);
}
-/*
-char WebProcTemplate[] = "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=15>"
- "<link rel='stylesheet' href='webproc.css'>\r\n"
- "<script type=\"text/javascript\">\r\n"
- "function ScrollOutput()\r\n"
- "{var textarea = document.getElementById('textarea');"
- "textarea.scrollTop = textarea.scrollHeight;}\r\n"
- "function xxx(data){\r\n"
- "req = new XMLHttpRequest();\r\n"
- "req.open('POST', 'PortAction?%d', true);\r\n"
- "req.send(data);alert(data + ' Sent');}\r\n"
- "</script>"
- "</head><title>%s</title></head><body id=Text onload=\"ScrollOutput()\">"
- "<span class='dropdown'>"
- "<button class='dropbtn'>Actions</button><span style=\"margin-left:120px;font-size:16px\"><b>%s</b></span>"
- "<div class='dropdown-content'>"
- "<a href='javascript:xxx(\"Abort\");'>Abort Session</a>"
- "<a href='javascript:xxx(\"Kill\");'>Kill TNC</a>"
- "<a href='javascript:xxx(\"KillRestart\");'>Kill and Restart TNC</a>"
- "</div></span>";
-*/
-char WebProcTemplate[] = "<html><meta http-equiv=expires content=0>"
+
+char WebProcTemplate[] =
"<link rel='stylesheet' href='webproc.css'>\r\n"
"<script type=\"text/javascript\">\r\n"
- "function ScrollOutput()\r\n"
- "{var textarea = document.getElementById('textarea');"
- "textarea.scrollTop = textarea.scrollHeight;}\r\n"
- "function xxx(data){\r\n"
- "req = new XMLHttpRequest();\r\n"
- "req.open('POST', 'PortAction?%d', true);\r\n"
- "req.send(data);alert(data + ' Sent');}\r\n"
- "function yyy(data){\r\n"
- "req = new XMLHttpRequest();\r\n"
- "req.open('POST', 'freqOffset?%d', true);\r\n"
- "req.send(data);}\r\n"
- "myInt = setInterval('Refresh()', 15000 );\n"
- "function Refresh( )\n"
- "{location.reload()}\n"
"</script>\r\n"
- "</head><title>%s</title></head><body id=Text onload=\"ScrollOutput()\">\r\n"
- "<h2 style=\"margin-bottom: 0.2em; text-align:center\">%s</h2>";
+ "<h3 style=\"margin-bottom: 0.2em; text-align:center\">%s</h3>";
-char Menubit[] = "<span class='dropdown' style=\"position: absolute; left: 10;top: 12;\">"
- "<button class='dropbtn'>Actions</button>\r\n"
+char Menubit[] = "<span hidden class='dropdown' style=\"position: absolute; left: 10;top: 12;\">"
+ "<button hidden class='dropbtn'>Actions</button>\r\n"
"<span class='dropdown-content'>"
- "<a href='javascript:xxx(\"Abort\");'>Abort Session</a>"
- "<a href='javascript:xxx(\"Kill\");'>Kill TNC</a>"
- "<a href='javascript:xxx(\"KillRestart\");'>Kill and Restart TNC</a>"
+ "<a href='javascript:Action(\"Abort\");'>Abort Session</a>"
+ "<a href='javascript:Action(\"Kill\");'>Kill TNC</a>"
+ "<a href='javascript:Action(\"KillRestart\");'>Kill and Restart TNC</a>"
"</span></span>";
char sliderBit[] = "<span style=\"position: absolute; left: 380;top: 2;\"> TX Offset <span id='val'>%d</span></span>"
@@ -1082,16 +1035,16 @@ char sliderBit[] = "<span style=\"position: absolute; left: 380;top: 2;\"> TX Of
"var output = document.getElementById('val');"
"slider.oninput = function() {output.innerHTML = this.value;}\r\n"
"slider.onmouseout = function() {myInt = setInterval('Refresh()', 15000 );"
- "output.innerHTML = this.value;yyy(this.value);}\r\n"
+ "output.innerHTML = this.value;freqOffset(this.value);}\r\n"
"slider.onmouseover = function() {clearInterval(myInt)};"
"</script>\r\n";
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, WebProcTemplate, TNC->Port, TNC->Port, "VARA Status", "VARA Status");
+ int Len = sprintf(Buff, WebProcTemplate, "VARA Status");
if (LOCAL)
- Len += sprintf(&Buff[Len], Menubit, TNC->TXOffset, TNC->TXOffset);
+ Len += sprintf(&Buff[Len], Menubit);
if (TNC->TXFreq)
Len += sprintf(&Buff[Len], sliderBit, TNC->TXOffset, TNC->TXOffset);
@@ -1118,7 +1071,7 @@ VOID VARASuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
TNC->PortRecord->PORTCONTROL.PortSuspended = TRUE;
VARASendCommand(TNC, "LISTEN OFF\r", TRUE);
strcpy(TNC->WEB_TNCSTATE, "Interlocked");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
@@ -1127,7 +1080,7 @@ VOID VARAReleasePort(struct TNCINFO * TNC)
TNC->PortRecord->PORTCONTROL.PortSuspended = FALSE;
VARASendCommand(TNC, "LISTEN ON\r", TRUE);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
@@ -1508,7 +1461,7 @@ TNCRunning:
if (TNC->Alerted == FALSE)
{
sprintf(TNC->WEB_COMMSSTATE, "Connecting to TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
}
TNC->destaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
@@ -1583,7 +1536,7 @@ TNCRunning:
TNC->Alerted = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
}
// printf("VARA Connect failed\n");
@@ -1613,7 +1566,7 @@ VConnected:
i=sprintf(Msg, "Connect Failed for VARA Data socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -1676,7 +1629,7 @@ VConnected:
TNC->Alerted = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to VARA TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
@@ -1742,7 +1695,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -1766,7 +1719,7 @@ Lost:
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -1795,7 +1748,7 @@ Lost:
// sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
// GetSemaphore(&Semaphore, 52);
-// MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+// MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
// FreeSemaphore(&Semaphore);
@@ -1900,7 +1853,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (_memicmp(Buffer, "SN ", 3) == 0)
{
strcpy(TNC->WEB_PROTOSTATE, &Buffer[3]);
- MySetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+ MySetWindowText(TNC, TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
TNC->SNR = atof(&Buffer[3]);
return;
@@ -1913,10 +1866,10 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
TNC->BusyonTime = GetTickCount();
- MySetWindowText(TNC->xIDC_CHANSTATE, "Busy");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Busy");
strcpy(TNC->WEB_CHANSTATE, "Busy");
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -1935,8 +1888,8 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
}
- MySetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
- TNC->WinmorRestartCodecTimer = time(NULL);
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -2017,7 +1970,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %s",
STREAM->bytesTXed, STREAM->bytesRXed, &Buffer[7]);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
return;
}
@@ -2077,7 +2030,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
strcpy(TNC->WEB_MODE, "2750");
}
- MySetWindowText(TNC->xIDC_MODE, TNC->WEB_MODE);
+ MySetWindowText(TNC, TNC->xIDC_MODE, TNC->WEB_MODE);
memcpy(Call, &Buffer[10], 10);
ptr = strchr(Call, ' ');
@@ -2105,7 +2058,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
memset(STREAM, 0, sizeof(struct STREAMINFO));
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
SuspendOtherPorts(TNC);
@@ -2146,7 +2099,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (WL2K)
strcpy(SESS->RMSCall, WL2K->RMSCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Check for ExcludeList
@@ -2297,7 +2250,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
char Reply[80];
int ReplyLen;
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
if (TNC->NetRomMode)
{
@@ -2342,7 +2295,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
else
sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Outbound", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
UpdateMH(TNC, TNC->TargetCall, '+', 'O');
return;
@@ -2499,7 +2452,7 @@ VOID VARAProcessReceivedData(struct TNCINFO * TNC)
// closesocket(TNC->TCPSock);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
@@ -2701,7 +2654,7 @@ VOID VARAProcessReceivedControl(struct TNCINFO * TNC)
TNC->Streams[0].Disconnecting = FALSE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return;
}
@@ -2773,7 +2726,7 @@ VOID VARAProcessDataPacket(struct TNCINFO * TNC, UCHAR * Data, int Length)
sprintf(TNC->WEB_TRAFFIC, "Sent %d RXed %d Queued %d",
STREAM->bytesTXed, STREAM->bytesRXed,STREAM->BytesOutstanding);
- MySetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+ MySetWindowText(TNC, TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
// if VARAAC Mode, remove byte count from front and add cr
// could possibly be longer than buffer size
@@ -2970,7 +2923,7 @@ VOID VARAReleaseTNC(struct TNCINFO * TNC)
VARASendCommand(TNC, "LISTEN ON\r", TRUE);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
// Start Scanner
@@ -3047,7 +3000,7 @@ void SendVARANetrom(struct TNCINFO * TNC, unsigned char * Data, int Len)
// Save Command, and wait up to 10 secs
sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
TNC->ConnectCmd = _strdup(Connect);
TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
@@ -3057,13 +3010,13 @@ void SendVARANetrom(struct TNCINFO * TNC, unsigned char * Data, int Len)
TNC->OverrideBusy = FALSE;
VARASendCommand(TNC, Connect, TRUE);
- TNC->Streams[0].ConnectTime = time(NULL);
+ TNC->Streams[0].ConnectTime = NOW;
memset(TNC->Streams[0].RemoteCall, 0, 10);
strcpy(TNC->Streams[0].RemoteCall, MYNETROMCALL);
sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
}
}
diff --git a/Versions.h b/Versions.h
index 1115329..d8cfb21 100644
--- a/Versions.h
+++ b/Versions.h
@@ -1,4 +1,3 @@
-
#ifdef Kernel
#define Vers 5,2,9,2
@@ -10,15 +9,15 @@
#endif
-#define KVers 6,0,25,30
-#define KVerstring "6.0.25.30\0"
+#define KVers 6,0,25,41
+#define KVerstring "6.0.25.41\0"
#ifdef CKernel
#define Vers KVers
#define Verstring KVerstring
-#define Datestring "April 2026"
+#define Datestring "September 2026"
#define VerComments "G8BPQ Packet Switch (C Version)" KVerstring
#define VerCopyright "Copyright © 2001-2026 John Wiseman G8BPQ\0"
#define VerDesc "BPQ32 Switch\0"
diff --git a/WINMOR.c b/WINMOR.c
index ac47068..834636e 100644
--- a/WINMOR.c
+++ b/WINMOR.c
@@ -151,6 +151,8 @@ VOID WritetoTraceSupport(struct TNCINFO * TNC, char * Msg, int Len)
if (Len < 0)
return;
+ TNC->PageChanged = TNC->WebSockUsed;
+
Save = Msg[Len];
Msg[Len] = 0;
@@ -215,7 +217,7 @@ lineloop:
#endif
// Write to Web Buffer
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf_s(Time, sizeof(Time),"%02d:%02d ", tm->tm_hour, tm->tm_min);
@@ -263,7 +265,7 @@ lineloop:
#else
index=SendMessage(TNC->hMonitor, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) ptr1 );
#endif
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf_s(Time, sizeof(Time),"%02d:%02d ", tm->tm_hour, tm->tm_min);
@@ -314,24 +316,28 @@ int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF);
struct SEM SetWindTextSem = {0, 0, 0, 0};
-VOID MySetWindowText(HWND hWnd, char * Msg)
+VOID MySetWindowText(struct TNCINFO * TNC, HWND hWnd, char * Msg)
{
+ if (TNC)
+ TNC->PageChanged = TNC->WebSockUsed;
+
#ifndef LINBPQ
+ {
+ PMSGWITHLEN buffptr;
- PMSGWITHLEN buffptr;
+ GetSemaphore(&SetWindTextSem, 61);
+ buffptr = zalloc(400);
- GetSemaphore(&SetWindTextSem, 61);
- buffptr = zalloc(400);
+ if (buffptr)
+ {
+ buffptr->Len= (UINT)hWnd;
+ memcpy(&buffptr->Data[0], Msg, strlen(Msg) + 1);
- if (buffptr)
- {
- buffptr->Len= (UINT)hWnd;
- memcpy(&buffptr->Data[0], Msg, strlen(Msg) + 1);
-
- C_Q_ADD_NP(&SetWindowTextQ, buffptr);
- }
+ C_Q_ADD_NP(&SetWindowTextQ, buffptr);
+ }
- FreeSemaphore(&SetWindTextSem);
+ FreeSemaphore(&SetWindTextSem);
+ }
#endif
}
@@ -592,13 +598,13 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
switch (fn)
{
- case 1: // poll
+ case 7: // poll
// Check session limit timer
if ((STREAM->Connecting || STREAM->Connected) && !STREAM->Disconnecting)
{
- if (TNC->SessionTimeLimit && STREAM->ConnectTime && time(NULL) > (TNC->SessionTimeLimit + STREAM->ConnectTime))
+ if (TNC->SessionTimeLimit && STREAM->ConnectTime && NOW > (TNC->SessionTimeLimit + STREAM->ConnectTime))
{
send(TNC->TCPSock,"DISCONNECT\r\n", 12, 0);
STREAM->Disconnecting = TRUE;
@@ -680,7 +686,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
{
char wtext[100];
sprintf (wtext, "WINMOR Sound Card TNC - BPQ %s", TNC->PortRecord->PORTCONTROL.PORTDESCRIPTION);
- MySetWindowText(TNC->hWnd, wtext);
+ MySetWindowText(TNC, TNC->hWnd, wtext);
}
TNC->HeartBeat = 0;
@@ -693,7 +699,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
send(TNC->TCPSock, "MODE\r\n", 6, 0);
else
{
- if (time(NULL) - TNC->WinmorRestartCodecTimer > 900) // 15 mins
+ if (NOW - TNC->WinmorRestartCodecTimer > 900) // 15 mins
{
send(TNC->TCPSock, "CODEC FALSE\r\n", 13, 0);
send(TNC->TCPSock, "CODEC TRUE\r\n", 12, 0);
@@ -759,19 +765,19 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (TNC->TimeSinceLast++ > 800) // Allow 10 secs for Keepalive
{
// Restart TNC
-
+
if (TNC->ProgramPath && TNC->CONNECTED)
{
if (strstr(TNC->ProgramPath, "WINMOR TNC"))
{
struct tm * tm;
char Time[80];
-
+
TNC->Restarts++;
- TNC->LastRestart = time(NULL);
+ TNC->LastRestart = NOW;
tm = gmtime(&TNC->LastRestart);
-
+
sprintf_s(Time, sizeof(Time),"%04d/%02d/%02d %02d:%02dZ",
tm->tm_year +1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
@@ -781,7 +787,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
sprintf_s(Time, sizeof(Time),"%d", TNC->Restarts);
SetWindowText(TNC->xIDC_RESTARTS, Time);
strcpy(TNC->WEB_RESTARTS, Time);
-
+
KillTNC(TNC);
RestartTNC(TNC);
@@ -819,7 +825,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
// Stop Scanning
sprintf(Msg, "%d SCANSTOP", TNC->Port);
-
+
Rig_Command( (TRANSPORTENTRY *) -1, Msg);
}
@@ -827,72 +833,76 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
if (TNC->Streams[0].Attached)
CheckForDetach(TNC, 0, &TNC->Streams[0], TidyClose, ForcedClose, CloseComplete);
- if (TNC->Streams[0].ReportDISC)
- {
- TNC->Streams[0].ReportDISC = FALSE;
- buff->PORT = 0;
- return -1;
- }
-
- if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+ if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+ {
+ // See if time to reconnect
+
+ time(&ltime);
+ if (ltime - TNC->lasttime > 9 )
{
- // See if time to reconnect
-
- time(&ltime);
- if (ltime - TNC->lasttime > 9 )
- {
- ConnecttoWINMOR(port);
- TNC->lasttime = ltime;
- }
+ ConnecttoWINMOR(port);
+ TNC->lasttime = ltime;
}
-
- FD_ZERO(&readfs);
-
- if (TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&readfs);
-
- FD_ZERO(&writefs);
+ }
- if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+ FD_ZERO(&readfs);
- FD_ZERO(&errorfs);
-
- if (TNC->CONNECTING || TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&errorfs);
+ if (TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&readfs);
+
+ FD_ZERO(&writefs);
+
+ if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPDataSock,&writefs); // Need notification of busy clearing
+
+ FD_ZERO(&errorfs);
+
+ if (TNC->CONNECTING || TNC->CONNECTED) FD_SET(TNC->TCPDataSock,&errorfs);
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0; // poll
+
+ if (select((int)TNC->TCPDataSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ {
+ // See what happened
- timeout.tv_sec = 0;
- timeout.tv_usec = 0; // poll
+ if (FD_ISSET(TNC->TCPDataSock, &readfs))
+ ProcessDataSocketData(port);
- if (select((int)TNC->TCPDataSock + 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ if (FD_ISSET(TNC->TCPDataSock, &writefs))
{
- // See what happened
+ // Write block has cleared. Send rest of packet
- if (FD_ISSET(TNC->TCPDataSock, &readfs))
- ProcessDataSocketData(port);
-
- if (FD_ISSET(TNC->TCPDataSock, &writefs))
- {
- // Write block has cleared. Send rest of packet
+ buffptr=Q_REM(&TNC->BPQtoWINMOR_Q);
+ txlen = buffptr->Len;
+ memcpy(txbuff,buffptr->Data,txlen);
+ bytes=send(TNC->TCPSock, (const char FAR *)&txbuff, (int)txlen, 0);
+ ReleaseBuffer(buffptr);
+ }
- buffptr=Q_REM(&TNC->BPQtoWINMOR_Q);
- txlen = buffptr->Len;
- memcpy(txbuff,buffptr->Data,txlen);
- bytes=send(TNC->TCPSock, (const char FAR *)&txbuff, (int)txlen, 0);
- ReleaseBuffer(buffptr);
- }
-
- if (FD_ISSET(TNC->TCPDataSock, &errorfs))
- {
- i=sprintf(ErrMsg, "WINMOR Data Connection lost for BPQ Port %d\r\n", port);
- WritetoConsole(ErrMsg);
- TNC->CONNECTING = FALSE;
- TNC->CONNECTED = FALSE;
- TNC->Streams[0].ReportDISC = TRUE;
- }
+ if (FD_ISSET(TNC->TCPDataSock, &errorfs))
+ {
+ i=sprintf(ErrMsg, "WINMOR Data Connection lost for BPQ Port %d\r\n", port);
+ WritetoConsole(ErrMsg);
+ TNC->CONNECTING = FALSE;
+ TNC->CONNECTED = FALSE;
+ TNC->Streams[0].ReportDISC = TRUE;
}
-
+ }
+
+ return 0;
+
+ case 1:
+
// See if any frames for this port
+ if (TNC->Streams[0].ReportDISC)
+ {
+ TNC->Streams[0].ReportDISC = FALSE;
+ buff->PORT = 0;
+ return -1;
+ }
+
if (TNC->WINMORtoBPQ_Q != 0)
{
buffptr=Q_REM(&TNC->WINMORtoBPQ_Q);
@@ -1336,12 +1346,12 @@ VOID ReleaseTNC(struct TNCINFO * TNC)
send(TNC->TCPSock, "LISTEN TRUE\r\nMAXCONREQ 4\r\n", 26, 0);
strcpy(TNC->WEB_TNCSTATE, "Free");
- MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ MySetWindowText(TNC, TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
if (TNC->hWnd)
{
sprintf (wtext, "WINMOR Sound Card TNC - BPQ %s", TNC->PortRecord->PORTCONTROL.PORTDESCRIPTION);
- MySetWindowText(TNC->hWnd, wtext);
+ MySetWindowText(TNC, TNC->hWnd, wtext);
}
// Start Scanner
@@ -1416,7 +1426,7 @@ VOID WinmorSuspendPort(struct TNCINFO * TNC, struct TNCINFO * ThisTNC)
if (TNC->Busy)
{
TNC->Busy = FALSE; // Can't clear detector if CODEC off.
- MySetWindowText(TNC->xIDC_CHANSTATE, "Clear");
+ MySetWindowText(TNC, TNC->xIDC_CHANSTATE, "Clear");
strcpy(TNC->WEB_CHANSTATE, "Clear");
}
}
@@ -1429,15 +1439,18 @@ VOID WinmorReleasePort(struct TNCINFO * TNC)
extern char WebProcTemplate[];
extern char sliderBit[];
+extern char Menubit[];
static int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Len = sprintf(Buff, WebProcTemplate, TNC->Port, TNC->Port, "WINMOR Status", "WINMOR Status");
+ int Len = sprintf(Buff, WebProcTemplate, "WINMOR Status");
+
+ if (LOCAL)
+ Len += sprintf(&Buff[Len], Menubit);
if (TNC->TXFreq)
Len += sprintf(&Buff[Len], sliderBit, TNC->TXOffset, TNC->TXOffset);
-
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 500px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
Len += sprintf(&Buff[Len], "<tr><td width=110px>Comms State</td><td>%s</td></tr>", TNC->WEB_COMMSSTATE);
Len += sprintf(&Buff[Len], "<tr><td>TNC State</td><td>%s</td></tr>", TNC->WEB_TNCSTATE);
@@ -1801,7 +1814,7 @@ VOID WINMORThread(void * portptr)
i=sprintf(Msg, "Connect Failed for WINMOR socket - error code = %d\r\n", err);
WritetoConsole(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -1867,7 +1880,7 @@ VOID WINMORThread(void * portptr)
sprintf(TNC->WEB_COMMSSTATE, "Connected to WINMOR TNC");
GetSemaphore(&Semaphore, 40);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
}
@@ -1925,7 +1938,7 @@ Lost:
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
GetSemaphore(&Semaphore, 40);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
TNC->CONNECTED = FALSE;
@@ -1955,7 +1968,7 @@ Lost:
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
GetSemaphore(&Semaphore, 40);
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
TNC->CONNECTED = FALSE;
@@ -2082,7 +2095,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
SetWindowText(TNC->xIDC_CHANSTATE, "Busy");
strcpy(TNC->WEB_CHANSTATE, "Busy");
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -2095,7 +2108,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
strcpy(TNC->WEB_CHANSTATE, "Clear");
SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
return;
}
@@ -2132,7 +2145,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
WritetoTrace(TNC, Buffer, MsgLen - 2);
FreeSemaphore(&Semaphore);
- STREAM->ConnectTime = time(NULL);
+ STREAM->ConnectTime = NOW;
STREAM->bytesRXed = STREAM->bytesTXed = STREAM->PacketsSent = 0;
if (TNC->StartInRobust)
@@ -2483,7 +2496,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
strcpy(TNC->WEB_MODE, &Buffer[5]);
GetSemaphore(&Semaphore, 50);
- MySetWindowText(TNC->xIDC_MODE, &Buffer[5]);
+ MySetWindowText(TNC, TNC->xIDC_MODE, &Buffer[5]);
FreeSemaphore(&Semaphore);
return;
}
@@ -2499,7 +2512,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (_memicmp(Buffer, "NEWSTATE", 8) == 0)
{
- TNC->WinmorRestartCodecTimer = time(NULL);
+ TNC->WinmorRestartCodecTimer = NOW;
SetWindowText(TNC->xIDC_PROTOSTATE, &Buffer[9]);
strcpy(TNC->WEB_PROTOSTATE, &Buffer[9]);
@@ -2710,7 +2723,7 @@ loop:
// Does this mean closed?
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTING = FALSE;
TNC->CONNECTED = FALSE;
diff --git a/WebMail.c b/WebMail.c
index f7ba786..4c3d3f8 100644
--- a/WebMail.c
+++ b/WebMail.c
@@ -1006,7 +1006,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
if (Msg == NULL)
{
ptr += sprintf(ptr, "Message %d not found\r\n", Number);
- return sprintf(Reply, WebMailTemplate, BBSName, User->Call, Key, Key, Key, Key, Key, Key, Key, Message);
+ return sprintf(Reply, WebMailTemplate, BBSName, User->Call, Key, Key, Key, Key, Key, Key, Key, Key, Key, Key, Message);
}
// New Display so free any old values
@@ -1019,7 +1019,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
if (!CheckUserMsg(Msg, User->Call, User->flags & F_SYSOP))
{
ptr += sprintf(ptr, "Message %d not for you\r", Number);
- return sprintf(Reply, WebMailTemplate, BBSName, User->Call, Key, Key, Key, Key, Key, Key, Key, Message);
+ return sprintf(Reply, WebMailTemplate, BBSName, User->Call, Key, Key, Key, Key, Key, Key, Key, Key, Key, Key, Message);
}
if (_stricmp(Msg->to, "RMS") == 0)
@@ -1995,10 +1995,10 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL
" if (\"WebSocket\" in window)"
" {"
" // open a web socket. Get address from URL\r\n"
- " var text = window.location.href;"
- " var result = text.substring(7);"
- " var myArray = result.split('/', 1);"
- " ws = new WebSocket('ws://' + myArray[0] + '/WMRefresh&%s');\r\n"
+
+ " var proto = (window.location.protocol === 'https:') ? 'wss://' : 'ws://';\r\n"
+ " ws = new WebSocket(proto + window.location.host + '/WMRefresh&%s');\r\n"
+
" ws.onopen = function() {\r\n"
@@ -2191,7 +2191,7 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL
EncodedTitle = doXMLTransparency(Msg->title);
- *RLen = sprintf(Reply, MsgInputPage, Key, Msg->from, Temp, EncodedTitle , "");
+ *RLen = sprintf(Reply, MsgInputPage, Key, ReplyAddr, Temp, EncodedTitle , "");
free(EncodedTitle);
return;
diff --git a/Win32bits/AFXRES.H b/Win32bits/AFXRES.H
new file mode 100644
index 0000000..5ae2ed0
--- /dev/null
+++ b/Win32bits/AFXRES.H
@@ -0,0 +1,750 @@
+// This is a part of the Microsoft Foundation Classes C++ library.
+// Copyright (C) 1992-1995 Microsoft Corporation
+// All rights reserved.
+//
+// This source code is only intended as a supplement to the
+// Microsoft Foundation Classes Reference and related
+// electronic documentation provided with the library.
+// See these sources for detailed information regarding the
+// Microsoft Foundation Classes product.
+
+#ifndef __AFXRES_H__
+#define __AFXRES_H__
+
+#ifdef REZ // Mac resource compiler (mrc) defines REZ
+#define RC_INVOKED
+#endif
+
+#ifdef RC_INVOKED
+#ifndef _INC_WINDOWS
+#define _INC_WINDOWS
+ #include "winres.h" // extract from windows header
+#endif
+#endif
+
+#ifdef _AFX_MINREBUILD
+#pragma component(minrebuild, off)
+#endif
+
+#ifdef APSTUDIO_INVOKED
+#define APSTUDIO_HIDDEN_SYMBOLS
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// MFC resource types (see Technical note TN024 for implementation details)
+
+#ifndef RC_INVOKED
+#define RT_DLGINIT MAKEINTRESOURCE(240)
+#define RT_TOOLBAR MAKEINTRESOURCE(241)
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef APSTUDIO_INVOKED
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// General style bits etc
+
+// Tab Control styles
+#ifndef TCS_MULTILINE // new in later versions of Win32
+#define TCS_MULTILINE 0x0200
+#endif
+
+// ControlBar styles
+#define CBRS_ALIGN_LEFT 0x1000L
+#define CBRS_ALIGN_TOP 0x2000L
+#define CBRS_ALIGN_RIGHT 0x4000L
+#define CBRS_ALIGN_BOTTOM 0x8000L
+#define CBRS_ALIGN_ANY 0xF000L
+
+#define CBRS_BORDER_LEFT 0x0100L
+#define CBRS_BORDER_TOP 0x0200L
+#define CBRS_BORDER_RIGHT 0x0400L
+#define CBRS_BORDER_BOTTOM 0x0800L
+#define CBRS_BORDER_ANY 0x0F00L
+
+#define CBRS_TOOLTIPS 0x0010L
+#define CBRS_FLYBY 0x0020L
+#define CBRS_FLOAT_MULTI 0x0040L
+#define CBRS_BORDER_3D 0x0080L
+#define CBRS_HIDE_INPLACE 0x0008L
+#define CBRS_SIZE_DYNAMIC 0x0004L
+#define CBRS_SIZE_FIXED 0x0002L
+#define CBRS_FLOATING 0x0001L
+
+#define CBRS_ORIENT_HORZ (CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM)
+#define CBRS_ORIENT_VERT (CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT)
+#define CBRS_ORIENT_ANY (CBRS_ORIENT_HORZ|CBRS_ORIENT_VERT)
+
+#define CBRS_ALL 0xFFFFL
+
+
+// the CBRS_ style is made up of an alignment style and a draw border style
+// the alignment styles are mutually exclusive
+// the draw border styles may be combined
+#define CBRS_NOALIGN 0x00000000L
+#define CBRS_LEFT (CBRS_ALIGN_LEFT|CBRS_BORDER_RIGHT)
+#define CBRS_TOP (CBRS_ALIGN_TOP|CBRS_BORDER_BOTTOM)
+#define CBRS_RIGHT (CBRS_ALIGN_RIGHT|CBRS_BORDER_LEFT)
+#define CBRS_BOTTOM (CBRS_ALIGN_BOTTOM|CBRS_BORDER_TOP)
+
+/////////////////////////////////////////////////////////////////////////////
+// Standard window components
+
+// Mode indicators in status bar - these are routed like commands
+#define ID_INDICATOR_EXT 0xE700 // extended selection indicator
+#define ID_INDICATOR_CAPS 0xE701 // cap lock indicator
+#define ID_INDICATOR_NUM 0xE702 // num lock indicator
+#define ID_INDICATOR_SCRL 0xE703 // scroll lock indicator
+#define ID_INDICATOR_OVR 0xE704 // overtype mode indicator
+#define ID_INDICATOR_REC 0xE705 // record mode indicator
+#define ID_INDICATOR_KANA 0xE706 // kana lock indicator
+
+#define ID_SEPARATOR 0 // special separator value
+
+#ifndef RC_INVOKED // code only
+// Standard control bars (IDW = window ID)
+#define AFX_IDW_CONTROLBAR_FIRST 0xE800
+#define AFX_IDW_CONTROLBAR_LAST 0xE8FF
+
+#define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window
+#define AFX_IDW_STATUS_BAR 0xE801 // Status bar window
+#define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar
+#define AFX_IDW_RESIZE_BAR 0xE803 // OLE in-place resize bar
+
+// Note: If your application supports docking toolbars, you should
+// not use the following IDs for your own toolbars. The IDs chosen
+// are at the top of the first 32 such that the bars will be hidden
+// while in print preview mode, and are not likely to conflict with
+// IDs your application may have used succesfully in the past.
+
+#define AFX_IDW_DOCKBAR_TOP 0xE81B
+#define AFX_IDW_DOCKBAR_LEFT 0xE81C
+#define AFX_IDW_DOCKBAR_RIGHT 0xE81D
+#define AFX_IDW_DOCKBAR_BOTTOM 0xE81E
+#define AFX_IDW_DOCKBAR_FLOAT 0xE81F
+
+// Macro for mapping standard control bars to bitmask (limit of 32)
+#define AFX_CONTROLBAR_MASK(nIDC) (1L << (nIDC - AFX_IDW_CONTROLBAR_FIRST))
+
+// parts of Main Frame
+#define AFX_IDW_PANE_FIRST 0xE900 // first pane (256 max)
+#define AFX_IDW_PANE_LAST 0xE9ff
+#define AFX_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max)
+#define AFX_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max)
+
+#define AFX_IDW_SIZE_BOX 0xEA20 // size box for splitters
+#define AFX_IDW_PANE_SAVE 0xEA21 // to shift AFX_IDW_PANE_FIRST
+#endif //!RC_INVOKED
+
+#ifndef APSTUDIO_INVOKED
+
+// common style for form views
+#define AFX_WS_DEFAULT_VIEW (WS_CHILD | WS_VISIBLE | WS_BORDER)
+
+#endif //!APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+// Standard app configurable strings
+
+// for application title (defaults to EXE name or name in constructor)
+#define AFX_IDS_APP_TITLE 0xE000
+// idle message bar line
+#define AFX_IDS_IDLEMESSAGE 0xE001
+// message bar line when in shift-F1 help mode
+#define AFX_IDS_HELPMODEMESSAGE 0xE002
+// document title when editing OLE embedding
+#define AFX_IDS_APP_TITLE_EMBEDDING 0xE003
+// company name
+#define AFX_IDS_COMPANY_NAME 0xE004
+// object name when server is inplace
+#define AFX_IDS_OBJ_TITLE_INPLACE 0xE005
+
+/////////////////////////////////////////////////////////////////////////////
+// Standard Commands
+
+// File commands
+#define ID_FILE_NEW 0xE100
+#define ID_FILE_OPEN 0xE101
+#define ID_FILE_CLOSE 0xE102
+#define ID_FILE_SAVE 0xE103
+#define ID_FILE_SAVE_AS 0xE104
+#define ID_FILE_PAGE_SETUP 0xE105
+#define ID_FILE_PRINT_SETUP 0xE106
+#define ID_FILE_PRINT 0xE107
+#define ID_FILE_PRINT_DIRECT 0xE108
+#define ID_FILE_PRINT_PREVIEW 0xE109
+#define ID_FILE_UPDATE 0xE10A
+#define ID_FILE_SAVE_COPY_AS 0xE10B
+#define ID_FILE_SEND_MAIL 0xE10C
+
+#define ID_FILE_MRU_FIRST 0xE110
+#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max
+#define ID_FILE_MRU_FILE2 0xE111
+#define ID_FILE_MRU_FILE3 0xE112
+#define ID_FILE_MRU_FILE4 0xE113
+#define ID_FILE_MRU_FILE5 0xE114
+#define ID_FILE_MRU_FILE6 0xE115
+#define ID_FILE_MRU_FILE7 0xE116
+#define ID_FILE_MRU_FILE8 0xE117
+#define ID_FILE_MRU_FILE9 0xE118
+#define ID_FILE_MRU_FILE10 0xE119
+#define ID_FILE_MRU_FILE11 0xE11A
+#define ID_FILE_MRU_FILE12 0xE11B
+#define ID_FILE_MRU_FILE13 0xE11C
+#define ID_FILE_MRU_FILE14 0xE11D
+#define ID_FILE_MRU_FILE15 0xE11E
+#define ID_FILE_MRU_FILE16 0xE11F
+#define ID_FILE_MRU_LAST 0xE11F
+
+// Edit commands
+#define ID_EDIT_CLEAR 0xE120
+#define ID_EDIT_CLEAR_ALL 0xE121
+#define ID_EDIT_COPY 0xE122
+#define ID_EDIT_CUT 0xE123
+#define ID_EDIT_FIND 0xE124
+#define ID_EDIT_PASTE 0xE125
+#define ID_EDIT_PASTE_LINK 0xE126
+#define ID_EDIT_PASTE_SPECIAL 0xE127
+#define ID_EDIT_REPEAT 0xE128
+#define ID_EDIT_REPLACE 0xE129
+#define ID_EDIT_SELECT_ALL 0xE12A
+#define ID_EDIT_UNDO 0xE12B
+#define ID_EDIT_REDO 0xE12C
+
+// Window commands
+#define ID_WINDOW_NEW 0xE130
+#define ID_WINDOW_ARRANGE 0xE131
+#define ID_WINDOW_CASCADE 0xE132
+#define ID_WINDOW_TILE_HORZ 0xE133
+#define ID_WINDOW_TILE_VERT 0xE134
+#define ID_WINDOW_SPLIT 0xE135
+#ifndef RC_INVOKED // code only
+#define AFX_IDM_WINDOW_FIRST 0xE130
+#define AFX_IDM_WINDOW_LAST 0xE13F
+#define AFX_IDM_FIRST_MDICHILD 0xFF00 // window list starts here
+#endif //!RC_INVOKED
+
+// Help and App commands
+#define ID_APP_ABOUT 0xE140
+#define ID_APP_EXIT 0xE141
+#define ID_HELP_INDEX 0xE142
+#define ID_HELP_FINDER 0xE143
+#define ID_HELP_USING 0xE144
+#define ID_CONTEXT_HELP 0xE145 // shift-F1
+// special commands for processing help
+#define ID_HELP 0xE146 // first attempt for F1
+#define ID_DEFAULT_HELP 0xE147 // last attempt
+
+// Misc
+#define ID_NEXT_PANE 0xE150
+#define ID_PREV_PANE 0xE151
+
+// Format
+#define ID_FORMAT_FONT 0xE160
+
+// OLE commands
+#define ID_OLE_INSERT_NEW 0xE200
+#define ID_OLE_EDIT_LINKS 0xE201
+#define ID_OLE_EDIT_CONVERT 0xE202
+#define ID_OLE_EDIT_CHANGE_ICON 0xE203
+#define ID_OLE_EDIT_PROPERTIES 0xE204
+#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max
+#ifndef RC_INVOKED // code only
+#define ID_OLE_VERB_LAST 0xE21F
+#endif //!RC_INVOKED
+
+// for print preview dialog bar
+#define AFX_ID_PREVIEW_CLOSE 0xE300
+#define AFX_ID_PREVIEW_NUMPAGE 0xE301 // One/Two Page button
+#define AFX_ID_PREVIEW_NEXT 0xE302
+#define AFX_ID_PREVIEW_PREV 0xE303
+#define AFX_ID_PREVIEW_PRINT 0xE304
+#define AFX_ID_PREVIEW_ZOOMIN 0xE305
+#define AFX_ID_PREVIEW_ZOOMOUT 0xE306
+
+// View commands (same number used as IDW used for control bar)
+#define ID_VIEW_TOOLBAR 0xE800
+#define ID_VIEW_STATUS_BAR 0xE801
+ // -> E8FF reserved for other control bar commands
+
+// RecordForm commands
+#define ID_RECORD_FIRST 0xE900
+#define ID_RECORD_LAST 0xE901
+#define ID_RECORD_NEXT 0xE902
+#define ID_RECORD_PREV 0xE903
+
+/////////////////////////////////////////////////////////////////////////////
+// Standard control IDs
+
+#ifdef IDC_STATIC
+#undef IDC_STATIC
+#endif
+#define IDC_STATIC (-1) // all static controls
+
+/////////////////////////////////////////////////////////////////////////////
+// Standard string error/warnings
+
+#ifndef RC_INVOKED // code only
+#define AFX_IDS_SCFIRST 0xEF00
+#endif //!RC_INVOKED
+
+#define AFX_IDS_SCSIZE 0xEF00
+#define AFX_IDS_SCMOVE 0xEF01
+#define AFX_IDS_SCMINIMIZE 0xEF02
+#define AFX_IDS_SCMAXIMIZE 0xEF03
+#define AFX_IDS_SCNEXTWINDOW 0xEF04
+#define AFX_IDS_SCPREVWINDOW 0xEF05
+#define AFX_IDS_SCCLOSE 0xEF06
+#define AFX_IDS_SCRESTORE 0xEF12
+#define AFX_IDS_SCTASKLIST 0xEF13
+
+#define AFX_IDS_MDICHILD 0xEF1F
+
+#define AFX_IDS_DESKACCESSORY 0xEFDA
+
+// General strings
+#define AFX_IDS_OPENFILE 0xF000
+#define AFX_IDS_SAVEFILE 0xF001
+#define AFX_IDS_ALLFILTER 0xF002
+#define AFX_IDS_UNTITLED 0xF003
+#define AFX_IDS_SAVEFILECOPY 0xF004
+#define AFX_IDS_PREVIEW_CLOSE 0xF005
+#define AFX_IDS_UNNAMED_FILE 0xF006
+#ifdef _MAC
+#define AFX_IDS_ABOUT 0xF010
+#endif
+#define AFX_IDS_HIDE 0xF011
+
+// MFC Standard Exception Error messages
+#define AFX_IDP_NO_ERROR_AVAILABLE 0xF020
+#define AFX_IDS_NOT_SUPPORTED_EXCEPTION 0xF021
+#define AFX_IDS_RESOURCE_EXCEPTION 0xF022
+#define AFX_IDS_MEMORY_EXCEPTION 0xF023
+#define AFX_IDS_USER_EXCEPTION 0xF024
+
+// Printing and print preview strings
+#define AFX_IDS_PRINTONPORT 0xF040
+#define AFX_IDS_ONEPAGE 0xF041
+#define AFX_IDS_TWOPAGE 0xF042
+#define AFX_IDS_PRINTPAGENUM 0xF043
+#define AFX_IDS_PREVIEWPAGEDESC 0xF044
+#define AFX_IDS_PRINTDEFAULTEXT 0xF045
+#define AFX_IDS_PRINTDEFAULT 0xF046
+#define AFX_IDS_PRINTFILTER 0xF047
+#define AFX_IDS_PRINTCAPTION 0xF048
+#define AFX_IDS_PRINTTOFILE 0xF049
+
+
+// OLE strings
+#define AFX_IDS_OBJECT_MENUITEM 0xF080
+#define AFX_IDS_EDIT_VERB 0xF081
+#define AFX_IDS_ACTIVATE_VERB 0xF082
+#define AFX_IDS_CHANGE_LINK 0xF083
+#define AFX_IDS_AUTO 0xF084
+#define AFX_IDS_MANUAL 0xF085
+#define AFX_IDS_FROZEN 0xF086
+#define AFX_IDS_ALL_FILES 0xF087
+// dynamically changing menu items
+#define AFX_IDS_SAVE_MENU 0xF088
+#define AFX_IDS_UPDATE_MENU 0xF089
+#define AFX_IDS_SAVE_AS_MENU 0xF08A
+#define AFX_IDS_SAVE_COPY_AS_MENU 0xF08B
+#define AFX_IDS_EXIT_MENU 0xF08C
+#define AFX_IDS_UPDATING_ITEMS 0xF08D
+// COlePasteSpecialDialog defines
+#define AFX_IDS_METAFILE_FORMAT 0xF08E
+#define AFX_IDS_DIB_FORMAT 0xF08F
+#define AFX_IDS_BITMAP_FORMAT 0xF090
+#define AFX_IDS_LINKSOURCE_FORMAT 0xF091
+#define AFX_IDS_EMBED_FORMAT 0xF092
+// other OLE utility strings
+#define AFX_IDS_PASTELINKEDTYPE 0xF094
+#define AFX_IDS_UNKNOWNTYPE 0xF095
+#define AFX_IDS_RTF_FORMAT 0xF096
+#define AFX_IDS_TEXT_FORMAT 0xF097
+// OLE datatype format error strings
+#define AFX_IDS_INVALID_CURRENCY 0xF098
+#define AFX_IDS_INVALID_DATETIME 0xF099
+#define AFX_IDS_INVALID_DATETIMESPAN 0xF09A
+
+// General error / prompt strings
+#define AFX_IDP_INVALID_FILENAME 0xF100
+#define AFX_IDP_FAILED_TO_OPEN_DOC 0xF101
+#define AFX_IDP_FAILED_TO_SAVE_DOC 0xF102
+#define AFX_IDP_ASK_TO_SAVE 0xF103
+#define AFX_IDP_FAILED_TO_CREATE_DOC 0xF104
+#define AFX_IDP_FILE_TOO_LARGE 0xF105
+#define AFX_IDP_FAILED_TO_START_PRINT 0xF106
+#define AFX_IDP_FAILED_TO_LAUNCH_HELP 0xF107
+#define AFX_IDP_INTERNAL_FAILURE 0xF108 // general failure
+#define AFX_IDP_COMMAND_FAILURE 0xF109 // command failure
+#define AFX_IDP_FAILED_MEMORY_ALLOC 0xF10A
+
+// DDV parse errors
+#define AFX_IDP_PARSE_INT 0xF110
+#define AFX_IDP_PARSE_REAL 0xF111
+#define AFX_IDP_PARSE_INT_RANGE 0xF112
+#define AFX_IDP_PARSE_REAL_RANGE 0xF113
+#define AFX_IDP_PARSE_STRING_SIZE 0xF114
+#define AFX_IDP_PARSE_RADIO_BUTTON 0xF115
+#define AFX_IDP_PARSE_BYTE 0xF116
+#define AFX_IDP_PARSE_UINT 0xF117
+#define AFX_IDP_PARSE_DATETIME 0xF118
+#define AFX_IDP_PARSE_CURRENCY 0xF119
+
+// CFile/CArchive error strings for user failure
+#define AFX_IDP_FAILED_INVALID_FORMAT 0xF120
+#define AFX_IDP_FAILED_INVALID_PATH 0xF121
+#define AFX_IDP_FAILED_DISK_FULL 0xF122
+#define AFX_IDP_FAILED_ACCESS_READ 0xF123
+#define AFX_IDP_FAILED_ACCESS_WRITE 0xF124
+#define AFX_IDP_FAILED_IO_ERROR_READ 0xF125
+#define AFX_IDP_FAILED_IO_ERROR_WRITE 0xF126
+
+// OLE errors / prompt strings
+#define AFX_IDP_STATIC_OBJECT 0xF180
+#define AFX_IDP_FAILED_TO_CONNECT 0xF181
+#define AFX_IDP_SERVER_BUSY 0xF182
+#define AFX_IDP_BAD_VERB 0xF183
+#define AFX_IDP_FAILED_TO_NOTIFY 0xF185
+#define AFX_IDP_FAILED_TO_LAUNCH 0xF186
+#define AFX_IDP_ASK_TO_UPDATE 0xF187
+#define AFX_IDP_FAILED_TO_UPDATE 0xF188
+#define AFX_IDP_FAILED_TO_REGISTER 0xF189
+#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A
+#define AFX_IDP_FAILED_TO_CONVERT 0xF18B
+#define AFX_IDP_GET_NOT_SUPPORTED 0xF18C
+#define AFX_IDP_SET_NOT_SUPPORTED 0xF18D
+#define AFX_IDP_ASK_TO_DISCARD 0xF18E
+#define AFX_IDP_FAILED_TO_CREATE 0xF18F
+
+// MAPI errors / prompt strings
+#define AFX_IDP_FAILED_MAPI_LOAD 0xF190
+#define AFX_IDP_INVALID_MAPI_DLL 0xF191
+#define AFX_IDP_FAILED_MAPI_SEND 0xF192
+
+#define AFX_IDP_FILE_NONE 0xF1A0
+#define AFX_IDP_FILE_GENERIC 0xF1A1
+#define AFX_IDP_FILE_NOT_FOUND 0xF1A2
+#define AFX_IDP_FILE_BAD_PATH 0xF1A3
+#define AFX_IDP_FILE_TOO_MANY_OPEN 0xF1A4
+#define AFX_IDP_FILE_ACCESS_DENIED 0xF1A5
+#define AFX_IDP_FILE_INVALID_FILE 0xF1A6
+#define AFX_IDP_FILE_REMOVE_CURRENT 0xF1A7
+#define AFX_IDP_FILE_DIR_FULL 0xF1A8
+#define AFX_IDP_FILE_BAD_SEEK 0xF1A9
+#define AFX_IDP_FILE_HARD_IO 0xF1AA
+#define AFX_IDP_FILE_SHARING 0xF1AB
+#define AFX_IDP_FILE_LOCKING 0xF1AC
+#define AFX_IDP_FILE_DISKFULL 0xF1AD
+#define AFX_IDP_FILE_EOF 0xF1AE
+
+#define AFX_IDP_ARCH_NONE 0xF1B0
+#define AFX_IDP_ARCH_GENERIC 0xF1B1
+#define AFX_IDP_ARCH_READONLY 0xF1B2
+#define AFX_IDP_ARCH_ENDOFFILE 0xF1B3
+#define AFX_IDP_ARCH_WRITEONLY 0xF1B4
+#define AFX_IDP_ARCH_BADINDEX 0xF1B5
+#define AFX_IDP_ARCH_BADCLASS 0xF1B6
+#define AFX_IDP_ARCH_BADSCHEMA 0xF1B7
+
+#define AFX_IDS_OCC_SCALEUNITS_PIXELS 0xF1C0
+
+// 0xf200-0xf20f reserved
+
+// font names and point sizes
+#define AFX_IDS_STATUS_FONT 0xF230
+#define AFX_IDS_TOOLTIP_FONT 0xF231
+#define AFX_IDS_UNICODE_FONT 0xF232
+#define AFX_IDS_MINI_FONT 0xF233
+
+// ODBC Database errors / prompt strings
+#ifndef RC_INVOKED // code only
+#define AFX_IDP_SQL_FIRST 0xF280
+#endif //!RC_INVOKED
+#define AFX_IDP_SQL_CONNECT_FAIL 0xF281
+#define AFX_IDP_SQL_RECORDSET_FORWARD_ONLY 0xF282
+#define AFX_IDP_SQL_EMPTY_COLUMN_LIST 0xF283
+#define AFX_IDP_SQL_FIELD_SCHEMA_MISMATCH 0xF284
+#define AFX_IDP_SQL_ILLEGAL_MODE 0xF285
+#define AFX_IDP_SQL_MULTIPLE_ROWS_AFFECTED 0xF286
+#define AFX_IDP_SQL_NO_CURRENT_RECORD 0xF287
+#define AFX_IDP_SQL_NO_ROWS_AFFECTED 0xF288
+#define AFX_IDP_SQL_RECORDSET_READONLY 0xF289
+#define AFX_IDP_SQL_SQL_NO_TOTAL 0xF28A
+#define AFX_IDP_SQL_ODBC_LOAD_FAILED 0xF28B
+#define AFX_IDP_SQL_DYNASET_NOT_SUPPORTED 0xF28C
+#define AFX_IDP_SQL_SNAPSHOT_NOT_SUPPORTED 0xF28D
+#define AFX_IDP_SQL_API_CONFORMANCE 0xF28E
+#define AFX_IDP_SQL_SQL_CONFORMANCE 0xF28F
+#define AFX_IDP_SQL_NO_DATA_FOUND 0xF290
+#define AFX_IDP_SQL_ROW_UPDATE_NOT_SUPPORTED 0xF291
+#define AFX_IDP_SQL_ODBC_V2_REQUIRED 0xF292
+#define AFX_IDP_SQL_NO_POSITIONED_UPDATES 0xF293
+#define AFX_IDP_SQL_LOCK_MODE_NOT_SUPPORTED 0xF294
+#define AFX_IDP_SQL_DATA_TRUNCATED 0xF295
+#define AFX_IDP_SQL_ROW_FETCH 0xF296
+#define AFX_IDP_SQL_INCORRECT_ODBC 0xF297
+#define AFX_IDP_SQL_UPDATE_DELETE_FAILED 0xF298
+#define AFX_IDP_SQL_DYNAMIC_CURSOR_NOT_SUPPORTED 0xF299
+
+// DAO Database errors / prompt strings
+#ifndef RC_INVOKED // code only
+#define AFX_IDP_DAO_FIRST 0xF2A0
+#endif //!RC_INVOKED
+#define AFX_IDP_DAO_ENGINE_INITIALIZATION 0xF2A0
+#define AFX_IDP_DAO_DFX_BIND 0xF2A1
+#define AFX_IDP_DAO_OBJECT_NOT_OPEN 0xF2A2
+
+// ICDAORecordset::GetRows Errors
+// These are not placed in DAO Errors collection
+// and must be handled directly by MFC.
+#define AFX_IDP_DAO_ROWTOOSHORT 0xF2A3
+#define AFX_IDP_DAO_BADBINDINFO 0xF2A4
+#define AFX_IDP_DAO_COLUMNUNAVAILABLE 0xF2A5
+
+/////////////////////////////////////////////////////////////////////////////
+// AFX implementation - control IDs (AFX_IDC)
+
+// Parts of dialogs
+#define AFX_IDC_LISTBOX 100
+#define AFX_IDC_CHANGE 101
+
+// for print dialog
+#define AFX_IDC_PRINT_DOCNAME 201
+#define AFX_IDC_PRINT_PRINTERNAME 202
+#define AFX_IDC_PRINT_PORTNAME 203
+#define AFX_IDC_PRINT_PAGENUM 204
+
+// Property Sheet control id's (determined with Spy++)
+#define ID_APPLY_NOW 0x3021
+#define ID_WIZBACK 0x3023
+#define ID_WIZNEXT 0x3024
+#define ID_WIZFINISH 0x3025
+#define AFX_IDC_TAB_CONTROL 0x3020
+
+/////////////////////////////////////////////////////////////////////////////
+// IDRs for standard components
+
+#ifndef RC_INVOKED // code only
+// These are really COMMDLG dialogs, so there usually isn't a resource
+// for them, but these IDs are used as help IDs.
+#define AFX_IDD_FILEOPEN 28676
+#define AFX_IDD_FILESAVE 28677
+#define AFX_IDD_FONT 28678
+#define AFX_IDD_COLOR 28679
+#define AFX_IDD_PRINT 28680
+#define AFX_IDD_PRINTSETUP 28681
+#define AFX_IDD_FIND 28682
+#define AFX_IDD_REPLACE 28683
+#endif //!RC_INVOKED
+
+// Standard dialogs app should leave alone (0x7801->)
+#define AFX_IDD_NEWTYPEDLG 30721
+#define AFX_IDD_PRINTDLG 30722
+#define AFX_IDD_PREVIEW_TOOLBAR 30723
+#ifdef _MAC
+#define AFX_IDD_PREVIEW_SHORTTOOLBAR 30731
+#endif
+
+// Dialogs defined for OLE2UI library
+#define AFX_IDD_INSERTOBJECT 30724
+#define AFX_IDD_CHANGEICON 30725
+#define AFX_IDD_CONVERT 30726
+#define AFX_IDD_PASTESPECIAL 30727
+#define AFX_IDD_EDITLINKS 30728
+#define AFX_IDD_FILEBROWSE 30729
+#define AFX_IDD_BUSY 30730
+
+#define AFX_IDD_OBJECTPROPERTIES 30732
+#define AFX_IDD_CHANGESOURCE 30733
+
+// Standard cursors (0x7901->)
+ // AFX_IDC = Cursor resources
+#define AFX_IDC_CONTEXTHELP 30977 // context sensitive help
+#define AFX_IDC_MAGNIFY 30978 // print preview zoom
+#define AFX_IDC_SMALLARROWS 30979 // splitter
+#define AFX_IDC_HSPLITBAR 30980 // splitter
+#define AFX_IDC_VSPLITBAR 30981 // splitter
+#define AFX_IDC_NODROPCRSR 30982 // No Drop Cursor
+#define AFX_IDC_TRACKNWSE 30983 // tracker
+#define AFX_IDC_TRACKNESW 30984 // tracker
+#define AFX_IDC_TRACKNS 30985 // tracker
+#define AFX_IDC_TRACKWE 30986 // tracker
+#define AFX_IDC_TRACK4WAY 30987 // tracker
+#define AFX_IDC_MOVE4WAY 30988 // resize bar (server only)
+
+// Mini frame window bitmap ID
+#define AFX_IDB_MINIFRAME_MENU 30994
+
+// CheckListBox checks bitmap ID
+#define AFX_IDB_CHECKLISTBOX_NT 30995
+#define AFX_IDB_CHECKLISTBOX_95 30996
+
+// AFX standard accelerator resources
+#define AFX_IDR_PREVIEW_ACCEL 30997
+
+// AFX standard ICON IDs (for MFC V1 apps) (0x7A01->)
+#define AFX_IDI_STD_MDIFRAME 31233
+#define AFX_IDI_STD_FRAME 31234
+
+/////////////////////////////////////////////////////////////////////////////
+// AFX OLE control implementation - control IDs (AFX_IDC)
+
+// Font property page
+#define AFX_IDC_FONTPROP 1000
+#define AFX_IDC_FONTNAMES 1001
+#define AFX_IDC_FONTSTYLES 1002
+#define AFX_IDC_FONTSIZES 1003
+#define AFX_IDC_STRIKEOUT 1004
+#define AFX_IDC_UNDERLINE 1005
+#define AFX_IDC_SAMPLEBOX 1006
+
+// Color property page
+#define AFX_IDC_COLOR_BLACK 1100
+#define AFX_IDC_COLOR_WHITE 1101
+#define AFX_IDC_COLOR_RED 1102
+#define AFX_IDC_COLOR_GREEN 1103
+#define AFX_IDC_COLOR_BLUE 1104
+#define AFX_IDC_COLOR_YELLOW 1105
+#define AFX_IDC_COLOR_MAGENTA 1106
+#define AFX_IDC_COLOR_CYAN 1107
+#define AFX_IDC_COLOR_GRAY 1108
+#define AFX_IDC_COLOR_LIGHTGRAY 1109
+#define AFX_IDC_COLOR_DARKRED 1110
+#define AFX_IDC_COLOR_DARKGREEN 1111
+#define AFX_IDC_COLOR_DARKBLUE 1112
+#define AFX_IDC_COLOR_LIGHTBROWN 1113
+#define AFX_IDC_COLOR_DARKMAGENTA 1114
+#define AFX_IDC_COLOR_DARKCYAN 1115
+#define AFX_IDC_COLORPROP 1116
+#define AFX_IDC_SYSTEMCOLORS 1117
+
+// Picture porperty page
+#define AFX_IDC_PROPNAME 1201
+#define AFX_IDC_PICTURE 1202
+#define AFX_IDC_BROWSE 1203
+#define AFX_IDC_CLEAR 1204
+
+/////////////////////////////////////////////////////////////////////////////
+// IDRs for OLE control standard components
+
+// Standard propery page dialogs app should leave alone (0x7E01->)
+#define AFX_IDD_PROPPAGE_COLOR 32257
+#define AFX_IDD_PROPPAGE_FONT 32258
+#define AFX_IDD_PROPPAGE_PICTURE 32259
+
+#define AFX_IDB_TRUETYPE 32384
+
+/////////////////////////////////////////////////////////////////////////////
+// Standard OLE control strings
+
+// OLE Control page strings
+#define AFX_IDS_PROPPAGE_UNKNOWN 0xFE01
+#define AFX_IDS_COLOR_DESKTOP 0xFE04
+#define AFX_IDS_COLOR_APPWORKSPACE 0xFE05
+#define AFX_IDS_COLOR_WNDBACKGND 0xFE06
+#define AFX_IDS_COLOR_WNDTEXT 0xFE07
+#define AFX_IDS_COLOR_MENUBAR 0xFE08
+#define AFX_IDS_COLOR_MENUTEXT 0xFE09
+#define AFX_IDS_COLOR_ACTIVEBAR 0xFE0A
+#define AFX_IDS_COLOR_INACTIVEBAR 0xFE0B
+#define AFX_IDS_COLOR_ACTIVETEXT 0xFE0C
+#define AFX_IDS_COLOR_INACTIVETEXT 0xFE0D
+#define AFX_IDS_COLOR_ACTIVEBORDER 0xFE0E
+#define AFX_IDS_COLOR_INACTIVEBORDER 0xFE0F
+#define AFX_IDS_COLOR_WNDFRAME 0xFE10
+#define AFX_IDS_COLOR_SCROLLBARS 0xFE11
+#define AFX_IDS_COLOR_BTNFACE 0xFE12
+#define AFX_IDS_COLOR_BTNSHADOW 0xFE13
+#define AFX_IDS_COLOR_BTNTEXT 0xFE14
+#define AFX_IDS_COLOR_BTNHIGHLIGHT 0xFE15
+#define AFX_IDS_COLOR_DISABLEDTEXT 0xFE16
+#define AFX_IDS_COLOR_HIGHLIGHT 0xFE17
+#define AFX_IDS_COLOR_HIGHLIGHTTEXT 0xFE18
+#define AFX_IDS_REGULAR 0xFE19
+#define AFX_IDS_BOLD 0xFE1A
+#define AFX_IDS_ITALIC 0xFE1B
+#define AFX_IDS_BOLDITALIC 0xFE1C
+#define AFX_IDS_SAMPLETEXT 0xFE1D
+#define AFX_IDS_DISPLAYSTRING_FONT 0xFE1E
+#define AFX_IDS_DISPLAYSTRING_COLOR 0xFE1F
+#define AFX_IDS_DISPLAYSTRING_PICTURE 0xFE20
+#define AFX_IDS_PICTUREFILTER 0xFE21
+#define AFX_IDS_PICTYPE_UNKNOWN 0xFE22
+#define AFX_IDS_PICTYPE_NONE 0xFE23
+#define AFX_IDS_PICTYPE_BITMAP 0xFE24
+#define AFX_IDS_PICTYPE_METAFILE 0xFE25
+#define AFX_IDS_PICTYPE_ICON 0xFE26
+#define AFX_IDS_COLOR_PPG 0xFE28
+#define AFX_IDS_COLOR_PPG_CAPTION 0xFE29
+#define AFX_IDS_FONT_PPG 0xFE2A
+#define AFX_IDS_FONT_PPG_CAPTION 0xFE2B
+#define AFX_IDS_PICTURE_PPG 0xFE2C
+#define AFX_IDS_PICTURE_PPG_CAPTION 0xFE2D
+#define AFX_IDS_PICTUREBROWSETITLE 0xFE30
+#define AFX_IDS_BORDERSTYLE_0 0xFE31
+#define AFX_IDS_BORDERSTYLE_1 0xFE32
+
+// OLE Control verb names
+#define AFX_IDS_VERB_EDIT 0xFE40
+#define AFX_IDS_VERB_PROPERTIES 0xFE41
+
+// OLE Control internal error messages
+#define AFX_IDP_PICTURECANTOPEN 0xFE83
+#define AFX_IDP_PICTURECANTLOAD 0xFE84
+#define AFX_IDP_PICTURETOOLARGE 0xFE85
+#define AFX_IDP_PICTUREREADFAILED 0xFE86
+
+// Standard OLE Control error strings
+#define AFX_IDP_E_ILLEGALFUNCTIONCALL 0xFEA0
+#define AFX_IDP_E_OVERFLOW 0xFEA1
+#define AFX_IDP_E_OUTOFMEMORY 0xFEA2
+#define AFX_IDP_E_DIVISIONBYZERO 0xFEA3
+#define AFX_IDP_E_OUTOFSTRINGSPACE 0xFEA4
+#define AFX_IDP_E_OUTOFSTACKSPACE 0xFEA5
+#define AFX_IDP_E_BADFILENAMEORNUMBER 0xFEA6
+#define AFX_IDP_E_FILENOTFOUND 0xFEA7
+#define AFX_IDP_E_BADFILEMODE 0xFEA8
+#define AFX_IDP_E_FILEALREADYOPEN 0xFEA9
+#define AFX_IDP_E_DEVICEIOERROR 0xFEAA
+#define AFX_IDP_E_FILEALREADYEXISTS 0xFEAB
+#define AFX_IDP_E_BADRECORDLENGTH 0xFEAC
+#define AFX_IDP_E_DISKFULL 0xFEAD
+#define AFX_IDP_E_BADRECORDNUMBER 0xFEAE
+#define AFX_IDP_E_BADFILENAME 0xFEAF
+#define AFX_IDP_E_TOOMANYFILES 0xFEB0
+#define AFX_IDP_E_DEVICEUNAVAILABLE 0xFEB1
+#define AFX_IDP_E_PERMISSIONDENIED 0xFEB2
+#define AFX_IDP_E_DISKNOTREADY 0xFEB3
+#define AFX_IDP_E_PATHFILEACCESSERROR 0xFEB4
+#define AFX_IDP_E_PATHNOTFOUND 0xFEB5
+#define AFX_IDP_E_INVALIDPATTERNSTRING 0xFEB6
+#define AFX_IDP_E_INVALIDUSEOFNULL 0xFEB7
+#define AFX_IDP_E_INVALIDFILEFORMAT 0xFEB8
+#define AFX_IDP_E_INVALIDPROPERTYVALUE 0xFEB9
+#define AFX_IDP_E_INVALIDPROPERTYARRAYINDEX 0xFEBA
+#define AFX_IDP_E_SETNOTSUPPORTEDATRUNTIME 0xFEBB
+#define AFX_IDP_E_SETNOTSUPPORTED 0xFEBC
+#define AFX_IDP_E_NEEDPROPERTYARRAYINDEX 0xFEBD
+#define AFX_IDP_E_SETNOTPERMITTED 0xFEBE
+#define AFX_IDP_E_GETNOTSUPPORTEDATRUNTIME 0xFEBF
+#define AFX_IDP_E_GETNOTSUPPORTED 0xFEC0
+#define AFX_IDP_E_PROPERTYNOTFOUND 0xFEC1
+#define AFX_IDP_E_INVALIDCLIPBOARDFORMAT 0xFEC2
+#define AFX_IDP_E_INVALIDPICTURE 0xFEC3
+#define AFX_IDP_E_PRINTERERROR 0xFEC4
+#define AFX_IDP_E_CANTSAVEFILETOTEMP 0xFEC5
+#define AFX_IDP_E_SEARCHTEXTNOTFOUND 0xFEC6
+#define AFX_IDP_E_REPLACEMENTSTOOLONG 0xFEC7
+
+#ifdef _AFX_MINREBUILD
+#pragma component(minrebuild, on)
+#endif
+
+#endif //__AFXRES_H__
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Win32bits/StdExcept.c b/Win32bits/StdExcept.c
new file mode 100644
index 0000000..5e8a548
--- /dev/null
+++ b/Win32bits/StdExcept.c
@@ -0,0 +1,75 @@
+//
+// Standard __except handler to dump stack and code around eip
+//
+
+__except(memcpy(&exinfo, GetExceptionInformation(), sizeof(struct _EXCEPTION_POINTERS)), EXCEPTION_EXECUTE_HANDLER)
+{
+ unsigned __int32 SPPtr = 0;
+ unsigned __int32 SPVal = 0;
+ unsigned __int32 eip = 0;
+ unsigned __int32 rev = 0;
+ int i;
+
+ DWORD Stack[16];
+ DWORD CodeDump[16];
+
+#ifndef BPQ64
+
+ eip = exinfo.ContextRecord->Eip;
+ SPPtr = exinfo.ContextRecord->Esp;
+
+ __asm
+ {
+ mov eax, SPPtr
+ mov SPVal,eax
+ lea edi,Stack
+ mov esi,eax
+ mov ecx,64
+ rep movsb
+
+ lea edi,CodeDump
+ mov esi,eip
+ mov ecx,64
+ rep movsb
+ }
+
+
+
+ Debugprintf("BPQ32 *** Program Error %x at %x in %s",
+ exinfo.ExceptionRecord->ExceptionCode, exinfo.ExceptionRecord->ExceptionAddress, EXCEPTMSG);
+
+ Debugprintf("EAX %x EBX %x ECX %x EDX %x ESI %x EDI %x ESP %x",
+ exinfo.ContextRecord->Eax, exinfo.ContextRecord->Ebx, exinfo.ContextRecord->Ecx,
+ exinfo.ContextRecord->Edx, exinfo.ContextRecord->Esi, exinfo.ContextRecord->Edi, SPVal);
+
+#endif
+
+ Debugprintf("Stack:");
+
+ Debugprintf("%08x %08x %08x %08x %08x %08x %08x %08x %08x ",
+ SPVal, Stack[0], Stack[1], Stack[2], Stack[3], Stack[4], Stack[5], Stack[6], Stack[7]);
+
+ Debugprintf("%08x %08x %08x %08x %08x %08x %08x %08x %08x ",
+ SPVal+32, Stack[8], Stack[9], Stack[10], Stack[11], Stack[12], Stack[13], Stack[14], Stack[15]);
+
+ Debugprintf("Code:");
+
+ for (i = 0; i < 16; i++)
+ {
+ rev = (CodeDump[i] & 0xff) << 24;
+ rev |= (CodeDump[i] & 0xff00) << 8;
+ rev |= (CodeDump[i] & 0xff0000) >> 8;
+ rev |= (CodeDump[i] & 0xff000000) >> 24;
+
+ CodeDump[i] = rev;
+ }
+
+ Debugprintf("%08x %08x %08x %08x %08x %08x %08x %08x %08x ",
+ eip, CodeDump[0], CodeDump[1], CodeDump[2], CodeDump[3], CodeDump[4], CodeDump[5], CodeDump[6], CodeDump[7]);
+
+ Debugprintf("%08x %08x %08x %08x %08x %08x %08x %08x %08x ",
+ eip+32, CodeDump[8], CodeDump[9], CodeDump[10], CodeDump[11], CodeDump[12], CodeDump[13], CodeDump[14], CodeDump[15]);
+
+ // Note - no closing } so additional code may be run in the __except block
+
+#undef EXCEPTMSG
diff --git a/Win32bits/Strucs.inc b/Win32bits/Strucs.inc
new file mode 100644
index 0000000..df7fbcd
--- /dev/null
+++ b/Win32bits/Strucs.inc
@@ -0,0 +1,572 @@
+
+EXCLUDEBITS EQU 0 ; INCLUDE ExcludeList SUPPORT
+
+TNCBUFFLEN EQU 400h
+BPQHOSTSTREAMS EQU 64
+;BUFFLEN EQU 400 ; ??
+
+MAXAPPLS EQU 32 ; Max Application Commands
+ApplOffset EQU 80000 ; Applications string in buffer
+C_INFOMSG EQU 85000 ; Info Msg in buffer
+ApplStringLen EQU 48 ; Length of each config entry
+
+ALIASLEN EQU 32 ; Max chars in command alias
+
+MHENTRIES EQU 30 ; Entries in MH List
+
+;
+; BUFFLEN-4 = L2 POINTER (FOR CLEARING TIMEOUT WHEN ACKMODE USED)
+; BUFFLEN-8 = TIMESTAMP
+; BUFFLEN-12 = BUFFER ALLOCATED FLAG (ADDR OF ALLOCATING ROUTINE)
+
+;MAXDATA EQU BUFFLEN-16
+
+MAXDIGIS EQU 8
+;
+; BPQHOST MODE VECTOR STRUC
+;
+BPQVECSTRUC STRUC
+
+
+HOSTSESSION DD 0
+HOSTFLAGS DB 0 ; ALLOCATED AND STATE CHANGE FLAGS
+HOSTAPPLMASK DD 0
+HOSTAPPLFLAGS DB 0
+HOSTSTREAM DB 0 ; STREAM NUMBER
+HOSTTRACEQ DD 0
+
+HOSTHANDLE DD 0 ; HANDLE FOR POSTING MSGS TO
+
+HOSTAPPLNUM DD 0 ; Application Number
+
+STREAMOWNER DD 0 ; PID of Process owning stream
+HOSTPGMNAME DB 32 dup (0);
+
+BPQVECSTRUC ENDS
+
+; HOSTFLAGS = Bit 80 = Allocated
+; Bit 40 = Disc Request
+; Bit 20 = Stay Flag
+; Bit 02 and 01 State Change Bits
+
+
+VECTORLENGTH EQU TYPE BPQVECSTRUC
+
+;
+; BASIC LINK LEVEL MESSAGE BUFFER LAYOUT
+;
+MESSAGE STRUC
+
+MSGCHAIN DD ? ; CHAIN WORD
+MSGPORT DB ? ; PORT
+MSGLENGTH DW ? ; LENGTH
+
+MSGDEST DB 7 DUP (?) ; DESTINATION
+MSGORIGIN DB 7 DUP (?) ; ORIGIN
+;
+; MAY BE UP TO 56 BYTES OF DIGIS
+;
+MSGCONTROL DB ? ; CONTROL BYTE
+MSGPID DB ? ; PROTOCOL IDENTIFIER
+MSGDATA DB ? ; START OF LEVEL 2 MESSAGE
+;
+MESSAGE ENDS
+;
+
+L3MESSAGE STRUC
+;
+; NETROM LEVEL 3 MESSAGE - WITHOUT L2 INFO
+;
+L3HEADER DB 7 DUP (?) ; CHAIN, PORT, LENGTH
+L3PID DB ? ; PID
+
+L3SRCE DB 7 DUP (?) ; ORIGIN NODE
+L3DEST DB 7 DUP (?) ; DEST NODE
+L3MONR DB ? ; TX MONITOR FIELD - TO PREVENT MESSAGE GOING
+ ; ROUND THE NETWORK FOR EVER DUE TO ROUTING LOOP
+;
+; NETROM LEVEL 4 DATA
+;
+L4INDEX DB ? ; TRANSPORT SESSION INDEX
+L4ID DB ? ; TRANSPORT SESSION ID
+L4TXNO DB ? ; TRANSMIT SEQUENCE NUMBER
+L4RXNO DB ? ; RECEIVE (ACK) SEQ NUMBER
+L4FLAGS DB ? ; FRAGMENTATION, ACK/NAK, FLOW CONTROL AND MSG TYPE BITS
+
+L4DATA DB ? ; DATA
+L4CALLS DB 14 DUP (?) ; CALLS IN CONNECT REQUEST
+L4_BPQ DB ? ; THENODE EXTENDED CONNECT PARAMS
+
+L3MESSAGE ENDS
+
+;
+; L4FLAGS DEFINITION
+;
+L4BUSY EQU 80H ; BNA - DONT SEND ANY MORE
+L4NAK EQU 40H ; NEGATIVE RESPONSE FLAG
+L4MORE EQU 20H ; MORE DATA FOLLOWS - FRAGMENTATION FLAG
+
+L4CREQ EQU 1 ; CONNECT REQUEST
+L4CACK EQU 2 ; CONNECT ACK
+L4DREQ EQU 3 ; DISCONNECT REQUEST
+L4DACK EQU 4 ; DISCONNECT ACK
+L4INFO EQU 5 ; INFORMATION
+L4IACK EQU 6 ; INFORMATION ACK
+;
+; PORT CONTROL TABLE
+;
+PORTCONTROL STRUC
+
+PORTCALL DB 7 DUP (0)
+PORTALIAS DB 7 DUP (0) ; USED FOR UPLINKS ONLY
+PORTNUMBER DB ?
+PORTPOINTER DD ? ; NEXT IN CHAIN
+PORTQUALITY DB ? ; 'STANDARD' QUALITY FOR THIS PORT
+PORTRX_Q DD ? ; FRAMES RECEIVED ON THIS PORT
+PORTTX_Q DD ? ; FRAMES TO BE SENT ON THIS PORT
+PORTTXROUTINE DD ? ; POINTER TO TRANSMIT ROUTINE FOR THIS PORT
+PORTRXROUTINE DD ? ; POINTER TO RECEIVE ROUTINE FOR THIS PORT
+PORTINITCODE DD ? ; INITIALISATION ROUTINE
+PORTTIMERCODE DD ?
+PORTCLOSECODE DD ?
+PORTTXCHECK DD ? ; OK to Send Check
+
+PORTDESCRIPTION DB 30 DUP (0) ; TEXT DESCRIPTION OF FREQ/SPEED ETC
+PORTBBSFLAG DB ? ; NZ MEANS PORT CALL/ALIAS ARE FOR BBS
+PORTL3FLAG DB ? ; NZ RESTRICTS OUTGOING L2 CONNECTS
+;
+; CWID FIELDS
+;
+CWID DW 9 DUP (0) ; 8 ELEMENTS + FLAG
+ELEMENT DW ? ; REMAINING BITS OF CURRENT CHAR
+CWPOINTER DD ? ; POINTER TO NEXT CHAR
+CWIDTIMER DW ? ; TIME TO NEXT ID
+CWSTATE DB ? ; STATE MACHINE FOR CWID
+CWTYPE DB ? ; SET TO USE ON/OFF KEYING INSTEAD OF
+ ; FSK (FOR RUH MODEMS)
+PORTMINQUAL DB ? ; MIN QUAL TO BRAOCAST ON THIS PORT
+
+; STATS COUNTERS
+;
+L2DIGIED DD ?
+L2FRAMES DD ?
+L2FRAMESFORUS DD ?
+L2FRAMESSENT DD ?
+L2TIMEOUTS DD ?
+L2ORUNC DD ? ; OVERRUNS
+L2URUNC DD ? ; UNDERRUNS
+L1DISCARD DD ? ; FRAMES DISCARDED (UNABLE TO TX DUE TO DCD)
+L2FRMRRX DD ?
+L2FRMRTX DD ?
+RXERRORS DD ? ; RECEIVE ERRORS
+L2REJCOUNT DD ? ; REJ FRAMES RECEIVED
+L2OUTOFSEQ DD ? ; FRAMES RECEIVED OUT OF SEQUENCE
+L2RESEQ DD ? ; FRAMES RESEQUENCED
+SENDING DW 0 ; LINK STATUS BITS
+ACTIVE DW 0
+
+AVSENDING DB 0 ; LAST MINUTE
+AVACTIVE DB 0
+
+PORTTYPE DB 0 ; H/W TYPE
+ ; 0 = ASYNC, 2 = PC120, 4 = DRSI
+ ; 6 = TOSH, 8 = QUAD, 10 = RLC100
+ ; 12 = RLC400 14 = INTERNAL 16 = EXTERNAL ; 18 = i2c
+
+PROTOCOL DB 0 ; PORT PROTOCOL
+ ; 0 = KISS, 2 = NETROM, 4 = BPQKISS
+ ; 6 = HDLC, 8 = L2, 10 = PACTOR
+
+IOBASE DW ? ; CONFIG PARAMS FOR HARDWARE DRIVERS
+INTLEVEL DB ? ; FIRST 4 SAME FOR ALL H/W TYPES
+BAUDRATE DD ? ; SPEED
+CHANNELNUM DB ? ; ON MULTICHANNEL H/W
+INTCHAIN DD ? ; POINTER TO NEXT PORT USING THIS LEVEL
+PORTWINDOW DB ? ; L2 WINDOW FOR THIS PORT
+PORTTXDELAY DW ? ; TX DELAY FOR THIS PORT
+PORTPERSISTANCE DB ? ; PERSISTANCE VALUE FOR THIS PORT
+FULLDUPLEX DB ? ; FULL DUPLEX IF SET
+SOFTDCDFLAG DB ? ; IF SET USE 'SOFT DCD' - IF MODEM CANT GIVE A REAL ONE
+PORTSLOTTIME DB ? ; SLOT TIME
+PORTTAILTIME DB ? ; TAIL TIME
+BBSBANNED DB ? ; SET IF PORT CAN'T ACCEPT L2 CALLS TO BBS CALLSIGN
+PORTT1 DB ? ; L2 TIMEOUT
+PORTT2 DB ? ; L2 DELAYED ACK TIMER
+PORTN2 DB ? ; RETRIES
+PORTPACLEN DB ? ; DEFAULT PACLEN FOR INCOMING SESSIONS
+PORTINTERRUPT DD ? ; ADDRESS OF INTERRUPT HANDLER
+
+QUAL_ADJUST DB ? ; % REDUCTION IN QUALITY IF ON SAME PORT
+
+PERMITTEDCALLS DD ? ; POINTER TO PERMITED CALLS LIST
+PORTUNPROTO DD ? ; POINTER TO UI DEST AND DIGI LIST
+PORTDISABLED DB 0 ; PORT TX DISABLE FLAG
+DIGIFLAG DB 0 ; ENABLE/DISABLE/UI ONLY
+DIGIPORT DB 0 ; CROSSBAND DIGI PORT
+DIGIMASK DW 0 ; CROSSBAND DIGI MASK
+USERS DB 0 ; MAX USERS ON PORT
+KISSFLAGS DB 0 ; KISS SPECIAL MODE BITS
+PORTINTERLOCK DB 0 ; TO DEFINE PORTS WHICH CANT TX AT SAME TIME
+NODESPACLEN DB 0 ; MAX LENGTH OF 'NODES' MSG
+TXPORT DB 0 ; PORT FOR SHARED TX OPERATION
+PORTMHEARD DD 0 ; POINTER TO MH DATA
+
+PARAMTIMER DW 0 ; MOVED FROM HW DATA FOR SYSOPH
+PORTMAXDIGIS DB 0 ; DIGIS ALLOWED ON THIS PORT
+PORTALIAS2 DB 7 DUP (0) ; 2ND ALIAS FOR DIGIPEATING FOR APRS
+PORTBCALL DB 7 DUP (0) ; Source for Beacons
+PortNoKeepAlive DB 0; ; Default to No Keepalives
+PortUIOnly DB 0;
+UICAPABLE DB 0; ; Pactor-style port that can do UI
+WL2K DB 189 DUP (0) ; WL2K Report Data
+PORTIPADDR DD 0;
+SerialPortName DD 0 ; Serial Port Name for Unix
+XDIGIS DD 0; ; Cross Port Digi Definitions
+
+NormalizeQuality DD 0 ; Normalise Node Qualities
+IgnoreUnlocked DD 0 ; Ignore Unlocked Routes
+
+HARDWAREDATA DB 200 DUP (?) ; WORK AREA FOR HARDWARE DRIVERS
+
+PORTCONTROL ENDS
+
+;
+; DEFINE MAPPING FOR EXTERNAL DRIVER
+;
+EXTDATA STRUC
+ DB HARDWAREDATA DUP (0) ; REMAP HARDWARE INFO
+
+PORT_EXT_ADDR DD ? ; ADDR OF RESIDENT ROUTINE
+PORT_DLL_NAME DB 16 DUP (0);
+EXTRESTART DB ? ; FLAG FOR DRIVER REINIT
+DLLHANDLE DD ?
+MAXHOSTMODESESSIONS DD ? ; Max Host Sessions supported (Used for KAM Pactor + ax.25 support)
+ATTACHEDSESSIONS DD 27 DUP (0); Owning Sessions for PACTOR, etc
+PERMITGATEWAY DD 0 ; Set if ax.25 ports can change callsign (ie SCS, not KAM
+SCANCAPABILITIES DD 0 ; Type of scan control Controller supports (None, Simple, Connect Lock)
+UI_Q DD 0 ; Unproto Frames for Session Mode Drivers (TRK, etc)
+
+EXTDATA ENDS
+
+ IF TYPE EXTDATA GT TYPE PORTCONTROL
+ .ERR2 TOO MUCH PORT DATA
+ ENDIF
+
+EXTERNAL EQU 16
+L2 EQU 8
+;
+; CW STATE MACHINE EQUATES
+;
+dot equ 1b
+dash equ 10b
+dotspace equ 100b
+letterspace equ 1000b
+IDPENDING EQU 10000B
+;
+; LEVEL 2 LINK CONTROL TABLE
+;
+LINKTABLE STRUC
+
+LINKCALL DB 7 DUP (?) ; CALLSIGN OF STATION
+OURCALL DB 7 DUP (?) ; CALLSIGN OF OUR END
+DIGIS DB MAXDIGIS*7 DUP (?) ; LEVEL 2 DIGIS IN PATH
+
+LINKPORT DD ? ; PORT POINTER
+LINKTYPE DB ? ; 1 = UP, 2= DOWN, 3 = INTERNODE
+
+LINKNR DB ?
+LINKNS DB ? ; LEV 2 SEQUENCE COUNTS
+LINKWS DB ? ; WINDOW START
+LINKOWS DB ? ; OLD (LAST ACKED) WINDOW START
+LINKWINDOW DB ? ; LEVEL 2 WINDOW SIZE
+
+L2FLAGS DB ? ; CONTROL BITS
+VER1FLAG DB ? ; SET IF OTHER END RUNNING VERSION 1
+
+RX_Q DD ? ; PACKETS RECEIVED ON THIS LINK
+
+TX_Q DD ? ; PACKETS TO SEND
+FRAMES DD 8 DUP (?) ; FRAMES WAITING ACK
+RXFRAMES DD 8 DUP (?) ; Frames received out of sequence
+
+L2STATE DB ? ; PROCESSING STATE
+L2TIMER DW ? ; FRAME RETRY TIMER
+L2TIME DB ? ; RETRY TIMER INITIAL VALUE
+L2SLOTIM DW ? ; DELAY FOR LINK VALIDATION POLL
+L2ACKREQ DB ? ; DELAYED TEXT ACK TIMER
+REJTIMER DB ? ; TO TIME OUT REJ IN VERSION 1
+LAST_F_TIME DW ? ; TIME LAST R(F) SENT
+SDREJF DB ? ; FLAGS FOR FRMR
+SDRBYTE DB ? ; SAVED CONTROL BYTE FOR FRMR
+
+SDTSLOT DB ? ; POINTER TO NEXT TXSLOT TO USE
+
+L2RETRIES DB ? ; RETRY COUNTER
+
+SESSACTIVE DB ? ; SET WHEN WE ARE SURE SESSION IS UP
+
+KILLTIMER DW ? ; TIME TO KILL IDLE LINK
+
+CIRCUITPOINTER DD ? ; POINTER TO L4 CIRCUIT TABLE ENTRY
+ ; (IF UP/DOWN)
+NEIGHBOUR DD ? ; POINTER TO NEIGHBOUR (IF CROSSLINK)
+
+L2FRAG_Q DD ? ; DEFRAGMENTATION QUEUE
+
+LINKTABLE ENDS
+;
+; L2FLAGS EQUATES
+;
+REJSENT EQU 1B ; SET WHEN FIRST REJ IS SENT IN REPLY
+ ; TO AN I(P)
+RNRSET EQU 10B ; RNR RECEIVED FROM OTHER END
+;DISCPENDING EQU 1000B ; SEND DISC WHEN ALL DATA ACK'ED
+RNRSENT EQU 10000B ; WE HAVE SEND RNR
+POLLSENT EQU 100000B ; POLL BIT OUTSTANDING
+;
+; FRMR REJECT FLAGS
+;
+SDINVC EQU 1B ; INVALID COMMAND
+SDNRER EQU 1000B ; INVALID N(R)
+
+TRANSPORTENTRY STRUC
+
+L4USER DB 7 DUP (?) ; CALL OF ORIGINATING USER
+L4TARGET DD ? ; POINTER TO TARGET LINK/DEST
+L4MYCALL DB 7 DUP (0) ; CALL WE ARE USING
+
+CIRCUITINDEX DB ? ; OUR CIRCUIT INFO
+CIRCUITID DB ?
+
+FARINDEX DB ?
+FARID DB ? ; OTHER END'S INFO
+
+L4WINDOW DB ? ; WINDOW SIZE
+L4WS DB ? ; WINDOW START - NEXT FRAME TO ACK
+TXSEQNO DB ?
+RXSEQNO DB ? ; TRANSPORT LEVEL SEQUENCE INFO
+L4LASTACKED DB ? ; LAST SEQUENCE ACKED
+
+FLAGS DB ? ; TRANSPORT LEVEL FLAGS
+NAKBITS DB ? ; NAK & CHOKE BITS TO BE SENT
+L4CROSSLINK DD ? ; POINTER TO LINKED L4 SESSION ENTRY
+L4CIRCUITTYPE DB ? ; BIT SIGNIFICANT - SEE BELOW
+KAMSESSION DB ? ; Session Number on KAM Host Mode TNC
+L4TX_Q DD ?
+L4RX_Q DD ?
+L4HOLD_Q DD ? ; FRAMES WAITING TO BE ACKED
+L4RESEQ_Q DD ? ; FRAMES RECEIVED OUT OF SEQUENCE
+
+L4STATE DB ?
+L4TIMER DW ?
+L4ACKREQ DB ? ; DATA ACK NEEDED
+L4RETRIES DB ? ; RETRY COUNTER
+L4KILLTIMER DW 0 ; IDLE CIRCUIT TIMER
+SESSIONT1 DW 0 ; TIMEOUT FOR SESSIONS FROM HERE
+SESSPACLEN DB 0 ; PACLEN FOR THIS SESSION
+BADCOMMANDS DB 0 ; SUCCESSIVE BAD COMMANDS
+STAYFLAG DB 0 ; STAY CONNECTED FLAG
+SPYFLAG DB 0 ; SPY - CONNECT TO NODE VIA BBS CALLSIGN
+
+RTT_SEQ DB 0 ; SEQUENCE NUMBER BEING TIMED
+RTT_TIMER DD 0 ; TIME ABOVE SEQUENCE WAS SENT
+
+PASSWORD DW 0 ; AUTHORISATION CODE FOR REMOTE SYSOP
+;
+SESS_APPLFLAGS DB 0 ; APPL FLAGS FOR THIS SESSION
+
+Authorised_Session DB 0; // Set if Host session from BPQTerminal or BPQMailChat
+
+DUMPPTR DD 0 ; POINTER FOR REMOTE DUMP MODE
+PARTCMDBUFFER DD 0 ; Save area for incomplete commmand
+
+Frequency DD 0 ; If known - for CMS Reporting Hz
+RMSCall DB 10 DUP (0);
+Mode DB 0 ; ditto
+
+UNPROTO DD 0 ; Unproto Mode flag - port number if in unproto mode
+UAddrLen DD 0 ;
+UADDRESS DB 64 DUP (0); Unproto Address String - Dest + Digis
+
+LISTEN DD 0 ; Listen Mode flag - port number of Listen Mode
+
+APPL DB 16 DUP (0); Set if session initiated by an APPL
+L4LIMIT dd 0 ; Idle Timout for this session
+
+TRANSPORTENTRY ENDS
+;
+; CIRCUITTYPE EQUATES
+;
+L2LINK EQU 1
+SESSION EQU 10B
+UPLINK EQU 100B
+DOWNLINK EQU 1000B
+BPQHOST EQU 100000B
+PACTOR EQU 1000000B
+;
+; FLAGS EQUATES
+;
+DISCPENDING EQU 1000B ; SEND DISC WHEN ALL DATA ACK'ED
+;
+; TOP 4 BITS MATCH L4FLAGS BITS - ALSO USED FOR NAKBITS
+;
+;L4BUSY EQU 80H ; BNA - DONT SEND ANY MORE
+;L4NAK EQU 40H ; NEGATIVE RESPONSE FLAG
+;L4MORE EQU 20H ; MORE DATA FOLLOWS - FRAGMENTATION FLAG
+
+
+
+DEST_LIST STRUC
+
+DEST_CHAIN DD ? ; SORTED LIST CHAIN
+
+DEST_CALL DB 7 DUP (?) ; DESTINATION CALLSIGN (AX25 FORMAT)
+DEST_ALIAS DB 6 DUP (?)
+
+DEST_STATE DB ? ; CONTROL BITS - SETTING UP, ACTIVE ETC
+
+DEST_ROUTE DB ? ; CURRENTY ACTIVE DESTINATION
+
+INP3FLAGS DB ?
+
+ROUT1_NEIGHBOUR DD ? ; POINTER TO NEXT NODE IN PATH
+ROUT1_QUALITY DB ? ; QUALITY
+ROUT1_OBSCOUNT DB ?
+ db 5 dup (?); Padding
+
+ROUT2_NEIGHBOUR DD ?
+ROUT2_QUALITY DB ?
+ROUT2_OBSCOUNT DB ?
+ db 5 dup (?); Padding
+
+ROUT3_NEIGHBOUR DD ?
+ROUT3_QUALITY DB ?
+ROUT3_OBSCOUNT DB ?
+ db 5 dup (?); Padding
+
+INPROUT1_NEIGHBOUR DD ?
+LastRTT1 DW ?; // Last Value Reported
+RTT1 DW ?; // Current
+SRTT1 DW ?; // Smoothed RTT
+Hops1 DB ?;
+
+INPROUT2_NEIGHBOUR DD ?
+LastRTT2 DW ?; // Last Value Reported
+RTT2 DW ?; // Current
+SRTT2 DW ?; // Smoothed RTT
+Hops2 DB ?;
+
+INPROUT3_NEIGHBOUR DD ?
+LastRTT3 DW ?; // Last Value Reported
+RTT3 DW ?; // Current
+SRTT3 DW ?; // Smoothed RTT
+Hops3 DB ?;
+DEST_Q DD ? ; QUEUE OF FRAMES FOR THIS DESTINATION
+
+DEST_RTT DD ? ; SMOOTHED ROUND TRIP TIMER
+DEST_COUNT DD ? ; FRAMES SENT
+
+DEST_LIST ENDS
+
+
+;
+; MODEFLAG DEFINITIONS
+;
+COMMAND EQU 1B
+TRANS EQU 10B
+CONV EQU 100B
+;
+; APPL DEFINITIONS
+;
+BBSAPPL EQU 1B
+HOSTAPPL EQU 10B
+SYSOPAPPL EQU 100B
+;
+; HOSTFLAG DEFINITIONS
+;
+;HOSTMODE EQU 1B ; PK232 HOSTMODE ENABLED
+;HOSTESCBIT EQU 10B ; IN ESCAPE SEQUENCE
+;UFQ EQU 100B ; UFQ MODE (IE NOT AA4RE)
+;POLLED EQU 1000B ; POLL RECEIVED
+
+;KISSMODE EQU 10000B ; KISS MODE
+;KISSESC EQU 100000B ; IN ESCAPE SEQUENCE
+;
+; APPLFLAGS BITS
+;
+CMD_TO_APPL EQU 1B ; PASS COMMAND TO APPLICATION
+MSG_TO_USER EQU 10B ; SEND 'CONNECTED' TO USER
+MSG_TO_APPL EQU 100B ; SEND 'CONECTED' TO APPL
+;
+; HDLC COMMANDS (WITHOUT P/F)
+;
+UI EQU 3
+SABM EQU 2FH
+DISC EQU 43H
+DM EQU 0FH
+UA EQU 63H
+FRMR EQU 87H
+RR EQU 1
+RNR EQU 5
+REJ EQU 9
+;
+PFBIT EQU 10H ; POLL/FINAL BIT IN CONTROL BYTE
+;
+; MH DATA AREA
+;
+;MHSTRUC STRUC
+
+;MHCALL DB 7 DUP (0)
+;MHTIME DD 0 ; ? FROM BIOS
+;MHDIGI DB 0
+;MHFreq DB 12 DUP (0)
+;MHLocator DB 6 DUP (0)
+
+;MHSTRUC ENDS
+
+; Application Calls/Alias Supports multiple L4 application calls
+
+APPLCALLS STRUC
+
+APPLCALL DB 7 DUP (0) ; ax.25
+APPLALIAS_TEXT DB 10 DUP (0) ; TEXT, WITH APPENDED SPACE
+
+APPLCALL_TEXT DB 10 DUP (0)
+APPLALIAS DB 6 DUP (0)
+APFiller DB 0
+APPLQUAL DW 0
+APPNODEPOINTER DD 0 ; Pointer to "NODES" entry for this App (if L4)
+APPLCMDNAME DB 13 DUP (0) ; Command to invoke this APPL
+APPLHASALIAS DD 0
+APPLPORT DD 0 ; Port if Appl has an alias
+APPLALIASPTR DD 0 ; Pointer to Alias if defined
+
+APPLCALLS ENDS
+
+; New Style APPL configuration
+
+APPLCONFIG STRUC
+
+ACCommand DB 12 DUP (0);
+ACCommandAlias DB 48 DUP (0);
+ACApplCall DB 10 DUP (0);
+ACApplAlias DB 10 DUP (0);
+ACApplQual DD 0
+
+APPLCONFIG ENDS
+;
+; HARDWARE TYPE EQUATES
+;
+KISS EQU 0
+PC120 EQU 2
+DRSI EQU 4
+TOSH EQU 6
+QUADRAM EQU 8
+RLC100 EQU 0AH
+RLC400 EQU 0CH
+INTERNAL EQU 0EH
+EXTERNAL EQU 10H
+BAYCOM EQU 12H
+PA0HZP EQU 14H
+
+
diff --git a/Win32bits/bpq32.exp b/Win32bits/bpq32.exp
new file mode 100644
index 0000000..3cb06aa
--- /dev/null
+++ b/Win32bits/bpq32.exp
Binary files differ
diff --git a/Win32bits/libconfig.h b/Win32bits/libconfig.h
new file mode 100644
index 0000000..08414ce
--- /dev/null
+++ b/Win32bits/libconfig.h
@@ -0,0 +1,321 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_h
+#define __libconfig_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+#if defined(LIBCONFIG_STATIC)
+#define LIBCONFIG_API
+#elif defined(LIBCONFIG_EXPORTS)
+#define LIBCONFIG_API __declspec(dllexport)
+#else /* ! LIBCONFIG_EXPORTS */
+#define LIBCONFIG_API __declspec(dllimport)
+#endif /* LIBCONFIG_STATIC */
+#else /* ! WIN32 */
+#define LIBCONFIG_API
+#endif /* WIN32 */
+
+#define LIBCONFIG_VER_MAJOR 1
+#define LIBCONFIG_VER_MINOR 4
+#define LIBCONFIG_VER_REVISION 9
+
+#include <stdio.h>
+
+#define CONFIG_TYPE_NONE 0
+#define CONFIG_TYPE_GROUP 1
+#define CONFIG_TYPE_INT 2
+#define CONFIG_TYPE_INT64 3
+#define CONFIG_TYPE_FLOAT 4
+#define CONFIG_TYPE_STRING 5
+#define CONFIG_TYPE_BOOL 6
+#define CONFIG_TYPE_ARRAY 7
+#define CONFIG_TYPE_LIST 8
+
+#define CONFIG_FORMAT_DEFAULT 0
+#define CONFIG_FORMAT_HEX 1
+
+#define CONFIG_OPTION_AUTOCONVERT 0x01
+
+#define CONFIG_TRUE (1)
+#define CONFIG_FALSE (0)
+
+typedef union config_value_t
+{
+ int ival;
+ long long llval;
+ double fval;
+ char *sval;
+ struct config_list_t *list;
+} config_value_t;
+
+typedef struct config_setting_t
+{
+ char *name;
+ short type;
+ short format;
+ config_value_t value;
+ struct config_setting_t *parent;
+ struct config_t *config;
+ void *hook;
+ unsigned int line;
+ const char *file;
+} config_setting_t;
+
+typedef enum
+{
+ CONFIG_ERR_NONE = 0,
+ CONFIG_ERR_FILE_IO = 1,
+ CONFIG_ERR_PARSE = 2
+} config_error_t;
+
+typedef struct config_list_t
+{
+ unsigned int length;
+ config_setting_t **elements;
+} config_list_t;
+
+typedef struct config_t
+{
+ config_setting_t *root;
+ void (*destructor)(void *);
+ unsigned short flags;
+ unsigned short tab_width;
+ short default_format;
+ const char *include_dir;
+ const char *error_text;
+ const char *error_file;
+ int error_line;
+ config_error_t error_type;
+ const char **filenames;
+ unsigned int num_filenames;
+} config_t;
+
+extern LIBCONFIG_API int config_read(config_t *config, FILE *stream);
+extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream);
+
+extern LIBCONFIG_API void config_set_default_format(config_t *config,
+ short format);
+
+extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int flag);
+extern LIBCONFIG_API int config_get_auto_convert(const config_t *config);
+
+extern LIBCONFIG_API int config_read_string(config_t *config, const char *str);
+
+extern LIBCONFIG_API int config_read_file(config_t *config,
+ const char *filename);
+extern LIBCONFIG_API int config_write_file(config_t *config,
+ const char *filename);
+
+extern LIBCONFIG_API void config_set_destructor(config_t *config,
+ void (*destructor)(void *));
+extern LIBCONFIG_API void config_set_include_dir(config_t *config,
+ const char *include_dir);
+
+extern LIBCONFIG_API void config_init(config_t *config);
+extern LIBCONFIG_API void config_destroy(config_t *config);
+
+extern LIBCONFIG_API int config_setting_get_int(
+ const config_setting_t *setting);
+extern LIBCONFIG_API long long config_setting_get_int64(
+ const config_setting_t *setting);
+extern LIBCONFIG_API double config_setting_get_float(
+ const config_setting_t *setting);
+extern LIBCONFIG_API int config_setting_get_bool(
+ const config_setting_t *setting);
+extern LIBCONFIG_API const char *config_setting_get_string(
+ const config_setting_t *setting);
+
+extern LIBCONFIG_API int config_setting_lookup_int(
+ const config_setting_t *setting, const char *name, int *value);
+extern LIBCONFIG_API int config_setting_lookup_int64(
+ const config_setting_t *setting, const char *name, long long *value);
+extern LIBCONFIG_API int config_setting_lookup_float(
+ const config_setting_t *setting, const char *name, double *value);
+extern LIBCONFIG_API int config_setting_lookup_bool(
+ const config_setting_t *setting, const char *name, int *value);
+extern LIBCONFIG_API int config_setting_lookup_string(
+ const config_setting_t *setting, const char *name, const char **value);
+
+extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting,
+ int value);
+extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting,
+ long long value);
+extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting,
+ double value);
+extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting,
+ int value);
+extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting,
+ const char *value);
+
+extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting,
+ short format);
+extern LIBCONFIG_API short config_setting_get_format(
+ const config_setting_t *setting);
+
+extern LIBCONFIG_API int config_setting_get_int_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API long long config_setting_get_int64_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API double config_setting_get_float_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API int config_setting_get_bool_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API const char *config_setting_get_string_elem(
+ const config_setting_t *setting, int idx);
+
+extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem(
+ config_setting_t *setting, int idx, int value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem(
+ config_setting_t *setting, int idx, long long value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem(
+ config_setting_t *setting, int idx, double value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem(
+ config_setting_t *setting, int idx, int value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem(
+ config_setting_t *setting, int idx, const char *value);
+
+#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \
+ ((C)->include_dir)
+
+#define /* int */ config_setting_type(/* const config_setting_t * */ S) \
+ ((S)->type)
+
+#define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \
+ ((S)->type == CONFIG_TYPE_GROUP)
+#define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \
+ ((S)->type == CONFIG_TYPE_ARRAY)
+#define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \
+ ((S)->type == CONFIG_TYPE_LIST)
+
+#define /* int */ config_setting_is_aggregate( \
+ /* const config_setting_t * */ S) \
+ (((S)->type == CONFIG_TYPE_GROUP) || ((S)->type == CONFIG_TYPE_LIST) \
+ || ((S)->type == CONFIG_TYPE_ARRAY))
+
+#define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \
+ (((S)->type == CONFIG_TYPE_INT) \
+ || ((S)->type == CONFIG_TYPE_INT64) \
+ || ((S)->type == CONFIG_TYPE_FLOAT))
+
+#define /* int */ config_setting_is_scalar(/* const config_setting_t * */ S) \
+ (((S)->type == CONFIG_TYPE_BOOL) || ((S)->type == CONFIG_TYPE_STRING) \
+ || config_setting_is_number(S))
+
+#define /* const char * */ config_setting_name( \
+ /* const config_setting_t * */ S) \
+ ((S)->name)
+
+#define /* config_setting_t * */ config_setting_parent( \
+ /* const config_setting_t * */ S) \
+ ((S)->parent)
+
+#define /* int */ config_setting_is_root( \
+ /* const config_setting_t * */ S) \
+ ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE)
+
+extern LIBCONFIG_API int config_setting_index(const config_setting_t *setting);
+
+extern LIBCONFIG_API int config_setting_length(
+ const config_setting_t *setting);
+extern LIBCONFIG_API config_setting_t *config_setting_get_elem(
+ const config_setting_t *setting, unsigned int idx);
+
+extern LIBCONFIG_API config_setting_t *config_setting_get_member(
+ const config_setting_t *setting, const char *name);
+
+extern LIBCONFIG_API config_setting_t *config_setting_add(
+ config_setting_t *parent, const char *name, int type);
+extern LIBCONFIG_API int config_setting_remove(config_setting_t *parent,
+ const char *name);
+extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent,
+ unsigned int idx);
+extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting,
+ void *hook);
+
+#define config_setting_get_hook(S) ((S)->hook)
+
+extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config,
+ const char *path);
+extern LIBCONFIG_API config_setting_t *config_lookup_from(
+ config_setting_t *setting, const char *path);
+
+extern LIBCONFIG_API int config_lookup_int(const config_t *config,
+ const char *path, int *value);
+extern LIBCONFIG_API int config_lookup_int64(const config_t *config,
+ const char *path,
+ long long *value);
+extern LIBCONFIG_API int config_lookup_float(const config_t *config,
+ const char *path, double *value);
+extern LIBCONFIG_API int config_lookup_bool(const config_t *config,
+ const char *path, int *value);
+extern LIBCONFIG_API int config_lookup_string(const config_t *config,
+ const char *path,
+ const char **value);
+
+#define /* config_setting_t * */ config_root_setting( \
+ /* const config_t * */ C) \
+ ((C)->root)
+
+#define /* void */ config_set_default_format(/* config_t * */ C, \
+ /* short */ F) \
+ (C)->default_format = (F)
+
+#define /* short */ config_get_default_format(/* config_t * */ C) \
+ ((C)->default_format)
+
+#define /* void */ config_set_tab_width(/* config_t * */ C, \
+ /* unsigned short */ W) \
+ (C)->tab_width = ((W) & 0x0F)
+
+#define /* unsigned char */ config_get_tab_width(/* const config_t * */ C) \
+ ((C)->tab_width)
+
+#define /* unsigned short */ config_setting_source_line( \
+ /* const config_setting_t * */ S) \
+ ((S)->line)
+
+#define /* const char */ config_setting_source_file( \
+ /* const config_setting_t * */ S) \
+ ((S)->file)
+
+#define /* const char * */ config_error_text(/* const config_t * */ C) \
+ ((C)->error_text)
+
+#define /* const char * */ config_error_file(/* const config_t * */ C) \
+ ((C)->error_file)
+
+#define /* int */ config_error_line(/* const config_t * */ C) \
+ ((C)->error_line)
+
+#define /* config_error_t */ config_error_type(/* const config_t * */ C) \
+ ((C)->error_type)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __libconfig_h */
diff --git a/Win32bits/pcap-bpf.h b/Win32bits/pcap-bpf.h
new file mode 100644
index 0000000..4020909
--- /dev/null
+++ b/Win32bits/pcap-bpf.h
@@ -0,0 +1,697 @@
+/*-
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)bpf.h 7.1 (Berkeley) 5/7/91
+ *
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.6 2005/08/13 22:29:47 hannes Exp $ (LBL)
+ */
+
+/*
+ * This is libpcap's cut-down version of bpf.h; it includes only
+ * the stuff needed for the code generator and the userland BPF
+ * interpreter, and the libpcap APIs for setting filters, etc..
+ *
+ * "pcap-bpf.c" will include the native OS version, as it deals with
+ * the OS's BPF implementation.
+ *
+ * XXX - should this all just be moved to "pcap.h"?
+ */
+
+#ifndef BPF_MAJOR_VERSION
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* BSD style release date */
+#define BPF_RELEASE 199606
+
+#ifdef MSDOS /* must be 32-bit */
+typedef long bpf_int32;
+typedef unsigned long bpf_u_int32;
+#else
+typedef int bpf_int32;
+typedef u_int bpf_u_int32;
+#endif
+
+/*
+ * Alignment macros. BPF_WORDALIGN rounds up to the next
+ * even multiple of BPF_ALIGNMENT.
+ */
+#ifndef __NetBSD__
+#define BPF_ALIGNMENT sizeof(bpf_int32)
+#else
+#define BPF_ALIGNMENT sizeof(long)
+#endif
+#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
+
+#define BPF_MAXINSNS 512
+#define BPF_MAXBUFSIZE 0x8000
+#define BPF_MINBUFSIZE 32
+
+/*
+ * Structure for "pcap_compile()", "pcap_setfilter()", etc..
+ */
+struct bpf_program {
+ u_int bf_len;
+ struct bpf_insn *bf_insns;
+};
+
+/*
+ * Struct return by BIOCVERSION. This represents the version number of
+ * the filter language described by the instruction encodings below.
+ * bpf understands a program iff kernel_major == filter_major &&
+ * kernel_minor >= filter_minor, that is, if the value returned by the
+ * running kernel has the same major number and a minor number equal
+ * equal to or less than the filter being downloaded. Otherwise, the
+ * results are undefined, meaning an error may be returned or packets
+ * may be accepted haphazardly.
+ * It has nothing to do with the source code version.
+ */
+struct bpf_version {
+ u_short bv_major;
+ u_short bv_minor;
+};
+/* Current version number of filter architecture. */
+#define BPF_MAJOR_VERSION 1
+#define BPF_MINOR_VERSION 1
+
+/*
+ * Data-link level type codes.
+ *
+ * Do *NOT* add new values to this list without asking
+ * "tcpdump-workers@tcpdump.org" for a value. Otherwise, you run the
+ * risk of using a value that's already being used for some other purpose,
+ * and of having tools that read libpcap-format captures not being able
+ * to handle captures with your new DLT_ value, with no hope that they
+ * will ever be changed to do so (as that would destroy their ability
+ * to read captures using that value for that other purpose).
+ */
+
+/*
+ * These are the types that are the same on all platforms, and that
+ * have been defined by <net/bpf.h> for ages.
+ */
+#define DLT_NULL 0 /* BSD loopback encapsulation */
+#define DLT_EN10MB 1 /* Ethernet (10Mb) */
+#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
+#define DLT_AX25 3 /* Amateur Radio AX.25 */
+#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
+#define DLT_CHAOS 5 /* Chaos */
+#define DLT_IEEE802 6 /* IEEE 802 Networks */
+#define DLT_ARCNET 7 /* ARCNET, with BSD-style header */
+#define DLT_SLIP 8 /* Serial Line IP */
+#define DLT_PPP 9 /* Point-to-point Protocol */
+#define DLT_FDDI 10 /* FDDI */
+
+/*
+ * These are types that are different on some platforms, and that
+ * have been defined by <net/bpf.h> for ages. We use #ifdefs to
+ * detect the BSDs that define them differently from the traditional
+ * libpcap <net/bpf.h>
+ *
+ * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS,
+ * but I don't know what the right #define is for BSD/OS.
+ */
+#define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */
+
+#ifdef __OpenBSD__
+#define DLT_RAW 14 /* raw IP */
+#else
+#define DLT_RAW 12 /* raw IP */
+#endif
+
+/*
+ * Given that the only OS that currently generates BSD/OS SLIP or PPP
+ * is, well, BSD/OS, arguably everybody should have chosen its values
+ * for DLT_SLIP_BSDOS and DLT_PPP_BSDOS, which are 15 and 16, but they
+ * didn't. So it goes.
+ */
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+#ifndef DLT_SLIP_BSDOS
+#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */
+#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */
+#endif
+#else
+#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */
+#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */
+#endif
+
+/*
+ * 17 is used for DLT_OLD_PFLOG in OpenBSD;
+ * OBSOLETE: DLT_PFLOG is 117 in OpenBSD now as well. See below.
+ * 18 is used for DLT_PFSYNC in OpenBSD; don't use it for anything else.
+ */
+
+#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */
+
+/*
+ * Apparently Redback uses this for its SmartEdge 400/800. I hope
+ * nobody else decided to use it, too.
+ */
+#define DLT_REDBACK_SMARTEDGE 32
+
+/*
+ * These values are defined by NetBSD; other platforms should refrain from
+ * using them for other purposes, so that NetBSD savefiles with link
+ * types of 50 or 51 can be read as this type on all platforms.
+ */
+#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */
+#define DLT_PPP_ETHER 51 /* PPP over Ethernet */
+
+/*
+ * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses
+ * a link-layer type of 99 for the tcpdump it supplies. The link-layer
+ * header has 6 bytes of unknown data, something that appears to be an
+ * Ethernet type, and 36 bytes that appear to be 0 in at least one capture
+ * I've seen.
+ */
+#define DLT_SYMANTEC_FIREWALL 99
+
+/*
+ * Values between 100 and 103 are used in capture file headers as
+ * link-layer types corresponding to DLT_ types that differ
+ * between platforms; don't use those values for new DLT_ new types.
+ */
+
+/*
+ * This value was defined by libpcap 0.5; platforms that have defined
+ * it with a different value should define it here with that value -
+ * a link type of 104 in a save file will be mapped to DLT_C_HDLC,
+ * whatever value that happens to be, so programs will correctly
+ * handle files with that link type regardless of the value of
+ * DLT_C_HDLC.
+ *
+ * The name DLT_C_HDLC was used by BSD/OS; we use that name for source
+ * compatibility with programs written for BSD/OS.
+ *
+ * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
+ * for source compatibility with programs written for libpcap 0.5.
+ */
+#define DLT_C_HDLC 104 /* Cisco HDLC */
+#define DLT_CHDLC DLT_C_HDLC
+
+#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */
+
+/*
+ * 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW,
+ * except when it isn't. (I.e., sometimes it's just raw IP, and
+ * sometimes it isn't.) We currently handle it as DLT_LINUX_SLL,
+ * so that we don't have to worry about the link-layer header.)
+ */
+
+/*
+ * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides
+ * with other values.
+ * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header
+ * (DLCI, etc.).
+ */
+#define DLT_FRELAY 107
+
+/*
+ * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
+ * that the AF_ type in the link-layer header is in network byte order.
+ *
+ * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
+ * define it as 108 here. If OpenBSD picks up this file, it should
+ * define DLT_LOOP as 12 in its version, as per the comment above -
+ * and should not use 108 as a DLT_ value.
+ */
+#define DLT_LOOP 108
+
+/*
+ * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
+ * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other
+ * than OpenBSD.
+ */
+#ifdef __OpenBSD__
+#define DLT_ENC 13
+#else
+#define DLT_ENC 109
+#endif
+
+/*
+ * Values between 110 and 112 are reserved for use in capture file headers
+ * as link-layer types corresponding to DLT_ types that might differ
+ * between platforms; don't use those values for new DLT_ types
+ * other than the corresponding DLT_ types.
+ */
+
+/*
+ * This is for Linux cooked sockets.
+ */
+#define DLT_LINUX_SLL 113
+
+/*
+ * Apple LocalTalk hardware.
+ */
+#define DLT_LTALK 114
+
+/*
+ * Acorn Econet.
+ */
+#define DLT_ECONET 115
+
+/*
+ * Reserved for use with OpenBSD ipfilter.
+ */
+#define DLT_IPFILTER 116
+
+/*
+ * OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD, but that's DLT_LANE8023
+ * in SuSE 6.3, so we can't use 17 for it in capture-file headers.
+ *
+ * XXX: is there a conflict with DLT_PFSYNC 18 as well?
+ */
+#ifdef __OpenBSD__
+#define DLT_OLD_PFLOG 17
+#define DLT_PFSYNC 18
+#endif
+#define DLT_PFLOG 117
+
+/*
+ * Registered for Cisco-internal use.
+ */
+#define DLT_CISCO_IOS 118
+
+/*
+ * For 802.11 cards using the Prism II chips, with a link-layer
+ * header including Prism monitor mode information plus an 802.11
+ * header.
+ */
+#define DLT_PRISM_HEADER 119
+
+/*
+ * Reserved for Aironet 802.11 cards, with an Aironet link-layer header
+ * (see Doug Ambrisko's FreeBSD patches).
+ */
+#define DLT_AIRONET_HEADER 120
+
+/*
+ * Reserved for Siemens HiPath HDLC.
+ */
+#define DLT_HHDLC 121
+
+/*
+ * This is for RFC 2625 IP-over-Fibre Channel.
+ *
+ * This is not for use with raw Fibre Channel, where the link-layer
+ * header starts with a Fibre Channel frame header; it's for IP-over-FC,
+ * where the link-layer header starts with an RFC 2625 Network_Header
+ * field.
+ */
+#define DLT_IP_OVER_FC 122
+
+/*
+ * This is for Full Frontal ATM on Solaris with SunATM, with a
+ * pseudo-header followed by an AALn PDU.
+ *
+ * There may be other forms of Full Frontal ATM on other OSes,
+ * with different pseudo-headers.
+ *
+ * If ATM software returns a pseudo-header with VPI/VCI information
+ * (and, ideally, packet type information, e.g. signalling, ILMI,
+ * LANE, LLC-multiplexed traffic, etc.), it should not use
+ * DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump
+ * and the like don't have to infer the presence or absence of a
+ * pseudo-header and the form of the pseudo-header.
+ */
+#define DLT_SUNATM 123 /* Solaris+SunATM */
+
+/*
+ * Reserved as per request from Kent Dahlgren <kent@praesum.com>
+ * for private use.
+ */
+#define DLT_RIO 124 /* RapidIO */
+#define DLT_PCI_EXP 125 /* PCI Express */
+#define DLT_AURORA 126 /* Xilinx Aurora link layer */
+
+/*
+ * Header for 802.11 plus a number of bits of link-layer information
+ * including radio information, used by some recent BSD drivers as
+ * well as the madwifi Atheros driver for Linux.
+ */
+#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus radiotap radio header */
+
+/*
+ * Reserved for the TZSP encapsulation, as per request from
+ * Chris Waters <chris.waters@networkchemistry.com>
+ * TZSP is a generic encapsulation for any other link type,
+ * which includes a means to include meta-information
+ * with the packet, e.g. signal strength and channel
+ * for 802.11 packets.
+ */
+#define DLT_TZSP 128 /* Tazmen Sniffer Protocol */
+
+/*
+ * BSD's ARCNET headers have the source host, destination host,
+ * and type at the beginning of the packet; that's what's handed
+ * up to userland via BPF.
+ *
+ * Linux's ARCNET headers, however, have a 2-byte offset field
+ * between the host IDs and the type; that's what's handed up
+ * to userland via PF_PACKET sockets.
+ *
+ * We therefore have to have separate DLT_ values for them.
+ */
+#define DLT_ARCNET_LINUX 129 /* ARCNET */
+
+/*
+ * Juniper-private data link types, as per request from
+ * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
+ * for passing on chassis-internal metainformation such as
+ * QOS profiles, etc..
+ */
+#define DLT_JUNIPER_MLPPP 130
+#define DLT_JUNIPER_MLFR 131
+#define DLT_JUNIPER_ES 132
+#define DLT_JUNIPER_GGSN 133
+#define DLT_JUNIPER_MFR 134
+#define DLT_JUNIPER_ATM2 135
+#define DLT_JUNIPER_SERVICES 136
+#define DLT_JUNIPER_ATM1 137
+
+/*
+ * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund
+ * <dieter@apple.com>. The header that's presented is an Ethernet-like
+ * header:
+ *
+ * #define FIREWIRE_EUI64_LEN 8
+ * struct firewire_header {
+ * u_char firewire_dhost[FIREWIRE_EUI64_LEN];
+ * u_char firewire_shost[FIREWIRE_EUI64_LEN];
+ * u_short firewire_type;
+ * };
+ *
+ * with "firewire_type" being an Ethernet type value, rather than,
+ * for example, raw GASP frames being handed up.
+ */
+#define DLT_APPLE_IP_OVER_IEEE1394 138
+
+/*
+ * Various SS7 encapsulations, as per a request from Jeff Morriss
+ * <jeff.morriss[AT]ulticom.com> and subsequent discussions.
+ */
+#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */
+#define DLT_MTP2 140 /* MTP2, without pseudo-header */
+#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */
+#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */
+
+/*
+ * DOCSIS MAC frames.
+ */
+#define DLT_DOCSIS 143
+
+/*
+ * Linux-IrDA packets. Protocol defined at http://www.irda.org.
+ * Those packets include IrLAP headers and above (IrLMP...), but
+ * don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy
+ * framing can be handled by the hardware and depend on the bitrate.
+ * This is exactly the format you would get capturing on a Linux-IrDA
+ * interface (irdaX), but not on a raw serial port.
+ * Note the capture is done in "Linux-cooked" mode, so each packet include
+ * a fake packet header (struct sll_header). This is because IrDA packet
+ * decoding is dependant on the direction of the packet (incomming or
+ * outgoing).
+ * When/if other platform implement IrDA capture, we may revisit the
+ * issue and define a real DLT_IRDA...
+ * Jean II
+ */
+#define DLT_LINUX_IRDA 144
+
+/*
+ * Reserved for IBM SP switch and IBM Next Federation switch.
+ */
+#define DLT_IBM_SP 145
+#define DLT_IBM_SN 146
+
+/*
+ * Reserved for private use. If you have some link-layer header type
+ * that you want to use within your organization, with the capture files
+ * using that link-layer header type not ever be sent outside your
+ * organization, you can use these values.
+ *
+ * No libpcap release will use these for any purpose, nor will any
+ * tcpdump release use them, either.
+ *
+ * Do *NOT* use these in capture files that you expect anybody not using
+ * your private versions of capture-file-reading tools to read; in
+ * particular, do *NOT* use them in products, otherwise you may find that
+ * people won't be able to use tcpdump, or snort, or Ethereal, or... to
+ * read capture files from your firewall/intrusion detection/traffic
+ * monitoring/etc. appliance, or whatever product uses that DLT_ value,
+ * and you may also find that the developers of those applications will
+ * not accept patches to let them read those files.
+ *
+ * Also, do not use them if somebody might send you a capture using them
+ * for *their* private type and tools using them for *your* private type
+ * would have to read them.
+ *
+ * Instead, ask "tcpdump-workers@tcpdump.org" for a new DLT_ value,
+ * as per the comment above, and use the type you're given.
+ */
+#define DLT_USER0 147
+#define DLT_USER1 148
+#define DLT_USER2 149
+#define DLT_USER3 150
+#define DLT_USER4 151
+#define DLT_USER5 152
+#define DLT_USER6 153
+#define DLT_USER7 154
+#define DLT_USER8 155
+#define DLT_USER9 156
+#define DLT_USER10 157
+#define DLT_USER11 158
+#define DLT_USER12 159
+#define DLT_USER13 160
+#define DLT_USER14 161
+#define DLT_USER15 162
+
+/*
+ * For future use with 802.11 captures - defined by AbsoluteValue
+ * Systems to store a number of bits of link-layer information
+ * including radio information:
+ *
+ * http://www.shaftnet.org/~pizza/software/capturefrm.txt
+ *
+ * but it might be used by some non-AVS drivers now or in the
+ * future.
+ */
+#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */
+
+/*
+ * Juniper-private data link type, as per request from
+ * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
+ * for passing on chassis-internal metainformation such as
+ * QOS profiles, etc..
+ */
+#define DLT_JUNIPER_MONITOR 164
+
+/*
+ * Reserved for BACnet MS/TP.
+ */
+#define DLT_BACNET_MS_TP 165
+
+/*
+ * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
+ *
+ * This is used in some OSes to allow a kernel socket filter to distinguish
+ * between incoming and outgoing packets, on a socket intended to
+ * supply pppd with outgoing packets so it can do dial-on-demand and
+ * hangup-on-lack-of-demand; incoming packets are filtered out so they
+ * don't cause pppd to hold the connection up (you don't want random
+ * input packets such as port scans, packets from old lost connections,
+ * etc. to force the connection to stay up).
+ *
+ * The first byte of the PPP header (0xff03) is modified to accomodate
+ * the direction - 0x00 = IN, 0x01 = OUT.
+ */
+#define DLT_PPP_PPPD 166
+
+/*
+ * Names for backwards compatibility with older versions of some PPP
+ * software; new software should use DLT_PPP_PPPD.
+ */
+#define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD
+#define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD
+
+/*
+ * Juniper-private data link type, as per request from
+ * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
+ * for passing on chassis-internal metainformation such as
+ * QOS profiles, cookies, etc..
+ */
+#define DLT_JUNIPER_PPPOE 167
+#define DLT_JUNIPER_PPPOE_ATM 168
+
+#define DLT_GPRS_LLC 169 /* GPRS LLC */
+#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
+#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
+
+/*
+ * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
+ * monitoring equipment.
+ */
+#define DLT_GCOM_T1E1 172
+#define DLT_GCOM_SERIAL 173
+
+/*
+ * Juniper-private data link type, as per request from
+ * Hannes Gredler <hannes@juniper.net>. The DLT_ is used
+ * for internal communication to Physical Interface Cards (PIC)
+ */
+#define DLT_JUNIPER_PIC_PEER 174
+
+/*
+ * Link types requested by Gregor Maier <gregor@endace.com> of Endace
+ * Measurement Systems. They add an ERF header (see
+ * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
+ * the link-layer header.
+ */
+#define DLT_ERF_ETH 175 /* Ethernet */
+#define DLT_ERF_POS 176 /* Packet-over-SONET */
+
+/*
+ * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
+ * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
+ * includes additional information before the LAPD header, so it's
+ * not necessarily a generic LAPD header.
+ */
+#define DLT_LINUX_LAPD 177
+
+/*
+ * Juniper-private data link type, as per request from
+ * Hannes Gredler <hannes@juniper.net>.
+ * The DLT_ are used for prepending meta-information
+ * like interface index, interface name
+ * before standard Ethernet, PPP, Frelay & C-HDLC Frames
+ */
+#define DLT_JUNIPER_ETHER 178
+#define DLT_JUNIPER_PPP 179
+#define DLT_JUNIPER_FRELAY 180
+#define DLT_JUNIPER_CHDLC 181
+
+/*
+ * The instruction encodings.
+ */
+/* instruction classes */
+#define BPF_CLASS(code) ((code) & 0x07)
+#define BPF_LD 0x00
+#define BPF_LDX 0x01
+#define BPF_ST 0x02
+#define BPF_STX 0x03
+#define BPF_ALU 0x04
+#define BPF_JMP 0x05
+#define BPF_RET 0x06
+#define BPF_MISC 0x07
+
+/* ld/ldx fields */
+#define BPF_SIZE(code) ((code) & 0x18)
+#define BPF_W 0x00
+#define BPF_H 0x08
+#define BPF_B 0x10
+#define BPF_MODE(code) ((code) & 0xe0)
+#define BPF_IMM 0x00
+#define BPF_ABS 0x20
+#define BPF_IND 0x40
+#define BPF_MEM 0x60
+#define BPF_LEN 0x80
+#define BPF_MSH 0xa0
+
+/* alu/jmp fields */
+#define BPF_OP(code) ((code) & 0xf0)
+#define BPF_ADD 0x00
+#define BPF_SUB 0x10
+#define BPF_MUL 0x20
+#define BPF_DIV 0x30
+#define BPF_OR 0x40
+#define BPF_AND 0x50
+#define BPF_LSH 0x60
+#define BPF_RSH 0x70
+#define BPF_NEG 0x80
+#define BPF_JA 0x00
+#define BPF_JEQ 0x10
+#define BPF_JGT 0x20
+#define BPF_JGE 0x30
+#define BPF_JSET 0x40
+#define BPF_SRC(code) ((code) & 0x08)
+#define BPF_K 0x00
+#define BPF_X 0x08
+
+/* ret - BPF_K and BPF_X also apply */
+#define BPF_RVAL(code) ((code) & 0x18)
+#define BPF_A 0x10
+
+/* misc */
+#define BPF_MISCOP(code) ((code) & 0xf8)
+#define BPF_TAX 0x00
+#define BPF_TXA 0x80
+
+/*
+ * The instruction data structure.
+ */
+struct bpf_insn {
+ u_short code;
+ u_char jt;
+ u_char jf;
+ bpf_int32 k;
+};
+
+/*
+ * Macros for insn array initializers.
+ */
+#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
+#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
+
+#if __STDC__ || defined(__cplusplus)
+extern int bpf_validate(struct bpf_insn *, int);
+extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
+#else
+extern int bpf_validate();
+extern u_int bpf_filter();
+#endif
+
+/*
+ * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
+ */
+#define BPF_MEMWORDS 16
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Win32bits/pcap-stdinc.h b/Win32bits/pcap-stdinc.h
new file mode 100644
index 0000000..4c3bd3f
--- /dev/null
+++ b/Win32bits/pcap-stdinc.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2002 - 2003
+ * NetGroup, Politecnico di Torino (Italy)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Politecnico di Torino nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#define SIZEOF_CHAR 1
+#define SIZEOF_SHORT 2
+#define SIZEOF_INT 4
+#ifndef _MSC_EXTENSIONS
+#define SIZEOF_LONG_LONG 8
+#endif
+
+/*
+ * Avoids a compiler warning in case this was already defined
+ * (someone defined _WINSOCKAPI_ when including 'windows.h', in order
+ * to prevent it from including 'winsock.h')
+ */
+#ifdef _WINSOCKAPI_
+#undef _WINSOCKAPI_
+#endif
+//#include <winsock2.h>
+
+#include <fcntl.h>
+
+//#include "bittypes.h"
+#include <time.h>
+#include <io.h>
+
+#ifndef __MINGW32__
+//#include "IP6_misc.h"
+#endif
+
+#define caddr_t char*
+
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#define inline __inline
diff --git a/Win32bits/winres.h b/Win32bits/winres.h
new file mode 100644
index 0000000..281950a
--- /dev/null
+++ b/Win32bits/winres.h
@@ -0,0 +1,597 @@
+// This is a part of the Microsoft Foundation Classes C++ library.
+// Copyright (C) 1992-1995 Microsoft Corporation
+// All rights reserved.
+//
+// This source code is only intended as a supplement to the
+// Microsoft Foundation Classes Reference and related
+// electronic documentation provided with the library.
+// See these sources for detailed information regarding the
+// Microsoft Foundation Classes product.
+
+// winres.h - Windows resource definitions
+// extracted from WINUSER.H and COMMCTRL.H
+
+#ifdef _AFX_MINREBUILD
+#pragma component(minrebuild, off)
+#endif
+
+#define VS_VERSION_INFO 1
+
+#ifdef APSTUDIO_INVOKED
+#define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols
+#endif
+
+#ifndef WINVER
+#define WINVER 0x0400 // default to Windows Version 4.0
+#endif
+
+#define OBM_CLOSE 32754
+#define OBM_UPARROW 32753
+#define OBM_DNARROW 32752
+#define OBM_RGARROW 32751
+#define OBM_LFARROW 32750
+#define OBM_REDUCE 32749
+#define OBM_ZOOM 32748
+#define OBM_RESTORE 32747
+#define OBM_REDUCED 32746
+#define OBM_ZOOMD 32745
+#define OBM_RESTORED 32744
+#define OBM_UPARROWD 32743
+#define OBM_DNARROWD 32742
+#define OBM_RGARROWD 32741
+#define OBM_LFARROWD 32740
+#define OBM_MNARROW 32739
+#define OBM_COMBO 32738
+#define OBM_UPARROWI 32737
+#define OBM_DNARROWI 32736
+#define OBM_RGARROWI 32735
+#define OBM_LFARROWI 32734
+#define OBM_OLD_CLOSE 32767
+#define OBM_SIZE 32766
+#define OBM_OLD_UPARROW 32765
+#define OBM_OLD_DNARROW 32764
+#define OBM_OLD_RGARROW 32763
+#define OBM_OLD_LFARROW 32762
+#define OBM_BTSIZE 32761
+#define OBM_CHECK 32760
+#define OBM_CHECKBOXES 32759
+#define OBM_BTNCORNERS 32758
+#define OBM_OLD_REDUCE 32757
+#define OBM_OLD_ZOOM 32756
+#define OBM_OLD_RESTORE 32755
+#define OCR_NORMAL 32512
+#define OCR_IBEAM 32513
+#define OCR_WAIT 32514
+#define OCR_CROSS 32515
+#define OCR_UP 32516
+#define OCR_SIZE 32640
+#define OCR_ICON 32641
+#define OCR_SIZENWSE 32642
+#define OCR_SIZENESW 32643
+#define OCR_SIZEWE 32644
+#define OCR_SIZENS 32645
+#define OCR_SIZEALL 32646
+#define OCR_ICOCUR 32647
+#define OCR_NO 32648
+#define OIC_SAMPLE 32512
+#define OIC_HAND 32513
+#define OIC_QUES 32514
+#define OIC_BANG 32515
+#define OIC_NOTE 32516
+
+#if (WINVER >= 0x0400)
+#define OCR_APPSTARTING 32650
+#define OIC_WINLOGO 32517
+#define OIC_WARNING OIC_BANG
+#define OIC_ERROR OIC_HAND
+#define OIC_INFORMATION OIC_NOTE
+#endif
+
+#define WS_OVERLAPPED 0x00000000L
+#define WS_POPUP 0x80000000L
+#define WS_CHILD 0x40000000L
+#define WS_CLIPSIBLINGS 0x04000000L
+#define WS_CLIPCHILDREN 0x02000000L
+#define WS_VISIBLE 0x10000000L
+#define WS_DISABLED 0x08000000L
+#define WS_MINIMIZE 0x20000000L
+#define WS_MAXIMIZE 0x01000000L
+#define WS_CAPTION 0x00C00000L
+#define WS_BORDER 0x00800000L
+#define WS_DLGFRAME 0x00400000L
+#define WS_VSCROLL 0x00200000L
+#define WS_HSCROLL 0x00100000L
+#define WS_SYSMENU 0x00080000L
+#define WS_THICKFRAME 0x00040000L
+#define WS_MINIMIZEBOX 0x00020000L
+#define WS_MAXIMIZEBOX 0x00010000L
+#define WS_GROUP 0x00020000L
+#define WS_TABSTOP 0x00010000L
+
+// other aliases
+#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
+#define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU)
+#define WS_CHILDWINDOW (WS_CHILD)
+#define WS_TILED WS_OVERLAPPED
+#define WS_ICONIC WS_MINIMIZE
+#define WS_SIZEBOX WS_THICKFRAME
+#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
+
+#define WS_EX_DLGMODALFRAME 0x00000001L
+#define WS_EX_NOPARENTNOTIFY 0x00000004L
+#define WS_EX_TOPMOST 0x00000008L
+#define WS_EX_ACCEPTFILES 0x00000010L
+#define WS_EX_TRANSPARENT 0x00000020L
+#if (WINVER >= 0x0400)
+#define WS_EX_MDICHILD 0x00000040L
+#define WS_EX_TOOLWINDOW 0x00000080L
+#define WS_EX_WINDOWEDGE 0x00000100L
+#define WS_EX_CLIENTEDGE 0x00000200L
+#define WS_EX_CONTEXTHELP 0x00000400L
+
+#define WS_EX_RIGHT 0x00001000L
+#define WS_EX_LEFT 0x00000000L
+#define WS_EX_RTLREADING 0x00002000L
+#define WS_EX_LTRREADING 0x00000000L
+#define WS_EX_LEFTSCROLLBAR 0x00004000L
+#define WS_EX_RIGHTSCROLLBAR 0x00000000L
+
+#define WS_EX_CONTROLPARENT 0x00010000L
+#define WS_EX_STATICEDGE 0x00020000L
+#define WS_EX_APPWINDOW 0x00040000L
+
+#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
+#define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
+#endif
+
+#define VK_LBUTTON 0x01
+#define VK_RBUTTON 0x02
+#define VK_CANCEL 0x03
+#define VK_MBUTTON 0x04
+#define VK_BACK 0x08
+#define VK_TAB 0x09
+#define VK_CLEAR 0x0C
+#define VK_RETURN 0x0D
+#define VK_SHIFT 0x10
+#define VK_CONTROL 0x11
+#define VK_MENU 0x12
+#define VK_PAUSE 0x13
+#define VK_CAPITAL 0x14
+#define VK_ESCAPE 0x1B
+#define VK_SPACE 0x20
+#define VK_PRIOR 0x21
+#define VK_NEXT 0x22
+#define VK_END 0x23
+#define VK_HOME 0x24
+#define VK_LEFT 0x25
+#define VK_UP 0x26
+#define VK_RIGHT 0x27
+#define VK_DOWN 0x28
+#define VK_SELECT 0x29
+#define VK_PRINT 0x2A
+#define VK_EXECUTE 0x2B
+#define VK_SNAPSHOT 0x2C
+#define VK_INSERT 0x2D
+#define VK_DELETE 0x2E
+#define VK_HELP 0x2F
+#define VK_NUMPAD0 0x60
+#define VK_NUMPAD1 0x61
+#define VK_NUMPAD2 0x62
+#define VK_NUMPAD3 0x63
+#define VK_NUMPAD4 0x64
+#define VK_NUMPAD5 0x65
+#define VK_NUMPAD6 0x66
+#define VK_NUMPAD7 0x67
+#define VK_NUMPAD8 0x68
+#define VK_NUMPAD9 0x69
+#define VK_MULTIPLY 0x6A
+#define VK_ADD 0x6B
+#define VK_SEPARATOR 0x6C
+#define VK_SUBTRACT 0x6D
+#define VK_DECIMAL 0x6E
+#define VK_DIVIDE 0x6F
+#define VK_F1 0x70
+#define VK_F2 0x71
+#define VK_F3 0x72
+#define VK_F4 0x73
+#define VK_F5 0x74
+#define VK_F6 0x75
+#define VK_F7 0x76
+#define VK_F8 0x77
+#define VK_F9 0x78
+#define VK_F10 0x79
+#define VK_F11 0x7A
+#define VK_F12 0x7B
+#define VK_F13 0x7C
+#define VK_F14 0x7D
+#define VK_F15 0x7E
+#define VK_F16 0x7F
+#define VK_F17 0x80
+#define VK_F18 0x81
+#define VK_F19 0x82
+#define VK_F20 0x83
+#define VK_F21 0x84
+#define VK_F22 0x85
+#define VK_F23 0x86
+#define VK_F24 0x87
+#define VK_NUMLOCK 0x90
+#define VK_SCROLL 0x91
+
+#define VK_LSHIFT 0xA0
+#define VK_RSHIFT 0xA1
+#define VK_LCONTROL 0xA2
+#define VK_RCONTROL 0xA3
+#define VK_LMENU 0xA4
+#define VK_RMENU 0xA5
+
+#if (WINVER >= 0x0400)
+#define VK_PROCESSKEY 0xE5
+#endif /* WINVER >= 0x0400 */
+
+#define VK_ATTN 0xF6
+#define VK_CRSEL 0xF7
+#define VK_EXSEL 0xF8
+#define VK_EREOF 0xF9
+#define VK_PLAY 0xFA
+#define VK_ZOOM 0xFB
+#define VK_NONAME 0xFC
+#define VK_PA1 0xFD
+#define VK_OEM_CLEAR 0xFE
+
+#define SC_SIZE 0xF000
+#define SC_MOVE 0xF010
+#define SC_MINIMIZE 0xF020
+#define SC_MAXIMIZE 0xF030
+#define SC_NEXTWINDOW 0xF040
+#define SC_PREVWINDOW 0xF050
+#define SC_CLOSE 0xF060
+#define SC_VSCROLL 0xF070
+#define SC_HSCROLL 0xF080
+#define SC_MOUSEMENU 0xF090
+#define SC_KEYMENU 0xF100
+#define SC_ARRANGE 0xF110
+#define SC_RESTORE 0xF120
+#define SC_TASKLIST 0xF130
+#define SC_SCREENSAVE 0xF140
+#define SC_HOTKEY 0xF150
+
+#define DS_ABSALIGN 0x01L
+#define DS_SYSMODAL 0x02L
+#define DS_LOCALEDIT 0x20L
+#define DS_SETFONT 0x40L
+#define DS_MODALFRAME 0x80L
+#define DS_NOIDLEMSG 0x100L
+#define DS_SETFOREGROUND 0x200L
+
+#ifdef _MAC
+#define DS_WINDOWSUI 0x8000L
+#endif
+
+#if (WINVER >= 0x0400)
+#define DS_3DLOOK 0x0004L
+#define DS_FIXEDSYS 0x0008L
+#define DS_NOFAILCREATE 0x0010L
+#define DS_CONTROL 0x0400L
+#define DS_CENTER 0x0800L
+#define DS_CENTERMOUSE 0x1000L
+#define DS_CONTEXTHELP 0x2000L
+#endif
+
+#define SS_LEFT 0x00000000L
+#define SS_CENTER 0x00000001L
+#define SS_RIGHT 0x00000002L
+#define SS_ICON 0x00000003L
+#define SS_BLACKRECT 0x00000004L
+#define SS_GRAYRECT 0x00000005L
+#define SS_WHITERECT 0x00000006L
+#define SS_BLACKFRAME 0x00000007L
+#define SS_GRAYFRAME 0x00000008L
+#define SS_WHITEFRAME 0x00000009L
+#define SS_SIMPLE 0x0000000BL
+#define SS_LEFTNOWORDWRAP 0x0000000CL
+#define SS_BITMAP 0x0000000EL
+
+#if (WINVER >= 0x0400)
+#define SS_OWNERDRAW 0x0000000DL
+#define SS_ENHMETAFILE 0x0000000FL
+#define SS_ETCHEDHORZ 0x00000010L
+#define SS_ETCHEDVERT 0x00000011L
+#define SS_ETCHEDFRAME 0x00000012L
+#endif
+
+#define SS_NOPREFIX 0x00000080L
+#if (WINVER >= 0x0400)
+#define SS_NOTIFY 0x00000100L
+#endif
+#define SS_CENTERIMAGE 0x00000200L
+#if (WINVER >= 0x0400)
+#define SS_RIGHTJUST 0x00000400L
+#define SS_REALSIZEIMAGE 0x00000800L
+#define SS_SUNKEN 0x00001000L
+#endif
+
+#define BS_PUSHBUTTON 0x00000000L
+#define BS_DEFPUSHBUTTON 0x00000001L
+#define BS_CHECKBOX 0x00000002L
+#define BS_AUTOCHECKBOX 0x00000003L
+#define BS_RADIOBUTTON 0x00000004L
+#define BS_3STATE 0x00000005L
+#define BS_AUTO3STATE 0x00000006L
+#define BS_GROUPBOX 0x00000007L
+#define BS_USERBUTTON 0x00000008L
+#define BS_AUTORADIOBUTTON 0x00000009L
+#define BS_OWNERDRAW 0x0000000BL
+#define BS_LEFTTEXT 0x00000020L
+#if (WINVER >= 0x0400)
+#define BS_TEXT 0x00000000L
+#define BS_ICON 0x00000040L
+#define BS_BITMAP 0x00000080L
+#define BS_LEFT 0x00000100L
+#define BS_RIGHT 0x00000200L
+#define BS_CENTER 0x00000300L
+#define BS_TOP 0x00000400L
+#define BS_BOTTOM 0x00000800L
+#define BS_VCENTER 0x00000C00L
+#define BS_PUSHLIKE 0x00001000L
+#define BS_MULTILINE 0x00002000L
+#define BS_NOTIFY 0x00004000L
+#define BS_FLAT 0x00008000L
+#define BS_RIGHTBUTTON BS_LEFTTEXT
+#endif
+
+#define ES_LEFT 0x00000000L
+#define ES_CENTER 0x00000001L
+#define ES_RIGHT 0x00000002L
+#define ES_MULTILINE 0x00000004L
+#define ES_UPPERCASE 0x00000008L
+#define ES_LOWERCASE 0x00000010L
+#define ES_PASSWORD 0x00000020L
+#define ES_AUTOVSCROLL 0x00000040L
+#define ES_AUTOHSCROLL 0x00000080L
+#define ES_NOHIDESEL 0x00000100L
+#define ES_OEMCONVERT 0x00000400L
+#define ES_READONLY 0x00000800L
+#define ES_WANTRETURN 0x00001000L
+#if (WINVER >= 0x0400)
+#define ES_NUMBER 0x2000L
+#endif
+
+#define SBS_HORZ 0x0000L
+#define SBS_VERT 0x0001L
+#define SBS_TOPALIGN 0x0002L
+#define SBS_LEFTALIGN 0x0002L
+#define SBS_BOTTOMALIGN 0x0004L
+#define SBS_RIGHTALIGN 0x0004L
+#define SBS_SIZEBOXTOPLEFTALIGN 0x0002L
+#define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L
+#define SBS_SIZEBOX 0x0008L
+#if (WINVER >= 0x0400)
+#define SBS_SIZEGRIP 0x0010L
+#endif
+
+#define LBS_NOTIFY 0x0001L
+#define LBS_SORT 0x0002L
+#define LBS_NOREDRAW 0x0004L
+#define LBS_MULTIPLESEL 0x0008L
+#define LBS_OWNERDRAWFIXED 0x0010L
+#define LBS_OWNERDRAWVARIABLE 0x0020L
+#define LBS_HASSTRINGS 0x0040L
+#define LBS_USETABSTOPS 0x0080L
+#define LBS_NOINTEGRALHEIGHT 0x0100L
+#define LBS_MULTICOLUMN 0x0200L
+#define LBS_WANTKEYBOARDINPUT 0x0400L
+#define LBS_EXTENDEDSEL 0x0800L
+#define LBS_DISABLENOSCROLL 0x1000L
+#if (WINVER >= 0x0400)
+#define LBS_NOSEL 0x4000L
+#endif
+#define LBS_STANDARD (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
+
+#define CBS_SIMPLE 0x0001L
+#define CBS_DROPDOWN 0x0002L
+#define CBS_DROPDOWNLIST 0x0003L
+#define CBS_OWNERDRAWFIXED 0x0010L
+#define CBS_OWNERDRAWVARIABLE 0x0020L
+#define CBS_AUTOHSCROLL 0x0040L
+#define CBS_OEMCONVERT 0x0080L
+#define CBS_SORT 0x0100L
+#define CBS_HASSTRINGS 0x0200L
+#define CBS_NOINTEGRALHEIGHT 0x0400L
+#define CBS_DISABLENOSCROLL 0x0800L
+#if (WINVER >= 0x0400)
+#define CBS_UPPERCASE 0x2000L
+#define CBS_LOWERCASE 0x4000L
+#endif
+
+// operation messages sent to DLGINIT
+#define WM_USER 0x0400
+#define LB_ADDSTRING (WM_USER+1)
+#define CB_ADDSTRING (WM_USER+3)
+
+#if (WINVER >= 0x0400)
+
+#define HDS_HORZ 0x00000000
+#define HDS_BUTTONS 0x00000002
+#define HDS_HIDDEN 0x00000008
+
+#define TTS_ALWAYSTIP 0x01
+#define TTS_NOPREFIX 0x02
+
+#define SBARS_SIZEGRIP 0x0100
+
+#define TBS_AUTOTICKS 0x0001
+#define TBS_VERT 0x0002
+#define TBS_HORZ 0x0000
+#define TBS_TOP 0x0004
+#define TBS_BOTTOM 0x0000
+#define TBS_LEFT 0x0004
+#define TBS_RIGHT 0x0000
+#define TBS_BOTH 0x0008
+#define TBS_NOTICKS 0x0010
+#define TBS_ENABLESELRANGE 0x0020
+#define TBS_FIXEDLENGTH 0x0040
+#define TBS_NOTHUMB 0x0080
+
+#define UDS_WRAP 0x0001
+#define UDS_SETBUDDYINT 0x0002
+#define UDS_ALIGNRIGHT 0x0004
+#define UDS_ALIGNLEFT 0x0008
+#define UDS_AUTOBUDDY 0x0010
+#define UDS_ARROWKEYS 0x0020
+#define UDS_HORZ 0x0040
+#define UDS_NOTHOUSANDS 0x0080
+
+#define CCS_TOP 0x00000001L
+#define CCS_NOMOVEY 0x00000002L
+#define CCS_BOTTOM 0x00000003L
+#define CCS_NORESIZE 0x00000004L
+#define CCS_NOPARENTALIGN 0x00000008L
+#define CCS_NOHILITE 0x00000010L
+#define CCS_ADJUSTABLE 0x00000020L
+#define CCS_NODIVIDER 0x00000040L
+
+#define LVS_ICON 0x0000
+#define LVS_REPORT 0x0001
+#define LVS_SMALLICON 0x0002
+#define LVS_LIST 0x0003
+#define LVS_TYPEMASK 0x0003
+#define LVS_SINGLESEL 0x0004
+#define LVS_SHOWSELALWAYS 0x0008
+#define LVS_SORTASCENDING 0x0010
+#define LVS_SORTDESCENDING 0x0020
+#define LVS_SHAREIMAGELISTS 0x0040
+#define LVS_NOLABELWRAP 0x0080
+#define LVS_AUTOARRANGE 0x0100
+#define LVS_EDITLABELS 0x0200
+#define LVS_NOSCROLL 0x2000
+
+#define LVS_ALIGNTOP 0x0000
+#define LVS_ALIGNLEFT 0x0800
+#define LVS_ALIGNMASK 0x0c00
+
+#define LVS_OWNERDRAWFIXED 0x0400
+#define LVS_NOCOLUMNHEADER 0x4000
+#define LVS_NOSORTHEADER 0x8000
+
+#define TVS_HASBUTTONS 0x0001
+#define TVS_HASLINES 0x0002
+#define TVS_LINESATROOT 0x0004
+#define TVS_EDITLABELS 0x0008
+#define TVS_DISABLEDRAGDROP 0x0010
+#define TVS_SHOWSELALWAYS 0x0020
+
+#define TCS_FORCEICONLEFT 0x0010
+#define TCS_FORCELABELLEFT 0x0020
+#define TCS_SHAREIMAGELISTS 0x0040
+#define TCS_TABS 0x0000
+#define TCS_BUTTONS 0x0100
+#define TCS_SINGLELINE 0x0000
+#define TCS_MULTILINE 0x0200
+#define TCS_RIGHTJUSTIFY 0x0000
+#define TCS_FIXEDWIDTH 0x0400
+#define TCS_RAGGEDRIGHT 0x0800
+#define TCS_FOCUSONBUTTONDOWN 0x1000
+#define TCS_OWNERDRAWFIXED 0x2000
+#define TCS_TOOLTIPS 0x4000
+#define TCS_FOCUSNEVER 0x8000
+
+#define ACS_CENTER 0x0001
+#define ACS_TRANSPARENT 0x0002
+#define ACS_AUTOPLAY 0x0004
+
+#endif // (WINVER >= 0x0400)
+
+// 32-bit language/sub-language identifiers
+
+#ifndef LANG_NEUTRAL
+// Primary language IDs.
+#define LANG_NEUTRAL 0x00
+
+#define LANG_BULGARIAN 0x02
+#define LANG_CHINESE 0x04
+#define LANG_CROATIAN 0x1a
+#define LANG_CZECH 0x05
+#define LANG_DANISH 0x06
+#define LANG_DUTCH 0x13
+#define LANG_ENGLISH 0x09
+#define LANG_FINNISH 0x0b
+#define LANG_FRENCH 0x0c
+#define LANG_GERMAN 0x07
+#define LANG_GREEK 0x08
+#define LANG_HUNGARIAN 0x0e
+#define LANG_ICELANDIC 0x0f
+#define LANG_ITALIAN 0x10
+#define LANG_JAPANESE 0x11
+#define LANG_KOREAN 0x12
+#define LANG_NORWEGIAN 0x14
+#define LANG_POLISH 0x15
+#define LANG_PORTUGUESE 0x16
+#define LANG_ROMANIAN 0x18
+#define LANG_RUSSIAN 0x19
+#define LANG_SLOVAK 0x1b
+#define LANG_SLOVENIAN 0x24
+#define LANG_SPANISH 0x0a
+#define LANG_SWEDISH 0x1d
+#define LANG_TURKISH 0x1f
+#endif //!LANG_NEUTRAL
+
+#ifndef SUBLANG_NEUTRAL
+// Sublanguage IDs.
+#define SUBLANG_NEUTRAL 0x00
+#define SUBLANG_DEFAULT 0x01
+#define SUBLANG_SYS_DEFAULT 0x02
+
+#define SUBLANG_CHINESE_TRADITIONAL 0x01
+#define SUBLANG_CHINESE_SIMPLIFIED 0x02
+#define SUBLANG_CHINESE_HONGKONG 0x03
+#define SUBLANG_CHINESE_SINGAPORE 0x04
+#define SUBLANG_DUTCH 0x01
+#define SUBLANG_DUTCH_BELGIAN 0x02
+#define SUBLANG_ENGLISH_US 0x01
+#define SUBLANG_ENGLISH_UK 0x02
+#define SUBLANG_ENGLISH_AUS 0x03
+#define SUBLANG_ENGLISH_CAN 0x04
+#define SUBLANG_ENGLISH_NZ 0x05
+#define SUBLANG_ENGLISH_EIRE 0x06
+#define SUBLANG_FRENCH 0x01
+#define SUBLANG_FRENCH_BELGIAN 0x02
+#define SUBLANG_FRENCH_CANADIAN 0x03
+#define SUBLANG_FRENCH_SWISS 0x04
+#define SUBLANG_GERMAN 0x01
+#define SUBLANG_GERMAN_SWISS 0x02
+#define SUBLANG_GERMAN_AUSTRIAN 0x03
+#define SUBLANG_ITALIAN 0x01
+#define SUBLANG_ITALIAN_SWISS 0x02
+#define SUBLANG_NORWEGIAN_BOKMAL 0x01
+#define SUBLANG_NORWEGIAN_NYNORSK 0x02
+#define SUBLANG_PORTUGUESE 0x02
+#define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
+#define SUBLANG_SPANISH 0x01
+#define SUBLANG_SPANISH_MEXICAN 0x02
+#define SUBLANG_SPANISH_MODERN 0x03
+#endif //!SUBLANG_NEUTRAL
+
+#ifdef APSTUDIO_INVOKED
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#endif
+
+#define IDOK 1
+#define IDCANCEL 2
+#define IDABORT 3
+#define IDRETRY 4
+#define IDIGNORE 5
+#define IDYES 6
+#define IDNO 7
+#if (WINVER >= 0x0400)
+#define IDCLOSE 8
+#define IDHELP 9
+#endif
+
+#ifdef IDC_STATIC
+#undef IDC_STATIC
+#endif
+#define IDC_STATIC (-1)
+
+#ifdef _AFX_MINREBUILD
+#pragma component(minrebuild, on)
+#endif
diff --git a/WinRPR.c b/WinRPR.c
index 531f41e..30f6cc4 100644
--- a/WinRPR.c
+++ b/WinRPR.c
@@ -511,6 +511,10 @@ ok:
}
}
+ DEDCheckRX(TNC);
+ DEDPoll(port);
+ DEDCheckRX(TNC);
+
return 0;
case 1: // poll
@@ -525,9 +529,6 @@ ok:
}
}
- DEDCheckRX(TNC);
- DEDPoll(port);
- DEDCheckRX(TNC);
for (Stream = 0; Stream <= MaxStreams; Stream++)
{
@@ -718,33 +719,9 @@ ok:
int WebProc(struct TNCINFO * TNC, char * Buff, BOOL LOCAL)
{
- int Interval = 15;
int Len;
- if (LOCAL)
- {
- if (TNC->WEB_CHANGED)
- Interval = 1;
- else
- Interval = 4;
- }
- else
- {
- if (TNC->WEB_CHANGED)
- Interval = 4;
- else
- Interval = 15;
- }
-
- if (TNC->WEB_CHANGED)
- {
- TNC->WEB_CHANGED -= Interval;
- if (TNC->WEB_CHANGED < 0)
- TNC->WEB_CHANGED = 0;
- }
-
- Len = sprintf(Buff, "<html><meta http-equiv=expires content=0><meta http-equiv=refresh content=%d>"
- "<head><title>WinRPR Status</title></head><body><h2>WinRPR Status</h2>", Interval);
+ Len = sprintf(Buff, "<h2>WinRPR Status</h2>");
Len += sprintf(&Buff[Len], "<table style=\"text-align: left; width: 480px; font-family: monospace; align=center \" border=1 cellpadding=2 cellspacing=2>");
@@ -1177,7 +1154,7 @@ VOID WinRPRProcessReceivedPacket(struct TNCINFO * TNC)
TNC->Streams[0].ReportDISC = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
return;
}
@@ -1533,10 +1510,11 @@ TNCRunning:
// sinx.sin_addr.s_addr = INADDR_ANY;
// sinx.sin_port = 0;
- sprintf(TNC->WEB_COMMSSTATE, "Connecting to TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
-
-
+ if (!TNC->Alerted)
+ {
+ sprintf(TNC->WEB_COMMSSTATE, "Connecting to TNC");
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ }
if (connect(TNC->TCPSock,(LPSOCKADDR) &TNC->destaddr,sizeof(TNC->destaddr)) == 0)
{
@@ -1556,9 +1534,9 @@ TNCRunning:
sprintf(Msg, "Connect Failed for WinRPR socket - error code = %d Port %d\n",
WSAGetLastError(), htons(TNC->destaddr.sin_port));
- WritetoConsoleLocal(Msg);
+ // WritetoConsoleLocal(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->Alerted = TRUE;
}
@@ -1614,7 +1592,7 @@ TNCRunning:
TNC->Alerted = TRUE;
sprintf(TNC->WEB_COMMSSTATE, "Connected to WinRPR TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
FreeSemaphore(&Semaphore);
@@ -1666,7 +1644,7 @@ Lost:
WritetoConsoleLocal(Msg);
sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC lost");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ MySetWindowText(TNC, TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
TNC->CONNECTED = FALSE;
TNC->Alerted = FALSE;
diff --git a/WinmorControl.c b/WinmorControl.c
index da24ff6..369d276 100644
--- a/WinmorControl.c
+++ b/WinmorControl.c
@@ -36,6 +36,7 @@
#include <malloc.h>
#include <memory.h>
#include <Psapi.h>
+#include "bpq32.h"
#define BPQICON 400
@@ -70,17 +71,6 @@ int addrlen = sizeof(struct sockaddr_in);
BOOL MinimizetoTray=FALSE;
-VOID __cdecl Debugprintf(const char * format, ...)
-{
- char Mess[10000];
- va_list(arglist);
- va_start(arglist, format);
- vsprintf(Mess, format, arglist);
- strcat(Mess, "\r\n");
- OutputDebugString(Mess);
-
- return;
-}
char * strlop(char * buf, char delim)
{
@@ -527,7 +517,7 @@ HANDLE OpenCOMPort(char * pPort, int speed, BOOL SetDTR, BOOL SetRTS, BOOL Quiet
else
{
sprintf(buf,"%s Setup Failed %d ", pPort, GetLastError());
- OutputDebugString(buf);
+ Debugprintf(buf);
CloseHandle(fd);
return 0;
}
diff --git a/WinmorControl.rc b/WinmorControl.rc
index f43f2d3..4fd61a6 100644
--- a/WinmorControl.rc
+++ b/WinmorControl.rc
@@ -25,7 +25,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#define BPQICON 400
-BPQICON ICON DISCARDABLE "..\BPQIcon.ICO"
+BPQICON ICON DISCARDABLE "BPQIcon.ICO"
//
// Version
diff --git a/adif.c b/adif.c
index 6fab6fc..1214fed 100644
--- a/adif.c
+++ b/adif.c
@@ -143,7 +143,7 @@ BOOL UpdateADIFRecord(ADIF * ADIF, char * Msg, char Dirn)
if (ADIF->StartTime == 0)
{
- ADIF->StartTime = time(NULL);
+ ADIF->StartTime = NOW;
// ADIF->Mode = 49; // Unused value (unforunately 0 = PKT1200)
}
@@ -393,7 +393,7 @@ BOOL WriteADIFRecord(ADIF * ADIF)
if (ADIF == NULL)
return TRUE;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
memcpy(&endtm, tm, sizeof(endtm));
diff --git a/asmstrucs.h b/asmstrucs.h
index 5e7fb29..22a00e5 100644
--- a/asmstrucs.h
+++ b/asmstrucs.h
@@ -139,7 +139,7 @@ typedef struct _TRANSPORTENTRY
UCHAR SPYFLAG; // SPY - CONNECT TO NODE VIA BBS CALLSIGN
UCHAR RTT_SEQ; // SEQUENCE NUMBER BEING TIMED
- uint32_t RTT_TIMER; // TIME ABOVE SEQUENCE WAS SENT
+ uint64_t RTT_TIMER; // TIME ABOVE SEQUENCE WAS SENT
USHORT PASSWORD; // AUTHORISATION CODE FOR REMOTE SYSOP
@@ -182,7 +182,7 @@ typedef struct _TRANSPORTENTRY
int segsResent;
int NRRID;
- time_t NRRTime;
+ uint64_t NRRTicks;
time_t ConnectTime;
char Direction[16]; // In or Out
@@ -237,7 +237,9 @@ typedef struct ROUTE
int ConnectionAttempts;
int Status; //
- int OldBPQ; // Set if other end is BPQ sending RIF in mS
+ int mSRIF; // Set if other end is BPQ sending RIF in mS (Ver < 2)
+ int senderaddsRTT; // Set if link RTT added before sending (Ver = 1)
+ int timeoutRoutes; // Set if other end always sends timed RIF updates (Hourly)
int LastRTT; // Last Value Reported
int RTT; // Current
int SRTT; // Smoothed RTT
@@ -264,6 +266,7 @@ typedef struct ROUTE
int recNum; // This entry's index it Routes table
int noV2point2; // Set to force V2.0 connect. Can be set in config or dynamically learned
int Stopped; // Set by STOPROUTE command
+ int NPR; // NPR Link
} *PROUTE;
@@ -481,21 +484,45 @@ typedef struct _APPLCALLS
// We treat the Routes as an array of 6. First 3 are NODES routes, next 3 are INP3 Routes. This works, but maybe is not ideal
-typedef struct NR_DEST_ROUTE_ENTRY
+struct NR_DEST_ROUTE_ENTRY
{
struct ROUTE * ROUT_NEIGHBOUR; // POINTER TO NEXT NODE IN PATH
- UCHAR ROUT_QUALITY; // QUALITY
- UCHAR ROUT_OBSCOUNT;
- UCHAR ROUT_LOCKED;
-} *PNR_DEST_ROUTE_ENTRY;
+ time_t padding; //
+ uint8_t ROUT_QUALITY; // QUALITY
+ uint8_t ROUT_OBSCOUNT;
+ uint8_t ROUT_LOCKED;
+};
-typedef struct INP3_DEST_ROUTE_ENTRY
+struct INP3_DEST_ROUTE_ENTRY
{
struct ROUTE * ROUT_NEIGHBOUR; // POINTER TO NEXT NODE IN PATH
- USHORT STT; // Current time to dest from here (was called RTT but is one way not round trip.
+ time_t LastRefreshed;
+ uint16_t STT; // Current time to dest from here (was called RTT but is one way not round trip.
// Is actually a smoothed value as is calculated from smoothed link times)
- UCHAR Hops;
-} *PDEST_ROUTE_ENTRY;
+ uint8_t Hops;
+};
+
+// Extended XR options for XROUTER
+
+typedef struct
+{
+ uint32_t IPADDR;
+ uint8_t Mask;
+ double Lat;
+ double Lon;
+ time_t Time;
+ uint16_t Port;
+ int16_t TZOffset;
+ char * LOC;
+ char * QTH;
+ char * Ver;
+ uint8_t SWType;
+ uint8_t NetworkFlags;
+ uint8_t ApplFlags;
+ uint8_t * Optionslist; // raw options as last received for relay
+} XROptions;
+
+
typedef struct DEST_LIST
{
@@ -520,6 +547,7 @@ typedef struct DEST_LIST
int DEST_RTT; // SMOOTHED ROUND TRIP TIMER
int DEST_COUNT; // FRAMES SENT
USHORT LastTT; // Last INP3 Value sent. This is our value, which we now send
+ XROptions * XROptions;
} dest_list;
@@ -663,8 +691,8 @@ typedef struct PORTCONTROL
UCHAR SOFTDCDFLAG; // IF SET USE 'SOFT DCD' - IF MODEM CANT GIVE A REAL ONE
UCHAR PORTSLOTTIME; // SLOT TIME
UCHAR PORTTAILTIME; // TAIL TIME
- UCHAR PORTT1; // L2 TIMEOUT
- UCHAR PORTT2; // L2 DELAYED ACK TIMER
+ UCHAR PORTT1; // L2 TIMEOUT (100 ms intervals)
+ UCHAR PORTT2; // L2 DELAYED ACK TIMER (100 ms intervals)
UCHAR PORTN2; // RETRIES
UCHAR PORTPACLEN; // DEFAULT PACLEN FOR INCOMING SESSIONS
diff --git a/bpq32.h b/bpq32.h
index 2bab90a..25951aa 100644
--- a/bpq32.h
+++ b/bpq32.h
@@ -13,7 +13,7 @@ make the code use GetProcAddress rather than LoadLibrary. Without this the refer
count on BPQ32.dll gets messed up, and the code will not unload cleanly.
*/
-
+#include "winstdint.h"
#ifndef DYNLOADBPQ
@@ -264,9 +264,18 @@ VOID APIENTRY SendChatReport(UINT_PTR ChatReportSocket, char * buff, int txlen);
int APIENTRY CountFramesQueuedOnStream(int Stream);
+int APIENTRY RunBPQ32Background();
+
char * APIENTRY GetLOC();
-DllExport uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqString);
+uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqString);
+
+VOID APIENTRY RealCloseAllPrograms();
+VOID APIENTRY CloseAllPrograms();
+
+VOID __cdecl Debugprintf(const char * format, ...);
+VOID APIENTRY OpenDebugLog();
+VOID APIENTRY CloseDebugLog();
#else
diff --git a/bpqaxip.c b/bpqaxip.c
index 5553b8c..ffd1569 100644
--- a/bpqaxip.c
+++ b/bpqaxip.c
@@ -400,9 +400,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
if (len > MAXDATA)
{
- sprintf(errmsg,"BPQAXIP Invalid Msg Len=%d Source=%s",len,inet_ntoa(RXaddr.rxaddr.sin_addr));
- OutputDebugString(errmsg);
- DumpFrameInHex(&rxbuff[20], len);
+ Debugprintf(errmsg,"BPQAXIP Invalid Msg Len=%d Source=%s",len,inet_ntoa(RXaddr.rxaddr.sin_addr));
return 0;
}
@@ -458,8 +456,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
// CRC Error
//
- sprintf(errmsg,"BPQAXIP Invalid CRC=%d Source=%s",crc,inet_ntoa(RXaddr.rxaddr.sin_addr));
- OutputDebugString(errmsg);
+ Debugprintf(errmsg,"BPQAXIP Invalid CRC=%d Source=%s",crc,inet_ntoa(RXaddr.rxaddr.sin_addr));
return (0);
}
@@ -503,9 +500,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
if (len > MAXDATA)
{
- sprintf(errmsg,"BPQAXIP Invalid Msg Len=%d Source=%s Port %d",len,inet_ntoa(RXaddr.rxaddr.sin_addr),PORT->udpport[i]);
- OutputDebugString(errmsg);
- DumpFrameInHex(&rxbuff[0], len);
+ Debugprintf(errmsg,"BPQAXIP Invalid Msg Len=%d Source=%s Port %d",len,inet_ntoa(RXaddr.rxaddr.sin_addr),PORT->udpport[i]);
return 0;
}
@@ -2630,7 +2625,7 @@ BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int FromPo
arp->SourcePort = ToPort;
}
}
- arp->LastHeard = time(NULL);
+ arp->LastHeard = NOW;
return 1; // Ok to process
}
index++;
@@ -2731,24 +2726,6 @@ int Update_MH_KeepAlive(struct AXIPPORTINFO * PORT, struct in_addr ipad, char pr
}
-int DumpFrameInHex(unsigned char * msg, int len)
-{
- char errmsg[100];
- int i=0;
-
- for (i=0;i<len;i+=16)
- {
- sprintf(errmsg,"%04x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x ",
- i, msg[i], msg[i+1],msg[i+2],msg[i+3],msg[i+4],msg[i+5],msg[i+6],msg[i+7],
- msg[i+8],msg[i+9],msg[i+10],msg[i+11],msg[i+12],msg[i+13],msg[i+14],msg[i+15]);
-
- OutputDebugString(errmsg);
- }
-
- return 0;
-}
-
-
int GetMessageFromBuffer(struct AXIPPORTINFO * PORT, char * Buffer)
{
struct arp_table_entry * sockptr;
@@ -3052,7 +3029,6 @@ VOID TCPConnectThread(void * Param)
//
arp->TCPState = TCPConnected;
- OutputDebugString("AXTCP Connected\r\n");
ioctl (arp->TCPSock, FIONBIO, &param);
Alerted = 0;
}
@@ -3065,10 +3041,8 @@ VOID TCPConnectThread(void * Param)
if (Alerted == 0)
{
- i = sprintf(Msg, "Connect Failed for AX/TCP port %d - error code = %d\n", htons(arp->destaddr.sin_port), err);
- WritetoConsole(Msg);
- OutputDebugString(Msg);
- Alerted = 1;
+ Debugprintf("Connect Failed for AX/TCP port %d - error code = %d", htons(arp->destaddr.sin_port), err);
+ Alerted = 1;
}
closesocket(arp->TCPSock);
arp->TCPSock = 0;
diff --git a/bpqchat.c b/bpqchat.c
index 3fc9ab2..c12b5ab 100644
--- a/bpqchat.c
+++ b/bpqchat.c
@@ -70,12 +70,16 @@
// Allow /History to be shortened to /Hi (45)
// Fix extra r charater in Chat Config Web Page
-//.25
+//.24
// Increase size of status display buffers (7)
// Allow sending BEL (CTRL/G) (79)
// Fix sending BEL (CTRL/G) (81)
+// .25
+
+// Only flush logs every 30 secs (25.31)
+
#include "BPQChat.h"
#include "Dbghelp.h"
diff --git a/bpqether.c b/bpqether.c
index 8de8801..cccb42a 100644
--- a/bpqether.c
+++ b/bpqether.c
@@ -56,7 +56,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include <process.h>
#include "pcap.h"
-#include "../CommonSource/bpq32.h"
+#include "bpq32.h"
//#include "packet32.h"
//#include "ntddndis.h"
@@ -153,8 +153,31 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
}
switch (fn)
{
+ case 7:
+
+ if (PCAP->adhandle == 0)
+ {
+ // No handle.
+
+ if (PCAP->Adapter[0])
+ {
+ // Try reopening periodically
+
+ PCAP->pcap_reopen_delay --;
+
+ if (PCAP->pcap_reopen_delay < 0)
+ if (OpenPCAP(PCAP) == FALSE)
+ PCAP->pcap_reopen_delay = 300; // Retry every 30 seconds
+ }
+ }
+
+ return 0;
+
case 1: // poll
+ if (PCAP->adhandle == 0)
+ return 0;
+
res = pcap_next_exx(PCAP->adhandle, &header, &pkt_data);
if (res == 0)
diff --git a/bpqhdlc.c b/bpqhdlc.c
index d8e3b3e..59aabf4 100644
--- a/bpqhdlc.c
+++ b/bpqhdlc.c
@@ -363,7 +363,6 @@ int HDLCINIT(HDLCDATA * PORTVEC)
else
{
Init98(PORTVEC);
- OutputDebugString("HDLC Win98 Return from Init98\n");
return 0;
}
@@ -376,8 +375,6 @@ int Init98(HDLCDATA * PORTVEC)
Win98 = TRUE;
- OutputDebugString("Init HDLC 98\n");
-
//
// Open HDLC Driver, send send config params
//
@@ -394,32 +391,14 @@ int Init98(HDLCDATA * PORTVEC)
if (hDevice == INVALID_HANDLE_VALUE)
{
hDevice=0;
-
- err=GetLastError();
-
- sprintf(msg,"Error loading Driver \\\\.\\BPQHDLC.VXD - Error code %d\n",err);
- OutputDebugString(msg);
-
- MessageBox(NULL,msg,"BPQ32",MB_ICONSTOP);
-
WritetoConsole("Initialisation Failed");
return (FALSE);
}
-// OutputDebugString("Calling GetVersion\n");
-
-// fResult = DeviceIoControl(
-// hDevice, // device handle
-// 10,//DIOC_GETVERSION, // control code
-// NULL,0,// input parameters
-// bOutput, 4, &cb, // output parameters
-// 0);
-
srand( (unsigned)time( NULL ) ); //Prime random no generator
}
- OutputDebugString("Calling Initialize\n");
//
// Initialize Driver for this card and channel
@@ -436,9 +415,6 @@ int Init98(HDLCDATA * PORTVEC)
memcpy(&PORTVEC->DRIVERPORTTABLE,bOutput,4);
Debugprintf("BPQ32 HDLC Driver Table ADDR %X", PORTVEC->DRIVERPORTTABLE);
-
- OutputDebugString("Initialize Returned\n");
-
return (TRUE);
}
@@ -607,8 +583,7 @@ int Init2K(HDLCDATA * PORTVEC)
err=GetLastError();
- sprintf(msg,"Error Opening Driver \\device\\BPQHDLC - Error code %d\n", err);
- OutputDebugString(msg);
+ Debugprintf("Error Opening Driver \\device\\BPQHDLC - Error code %d", err);
WritetoConsole(msg);
diff --git a/bpqmail.h b/bpqmail.h
index 941d24a..ea7e73b 100644
--- a/bpqmail.h
+++ b/bpqmail.h
@@ -883,7 +883,6 @@ struct MSESSION
int Index; // Line in Display
};
-VOID __cdecl nprintf(CIRCUIT * conn, const char * format, ...);
char * strlop(char * buf, char delim);
int rt_cmd(CIRCUIT *circuit, char * Buffer);
CIRCUIT *circuit_new(CIRCUIT *circuit, int flags);
diff --git a/bpqtermTCP.c b/bpqtermTCP.c
new file mode 100644
index 0000000..64ba1c8
--- /dev/null
+++ b/bpqtermTCP.c
@@ -0,0 +1,4170 @@
+
+// Version 2.0.1 November 2007
+
+// Change resizing algorith
+
+
+// Version 2.0.2 January 2008
+
+// Restore Checked state of Bells and AutoConnect Flags
+// Call CheckTimer on startup (for new Initialisation Scheme for perl)
+
+// Version 2.0.3 July 2008
+
+// Display lines received without a terminaing CR
+
+
+// Version 2.0.4 November 2008
+
+// Add option to remove a Line Feed following a CR
+// Add Logging Option
+
+// Version 2.0.5 January 2009
+
+// Add Start Minimized Option
+
+// Version 2.0.6 June 2009
+
+// Add Option to send *** Disconnnected on disconnect
+// Add line wrap code
+// Add option not to monitor NODES broadcasts
+
+// Version 2.0.7 October 2009
+
+// Add input buffer scrollback.
+// Fix monitoring when PORTNUM specified
+
+// Version 2.0.8 December 2009
+
+// Fix use of numeric keypad 2 and 8 (were treated as up and down)
+
+// Version 2.0.9 March 2010
+
+// Add colour for monitor and BPQ Chat
+
+// Version 2.0.0 October 2010
+
+// Add Chat Terminal Mode (sends keepalives)
+
+// Version 1.0.4.1 June 2012
+
+// Add UIOnly Monitor Option
+
+// Version 1.0.5.1 November 2012
+
+// Allow up to 8 hosts
+
+// Version 1.0.6.1 MY 2013
+
+// Send Connect Failed prompt after setting terminal status
+
+// Version 1.0.7.1 Aug 2013
+
+// Allow 16 hosts
+// Save host setup when changed instead of on exit
+
+
+// Version 1.0.8.1 ...
+
+// Operates in UTF-8
+
+// Version 1.0.9.1 Aug 2014
+
+// Add "alert on text" option
+
+// Version 1.0.10.1 Nov 2014
+// Fix possible crash on processing part line
+
+// Version 1.0.11.1 Feb 2015
+// Add "Alert after interval" feature
+// Fix "Copy to Clipboard"
+
+// Version 1.0.12.1 Nov 2015
+// Add Port Names to Monitor Config and fix saving monitor option s by host
+
+
+// Version 1.0.13.1 Sept 2016
+
+// Fix buffer overrun introduced in 1.0.12.1
+// Fix saving Alert and Keyword filenames
+
+// Version 1.0.14.1 July 2017
+
+// Add popup if keywords file can't be found
+
+// Version 1.0.15.1 Feb 2018
+
+// Allow use of IPV6 even if host resolves to both V4 and V6 addresses (add IPV6: on front of hostname)
+// Add Listen Mode
+// Only send UTF-8 option if send in UTF-8 is set
+// Drop received Keepalive packets
+
+// Version 1.0.16.1 ??
+
+// Add YAPP File Transfer
+
+// Version 1.0.16.2 August 20203
+
+// Support Monitoring 63 ports
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "winsock2.h"
+#include "WS2tcpip.h"
+#include <windows.h>
+#include <winstdint.h>
+#include <winuser.h>
+#include <time.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <memory.h>
+#include <sys/types.h>
+#include <wchar.h>
+#include <sys/stat.h>
+//#define _RICHEDIT_VER 0x0100
+#include <Richedit.h>
+#define IDC_STATIC -1
+#include "bpqtermTCP.h"
+#define TermTCP
+#include "Versions.h"
+#include "GetVersion.h"
+#include "Shlobj.h"
+
+#define BPQICON 2
+
+#define BGCOLOUR RGB(236,233,216)
+
+#define WSA_ACCEPT WM_USER + 1
+#define WSA_CONNECT WM_USER + 2
+#define WSA_DATA WM_USER + 3
+
+#define BPQBASE 1100
+
+HBRUSH bgBrush;
+
+HINSTANCE hInst;
+TCHAR AppName[] = L"BPQTerm 32";
+TCHAR ClassName[] = L"BPQMAINWINDOW";
+TCHAR Title[80];
+
+BOOL WINE;
+
+BOOL UseKeywords = TRUE;
+
+TCHAR KeyWordsName[MAX_PATH] = L"Keywords.sys";
+char ** KeyWords = NULL;
+int NumberofKeyWords = 0;
+
+// YAPP stuff
+
+#define SOH 1
+#define STX 2
+#define ETX 3
+#define EOT 4
+#define ENQ 5
+#define ACK 6
+#define DLE 0x10
+#define NAK 0x15
+#define CAN 0x18
+
+
+UCHAR InputMode; // Normal or YAPP
+WCHAR YAPPPath[MAX_PATH] = L""; // Path for saving YAPP Files
+
+// Foward declarations of functions included in this code module:
+
+ATOM MyRegisterClass(CONST WNDCLASS*);
+BOOL InitApplication(HINSTANCE);
+BOOL InitInstance(HINSTANCE, int);
+LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
+int NewLine();
+VOID DoRefresh(struct RTFTerm * OPData);
+VOID SendTraceOptions();
+int ProcessBuff(char * readbuff,int len);
+VOID EnableConnectMenu(HWND hWnd);
+VOID EnableDisconnectMenu(HWND hWnd);
+VOID DisableConnectMenu(HWND hWnd);
+VOID DisableDisconnectMenu(HWND hWnd);
+VOID DisableYAPPMenu(HWND hWnd);
+VOID EnableYAPPMenu(HWND hWnd);
+
+int DoReceivedData(HWND hWnd);
+int DoStateChange(HWND hWnd);
+int ToggleFlags(HWND hWnd, int Item, int mask);
+int DoMonData(HWND hWnd);
+int TogglePort(HWND hWnd, int Item, int mask);
+int ToggleMTX(HWND hWnd);
+int ToggleMCOM(HWND hWnd);
+int ToggleMUI(HWND hWnd);
+int ToggleParam(HWND hWnd, BOOL * Param, int Item);
+int ToggleChat(HWND hWnd);
+void MoveWindows();
+void CopyListToClipboard(HWND hWnd);
+void CopyRichTextToClipboard(HWND hWnd);
+BOOL OpenMonitorLogfile();
+void WriteMonitorLine(TCHAR * Msg, int MsgLen);
+VOID WritetoOutputWindow(struct RTFTerm * OPData, TCHAR * Msg, int len);
+int SendMsg(TCHAR * msg, int len);
+TCPConnect(TCHAR * Host, int Port);
+int Telnet_Connected(SOCKET sock, int Error);
+VOID DataSocket_Read(SOCKET sock);
+VOID Socket_Data(int sock, int error, int eventcode);
+VOID Socket_Accept(int sock, int error, int eventcode);
+SOCKET OpenListenSocket4(int port);
+void YAPPSendFile(WCHAR * filename);
+void QueueMsg(UCHAR * Msg, int Len);
+BOOL ProcessYAPPMessage(UCHAR * Msg, int Len);
+
+COLORREF Colours[256] = {0,
+ RGB(0,0,0), RGB(0,0,128), RGB(0,0,192), RGB(0,0,255), // 1 - 4
+ RGB(0,64,0), RGB(0,64,128), RGB(0,64,192), RGB(0,64,255), // 5 - 8
+ RGB(0,128,0), RGB(0,128,128), RGB(0,128,192), RGB(0,128,255), // 9 - 12
+ RGB(0,192,0), RGB(0,192,128), RGB(0,192,192), RGB(0,192,255), // 13 - 16
+ RGB(0,255,0), RGB(0,255,128), RGB(0,255,192), RGB(0,255,255), // 17 - 20
+
+ RGB(64,0,0), RGB(64,0,128), RGB(64,0,192), RGB(0,0,255), // 21
+ RGB(64,64,0), RGB(64,64,128), RGB(64,64,192), RGB(64,64,255),
+ RGB(64,128,0), RGB(64,128,128), RGB(64,128,192), RGB(64,128,255),
+ RGB(64,192,0), RGB(64,192,128), RGB(64,192,192), RGB(64,192,255),
+ RGB(64,255,0), RGB(64,255,128), RGB(64,255,192), RGB(64,255,255),
+
+ RGB(128,0,0), RGB(128,0,128), RGB(128,0,192), RGB(128,0,255), // 41
+ RGB(128,64,0), RGB(128,64,128), RGB(128,64,192), RGB(128,64,255),
+ RGB(128,128,0), RGB(128,128,128), RGB(128,128,192), RGB(128,128,255),
+ RGB(128,192,0), RGB(128,192,128), RGB(128,192,192), RGB(128,192,255),
+ RGB(128,255,0), RGB(128,255,128), RGB(128,255,192), RGB(128,255,255),
+
+ RGB(192,0,0), RGB(192,0,128), RGB(192,0,192), RGB(192,0,255), // 61
+ RGB(192,64,0), RGB(192,64,128), RGB(192,64,192), RGB(192,64,255),
+ RGB(192,128,0), RGB(192,128,128), RGB(192,128,192), RGB(192,128,255),
+ RGB(192,192,0), RGB(192,192,128), RGB(192,192,192), RGB(192,192,255),
+ RGB(192,255,0), RGB(192,255,128), RGB(192,255,192), RGB(192,2552,255),
+
+ RGB(255,0,0), RGB(255,0,128), RGB(255,0,192), RGB(255,0,255), // 81
+ RGB(255,64,0), RGB(255,64,128), RGB(255,64,192), RGB(255,64,255),
+ RGB(255,128,0), RGB(255,128,128), RGB(255,128,192), RGB(255,128,255),
+ RGB(255,192,0), RGB(255,192,128), RGB(255,192,192), RGB(255,192,255),
+ RGB(255,255,0), RGB(255,255,128), RGB(255,255,192), RGB(255,2552,255)
+};
+
+LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+//LRESULT APIENTRY OutputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+LRESULT APIENTRY MonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+LRESULT APIENTRY SplitProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
+
+
+LONG_PTR wpOrigInputProc;
+//WNDPROC wpOrigOutputProc;
+LONG_PTR wpOrigMonProc;
+LONG_PTR wpOrigSplitProc;
+
+HWND hwndInput;
+HWND hwndOutput;
+HWND hwndMon;
+HWND hwndSplit;
+
+HMENU trayMenu;
+
+#define AUTO -1
+#define CP437 437
+#define CP1251 1251
+#define CP1252 1252
+
+int RXMode = AUTO;
+int TXMode = CP_UTF8;
+
+int xsize,ysize; // Screen size at startup
+
+double Split=0.5;
+int SplitPos=300;
+#define SplitBarHeight 5
+#define InputBoxHeight 25
+RECT Rect;
+RECT MonRect;
+//RECT OutputRect;
+RECT SplitRect;
+
+int OutputBoxHeight;
+
+int Height, Width, LastY;
+
+int maxlinelen = 80;
+
+#define MAXHOSTS 16
+
+TCHAR Host[MAXHOSTS + 1][100] = {L"localhost"};
+int Port[MAXHOSTS + 1] = {0};
+TCHAR UserName[MAXHOSTS + 1][80] = {L""};
+TCHAR Password[MAXHOSTS + 1][80] = {L""};
+TCHAR MonParams[MAXHOSTS + 1][80] = {L""};
+int ListenPort = 8015;
+
+TCHAR HN[MAXHOSTS + 1][7] = {L"Host1", L"Host2", L"Host3", L"Host4", L"Host5", L"Host6", L"Host7", L"Host8",
+ L"Host9", L"Host10", L"Host11", L"Host12", L"Host13", L"Host14", L"Host15", L"Host16"};
+TCHAR PN[MAXHOSTS + 1][7] = {L"Port1", L"Port2", L"Port3", L"Port4", L"Port5", L"Port6", L"Port7", L"Port8",
+ L"Port9", L"Port10", L"Port11", L"Port12", L"Port13", L"Port14", L"Port15", L"Port16"};
+TCHAR UN[MAXHOSTS + 1][7] = {L"User1", L"User2", L"User3", L"User4", L"User5", L"User6", L"User7", L"User8",
+ L"User9", L"User10", L"User11", L"User12", L"User13", L"User14", L"User15", L"User16"};
+TCHAR MON[MAXHOSTS + 1][7] = {L"MON1", L"MON2", L"MON3", L"MON4", L"MON5", L"MON6", L"MON7", L"MON8",
+ L"MON9", L"MON10", L"MON11", L"MON12", L"MON13", L"MON14", L"MON15", L"MON16"};
+TCHAR PASSN[MAXHOSTS + 1][7] = {L"Pass1", L"Pass2", L"Pass3", L"Pass4", L"Pass5", L"Pass6", L"Pass7", L"Pass8",
+ L"Pass9", L"Pass10", L"Pass11", L"Pass12", L"Pass13", L"Pass14", L"Pass15", L"Pass16"};
+
+
+#define MAXLINES 1000
+#define LINELEN 200
+
+char RTFHeader[4000];
+
+int RTFHddrLen;
+
+typedef struct RTFTerm
+{
+ int CurrentLine; // Line we are writing to in circular buffer.
+
+ int Index;
+ BOOL SendHeader;
+ BOOL Finished;
+
+ TCHAR OutputScreen[MAXLINES][LINELEN];
+
+ int Colourvalue[MAXLINES];
+ int LineLen[MAXLINES];
+ int CharWidth;
+ int CurrentColour;
+ int Thumb;
+ int FirstTime;
+ int RTFHeight; // Height of RTF control in pixels
+ BOOL Scrolled; // Window is scrolled back
+
+};
+
+TCHAR FontName[100] = L"Courier New";
+int FontSize = 20;
+int FontWidth = 8;
+int CodePage = 437;
+int CharSet = 0;
+
+
+struct RTFTerm OutputData;
+
+int CurrentHost = 0;
+int CfgNo = 0;
+
+SOCKET sock = 0;
+SOCKET ListenSock = 0;
+
+BOOL MonData = FALSE;
+
+TCHAR Key[80];
+uint64_t portmask=0;
+int mtxparam=1;
+int mcomparam=1;
+int monUI=0;
+
+TCHAR kbbuf[250];
+int kbptr=0;
+TCHAR readbuff[100000]; // for stupid bbs programs
+
+//int ptr=0;
+
+int Stream;
+int len,count;
+
+TCHAR callsign[10];
+int state;
+int change;
+
+int PartLinePtr=0;
+int PartLineIndex=0; // Listbox index of (last) incomplete line
+
+BOOL Bells = FALSE;
+BOOL StripLF = FALSE;
+BOOL LogMonitor = FALSE;
+BOOL LogOutput = FALSE;
+BOOL SendDisconnected = TRUE;
+BOOL MonitorNODES = TRUE;
+BOOL MonitorColour = TRUE;
+BOOL ChatMode = FALSE;
+int MonPorts = 1;
+BOOL ListenOn = FALSE;
+
+time_t LastWrite = 0xffffffff;
+int AlertInterval = 300;
+BOOL AlertBeep = TRUE;
+int AlertFreq = 600;
+int AlertDuration = 250;
+TCHAR AlertFileName[MAX_PATH] = {0};
+
+HANDLE MonHandle=INVALID_HANDLE_VALUE;
+
+HCURSOR DragCursor;
+HCURSOR Cursor;
+
+BOOL MinimizetoTray=FALSE;
+//BOOL StartMinimized = FALSE;
+
+HWND MainWnd, hWnd;
+
+BOOL SocketActive = FALSE;
+BOOL Connecting = FALSE;
+BOOL Connected = FALSE;
+BOOL Disconnecting = FALSE;
+
+VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime );
+
+TIMERPROC lpTimerFunc = (TIMERPROC) TimerProc;
+
+int TimerHandle = 0;
+
+int SlowTimer;
+
+VOID __cdecl Debugprintf(const char * format, ...)
+{
+ char Mess[1000];
+ va_list(arglist);int Len;
+
+ va_start(arglist, format);
+ Len = vsprintf_s(Mess, sizeof(Mess), format, arglist);
+ strcat(Mess, "\r\n");
+ OutputDebugStringA(Mess);
+ return;
+}
+
+
+VOID SaveIntValue(TCHAR * Key, int Value)
+{
+ TCHAR Val[100];
+
+ wsprintf(Val, L"%d", Value);
+ WritePrivateProfileString(L"Session 1", Key, Val, L".\\BPQTermTCP.ini");
+}
+
+VOID SaveStringValue(TCHAR * Key, TCHAR * Value)
+{
+ WritePrivateProfileString(L"Session 1", Key, Value, L".\\BPQTermTCP.ini");
+}
+
+int GetIntValue(TCHAR * Key, int Default)
+{
+ return GetPrivateProfileInt(L"Session 1", Key, Default, L".\\BPQTermTCP.ini");
+}
+
+VOID GetStringValue(TCHAR * Key, TCHAR * Value, int Len)
+{
+ GetPrivateProfileString(L"Session 1", Key, L"", Value, Len, L".\\BPQTermTCP.ini");
+}
+
+VOID CALLBACK TimerProc(
+
+ HWND hwnd, // handle of window for timer messages
+ UINT uMsg, // WM_TIMER message
+ UINT idEvent, // timer identifier
+ DWORD dwTime) // current system time
+{
+
+ // entered every 10 secs
+
+ if (!Connected)
+ return;
+
+ if (!ChatMode)
+ return;
+
+ SlowTimer++;
+
+ if (SlowTimer > 50) // About 9 mins
+ {
+ SlowTimer = 0;
+ SendMsg(L"\0", 1);
+ }
+}
+
+VOID GetKeyWordFile()
+{
+ FILE * Handle;
+ DWORD FileSize;
+ char * ptr1, * ptr2;
+ struct stat STAT;
+ char * KeyWordFile;
+
+ if (_wstat(KeyWordsName, &STAT) == -1)
+ {
+ if (UseKeywords)
+ {
+ TCHAR Dir[MAX_PATH];
+ TCHAR Msg[512];
+ GetCurrentDirectory(MAX_PATH, Dir);
+ wsprintf(Msg, L"Couldn't find file %s in %s", KeyWordsName, Dir);
+ MessageBox(NULL, Msg, L"BPQTermTCP", MB_OK);
+ }
+ return;
+ }
+
+ FileSize = STAT.st_size;
+
+ Handle = _wfopen(KeyWordsName, L"rb");
+
+ if (Handle == NULL)
+ return;
+
+ KeyWordFile = malloc(FileSize+1);
+
+ fread(KeyWordFile, 1, FileSize, Handle);
+
+ fclose(Handle);
+
+ KeyWordFile[FileSize]=0;
+
+ _strlwr(KeyWordFile); // Compares are case-insensitive
+
+ ptr1 = KeyWordFile;
+
+ while (ptr1)
+ {
+ if (*ptr1 == '\n') ptr1++;
+
+ ptr2 = strtok_s(NULL, "\r\n", &ptr1);
+ if (ptr2)
+ {
+ if (*ptr2 != '#')
+ {
+ KeyWords = realloc(KeyWords,(++NumberofKeyWords+1)*4);
+ KeyWords[NumberofKeyWords] = ptr2;
+ }
+ }
+ else
+ break;
+ }
+}
+
+BOOL CheckKeyWord(char * Word, char * Msg)
+{
+ char * ptr1 = Msg, * ptr2;
+ int len = strlen(Word);
+
+ while (*ptr1) // Stop at end
+ {
+ ptr2 = strstr(ptr1, Word);
+
+ if (ptr2 == NULL)
+ return FALSE; // OK
+
+ // Only bad if it ia not part of a longer word
+
+ if ((ptr2 == Msg) || !(isalpha(*(ptr2 - 1)))) // No alpha before
+ if (!(isalpha(*(ptr2 + len)))) // No alpha after
+ return TRUE; // Bad word
+
+ // Keep searching
+
+ ptr1 = ptr2 + len;
+ }
+
+ return FALSE; // OK
+}
+
+BOOL CheckKeyWords(char * Msg, int len)
+{
+ char dupMsg[2048];
+ int i;
+
+ if (UseKeywords == 0 || NumberofKeyWords == 0)
+ return FALSE;
+
+ memcpy(dupMsg, Msg, len);
+ dupMsg[len] = 0;
+ _strlwr(dupMsg);
+
+ for (i = 1; i <= NumberofKeyWords; i++)
+ {
+ if (CheckKeyWord(KeyWords[i], dupMsg))
+ {
+ Beep(660,250);
+ return TRUE; // Alert
+ }
+ }
+
+ return FALSE; // OK
+
+}
+
+
+
+//
+// FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
+//
+// PURPOSE: Entry point for the application.
+//
+// COMMENTS:
+//
+// This function initializes the application and processes the
+// message loop.
+//
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char * lpCmdLine, int nCmdShow)
+{
+ MSG msg;
+ TCHAR Size[80];
+
+ if (_stricmp(lpCmdLine, "Listen") == 0)
+ ListenOn = TRUE;
+
+ if (!InitApplication(hInstance))
+ return (FALSE);
+
+ if (!InitInstance(hInstance, nCmdShow))
+ return (FALSE);
+
+ if (ListenOn == TRUE)
+ {
+ DisableConnectMenu(hWnd);
+ ListenSock = OpenListenSocket4(ListenPort);
+ }
+
+ DisableYAPPMenu(hWnd);
+
+ // Main message loop:
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ SaveIntValue(L"PortMask", portmask);
+ SaveIntValue(L"Bells", Bells);
+ SaveIntValue(L"StripLF", StripLF);
+
+ SaveIntValue(L"MTX",mtxparam);
+ SaveIntValue(L"MCOM", mcomparam);
+ SaveIntValue(L"MUIONLY", monUI);
+
+#pragma warning(push)
+#pragma warning(disable:4244)
+ SaveIntValue(L"Split", Split * 100);
+#pragma warning(pop)
+
+ SaveIntValue(L"MONColour", MonitorColour);
+ SaveIntValue(L"MonNODES", MonitorNODES);
+ SaveIntValue(L"MonPorts", MonPorts);
+ SaveIntValue(L"ChatMode", ChatMode);
+ SaveIntValue(L"CurrentHost", CurrentHost);
+
+ wsprintf(Size,L"%d,%d,%d,%d",Rect.left,Rect.right,Rect.top,Rect.bottom);
+ SaveStringValue(L"Size", Size);
+
+ SaveStringValue(L"FontName", FontName);
+ SaveIntValue(L"CharSet", CharSet);
+ SaveIntValue(L"CodePage", CodePage);
+ SaveIntValue(L"FontSize", FontSize);
+ SaveIntValue(L"FontWidth", FontWidth);
+ SaveIntValue(L"AlertInterval", AlertInterval);
+
+ KillTimer(NULL, TimerHandle);
+
+ return (msg.wParam);
+}
+
+//
+
+//
+// FUNCTION: InitApplication(HANDLE)
+//
+// PURPOSE: Initializes window data and registers window class
+//
+// COMMENTS:
+//
+// In this function, we initialize a window class by filling out a data
+// structure of type WNDCLASS and calling either RegisterClass or
+// the internal MyRegisterClass.
+//
+BOOL InitApplication(HINSTANCE hInstance)
+{
+ WNDCLASS wc;
+
+ bgBrush = CreateSolidBrush(BGCOLOUR);
+
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = WndProc;
+
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = DLGWINDOWEXTRA;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(BPQICON));
+ wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = bgBrush;
+
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = ClassName;
+
+ return (RegisterClass(&wc));
+
+}
+
+HMENU hMenu, hPopMenu1, hPopMenu2, hPopMenu3; // handle of menu
+
+VOID SetupRTFHddr()
+{
+ int i, n;
+ char RTFColours[3000];
+ char Temp[1000];
+
+ // Set up RTF Header, including Colours String;
+
+ memcpy(RTFColours, "{\\colortbl ;", 12);
+ n = 12;
+
+ for (i = 1; i < 100; i++)
+ {
+ COLORREF Colour = Colours[i];
+ n += sprintf(&RTFColours[n], "\\red%d\\green%d\\blue%d;", GetRValue(Colour), GetGValue(Colour),GetBValue(Colour));
+ }
+
+ RTFColours[n++] = '}';
+ RTFColours[n] = 0;
+
+// wcscpy(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset204 ;}}");
+ sprintf(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fprq1\\cpg%d\\fcharset%d %s;}}", CodePage, CharSet, FontName);
+ sprintf(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fmodern\\fprq1;}}");
+ strcat(RTFHeader, RTFColours);
+ sprintf(Temp, "\\viewkind4\\uc1\\pard\\f0\\fs%d\\uc0", FontSize);
+ strcat(RTFHeader, Temp);
+
+ RTFHddrLen = strlen(RTFHeader);
+}
+
+TCHAR VersionStringW[100];
+
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ int i, n, tempmask=0xffff;
+ TCHAR msg[20];
+ TCHAR Size[80];
+ WSADATA WsaData; // receives data from WSAStartup
+ struct RTFTerm * OPData;
+ int retCode;
+ HKEY hKey=0;
+
+ hInst = hInstance; // Store instance handle in our global variable
+
+ WSAStartup(MAKEWORD(2, 0), &WsaData);
+
+ // See if running under WINE
+
+ retCode = RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Wine", 0, KEY_QUERY_VALUE, &hKey);
+
+ if (retCode == ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ WINE =TRUE;
+ Debugprintf("Running under WINE");
+ }
+// Get saved config from ini
+
+// MonitorNODES = GetIntValue("MonNODES", 0);
+ MonPorts = GetIntValue(L"MonPorts", 0);
+// mtxparam = GetIntValue("MTX", 0);
+// mcomparam = GetIntValue("MCOM", 0);
+// monUI = GetIntValue("MUIONLY", 0);
+ tempmask = GetIntValue(L"PortMask", 0);
+ ChatMode = GetIntValue(L"ChatMode", 0);
+ MonitorColour = GetIntValue(L"MONColour", 0);
+ Bells = GetIntValue(L"Bells", 0);
+ StripLF = GetIntValue(L"StripLF", 0);
+ CurrentHost = GetIntValue(L"CurrentHost", 0);
+ Split = GetIntValue(L"Split", 0);
+ if (Split == 0)
+ Split = 50;
+
+ Split /= 100; // Stored as a %,used as 0 - 1
+
+ for (n = 0; n < MAXHOSTS; n++)
+ {
+ GetStringValue(HN[n], Host[n], 100);
+ GetStringValue(UN[n], UserName[n], 80);
+ GetStringValue(PASSN[n], Password[n], 80);
+ Port[n] = GetIntValue(PN[n], 0);
+ GetStringValue(MON[n], MonParams[n], 80);
+ }
+
+ n = swscanf(MonParams[CurrentHost], L"%x %x %x %x %x %x",
+ &portmask, &mtxparam, &mcomparam, &MonitorNODES, &MonitorColour, &monUI);
+
+
+// GetStringValue(L"FontName", FontName, 99);
+
+// if (FontName[0] == 0)
+// wcscpy(FontName, L"Courier New");
+
+// CharSet = GetIntValue(L"CharSet", 0);
+// CodePage = GetIntValue(L"CodePage", 437);
+
+ FontSize = GetIntValue(L"FontSize", 20);
+ FontWidth = GetIntValue(L"FontWidth", 8);
+ RXMode = GetIntValue(L"RXMODE", -1);
+ TXMode = GetIntValue(L"TXMODE", CP_UTF8);
+
+ AlertInterval = GetIntValue(L"AlertInterval", 3600);
+ AlertBeep = GetIntValue(L"AlertBeep", 1);
+ AlertFreq = GetIntValue(L"AlertFreq", 600);
+ AlertDuration = GetIntValue(L"AlertDuration", 250);
+
+ GetStringValue(L"AlertFileName", AlertFileName, MAX_PATH - 1);
+
+ ListenPort = GetIntValue(L"ListenPort", 8515);
+
+ UseKeywords = GetIntValue(L"UseKeywords", 1);
+ GetStringValue(L"AlertKeyFile", KeyWordsName, MAX_PATH - 1);
+
+ if (UseKeywords && KeyWordsName[0] == 0)
+ wcscpy(&KeyWordsName[0], L"Keywords.sys");
+
+ GetStringValue(L"YAPPPath", YAPPPath, MAX_PATH - 1);
+
+
+ OutputData.CharWidth = FontWidth;
+
+ // Create a dialog box as the main window
+
+ hWnd = CreateDialog(hInst,ClassName,0,NULL);
+
+ if (!hWnd)
+ return (FALSE);
+
+ MainWnd=hWnd;
+
+ GetStringValue(L"Size", Size, 80);
+ swscanf(Size,L"%d,%d,%d,%d",&Rect.left,&Rect.right,&Rect.top,&Rect.bottom);
+
+ if (Rect.right < 100 || Rect.bottom < 100)
+ {
+ GetWindowRect(hWnd, &Rect);
+ }
+
+ Height = Rect.bottom-Rect.top;
+ Width = Rect.right-Rect.left;
+
+#pragma warning(push)
+#pragma warning(disable:4244)
+ SplitPos=Height*Split;
+#pragma warning(pop)
+
+ SetupRTFHddr();
+
+ // Create a Rich Text Control
+
+ OPData = &OutputData;
+
+ OPData->SendHeader = TRUE;
+ OPData->Finished = TRUE;
+ OPData->CurrentColour = 1;
+
+ LoadLibrary(L"riched20.dll");
+
+ hwndOutput = CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, L"",
+ WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_NOHIDESEL | WS_VSCROLL | ES_READONLY,
+ 6,145,290,130, MainWnd, NULL, hInstance, NULL);
+
+ // Register for Mouse Events for Copy/Paste
+
+ SendMessage(hwndOutput, EM_SETEVENTMASK, (WPARAM)0, (LPARAM)ENM_MOUSEEVENTS | ENM_SCROLLEVENTS | ENM_KEYEVENTS);
+ SendMessage(hwndOutput, EM_EXLIMITTEXT, 0, MAXLINES * LINELEN);
+
+ trayMenu = CreatePopupMenu();
+
+ AppendMenu(trayMenu,MF_STRING,40000,L"Copy");
+
+ // Retrieve the handlse to the edit controls.
+
+ hwndInput = GetDlgItem(hWnd, 118);
+ hwndSplit = GetDlgItem(hWnd, 119);
+ hwndMon = GetDlgItem(hWnd, 116);
+
+ // Set our own WndProcs for the controls.
+
+ wpOrigInputProc = (WNDPROC) SetWindowLongPtr(hwndInput, GWLP_WNDPROC, InputProc);
+ wpOrigMonProc = (WNDPROC)SetWindowLongPtr(hwndMon, GWLP_WNDPROC, MonProc);
+ wpOrigSplitProc = (WNDPROC)SetWindowLongPtr(hwndSplit, GWLP_WNDPROC, SplitProc);
+
+ MoveWindow(hWnd,Rect.left,Rect.top, Rect.right-Rect.left, Rect.bottom-Rect.top, TRUE);
+
+ MoveWindows();
+
+ GetVersionInfo(NULL);
+
+ mbstowcs(VersionStringW, VersionString, 50);
+
+ if (ListenOn)
+ wsprintf(Title,L"BPQTermTCP Version %s Listening for Calls", VersionStringW);
+ else
+ wsprintf(Title,L"BPQTermTCP Version %s", VersionStringW);
+
+ SetWindowText(hWnd,Title);
+
+ hMenu=GetMenu(hWnd);
+
+ hPopMenu1=GetSubMenu(hMenu,4);
+
+ if (ListenOn == 0)
+ {
+ for (i = 1; i <= MonPorts; i++)
+ {
+ wsprintf(msg,L"Port %d",i);
+
+ if (tempmask & (1<<(i-1)))
+ {
+ AppendMenu(hPopMenu1,MF_STRING | MF_CHECKED,BPQBASE + i, &msg[0]);
+ portmask |= ((uint64_t)1<<(i-1));
+ }
+ else
+ AppendMenu(hPopMenu1,MF_STRING | MF_UNCHECKED,BPQBASE + i, &msg[0]);
+ }
+ }
+ CheckMenuItem(hMenu, BPQMTX, (mtxparam) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQBELLS, (Bells) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQStripLF, (StripLF) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQMNODES, (MonitorNODES) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, MONCOLOUR, (MonitorColour) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, CHATTERM, (ChatMode) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQBELLS, (Bells) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQENABLE, (ListenOn) ? MF_CHECKED : MF_UNCHECKED);
+
+ for (i = 0; i < MAXHOSTS; i++)
+ {
+ if (Host[i][0])
+ {
+ ModifyMenu(hMenu, IDC_HOST1 + i, MF_BYCOMMAND, IDC_HOST1 + i, Host[i]);
+ ModifyMenu(hMenu, BPQCONNECT1 + i, MF_BYCOMMAND, BPQCONNECT1 + i, Host[i]);
+ }
+ }
+
+ EnableMenuItem(hMenu,BPQDISCONNECT,MF_GRAYED);
+
+ DrawMenuBar(hWnd);
+
+ DragCursor = LoadCursor(hInstance, L"IDC_DragSize");
+ Cursor = LoadCursor(NULL, IDC_ARROW);
+
+ if ((nCmdShow == SW_SHOWMINIMIZED) || (nCmdShow == SW_SHOWMINNOACTIVE))
+ if (MinimizetoTray)
+ ShowWindow(hWnd, SW_HIDE);
+ else
+ ShowWindow(hWnd, nCmdShow);
+ else
+ ShowWindow(hWnd, nCmdShow);
+
+ UpdateWindow(hWnd);
+
+ GetKeyWordFile(); // Words/Phrases to alert on
+
+ TimerHandle = SetTimer(NULL, 0, 10000, lpTimerFunc);
+
+ return (TRUE);
+}
+
+
+INT_PTR CALLBACK ConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int n;
+
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ SetDlgItemText(hDlg, IDC_HOST, Host[CfgNo]);
+ SetDlgItemInt(hDlg, IDC_PORT, Port[CfgNo], FALSE);
+ SetDlgItemText(hDlg, IDC_USER, UserName[CfgNo]);
+ SetDlgItemText(hDlg, IDC_PASS, Password[CfgNo]);
+
+ return (INT_PTR)TRUE;
+
+ case WM_CTLCOLORDLG:
+ return (LONG)bgBrush;
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+ return (LONG)bgBrush;
+ }
+
+
+ case WM_COMMAND:
+
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+
+ GetDlgItemText(hDlg, IDC_HOST, Host[CfgNo], 99);
+ Port[CfgNo] = GetDlgItemInt(hDlg, IDC_PORT,NULL, FALSE);
+ GetDlgItemText(hDlg, IDC_USER, UserName[CfgNo], 79);
+ GetDlgItemText(hDlg, IDC_PASS, Password[CfgNo], 79);
+
+ ModifyMenu(hMenu, BPQCONNECT1 + CfgNo, MF_BYCOMMAND, BPQCONNECT1 + CfgNo, Host[CfgNo]);
+ ModifyMenu(hMenu, IDC_HOST1 + CfgNo, MF_BYCOMMAND, IDC_HOST1 + CfgNo, Host[CfgNo]);
+
+ for (n = 0; n < MAXHOSTS; n++)
+ {
+ SaveStringValue(HN[n], Host[n]);
+ SaveStringValue(UN[n], UserName[n]);
+ SaveStringValue(PASSN[n], Password[n]);
+ SaveIntValue(PN[n], Port[n]);
+ SaveStringValue(MON[n], MonParams[n]);
+ }
+
+
+ case IDCANCEL:
+
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+
+INT_PTR CALLBACK ListenWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ SetDlgItemInt(hDlg, IDC_LISTENPORT, ListenPort, FALSE);
+
+ return (INT_PTR)TRUE;
+
+ case WM_CTLCOLORDLG:
+ return (LONG)bgBrush;
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+ return (LONG)bgBrush;
+ }
+
+
+ case WM_COMMAND:
+
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+
+ ListenPort = GetDlgItemInt(hDlg, IDC_LISTENPORT,NULL, FALSE);
+
+ SaveIntValue(L"ListenPort", ListenPort);
+
+ case IDCANCEL:
+
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+
+INT_PTR CALLBACK AlertConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ SetDlgItemInt(hDlg, IDC_ALERTINTERVAL, AlertInterval, FALSE);
+ if (AlertBeep)
+ CheckDlgButton(hDlg, IDC_RADIO1, TRUE);
+ else
+ CheckDlgButton(hDlg, IDC_RADIO2, TRUE);
+
+ SetDlgItemInt(hDlg, IDC_FREQ, AlertFreq, FALSE);
+ SetDlgItemInt(hDlg, IDC_DURATION, AlertDuration, FALSE);
+ SetDlgItemText(hDlg, IDC_ALERTFILENAME, &AlertFileName[0]);
+
+ CheckDlgButton(hDlg, IDC_USEKEYWORDS, UseKeywords);
+ SetDlgItemText(hDlg, IDC_ALERTKEYNAME, &KeyWordsName[0]);
+
+ return (INT_PTR)TRUE;
+
+ case WM_CTLCOLORDLG:
+ return (LONG)bgBrush;
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+ return (LONG)bgBrush;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+
+ AlertInterval = GetDlgItemInt(hDlg, IDC_ALERTINTERVAL, NULL, FALSE);
+ AlertBeep = IsDlgButtonChecked(hDlg,IDC_RADIO1);
+ AlertFreq = GetDlgItemInt(hDlg, IDC_FREQ, NULL, FALSE);
+ AlertDuration = GetDlgItemInt(hDlg, IDC_DURATION, NULL, FALSE);
+ UseKeywords = IsDlgButtonChecked(hDlg, IDC_USEKEYWORDS);
+
+ GetDlgItemText(hDlg, IDC_ALERTFILENAME, &AlertFileName[0], MAX_PATH-1 );
+ GetDlgItemText(hDlg, IDC_ALERTKEYNAME, &KeyWordsName[0], MAX_PATH-1 );
+
+ SaveIntValue(L"AlertInterval", AlertInterval);
+ SaveIntValue(L"AlertBeep", AlertBeep);
+ SaveIntValue(L"AlertFreq", AlertFreq);
+ SaveIntValue(L"AlertDuration", AlertDuration);
+
+ SaveIntValue(L"UseKeywords", UseKeywords);
+ SaveStringValue(L"AlertKeyFile", KeyWordsName);
+
+ SaveStringValue(L"AlertFileName", AlertFileName);
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+
+ case IDCANCEL:
+
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+
+
+
+INT_PTR CALLBACK FontConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ POINT Point;
+ int Min, Max;
+
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ if (RXMode == AUTO)
+ CheckDlgButton(hDlg, IDC_AUTO, BST_CHECKED);
+ else if (RXMode == CP1251)
+ CheckDlgButton(hDlg, IDC_1251, BST_CHECKED);
+ else if (RXMode == CP1252)
+ CheckDlgButton(hDlg, IDC_1252, BST_CHECKED);
+ else if (RXMode == CP437)
+ CheckDlgButton(hDlg, IDC_437, BST_CHECKED);
+
+ if (TXMode == CP_UTF8)
+ CheckDlgButton(hDlg, IDC_UTF8, BST_CHECKED);
+ else if (TXMode == CP1251)
+ CheckDlgButton(hDlg, IDC_Send1251, BST_CHECKED);
+ else if (TXMode == CP1252)
+ CheckDlgButton(hDlg, IDC_Send1252, BST_CHECKED);
+
+ SetDlgItemInt(hDlg, IDC_FONTSIZE, FontSize, FALSE);
+ SetDlgItemInt(hDlg, IDC_FONTWIDTH, FontWidth, FALSE);
+
+ return (INT_PTR)TRUE;
+
+ case WM_CTLCOLORDLG:
+ return (LONG)bgBrush;
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+ return (LONG)bgBrush;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+
+// GetDlgItemText(hDlg, IDC_FONTNAME, FontName, 99);
+// CharSet = GetDlgItemInt(hDlg, IDC_CHARSET, NULL, FALSE);
+// CodePage = GetDlgItemInt(hDlg, IDC_CODEPAGE, NULL, FALSE);
+
+ FontSize = GetDlgItemInt(hDlg, IDC_FONTSIZE, NULL, FALSE);
+ FontWidth = GetDlgItemInt(hDlg, IDC_FONTWIDTH, NULL, FALSE);
+
+ if (IsDlgButtonChecked(hDlg, IDC_AUTO))
+ RXMode = AUTO;
+ else if (IsDlgButtonChecked(hDlg, IDC_1251))
+ RXMode = CP1251;
+ else if (IsDlgButtonChecked(hDlg, IDC_1252))
+ RXMode = CP1252;
+ else if (IsDlgButtonChecked(hDlg, IDC_437))
+ RXMode = CP437;
+
+ if (IsDlgButtonChecked(hDlg, IDC_UTF8))
+ TXMode = CP_UTF8;
+ else if (IsDlgButtonChecked(hDlg, IDC_Send1251))
+ TXMode = CP1251;
+ else if (IsDlgButtonChecked(hDlg, IDC_Send1252))
+ TXMode = CP1252;
+
+// SaveStringValue(L"FontName", FontName);
+// SaveIntValue(L"CharSet", CharSet);
+// SaveIntValue(L"CodePage", CodePage);
+ SaveIntValue(L"FontSize", FontSize);
+ SaveIntValue(L"FontWidth", FontWidth);
+ SaveIntValue(L"RXMODE", RXMode);
+ SaveIntValue(L"TXMODE", TXMode);
+
+ OutputData.CharWidth = FontWidth;
+
+ SetupRTFHddr();
+
+ Point.x = 0;
+ Point.y = 25000; // Should be plenty for any font
+
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ OutputData.Scrolled = FALSE;
+
+ GetScrollRange(hwndOutput, SB_VERT, &Min, &Max); // Get Actual Height
+ OutputData.RTFHeight = Max;
+
+ DoRefresh(&OutputData);
+
+ return TRUE;
+
+ case IDCANCEL:
+
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+
+
+//
+// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// PURPOSE: Processes messages for the main window.
+//
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ LPRECT lprc;
+ TCHAR Buffer[1000];
+ TCHAR * buf = Buffer;
+ TEXTMETRIC tm;
+ int y, i;
+ LPMEASUREITEMSTRUCT lpmis;
+ LPDRAWITEMSTRUCT lpdis;
+ OPENFILENAME ofn;
+ WCHAR FN[MAX_PATH] = L"";
+ BROWSEINFO bi;
+ LPITEMIDLIST pidl;
+ char Mess[64];
+
+
+ switch (message)
+ {
+ case WSA_DATA: // Notification on data socket
+
+ Socket_Data(wParam, WSAGETSELECTERROR(lParam), WSAGETSELECTEVENT(lParam));
+ return 0;
+
+ case WSA_ACCEPT: /* Notification if a socket connection is pending. */
+
+ Socket_Accept(wParam, WSAGETSELECTERROR(lParam), WSAGETSELECTEVENT(lParam));
+ return 0;
+
+ case WSA_CONNECT: /* Notification if a socket connection is pending. */
+
+ Telnet_Connected(wParam, WSAGETSELECTERROR(lParam));
+ return 0;
+
+// case WM_CREATE:
+
+// SendMessage(hWndRichEdit, EM_SETEVENTMASK, (WPARAM)0 (LPARAM)ENM_MOUSEEVENTS);
+// break;
+
+
+ case WM_CTLCOLOREDIT:
+
+ if (OutputData.Scrolled)
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetBkMode(hdcStatic, TRANSPARENT);
+
+ return (LONG)GetStockObject(LTGRAY_BRUSH);
+ }
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ case WM_NOTIFY:
+ {
+ const MSGFILTER * pF = (MSGFILTER *)lParam;
+ POINT pos;
+ CHARRANGE Range;
+
+ if(pF->nmhdr.hwndFrom == hwndOutput)
+ {
+ if(pF->msg == WM_VSCROLL)
+ {
+// OutputData.Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+ DoRefresh(&OutputData);
+// return TRUE;
+ }
+
+ if(pF->msg == WM_KEYUP)
+ {
+ if (pF->wParam == VK_PRIOR || pF->wParam == VK_NEXT)
+ {
+// OutputData.Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+ DoRefresh(&OutputData);
+ }
+ }
+
+ if(pF->msg == WM_RBUTTONDOWN)
+ {
+ // Only allow popup if something is selected
+
+ SendMessage(hwndOutput, EM_EXGETSEL , 0, (WPARAM)&Range);
+ if (Range.cpMin == Range.cpMax)
+ return TRUE;
+
+ GetCursorPos(&pos);
+ TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, hWnd, 0);
+ return TRUE;
+ }
+ }
+ break;
+ }
+
+ case WM_MEASUREITEM:
+
+ lpmis = (LPMEASUREITEMSTRUCT) lParam;
+ return TRUE;
+
+ case WM_DRAWITEM:
+
+ lpdis = (LPDRAWITEMSTRUCT) lParam;
+
+ // If there are no list box items, skip this message.
+
+ if (lpdis->itemID == -1)
+ {
+ return TRUE;
+ }
+
+ switch (lpdis->itemAction)
+ {
+ case ODA_SELECT:
+ case ODA_DRAWENTIRE:
+
+ // if Chat Console, and message has a colour eacape, action it
+
+ SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM) Buffer);
+
+ GetTextMetrics(lpdis->hDC, &tm);
+
+ y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
+
+ if (Buffer[0] == 0x1b)
+ {
+ SetTextColor(lpdis->hDC, Colours[Buffer[1] - 10]);
+ buf += 2;
+ }
+// SetBkColor(lpdis->hDC, 0);
+
+ TextOut(lpdis->hDC,
+ 6,
+ y,
+ buf,
+ wcslen(buf));
+
+ // SetTextColor(lpdis->hDC, OldColour);
+
+ break;
+ }
+
+ return TRUE;
+
+ case WM_ACTIVATE:
+
+ SetFocus(hwndInput);
+ break;
+
+
+
+ case WM_COMMAND:
+
+ wmId = LOWORD(wParam); // Remember, these are...
+ wmEvent = HIWORD(wParam); // ...different for Win32!
+
+ //Parse the menu selections:
+
+ if (wmId > BPQBASE && wmId <= BPQBASE + 64)
+ {
+ TogglePort(hWnd,wmId,0x1 << (wmId - (BPQBASE + 1)));
+ break;
+ }
+
+ if (wmId >= BPQCONNECT1 && wmId < BPQCONNECT1 + MAXHOSTS)
+ {
+ CurrentHost = wmId - BPQCONNECT1;
+
+ i = swscanf(MonParams[CurrentHost], L"%llx %x %x %x %x %x",
+ &portmask, &mtxparam, &mcomparam, &MonitorNODES, &MonitorColour, &monUI);
+
+ for (i = 1; i <= MonPorts; i++)
+ {
+ if (portmask & ((uint64_t)1<<(i-1)))
+ CheckMenuItem(hMenu, BPQBASE + i, MF_CHECKED);
+ else
+ CheckMenuItem(hMenu, BPQBASE + i, MF_UNCHECKED);
+
+ }
+
+ CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQMTX, (mtxparam) ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, BPQMNODES, (MonitorNODES) ? MF_CHECKED : MF_UNCHECKED);
+
+
+ TCPConnect(Host[CurrentHost], Port[CurrentHost]);
+ break;
+ }
+
+ if (wmId >= IDC_HOST1 && wmId < IDC_HOST1 + MAXHOSTS)
+ {
+ CfgNo = wmId - IDC_HOST1;
+
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), hWnd, ConfigWndProc);
+ break;
+ }
+
+ switch (wmId)
+ {
+ case BPQPORT:
+
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_LISTEN), hWnd, ListenWndProc);
+ break;
+
+
+ case 40000:
+ {
+ int len=0;
+ HGLOBAL hMem;
+ char * ptr;
+ CHARRANGE Range;
+
+ // Copy Rich Text Selection to Clipboard
+
+ SendMessage(hwndOutput, EM_EXGETSEL , 0, (WPARAM)&Range);
+
+ hMem=GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (Range.cpMax - Range.cpMin + 1) * 2);
+
+ if (hMem != 0)
+ {
+ ptr=GlobalLock(hMem);
+
+ if (OpenClipboard(MainWnd))
+ {
+ len = SendMessage(hwndOutput, EM_GETSELTEXT , 0, (WPARAM)ptr);
+
+ GlobalUnlock(hMem);
+ EmptyClipboard();
+ SetClipboardData(CF_UNICODETEXT,hMem);
+ CloseClipboard();
+ }
+ }
+ else
+ GlobalFree(hMem);
+
+ SetFocus(hwndInput);
+ return TRUE;
+ }
+
+ case BPQMTX:
+
+ ToggleMTX(hWnd);
+ break;
+
+ case BPQMCOM:
+
+ ToggleMCOM(hWnd);
+ break;
+
+ case MUIONLY:
+
+ ToggleMUI(hWnd);
+ break;
+
+ case BPQDISCONNECT:
+
+ if (Disconnecting)
+ {
+ // Force close
+
+ if (SocketActive)
+ closesocket(sock);
+
+ wsprintf(Title, L"BPQTermTCP Version %s - Disconnected", VersionStringW);
+ SetWindowText(hWnd,Title);
+ DisableDisconnectMenu(hWnd);
+ DisableYAPPMenu(hWnd);
+ EnableConnectMenu(hWnd);
+
+ WritetoOutputWindow(&OutputData , L"*** Disconnected\r", 17);
+ DoRefresh(&OutputData);
+ SocketActive = FALSE;
+ Connected = FALSE;
+ Disconnecting = FALSE;
+ InputMode = 0;
+
+ break;
+ }
+
+ shutdown(sock, 2); // SD_BOTH
+ Disconnecting = TRUE;
+ break;
+
+ case BPQBELLS:
+
+ ToggleParam(hWnd, &Bells, BPQBELLS);
+ break;
+
+ case BPQENABLE:
+
+ ToggleParam(hWnd, &ListenOn, BPQENABLE);
+ if (ListenOn)
+ {
+ DisableConnectMenu(hWnd);
+ ListenSock = OpenListenSocket4(ListenPort);
+ }
+ else
+ {
+ EnableConnectMenu(hWnd);
+ closesocket(ListenSock);
+ }
+
+ break;
+
+
+ case BPQStripLF:
+
+ ToggleParam(hWnd, &StripLF, BPQStripLF);
+ break;
+
+ case BPQLogOutput:
+
+ ToggleParam(hWnd, &LogOutput, BPQLogOutput);
+ break;
+
+ case CHATTERM:
+
+ ToggleParam(hWnd, &ChatMode, CHATTERM);
+ break;
+
+
+ case ID_SETUP_FONT:
+
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_FONT), hWnd, FontConfigWndProc);
+ break;
+
+ case ID_SETUP_ALERTSETUP:
+
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_ALERTDLG), hWnd, AlertConfigWndProc);
+ break;
+
+ case BPQMNODES:
+
+ ToggleParam(hWnd, &MonitorNODES, BPQMNODES);
+ SendTraceOptions();
+ break;
+
+
+ case MONITOR_ADDPORT:
+
+ wsprintf(Buffer, L"Port %d", ++MonPorts);
+
+ AppendMenu(hPopMenu1,MF_STRING | MF_UNCHECKED,BPQBASE + MonPorts, Buffer);
+
+
+ case MONCOLOUR:
+
+ ToggleParam(hWnd, &MonitorColour, MONCOLOUR);
+ SendTraceOptions();
+ break;
+
+ case BPQLogMonitor:
+
+ ToggleParam(hWnd, &LogMonitor, BPQLogMonitor);
+ break;
+
+ case BPQCLEARMON:
+
+ SendMessage(hwndMon,LB_RESETCONTENT, 0, 0);
+ break;
+
+ case BPQCLEAROUT:
+
+ for (i = 0; i < MAXLINES; i++)
+ {
+ OutputData.OutputScreen[i][0] = 0;
+ }
+
+ OutputData.CurrentLine = 0;
+ DoRefresh(&OutputData);
+ break;
+
+ case BPQCOPYMON:
+
+ CopyListToClipboard(hwndMon);
+ break;
+
+ case BPQCOPYOUT:
+
+ CopyRichTextToClipboard(hwndOutput);
+ break;
+
+ case BPQHELP:
+
+// HtmlHelp(hWnd,"BPQTerminal.chm",HH_HELP_FINDER,0);
+ break;
+
+ case YAPPSEND:
+
+ memset(&ofn, 0, sizeof (OPENFILENAME));
+ ofn.lStructSize = sizeof (OPENFILENAME);
+ ofn.hwndOwner = hWnd;
+ ofn.lpstrFile = FN;
+ ofn.nMaxFile = 250;
+ ofn.lpstrTitle = L"File to send";
+// ofn.lpstrInitialDir = BPQDirectory;
+
+ // Turn off monitoring
+
+ len = sprintf(Mess, "\\\\\\\\%x %x %x %x %x %x %x %x\r", 0, 0, 0, 0, 0, 0, 0, 0);
+ send(sock, Mess, len, 0);
+
+
+ if (GetOpenFileName(&ofn))
+ YAPPSendFile(FN);
+ else
+ SendTraceOptions();
+ break;
+
+
+ case YAPPDIR:
+
+ memset(&bi, 0, sizeof (BROWSEINFO));
+
+ bi.hwndOwner = NULL;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = FN;
+ bi.lpszTitle = L"Please select a folder for storing received files";
+ bi.ulFlags = BIF_RETURNONLYFSDIRS;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ pidl = SHBrowseForFolder(&bi);
+
+ if (pidl)
+ {
+ SHGetPathFromIDList(pidl, YAPPPath);
+ wcscat(YAPPPath, L"\\");
+ SaveStringValue(L"YAPPPath", YAPPPath);
+ }
+
+ break;
+
+
+
+ default:
+
+ return 0;
+
+ }
+
+ case WM_SYSCOMMAND:
+
+ wmId = LOWORD(wParam); // Remember, these are...
+ wmEvent = HIWORD(wParam); // ...different for Win32!
+
+ switch (wmId) {
+
+ case SC_RESTORE:
+
+ case SC_MINIMIZE:
+
+ default:
+
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+ }
+
+ case WM_SIZE:
+
+ MoveWindows();
+
+ return TRUE;
+
+ case WM_SIZING:
+
+ lprc = (LPRECT) lParam;
+
+ Height = lprc->bottom-lprc->top;
+ Width = lprc->right-lprc->left;
+
+#pragma warning(push)
+#pragma warning(disable:4244)
+ SplitPos=Height*Split;
+#pragma warning(pop)
+
+ MoveWindows();
+
+ return TRUE;
+
+
+ case WM_DESTROY:
+
+ // Remove the subclass from the edit control.
+
+ GetWindowRect(hWnd, &Rect); // For save soutine
+
+ SetWindowLong(hwndInput, -4,
+ (LONG) wpOrigInputProc);
+
+ PostQuitMessage(0);
+
+
+ break;
+
+ default:
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ }
+ return (0);
+}
+
+static TCHAR * KbdStack[20];
+
+int StackIndex=0;
+
+LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ TCHAR DisplayLine[250] = L"";
+
+ if (uMsg == WM_CTLCOLOREDIT)
+ {
+ HBRUSH Brush = CreateSolidBrush(RGB(0, 255, 0));
+ HDC hdcStatic = (HDC)wParam;
+ SetTextColor(hdcStatic, RGB(0, 0, 0));
+ SetBkMode(hdcStatic, TRANSPARENT);
+
+ return (LONG)Brush;
+ }
+
+
+ if (uMsg == WM_KEYUP)
+ {
+ unsigned int i;
+
+// Debugprintf("5%x", LOBYTE(HIWORD(lParam)));
+
+ if (LOBYTE(HIWORD(lParam)) == 0x48 && wParam == 0x26)
+ {
+ // Scroll up
+
+ if (KbdStack[StackIndex] == NULL)
+ return TRUE;
+
+ SendMessage(hwndInput, WM_SETTEXT,0,(LPARAM)(LPCSTR) KbdStack[StackIndex]);
+
+ for (i = 0; i < wcslen(KbdStack[StackIndex]); i++)
+ {
+ SendMessage(hwndInput, WM_KEYDOWN, VK_RIGHT, 0);
+ SendMessage(hwndInput, WM_KEYUP, VK_RIGHT, 0);
+ }
+
+ StackIndex++;
+ if (StackIndex == 20)
+ StackIndex = 19;
+
+ return TRUE;
+ }
+
+ if (LOBYTE(HIWORD(lParam)) == 0x50 && wParam == 0x28)
+ {
+ // Scroll up
+
+ StackIndex--;
+ if (StackIndex < 0)
+ StackIndex = 0;
+
+ if (KbdStack[StackIndex] == NULL)
+ return TRUE;
+
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) KbdStack[StackIndex]);
+
+ for (i = 0; i < wcslen(KbdStack[StackIndex]); i++)
+ {
+ SendMessage(hwndInput, WM_KEYDOWN, VK_RIGHT, 0);
+ SendMessage(hwndInput, WM_KEYUP, VK_RIGHT, 0);
+ }
+
+ return TRUE;
+ }
+ }
+
+ if (uMsg == WM_CHAR)
+ {
+ if (wParam == 13)
+ {
+ int i;
+
+ if (!Connected && ! Connecting)
+ {
+ TCPConnect(Host[CurrentHost], Port[CurrentHost]);
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) L"");
+ return 0;
+ }
+
+ kbptr=SendMessage(hwndInput,WM_GETTEXT,199,(LPARAM) (LPCSTR) kbbuf);
+
+ // Stack it
+
+ StackIndex = 0;
+
+ if (KbdStack[19])
+ free(KbdStack[19]);
+
+ for (i = 18; i >= 0; i--)
+ {
+ KbdStack[i+1] = KbdStack[i];
+ }
+
+ KbdStack[0] = _wcsdup(kbbuf);
+
+ kbbuf[kbptr]=13;
+
+ SlowTimer = 0;
+
+ // Echo, with set Black escape
+
+ DisplayLine[0] = 0x1b;
+ DisplayLine[1] = 0x21;
+
+ memcpy(&DisplayLine[2], kbbuf, (kbptr+1) * 2);
+
+ if (OutputData.Scrolled)
+ {
+ POINT Point;
+ Point.x = 0;
+ Point.y = 25000; // Should be plenty for any font
+
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ OutputData.Scrolled = FALSE;
+ }
+
+ LastWrite = time(NULL);
+
+ WritetoOutputWindow(&OutputData, DisplayLine, kbptr+3);
+ DoRefresh(&OutputData);
+
+ // Replace null with CR, and send to Node
+
+ SendMsg(&kbbuf[0], kbptr+1);
+
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) L"");
+
+ return 0;
+ }
+ if (wParam == 0x1a) // Ctrl/Z
+ {
+ kbbuf[0]=0x1a;
+ kbbuf[1]=13;
+
+ SendMsg(&kbbuf[0], 2);
+
+ SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) L"");
+
+ return 0;
+ }
+ }
+ return CallWindowProc(wpOrigInputProc, hwnd, uMsg, wParam, lParam);
+}
+
+//int FirstItem=-1, LastItem=-1, SELECTING=FALSE, MOVED=FALSE, LastSelected=0;
+
+LRESULT APIENTRY MonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
+ return TRUE;
+
+ return CallWindowProc(wpOrigMonProc, hwnd, uMsg, wParam, lParam);
+}
+
+LRESULT APIENTRY SplitProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ int xPos, yPos;
+
+ switch (uMsg) {
+
+ case WM_LBUTTONDOWN:
+
+ SetCapture(hwnd);
+ return 0;
+
+ case WM_LBUTTONUP:
+
+ xPos = LOWORD(lParam); // horizontal position of cursor
+ yPos = lParam >> 16; // vertical position of cursor
+
+ SplitPos = SplitPos + yPos - 5;
+
+ if (SplitPos < 0) SplitPos = 0;
+
+ Split=SplitPos;
+ Split=Split/Height;
+
+ ReleaseCapture();
+ MoveWindows();
+ DoRefresh(&OutputData);
+ return 0;
+
+ case WM_MOUSEMOVE:
+
+ // Used to size split between Monitor and Output Windows
+
+ SetCursor(DragCursor);
+ break;
+ }
+
+ return CallWindowProc(wpOrigSplitProc, hwnd, uMsg, wParam, lParam);
+}
+
+VOID wcstoRTF(char * out, TCHAR * in)
+{
+ TCHAR * ptr1 = in;
+ char * ptr2 = out;
+ int val = *ptr1++;
+
+ while (val)
+ {
+ {
+ if (val > 127 || val < -128 )
+ ptr2 += sprintf(ptr2, "\\u%d ", val);
+ else
+ *(ptr2++) = val;
+ }
+ val = *ptr1++;
+ }
+ *ptr2 = 0;
+}
+
+DWORD CALLBACK EditStreamCallback(DWORD_PTR Cookie, unsigned char * lpBuff, LONG cb, PLONG pcb)
+{
+ struct RTFTerm * OPData = (struct RTFTerm *)Cookie;
+ int ReqLen = cb;
+ int i;
+ int Line;
+ char LineB[20000];
+
+// if (cb != 4092)
+// return 0;
+
+ if (OPData->SendHeader)
+ {
+ // Return header
+
+ memcpy(lpBuff, RTFHeader, RTFHddrLen);
+ *pcb = RTFHddrLen;
+ OPData->SendHeader = FALSE;
+ OPData->Finished = FALSE;
+ OPData->Index = 0;
+ return 0;
+ }
+
+ if (OPData->Finished)
+ {
+ *pcb = 0;
+ return 0;
+ }
+
+/*
+ if (BufferLen > cb)
+ {
+ memcpy(lpBuff, &Buffer[Offset], cb);
+ BufferLen -= cb;
+ Offset += cb;
+ *pcb = cb;
+ return 0;
+ }
+
+ memcpy(lpBuff, &Buffer[Offset], BufferLen);
+
+ *pcb = BufferLen;
+*/
+
+ // Return 10 line at a time
+
+ for (i = 0; i < 10; i++);
+ {
+ Line = OPData->Index++ + OPData->CurrentLine - MAXLINES;
+
+ if (Line <0)
+ Line = Line + MAXLINES;
+
+ wcstoRTF(LineB, OPData->OutputScreen[Line]);
+
+ sprintf(lpBuff, "\\cf%d ", OPData->Colourvalue[Line]);
+ strcat(lpBuff, LineB);
+ strcat(lpBuff, "\\line");
+
+ if (OPData->Index == MAXLINES)
+ {
+ OPData->Finished = TRUE;
+ strcat(lpBuff, "}");
+ i = 10;
+ }
+ }
+ *pcb = strlen(lpBuff);
+ return 0;
+}
+
+VOID ForceRefresh(struct RTFTerm * OPData)
+{
+ OPData->Thumb = 25000;
+ DoRefresh(OPData);
+ OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+}
+
+VOID DoRefresh(struct RTFTerm * OPData)
+{
+ EDITSTREAM es = {0};
+ int Min, Max, Pos;
+ POINT Point;
+ SCROLLINFO ScrollInfo;
+ int LoopTrap = 0;
+
+ if(WINE)
+ OPData->Thumb = 30000;
+ else
+ OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+
+ Pos = OPData->Thumb + OutputBoxHeight;
+
+ if (Pos > OPData->RTFHeight - 10) // Don't bother writing to screen if scrolled back
+ {
+ es.pfnCallback = EditStreamCallback;
+ es.dwCookie = (DWORD_PTR)OPData;
+ OPData->SendHeader = TRUE;
+ SendMessage(hwndOutput, EM_STREAMIN, SF_RTF, (LPARAM)&es);
+ }
+// else
+// Debugprintf("Pos %d RTFHeight %d - Not refreshing", Pos, OPData->RTFHeight);
+
+ GetScrollRange(hwndOutput, SB_VERT, &Min, &Max);
+ ScrollInfo.cbSize = sizeof(ScrollInfo);
+ ScrollInfo.fMask = SIF_ALL;
+
+ GetScrollInfo(hwndOutput, SB_VERT, &ScrollInfo);
+
+// Debugprintf("Thumb %d Pos %d Min %d Max %d nMax %d ClientH %d RTFHeight %d",
+// OPData->Thumb, Pos, Min, Max, ScrollInfo.nMax, OutputBoxHeight, OPData->RTFHeight);
+
+ if (OPData->FirstTime == FALSE)
+ {
+ // RTF Controls don't immediately scroll to end - don't know why.
+
+ OPData->FirstTime = TRUE;
+ Point.x = 0;
+ Point.y = 25000; // Should be plenty for any font
+
+ while (LoopTrap++ < 20)
+ {
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ }
+
+ GetScrollRange(hwndOutput, SB_VERT, &Min, &Max); // Get Actual Height
+ OPData->RTFHeight = Max;
+ Point.x = 0;
+ Point.y = OPData->RTFHeight - ScrollInfo.nPage;
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0);
+ }
+
+ Point.x = 0;
+ Point.y = OPData->RTFHeight - ScrollInfo.nPage;
+
+ if (OPData->Thumb > (Point.y - 10)) // Don't Scroll if user has scrolled back
+ {
+// Debugprintf("Scrolling to %d", Point.y);
+ SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point);
+ if (OPData->Scrolled)
+ {
+ OPData->Scrolled = FALSE;
+ InvalidateRect(hwndInput, NULL, TRUE);
+ }
+ return;
+ }
+
+// Debugprintf("Thumb = %d Point.y = %d - Not Scrolling", OPData->Thumb, Point.y);
+
+ if (!OPData->Scrolled)
+ {
+ OPData->Scrolled = TRUE;
+ InvalidateRect(hwndInput, NULL, TRUE);
+ }
+}
+
+VOID AddLinetoWindow(struct RTFTerm * OPData, TCHAR * Line)
+{
+ int Len = wcslen(Line);
+ TCHAR * ptr1 = Line;
+ TCHAR * ptr2;
+ int l, Index;
+ TCHAR LineCopy[LINELEN * 2];
+
+ if (Line[0] == 0x1b && Len > 1)
+ {
+ // Save Colour Char
+
+ OPData->CurrentColour = Line[1] - 10;
+ ptr1 +=2;
+ Len -= 2;
+ }
+
+ wcscpy(OPData->OutputScreen[OPData->CurrentLine], ptr1);
+
+ // Look for chars we need to escape (\ { })
+
+ ptr1 = OPData->OutputScreen[OPData->CurrentLine];
+ Index = 0;
+ ptr2 = wcschr(ptr1, L'\\'); // Look for Backslash first, as we may add some later
+
+ if (ptr2)
+ {
+ while (ptr2)
+ {
+ l = ++ptr2 - ptr1;
+ memcpy(&LineCopy[Index], ptr1, l * 2); // Copy Including found char (\)
+ Index += l;
+ LineCopy[Index++] = L'\\'; // Add second \
+ Len++;
+ ptr1 = ptr2;
+ ptr2 = wcschr(ptr1, L'\\');
+ }
+
+ wcscpy(&LineCopy[Index], ptr1); // Copy in rest
+ wcscpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy);
+ }
+
+ ptr1 = OPData->OutputScreen[OPData->CurrentLine];
+ Index = 0;
+ ptr2 = wcschr(ptr1, L'{');
+
+ if (ptr2)
+ {
+ while (ptr2)
+ {
+ l = ptr2 - ptr1;
+ memcpy(&LineCopy[Index], ptr1, l * 2);
+ Index += l;
+ LineCopy[Index++] = L'\\';
+ LineCopy[Index++] = L'{';
+ Len++;
+ ptr1 = ++ptr2;
+ ptr2 = wcschr(ptr1, L'{');
+ }
+ wcscpy(&LineCopy[Index], ptr1); // Copy in rest
+ wcscpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy);
+ }
+
+ ptr1 = OPData->OutputScreen[OPData->CurrentLine];
+ Index = 0;
+ ptr2 = wcschr(ptr1, '}'); // Look for Backslash first, as we may add some later
+
+ if (ptr2)
+ {
+ while (ptr2)
+ {
+ l = ptr2 - ptr1;
+ memcpy(&LineCopy[Index], ptr1, l * 2); // Copy
+ Index += l;
+ LineCopy[Index++] = L'\\';
+ LineCopy[Index++] = L'}';
+ Len++;
+ ptr1 = ++ptr2;
+ ptr2 = wcschr(ptr1, L'}');
+ }
+ wcscpy(&LineCopy[Index], ptr1); // Copy in rest
+ wcscpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy);
+ }
+
+
+ OPData->Colourvalue[OPData->CurrentLine] = OPData->CurrentColour;
+ OPData->LineLen[OPData->CurrentLine++] = Len;
+ if (OPData->CurrentLine >= MAXLINES) OPData->CurrentLine = 0;
+}
+
+VOID WritetoOutputWindow(struct RTFTerm * OPData, TCHAR * Msg, int len)
+{
+ time_t NOW = time(NULL);
+ TCHAR * ptr1, * ptr2;
+
+ if (AlertInterval && (NOW - LastWrite) > AlertInterval)
+ {
+ if (AlertBeep)
+ Beep(AlertFreq, AlertDuration);
+ else
+ PlaySound(AlertFileName, NULL, SND_FILENAME | SND_ASYNC);
+ }
+
+
+ LastWrite = NOW;
+
+ if (PartLinePtr != 0)
+ {
+ OPData->CurrentLine--; // Overwrite part line in buffer
+ if (OPData->CurrentLine < 0)
+ OPData->CurrentLine = MAXLINES - 1;
+
+ if (Msg[0] == 0x1b && len > 1)
+ {
+ Msg += 2; // Remove Colour Escape
+ len -= 2;
+ }
+ }
+
+ memcpy(&readbuff[PartLinePtr], Msg, len * 2);
+
+ len += PartLinePtr;
+
+ ptr1=&readbuff[0];
+ readbuff[len]=0;
+
+ if (Bells)
+ {
+ do {
+ ptr2 = wmemchr(ptr1,7,len);
+
+ if (ptr2)
+ {
+ *(ptr2)=32;
+ Beep(440,250);
+ }
+ } while (ptr2);
+ }
+
+lineloop:
+
+ if (len > 0)
+ {
+ // copy text to buffer a line at a time
+
+ ptr2=wmemchr(ptr1, 13, len);
+
+ if (ptr2 == 0)
+ {
+ // no newline. Move data to start of buffer and Save pointer
+
+ while (len > LINELEN)
+ {
+ // Break up
+
+ TCHAR * partptr = ptr1 + LINELEN;
+ TCHAR Save = *partptr;
+ *ptr1 = 0;
+ AddLinetoWindow(OPData, ptr1);
+ *partptr = Save;
+ ptr1 = partptr;
+ len -= LINELEN;
+ }
+
+ PartLinePtr = len;
+ memmove(readbuff, ptr1, len * 2);
+ AddLinetoWindow(OPData, ptr1);
+ return;
+ }
+
+ *(ptr2++)=0;
+
+ if (LogOutput) WriteMonitorLine(ptr1, ptr2 - ptr1);
+
+ // If len is greater that screen with, fold
+
+ if ((ptr2 - ptr1) > maxlinelen)
+ {
+ TCHAR * ptr3;
+ TCHAR * saveptr1 = ptr1;
+ int linelen = ptr2 - ptr1;
+ int foldlen;
+ TCHAR save;
+
+ foldloop:
+
+ ptr3 = ptr1 + maxlinelen;
+
+ while(*ptr3!= 0x20 && ptr3 > ptr1)
+ {
+ ptr3--;
+ }
+ foldlen = ptr3 - ptr1 ;
+
+ if (foldlen == 0)
+ {
+ // No space before, so split at width
+
+ foldlen = maxlinelen;
+ ptr3 = ptr1 + maxlinelen;
+
+ }
+ else
+ {
+ ptr3++ ; // Omit space
+ linelen--;
+ }
+ save = ptr1[foldlen];
+ ptr1[foldlen] = 0;
+
+ AddLinetoWindow(OPData, ptr1);
+
+ ptr1[foldlen] = save;
+ linelen -= foldlen;
+ ptr1 = ptr3;
+
+ if (linelen > maxlinelen)
+ goto foldloop;
+
+ AddLinetoWindow(OPData, ptr1);
+ ptr1 = saveptr1;
+
+ }
+ else
+ AddLinetoWindow(OPData, ptr1);
+
+
+ PartLinePtr=0;
+
+ len-=(ptr2-ptr1);
+
+ ptr1=ptr2;
+
+ if ((len > 0) && StripLF)
+ {
+ if (*ptr1 == 0x0a) // Line Feed
+ {
+ ptr1++;
+ len--;
+ }
+ }
+ goto lineloop;
+ }
+}
+
+
+
+TCHAR MonSave[2000];
+int MonSaveLen;
+
+VOID WritetoMonWindow(TCHAR * Msg, int len)
+{
+ TCHAR * ptr1 = Msg, * ptr2;
+ int index;
+
+ if (MonSaveLen)
+ {
+ // Have part line - append to it
+ memcpy(&MonSave[MonSaveLen], Msg, len * 2);
+ MonSaveLen += len;
+ ptr1 = MonSave;
+ len = MonSaveLen;
+ MonSaveLen = 0;
+ }
+
+lineloop:
+
+ if (len <= 0)
+ return;
+
+ // copy text to control a line at a time
+
+ ptr2 = wmemchr(ptr1,13,len);
+
+ if (ptr2 == 0) // No CR
+ {
+ memmove(MonSave, ptr1, len * 2);
+ MonSaveLen = len;
+ return;
+ }
+
+ *(ptr2++) = 0;
+
+ index = SendMessage(hwndMon, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) ptr1 );
+
+ if (LogMonitor) WriteMonitorLine(ptr1, ptr2 - ptr1);
+
+ if (index > 1200)
+ do {index=SendMessage(hwndMon,LB_DELETESTRING, 0, 0);} while (index > 1000);
+
+ SendMessage(hwndMon,LB_SETCARETINDEX,(WPARAM) index, MAKELPARAM(FALSE, 0));
+
+ len -= (ptr2 - ptr1);
+ ptr1 = ptr2;
+
+ goto lineloop;
+}
+
+VOID DisableConnectMenu(HWND hWnd)
+{
+ int n;
+
+ for (n = 0; n < MAXHOSTS; n++)
+ EnableMenuItem(GetMenu(hWnd), BPQCONNECT1 + n, MF_GRAYED);
+
+ DrawMenuBar(hWnd);
+}
+
+VOID DisableDisconnectMenu(HWND hWnd)
+{
+ EnableMenuItem(GetMenu(hWnd), BPQDISCONNECT, MF_GRAYED);
+ DrawMenuBar(hWnd);
+}
+
+VOID DisableYAPPMenu(HWND hWnd)
+{
+ EnableMenuItem(GetMenu(hWnd), YAPPSEND, MF_GRAYED);
+ DrawMenuBar(hWnd);
+}
+
+VOID EnableYAPPMenu(HWND hWnd)
+{
+ EnableMenuItem(GetMenu(hWnd), YAPPSEND, MF_ENABLED);
+ DrawMenuBar(hWnd);
+}
+
+
+
+VOID EnableConnectMenu(HWND hWnd)
+{
+ HMENU hMenu; // handle of menu
+ int n;
+
+ hMenu=GetMenu(hWnd);
+
+ for (n = 0; n < MAXHOSTS; n++)
+ EnableMenuItem(hMenu, BPQCONNECT1 + n, MF_ENABLED);
+
+ DrawMenuBar(hWnd);
+}
+
+VOID EnableDisconnectMenu(HWND hWnd)
+{
+ EnableMenuItem(GetMenu(hWnd), BPQDISCONNECT, MF_ENABLED);
+ DrawMenuBar(hWnd);
+}
+
+
+int TogglePort(HWND hWnd, int Item, int mask)
+{
+ portmask ^= mask;
+
+ if (portmask & mask)
+ CheckMenuItem(hMenu,Item,MF_CHECKED);
+ else
+ CheckMenuItem(hMenu,Item,MF_UNCHECKED);
+
+ SendTraceOptions();
+
+ return (0);
+
+}
+int ToggleMTX(HWND hWnd)
+{
+ mtxparam = mtxparam ^ 1;
+ CheckMenuItem(hMenu, BPQMTX, (mtxparam) ? MF_CHECKED : MF_UNCHECKED);
+ SendTraceOptions();
+
+ return (0);
+
+}
+int ToggleMCOM(HWND hWnd)
+{
+ mcomparam = mcomparam ^ 1;
+ CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED);
+ SendTraceOptions();
+
+ return (0);
+
+}
+int ToggleMUI(HWND hWnd)
+{
+ monUI = monUI ^ 1;
+ CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED);
+ SendTraceOptions();
+
+ return (0);
+
+}
+int ToggleParam(HWND hWnd, BOOL * Param, int Item)
+{
+ *Param = !(*Param);
+
+ CheckMenuItem(hMenu,Item, (*Param) ? MF_CHECKED : MF_UNCHECKED);
+
+ return (0);
+}
+
+void MoveWindows()
+{
+ RECT rcMain, rcClient;
+ int ClientHeight, ClientWidth;
+
+ GetWindowRect(hWnd, &rcMain);
+ GetClientRect(hWnd, &rcClient);
+
+ ClientHeight = rcClient.bottom;
+ ClientWidth = rcClient.right;
+
+ if (ClientWidth == 0) // Minimized
+ return;
+
+ OutputBoxHeight = ClientHeight - SplitPos - InputBoxHeight - SplitBarHeight - SplitBarHeight;
+
+ MoveWindow(hwndMon,2, 0, ClientWidth-4, SplitPos, TRUE);
+ MoveWindow(hwndOutput,2, SplitPos+SplitBarHeight, ClientWidth-4, OutputBoxHeight, TRUE);
+ MoveWindow(hwndInput,2, ClientHeight-InputBoxHeight-2, ClientWidth-4, InputBoxHeight, TRUE);
+ MoveWindow(hwndSplit,0, SplitPos, ClientWidth, SplitBarHeight, TRUE);
+
+ GetClientRect(hwndOutput, &rcClient);
+
+ ClientHeight = rcClient.bottom;
+ ClientWidth = rcClient.right;
+
+ if (ClientWidth > 16)
+ maxlinelen = ClientWidth/OutputData.CharWidth - 1;
+
+ InvalidateRect(hWnd, NULL, TRUE);
+}
+
+void CopyRichTextToClipboard(HWND hWnd)
+{
+ int len=0;
+ HGLOBAL hMem;
+ char * ptr;
+
+ // Copy Rich Text to Clipboard
+
+ len = SendMessage(hwndOutput, WM_GETTEXTLENGTH, 0, 0);
+
+ hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1)*2);
+
+ if (hMem != 0)
+ {
+ ptr=GlobalLock(hMem);
+
+ if (OpenClipboard(MainWnd))
+ {
+ len = SendMessage(hwndOutput, WM_GETTEXT , len, (LPARAM)ptr);
+
+ GlobalUnlock(hMem);
+ EmptyClipboard();
+ SetClipboardData(CF_UNICODETEXT,hMem);
+ CloseClipboard();
+ }
+ }
+ else
+ GlobalFree(hMem);
+}
+
+
+void CopyListToClipboard(HWND hWnd)
+{
+ int i,n, len=0;
+ HGLOBAL hMem;
+ char * ptr;
+ //
+ // Copy List Box to clipboard
+ //
+
+ n = SendMessage(hWnd, LB_GETCOUNT, 0, 0);
+
+ for (i=0; i<n; i++)
+ {
+ len+=SendMessage(hWnd, LB_GETTEXTLEN, i, 0);
+ }
+
+ hMem=GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len+n+n+1)*2);
+
+
+ if (hMem != 0)
+ {
+ ptr=GlobalLock(hMem);
+
+ if (OpenClipboard(MainWnd))
+ {
+ // CopyScreentoBuffer(GlobalLock(hMem));
+
+ for (i=0; i<n; i++)
+ {
+ len=SendMessage(hWnd, LB_GETTEXT, i, (LPARAM) ptr);
+ ptr += len;
+ ptr += len; // 2 bytes per char
+ *(ptr++)=13;
+ *(ptr++)=0;
+ *(ptr++)=10;
+ *(ptr++)=0;
+ }
+
+ *(ptr)=0; // end of data
+
+ GlobalUnlock(hMem);
+ EmptyClipboard();
+ SetClipboardData(CF_UNICODETEXT,hMem);
+ CloseClipboard();
+ }
+ else
+ GlobalFree(hMem);
+ }
+}
+
+BOOL OpenMonitorLogfile()
+{
+ TCHAR FN[MAX_PATH];
+
+ wsprintf(FN,L"BPQTerm_%d.log", Stream);
+
+ MonHandle = CreateFile(FN,
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ SetFilePointer(MonHandle, 0, 0, FILE_END);
+
+ return (MonHandle != INVALID_HANDLE_VALUE);
+}
+
+void WriteMonitorLine(TCHAR * Msg, int MsgLen)
+{
+ int cnt;
+ char CRLF[2] = {0x0d,0x0a};
+ unsigned char MsgB[1000];
+
+ if (MonHandle == INVALID_HANDLE_VALUE) OpenMonitorLogfile();
+
+ if (MonHandle == INVALID_HANDLE_VALUE) return;
+
+ MsgLen = WideCharToMultiByte(TXMode, 0, Msg, MsgLen, MsgB, 1000, NULL, NULL);
+
+ WriteFile(MonHandle ,MsgB , MsgLen, &cnt, NULL);
+ WriteFile(MonHandle ,CRLF , 2, &cnt, NULL);
+}
+
+// TCP Interface
+
+TCPConnect(TCHAR * Host, int Port)
+{
+ int err, status;
+ u_long param=1;
+ UCHAR bcopt = 1;
+ int optlen = 1;
+ SOCKADDR_IN sinx;
+
+ int addrlen=sizeof(sinx);
+ char PortString[10];
+ char HostB[256];
+ struct addrinfo hints, *res;
+ BOOL UseV6 = FALSE;
+
+
+ wcstombs(HostB, Host, 256);
+ sprintf(PortString, "%d", Port);
+
+ if (_memicmp(HostB, "ipv6:", 5) == 0)
+ UseV6 = TRUE;
+
+ // get host info, make socket, and connect it
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_socktype = SOCK_STREAM;
+
+ if (UseV6)
+ {
+ hints.ai_family = AF_INET6; // use IPv6
+ getaddrinfo(&HostB[5], PortString, &hints, &res);
+ }
+ else
+ {
+ hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever
+ getaddrinfo(HostB, PortString, &hints, &res);
+ }
+
+ if (!res)
+ {
+ MessageBox(NULL, L"Resolve HostName Failed", L"BPQTermTCP", MB_OK);
+ wsprintf(Title, L"BPQTermTCP Version %s - Disconnected", VersionStringW);
+ SetWindowText(hWnd,Title);
+
+ return FALSE; // Resolve failed
+ }
+
+ sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+
+ WSAAsyncSelect(sock, hWnd, WSA_DATA,
+ FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE);
+
+/*
+
+ // Resolve Name if needed
+
+ destaddr.sin_family = AF_INET;
+ destaddr.sin_port = htons(Port);
+ destaddr.sin_addr.s_addr = inet_addr(Host);
+
+ if (destaddr.sin_addr.s_addr == INADDR_NONE)
+ {
+ struct hostent * HostEnt;
+
+ // Resolve name to address
+
+ wsprintf(Title,"BPQTermTCP Version %s - Resolving %s", VersionString, Host);
+ SetWindowText(hWnd,Title);
+
+ HostEnt = gethostbyname(Host);
+
+ if (!HostEnt)
+ {
+ MessageBox(NULL, "Resolve HostName Failed", "BPQTermTCP", MB_OK);
+ wsprintf(Title,"BPQTermTCP Version %s - Disconnected", VersionString);
+ SetWindowText(hWnd,Title);
+
+ return FALSE; // Resolve failed
+ }
+
+ i = 0;
+
+ memcpy(&destaddr.sin_addr.s_addr, HostEnt->h_addr, 4);
+ }
+
+ ioctlsocket (sock, FIONBIO, &param);
+
+ setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (const char FAR *)&bcopt,4);
+
+ sinx.sin_family = AF_INET;
+ sinx.sin_addr.s_addr = INADDR_ANY;
+ sinx.sin_port = 0;
+
+ if (bind(sock, (LPSOCKADDR) &sinx, addrlen) != 0 )
+ {
+ MessageBox(NULL, "Bind Failed", "BPQTermTCP", MB_OK);
+ return FALSE;
+ }
+*/
+ if ((status = WSAAsyncSelect(sock, hWnd, WSA_CONNECT, FD_CONNECT)) > 0)
+ {
+ closesocket(sock);
+ return FALSE;
+ }
+
+ if (connect(sock, res->ai_addr, res->ai_addrlen) == 0)
+ {
+ //
+ // Connected successful
+ //
+
+ return TRUE;
+ }
+ else
+ {
+ err=WSAGetLastError();
+
+ if (err == WSAEWOULDBLOCK)
+ {
+ // Connect in Progress
+
+ wsprintf(Title,L"BPQTermTCP Version %s - Connecting to %s", VersionStringW, Host);
+ SetWindowText(hWnd,Title);
+
+ EnableDisconnectMenu(hWnd);
+ DisableConnectMenu(hWnd);
+
+ return TRUE;
+ }
+ else
+ {
+ // Connect failed
+
+ closesocket(sock);
+ MessageBox(NULL, L"Connect Failed", L"BPQTermTCP", MB_OK);
+ return FALSE;
+ }
+ }
+ return FALSE;
+}
+
+int Telnet_Connected(SOCKET sock, int Error)
+{
+ TCHAR Msg[80];
+ int Len;
+ int i = 1;
+ BOOL bcopt = TRUE;
+
+ // Connect Complete
+
+ if (Error)
+ {
+ closesocket(sock);
+ Connecting = FALSE;
+ SocketActive = FALSE;
+
+ wsprintf(Title,L"BPQTermTCP Version %s - Disconnected", VersionStringW);
+ SetWindowText(hWnd,Title);
+ DisableDisconnectMenu(hWnd);
+ DisableYAPPMenu(hWnd);
+ EnableConnectMenu(hWnd);
+
+ wsprintf(Msg, L"Connect Failed - Error %d\r", Error);
+ MessageBox(NULL, Msg, L"BPQTermTCP", MB_OK);
+
+ return 0;
+
+ }
+
+ WSAAsyncSelect(sock, hWnd, WSA_DATA, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE);
+
+ SocketActive = TRUE;
+ Connecting = FALSE;
+ Connected = TRUE;
+ InputMode = 0;
+
+ // Reset Monitor Menu
+
+ // Remove old menu
+
+ while (i)
+ {
+ i = RemoveMenu(hPopMenu1, 6, MF_BYPOSITION);
+ }
+
+ for (i = 1; i <= MonPorts; i++)
+ {
+ wsprintf(Msg,L"Port %d",i);
+
+ if (portmask & ((uint64_t)1<<(i-1)))
+ {
+ AppendMenu(hPopMenu1,MF_STRING | MF_CHECKED,BPQBASE + i, &Msg[0]);
+ portmask |= ((uint64_t)1<<(i-1));
+ }
+ else
+ AppendMenu(hPopMenu1,MF_STRING | MF_UNCHECKED,BPQBASE + i, &Msg[0]);
+ }
+
+
+ Len = wsprintf(Msg, L"%s\r%s\rBPQTermTCP\r", UserName[CurrentHost], Password[CurrentHost]);
+
+ SendMsg(Msg, Len);
+
+ SendTraceOptions();
+
+ SlowTimer = 0;
+
+ wsprintf(Title, L"BPQTermTCP Version %s - Connected to %s", VersionStringW, Host[CurrentHost]);
+ SetWindowText(hWnd,Title);
+ DisableConnectMenu(hWnd);
+ EnableDisconnectMenu(hWnd);
+ EnableYAPPMenu(hWnd);
+
+ return 0;
+}
+
+VOID Socket_Accept(int SocketId, int error, int eventcode)
+{
+ int i = 1, addrlen = sizeof(struct sockaddr_in6);
+ struct sockaddr_in sin;
+ unsigned char work[4];
+
+ u_long param=1;
+
+ sock = accept(SocketId, (struct sockaddr *)&sin, &addrlen);
+
+ WSAAsyncSelect(sock, hWnd, WSA_DATA, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE);
+
+ SocketActive = TRUE;
+ Connecting = FALSE;
+ Connected = TRUE;
+
+ // Reset Monitor Menu
+
+ // Remove old menu
+
+ while (i)
+ {
+ i = RemoveMenu(hPopMenu1, 6, MF_BYPOSITION);
+ }
+
+// Len = wsprintf(Msg, L"Connected to BPQTermTCP\r");
+// SendMsg(Msg, Len);
+
+// SendTraceOptions();
+
+ SlowTimer = 0;
+
+ memcpy(work, &sin.sin_addr.s_addr, 4);
+ wsprintf(Title, L"BPQTermTCP Version %s - Incoming Connection from %d.%d.%d.%d", VersionStringW, work[0], work[1], work[2], work[3]);
+ SetWindowText(hWnd,Title);
+ DisableConnectMenu(hWnd);
+ EnableDisconnectMenu(hWnd);
+
+ if (AlertFileName[0])
+ PlaySound(AlertFileName, NULL, SND_FILENAME | SND_ASYNC);
+ else
+ Beep(AlertFreq, AlertDuration);
+
+ return;
+}
+
+
+
+VOID Socket_Data(int sock, int error, int eventcode)
+{
+ TCHAR Title[100];
+
+ switch (eventcode)
+ {
+ case FD_READ:
+
+ DataSocket_Read(sock);
+ return;
+
+ case FD_WRITE:
+ case FD_OOB:
+ case FD_ACCEPT:
+ case FD_CONNECT:
+
+ return;
+
+ case FD_CLOSE:
+
+ if (SocketActive)
+ closesocket(sock);
+
+ if (ListenOn)
+ wsprintf(Title, L"BPQTermTCP Version %s Listening for Calls", VersionStringW);
+ else
+ wsprintf(Title, L"BPQTermTCP Version %s - Disconnected", VersionStringW);
+
+ SetWindowText(hWnd,Title);
+ DisableDisconnectMenu(hWnd);
+ DisableYAPPMenu(hWnd);
+
+ if (ListenOn == 0)
+ EnableConnectMenu(hWnd);
+
+ WritetoOutputWindow(&OutputData, L"*** Disconnected\r", 17);
+ DoRefresh(&OutputData);
+ SocketActive = FALSE;
+ Connected = FALSE;
+ Disconnecting = FALSE;
+ return ;
+ }
+ return ;
+}
+int TrytoGuessCode(unsigned char * Char, int Len)
+{
+ int Above127 = 0;
+ int LineDraw = 0;
+ int NumericAndSpaces = 0;
+ int n;
+
+ for (n = 0; n < Len; n++)
+ {
+ if (Char[n] < 65)
+ {
+ NumericAndSpaces++;
+ }
+ else
+ {
+ if (Char[n] > 127)
+ {
+ Above127++;
+ if (Char[n] > 178 && Char[n] < 219)
+ {
+ LineDraw++;
+ }
+ }
+ }
+ }
+
+ if (Above127 == 0) // DOesn't really matter!
+ return CP1252;
+
+ if (Above127 == LineDraw)
+ return CP437; // If only Line Draw chars, assume line draw
+
+ // If mainly below 128, it is probably Latin if mainly above, probably Cyrillic
+
+ if ((Len - (NumericAndSpaces + Above127)) < Above127)
+ return CP1251;
+ else
+ return CP1252;
+}
+
+VOID DataSocket_Read(SOCKET sock)
+{
+ int len = 0, MonLen, wlen, err = 0, newlen;
+ unsigned char Buffer[2000];
+ UCHAR * ptr;
+ UCHAR * Buffptr;
+ UCHAR * FEptr = 0;
+ TCHAR BufferW[2000];
+
+ ioctlsocket(sock, FIONREAD, &len);
+
+ if (len > 2000) len = 2000;
+
+ len = recv(sock, Buffer, len, 0);
+
+ if (len == SOCKET_ERROR || len == 0)
+ {
+ // Failed or closed - clear connection
+
+ return;
+ }
+
+ if (InputMode == 'Y') // Yapp
+ {
+ ProcessYAPPMessage(Buffer, len);
+ return;
+ }
+
+// mbstowcs(Buffer, BufferB, len);
+
+ // Look for MON delimiters (FF/FE)
+
+ Buffptr = Buffer;
+
+ if (MonData)
+ {
+ // Already in MON State
+
+ FEptr = memchr(Buffptr, 0xfe, len);
+
+ if (!FEptr)
+ {
+ // no FE - so send all to monitor
+
+ len = MultiByteToWideChar(CP_UTF8, 0, Buffptr, len, BufferW, 2000);
+
+ if (len == 0)
+ return;
+
+ WritetoMonWindow(BufferW, len);
+ return;
+ }
+
+ MonData = FALSE;
+
+ MonLen = FEptr - Buffptr; // Mon Data, Excluding the FE
+
+ wlen = MultiByteToWideChar(CP_UTF8, 0, Buffptr, MonLen, BufferW, 2000);
+
+ if (wlen == 0)
+ return;
+
+ WritetoMonWindow(BufferW, wlen);
+
+ Buffptr = ++FEptr; // Char following FE
+
+ if (++MonLen < len)
+ {
+ len -= MonLen;
+ goto MonLoop; // See if next in MON or Data
+ }
+
+ // Nothing Left
+
+ DoRefresh(&OutputData);
+ return ;
+ }
+
+MonLoop:
+
+ if (ptr = memchr(Buffptr, 0xff, len))
+ {
+ // Buffer contains Mon Data
+
+ if (ptr > Buffptr)
+ {
+ // Some Normal Data before the FF
+
+ int NormLen = ptr - Buffptr; // Before the FF
+
+ if (NormLen == 1 && Buffptr[0] == 0)
+ {
+ // Keepalive
+ }
+
+ else
+ {
+ CheckKeyWords(Buffptr, NormLen);
+
+ wlen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, Buffptr, NormLen, BufferW, 2000);
+
+ err = GetLastError();
+
+ if (err == ERROR_NO_UNICODE_TRANSLATION)
+ {
+ // Input isn't UTF 8. if RXMode = AURO, Try to figure out what it is, otherwise convert usong specified mode
+
+ if (RXMode == AUTO)
+ {
+ int Table = TrytoGuessCode(Buffptr, NormLen);
+
+ wlen = MultiByteToWideChar(Table, 0, Buffptr, NormLen, BufferW, 2000);
+ }
+ else
+ {
+ wlen = MultiByteToWideChar(RXMode, 0, Buffptr, NormLen, BufferW, 2000);
+ }
+ }
+
+ if (wlen)
+ WritetoOutputWindow(&OutputData, BufferW, wlen);
+ }
+
+ len -= NormLen;
+ Buffptr = ptr;
+ goto MonLoop;
+ }
+
+ if (ptr[1] == 0xff)
+ {
+ // Port Definition String
+
+ int NumberofPorts = atoi(&ptr[2]);
+ char *p, *Context;
+ int i = 1;
+ TCHAR msg[80];
+ TCHAR ID[80];
+ int portnum;
+
+ // Remove old menu
+
+ while (i)
+ {
+ i = RemoveMenu(hPopMenu1, 6, MF_BYPOSITION);
+ }
+
+ p = strtok_s(&ptr[2], "|", &Context);
+
+ while(NumberofPorts--)
+ {
+ p = strtok_s(NULL, "|", &Context);
+ if (p == NULL)
+ break;
+
+ portnum = atoi(p);
+ mbstowcs(ID, p, strlen(p) +1);
+
+ wsprintf(msg, L"Port %s", ID);
+
+ if (portmask & ((uint64_t)1<<(portnum - 1)))
+ AppendMenu(hPopMenu1,MF_STRING | MF_CHECKED,BPQBASE + portnum, &msg[0]);
+ else
+ AppendMenu(hPopMenu1,MF_STRING | MF_UNCHECKED,BPQBASE + portnum, &msg[0]);
+
+ i++;
+ }
+
+ return;
+ }
+
+
+ MonData = TRUE;
+
+ FEptr = memchr(Buffptr, 0xfe, len);
+
+ if (FEptr)
+ {
+ MonData = FALSE;
+
+ MonLen = FEptr + 1 - Buffptr; // MonLen includes FF and FE
+
+ wlen = MultiByteToWideChar(CP_UTF8, 0, Buffptr + 1, MonLen - 2, BufferW, 2000);
+
+ if (wlen)
+ WritetoMonWindow(BufferW, wlen);
+
+ DoRefresh(&OutputData);
+
+ len -= MonLen;
+ Buffptr += MonLen; // Char Following FE
+
+ if (len <= 0)
+ {
+ return;
+ }
+ goto MonLoop;
+ }
+ else
+ {
+ // No FE, so rest of buffer is MON Data
+
+ wlen = MultiByteToWideChar(CP_UTF8, 0, Buffptr + 1, MonLen - 1, BufferW, 2000); // Exclude FF
+
+ if (wlen == 0)
+ return;
+
+ WritetoMonWindow(BufferW, wlen);
+ return;
+ }
+ }
+
+ // No FF, so must be session data
+
+ if (InputMode == 'Y') // Yapp
+ {
+ ProcessYAPPMessage(Buffer, len);
+ return;
+ }
+
+
+ if (len == 1 && Buffptr[0] == 0)
+ return; // Keepalive
+
+ // Could be a YAPP Header
+
+
+ if (len == 2 && Buffptr[0] == ENQ && Buffptr[1] == 1) // YAPP Send_Init
+ {
+ UCHAR YAPPRR[2];
+ char Mess[64];
+
+ // Turn off monitoring
+
+ len = sprintf(Mess, "\\\\\\\\%x %x %x %x %x %x %x %x\r", 0, 0, 0, 0, 0, 0, 0, 0);
+ send(sock, Mess, len, 0);
+ InputMode = 'Y';
+
+ YAPPRR[0] = ACK;
+ YAPPRR[1] = 1;
+
+ Sleep(1000); // To give Monitor Msg time to be sent
+ QueueMsg(YAPPRR, 2);
+
+ return;
+ }
+
+ CheckKeyWords(Buffptr, len);
+
+ newlen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, Buffptr, len, BufferW, 2000);
+
+ err = GetLastError();
+
+ if (err == ERROR_NO_UNICODE_TRANSLATION)
+ {
+ // Input isn't UTF 8. if RXMode = AURO, Try to figure out what it is, otherwise convert usong specified mode
+
+ if (RXMode == AUTO)
+ {
+ int Table = TrytoGuessCode(Buffptr, len);
+
+ newlen = MultiByteToWideChar(Table, 0, Buffptr, len, BufferW, 2000);
+ }
+ else
+ {
+ newlen = MultiByteToWideChar(RXMode, 0, Buffptr, len, BufferW, 2000);
+ }
+ }
+
+ if (newlen)
+ WritetoOutputWindow(&OutputData, BufferW, newlen);
+
+ DoRefresh(&OutputData);
+ SlowTimer = 0;
+ return;
+}
+
+int SendMsg(TCHAR * msg, int len)
+{
+ unsigned char MsgB[1000];
+
+ len = WideCharToMultiByte(TXMode, 0, msg, len, MsgB, 1000, NULL, NULL);
+
+ send(sock, MsgB, len, 0);
+ return 0;
+}
+
+VOID SendTraceOptions()
+{
+ char Buffer[80];
+ int Len = sprintf(Buffer, "\\\\\\\\%llx %x %x %x %x %x %x %x\r", portmask, mtxparam, mcomparam, MonitorNODES, MonitorColour, monUI, TXMode == CP_UTF8, 1);
+ mbstowcs(&MonParams[CurrentHost][0], &Buffer[4], Len - 4);
+ SaveStringValue(MON[CurrentHost], MonParams[CurrentHost]);
+ Sleep(1000); // To give YAPP Msg tome to be sent
+ send(sock, Buffer, Len, 0);
+
+}
+
+SOCKET OpenListenSocket4(int port)
+{
+ struct sockaddr_in local_sin; /* Local socket - internet style */
+ struct sockaddr_in * psin;
+ SOCKET sock = 0;
+ u_long param=1;
+ WCHAR Msg[80];
+
+ psin=&local_sin;
+ psin->sin_family = AF_INET;
+ psin->sin_addr.s_addr = INADDR_ANY;
+
+ if (port)
+ {
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+
+ if (sock == INVALID_SOCKET)
+ {
+ wsprintf(Msg, L"socket() failed error %d", WSAGetLastError());
+ MessageBox(NULL, Msg, L"BPQTermTCP", MB_OK);
+ return 0;
+ }
+
+ setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (char *)&param,4);
+
+ psin->sin_port = htons(port); // Convert to network ordering
+
+ if (bind( sock, (struct sockaddr *) &local_sin, sizeof(local_sin)) == SOCKET_ERROR)
+ {
+ wsprintf(Msg, L"bind(sock) failed port %d Error %d", port, WSAGetLastError());
+ MessageBox(NULL, Msg, L"BPQTermTCP", MB_OK);
+ closesocket(sock);
+ return FALSE;
+ }
+
+ if (listen(sock, 4) < 0)
+ {
+ wsprintf(Msg, L"listen(sock) failed port %d Error %d", port, WSAGetLastError());
+ MessageBox(NULL, Msg, L"BPQTermTCP", MB_OK);
+ closesocket(sock);
+ }
+
+ WSAAsyncSelect(sock, hWnd, WSA_ACCEPT, FD_ACCEPT | FD_CLOSE);
+ }
+ return sock;
+}
+
+
+
+static unsigned int cp1251Map[256] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, '\n', 0x000B, 0x000C, '\r', 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, '\'',
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, '\\', 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
+ 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0xFFFD, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
+ 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
+ 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
+ 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
+ 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F
+};
+
+#define INCLUDEYAPP
+#ifdef INCLUDEYAPP
+
+
+// YAPP stuff
+
+#define SOH 1
+#define STX 2
+#define ETX 3
+#define EOT 4
+#define ENQ 5
+#define ACK 6
+#define DLE 0x10
+#define NAK 0x15
+#define CAN 0x18
+
+#define YAPPTX 32768 // Sending YAPP file
+
+int MaxRXSize = 100000;
+char BaseDir[256] = "";
+
+UCHAR InputBuffer[1024];
+
+UCHAR InputMode; // Line by Line or Binary or YAPP
+int paclen = 128;
+
+int InputLen; // Data we have already = Offset of end of an incomplete packet;
+
+UCHAR * MailBuffer; // Yapp Message being received
+int MailBufferSize;
+int YAPPLen; // Bytes sent/received of YAPP Message
+long YAPPDate; // Date for received file - if set enables YAPPC
+char ARQFilename[256]; // Filename from YAPP Header
+
+UCHAR SavedData[4096]; // Max receive is 2000 is should never get more that 4000
+int SaveLen = 0;
+
+void YAPPSendData();
+
+void QueueMsg(UCHAR * Msg, int Len)
+{
+ int Sent = send(sock, Msg, Len, 0);
+
+ if (Sent != Len)
+ Sent = 0;
+}
+
+int InnerProcessYAPPMessage(UCHAR * Msg, int Len);
+
+BOOL ProcessYAPPMessage(UCHAR * Msg, int Len)
+{
+ // may have saved data
+
+ memcpy(&SavedData[SaveLen], Msg, Len);
+
+ SaveLen += Len;
+
+ while (SaveLen && InputMode == 'Y')
+ {
+ int Used = InnerProcessYAPPMessage(SavedData, SaveLen);
+
+ if (Used == 0)
+ return 0; // Waiting for more
+
+ SaveLen -= Used;
+
+ if (SaveLen)
+ memmove(SavedData, &SavedData[Used], SaveLen);
+ }
+ return 0;
+}
+
+int InnerProcessYAPPMessage(UCHAR * Msg, int Len)
+{
+ int pktLen = Msg[1];
+ char Reply[2] = {ACK};
+ int NameLen, SizeLen, OptLen;
+ char * ptr;
+ int FileSize;
+ WCHAR MsgFile[MAX_PATH];
+ FILE * hFile;
+ char Mess[255];
+ int len;
+ TCHAR BufferW[2000];
+ WCHAR WFN[MAX_PATH];
+
+ switch (Msg[0])
+ {
+ case ENQ: // YAPP Send_Init
+
+ // Shouldn't occur in session. Reset state and process
+
+ if (MailBuffer)
+ {
+ free(MailBuffer);
+ MailBufferSize=0;
+ MailBuffer=0;
+ }
+
+ Mess[0] = ACK;
+ Mess[1] = 1;
+
+ InputMode = 'Y';
+ QueueMsg(Mess, 2);
+
+ // Turn off monitoring
+
+ Sleep(1000); // To give YAPP Msg tome to be sent
+
+ len = sprintf(Mess, "\\\\\\\\%x %x %x %x %x %x %x %x\r", 0, 0, 0, 0, 0, 0, 0, 0);
+ send(sock, Mess, len, 0);
+
+ return Len;
+
+ case SOH:
+
+ // HD Send_Hdr SOH len (Filename) NUL (File Size in ASCII) NUL (Opt)
+
+ // YAPPC has date/time in dos format
+
+ NameLen = strlen(&Msg[2]);
+ strcpy(ARQFilename, &Msg[2]);
+
+ // ARQFN normal string. Create WCS copy
+
+ mbstowcs(WFN, ARQFilename, MAX_PATH);
+
+
+ ptr = &Msg[3 + NameLen];
+ SizeLen = strlen(ptr);
+ FileSize = atoi(ptr);
+
+ OptLen = pktLen - (NameLen + SizeLen + 2);
+
+ YAPPDate = 0;
+
+ if (OptLen >= 8) // We have a Date/Time for YAPPC
+ {
+ ptr = ptr + SizeLen + 1;
+ YAPPDate = strtol(ptr, NULL, 16);
+ }
+
+ // Check Size
+
+ if (FileSize > MaxRXSize)
+ {
+ Mess[0] = NAK;
+ Mess[1] = sprintf(&Mess[2], "File %s size %d larger than limit %d\r", WFN, FileSize, MaxRXSize);
+ Sleep(1000); // To give YAPP Msg tome to be sent
+ QueueMsg(Mess, Mess[1] + 2);
+
+ len = wsprintf(BufferW, L"YAPP File %s size %d larger than limit %d\r", WFN, FileSize, MaxRXSize);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+ InputMode = 0;
+ SendTraceOptions();
+
+ return Len;
+ }
+
+ // Make sure file does not exist
+
+ // Path is Wide String, ARQFN normal
+
+ wsprintf(MsgFile, L"%s%s", YAPPPath, WFN);
+
+ hFile = CreateFile(MsgFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
+ {
+ Mess[0] = NAK;
+ Mess[1] = sprintf(&Mess[2], "%s", "File Already Exists");
+ Sleep(1000); // To give YAPP Msg tome to be sent
+ QueueMsg(Mess, Mess[1] + 2);
+ len = wsprintf(BufferW, L"YAPP File Receive Failed - %s already exists\r", MsgFile);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+ CloseHandle(hFile);
+ InputMode = 0;
+ SendTraceOptions();
+
+ return Len;
+ }
+
+
+ MailBufferSize = FileSize;
+ MailBuffer = malloc(FileSize);
+ YAPPLen = 0;
+
+ if (YAPPDate) // If present use YAPPC
+ Reply[1] = ACK; //Receive_TPK
+ else
+ Reply[1] = 2; //Rcv_File
+
+ QueueMsg( Reply, 2);
+
+ len = wsprintf(BufferW, L"YAPP Receving File %s size %d\r", WFN, FileSize);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+
+ return Len;
+
+ case STX:
+
+ // Data Packet
+
+ // Check we have it all
+
+ if (YAPPDate) // If present use YAPPC so have checksum
+ {
+ if (pktLen > (Len - 3)) // -2 for header and checksum
+ return 0; // Wait for rest
+ }
+ else
+ {
+ if (pktLen > (Len - 2)) // -2 for header
+ return 0; // Wait for rest
+ }
+
+ // Save data and remove from buffer
+
+ // if YAPPC check checksum
+
+ if (YAPPDate)
+ {
+ UCHAR Sum = 0;
+ int i;
+ UCHAR * uptr = &Msg[2];
+
+ i = pktLen;
+
+ while(i--)
+ Sum += *(uptr++);
+
+ if (Sum != *uptr)
+ {
+ // Checksum Error
+
+ Mess[0] = CAN;
+ Mess[1] = sprintf_s(&Mess[2], sizeof(Mess), "YAPPC Checksum Error");
+ QueueMsg( Mess, Mess[1] + 2);
+
+ len = wsprintf(BufferW, L"YAPPC Checksum Error\r", MsgFile);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+ InputMode = 0;
+ SendTraceOptions();
+ return Len;
+ }
+ }
+
+ if ((YAPPLen) + pktLen > MailBufferSize)
+ {
+ // Too Big ??
+
+ Mess[0] = CAN;
+ Mess[1] = sprintf(&Mess[2], "YAPP Too much data received");
+ QueueMsg(Mess, Mess[1] + 2);
+
+ len = wsprintf(BufferW, L"YAPP Too much data received\r", MsgFile);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+ InputMode = 0;
+ SendTraceOptions();
+ return Len;
+ }
+
+
+ memcpy(&MailBuffer[YAPPLen], &Msg[2], pktLen);
+ YAPPLen += pktLen;
+
+ if (YAPPDate)
+ ++pktLen; // Add Checksum
+
+ return pktLen + 2;
+
+ case ETX:
+
+ // End Data
+
+ if (YAPPLen == MailBufferSize)
+ {
+ // All received
+
+ int ret;
+ DWORD Written = 0;
+ WCHAR WFN[MAX_PATH];
+
+ // Path is Wide String, ARQFN normal
+
+ mbstowcs(WFN, ARQFilename, MAX_PATH);
+
+ wsprintf(MsgFile, L"%s%s", YAPPPath, WFN);
+
+#ifdef WIN32
+ hFile = CreateFile(MsgFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
+ {
+ ret = WriteFile(hFile, MailBuffer, YAPPLen, &Written, NULL);
+
+ if (YAPPDate)
+ {
+ FILETIME FileTime;
+ struct tm TM;
+ struct timeval times[2];
+ time_t TT;
+/*
+ The MS-DOS date. The date is a packed value with the following format.
+
+ cant use DosDateTimeToFileTime on Linux
+
+ Bits Description
+ 0-4 Day of the month (1–31)
+ 5-8 Month (1 = January, 2 = February, and so on)
+ 9-15 Year offset from 1980 (add 1980 to get actual year)
+ wFatTime
+ The MS-DOS time. The time is a packed value with the following format.
+ Bits Description
+ 0-4 Second divided by 2
+ 5-10 Minute (0–59)
+ 11-15 Hour (0–23 on a 24-hour clock)
+*/
+ memset(&TM, 0, sizeof(TM));
+
+ TM.tm_sec = (YAPPDate & 0x1f) << 1;
+ TM.tm_min = ((YAPPDate >> 5) & 0x3f);
+ TM.tm_hour = ((YAPPDate >> 11) & 0x1f);
+
+ TM.tm_mday = ((YAPPDate >> 16) & 0x1f);
+ TM.tm_mon = ((YAPPDate >> 21) & 0xf) - 1;
+ TM.tm_year = ((YAPPDate >> 25) & 0x7f) + 80;
+
+ Debugprintf("%d %d %d %d %d %d", TM.tm_year, TM.tm_mon, TM.tm_mday, TM.tm_hour, TM.tm_min, TM.tm_sec);
+
+ TT = mktime(&TM);
+ times[0].tv_sec = times[1].tv_sec =
+ times[0].tv_usec = times[1].tv_usec = 0;
+
+ DosDateTimeToFileTime((WORD)(YAPPDate >> 16), (WORD)YAPPDate & 0xFFFF, &FileTime);
+ ret = SetFileTime(hFile, &FileTime, &FileTime, &FileTime);
+ ret = GetLastError();
+
+ }
+ CloseHandle(hFile);
+ }
+#else
+
+ hFile = fopen(MsgFile, "wb");
+ if (hFile)
+ {
+ Written = fwrite(MailBuffer, 1, YAPPLen, hFile);
+ fclose(hFile);
+
+ if (YAPPDate)
+ {
+ struct tm TM;
+ struct timeval times[2];
+/*
+ The MS-DOS date. The date is a packed value with the following format.
+
+ cant use DosDateTimeToFileTime on Linux
+
+ Bits Description
+ 0-4 Day of the month (1–31)
+ 5-8 Month (1 = January, 2 = February, and so on)
+ 9-15 Year offset from 1980 (add 1980 to get actual year)
+ wFatTime
+ The MS-DOS time. The time is a packed value with the following format.
+ Bits Description
+ 0-4 Second divided by 2
+ 5-10 Minute (0–59)
+ 11-15 Hour (0–23 on a 24-hour clock)
+*/
+ memset(&TM, 0, sizeof(TM));
+
+ TM.tm_sec = (YAPPDate & 0x1f) << 1;
+ TM.tm_min = ((YAPPDate >> 5) & 0x3f);
+ TM.tm_hour = ((YAPPDate >> 11) & 0x1f);
+
+ TM.tm_mday = ((YAPPDate >> 16) & 0x1f);
+ TM.tm_mon = ((YAPPDate >> 21) & 0xf) - 1;
+ TM.tm_year = ((YAPPDate >> 25) & 0x7f) + 80;
+
+ Debugprintf("%d %d %d %d %d %d", TM.tm_year, TM.tm_mon, TM.tm_mday, TM.tm_hour, TM.tm_min, TM.tm_sec);
+
+ times[0].tv_sec = times[1].tv_sec = mktime(&TM);
+ times[0].tv_usec = times[1].tv_usec = 0;
+ }
+ }
+#endif
+
+ free(MailBuffer);
+ MailBufferSize=0;
+ MailBuffer=0;
+
+ if (Written != YAPPLen)
+ {
+ Mess[0] = CAN;
+ Mess[1] = sprintf_s(&Mess[2], sizeof(Mess), "Failed to save YAPP File");
+ QueueMsg(Mess, Mess[1] + 2);
+
+ len = wsprintf(BufferW, L"Failed to save YAPP File\r", MsgFile);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+ InputMode = 0;
+ SendTraceOptions();
+ }
+ }
+
+ Reply[1] = 3; //Ack_EOF
+ QueueMsg( Reply, 2);
+
+ len = wsprintf(BufferW, L"Reception of file %s complete\r", MsgFile);
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+
+ return Len;
+
+ case EOT:
+
+ // End Session
+
+ Reply[1] = 4; // Ack_EOT
+ QueueMsg( Reply, 2);
+ InputMode = 0;
+
+ SendTraceOptions();
+ return Len;
+
+ case CAN:
+
+ // Abort
+
+ Mess[0] = ACK;
+ Mess[1] = 5; // CAN Ack
+ QueueMsg( Mess, 2);
+
+ if (MailBuffer)
+ {
+ free(MailBuffer);
+ MailBufferSize=0;
+ MailBuffer=0;
+ }
+
+ // May have an error message
+
+ len = Msg[1];
+
+ if (len)
+ {
+ WCHAR ws[256];
+
+ Msg[len + 2] = 0;
+ mbstowcs(ws, &Msg[2], 255);
+
+ len = wsprintf(BufferW, L"YAPP Transfer cancelled - %s\r", ws);
+ }
+ else
+ len = sprintf_s(Mess, sizeof(Mess), "YAPP Transfer cancelled\r");
+
+ InputMode = 0;
+ SendTraceOptions();
+
+ return Len;
+
+ case ACK:
+
+ switch (Msg[1])
+ {
+ char * ptr;
+
+ case 1: // Rcv_Rdy
+
+ // HD Send_Hdr SOH len (Filename) NUL (File Size in ASCII) NUL (Opt)
+
+ // Remote only needs filename so remove path
+
+ ptr = ARQFilename;
+
+ while (strchr(ptr, '\\'))
+ ptr = strchr(ptr, '\\') + 1;
+
+ len = strlen(ptr) + 3;
+
+ strcpy(&Mess[2], ptr);
+ len += sprintf(&Mess[len], "%d", MailBufferSize);
+ len++; // include null
+ len += sprintf(&Mess[len], "%8X", YAPPDate);
+ len++; // include null
+ Mess[0] = SOH;
+ Mess[1] = len - 2;
+
+ QueueMsg( Mess, len);
+
+ return Len;
+
+ case 2:
+
+ YAPPDate = 0; // Switch to Normal (No Checksum) Mode
+
+ case 6: // Send using YAPPC
+
+ // Start sending message
+
+ YAPPSendData();
+ return Len;
+
+ case 3:
+
+ // ACK EOF - Send EOT
+
+ Mess[0] = EOT;
+ Mess[1] = 1;
+ QueueMsg( Mess, 2);
+
+ return Len;
+
+ case 4:
+
+ // ACK EOT
+
+ InputMode = 0;
+ SendTraceOptions();
+
+ len = wsprintf(BufferW, L"File transfer complete\r");
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+ return Len;
+
+ default:
+ return Len;
+
+ }
+
+ case NAK:
+
+ // Either Reject or Restart
+
+ // RE Resume NAK len R NULL (File size in ASCII) NULL
+
+ if (Len > 2 && Msg[2] == 'R' && Msg[3] == 0)
+ {
+ int posn = atoi(&Msg[4]);
+
+ YAPPLen += posn;
+ MailBufferSize -= posn;
+
+ YAPPSendData();
+ return Len;
+
+ }
+
+ // May have an error message
+
+ len = Msg[1];
+
+ if (len)
+ {
+ WCHAR ws[256];
+
+ Msg[len + 2] = 0;
+
+ mbstowcs(ws, &Msg[2], 255);
+
+ len = wsprintf(BufferW, L"File rejected - %s\r", ws);
+ }
+ else
+ len = wsprintf(BufferW, L"File rejected\r");
+
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+ InputMode = 0;
+ SendTraceOptions();
+
+ return Len;
+
+ }
+
+ len = wsprintf(BufferW, L"Unexpected message during YAPP Transfer. Transfer canncelled\r");
+ WritetoOutputWindow(&OutputData, BufferW, len);
+ DoRefresh(&OutputData);
+
+ InputMode = 0;
+ SendTraceOptions();
+
+ return Len;
+
+}
+
+void YAPPSendFile(WCHAR * FN)
+{
+ int FileSize;
+ char MsgFile[MAX_PATH];
+ FILE * hFile;
+ struct stat STAT;
+ TCHAR BufferW[2000];
+ int Len;
+
+ wcstombs(MsgFile, FN, MAX_PATH);
+
+ if (MsgFile == NULL)
+ {
+ Len = wsprintf(BufferW, L"Filename missing\r");
+ WritetoOutputWindow(&OutputData, BufferW, Len);
+ DoRefresh(&OutputData);
+ SendTraceOptions();
+
+ return;
+ }
+
+ if (stat(MsgFile, &STAT) != -1)
+ {
+ FileSize = STAT.st_size;
+
+ hFile = fopen(MsgFile, "rb");
+
+ if (hFile)
+ {
+ char Mess[255];
+ time_t UnixTime = STAT.st_mtime;
+ FILETIME ft;
+ LONGLONG ll;
+ SYSTEMTIME st;
+ WORD FatDate;
+ WORD FatTime;
+ struct tm TM;
+
+ strcpy(ARQFilename, MsgFile);
+ MailBuffer = malloc(FileSize);
+ MailBufferSize = FileSize;
+ YAPPLen = 0;
+ fread(MailBuffer, 1, FileSize, hFile);
+
+ // Get Date and Time for YAPPC Mode
+
+/* The MS-DOS date. The date is a packed value with the following format.
+
+ cant use DosDateTimeToFileTime on Linux
+
+ Bits Description
+ 0-4 Day of the month (1–31)
+ 5-8 Month (1 = January, 2 = February, and so on)
+ 9-15 Year offset from 1980 (add 1980 to get actual year)
+ wFatTime
+ The MS-DOS time. The time is a packed value with the following format.
+ Bits Description
+ 0-4 Second divided by 2
+ 5-10 Minute (0–59)
+ 11-15 Hour (0–23 on a 24-hour clock)
+
+ memset(&TM, 0, sizeof(TM));
+
+ TM.tm_sec = (YAPPDate & 0x1f) << 1;
+ TM.tm_min = ((YAPPDate >> 5) & 0x3f);
+ TM.tm_hour = ((YAPPDate >> 11) & 0x1f);
+
+ TM.tm_mday = ((YAPPDate >> 16) & 0x1f);
+ TM.tm_mon = ((YAPPDate >> 21) & 0xf) - 1;
+ TM.tm_year = ((YAPPDate >> 25) & 0x7f) + 80;
+*/
+
+ // Note that LONGLONG is a 64-bit value
+
+ ll = Int32x32To64(UnixTime, 10000000) + 116444736000000000;
+ ft.dwLowDateTime = (DWORD)ll;
+ ll >>= 32;
+ ft.dwHighDateTime = (DWORD)ll;
+
+ FileTimeToSystemTime(&ft, &st);
+ FileTimeToDosDateTime(&ft, &FatDate, &FatTime);
+
+ YAPPDate = (FatDate << 16) + FatTime;
+
+ memset(&TM, 0, sizeof(TM));
+
+ TM.tm_sec = (YAPPDate & 0x1f) << 1;
+ TM.tm_min = ((YAPPDate >> 5) & 0x3f);
+ TM.tm_hour = ((YAPPDate >> 11) & 0x1f);
+
+ TM.tm_mday = ((YAPPDate >> 16) & 0x1f);
+ TM.tm_mon = ((YAPPDate >> 21) & 0xf) - 1;
+ TM.tm_year = ((YAPPDate >> 25) & 0x7f) + 80;
+
+ fclose(hFile);
+
+ Mess[0] = ENQ;
+ Mess[1] = 1;
+
+ QueueMsg(Mess, 2);
+ InputMode = 'Y';
+
+ return;
+ }
+ }
+
+ Len = wsprintf(BufferW, L"File %s not found\r", FN);
+ WritetoOutputWindow(&OutputData, BufferW, Len);
+ DoRefresh(&OutputData);
+}
+
+void YAPPSendData()
+{
+ char Mess[258];
+
+ while (1)
+ {
+ int Left = MailBufferSize;
+
+ if (Left == 0)
+ {
+ // Finished - send End Data
+
+ Mess[0] = ETX;
+ Mess[1] = 1;
+
+ QueueMsg( Mess, 2);
+
+ break;
+ }
+
+ if (Left > paclen - 3) // two bytes header and possible checksum
+ Left = paclen - 3;
+
+ memcpy(&Mess[2], &MailBuffer[YAPPLen], Left);
+
+ YAPPLen += Left;
+ MailBufferSize -= Left;
+
+ // if YAPPC add checksum
+
+ if (YAPPDate)
+ {
+ UCHAR Sum = 0;
+ int i;
+ UCHAR * uptr = &Mess[2];
+
+ i = Left;
+
+ while(i--)
+ Sum += *(uptr++);
+
+ *(uptr) = Sum;
+
+ Mess[0] = STX;
+ Mess[1] = Left;
+
+ QueueMsg( Mess, Left + 3);
+ }
+ else
+ {
+ Mess[0] = STX;
+ Mess[1] = Left;
+
+ QueueMsg( Mess, Left + 2);
+ }
+ }
+}
+
+#endif
diff --git a/cMain.c b/cMain.c
index fee87e5..62235a7 100644
--- a/cMain.c
+++ b/cMain.c
@@ -60,6 +60,7 @@ void hookNodeStarted();
void hookNodeRunning();
void DeleteLogFiles(int Age);
void APIL2Trace(struct _MESSAGE * Message, char * Dirn);
+DllExport VOID APIENTRY CloseDebugLog();
#include "configstructs.h"
@@ -73,6 +74,7 @@ extern SOCKADDR_IN UDPreportdest;
extern char NodeAPIServer[80];
extern int NodeAPIPort;
extern int RIFInterval;
+extern int LOCALNOTSECURE;
time_t LastNodeStatus = 0;
@@ -150,9 +152,9 @@ int PACLEN = 100; //MAX PACKET SIZE
// L2 SYSTEM TIMER RUNS AT 3 HZ
-int T3 = 3*61*3; // LINK VALIDATION TIMER (3 MINS) (+ a bit to reduce RR collisions)
+int T3 = 3*61*10; // LINK VALIDATION TIMER (3 MINS) (+ a bit to reduce RR collisions)
-int L2KILLTIME = 16*60*3; // IDLE LINK TIMER (16 MINS)
+int L2KILLTIME = 16*60*10; // IDLE LINK TIMER (16 MINS)
int L3LIVES = 15; // MAX L3 HOPS
int L4N2 = 3; // LEVEL 4 RETRY COUNT
int L4LIMIT = 60*15; // IDLE SESSION LIMIT - 15 MINS
@@ -254,15 +256,13 @@ void * TRACE_Q = NULL; // TRANSMITTED FRAMES TO BE TRACED
int RANDOM = 0; // 'RANDOM' NUMBER FOR PERSISTENCE CALCS
int L2TIMERFLAG = 0; // INCREMENTED AT 18HZ BY TIMER INTERRUPT
-int L3TIMERFLAG = 0; // DITTO
-int L4TIMERFLAG = 0; // DITTO
char HEADERCHAR = '}'; // CHAR FOR _NODE HEADER MSGS
VOID * LASTPOINTER = NULL; // PERVIOUS _NODE DURING CHAINING
-int REALTIMETICKS = 0;
-int BGTIMER = 0; // TO CONTROL BG SCANS
+int REALTIMETICKS = 0; // Count of 100 ms intervals since load
+
VOID * CONFIGPTR = NULL; // Internal Config Get Offset
@@ -451,6 +451,9 @@ VOID EXTTX(PEXTPORTDATA PORTVEC, MESSAGE * Buffer)
}
+VOID * GetBuffQuick();
+UINT ReleaseBufferQuick(VOID *pBUFF);
+
VOID EXTRX(PEXTPORTDATA PORTVEC)
{
struct _MESSAGE * Message;
@@ -462,16 +465,16 @@ Loop:
if (QCOUNT < 10)
return;
- Message = GetBuff();
-
+ Message = GetBuffQuick();
+
if (Message == NULL)
return;
Len = (size_t)PORTVEC->PORT_EXT_ADDR(1, PORT->PORTNUMBER, (PDATAMESSAGE)Message);
-
+
if (Len == 0)
{
- ReleaseBuffer((UINT *)Message);
+ ReleaseBufferQuick((UINT *)Message);
return;
}
@@ -484,7 +487,7 @@ Loop:
int Sessno = Message->PORT;
TRANSPORTENTRY * Session;
- ReleaseBuffer((UINT *)Message);
+ ReleaseBufferQuick((UINT *)Message);
// GET RID OF ANY SESSION ENTRIES
@@ -514,6 +517,8 @@ Loop:
Session.CIRCUITINDEX = -1;
Buffer->LENGTH = sprintf(Buffer->L2DATA, "%s\r", TNC->DisconnectScript[n++]) + (sizeof(void *) + 4);
CommandHandler(&Session, Buffer);
+ strlop(Buffer->L2DATA, 13);
+ Debugprintf("Disconnect Script Output %s", Buffer->L2DATA);
};
}
}
@@ -533,8 +538,12 @@ Loop:
VOID EXTTIMER(PEXTPORTDATA PORTVEC)
{
+ // Called every 100 mS
+
// USED TO SEND A RE-INIT IN THE CORRECT PROCESS
+ struct TNCINFO * TNC = TNCInfo[PORTVEC->PORTCONTROL.PORTNUMBER];
+
if (PORTVEC->EXTRESTART)
{
PORTVEC->EXTRESTART = 0; //CLEAR
@@ -542,10 +551,19 @@ VOID EXTTIMER(PEXTPORTDATA PORTVEC)
}
PORTVEC->PORT_EXT_ADDR(7, PORTVEC->PORTCONTROL.PORTNUMBER, 0); // Timer Routine
+
+ if (TNC && TNC->PageChanged)
+ {
+ BuildDevicePage(TNC);
+ TNC->PageChanged = FALSE;
+ }
+
}
VOID EXTSLOWTIMER(PEXTPORTDATA PORTVEC)
{
+ // Called every minute 60 secs
+
PORTVEC->PORT_EXT_ADDR(8, PORTVEC->PORTCONTROL.PORTNUMBER, 0); // Timer Routine
}
@@ -655,9 +673,9 @@ VOID * TXCHECKCODE[12] = {KISSTXCHECK, HDLCTXCHECK, HDLCTXCHECK, HDLCTXCHECK, KI
extern int BACKGROUND();
extern int L2TimerProc();
-extern int L3TimerProc();
-extern int L4TimerProc();
-extern int L3FastTimer();
+extern int L3MinuteTimerProc();
+extern int L4SecTimer();
+extern int L3SecTimer();
extern int StatsTimer();
extern int COMMANDHANDLER();
VOID SDETX(struct _LINKTABLE * LINK);
@@ -711,7 +729,7 @@ BOOL Start()
if (cfg->C_NODEALIAS[0] == 0)
memset(cfg->C_NODEALIAS, ' ', 10);
- TimeLoaded = time(NULL);
+ TimeLoaded = NOW;
AUTOSAVE = cfg->C_AUTOSAVE;
@@ -840,11 +858,13 @@ BOOL Start()
// MOV NUMBEROFBUFFERS,AX
PACLEN = cfg->C_PACLEN;
- T3 = cfg->C_T3 * 3;
+ T3 = cfg->C_T3 * 10;
L4LIMIT = cfg->C_IDLETIME;
+
if (L4LIMIT && L4LIMIT < 120)
L4LIMIT = 120; // Don't allow stupidly low
- L2KILLTIME = L4LIMIT * 3;
+
+ L2KILLTIME = L4LIMIT * 10;
L4DELAY = cfg->C_L4DELAY;
BBS = cfg->C_BBS;
NODE = cfg->C_NODE;
@@ -898,9 +918,11 @@ BOOL Start()
EnableOARCAPI = cfg->C_OARCAPI;
+ LOCALNOTSECURE = cfg->C_LOCALNOTSECURE;
MONTOFILEFLAG = cfg->C_MONTOFILE;
- RIFInterval = cfg->C_RIFInterval;
+ if (cfg->C_RIFInterval)
+ RIFInterval = cfg->C_RIFInterval;
if (cfg->C_OnlyVer2point0)
SUPPORT2point2 = 0;
@@ -1055,8 +1077,8 @@ BOOL Start()
PORT->FULLDUPLEX = (UCHAR)PortRec->FULLDUP;
PORT->SOFTDCDFLAG = (UCHAR)PortRec->SOFTDCD;
- PORT->PORTT1 = PortRec->FRACK / 333;
- PORT->PORTT2 = PortRec->RESPTIME /333;
+ PORT->PORTT1 = PortRec->FRACK / 100;
+ PORT->PORTT2 = PortRec->RESPTIME /100;
PORT->PORTN2 = (UCHAR)PortRec->RETRIES;
PORT->PORTPACLEN = (UCHAR)PortRec->PACLEN;
@@ -1431,7 +1453,7 @@ BOOL Start()
ROUTE->NBOUR_MAXFRAME = Rcfg->pwind & 0x3f;
FRACK = Rcfg->pfrack;
- ROUTE->NBOUR_FRACK = FRACK / 333;
+ ROUTE->NBOUR_FRACK = FRACK / 100;
ROUTE->NBOUR_PACLEN = Rcfg->ppacl;
ROUTE->OtherendsRouteQual = ROUTE->OtherendLocked = Rcfg->farQual;
@@ -1446,6 +1468,8 @@ BOOL Start()
ROUTE->TCPAddress->ai_addr = (struct sockaddr *) zalloc(sizeof(struct sockaddr));
}
+ ROUTE->NPR = Rcfg->NPR;
+
ROUTE->recNum = index++;
Rcfg++;
@@ -1635,7 +1659,11 @@ BOOL Start()
_beginthread(WritePacketLogThread, 0, NULL);
- lastSaveSecs = CurrentSecs = lastSlowSecs = time(NULL);
+ // Initialise interval timers
+
+ lastMinuteSecs = lastHourSecs = lastTenSecSecs = NOW = time(NULL);
+
+ last100mSTickCount = lastSecTickCount = GetTickCount();
// if EnableOARCAPI set try to resolve host here so we can send Node up event before anything else
@@ -1654,7 +1682,7 @@ BOOL Start()
hookNodeStarted();
nodeStartedSent = 1;
- LastNodeStatus = time(NULL);
+ LastNodeStatus = NOW;
}
}
@@ -2174,9 +2202,13 @@ int DelayBuffers = 0;
void sendModeReport();
void sendFreqReport();
-VOID TIMERINTERRUPT()
+int TIMERINTERRUPT()
{
- // Main Processing loop - CALLED EVERY 100 MS
+ // Main Processing - Called rapidly (maybe 1 mS)
+
+ // Returns 1 if 100mS has passed since last call
+
+ int retval = 0;
int i;
struct PORTCONTROL * PORT = PORTTABLE;
@@ -2185,41 +2217,47 @@ VOID TIMERINTERRUPT()
struct _MESSAGE * Message;
int toPort;
- CurrentSecs = time(NULL);
+ if (GetTickCount() - last100mSTickCount >= 100)
+ {
+ // 100mS has elaped
+
+ retval = 1;
+
+ last100mSTickCount = GetTickCount();
+ REALTIMETICKS++;
- BGTIMER++;
- REALTIMETICKS++;
- L2TIMERFLAG++; // INCREMENT FLAG FOR BG
- L3TIMERFLAG++; // INCREMENT FLAG FOR BG
- L4TIMERFLAG++; // INCREMENT FLAG FOR BG
+ // CALL PORT TIMER 100 mS ROUTINES
-// CALL PORT TIMER ROUTINES
+ for (i = 0; i < NUMBEROFPORTS; i++)
+ {
+ PORT->PORTTIMERCODE(PORT);
- for (i = 0; i < NUMBEROFPORTS; i++)
- {
- PORT->PORTTIMERCODE(PORT);
+ // Check Smart ID timer
- // Check Smart ID timer
+ if (PORT->SmartIDNeeded && PORT->SmartIDNeeded < NOW)
+ SendSmartID(PORT);
- if (PORT->SmartIDNeeded && PORT->SmartIDNeeded < time(NULL))
- SendSmartID(PORT);
+ PORT = PORT->PORTPOINTER;
+ }
- PORT = PORT->PORTPOINTER;
- }
- // CHECK FOR TIMER ACTIVITY
+ if (last100mSTickCount - lastSecTickCount >= 1000)
+ {
+ lastSecTickCount = last100mSTickCount;
- if (L2TIMERFLAG >= 3)
- {
- L2TIMERFLAG -= 3;
- L2TimerProc(); // 300 mS
+ L3SecTimer();
+ L4SecTimer();
+ }
+
+ L2TimerProc(); // Now 100 mS
}
- if (CurrentSecs - lastSlowSecs >= 60) // 1 PER MIN
+ if (NOW - lastMinuteSecs >= 60) // 1 PER MIN
{
- lastSlowSecs = CurrentSecs;
+ lastMinuteSecs = NOW;
- L3TimerProc();
+ CloseDebugLog();
+ L3MinuteTimerProc();
if (needAIS)
AISTimer();
@@ -2257,9 +2295,9 @@ VOID TIMERINTERRUPT()
if (MQTT)
MQTTTimer();
- if (LastNodeStatus && (time(NULL) - LastNodeStatus) > nodeStatusTimer)
+ if (LastNodeStatus && (NOW - LastNodeStatus) > nodeStatusTimer)
{
- LastNodeStatus = time(NULL);
+ LastNodeStatus = NOW;
hookNodeRunning();
}
@@ -2281,9 +2319,9 @@ VOID TIMERINTERRUPT()
// Check Autosave Nodes and MH timer
- if (CurrentSecs - lastSaveSecs >= 3600) // 1 per hour
+ if (NOW - lastHourSecs >= 3600) // 1 per hour
{
- lastSaveSecs = CurrentSecs;
+ lastHourSecs = NOW;
if (AUTOSAVE == 1)
SaveNodes();
@@ -2291,16 +2329,10 @@ VOID TIMERINTERRUPT()
SaveMH();
}
- if (L4TIMERFLAG >= 10) // 1 PER SEC
- {
- L4TIMERFLAG -= 10;
-
- L3FastTimer();
- L4TimerProc();
- }
-
// SEE IF ANY FRAMES TO TRACE
+ // The rest runs on every call
+
Buffer = Q_REM(&TRACE_Q);
while (Buffer)
@@ -2346,8 +2378,6 @@ VOID TIMERINTERRUPT()
while (Buffer)
{
Message = (struct _MESSAGE *) Buffer;
- if (CURRENTPORT == 30)
- Sent = Sent;
if (PORT->PROTOCOL == 10)
{
@@ -2427,7 +2457,7 @@ VOID TIMERINTERRUPT()
L2Packet:
// TIME STAMP IT
- time(&Message->Timestamp);
+ Message->Timestamp = NOW;
Message->PORT = CURRENTPORT;
@@ -2458,7 +2488,7 @@ L2Packet:
{
// Using Smart ID, but none scheduled
- BPORT->SmartIDNeeded = time(NULL) + BPORT->SmartIDInterval;
+ BPORT->SmartIDNeeded = NOW + BPORT->SmartIDInterval;
}
PUT_ON_PORT_Q(BPORT, BBuffer);
}
@@ -2625,7 +2655,7 @@ ENDOFLIST:
{
// Stuck link debug check
- if (LINK->LINKWINDOW == 0 || LINK->LASTFRAMESENT == 0 || (time(NULL) - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
+ if (LINK->LINKWINDOW == 0 || LINK->LASTFRAMESENT == 0 || (NOW - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
{
if (COUNT_AT_L2(LINK) > 16 || LINK->LINKWINDOW == 0)
{
@@ -2635,7 +2665,7 @@ ENDOFLIST:
char Normcall2[11] = "";
int Count = COUNT_AT_L2(LINK);
- int secs = time(NULL) - LINK->LASTFRAMESENT;
+ int secs = NOW - LINK->LASTFRAMESENT;
ConvFromAX25(LINK->LINKCALL, Normcall);
@@ -2656,12 +2686,10 @@ ENDOFLIST:
L2SENDCOMMAND(LINK, DISC | PFBIT);
- return;
+ return retval; // why??
}
}
-
}
-
}
}
LINK++;
@@ -2670,6 +2698,10 @@ ENDOFLIST:
L4BG(); // DO LEVEL 4 PROCESSING
L3BG();
TNCTimerProc();
+
+ return retval;
+
+
}
VOID DoListenMonitor(TRANSPORTENTRY * L4, MESSAGE * Msg)
@@ -3059,7 +3091,7 @@ void WriteConnectLog(char * fromCall, char * toCall, UCHAR * Mode)
char LogMsg[256];
int MsgLen;
- T = time(NULL);
+ T = NOW;
tm = gmtime(&T);
sprintf(FN,"%s/logs/ConnectLog_%02d%02d%02d.log", LogDirectory, tm->tm_year - 100, tm->tm_mon + 1, tm->tm_mday);
diff --git a/chatconfig.cfg b/chatconfig.cfg
index c990d97..7d23f4f 100644
--- a/chatconfig.cfg
+++ b/chatconfig.cfg
@@ -18,5 +18,5 @@ Chat :
MonitorSize = "828,1644,148,770";
DebugSize = "0,0,0,0";
WindowSize = "231,835,254,602";
- Version = "6,0,24,81";
+ Version = "6,0,25,40";
};
diff --git a/cheaders.h b/cheaders.h
index bd2b259..25d0e16 100644
--- a/cheaders.h
+++ b/cheaders.h
@@ -148,7 +148,7 @@ char * SetupNodeHeader(struct DATAMESSAGE * Buffer);
VOID L4CONNECTFAILED(TRANSPORTENTRY * L4);
int CountFramesQueuedOnSession(TRANSPORTENTRY * Session);
VOID CLEARSESSIONENTRY(TRANSPORTENTRY * Session);
-VOID __cdecl Debugprintf(const char * format, ...);
+Dll VOID __cdecl Debugprintf(const char * format, ...);
int APIENTRY Restart();
int APIENTRY Reboot();
@@ -161,7 +161,7 @@ struct SEM;
void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line);
void FreeSemaphore(struct SEM * Semaphore);
-void MySetWindowText(HWND hWnd, char * Msg);
+void MySetWindowText(struct TNCINFO * TNC, HWND hWnd, char * Msg);
Dll int APIENTRY SessionControl(int stream, int command, int Mask);
@@ -396,9 +396,14 @@ extern UCHAR AuthorisedProgram; // Local Variable. Set if Program is on secure
extern int REALTIMETICKS;
-extern time_t CurrentSecs;
-extern time_t lastSlowSecs;
-extern time_t lastSaveSecs;
+extern time_t NOW; // From time()
+extern time_t lastMinuteSecs; // Time minute process last run
+extern time_t lastHourSecs; // Time hour process last run
+extern time_t lastTenSecSecs;
+
+extern uint64_t last100mSTickCount;
+extern uint64_t lastSecTickCount;
+
// SNMP Variables
@@ -438,6 +443,7 @@ extern char MQTT_PASS[80];
extern int SUPPORT2point2;
+extern char * DevWebPage[MaxBPQPortNo];
DllExport uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqStringMhz);
diff --git a/compatbits.c b/compatbits.c
index a6ce8f5..e02fd7c 100644
--- a/compatbits.c
+++ b/compatbits.c
@@ -179,11 +179,6 @@ int Sleep(int ms)
return 0;
}
-VOID OutputDebugString(char * string)
-{
- syslog(LOG_DEBUG, "%s", string);
-}
-
void closesocket(int sock)
{
if (sock)
diff --git a/compatbits.h b/compatbits.h
index 1642af9..a75a726 100644
--- a/compatbits.h
+++ b/compatbits.h
@@ -238,9 +238,6 @@ VOID md5(char *arg, unsigned char * checksum);
int APIENTRY SendRaw(int port, char * msg, int len);
-
-VOID OutputDebugString(char * string);
-
#endif
#ifdef APIENTRY
diff --git a/config.c b/config.c
index 57fe125..b65fcc0 100644
--- a/config.c
+++ b/config.c
@@ -192,6 +192,8 @@ VOID Consoleprintf(const char * format, ...)
va_start(arglist, format);
vsprintf(Mess, format, arglist);
+ va_end(arglist);
+
strcat(Mess, "\n");
WritetoConsoleLocal(Mess);
@@ -255,7 +257,7 @@ int tnctypes(int i,char *value,char *rec);
int do_kiss(char *value,char *rec);
int decode_ded_rec(char *rec);
int simple(int i);
-int64_t int64_value(int64_t * val, char value[], char rec[]);
+int int64_value(int64_t * val, char value[], char rec[]);
int32_t int32_value(int32_t * val, char value[], char rec[]);
@@ -312,7 +314,7 @@ static char *keywords[] =
"EnableM0LTEMap", "MQTT", "MQTT_HOST", "MQTT_PORT", "MQTT_USER", "MQTT_PASS",
"L4Compress", "L4CompMaxframe", "L4CompPaclen", "L2Compress", "L2CompMaxframe",
"L2CompPaclen", "PREFERINP3ROUTES", "OnlyVer2point0", "DEBUGINP3", "ENABLEOARCAPI", "MONTOFILE",
-"RIFInterval"
+"RIFInterval", "LOCALNOTSECURE"
}; /* parameter keywords */
@@ -338,7 +340,8 @@ static void * offset[] =
&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, &xxcfg.C_L2Compress, &xxcfg.C_L2CompMaxframe,
&xxcfg.C_L2CompPaclen, &xxcfg.C_PREFERINP3ROUTES, &xxcfg.C_OnlyVer2point0, &xxcfg.C_DEBUGINP3, &xxcfg.C_OARCAPI, &xxcfg.C_MONTOFILE,
-&xxcfg.C_RIFInterval}; /* offset for corresponding data in config file */
+&xxcfg.C_RIFInterval, &xxcfg.C_LOCALNOTSECURE /* offset for corresponding data in config file */
+};
static int routine[] =
{
@@ -362,7 +365,7 @@ static int routine[] =
2, 2, 0, 1, 20, 20,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
-1}; // Routine to process param
+1, 1}; // Routine to process param
int PARAMLIM = sizeof(routine)/sizeof(int);
//int NUMBEROFKEYWORDS = sizeof(routine)/sizeof(int);
@@ -647,6 +650,7 @@ BOOL ProcessConfig()
paramok[100]=1; // BW
paramok[101]=1; // SF
paramok[102]=1; // CR
+ paramok[103]=1; // LOCALNOTSECURE
for (i=0; i < PARAMLIM; i++)
@@ -701,7 +705,7 @@ BOOL ProcessConfig()
/*
// Dump to file for debugging
- sprintf_s(inputname, sizeof(inputname), "CFG%d", time(NULL));
+ sprintf_s(inputname, sizeof(inputname), "CFG%d", NOW);
fp1 = fopen(inputname, "wb");
@@ -1416,7 +1420,7 @@ int int32_value(int32_t * val, char value[], char rec[])
return(1);
}
-int64_t int64_value(int64_t * val, char value[], char rec[])
+int int64_value(int64_t * val, char value[], char rec[])
{
*val = strtoll(value, NULL, 10);
return(1);
@@ -1700,6 +1704,13 @@ int routes(int i)
Route->inp3 = atoi(val);
}
+ else if (strcmp(ptr, "NPR") == 0)
+ {
+ char * val = strtok_s(NULL, " ,=", &context);
+
+ if (val)
+ Route->NPR = atoi(val);
+ }
else if (strcmp(ptr, "NOKEEPALIVES") == 0)
{
char * val = strtok_s(NULL, " ,=", &context);
diff --git a/configstructs.h b/configstructs.h
index 6c09c26..db72ab9 100644
--- a/configstructs.h
+++ b/configstructs.h
@@ -101,6 +101,7 @@ struct ROUTECONFIG
int ppacl;
int farQual;
int inp3;
+ int NPR;
int nokeepalives;
int noV2point2;
char * tcphost;
@@ -195,7 +196,7 @@ struct CONFIGTABLE
int C_OARCAPI;
int C_MONTOFILE;
int C_RIFInterval;
-
+ int C_LOCALNOTSECURE;
//#define ApplOffset 80000 // Applications offset in config buffer
diff --git a/datadefs.c b/datadefs.c
index e688283..b289d95 100644
--- a/datadefs.c
+++ b/datadefs.c
@@ -39,6 +39,8 @@ int DEBUGINP3 = 0;
int EnableOARCAPI = 0;
+int LOCALNOTSECURE = 0; // Dont treat 127.0.0.1 as secure (For Proxies)
+
int RTTInterval = 30; // 10 second increments - 5 Minutes
BOOL IPRequired = FALSE;
@@ -66,8 +68,15 @@ UCHAR PACTORCALL[7] = {'P'+'P','A'+'A','C'+'C','T'+'T','O'+'O','R'+'R'}; //PACTO
UCHAR L3RTT[7] = {'L'+'L','3'+'3','R'+'R','T'+'T','T'+'T',0x40, 0xe0}; // L3RTT IN AX25
UCHAR L3KEEP[7] = {'K'+'K','E'+'E','E'+'E','P'+'P','L'+'L','I'+'I', 0xe0}; // KEEPLI IN AX25
-time_t CurrentSecs;
-time_t lastSlowSecs;
+time_t NOW; // From time()
+time_t lastMinuteSecs; // Time minute process last run
+time_t lastHourSecs; // Time hour process last run
+time_t lastTenSecSecs;
+
+uint64_t last100mSTickCount;
+uint64_t lastSecTickCount;
+
+
time_t lastSaveSecs;
char WL2KCall[10] = "";
diff --git a/httpconnectioninfo.h b/httpconnectioninfo.h
index 46cb0b7..3c55e51 100644
--- a/httpconnectioninfo.h
+++ b/httpconnectioninfo.h
@@ -21,7 +21,11 @@ struct HTTPConnectionInfo // Used for Web Server for thread-specific stuff
int KillTimer; // Clean up timer (no activity timeout)
int Stream; // BPQ Stream Number
char Key[20]; // Session Key
- BOOL Connected;
+ uint8_t WebsockTerm; // Set if Term Session is using Websocks
+ uint8_t Spare1;
+ uint8_t Spare2;
+ uint8_t Spare3;
+
// Use by Mail Module
#ifdef MAIL
struct UserInfo * User; // Selected User
@@ -41,5 +45,6 @@ struct HTTPConnectionInfo // Used for Web Server for thread-specific stuff
BOOL WebMailMyTX; // List all meessage from me
BOOL WebMailMyRX; // List all meessage to me
time_t WebMailLastUsed;
+ struct ConnectionInfo * sockptr;
struct TNCINFO * TNC; // Session -> TNC link
};
diff --git a/kiss.c b/kiss.c
index 468d32c..b720485 100644
--- a/kiss.c
+++ b/kiss.c
@@ -1593,7 +1593,7 @@ SeeifMore:
// If a response to a qtsm command display it
- if (PORT->Session && (time(NULL) - PORT->LastKISSCmdTime < 10))
+ if (PORT->Session && (NOW - PORT->LastKISSCmdTime < 10))
{
PDATAMESSAGE Buffer;
BPQVECSTRUC * VEC;
@@ -1666,7 +1666,7 @@ SeeifMore:
// If a reply to a manual KISS command(Session set and time not too long ago)
// send reponse to terminal
- if (PORT->Session && (time(NULL) - PORT->LastKISSCmdTime < 10))
+ if (PORT->Session && (NOW - PORT->LastKISSCmdTime < 10))
{
PDATAMESSAGE Buffer;
BPQVECSTRUC * VEC;
@@ -2198,16 +2198,24 @@ int KISSGetTCPMessage(NPASYINFO ASY)
{
// Bind Failed
- int err = WSAGetLastError();
- Consoleprintf("Bind Failed for KISS TCP port %d - error code = %d", ASY->Portvector->ListenPort, err);
+ if (ASY->Alerted == FALSE)
+ {
+ int err = WSAGetLastError();
+ Consoleprintf("Bind Failed for KISS TCP port %d - error code = %d", ASY->Portvector->ListenPort, err);
+ ASY->Alerted = TRUE;
+ }
closesocket(sock);
}
else
{
if (listen(sock, 1) < 0)
{
- int err = WSAGetLastError();
- Consoleprintf("Listen Failed for KISS TCP port %d - error code = %d", ASY->Portvector->ListenPort, err);
+ if (ASY->Alerted == FALSE)
+ {
+ int err = WSAGetLastError();
+ Consoleprintf("Listen Failed for KISS TCP port %d - error code = %d", ASY->Portvector->ListenPort, err);
+ ASY->Alerted = TRUE;
+ }
closesocket(sock);
}
else
diff --git a/mailapi.c b/mailapi.c
index d8e6ed2..902e193 100644
--- a/mailapi.c
+++ b/mailapi.c
@@ -971,6 +971,10 @@ void SendBBSDataToPktMapThread(void * Param)
// Get Routing
MsgBytes = ReadMessageFile(Msg->number);
+
+ if (MsgBytes == NULL)
+ continue;
+
RLines = malloc(Msg->length * 2); // Very unlikely to need so much but better safe..
strcpy(RLines, "[]");
diff --git a/makefile b/makefile
index 26403e5..b2bd9db 100644
--- a/makefile
+++ b/makefile
@@ -22,7 +22,7 @@ OBJS = pngwtran.o pngrtran.o pngset.o pngrio.o pngwio.o pngtrans.o pngrutil.o pn
LDFLAGS = -Xlinker -Map=output.map -lrt
all: CFLAGS = -DLINBPQ -MMD -g -fcommon -fasynchronous-unwind-tables $(EXTRA_CFLAGS)
-all: LIBS = -lpaho-mqtt3a -ljansson -lminiupnpc -lm -lz -lpthread -lconfig -lpcap
+all: LIBS = -lpaho-mqtt3a -ljansson -lminiupnpc -lm -lz -lpthread -lconfig -lpcap -lbacktrace
all: linbpq
#other OS
diff --git a/mqtt.c b/mqtt.c
index a9e91b4..6cc3018 100644
--- a/mqtt.c
+++ b/mqtt.c
@@ -31,7 +31,7 @@ void MQTTSendStatus()
strcpy(payload,"{\"status\":\"online\"}");
MQTTSend(topic, payload, strlen(payload));
- MQTTLastStatus = time(NULL);
+ MQTTLastStatus = NOW;
}
void MQTTTimer()
@@ -39,7 +39,7 @@ void MQTTTimer()
if (MQTT_Connecting == 0 && MQTT_Connected == 0)
MQTTConnect(MQTT_HOST, MQTT_PORT, MQTT_USER, MQTT_PASS);
- if ((time(NULL) - MQTTLastStatus) > 1800)
+ if ((NOW - MQTTLastStatus) > 1800)
MQTTSendStatus();
}
diff --git a/nodeapi.c b/nodeapi.c
index 148728b..16d9ef2 100644
--- a/nodeapi.c
+++ b/nodeapi.c
@@ -246,7 +246,7 @@ Token * generate_token()
token->token[i] = 'A' + rand() % 26; // Random uppercase alphabet character
}
token->token[TOKEN_SIZE] = '\0'; // Null-terminate the token
- token->expiration_time = time(NULL) + TOKEN_EXPIRATION; // Set token expiration time
+ token->expiration_time = NOW + TOKEN_EXPIRATION; // Set token expiration time
add_token_to_list(token);
return token;
}
@@ -280,7 +280,7 @@ int verify_token(const char* token)
if (existing_token != NULL)
{
// Check if the token has expired
- time_t current_time = time(NULL);
+ time_t current_time = NOW;
if (current_time > existing_token->expiration_time)
{
// Token has expired, remove it from the token list
@@ -297,7 +297,7 @@ int verify_token(const char* token)
void remove_expired_tokens()
{
- time_t current_time = time(NULL);
+ time_t current_time = NOW;
Token* current_token = token_list;
Token* prev_token = NULL;
Token* next_token;
diff --git a/nodelog.txt b/nodelog.txt
deleted file mode 100644
index e69de29..0000000
--- a/nodelog.txt
+++ /dev/null
diff --git a/telnetserver.h b/telnetserver.h
index a93625c..17c0835 100644
--- a/telnetserver.h
+++ b/telnetserver.h
@@ -78,6 +78,8 @@ struct ConnectionInfo
int Connecting; // For outward connect
int Connected;
+
+ struct UserRec * USER; // Telnet Server USER record - Used for Webterm
};
diff --git a/tncinfo.h b/tncinfo.h
index 2e2c553..003cbd7 100644
--- a/tncinfo.h
+++ b/tncinfo.h
@@ -17,6 +17,10 @@ extern HANDLE hInstance;
extern HMENU hMainFrameMenu;
extern HMENU hWndMenu;
+
+void BuildDevicePage(struct TNCINFO * TNC);
+
+
/*
struct WL2KInfo
{
@@ -189,6 +193,7 @@ struct TCPINFO
HWND hCMSWnd;
int SecureTelnet;
+ int noWebSocks;
int ReportRelayTraffic; // Send WL2K Reports for Relay Traffic
char * WebTermCSS; // css override for web terminal
@@ -812,7 +817,13 @@ typedef struct TNCINFO
char * WEB_RESTARTS;
char * WEB_PACTORLEVEL;
char * WEB_LEVELS;
- int WEB_CHANGED; // Used to speed up refresh when active
+ char WEB_CHANGED; // Used to speed up refresh when active
+ char WebSockUsed; // If not set don't build page
+ char PageChanged; // Set when page could have changed
+
+ char * WebPage; // Device Web Page. Used for Websocks refresh
+ int WebPageLen;
+
HMENU hMenu;
HMENU hWndMenu;
@@ -863,9 +874,9 @@ typedef struct TNCINFO
int NRCloseTimer;
struct _LINKTABLE * DummyLink; // Simulated link to simplify interface to ax,25 netrom code
struct sixPackPortInfo * sixPack;
- int VaraACAllowed; // Set by config
- int VaraACMode; // Set by first message received
- int VaraModeSet; // Have decicded if VarAC mode or not
+ char VaraACAllowed; // Set by config
+ char VaraACMode; // Set by first message received
+ char VaraModeSet; // Have decicded if VarAC mode or not
char * VARACMsg; // to build message from packets
int VarACTimer; // delayed send timer
size_t VARACSize; // malloc'ed size
@@ -908,7 +919,7 @@ int BPQTRACE(MESSAGE * Msg, BOOL TOAPRS);
static int ProcessLine(char * buf, int Port);
-VOID __cdecl Debugprintf(const char * format, ...);
+Dll VOID __cdecl Debugprintf(const char * format, ...);
VOID __cdecl Consoleprintf(const char * format, ...);
extern BOOL MinimizetoTray;
diff --git a/utf8Routines.c b/utf8Routines.c
index c0f9ca3..d322013 100644
--- a/utf8Routines.c
+++ b/utf8Routines.c
@@ -537,15 +537,13 @@ int TrytoGuessCode(unsigned char * Char, int Len)
if (Char[n] > 127)
{
Above127++;
- if (Char[n] > 178 && Char[n] < 219)
- {
+ if (Char[n] > 175 && Char[n] < 224)
LineDraw++;
- }
}
}
}
- if (Above127 == 0) // DOesn't really matter!
+ if (Above127 == 0) // Doesn't really matter!
return 1252;
if (LineDraw > ((Above127 * 9) / 10))