summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2025-07-22 20:56:59 +0100
committerDave Hibberd <hibby@debian.org>2025-07-22 20:56:59 +0100
commit1f40ff4a07793ecfa679a1384053451c4f3f536f (patch)
treec0813999c7216f98b4ac66224bd01589baee84d1
parentb128f2a43a16acef50de045ae6526772c04c395e (diff)
New upstream version 6.0.24.77+repackupstream/6.0.24.77+repack
-rw-r--r--AGWAPI.c60
-rw-r--r--AGWMoncode.c92
-rw-r--r--ARDOP.c38
-rw-r--r--BBSHTMLConfig.c30
-rw-r--r--BBSUtilities.c128
-rw-r--r--BPQINP3.c573
-rw-r--r--BPQMail.apsbin0 -> 92636 bytes
-rw-r--r--BPQMail.c17
-rw-r--r--BPQMail.rc1090
-rw-r--r--BPQRemotePTT.cfg12
-rw-r--r--Bpq32.c29
-rw-r--r--CMSAuth.c3
-rw-r--r--ChatHTMLConfig.c4
-rw-r--r--Cmd.c145
-rw-r--r--CommonCode.c28
-rw-r--r--Events.c6
-rw-r--r--FBBRoutines.c193
-rw-r--r--FLDigi64.c3860
-rw-r--r--FreeDATA.c5
-rw-r--r--HALDriver64.c1907
-rw-r--r--HFCommon.c5
-rw-r--r--HTTPcode.c100
-rw-r--r--IPCode.c9
-rw-r--r--KAMPactor.c211
-rw-r--r--L2Code.c464
-rw-r--r--L3Code.c68
-rw-r--r--L4Code.c124
-rw-r--r--LinBPQ.c56
-rw-r--r--MHSave.txt0
-rw-r--r--MULTIPSK64.c1543
-rw-r--r--Moncode.c19
-rw-r--r--MultiConsole.c3
-rw-r--r--RHP.c51
-rw-r--r--RTKnown.txt0
-rw-r--r--RigControl.c1
-rw-r--r--SCSTrackeMulti64.c1714
-rw-r--r--TNCCode.c5
-rw-r--r--TNCEmulators.c10
-rw-r--r--TelnetV6.c129
-rw-r--r--UZ7HODrv.c5
-rw-r--r--VARA.c1
-rw-r--r--Versions.h7
-rw-r--r--WINMOR.c20
-rw-r--r--WPRoutines.c1
-rw-r--r--WebMail.c215
-rw-r--r--WinRPR.c3
-rw-r--r--asmstrucs.h38
-rw-r--r--bpq32.h2
-rw-r--r--bpqaxip.c51
-rw-r--r--bpqmail.h10
-rw-r--r--cMain.c36
-rw-r--r--cheaders.h7
-rw-r--r--config.c21
-rw-r--r--configstructs.h6
-rw-r--r--kiss.c2
-rw-r--r--linether.c24
-rw-r--r--lzhuf32.c2
-rw-r--r--makefile36
-rw-r--r--mqtt.c2
-rw-r--r--templatedefs.c3
-rw-r--r--upnp.c18
61 files changed, 11970 insertions, 1272 deletions
diff --git a/AGWAPI.c b/AGWAPI.c
index dcf3494..126a72a 100644
--- a/AGWAPI.c
+++ b/AGWAPI.c
@@ -36,7 +36,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
struct AGWHeader
{
- unsigned int Port;
+ uint8_t Port;
+ uint8_t filler1[3];
unsigned char DataKind;
unsigned char filler2;
unsigned char PID;
@@ -128,7 +129,7 @@ int DataSocket_Write(struct AGWSocketConnectionInfo * sockptr, SOCKET sock);
int AGWGetSessionKey(char * key, struct AGWSocketConnectionInfo * sockptr);
int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr);
int SendDataToAppl(int Stream, byte * Buffer, int Length);
-int InternalAGWDecodeFrame(char * msg, char * buffer, time_t Stamp, int * FrameType, int useLocalTime, int doNodes);
+int InternalAGWDecodeFrame(MESSAGE * msg, char * buffer, time_t Stamp, int * FrameType, int useLocalTime, int doNodes);
int AGWDataSocket_Disconnect( struct AGWSocketConnectionInfo * sockptr);
int SendRawPacket(struct AGWSocketConnectionInfo * sockptr, char *txmsg, int Length);
int ShowApps();
@@ -720,7 +721,7 @@ int AGWDoMonitorData()
RawLen = monbuff->LENGTH;
- if (RawLen < 7 || RawLen > 350)
+ if (RawLen < MSGHDDRLEN || RawLen > 350)
{
ReleaseBuffer(monbuff);
FreeSemaphore(&Semaphore);
@@ -734,12 +735,16 @@ int AGWDoMonitorData()
ReleaseBuffer(monbuff);
FreeSemaphore(&Semaphore);
+
+ // Set monbuff to point to the copy
+
+ monbuff = (MESSAGE *)Buffer;
//' 4 byte chain
//' 1 byte port - top bit = transmit
//' 2 byte length (LO-HI)
- Port = Buffer[4];
+ Port = monbuff->PORT;
if (Port > 127)
{
@@ -751,6 +756,12 @@ int AGWDoMonitorData()
RXFlag = TRUE;
}
+ if (Port == 0)
+ {
+ Debugprintf("AGWMON Port number is zero");
+ return 0;
+ }
+
// Can now have different mon flags per connection, so need to run decode for each socket
for (n = 1; n<= CurrentSockets; n++)
@@ -759,7 +770,7 @@ int AGWDoMonitorData()
if (sockptr->SocketActive && sockptr->MonFlag && (RXFlag || LoopMonFlag))
{
- Length = InternalAGWDecodeFrame(Buffer, AGWBuffer, Stamp, &Frametype, sockptr->useLocalTime, sockptr->doNodes);
+ Length = InternalAGWDecodeFrame(monbuff, AGWBuffer, Stamp, &Frametype, sockptr->useLocalTime, sockptr->doNodes);
if (Length > 0)
{
@@ -803,7 +814,7 @@ int AGWDoMonitorData()
}
}
- RawLen = RawLen - 6;
+ RawLen = RawLen - (MSGHDDRLEN - 1); // One more for KISS control
if (RXFlag || Loopflag) // Send transmitted frames if requested
{
@@ -811,8 +822,12 @@ int AGWDoMonitorData()
//
// Send raw data to any sockets that have requested Raw frames
//
-
- Buffer[6]=0;
+
+ // Format is ax.25 packet prceeded by a KISS command byte 00 for channel 1 0x10 for channel 2 etc
+ // As this is an application API I think all should go as Port 1
+
+
+ Buffer[MSGHDDRLEN - 1] = 0; // Just in case big-endian
AGWTXHeader.Port = Port - 1; // AGW Ports start from 0
AGWTXHeader.DataKind = 'K';
@@ -824,14 +839,12 @@ int AGWDoMonitorData()
sockptr=&Sockets[n];
if (sockptr->SocketActive && sockptr->RawFlag)
- SendRawPacket(sockptr, &Buffer[6], RawLen);
+ SendRawPacket(sockptr, &Buffer[MSGHDDRLEN - 1], RawLen);
}
}
}
-
- return 0;
-
+ return 0;
}
int DeleteConnection(struct BPQConnectionInfo * Con)
@@ -1128,6 +1141,7 @@ int AGWDataSocket_Read(struct AGWSocketConnectionInfo * sockptr, SOCKET sock)
int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
{
int AGWVersion[2]={2003,999};
+ byte AGWPortCaps[12] = { 0, 255, 30, 10, 63, 10, 4, 0, 1, 0, 0, 0 };
char AGWRegReply[1];
struct BPQConnectionInfo * Connection;
int Stream;
@@ -1195,7 +1209,7 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
// Need to convert port index (used by AGW) to port number
- conport=GetPortNumber(VisiblePortToRealPort[key[0]-48]);
+ conport=GetPortNumber(VisiblePortToRealPort[key[0]-49] + 1);
n = sprintf(ConnectMsg,"C %d %s",conport,ToCall);
@@ -1293,9 +1307,7 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
// Version
memset(&AGWTXHeader,0,36);
-
AGWTXHeader.DataKind = 'R';
-
AGWTXHeader.DataLength = 8; // Length
SendtoSocket(sockptr->socket, (char *)&AGWVersion[0]);
@@ -1309,15 +1321,27 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
memset(&AGWTXHeader,0,36);
-
AGWTXHeader.DataKind = 'G';
-
AGWTXHeader.DataLength =(int)strlen(AGWPorts)+1; // Length
SendtoSocket(sockptr->socket, AGWPorts);
return 0;
+
+ case 'g':
+
+ // Port capabilities. Currently hard-coded.
+
+ AGWTXHeader.Port = sockptr->AGWRXHeader.Port;
+ AGWTXHeader.DataKind = 'g';
+ AGWTXHeader.DataLength = 12;
+
+ SendtoSocket(sockptr->socket, (char *)&AGWPortCaps[0]);
+
+ return 0;
+
+
case 'k':
@@ -1416,6 +1440,8 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
AGWTXHeader.DataKind = 'X';
+ memcpy(&AGWTXHeader.callfrom, RegCall, 10);
+
AGWTXHeader.DataLength = 1; // Length
AGWRegReply[0] = 1;
diff --git a/AGWMoncode.c b/AGWMoncode.c
index 7427804..2c26191 100644
--- a/AGWMoncode.c
+++ b/AGWMoncode.c
@@ -49,9 +49,14 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#define DM 0x0F
#define UA 0x63
#define FRMR 0x87
+#define XID 0xAF
+#define TEST 0xE3
#define RR 1
#define RNR 5
#define REJ 9
+#define SREJ 0x0D
+#define SABME 0x6F
+
#define PFBIT 0x10 // POLL/FINAL BIT IN CONTROL BYTE
@@ -261,6 +266,18 @@ int InternalAGWDecodeFrame(MESSAGE * msg, char * buffer, time_t Stamp, int * Fra
strcpy(SUP, "FRMR");
FRMRFLAG = 1;
break;
+
+ case XID:
+
+ strcpy(SUP, "XID");
+ XIDFLAG = 1;
+ break;
+
+ case TEST:
+
+ strcpy(SUP, "TEST");
+ TESTFLAG = 1;
+ break;
}
Output += sprintf((char *)Output, "<%s%s%s>", SUP, CRCHAR, PFCHAR);
@@ -270,7 +287,7 @@ int InternalAGWDecodeFrame(MESSAGE * msg, char * buffer, time_t Stamp, int * Fra
// Super
int NR = (CTL >> 5) & 7;
- char SUP[4] = "??";
+ char SUP[5] = "??";
switch (CTL & 0x0F)
{
@@ -288,6 +305,13 @@ int InternalAGWDecodeFrame(MESSAGE * msg, char * buffer, time_t Stamp, int * Fra
strcpy(SUP, "REJ");
break;
+
+
+ case SREJ:
+
+ strcpy(SUP, "SREJ");
+ break;
+
}
Output += sprintf((char *)Output, "<%s%s%s R%d>", SUP, CRCHAR, PFCHAR, NR);
@@ -300,6 +324,72 @@ int InternalAGWDecodeFrame(MESSAGE * msg, char * buffer, time_t Stamp, int * Fra
if (FRMRFLAG)
Output += sprintf((char *)Output, "%02X %02X %02X", ADJBUFFER->PID, ADJBUFFER->L2DATA[0], ADJBUFFER->L2DATA[1]);
+ if (XIDFLAG)
+ {
+ // Decode and display XID
+
+ UCHAR * ptr = &ADJBUFFER->PID;
+
+ if (*ptr++ == 0x82 && *ptr++ == 0x80)
+ {
+ int Type;
+ int Len;
+ unsigned int value;
+ int xidlen = *(ptr++) << 8;
+ xidlen += *ptr++;
+
+ // XID is set of Type, Len, Value n-tuples
+
+// G8BPQ-2>G8BPQ:(XID cmd, p=1) Half-Duplex SREJ modulo-128 I-Field-Length-Rx=256 Window-Size-Rx=32 Ack-Timer=3000 Retries=10
+
+
+ while (xidlen > 0)
+ {
+ Type = *ptr++;
+ Len = *ptr++;
+
+ value = 0;
+ xidlen -= (Len + 2);
+
+ while (Len--)
+ {
+ value <<=8;
+ value += *ptr++;
+ }
+ switch(Type)
+ {
+ case 2: //Bin fields
+ case 3:
+
+ Output += sprintf((char *)Output, " %d=%x", Type, value);
+ break;
+
+ case 6: //RX Size
+
+ Output += sprintf((char *)Output, " RX Paclen=%d", value / 8);
+ break;
+
+ case 8: //RX Window
+
+ Output += sprintf((char *)Output, " RX Window=%d", value);
+ break;
+
+ case 16:
+
+ Output += sprintf((char *)Output, " Can Compress");
+ break;
+
+ case 17:
+
+ Output += sprintf((char *)Output, " Compress ok");
+ break;
+ }
+ }
+ }
+ }
+
+
+
if (Info)
{
// We have an info frame
diff --git a/ARDOP.c b/ARDOP.c
index a46fe3e..ade0ecf 100644
--- a/ARDOP.c
+++ b/ARDOP.c
@@ -888,6 +888,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
{
if (TNC->SessionTimeLimit && STREAM->ConnectTime && time(NULL) > (TNC->SessionTimeLimit + STREAM->ConnectTime))
{
+ Debugprintf("ARDOP closing session on SessionTimelimit");
ARDOPSendCommand(TNC, "DISCONNECT", TRUE);
STREAM->ReportDISC = 1;
STREAM->AttachTime = 0;
@@ -900,6 +901,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
{
if (STREAM->AttachTime && TNC->AttachTimeLimit && time(NULL) > (TNC->AttachTimeLimit + STREAM->AttachTime))
{
+ Debugprintf("ARDOP closing session on AttachTimelimit");
STREAM->ReportDISC = 1;
STREAM->AttachTime = 0;
}
@@ -2059,21 +2061,12 @@ VOID * ARDOPExtInit(EXTPORTDATA * PortEntry)
strcat(TempScript, "ARQTIMEOUT 90\r");
// strcat(TempScript, "ROBUST False\r");
- strcat(TempScript, TNC->InitScript);
-
- free(TNC->InitScript);
- TNC->InitScript = TempScript;
-
- // Set MYCALL
-
-// strcat(TNC->InitScript,"FECRCV True\r");
-// strcat(TNC->InitScript,"AUTOBREAK True\r");
+ // Make MYAUX and MYCALL overridable
+
sprintf(Msg, "MYCALL %s\r", TNC->NodeCall);
- strcat(TNC->InitScript, Msg);
-// strcat(TNC->InitScript,"PROCESSID\r");
-// strcat(TNC->InitScript,"CODEC TRUE\r");
-// strcat(TNC->InitScript,"LISTEN TRUE\r");
+ strcat(TempScript, Msg);
+
for (i = 0; i < 32; i++)
{
@@ -2097,9 +2090,25 @@ VOID * ARDOPExtInit(EXTPORTDATA * PortEntry)
if (strlen(Aux) > 8)
{
Aux[strlen(Aux) - 1] = '\r';
- strcat(TNC->InitScript, Aux);
+ strcat(TempScript, Aux);
}
+
+ strcat(TempScript, TNC->InitScript);
+
+ free(TNC->InitScript);
+ TNC->InitScript = TempScript;
+
+
+
+// strcat(TNC->InitScript,"FECRCV True\r");
+// strcat(TNC->InitScript,"AUTOBREAK True\r");
+// strcat(TNC->InitScript,"PROCESSID\r");
+// strcat(TNC->InitScript,"CODEC TRUE\r");
+// strcat(TNC->InitScript,"LISTEN TRUE\r");
+
+
+
strcpy(TNC->CurrentMYC, TNC->NodeCall);
if (TNC->WL2K == NULL)
@@ -3141,6 +3150,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
// Incoming Connect
TNC->SessionTimeLimit = TNC->DefaultSessionTimeLimit; // Reset Limit
+ STREAM->AttachTime = time(NULL);
// Stop other ports in same group
diff --git a/BBSHTMLConfig.c b/BBSHTMLConfig.c
index 6207298..027c786 100644
--- a/BBSHTMLConfig.c
+++ b/BBSHTMLConfig.c
@@ -117,6 +117,7 @@ struct UserInfo * FindBBS(char * Name);
void ReleaseWebMailStruct(WebMailInfo * WebMail);
VOID TidyWelcomeMsg(char ** pPrompt);
int MailAPIProcessHTTPMessage(struct HTTPConnectionInfo * Session, char * response, char * Method, char * URL, char * request, BOOL LOCAL, char * Param, char * Token);
+void UndoTransparency(char * input);
char UNC[] = "";
char CHKD[] = "checked=checked ";
@@ -186,7 +187,7 @@ char RefreshMainPage[] = "<html><head>"
char StatusPage [] =
"<form style=\"font-family: monospace; text-align: center\" method=post action=/Mail/DisSession?%s>"
-"<br>User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Callsign&nbsp;&nbsp; Stream Queue<br>"
+"<br>User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Callsign&nbsp;&nbsp; Stream &nbsp;Queue &nbsp;Sent &nbsp;Rxed<br>"
"<select style=\"font-family: monospace;\" tabindex=1 size=10 name=call>";
char StreamEnd[] =
@@ -1701,6 +1702,8 @@ VOID ProcessConfUpdate(struct HTTPConnectionInfo * Session, char * MsgPtr, char
free(Filters);
Filters = NULL;
+ UndoTransparency(input);
+
while (input)
{
// extract and validate before saving
@@ -1714,7 +1717,7 @@ VOID ProcessConfUpdate(struct HTTPConnectionInfo * Session, char * MsgPtr, char
input = strstr(input, "&Type=");
- if (Filter.Action == 'H' || Filter.Action == 'R')
+ if (Filter.Action == 'H' || Filter.Action == 'R' || Filter.Action == 'A')
{
Filter.Type = toupper(input[6]);
input = strstr(input, "&From=");
@@ -2755,6 +2758,19 @@ VOID SendUIPage(char * Reply, int * ReplyLen, char * Key)
*ReplyLen = Len;
}
+void ConvertSpaceTonbsp(char * msg)
+{
+ // Replace any space with &nbsp;
+
+ char * ptr;
+
+ while (ptr = strchr(msg, ' '))
+ {
+ memmove(ptr + 5, ptr, strlen(ptr) + 1);
+ memcpy(ptr, "&nbsp;", 6);
+ }
+}
+
VOID SendStatusPage(char * Reply, int * ReplyLen, char * Key)
{
int Len;
@@ -2777,6 +2793,8 @@ VOID SendStatusPage(char * Reply, int * ReplyLen, char * Key)
{
strcpy(msg,"Idle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n");
}
else
@@ -2789,16 +2807,16 @@ VOID SendStatusPage(char * Reply, int * ReplyLen, char * Key)
strcpy(Name, conn->UserPointer->Name);
Name[9] = 0;
- i=sprintf_s(msg, sizeof(msg), "%s%s%s%s%2d&nbsp;%5d\r\n",
+ i=sprintf_s(msg, sizeof(msg), "%-12s %-9s %3d %6d%6d%6d\r\n",
Name,
- &TenSpaces[strlen(Name) * 6],
conn->UserPointer->Call,
- &TenSpaces[strlen(conn->UserPointer->Call) * 6],
conn->BPQStream,
- conn->OutputQueueLength - conn->OutputGetPointer);
+ conn->OutputQueueLength - conn->OutputGetPointer, conn->bytesSent, conn->bytesRxed);
}
}
}
+
+ ConvertSpaceTonbsp(msg);
Len += sprintf(&Reply[Len], StatusLine, conn->BPQStream, msg);
}
diff --git a/BBSUtilities.c b/BBSUtilities.c
index 72a2371..90b4c7b 100644
--- a/BBSUtilities.c
+++ b/BBSUtilities.c
@@ -69,6 +69,10 @@ extern BPQVECSTRUC ** BPQHOSTVECPTR;
UCHAR * GetLogDirectory();
DllExport int APIENTRY SessionStateNoAck(int stream, int * state);
int RefreshWebMailIndex();
+struct PORTCONTROL * GetPortTableEntryFromSlot(int portslot);
+int GetPortHardwareType(struct PORTCONTROL *PORT);
+int GetNumberofPorts();
+
#else
__declspec(dllimport) BPQVECSTRUC ** BPQHOSTVECPTR;
typedef char * (WINAPI FAR *FARPROCZ)();
@@ -2085,6 +2089,7 @@ hold certain types or sizes of messages.
The first letter of each valid line specifies the action :
+A = Accept : Message is accepted without checking other filters
R = Reject : The message will not be received.
H = Hold : The message will be received but held until the sysop reviews.
L = Local Hold : Only messages created on this BBS will be held.
@@ -2179,21 +2184,38 @@ BOOL CheckRejFilters(char * From, char * To, char * ATBBS, char * BID, char Type
while (p)
{
- if (p->Action != 'R')
+ if (p->Action != 'R' && p->Action != 'A')
goto Continue;
if (p->Type != Type && p->Type != '*')
goto Continue;
+ // wildcardcompare returns true on a match
+
if (wildcardcompare(From, p->From) == 0)
goto Continue;
- if (wildcardcompare(ToCopy, p->TO) == 0)
- goto Continue;
+ if (p->TO[0] == '!')
+ {
+ if (wildcardcompare(ToCopy, &p->TO[1]) == 1)
+ goto Continue;
+ }
+ else
+ {
+ if (wildcardcompare(ToCopy, p->TO) == 0)
+ goto Continue;
+ }
if (ATBBS)
- if (wildcardcompare(ATBBS, p->AT) == 0)
+ {
+ char AtCopy[256];
+
+ strcpy(AtCopy, ATBBS);
+ _strupr(AtCopy);
+
+ if (wildcardcompare(AtCopy, p->AT) == 0)
goto Continue;
+ }
if (BID)
if (wildcardcompare(BID, p->BID) == 0)
@@ -2202,6 +2224,11 @@ BOOL CheckRejFilters(char * From, char * To, char * ATBBS, char * BID, char Type
if (p->MaxLen && Len < p->MaxLen)
goto Continue;
+ // if type 'A' matches all rules then accept without checking rest
+
+ if (p->Action == 'A')
+ return FALSE;
+
return TRUE; // Hold
Continue:
@@ -2244,6 +2271,7 @@ BOOL CheckHoldFilters(struct MsgInfo * Msg, char * From, char * To, char * ATBBS
{
char ** Calls;
FBBFilter * p = Filters;
+ char ToCopy[256];
if (HoldFrom && From)
{
@@ -2307,6 +2335,9 @@ BOOL CheckHoldFilters(struct MsgInfo * Msg, char * From, char * To, char * ATBBS
// check fbb reject.sys type filters
+ strcpy(ToCopy, To);
+ _strupr(ToCopy);
+
while (p)
{
if (p->Action != 'H')
@@ -2318,9 +2349,16 @@ BOOL CheckHoldFilters(struct MsgInfo * Msg, char * From, char * To, char * ATBBS
if (wildcardcompare(Msg->from, p->From) == 0)
goto Continue;
- if (wildcardcompare(Msg->to, p->TO) == 0)
- goto Continue;
-
+ if (p->TO[0] == '!')
+ {
+ if (wildcardcompare(ToCopy, &p->TO[1]) == 1)
+ goto Continue;
+ }
+ else
+ {
+ if (wildcardcompare(ToCopy, p->TO) == 0)
+ goto Continue;
+ }
if (wildcardcompare(Msg->via, p->AT) == 0)
goto Continue;
@@ -3388,6 +3426,7 @@ void Flush(CIRCUIT * conn)
SendUnbuffered(conn->BPQStream, &conn->OutputQueue[conn->OutputGetPointer], len);
conn->OutputGetPointer+=len;
+ conn->bytesSent += len;
tosend-=len;
SendUnbuffered(conn->BPQStream, "<A>bort, <CR> Continue..>", 25);
FreeSemaphore(&OutputSEM);
@@ -3399,6 +3438,7 @@ void Flush(CIRCUIT * conn)
}
SendUnbuffered(conn->BPQStream, &conn->OutputQueue[conn->OutputGetPointer], len);
+ conn->bytesSent += len;
conn->OutputGetPointer+=len;
@@ -5216,7 +5256,6 @@ char * CheckToAddress(CIRCUIT * conn, char * Addr)
return NewAddr;
}
}
- else
{
WPRecP WP = LookupWP(Addr);
@@ -5437,7 +5476,18 @@ BOOL DecodeSendParams(CIRCUIT * conn, char * Context, char ** From, char *To, ch
}
else
{
- conn->LocalMsg = TRUE;
+ // See if a WP entry
+
+ WP = LookupWP(To);
+
+ if (WP)
+ {
+ *ATBBS = WP->first_homebbs;
+ nodeprintf(conn, "Address @%s added from WP\r", *ATBBS);
+ conn->LocalMsg = FALSE;
+ }
+ else
+ conn->LocalMsg = TRUE;
}
}
else
@@ -9016,6 +9066,10 @@ CheckForSID:
return TRUE;
}
+#ifndef LINBPQ
+extern FARPROCX pGetPortHardwareType;
+#endif
+
VOID Parse_SID(CIRCUIT * conn, char * SID, int len)
{
ChangeSessionIdletime(conn->BPQStream, BBSIDLETIME); // Default Idletime for BBS Sessions
@@ -9072,10 +9126,44 @@ VOID Parse_SID(CIRCUIT * conn, char * SID, int len)
{
// We should really only do this on Telnet Connections, as OpenBCM flag is used to remove relnet transparency
+ // See if Telnet
+
+ struct PORTCONTROL * PORT;
+ char Call[11] = "";
+ int port, dummy;
+
+ GetConnectionInfo(conn->BPQStream, Call, &port, &dummy, &dummy, &dummy, &dummy);
+
+ PORT = GetPortTableEntryFromSlot(0); // Get first entry
+
+ do
+ {
+ if (PORT->PORTNUMBER == port)
+ break;
+
+ PORT=PORT->PORTPOINTER;
+
+ } while (PORT);
+
+#define H_TELNET 6
+
+#ifndef LINBPQ
+
+ if (pGetPortHardwareType)
+ {
+ if (PORT && GetPortHardwareType(PORT) == H_TELNET)
+ conn->OpenBCM = TRUE;
+ }
+ else
+ conn->OpenBCM = TRUE; // Old Node version so follow old behavoiur and treat all as telnet
+#else
+ if (PORT && GetPortHardwareType(PORT) == H_TELNET)
+ conn->OpenBCM = TRUE;
+#endif
- conn->OpenBCM = TRUE;
}
+
if (_memicmp(SID, "PMS-3.2", 7) == 0)
{
// Paccom TNC that doesn't send newline prompt ater receiving subject
@@ -10245,7 +10333,7 @@ BOOL GetConfig(char * ConfigName)
GetStringValue(group, "ISPAccountPass", EncryptedISPAccountPass, 100);
sprintf(SignoffMsg, "73 de %s\r", BBSName); // Default
- GetStringValue(group, "SignoffMsg", ISPAccountName, 50);
+ GetStringValue(group, "SignoffMsg", SignoffMsg, 50);
DecryptPass(EncryptedISPAccountPass, ISPAccountPass, (int)strlen(EncryptedISPAccountPass));
@@ -10550,7 +10638,7 @@ int Connected(int Stream)
char callsign[10];
int port, paclen, maxframe, l4window;
char ConnectedMsg[] = "*** CONNECTED ";
- char Msg[100];
+ char Msg[256];
char Title[100];
int64_t Freq = 0;
int Mode = 0;
@@ -10633,7 +10721,13 @@ int Connected(int Stream)
}
}
}
-
+
+ if (Mode < 0 || Mode > 54)
+ Mode = 0;
+
+ if (Freq < 0 || Freq > 11000000000)
+ Freq = 0;
+
memset(conn, 0, sizeof(ConnectionInfo)); // Clear everything
conn->Active = TRUE;
conn->BPQStream = Stream;
@@ -10698,7 +10792,7 @@ int Connected(int Stream)
LongFreq = GetPortFrequency(port, FreqString);
#endif
}
- Length += sprintf(MailBuffer, "New User %s Connected to Mailbox on Port %d Freq %d Mode %ld\r\n", callsign, port, LongFreq, Mode);
+ Length += sprintf(MailBuffer, "New User %s Connected to Mailbox on Port %d Freq %lld Mode %d\r\n", callsign, port, LongFreq, Mode);
sprintf(Title, "New User %s", callsign);
@@ -10758,10 +10852,10 @@ int Connected(int Stream)
}
if (port)
- n=sprintf_s(Msg, sizeof(Msg), "Incoming Connect from %s on Port %d Freq %d Mode %s",
+ n = sprintf_s(Msg, sizeof(Msg), "Incoming Connect from %s on Port %d Freq %lld Mode %s",
user->Call, port, Freq, WL2KModes[Mode]);
else
- n=sprintf_s(Msg, sizeof(Msg), "Incoming Connect from %s", user->Call);
+ n = sprintf_s(Msg, sizeof(Msg), "Incoming Connect from %s", user->Call);
// Send SID and Prompt (Unless Sync)
@@ -11051,7 +11145,6 @@ int DoReceivedData(int Stream)
if (Stream == conn->BPQStream)
{
conn->SIDResponseTimer = 0; // Got a message, so cancel timeout.
-
do
{
// May have several messages per packet, or message split over packets
@@ -11068,6 +11161,7 @@ int DoReceivedData(int Stream)
if (InputLen == 0 && conn->InputMode != 'Y')
return 0;
+ conn->bytesRxed += InputLen;
conn->InputLen += InputLen;
if (conn->InputLen == 0) return 0;
diff --git a/BPQINP3.c b/BPQINP3.c
index dcc17c6..aa4929c 100644
--- a/BPQINP3.c
+++ b/BPQINP3.c
@@ -37,6 +37,9 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
uint64_t timeLoadedMS = 0;
+VOID SendNegativeInfo();
+VOID SortRoutes(struct DEST_LIST * Dest);
+VOID SendRTTMsg(struct ROUTE * Route);
static VOID SendNetFrame(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Frame)
{
@@ -71,9 +74,9 @@ 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 UpdateRoute(struct DEST_LIST * Dest, struct DEST_ROUTE_ENTRY * ROUTEPTR, int hops, int rtt);
-VOID KillRoute(struct DEST_ROUTE_ENTRY * ROUTEPTR);
-VOID AddHere(struct DEST_ROUTE_ENTRY * ROUTEPTR,struct ROUTE * Route , int hops, int rtt);
+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);
VOID SendRIPToNeighbour(struct ROUTE * Route);
VOID DecayNETROMRoutes(struct ROUTE * Route);
VOID DeleteINP3Routes(struct ROUTE * Route);
@@ -133,8 +136,14 @@ VOID DeleteINP3Routes(struct ROUTE * Route)
{
int i;
struct DEST_LIST * Dest = DESTS;
+ char Call1[10];
+ char Call2[10];
- // Delete any NETROM Dest entries via this Route
+ Call1[ConvFromAX25(Route->NEIGHBOUR_CALL, Call1)] = 0;
+
+ Debugprintf("Deleting INP3 routes via %s", Call1);
+
+ // Delete any INP3 Dest entries via this Route
Route->SRTT = 0;
Route->RTT = 0;
@@ -156,48 +165,65 @@ VOID DeleteINP3Routes(struct ROUTE * Route)
if (Dest->NRROUTE[0].ROUT_OBSCOUNT >= 128) // Not if locked
continue;
- if (Dest->ROUTE[0].ROUT_NEIGHBOUR == Route)
+ Call2[ConvFromAX25(Dest->DEST_CALL, Call2)] = 0;
+
+ if (Dest->INP3ROUTE[0].ROUT_NEIGHBOUR == Route)
{
- // We are deleting the best route, so need to tell other nodes
+ // We are deleting the best INP3 route, so need to tell other nodes
// If this is the only one, we need to keep the entry with at 60000 rtt so
// we can send it. Remove when all gone
// How do we indicate is is dead - Maybe the 60000 is enough!
- if (Dest->ROUTE[1].ROUT_NEIGHBOUR == 0)
+
+ // If we are cleaning up after a sabm on an existing link (frmr or other end reloaded) then we don't need to tell anyone - the routes should be reestablished very quickly
+
+ Debugprintf("Deleting First INP3 Route to %s", Call2);
+
+ if (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR == 0)
{
+
// Only entry
- Dest->ROUTE[0].SRTT = 60000;
- Dest->ROUTE[0].Hops = 255;
+ Dest->INP3ROUTE[0].SRTT = 60000;
+ Dest->INP3ROUTE[0].Hops = 255;
+
+ Debugprintf("Was the only INP3 route");
+
+ if (Dest->DEST_ROUTE == 4) // we were using it
+ Dest->DEST_ROUTE = 0;
continue;
}
- Dest->ROUTE[1].LastRTT = Dest->ROUTE[0].SRTT; // So next scan will check if rtt has increaced
- // enough to need a RIF
-
- memcpy(&Dest->ROUTE[0], &Dest->ROUTE[1], sizeof(struct DEST_ROUTE_ENTRY));
- memcpy(&Dest->ROUTE[1], &Dest->ROUTE[2], sizeof(struct DEST_ROUTE_ENTRY));
- memset(&Dest->ROUTE[2], 0, sizeof(struct DEST_ROUTE_ENTRY));
+ Dest->INP3ROUTE[1].LastRTT = Dest->INP3ROUTE[0].SRTT; // So next scan will check if rtt has increaced enough to need a RIF
+ 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));
continue;
}
// If we aren't removing the best, we don't need to tell anyone.
- if (Dest->ROUTE[1].ROUT_NEIGHBOUR == Route)
+ if (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR == Route)
{
- memcpy(&Dest->ROUTE[1], &Dest->ROUTE[2], sizeof(struct DEST_ROUTE_ENTRY));
- memset(&Dest->ROUTE[2], 0, sizeof(struct DEST_ROUTE_ENTRY));
+ Debugprintf("Deleting 2nd INP3 Route to %s", Call2);
+ memcpy(&Dest->INP3ROUTE[1], &Dest->INP3ROUTE[2], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memset(&Dest->INP3ROUTE[2], 0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
continue;
}
- if (Dest->ROUTE[2].ROUT_NEIGHBOUR == Route)
+ if (Dest->INP3ROUTE[2].ROUT_NEIGHBOUR == Route)
{
- memset(&Dest->ROUTE[2], 0, sizeof(struct DEST_ROUTE_ENTRY));
+ Debugprintf("Deleting 3rd INP3 Route to %s", Call2);
+ memset(&Dest->INP3ROUTE[2], 0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
continue;
}
}
+
+ // I think we should send Negative info immediately
+
+ SendNegativeInfo();
}
VOID DecayNETROMRoutes(struct ROUTE * Route)
@@ -233,7 +259,7 @@ VOID DecayNETROMRoutes(struct ROUTE * Route)
if (Dest->NRROUTE[1].ROUT_NEIGHBOUR == 0) // No more Netrom Routes
{
- if (Dest->ROUTE[0].ROUT_NEIGHBOUR == 0) // Any INP3 ROutes?
+ if (Dest->INP3ROUTE[0].ROUT_NEIGHBOUR == 0) // Any INP3 ROutes?
{
// No More Routes - ZAP Dest
@@ -306,19 +332,9 @@ VOID ProcessRTTReply(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff)
int RTT;
unsigned int OrigTime;
- if ((Route->Status & GotRTTResponse) == 0)
- {
- // Link is just starting
+ char Normcall[10];
- Route->Status |= GotRTTResponse;
-
- if (Route->Status & GotRTTRequest)
- {
- Route->Status |= SentOurRIF;
- SendOurRIF(Route);
- SendRIPToNeighbour(Route);
- }
- }
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_CALL, Normcall)] = 0;
Route->Timeout = 0; // Got Response
@@ -334,6 +350,16 @@ VOID ProcessRTTReply(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff)
Route->SRTT = RTT;
else
Route->SRTT = ((Route->SRTT * 80)/100) + ((RTT * 20)/100);
+
+ if ((Route->Status & GotRTTResponse) == 0)
+ {
+ // Link is just starting
+
+ Debugprintf("INP3 got first RTT reply from %s - Link is (Re)staring", Normcall);
+
+ Route->Status |= GotRTTResponse;
+ }
+
}
VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
@@ -345,6 +371,13 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
int opcode;
char alias[6];
UINT Stamp, HH, MM;
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_LINK->LINKCALL, Normcall)] = 0;
+ Debugprintf("Processing RIF from %s INP3Node %d Route SRTT %d", Normcall, Route->INP3Node, Route->SRTT);
+
+ if (Route->SRTT == 0)
+ Debugprintf("INP3 Zero SRTT");
#ifdef NOINP3
@@ -386,10 +419,9 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
rtt = (*ptr1++ << 8);
rtt += *ptr1++;
- // rtt is value from remote node. Add our RTT to that node and update hops
+ // rtt is value from remote node. Add our RTT to that node
rtt += Route->SRTT;
- hops++;
msglen -= 10;
@@ -424,7 +456,7 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port)
return;
}
-VOID KillRoute(struct DEST_ROUTE_ENTRY * ROUTEPTR)
+VOID KillRoute(struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR)
{
}
@@ -432,32 +464,71 @@ VOID KillRoute(struct DEST_ROUTE_ENTRY * ROUTEPTR)
VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops, int rtt)
{
struct DEST_LIST * Dest;
- struct DEST_ROUTE_ENTRY * ROUTEPTR;
+ struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR;
int i;
char call[11]="";
+ APPLCALLS * APPL;
+ int App;
+ char Normcall[10];
+ Normcall[ConvFromAX25(axcall, Normcall)] = 0;
+
+
+// SEE IF any of OUR CALLs - DONT WANT TO PUT IT IN LIST!
+
+ if (CompareCalls(axcall, NETROMCALL))
+ {
+ Debugprintf("INP3 for our Nodecall - discarding");
+ return;
+ }
+
+ if (CheckExcludeList(axcall) == 0)
+ {
+ Debugprintf("INP3 excluded - discarding");
+ return;
+ }
+
+ for (App = 0; App < NumberofAppls; App++)
+ {
+ APPL=&APPLCALLTABLE[App];
+
+ if (APPL->APPLHASALIAS == 0 && CompareCalls(axcall, APPL->APPLCALL))
+ {
+ Debugprintf("INP3 for an APPLCALL - discarding");
+ return;
+ }
+ }
+
if (hops > MaxHops && hops < 255)
{
-// ConvFromAX25(axcall, call);
-// Debugprintf("Node %s Hops %d RTT %d Ignored - Hop Count too high", call, hops, rtt);
+ ConvFromAX25(axcall, call);
+ Debugprintf("INP3 Node %s Hops %d RTT %d Ignored - Hop Count too high", call, hops, rtt);
return;
}
if (rtt > MAXRTT && rtt < 60000)
{
-// ConvFromAX25(axcall, call);
-// Debugprintf("Node %s Hops %d RTT %d Ignored - rtt too high", call, hops, rtt);
+ ConvFromAX25(axcall, call);
+ Debugprintf("INP3 Node %s Hops %d RTT %d Ignored - rtt too high", call, hops, rtt);
return;
}
+ if (rtt >= 60000)
+ {
+ Debugprintf("INP3 RTT > 60000 - discarding");
+ return;
+ }
+
if (FindDestination(axcall, &Dest))
goto Found;
if (Dest == NULL)
- return; // Tsble Full
-
- if (rtt >= 60000)
- return; // No Point addind a new dead route
+ {
+ Debugprintf("INP3 Table Full - discarding");
+ return; // Table Full
+ }
+
+
memset(Dest, 0, sizeof(struct DEST_LIST));
@@ -466,58 +537,63 @@ VOID UpdateNode(struct ROUTE * Route, UCHAR * axcall, UCHAR * alias, int hops,
// Set up First Route
- Dest->ROUTE[0].Hops = hops;
- Dest->ROUTE[0].SRTT = rtt;
- Dest->ROUTE[0].LastRTT = 0;
+ Dest->INP3ROUTE[0].Hops = hops;
+ Dest->INP3ROUTE[0].SRTT = rtt;
+ Dest->INP3ROUTE[0].LastRTT = 0;
Dest->INP3FLAGS = NewNode;
- Dest->ROUTE[0].ROUT_NEIGHBOUR = Route;
+ Dest->INP3ROUTE[0].ROUT_NEIGHBOUR = Route;
NUMBEROFNODES++;
ConvFromAX25(Dest->DEST_CALL, call);
- Debugprintf("Adding Node %s Hops %d RTT %d", call, hops, rtt);
+ Debugprintf("INP3 Adding New Node %s Hops %d RTT %d", call, hops, rtt);
return;
Found:
if (Dest->DEST_STATE & 0x80) // Application Entry
- return;
+ {
+ Debugprintf("INP3 Application Entry - discarding");
+ return; // Tsble Full
+ }
// Update ALIAS
+ ConvFromAX25(Dest->DEST_CALL, call);
+ Debugprintf("INP3 Updating Node %s Hops %d RTT %d", call, hops, rtt);
+
+
if (alias[0] > ' ')
memcpy(Dest->DEST_ALIAS, alias, 6);
// See if we are known to it, it not add
- ROUTEPTR = &Dest->ROUTE[0];
-
- if (rtt >= 60000)
- {
- i=rtt+1;
- }
+ ROUTEPTR = &Dest->INP3ROUTE[0];
if (ROUTEPTR->ROUT_NEIGHBOUR == Route)
{
+ Debugprintf("INP3 Already have as route[0] - updating");
UpdateRoute(Dest, ROUTEPTR, hops, rtt);
return;
}
- ROUTEPTR = &Dest->ROUTE[1];
+ ROUTEPTR = &Dest->INP3ROUTE[1];
if (ROUTEPTR->ROUT_NEIGHBOUR == Route)
{
+ Debugprintf("INP3 Already have as route[1] - updating");
UpdateRoute(Dest, ROUTEPTR, hops, rtt);
return;
}
- ROUTEPTR = &Dest->ROUTE[2];
+ ROUTEPTR = &Dest->INP3ROUTE[2];
if (ROUTEPTR->ROUT_NEIGHBOUR == Route)
{
+ Debugprintf("INP3 Already have as route[2] - updating");
UpdateRoute(Dest, ROUTEPTR, hops, rtt);
return;
}
@@ -525,64 +601,68 @@ Found:
// Not in list. If any spare, add.
// If full, see if this is better
- if (rtt >= 60000)
- return; // No Point addind a new dead route
-
- ROUTEPTR = &Dest->ROUTE[0];
-
- for (i = 1; i < 4; i++)
+ for (i = 0; i < 3; i++)
{
+ ROUTEPTR = &Dest->INP3ROUTE[i];
+
if (ROUTEPTR->ROUT_NEIGHBOUR == NULL)
{
// Add here
- Dest->ROUTE[0].Hops = hops;
- Dest->ROUTE[0].SRTT = rtt;
- Dest->ROUTE[0].ROUT_NEIGHBOUR = Route;
-
+ Debugprintf("INP3 adding as route[%d]", i);
+ AddHere(ROUTEPTR, Route, hops, rtt);
+ SortRoutes(Dest);
return;
}
ROUTEPTR++;
}
+ Debugprintf("INP3 All entries in use - see if this is better than existing");
+
// Full, see if this is better
// Note that wont replace any netrom routes with INP3 ones unless we add pseudo rtt values to netrom entries
- if (Dest->ROUTE[0].SRTT > rtt)
+ if (Dest->INP3ROUTE[0].SRTT > rtt)
{
// We are better. Move others down and add on front
- memcpy(&Dest->ROUTE[2], &Dest->ROUTE[1], sizeof(struct DEST_ROUTE_ENTRY));
- memcpy(&Dest->ROUTE[1], &Dest->ROUTE[0], sizeof(struct DEST_ROUTE_ENTRY));
+ Debugprintf("INP3 Replacing route 0");
- AddHere(&Dest->ROUTE[0], Route, hops, rtt);
+ memcpy(&Dest->INP3ROUTE[2], &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ memcpy(&Dest->INP3ROUTE[1], &Dest->INP3ROUTE[0], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ AddHere(&Dest->INP3ROUTE[0], Route, hops, rtt);
return;
}
- if (Dest->ROUTE[1].SRTT > rtt)
+ if (Dest->INP3ROUTE[1].SRTT > rtt)
{
// We are better. Move 2nd down and add
- memcpy(&Dest->ROUTE[2], &Dest->ROUTE[1], sizeof(struct DEST_ROUTE_ENTRY));
-
- AddHere(&Dest->ROUTE[1], Route, hops, rtt);
+ Debugprintf("INP3 Replacing route 1");
+ memcpy(&Dest->INP3ROUTE[2], &Dest->INP3ROUTE[1], sizeof(struct INP3_DEST_ROUTE_ENTRY));
+ AddHere(&Dest->INP3ROUTE[1], Route, hops, rtt);
return;
}
- if (Dest->ROUTE[2].SRTT > rtt)
+ if (Dest->INP3ROUTE[2].SRTT > rtt)
{
// We are better. Add here
- AddHere(&Dest->ROUTE[2], Route, hops, rtt);
+ Debugprintf("INP3 Replacing route 2");
+ AddHere(&Dest->INP3ROUTE[2], Route, hops, rtt);
return;
}
- // Worse than any - ignoee
+
+ Debugprintf("INP3 Worse that any existing route");
+
+
+ // Worse than any - ignore
}
-VOID AddHere(struct DEST_ROUTE_ENTRY * ROUTEPTR,struct ROUTE * Route , int hops, int rtt)
+VOID AddHere(struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR,struct ROUTE * Route , int hops, int rtt)
{
ROUTEPTR->Hops = hops;
ROUTEPTR->SRTT = rtt;
@@ -642,39 +722,123 @@ NOTBADROUTE:
JMP SENDOK
*/
+
+struct INP3_DEST_ROUTE_ENTRY Temp;
VOID SortRoutes(struct DEST_LIST * Dest)
{
- struct DEST_ROUTE_ENTRY Temp;
+ char Call1[10], Call2[10], Call3[10];
+
// May now be out of order
- if (Dest->ROUTE[1].ROUT_NEIGHBOUR == 0)
+ if (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR == 0)
+ {
+ Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Debugprintf("INP3 1 route %d %s", Dest->INP3ROUTE[0].SRTT, Call1);
return; // Only One, so cant be out of order
-
- if (Dest->ROUTE[2].ROUT_NEIGHBOUR == 0)
+ }
+ if (Dest->INP3ROUTE[2].ROUT_NEIGHBOUR == 0)
{
// Only 2
- if (Dest->ROUTE[0].SRTT <= Dest->ROUTE[1].SRTT)
+ Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+
+ Debugprintf("INP3 2 routes %d %s %d %s", Dest->INP3ROUTE[0].SRTT, Call1, Dest->INP3ROUTE[1].SRTT, Call2);
+
+ if (Dest->INP3ROUTE[0].SRTT <= Dest->INP3ROUTE[1].SRTT)
return;
// Swap one and two
- memcpy(&Temp, &Dest->ROUTE[0], sizeof(struct DEST_ROUTE_ENTRY));
- memcpy(&Dest->ROUTE[0], &Dest->ROUTE[1], sizeof(struct DEST_ROUTE_ENTRY));
- memcpy(&Dest->ROUTE[1], &Temp, sizeof(struct DEST_ROUTE_ENTRY));
+ 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));
+ Call1[ConvFromAX25(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call1)] = 0;
+ Call2[ConvFromAX25(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Call2)] = 0;
+
+ Debugprintf("INP3 2 routes %d %s %d %s", Dest->INP3ROUTE[0].SRTT, Call1, Dest->INP3ROUTE[1].SRTT, 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;
+
+ Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].SRTT, Call1, Dest->INP3ROUTE[1].SRTT, Call2, Dest->INP3ROUTE[2].SRTT, Call3);
+
+ // In order?
+
+ if (Dest->INP3ROUTE[0].SRTT <= Dest->INP3ROUTE[1].SRTT && Dest->INP3ROUTE[1].SRTT <= Dest->INP3ROUTE[2].SRTT)// In order?
+ return;
+
+ // If second is better that first swap
+
+ if (Dest->INP3ROUTE[0].SRTT > Dest->INP3ROUTE[1].SRTT)
+ {
+ 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));
+ }
+
+
+ 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;
+
+ Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].SRTT, Call1, Dest->INP3ROUTE[1].SRTT, Call2, Dest->INP3ROUTE[2].SRTT, Call3);
+
+ // if 3 is better than 2 swap them. As two is worse than one. three will then be worst
+
+ if (Dest->INP3ROUTE[1].SRTT > Dest->INP3ROUTE[2].SRTT)
+ {
+ 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));
+ }
+
+
+ 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;
+
+ Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].SRTT, Call1, Dest->INP3ROUTE[1].SRTT, Call2, Dest->INP3ROUTE[2].SRTT, Call3);
+
+ // 3 is now slowest. 2 could still be better than 1
+
+
+ if (Dest->INP3ROUTE[0].SRTT > Dest->INP3ROUTE[1].SRTT)
+ {
+ 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));
+ }
+
+
+ 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;
+
+ Debugprintf("INP3 3 routes %d %s %d %s %d %s", Dest->INP3ROUTE[0].SRTT, Call1, Dest->INP3ROUTE[1].SRTT, Call2, Dest->INP3ROUTE[2].SRTT, Call3);
+
+ if (Dest->INP3ROUTE[0].SRTT <= Dest->INP3ROUTE[1].SRTT && Dest->INP3ROUTE[1].SRTT <= Dest->INP3ROUTE[2].SRTT)// In order?
+ return;
+
+ // Something went wrong
+
+ Debugprintf("INP3 Sort Failed");
+
}
-VOID UpdateRoute(struct DEST_LIST * Dest, struct DEST_ROUTE_ENTRY * ROUTEPTR, int hops, int rtt)
+VOID UpdateRoute(struct DEST_LIST * Dest, struct INP3_DEST_ROUTE_ENTRY * ROUTEPTR, int hops, int rtt)
{
if (ROUTEPTR->Hops == 0)
{
@@ -706,60 +870,70 @@ VOID UpdateRoute(struct DEST_LIST * Dest, struct DEST_ROUTE_ENTRY * ROUTEPTR, in
VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len, int Port)
{
+ int OtherRTT;
+ int Dummy;
+
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_LINK->LINKCALL, Normcall)] = 0;
+
// See if a reply to our message, or a new request
if (memcmp(Buff->L3SRCE, MYCALL,7) == 0)
{
ProcessRTTReply(Route, Buff);
ReleaseBuffer(Buff);
+ return;
}
- else
+
+ if (Route->NEIGHBOUR_LINK->LINKPORT->ALLOWINP3)
+ Route->INP3Node = 1;
+
+ if (Route->INP3Node == 0)
{
- int OtherRTT;
- int Dummy;
-
- if (Route->INP3Node == 0)
- {
- ReleaseBuffer(Buff);
- return; // We don't want to use INP3
- }
+ Debugprintf("Ignoring RTT Msg from %s - not using INP3", Normcall);
+ ReleaseBuffer(Buff);
+ return; // We don't want to use INP3
+ }
- // Extract other end's SRTT
+ // Extract other end's SRTT
- sscanf(&Buff->L4DATA[6], "%d %d", &Dummy, &OtherRTT);
- Route->NeighbourSRTT = OtherRTT * 10; // We store in mS
+ sscanf(&Buff->L4DATA[6], "%d %d", &Dummy, &OtherRTT);
+ Route->NeighbourSRTT = OtherRTT * 10; // We store in mS
- // Echo Back to sender
-
- SendNetFrame(Route, Buff);
+ // Echo Back to sender
- if ((Route->Status & GotRTTRequest) == 0)
- {
- // Link is just starting
+ SendNetFrame(Route, Buff);
- Route->Status |= GotRTTRequest;
-
- if (Route->Status & GotRTTResponse)
- {
- Route->Status |= SentOurRIF;
- SendOurRIF(Route);
- SendRIPToNeighbour(Route);
+ if ((Route->Status & GotRTTRequest) == 0)
+ {
+ // Link is just starting
- }
- else
- {
- // We have not yet seen a response (and maybe haven't sent one
+ Debugprintf("INP3 Processing first RTT frame from %s - link is (re)starting", Normcall);
+ Route->Status |= GotRTTRequest;
+
+ // I don't think we should send RIF until we get an RTT response.
+
+ if ((Route->Status & SentRTTRequest) == 0) // Not sent one yet so send it
+ SendRTTMsg(Route);
+
+ // No, it's the other end that must have an rrt response and we've just sent it
+
+ Route->Status |= SentOurRIF;
+ SendOurRIF(Route);
+ SendRIPToNeighbour(Route);
- Route->BCTimer = 0; // So send one
- }
- }
}
}
+
VOID SendRTTMsg(struct ROUTE * Route)
{
struct _L3MESSAGEBUFFER * Msg;
char Stamp[50];
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_CALL, Normcall)] = 0;
Msg = GetBuff();
if (Msg == 0)
@@ -788,6 +962,14 @@ VOID SendRTTMsg(struct ROUTE * Route)
Route->Timeout = RTTTimeout;
SendNetFrame(Route, Msg);
+
+ if (Route->Status & SentRTTRequest)
+ return;
+
+ Route->Status |= SentRTTRequest;
+
+ Debugprintf("INP3 Sending first RTT Msg to %s", Normcall);
+
}
VOID SendKeepAlive(struct ROUTE * Route)
@@ -821,7 +1003,9 @@ int BuildRIF(UCHAR * RIF, UCHAR * Call, UCHAR * Alias, int Hops, int RTT)
int RIFLen;
UCHAR AliasCopy[10] = "";
UCHAR * ptr;
+ char Normcall[10];
+ Normcall[ConvFromAX25(Call, Normcall)] = 0;
if (RTT > 60000) RTT = 60000; // Dont send more than 60000
@@ -848,9 +1032,12 @@ int BuildRIF(UCHAR * RIF, UCHAR * Call, UCHAR * Alias, int Hops, int RTT)
RIF[12+AliasLen] = 0;
RIFLen = 13 + AliasLen;
+ Debugprintf("INP3 sending RIF Entry %s:%s %d %d", AliasCopy, Normcall, Hops, RTT);
return RIFLen;
}
RIF[10] = 0;
+
+ Debugprintf("INP3 sending RIF Entry %s %d %d", Normcall, Hops, RTT);
return (11);
}
@@ -863,11 +1050,17 @@ VOID SendOurRIF(struct ROUTE * Route)
int totLen = 1;
int App;
APPLCALLS * APPL;
+ char Normcall[10];
Msg = GetBuff();
if (Msg == 0)
return;
+
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_LINK->LINKCALL, Normcall)] = 0;
+ Debugprintf("INP3 Sending Initial RIF to %s ", Normcall);
+
+
Msg->L3SRCE[0] = 0xff;
// send a RIF for our Node and all our APPLCalls
@@ -898,6 +1091,8 @@ int SendRIPTimer()
struct ROUTE * Route = NEIGHBOURS;
int MaxRoutes = MAXNEIGHBOURS;
int INP3Delay;
+ char Normcall[10];
+
for (count=0; count<MaxRoutes; count++)
{
@@ -946,6 +1141,12 @@ int SendRIPTimer()
// Try to activate link
+ if (Route->INP3Node)
+ {
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_CALL, Normcall)] = 0;
+ Debugprintf("INP3 Activating link to %s", Normcall);
+ }
+
L2SETUPCROSSLINKEX(Route, 2); // Only try SABM twice
Route->LastConnectAttempt = REALTIMETICKS;
@@ -1007,7 +1208,7 @@ int SendRIPTimer()
char Call [11] = "";
ConvFromAX25(Route->NEIGHBOUR_CALL, Call);
- Debugprintf("BPQ32 INP Neighbour %s Lost", Call);
+ Debugprintf("BPQ32 INP3 Neighbour %s Lost", Call);
Route->Status = 0; // Down
}
@@ -1042,27 +1243,39 @@ struct _L3MESSAGEBUFFER * CreateRIFHeader(struct ROUTE * Route)
struct _L3MESSAGEBUFFER * Msg = GetBuff();
UCHAR AliasCopy[10] = "";
- Msg->LENGTH = 1;
- Msg->L3SRCE[0] = 0xff;
-
- Msg->L3PID = NRPID;
+ if (Msg)
+ {
+ Msg->LENGTH = 1;
+ Msg->L3SRCE[0] = 0xff;
+ Msg->L3PID = NRPID;
+ }
return Msg;
}
VOID SendRIF(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Msg)
{
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_CALL, Normcall)] = 0;
+
Msg->LENGTH += MSGHDDRLEN + 1; // PID
+ Debugprintf("Sending INP3 RIF length %d to %s", Msg->LENGTH, Normcall);
SendNetFrame(Route, Msg);
}
-VOID SendRIPToOtherNeighbours(UCHAR * axcall, UCHAR * alias, struct DEST_ROUTE_ENTRY * Entry)
+VOID SendRIPToOtherNeighbours(UCHAR * axcall, UCHAR * alias, struct INP3_DEST_ROUTE_ENTRY * Entry)
{
struct ROUTE * Routes = NEIGHBOURS;
struct _L3MESSAGEBUFFER * Msg;
int count, MaxRoutes = MAXNEIGHBOURS;
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(axcall, Normcall)] = 0;
+
+ Debugprintf("INP3 SendRIPToOtherNeighbours for %s", Normcall);
for (count=0; count<MaxRoutes; count++)
{
@@ -1073,16 +1286,24 @@ VOID SendRIPToOtherNeighbours(UCHAR * axcall, UCHAR * alias, struct DEST_ROUTE_E
Msg = Routes->Msg;
if (Msg == NULL)
+ {
+ Normcall[ConvFromAX25(Routes->NEIGHBOUR_CALL, Normcall)] = 0;
+ Debugprintf("INP3 Building RIF to send to %s", Normcall);
Msg = Routes->Msg = CreateRIFHeader(Routes);
-
- Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH],
- axcall, alias, Entry->Hops + 1, Entry->SRTT + Entry->ROUT_NEIGHBOUR->SRTT/10);
+ }
- if (Msg->LENGTH > 250 - 15)
-// if (Msg->LENGTH > Routes->NBOUR_PACLEN - 11)
+ if (Msg)
{
- SendRIF(Routes, Msg);
- Routes->Msg = NULL;
+
+ Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH],
+ axcall, alias, Entry->Hops + 1, Entry->SRTT + Entry->ROUT_NEIGHBOUR->SRTT/10);
+
+ if (Msg->LENGTH > 250 - 15)
+// if (Msg->LENGTH > Routes->NBOUR_PACLEN - 11)
+ {
+ SendRIF(Routes, Msg);
+ Routes->Msg = NULL;
+ }
}
}
Routes+=1;
@@ -1093,9 +1314,14 @@ VOID SendRIPToNeighbour(struct ROUTE * Route)
{
int i;
struct DEST_LIST * Dest = DESTS;
- struct DEST_ROUTE_ENTRY * Entry;
+ struct INP3_DEST_ROUTE_ENTRY * Entry;
struct _L3MESSAGEBUFFER * Msg;
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(Route->NEIGHBOUR_LINK->LINKCALL, Normcall)] = 0;
+ Debugprintf("INP3 Sending Our Table to %s ", Normcall);
+
Dest--;
// Send all entries not via this Neighbour - used when link starts
@@ -1104,7 +1330,7 @@ VOID SendRIPToNeighbour(struct ROUTE * Route)
{
Dest++;
- Entry = &Dest->ROUTE[0];
+ Entry = &Dest->INP3ROUTE[0];
if (Entry->ROUT_NEIGHBOUR && Entry->Hops && Route != Entry->ROUT_NEIGHBOUR)
{
@@ -1115,6 +1341,9 @@ VOID SendRIPToNeighbour(struct ROUTE * Route)
if (Msg == NULL)
Msg = Route->Msg = CreateRIFHeader(Route);
+ if (Msg == NULL)
+ return;
+
Msg->LENGTH += BuildRIF(&Msg->L3SRCE[Msg->LENGTH],
Dest->DEST_CALL, Dest->DEST_ALIAS,
Entry->Hops + 1, Entry->SRTT + Entry->ROUT_NEIGHBOUR->SRTT/10);
@@ -1142,8 +1371,12 @@ VOID FlushRIFs()
{
if (Routes->Msg)
{
+ char Normcall[10];
+
+ Normcall[ConvFromAX25(Routes->NEIGHBOUR_CALL, Normcall)] = 0;
SendRIF(Routes, Routes->Msg);
Routes->Msg = NULL;
+ Debugprintf("INP3 Flushing RIF to %s", Normcall);
}
Routes+=1;
}
@@ -1153,7 +1386,7 @@ VOID SendNegativeInfo()
{
int i, Preload;
struct DEST_LIST * Dest = DESTS;
- struct DEST_ROUTE_ENTRY * Entry;
+ struct INP3_DEST_ROUTE_ENTRY * Entry;
Dest--;
@@ -1169,7 +1402,7 @@ VOID SendNegativeInfo()
{
Dest++;
- Entry = &Dest->ROUTE[0];
+ Entry = &Dest->INP3ROUTE[0];
if (Entry->SRTT > Entry->LastRTT)
{
@@ -1194,15 +1427,19 @@ VOID SendNegativeInfo()
{
char call[11]="";
ConvFromAX25(Dest->DEST_CALL, call);
- Debugprintf("Deleting Node %s", call);
+ Debugprintf("INP3 Deleting Node %s", call);
REMOVENODE(Dest); // Clear buffers, Remove from Sorted Nodes chain, and zap entry
}
else
{
// Have a NETROM route, so zap the INP3 one
- memset(Entry, 0, sizeof(struct DEST_ROUTE_ENTRY));
+ memset(Entry, 0, sizeof(struct INP3_DEST_ROUTE_ENTRY));
}
+
+ if (Dest->DEST_ROUTE == 4) // we were using it
+ Dest->DEST_ROUTE = 0;
+
}
}
}
@@ -1211,7 +1448,7 @@ VOID SendPositiveInfo()
{
int i;
struct DEST_LIST * Dest = DESTS;
- struct DEST_ROUTE_ENTRY * Entry;
+ struct INP3_DEST_ROUTE_ENTRY * Entry;
Dest--;
@@ -1221,14 +1458,14 @@ VOID SendPositiveInfo()
{
Dest++;
- Entry = &Dest->ROUTE[0];
+ Entry = &Dest->INP3ROUTE[0];
if (( (Entry->SRTT) && (Entry->LastRTT == 0) )|| // if zero haven't yet reported +ve info
((((Entry->SRTT * 125) /100) < Entry->LastRTT) && // Better by 25%
((Entry->LastRTT - Entry->SRTT) > 10))) // and 100ms
{
SendRIPToOtherNeighbours(Dest->DEST_CALL, 0, Entry);
- Dest->ROUTE[0].LastRTT = (Dest->ROUTE[0].SRTT * 11) / 10; //10% Negative Preload
+ Dest->INP3ROUTE[0].LastRTT = (Dest->INP3ROUTE[0].SRTT * 11) / 10; //10% Negative Preload
}
}
}
@@ -1238,7 +1475,7 @@ VOID SendNewInfo()
int i;
unsigned int NewRTT;
struct DEST_LIST * Dest = DESTS;
- struct DEST_ROUTE_ENTRY * Entry;
+ struct INP3_DEST_ROUTE_ENTRY * Entry;
Dest--;
@@ -1252,7 +1489,7 @@ VOID SendNewInfo()
{
Dest->INP3FLAGS &= ~NewNode;
- Entry = &Dest->ROUTE[0];
+ Entry = &Dest->INP3ROUTE[0];
SendRIPToOtherNeighbours(Dest->DEST_CALL, Dest->DEST_ALIAS, Entry);
@@ -1337,7 +1574,7 @@ UCHAR * DisplayINP3RIF(UCHAR * ptr1, UCHAR * ptr2, unsigned int msglen)
return ptr2;
}
}
-
+
ptr1+=7;
hops = *ptr1++;
@@ -1364,24 +1601,38 @@ UCHAR * DisplayINP3RIF(UCHAR * ptr1, UCHAR * ptr2, unsigned int msglen)
memcpy(&alias[6 - (len - 2)], ptr1+2, len-2); // Right Justiify
}
else
- if (opcode == 1 && len < 8)
- {
- memcpy(IP, ptr1+2, len-2);
- }
+ if (opcode == 1 && len < 8)
+ {
+ memcpy(IP, ptr1+2, len-2);
+ }
+ ptr2+=sprintf(ptr2, " %s:%s %d %4.2d\r", alias, call, hops, rtt);
- ptr1+=len;
- msglen -=len;
+ ptr1++;
+ msglen--; // EOP
}
- if (IP[0])
- ptr2+=sprintf(ptr2, " %s:%s %d %4.2d %d.%d.%d.%d\r", alias, call, hops, rtt, IP[0], IP[1], IP[2], IP[3]);
- else
- ptr2+=sprintf(ptr2, " %s:%s %d %4.2d\r", alias, call, hops, rtt);
-
- ptr1++;
- msglen--; // EOP
+ return ptr2;
}
-
return ptr2;
}
+// Paula's conversion of rtt to Quality
+
+int inp3_tt2qual (int tt, int hops)
+{
+ int qual;
+
+ if (tt >= 60000 || hops > 30)
+ return(0);
+
+ qual = 254 - (tt/20);
+
+ if (qual > 254 - hops)
+ qual = 254 - hops;
+
+ if (qual < 0)
+ qual=0;
+
+ return(qual);
+}
+
diff --git a/BPQMail.aps b/BPQMail.aps
new file mode 100644
index 0000000..96bcae6
--- /dev/null
+++ b/BPQMail.aps
Binary files differ
diff --git a/BPQMail.c b/BPQMail.c
index a0971d9..2aab885 100644
--- a/BPQMail.c
+++ b/BPQMail.c
@@ -1148,6 +1148,12 @@
// Fix bug in WP Message processing (56)
// Fix treating addresses ending in WW as Internet (57)
// Run sending to packetnodes.spots.radio in a separate thread (61)
+// Fix loading ISP Account Name from config file (67)
+// Fixes to using {FormFolder} in Webmail Templates (68)
+// Save FBB transfer restart data over program restarts (69)
+// Add Send and Receive byte counts to status displays (69)
+// Validate Mode and Frequency and fix formatting in Connected Message (71)
+// Fix using OpenBCM on other than Telnet connections (75)
#include "bpqmail.h"
#include "winstdint.h"
@@ -1168,6 +1174,7 @@ FARPROCX pRunEventProgram;
FARPROCX pGetPortFrequency;
FARPROCX pSendWebRequest;
FARPROCX pGetLatLon;
+FARPROCX pGetPortHardwareType;
BOOL WINE = FALSE;
@@ -1724,6 +1731,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
// SaveUserDatabase();
SaveMessageDatabase();
SaveBIDDatabase();
+ SaveRestartData();
configSaved = 1;
SaveConfig(ConfigName);
@@ -1950,6 +1958,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
pGetPortFrequency = GetProcAddress(ExtDriver,"_GetPortFrequency@8");
pSendWebRequest = GetProcAddress(ExtDriver,"_SendWebRequest@16");
pGetLatLon = GetProcAddress(ExtDriver,"_GetLatLon@8");
+ pGetPortHardwareType = GetProcAddress(ExtDriver,"_GetPortHardwareType@4");
+
if (pGetLOC)
@@ -3020,9 +3030,9 @@ int RefreshMainWindow()
strcpy(msg,"Logging in");
else
{
- i=sprintf_s(msg, sizeof(msg), "%-10s %-10s %2d %-10s%5d",
+ i=sprintf_s(msg, sizeof(msg), "%-10s %-10s %2d %-10s%5d %5d %5d",
conn->UserPointer->Name, conn->UserPointer->Call, conn->BPQStream,
- "BBS", conn->OutputQueueLength - conn->OutputGetPointer);
+ "BBS", conn->OutputQueueLength - conn->OutputGetPointer, conn->bytesSent, conn->bytesRxed);
}
}
}
@@ -3083,6 +3093,7 @@ static PSOCKADDR_IN psin;
SOCKET sock;
+void GetRestartData();
BOOL Initialise()
{
@@ -3270,6 +3281,8 @@ BOOL Initialise()
GetBadWordFile();
GetHTMLForms();
+ GetRestartData();
+
UsingingRegConfig = FALSE;
// Make sure SYSOPCALL is set
diff --git a/BPQMail.rc b/BPQMail.rc
index 88d1116..a220ae3 100644
--- a/BPQMail.rc
+++ b/BPQMail.rc
@@ -1,4 +1,4 @@
-//Microsoft Developer Studio generated resource script.
+// Microsoft Visual C++ generated resource script.
//
#include "BPQMailrc.h"
@@ -22,21 +22,19 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
+// English (United States) 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_PROPPAGE_LARGE DIALOG DISCARDABLE 0, 0, 235, 156
-STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
+IDD_PROPPAGE_LARGE DIALOG 0, 0, 235, 156
+STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Property Page"
FONT 8, "MS Sans Serif"
BEGIN
@@ -49,7 +47,7 @@ END
//
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO MOVEABLE PURE
+GUIDELINES DESIGNINFO
BEGIN
IDD_PROPPAGE_LARGE, DIALOG
BEGIN
@@ -61,57 +59,52 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
-#endif // English (U.S.) resources
+#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// English (U.K.) resources
+// English (United Kingdom) 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
//
-BPQMAIL DIALOG DISCARDABLE 120, 50, 294, 165
-STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
- WS_THICKFRAME
+BPQMAIL DIALOGEX 120, 50, 341, 165
+STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "G8BPQ Mail and Chat Server 1.0.0.10 Beta July 2009"
CLASS "BPQMail"
-FONT 8, "FixedSys"
+FONT 8, "FixedSys", 0, 0, 0x0
BEGIN
- LTEXT " User Callsign Stream Conf Queue",101,3,4,184,
- 10
- LTEXT "UTC",IDC_STATIC,197,3,15,10
- LTEXT "Local",IDC_STATIC,241,3,21,10
- LTEXT "",IDC_UTC,215,3,25,10
- LTEXT "",IDC_LOCAL,269,3,25,10
- LISTBOX 100,2,16,190,130,WS_VSCROLL
- LTEXT "Msgs",IDC_STATIC,197,21,40,10
- LTEXT "",IDC_MSGS,243,21,20,8
- LTEXT "Sysop Msgs",IDC_STATIC,197,32,40,10
- LTEXT "Held Msgs",IDC_STATIC,197,43,40,10
- LTEXT "",IDC_SYSOPMSGS,243,32,20,8
- LTEXT "",IDC_HELD,243,43,20,8
- LTEXT "SMTP Msgs",IDC_STATIC,197,54,40,10
- LTEXT "",IDC_SMTP,243,54,20,8
- LTEXT "Msg SEM Clashes",IDC_STATIC,197,70,63,10
- LTEXT "Alloc SEM Clashes",IDC_STATIC,197,81,68,10
- LTEXT "0",IDC_MSGSEM,274,70,20,10
- LTEXT "0",IDC_ALLOCSEM,274,81,20,10
- LTEXT "Con SEM Clashes",IDC_STATIC,197,92,68,10
- LTEXT "0",IDC_CONSEM,274,92,20,10
+ LTEXT " User Callsign Stream Conf Queue Sent Rxed",101,3,4,228,10
+ LTEXT "UTC",IDC_STATIC,236,5,15,10
+ LTEXT "Local",IDC_STATIC,280,5,21,10
+ LTEXT "",IDC_UTC,254,5,25,10
+ LTEXT "",IDC_LOCAL,307,5,25,10
+ LISTBOX 100,2,16,231,130,WS_VSCROLL
+ LTEXT "Msgs",IDC_STATIC,236,25,40,10
+ LTEXT "",IDC_MSGS,282,25,20,8
+ LTEXT "Sysop Msgs",IDC_STATIC,236,36,40,10
+ LTEXT "Held Msgs",IDC_STATIC,236,47,40,10
+ LTEXT "",IDC_SYSOPMSGS,282,36,20,8
+ LTEXT "",IDC_HELD,282,47,20,8
+ LTEXT "SMTP Msgs",IDC_STATIC,236,61,40,10
+ LTEXT "",IDC_SMTP,282,58,20,8
+ LTEXT "Msg SEM Clashes",IDC_STATIC,236,77,63,10
+ LTEXT "Alloc SEM Clashes",IDC_STATIC,236,88,68,10
+ LTEXT "0",IDC_MSGSEM,321,77,20,10
+ LTEXT "0",IDC_ALLOCSEM,321,88,20,10
+ LTEXT "Con SEM Clashes",IDC_STATIC,236,99,68,10
+ LTEXT "0",IDC_CONSEM,321,99,20,10
END
-CONSOLEWINDOW DIALOG DISCARDABLE 17, 25, 400, 301
-STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
- WS_THICKFRAME
+CONSOLEWINDOW DIALOG 17, 25, 400, 301
+STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Mail Console"
MENU CONSOLEMENU
CLASS "CONSOLEWINDOW"
@@ -120,21 +113,18 @@ BEGIN
EDITTEXT 118,24,228,348,15,ES_AUTOHSCROLL | ES_NOHIDESEL
END
-BPQMONWINDOW DIALOG DISCARDABLE 17, 25, 400, 300
-STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
- WS_THICKFRAME
+BPQMONWINDOW DIALOG 17, 25, 400, 300
+STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Mail Monitor"
MENU MENU_2
CLASS "BPQMONWINDOW"
FONT 8, "FixedSys"
BEGIN
- LISTBOX 121,6,25,290,109,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT |
- WS_VSCROLL | WS_HSCROLL
+ LISTBOX 121,6,25,290,109,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL
END
-BPQMCWINDOW DIALOG DISCARDABLE 17, 25, 500, 300
-STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
- WS_THICKFRAME
+BPQMCWINDOW DIALOG 17, 25, 500, 300
+STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Multicast Monitor"
MENU MENU_1
CLASS "BPQMCWINDOW"
@@ -142,55 +132,45 @@ FONT 8, "FixedSys"
BEGIN
END
-BPQDEBUGWINDOW DIALOG DISCARDABLE 17, 25, 400, 300
-STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
- WS_THICKFRAME
+BPQDEBUGWINDOW DIALOG 17, 25, 400, 300
+STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Mail Debug Window"
MENU MENU_3
CLASS "BPQDEBUGWINDOW"
FONT 8, "FixedSys"
BEGIN
- LISTBOX 122,5,156,290,109,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT |
- WS_VSCROLL | WS_HSCROLL
+ LISTBOX 122,5,156,290,109,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL
END
-102 DIALOG DISCARDABLE 0, 0, 385, 301
-STYLE WS_POPUP | WS_CAPTION | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU |
- WS_THICKFRAME
+102 DIALOG 0, 0, 385, 301
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU | WS_THICKFRAME
CAPTION "Configuration"
FONT 8, "System"
BEGIN
END
-BBS_CONFIG DIALOG DISCARDABLE 0, 0, 381, 306
-STYLE WS_CHILD
+BBS_CONFIG DIALOG 0, 0, 381, 306
+STYLE DS_SETFONT | WS_CHILD
FONT 8, "System"
BEGIN
- LTEXT "BBS Call is the base callsign, without SSID. This is not necessarily the same as the Application Callsign defined in the BPQ32 configuration. SYSOP Call is the callsign used by the local console.",
- IDC_STATIC,10,4,354,23
- LTEXT "The Application Number defines which BPQ32 Application gives access to the BBS. Note this is the APPLNumber (1-32) not an Application Mask, as used in many BPQ32 programs.",
- IDC_STATIC,10,27,353,18
- LTEXT "The eMail Server Params configure the NNTP, SMTP and POP3 Servers, which allow normal Internet email and News clients to get messages from, and post mesages to the BBS. If you don't want to use this, set them to zero.. ",
- IDC_STATIC,8,52,357,27
- LTEXT "Enable UI System activates FBB compatible UI broadcasting of Message Headers",
- IDC_STATIC,8,80,357,15
+ LTEXT "BBS Call is the base callsign, without SSID. This is not necessarily the same as the Application Callsign defined in the BPQ32 configuration. SYSOP Call is the callsign used by the local console.",IDC_STATIC,10,4,354,23
+ LTEXT "The Application Number defines which BPQ32 Application gives access to the BBS. Note this is the APPLNumber (1-32) not an Application Mask, as used in many BPQ32 programs.",IDC_STATIC,10,27,353,18
+ LTEXT "The eMail Server Params configure the NNTP, SMTP and POP3 Servers, which allow normal Internet email and News clients to get messages from, and post mesages to the BBS. If you don't want to use this, set them to zero.. ",IDC_STATIC,8,52,357,27
+ LTEXT "Enable UI System activates FBB compatible UI broadcasting of Message Headers",IDC_STATIC,8,80,357,15
LTEXT "BBS Call",IDC_STATIC,7,105,37,12
EDITTEXT IDC_BBSCall,83,103,47,14,ES_UPPERCASE
LTEXT "SYSOP Call",IDC_STATIC,138,105,42,12
EDITTEXT IDC_SYSOPCALL,184,103,42,14,ES_UPPERCASE
CONTROL "Send SYSTEM Msgs to SYSOP call",IDC_SYSTOSYSOPCALL,
- "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,231,
- 104,129,12
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,231,104,129,12
LTEXT "H Route",IDC_STATIC,7,122,37,12
EDITTEXT IDC_HRoute,83,120,119,13,ES_UPPERCASE
LTEXT "BBS Appl Number",IDC_STATIC,7,138,61,10
EDITTEXT IDC_BBSAppl,83,136,29,12
LTEXT "Streams",IDC_STATIC,130,138,32,10
EDITTEXT IDC_BBSStreams,168,136,29,12
- CONTROL "Refuse Bulls",IDC_REFUSEBULLS,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | WS_TABSTOP,211,138,53,10
- CONTROL "Enable FBB UI System",IDC_ENABLEUI,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,6,157,87,10
+ CONTROL "Refuse Bulls",IDC_REFUSEBULLS,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,211,138,53,10
+ CONTROL "Enable FBB UI System",IDC_ENABLEUI,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,6,157,87,10
LTEXT "Send Mail For Beacons Every",IDC_STATIC,102,157,100,12
EDITTEXT MAILFOR_MINS,205,156,22,12,ES_UPPERCASE
LTEXT "Minutes",IDC_STATIC,232,157,30,12
@@ -202,86 +182,58 @@ BEGIN
EDITTEXT IDC_POP3Port,130,241,29,14
LTEXT "SMTP Port",IDC_STATIC,170,243,37,12
EDITTEXT IDC_SMTPPort,210,241,29,14
- CONTROL "Enable Remote Access",1009,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,249,240,91,14
+ CONTROL "Enable Remote Access",1009,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,249,240,91,14
PUSHBUTTON "Save",IDC_BBSSAVE,159,281,50,14,BS_CENTER | BS_VCENTER
CONTROL "Don't hold messages from new users",IDC_DONTHOLDNEW,
- "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,5,
- 189,134,12
- CONTROL "Forward Messages to BBS Call",IDC_FORWARDTOBBS,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,145,189,114,
- 12
- CONTROL "Redirect msgs to BBS Call to SYSOP Call",
- IDC_BBSTOSYSOPCALL,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | WS_TABSTOP,213,120,146,12
- CONTROL "Don't Request Home BBS",IDC_NOHOMEBBS,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,260,174,99,12
- CONTROL "Don't Request Name",IDC_NONAME,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | WS_TABSTOP,176,174,79,12
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,5,189,134,12
+ CONTROL "Forward Messages to BBS Call",IDC_FORWARDTOBBS,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,145,189,114,12
+ CONTROL "Redirect msgs to BBS Call to SYSOP Call",IDC_BBSTOSYSOPCALL,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,213,120,146,12
+ CONTROL "Don't Request Home BBS",IDC_NOHOMEBBS,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,260,174,99,12
+ CONTROL "Don't Request Name",IDC_NONAME,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,176,174,79,12
EDITTEXT IDC_AMPR,72,258,119,13
LTEXT "AMPR Address",IDC_STATIC,6,260,60,12
- CONTROL "Send ampr.org mail to AMPR host",IDC_FORWARDAMPR,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,258,124,14
- CONTROL "Allow users to kill T msgs",IDC_USERRKILLT,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,264,189,95,12
- CONTROL "Set Don't add WINLINK.ORG flag on new users",
- IDC_DEFAULTNOWINLINK,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | WS_TABSTOP,5,174,162,12
- CONTROL "Don't allow unknown users",IDC_KNOWNUSERS,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,277,138,98,10
- CONTROL "Don't Check From Calls",IDC_DONTCHECKFROM,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,5,204,95,12
+ CONTROL "Send ampr.org mail to AMPR host",IDC_FORWARDAMPR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,258,124,14
+ CONTROL "Allow users to kill T msgs",IDC_USERRKILLT,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,264,189,95,12
+ CONTROL "Set Don't add WINLINK.ORG flag on new users",IDC_DEFAULTNOWINLINK,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,5,174,162,12
+ CONTROL "Don't allow unknown users",IDC_KNOWNUSERS,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,277,138,98,10
+ CONTROL "Don't Check From Calls",IDC_DONTCHECKFROM,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,5,204,95,12
END
-CHAT_CONFIG DIALOG DISCARDABLE 0, 0, 381, 266
-STYLE WS_CHILD
+CHAT_CONFIG DIALOG 0, 0, 381, 266
+STYLE DS_SETFONT | WS_CHILD
FONT 8, "System"
BEGIN
LTEXT "Chat Appl Number",-1,115,109,61,8
EDITTEXT 2001,185,106,29,14
LTEXT "Nodes to link to",-1,115,129,53,8
- EDITTEXT 2002,185,125,87,88,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT 2002,185,125,87,88,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
DEFPUSHBUTTON "Save",2100,172,226,50,14,BS_CENTER | BS_VCENTER
- LTEXT "The Application Number defines which BPQ32 Application gives access to the Chat Server. Note this is the APPLNumber (1-32) not an Application Mask, as uses in many BPQ32 programs.",
- -1,10,10,353,18
- LTEXT "The Nodes to link to box defines which other Chat Nodes should be connected to, or from which connections may be accepted. The format is ALIAS:CALL, eg BPQCHT:G8BPQ-4. Note these must be directly connectable - ie in your NODES table.",
- -1,10,30,355,25
- LTEXT "The Callsign of the Chat Node is not defined here - It is obtained from the BPQ32 APPLCALL parameter corresponding to the Chat Appl Number.",
- -1,10,60,360,25
+ LTEXT "The Application Number defines which BPQ32 Application gives access to the Chat Server. Note this is the APPLNumber (1-32) not an Application Mask, as uses in many BPQ32 programs.",-1,10,10,353,18
+ LTEXT "The Nodes to link to box defines which other Chat Nodes should be connected to, or from which connections may be accepted. The format is ALIAS:CALL, eg BPQCHT:G8BPQ-4. Note these must be directly connectable - ie in your NODES table.",-1,10,30,355,25
+ LTEXT "The Callsign of the Chat Node is not defined here - It is obtained from the BPQ32 APPLCALL parameter corresponding to the Chat Appl Number.",-1,10,60,360,25
END
IDD_USEREDIT DIALOGEX 20, 20, 293, 281
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit User"
FONT 8, "System", 0, 0, 0x1
BEGIN
- COMBOBOX 5000,7,10,57,123,CBS_SIMPLE | CBS_SORT | CBS_UPPERCASE |
- WS_VSCROLL | WS_TABSTOP
- CONTROL "BBS",IDC_BBSFLAG,"Button",BS_AUTOCHECKBOX | BS_LEFT |
- WS_TABSTOP,72,9,57,10
- CONTROL "PMS",IDC_PMSFLAG,"Button",BS_AUTOCHECKBOX | BS_LEFT |
- WS_TABSTOP,72,22,57,10
- CONTROL "Sysop",IDC_SYSOP,"Button",BS_AUTOCHECKBOX | BS_LEFT |
- WS_TABSTOP,72,35,57,10
- CONTROL "Expert",IDC_EXPERT,"Button",BS_AUTOCHECKBOX | BS_LEFT |
- WS_TABSTOP,72,48,57,10
- CONTROL "Excluded",IDC_EXCLUDED,"Button",BS_AUTOCHECKBOX |
- BS_LEFT | WS_TABSTOP,72,61,57,10
- CONTROL "Hold Messages",IDC_HOLDMAIL,"Button",BS_AUTOCHECKBOX |
- BS_LEFT | WS_TABSTOP,72,74,65,10
- CONTROL "NTS MPS",IDC_NTSMPS,"Button",BS_AUTOCHECKBOX | BS_LEFT |
- WS_TABSTOP,72,87,69,10
- CONTROL "Permit Email",IDC_EMAIL,"Button",BS_AUTOCHECKBOX |
- BS_LEFT | WS_TABSTOP,163,9,57,10
- CONTROL "Poll RMS for SSID's",IDC_POLLRMS,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,23,78,8,0,
- HIDC_POLLRMS
+ COMBOBOX 5000,7,10,57,123,CBS_SIMPLE | CBS_SORT | CBS_UPPERCASE | WS_VSCROLL | WS_TABSTOP
+ CONTROL "BBS",IDC_BBSFLAG,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,9,57,10
+ CONTROL "PMS",IDC_PMSFLAG,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,22,57,10
+ CONTROL "Sysop",IDC_SYSOP,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,35,57,10
+ CONTROL "Expert",IDC_EXPERT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,48,57,10
+ CONTROL "Excluded",IDC_EXCLUDED,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,61,57,10
+ CONTROL "Hold Messages",IDC_HOLDMAIL,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,74,65,10
+ CONTROL "NTS MPS",IDC_NTSMPS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,87,69,10
+ CONTROL "Permit Email",IDC_EMAIL,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,9,57,10
+ CONTROL "Poll RMS for SSID's",IDC_POLLRMS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,23,78,8,0,HIDC_POLLRMS
EDITTEXT RMS_SSID1,244,21,13,12,ES_AUTOHSCROLL
EDITTEXT RMS_SSID2,258,21,13,12,ES_AUTOHSCROLL
EDITTEXT RMS_SSID3,272,21,13,12,ES_AUTOHSCROLL
- CONTROL "RMS Express User",RMS_EXPRESS_USER,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,35,77,10
+ CONTROL "RMS Express User",RMS_EXPRESS_USER,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,35,77,10
LTEXT "Last Listed",IDC_STATIC,163,87,38,12
EDITTEXT IDC_LASTLISTED,248,85,29,12,ES_AUTOHSCROLL
LTEXT "Name",IDC_STATIC,7,184,35,14
@@ -292,8 +244,7 @@ BEGIN
EDITTEXT IDC_QTH,55,218,130,14,ES_AUTOHSCROLL
LTEXT "Home BBS",IDC_STATIC,7,238,40,14
EDITTEXT IDC_HOMEBBS,55,236,162,14,ES_UPPERCASE | ES_AUTOHSCROLL
- PUSHBUTTON "Add user",IDC_ADDUSER,79,257,42,14,BS_CENTER |
- BS_VCENTER
+ PUSHBUTTON "Add user",IDC_ADDUSER,79,257,42,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "Delete user",5101,124,257,42,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "Save",5102,169,257,42,14,BS_CENTER | BS_VCENTER
LTEXT "Connects in",IDC_STATIC,10,131,45,10
@@ -314,33 +265,25 @@ BEGIN
LTEXT "0",BYTES_IN,45,153,38,10,0,WS_EX_RIGHT
LTEXT "Last Connect",IDC_STATIC,87,153,45,10
LTEXT "Never",LASTCONNECT,134,153,93,10
- CONTROL "Don't add @winlink.org",NO_WINLINKdotORG,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,47,100,10
+ CONTROL "Don't add @winlink.org",NO_WINLINKdotORG,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,47,100,10
LTEXT "ZIP",IDC_STATIC,189,221,12,11
EDITTEXT IDC_UZIP,207,219,38,12,ES_AUTOHSCROLL
- CONTROL "Allow sending Bulls",ALLOW_BULLS,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,61,100,10
- CONTROL "Include SYSOP msgs in LM",IDC_SYSOP_IN_LM,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_DISABLED | WS_TABSTOP,163,
- 74,100,10
+ CONTROL "Allow sending Bulls",ALLOW_BULLS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,163,61,100,10
+ CONTROL "Include SYSOP msgs in LM",IDC_SYSOP_IN_LM,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_DISABLED | WS_TABSTOP,163,74,100,10
EDITTEXT IDC_CMSPASS,187,201,88,14,ES_PASSWORD
- CONTROL "CMS Pass",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP |
- WS_GROUP,149,203,34,14
- CONTROL "Send Mail For to APRS ssid",IDC_APRSMFOR,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,113,108,10
+ CONTROL "CMS Pass",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,149,203,34,14
+ CONTROL "Send Mail For to APRS ssid",IDC_APRSMFOR,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,113,108,10
EDITTEXT IDC_APRSSSID,182,112,16,12,ES_AUTOHSCROLL
- CONTROL "Redirect to RMS",IDC_RMSREDIRECT,"Button",
- BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,100,69,10
+ CONTROL "Redirect to RMS",IDC_RMSREDIRECT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,72,100,69,10
END
-ISP_CONFIG DIALOG DISCARDABLE 26, 5, 381, 284
-STYLE WS_CHILD | WS_VISIBLE
+ISP_CONFIG DIALOG 26, 5, 381, 284
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "System"
BEGIN
EDITTEXT 3001,95,110,100,15
LTEXT "SMTP Server",-1,10,130,53,13
- LTEXT "The system relies on having an email domain which supports forwarding of all email addresses to a fixed mailbox. For example, I could register domain mycall.org.uk, and have any mail sent to anyone@mycall.org.uk forwarded to mymailbox@myisp.com",
- 1,10,34,349,25
+ LTEXT "The system relies on having an email domain which supports forwarding of all email addresses to a fixed mailbox. For example, I could register domain mycall.org.uk, and have any mail sent to anyone@mycall.org.uk forwarded to mymailbox@myisp.com",1,10,34,349,25
LTEXT "POP3 Server",-1,10,146,61,13
LTEXT "ISP Account Name",-1,10,163,63,13
EDITTEXT IDC_ISPSMTPName,95,127,148,15
@@ -350,134 +293,87 @@ BEGIN
LTEXT "Port",-1,250,130,19,13
EDITTEXT 3005,275,144,29,15
EDITTEXT 3003,275,127,29,15
- LTEXT "This page configures the BBS <> Internet Mail Gateway. The Gateway allows local users to send messages to Internet email addresses, and get replies from those messages",
- -1,10,10,353,20
+ LTEXT "This page configures the BBS <> Internet Mail Gateway. The Gateway allows local users to send messages to Internet email addresses, and get replies from those messages",-1,10,10,353,20
LTEXT "My Domain",-1,10,112,51,8
LTEXT "ISP Account Password",-1,10,180,80,13
EDITTEXT 3007,95,178,147,15,ES_PASSWORD
LTEXT "POP3 Poll Interval (Seconds)",-1,10,216,80,18
EDITTEXT 3008,95,219,29,12
- LTEXT "WARNING This feature my be illegal in some administrations. Make sure your authorities permit forwarding mail from the Amateur Service before enabling it",
- -1,10,64,348,15
- CONTROL "Enable Internet Gateway",3000,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,10,90,90,15
+ LTEXT "WARNING This feature my be illegal in some administrations. Make sure your authorities permit forwarding mail from the Amateur Service before enabling it",-1,10,64,348,15
+ CONTROL "Enable Internet Gateway",3000,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,10,90,90,15
DEFPUSHBUTTON "Save",3100,165,261,57,17,BS_CENTER | BS_VCENTER
CONTROL "SMTP Server Requires Authentication",ISP_SMTP_AUTH,
- "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_LEFT |
- BS_MULTILINE | WS_TABSTOP,250,159,69,32
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_LEFT | BS_MULTILINE | WS_TABSTOP,250,159,69,32
EDITTEXT SMTP_EHELO,95,196,100,15
LTEXT "SMTP ""EHELO"" Domain",-1,10,198,80,8
END
-IDD_FORWARDING DIALOG DISCARDABLE 20, 20, 457, 327
-STYLE WS_POPUP | WS_CAPTION | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU |
- WS_THICKFRAME
+IDD_FORWARDING DIALOG 20, 20, 457, 327
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU | WS_THICKFRAME
CAPTION "Manage Forwarding"
FONT 8, "System"
BEGIN
- LTEXT "Forwarding Rules are define here. BBS Records are created by setting the BBS flag on a User Record.",
- IDC_STATIC,5,7,368,10
- LTEXT "The Enable Forwarding flag allows you to disable forwarding without losing the messages to be forwarded. ",
- IDC_STATIC,5,20,373,8
+ LTEXT "Forwarding Rules are define here. BBS Records are created by setting the BBS flag on a User Record.",IDC_STATIC,5,7,368,10
+ LTEXT "The Enable Forwarding flag allows you to disable forwarding without losing the messages to be forwarded. ",IDC_STATIC,5,20,373,8
GROUPBOX "Global Params",IDC_STATIC,2,33,114,263
LTEXT "Max Size to Send",IDC_STATIC,5,50,58,12
EDITTEXT IDC_MAXSEND,66,49,26,12,ES_AUTOHSCROLL
LTEXT "Max Size to Recv",IDC_STATIC,5,68,58,12
EDITTEXT IDC_MAXRECV,66,66,26,12,ES_AUTOHSCROLL
- CONTROL "Warn if no route for P or T",IDC_WARNNOROUTE,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,5,101,103,8
+ CONTROL "Warn if no route for P or T",IDC_WARNNOROUTE,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,101,103,8
LTEXT "Aliases",IDC_STATIC,5,165,57,13
- EDITTEXT IDC_ALIAS,4,183,99,81,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
- CONTROL "Readdress Locally Input",IDC_READDRESSLOCAL,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_DISABLED | WS_TABSTOP,4,267,97,8
- CONTROL "Readdress Received",IDC_READDRESSRXED,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_DISABLED | WS_TABSTOP,4,281,97,8
+ EDITTEXT IDC_ALIAS,4,183,99,81,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "Readdress Locally Input",IDC_READDRESSLOCAL,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,4,267,97,8
+ CONTROL "Readdress Received",IDC_READDRESSRXED,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,4,281,97,8
GROUPBOX "Per-BBS Params",IDC_STATIC,121,33,326,263
LTEXT "BBS",IDC_STATIC,128,46,57,10
- COMBOBOX IDC_BBS,122,59,50,60,CBS_SIMPLE | CBS_OEMCONVERT |
- CBS_SORT | CBS_NOINTEGRALHEIGHT | WS_VSCROLL
+ COMBOBOX IDC_BBS,122,59,50,60,CBS_SIMPLE | CBS_OEMCONVERT | CBS_SORT | CBS_NOINTEGRALHEIGHT | WS_VSCROLL
LTEXT "To Calls:",IDC_STATIC,186,46,40,10
- EDITTEXT IDC_TOCALLS,177,59,50,60,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
+ EDITTEXT IDC_TOCALLS,177,59,50,60,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
LTEXT "AT Calls:",IDC_STATIC,242,46,43,10
- EDITTEXT IDC_ATCALLS,233,59,50,60,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
+ EDITTEXT IDC_ATCALLS,233,59,50,60,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
LTEXT "Times",IDC_STATIC,299,46,30,13
- EDITTEXT IDC_FWDTIMES,288,59,50,60,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
+ EDITTEXT IDC_FWDTIMES,288,59,50,60,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
LTEXT "Connect Script",IDC_STATIC,348,46,57,13
- EDITTEXT IDC_CALL,343,59,92,60,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
- LTEXT "Hierarchical Routes (Flood Bulls)",IDC_STATIC,141,126,
- 114,12
- EDITTEXT IDC_HROUTES,122,140,148,60,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL | WS_HSCROLL
- LTEXT "HR (Personals and Directed Bulls)",IDC_STATIC,281,126,
- 125,12
- EDITTEXT IDC_HROUTESP,280,141,151,60,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL | WS_HSCROLL
+ EDITTEXT IDC_CALL,343,59,92,60,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ LTEXT "Hierarchical Routes (Flood Bulls)",IDC_STATIC,141,126,114,12
+ EDITTEXT IDC_HROUTES,122,140,148,60,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
+ LTEXT "HR (Personals and Directed Bulls)",IDC_STATIC,281,126,125,12
+ EDITTEXT IDC_HROUTESP,280,141,151,60,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
LTEXT "Interval (Secs)",IDC_STATIC,359,205,48,8
EDITTEXT IDC_FWDINT,253,204,22,12,ES_AUTOHSCROLL
- CONTROL "Enable Forwarding",4000,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,122,206,72,8
- CONTROL "Request Reverse",4006,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,286,206,67,8
- CONTROL "Send new messages without waiting for poll timer",
- IDC_SENDNEW,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT |
- BS_MULTILINE | WS_TABSTOP,122,221,182,8
+ CONTROL "Enable Forwarding",4000,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,122,206,72,8
+ CONTROL "Request Reverse",4006,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,286,206,67,8
+ CONTROL "Send new messages without waiting for poll timer",IDC_SENDNEW,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,122,221,182,8
LTEXT "BBS HA",IDC_STATIC,125,242,30,12
EDITTEXT IDC_BBSHA,162,240,134,12,ES_UPPERCASE | ES_AUTOHSCROLL
LTEXT "Max Block",IDC_STATIC,368,241,37,12
EDITTEXT IDC_MAXBLOCK,407,240,26,12,ES_AUTOHSCROLL
- CONTROL "Send Personal Mail Only",IDC_PERSONALONLY,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,321,221,108,8
- CONTROL "Allow Binary",IDC_ALLOWCOMP,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,125,260,58,8
- CONTROL "Use B1 Protocol",IDC_USEB1,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,185,260,72,8
- CONTROL "Use B2 Protocol",IDC_USEB2,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,261,260,67,8
- DEFPUSHBUTTON "? Help",IDC_HRHELP,381,6,33,11,BS_CENTER | BS_VCENTER |
- NOT WS_TABSTOP
+ CONTROL "Send Personal Mail Only",IDC_PERSONALONLY,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,321,221,108,8
+ CONTROL "Allow Binary",IDC_ALLOWCOMP,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,125,260,58,8
+ CONTROL "Use B1 Protocol",IDC_USEB1,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,185,260,72,8
+ CONTROL "Use B2 Protocol",IDC_USEB2,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,261,260,67,8
+ DEFPUSHBUTTON "? Help",IDC_HRHELP,381,6,33,11,BS_CENTER | BS_VCENTER | NOT WS_TABSTOP
DEFPUSHBUTTON "Save",4100,352,303,57,17,BS_CENTER | BS_VCENTER
LTEXT "Interval (Secs)",IDC_STATIC,198,206,48,8
EDITTEXT IDC_REVFWDINT,407,205,23,12,ES_AUTOHSCROLL
- CONTROL "Use Local Time ",IDC_USELOCALTIME,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,5,116,103,8
- CONTROL "Send ctrl/Z instead of /ex",IDC_CTRLZ,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,333,260,100,8
+ CONTROL "Use Local Time ",IDC_USELOCALTIME,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,116,103,8
+ CONTROL "Send ctrl/Z instead of /ex",IDC_CTRLZ,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,333,260,100,8
LTEXT "Max Bull Age",IDC_STATIC,5,86,58,12
EDITTEXT IDC_MAXAGE,66,84,26,12,ES_AUTOHSCROLL
- CONTROL "FBB Blocked",IDC_BLOCKED,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,301,241,61,8
- PUSHBUTTON "Copy From BBS",COPYCONFIG,160,303,57,17,BS_CENTER |
- BS_VCENTER
+ CONTROL "FBB Blocked",IDC_BLOCKED,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,301,241,61,8
+ PUSHBUTTON "Copy From BBS",COPYCONFIG,160,303,57,17,BS_CENTER | BS_VCENTER
EDITTEXT COPYFROMCALL,227,303,35,17,ES_UPPERCASE | ES_AUTOHSCROLL
- CONTROL "Send P to more than 1 BBS",IDC_MULTIP,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,5,130,103,8
+ CONTROL "Send P to more than 1 BBS",IDC_MULTIP,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,130,103,8
LTEXT "Incoming Connect Timeout",IDC_STATIC,125,278,95,12
EDITTEXT IDC_CONTIMEOUT,219,276,22,12,ES_AUTOHSCROLL
CONTROL "Use 4 Char Continent Codes",IDC_FOURCHARCONTINENT,
- "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,6,146,103,8
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,6,146,103,8
END
-IDD_USERADDED_BOX DIALOG DISCARDABLE 176, 132, 129, 68
-STYLE DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
+IDD_USERADDED_BOX DIALOG 176, 132, 129, 68
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
FONT 8, "System"
BEGIN
DEFPUSHBUTTON "Ok",0,47,48,36,17,BS_CENTER | BS_VCENTER
@@ -485,17 +381,14 @@ BEGIN
END
IDD_MSGEDIT DIALOGEX 20, 20, 421, 298
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Message"
FONT 8, "System", 0, 0, 0x1
BEGIN
RTEXT "Msg",IDC_STATIC,7,7,19,8
- LISTBOX 0,33,7,65,81,LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL |
- WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_MSGTYPE,125,9,25,55,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- COMBOBOX IDC_MSGSTATUS,185,9,25,55,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
+ LISTBOX 0,33,7,65,81,LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_MSGTYPE,125,9,25,55,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_MSGSTATUS,185,9,25,55,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "From",IDC_STATIC,7,98,19,8
EDITTEXT 6001,33,95,65,14,ES_UPPERCASE | ES_AUTOHSCROLL
RTEXT "BID",IDC_STATIC,7,114,19,8
@@ -516,333 +409,187 @@ BEGIN
RTEXT "Size",IDC_STATIC,116,147,32,8
EDITTEXT 6020,153,145,55,14,ES_AUTOHSCROLL
LTEXT "Type",IDC_STATIC,105,10,17,8
- CONTROL "",25,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,7,35,10
- CONTROL "",26,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,17,35,10
- CONTROL "",27,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,27,35,10
- CONTROL "",28,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,37,35,10
- CONTROL "",29,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,47,35,10
- CONTROL "",30,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,57,35,10
- CONTROL "",31,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,67,35,10
- CONTROL "",32,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,77,35,10
- CONTROL "",33,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,87,35,10
- CONTROL "",34,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,97,35,10
- CONTROL "",35,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,107,35,10
- CONTROL "",36,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,117,35,10
- CONTROL "",37,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,127,35,10
- CONTROL "",38,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,137,35,10
- CONTROL "",39,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,147,35,10
- CONTROL "",40,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,157,35,10
- CONTROL "",41,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,167,35,10
- CONTROL "",42,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,177,35,10
- CONTROL "",43,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,187,35,10
- CONTROL "",44,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,197,35,10
- CONTROL "",45,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,208,35,10
- CONTROL "",46,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,218,35,10
- CONTROL "",47,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,228,35,10
- CONTROL "",48,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,238,35,10
- CONTROL "",49,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,221,248,35,10
- CONTROL "",50,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,7,35,10
- CONTROL "",51,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,17,35,10
- CONTROL "",52,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,27,35,10
- CONTROL "",53,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,37,35,10
- CONTROL "",54,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,47,35,10
- CONTROL "",55,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,57,35,10
- CONTROL "",56,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,67,35,10
- CONTROL "",57,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,77,35,10
- CONTROL "",58,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,87,35,10
- CONTROL "",59,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,97,35,10
- CONTROL "",60,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,107,35,10
- CONTROL "",61,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,117,35,10
- CONTROL "",62,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,127,35,10
- CONTROL "",63,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,137,35,10
- CONTROL "",64,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,147,35,10
- CONTROL "",65,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,157,35,10
- CONTROL "",66,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,167,35,10
- CONTROL "",67,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,177,35,10
- CONTROL "",68,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,187,35,10
- CONTROL "",69,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,197,35,10
- CONTROL "",70,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,207,35,10
- CONTROL "",71,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,217,35,10
- CONTROL "",72,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,227,35,10
- CONTROL "",73,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,237,35,10
- CONTROL "",74,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,260,247,35,10
- CONTROL "",75,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,7,35,10
- CONTROL "",76,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,17,35,10
- CONTROL "",77,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,27,35,10
- CONTROL "",78,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,37,35,10
- CONTROL "",79,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,47,35,10
- CONTROL "",80,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,57,35,10
- CONTROL "",81,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,67,35,10
- CONTROL "",82,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,77,35,10
- CONTROL "",83,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,87,35,10
- CONTROL "",84,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,97,35,10
- CONTROL "",85,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,107,35,10
- CONTROL "",86,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,117,35,10
- CONTROL "",87,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,127,35,10
- CONTROL "",88,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,137,35,10
- CONTROL "",89,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,147,35,10
- CONTROL "",90,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,157,35,10
- CONTROL "",91,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,167,35,10
- CONTROL "",92,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,177,35,10
- CONTROL "",93,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,187,35,10
- CONTROL "",94,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,197,35,10
- CONTROL "",95,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,207,35,10
- CONTROL "",96,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,217,35,10
- CONTROL "",97,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,227,35,10
- CONTROL "",98,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,237,35,10
- CONTROL "",99,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,299,247,35,10
- CONTROL "",100,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,7,35,10
- CONTROL "",101,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,18,35,10
- CONTROL "",102,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,27,35,10
- CONTROL "",103,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,37,35,10
- CONTROL "",104,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,47,35,10
+ CONTROL "",25,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,7,35,10
+ CONTROL "",26,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,17,35,10
+ CONTROL "",27,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,27,35,10
+ CONTROL "",28,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,37,35,10
+ CONTROL "",29,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,47,35,10
+ CONTROL "",30,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,57,35,10
+ CONTROL "",31,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,67,35,10
+ CONTROL "",32,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,77,35,10
+ CONTROL "",33,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,87,35,10
+ CONTROL "",34,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,97,35,10
+ CONTROL "",35,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,107,35,10
+ CONTROL "",36,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,117,35,10
+ CONTROL "",37,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,127,35,10
+ CONTROL "",38,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,137,35,10
+ CONTROL "",39,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,147,35,10
+ CONTROL "",40,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,157,35,10
+ CONTROL "",41,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,167,35,10
+ CONTROL "",42,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,177,35,10
+ CONTROL "",43,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,187,35,10
+ CONTROL "",44,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,197,35,10
+ CONTROL "",45,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,208,35,10
+ CONTROL "",46,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,218,35,10
+ CONTROL "",47,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,228,35,10
+ CONTROL "",48,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,238,35,10
+ CONTROL "",49,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,221,248,35,10
+ CONTROL "",50,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,7,35,10
+ CONTROL "",51,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,17,35,10
+ CONTROL "",52,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,27,35,10
+ CONTROL "",53,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,37,35,10
+ CONTROL "",54,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,47,35,10
+ CONTROL "",55,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,57,35,10
+ CONTROL "",56,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,67,35,10
+ CONTROL "",57,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,77,35,10
+ CONTROL "",58,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,87,35,10
+ CONTROL "",59,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,97,35,10
+ CONTROL "",60,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,107,35,10
+ CONTROL "",61,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,117,35,10
+ CONTROL "",62,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,127,35,10
+ CONTROL "",63,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,137,35,10
+ CONTROL "",64,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,147,35,10
+ CONTROL "",65,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,157,35,10
+ CONTROL "",66,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,167,35,10
+ CONTROL "",67,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,177,35,10
+ CONTROL "",68,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,187,35,10
+ CONTROL "",69,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,197,35,10
+ CONTROL "",70,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,207,35,10
+ CONTROL "",71,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,217,35,10
+ CONTROL "",72,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,227,35,10
+ CONTROL "",73,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,237,35,10
+ CONTROL "",74,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,260,247,35,10
+ CONTROL "",75,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,7,35,10
+ CONTROL "",76,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,17,35,10
+ CONTROL "",77,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,27,35,10
+ CONTROL "",78,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,37,35,10
+ CONTROL "",79,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,47,35,10
+ CONTROL "",80,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,57,35,10
+ CONTROL "",81,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,67,35,10
+ CONTROL "",82,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,77,35,10
+ CONTROL "",83,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,87,35,10
+ CONTROL "",84,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,97,35,10
+ CONTROL "",85,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,107,35,10
+ CONTROL "",86,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,117,35,10
+ CONTROL "",87,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,127,35,10
+ CONTROL "",88,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,137,35,10
+ CONTROL "",89,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,147,35,10
+ CONTROL "",90,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,157,35,10
+ CONTROL "",91,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,167,35,10
+ CONTROL "",92,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,177,35,10
+ CONTROL "",93,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,187,35,10
+ CONTROL "",94,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,197,35,10
+ CONTROL "",95,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,207,35,10
+ CONTROL "",96,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,217,35,10
+ CONTROL "",97,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,227,35,10
+ CONTROL "",98,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,237,35,10
+ CONTROL "",99,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,299,247,35,10
+ CONTROL "",100,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,7,35,10
+ CONTROL "",101,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,18,35,10
+ CONTROL "",102,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,27,35,10
+ CONTROL "",103,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,37,35,10
+ CONTROL "",104,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,47,35,10
LTEXT "Key",IDC_STATIC,317,267,35,9
- CONTROL "Dont Send",205,"Button",BS_3STATE | BS_CENTER |
- BS_PUSHLIKE,262,281,43,10
- CONTROL "Send",206,"Button",BS_3STATE | BS_CENTER | BS_PUSHLIKE,
- 311,280,35,10
- CONTROL "Sent",207,"Button",BS_3STATE | BS_CENTER | BS_PUSHLIKE,
- 353,280,35,10
- DEFPUSHBUTTON "Edit Text",IDC_EDITTEXT,24,275,38,15,BS_CENTER |
- BS_VCENTER
- DEFPUSHBUTTON "Print",IDC_PRINTMSG,150,275,24,15,BS_CENTER |
- BS_VCENTER
+ CONTROL "Dont Send",205,"Button",BS_3STATE | BS_CENTER | BS_PUSHLIKE,262,281,43,10
+ CONTROL "Send",206,"Button",BS_3STATE | BS_CENTER | BS_PUSHLIKE,311,280,35,10
+ CONTROL "Sent",207,"Button",BS_3STATE | BS_CENTER | BS_PUSHLIKE,353,280,35,10
+ DEFPUSHBUTTON "Edit Text",IDC_EDITTEXT,24,275,38,15,BS_CENTER | BS_VCENTER
+ DEFPUSHBUTTON "Print",IDC_PRINTMSG,150,275,24,15,BS_CENTER | BS_VCENTER
RTEXT "Filter From",IDC_STATIC,104,30,38,8
EDITTEXT FILTER_FROM,147,28,62,14,ES_UPPERCASE | ES_AUTOHSCROLL
EDITTEXT FILTER_TO,147,44,62,14,ES_UPPERCASE | ES_AUTOHSCROLL
- EDITTEXT FILTER_VIA,147,60,62,14,ES_UPPERCASE | ES_AUTOHSCROLL,0,
- HFILTER_VIA
+ EDITTEXT FILTER_VIA,147,60,62,14,ES_UPPERCASE | ES_AUTOHSCROLL,0,HFILTER_VIA
RTEXT "Filter To",IDC_STATIC,104,46,38,8
RTEXT "Filter Via",IDC_STATIC,104,62,38,8
DEFPUSHBUTTON "Save",IDC_SAVEMSG,67,275,24,15,BS_CENTER | BS_VCENTER
- DEFPUSHBUTTON "Save to File",IDC_SAVETOFILE,96,275,49,15,BS_CENTER |
- BS_VCENTER
+ DEFPUSHBUTTON "Save to File",IDC_SAVETOFILE,96,275,49,15,BS_CENTER | BS_VCENTER
DEFPUSHBUTTON "Export",IDC_EXPORT,179,275,32,15,BS_CENTER | BS_VCENTER
EDITTEXT EMAILFROM,33,169,177,14,ES_UPPERCASE | ES_AUTOHSCROLL
RTEXT "Email From",IDC_STATIC,4,168,25,17
- CONTROL "",105,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,57,35,10
- CONTROL "",106,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,67,35,10
- CONTROL "",107,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,77,35,10
- CONTROL "",108,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,87,35,10
- CONTROL "",109,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,97,35,10
- CONTROL "",110,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,107,35,10
- CONTROL "",111,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,118,35,10
- CONTROL "",112,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,127,35,10
- CONTROL "",113,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,137,35,10
- CONTROL "",114,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,147,35,10
- CONTROL "",115,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,157,35,10
- CONTROL "",116,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,167,35,10
- CONTROL "",117,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,177,35,10
- CONTROL "",118,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,187,35,10
- CONTROL "",119,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,197,35,10
- CONTROL "",120,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,207,35,10
- CONTROL "",121,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,217,35,10
- CONTROL "",122,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,227,35,10
- CONTROL "",123,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,237,35,10
- CONTROL "",124,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,337,247,35,10
- CONTROL "",148,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,237,35,10
- CONTROL "",125,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,8,35,10
- CONTROL "",126,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,17,35,10
- CONTROL "",127,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,27,35,10
- CONTROL "",128,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,37,35,10
- CONTROL "",129,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,47,35,10
- CONTROL "",130,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,57,35,10
- CONTROL "",131,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,67,35,10
- CONTROL "",132,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,77,35,10
- CONTROL "",133,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,87,35,10
- CONTROL "",134,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,97,35,10
- CONTROL "",135,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,108,35,10
- CONTROL "",136,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,117,35,10
- CONTROL "",137,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,127,35,10
- CONTROL "",138,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,137,35,10
- CONTROL "",139,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,147,35,10
- CONTROL "",140,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,157,35,10
- CONTROL "",141,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,167,35,10
- CONTROL "",150,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,247,35,10
- CONTROL "",142,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,177,35,10
- CONTROL "",143,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,187,35,10
- CONTROL "",144,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,197,35,10
- CONTROL "",145,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,207,35,10
- CONTROL "",146,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,217,35,10
- CONTROL "",147,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE |
- WS_TABSTOP,377,227,35,10
- EDITTEXT FILTER_BID,147,76,62,14,ES_UPPERCASE | ES_AUTOHSCROLL,0,
- HFILTER_BID
+ CONTROL "",105,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,57,35,10
+ CONTROL "",106,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,67,35,10
+ CONTROL "",107,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,77,35,10
+ CONTROL "",108,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,87,35,10
+ CONTROL "",109,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,97,35,10
+ CONTROL "",110,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,107,35,10
+ CONTROL "",111,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,118,35,10
+ CONTROL "",112,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,127,35,10
+ CONTROL "",113,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,137,35,10
+ CONTROL "",114,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,147,35,10
+ CONTROL "",115,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,157,35,10
+ CONTROL "",116,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,167,35,10
+ CONTROL "",117,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,177,35,10
+ CONTROL "",118,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,187,35,10
+ CONTROL "",119,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,197,35,10
+ CONTROL "",120,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,207,35,10
+ CONTROL "",121,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,217,35,10
+ CONTROL "",122,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,227,35,10
+ CONTROL "",123,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,237,35,10
+ CONTROL "",124,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,337,247,35,10
+ CONTROL "",148,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,237,35,10
+ CONTROL "",125,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,8,35,10
+ CONTROL "",126,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,17,35,10
+ CONTROL "",127,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,27,35,10
+ CONTROL "",128,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,37,35,10
+ CONTROL "",129,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,47,35,10
+ CONTROL "",130,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,57,35,10
+ CONTROL "",131,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,67,35,10
+ CONTROL "",132,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,77,35,10
+ CONTROL "",133,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,87,35,10
+ CONTROL "",134,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,97,35,10
+ CONTROL "",135,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,108,35,10
+ CONTROL "",136,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,117,35,10
+ CONTROL "",137,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,127,35,10
+ CONTROL "",138,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,137,35,10
+ CONTROL "",139,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,147,35,10
+ CONTROL "",140,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,157,35,10
+ CONTROL "",141,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,167,35,10
+ CONTROL "",150,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,247,35,10
+ CONTROL "",142,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,177,35,10
+ CONTROL "",143,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,187,35,10
+ CONTROL "",144,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,197,35,10
+ CONTROL "",145,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,207,35,10
+ CONTROL "",146,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,217,35,10
+ CONTROL "",147,"Button",BS_AUTO3STATE | BS_LEFT | BS_PUSHLIKE | WS_TABSTOP,377,227,35,10
+ EDITTEXT FILTER_BID,147,76,62,14,ES_UPPERCASE | ES_AUTOHSCROLL,0,HFILTER_BID
RTEXT "Filter BID",IDC_STATIC,104,78,38,8
END
-WELCOMEMSG DIALOG DISCARDABLE 26, 5, 365, 281
-STYLE WS_CHILD | WS_VISIBLE
+WELCOMEMSG DIALOG 26, 5, 365, 281
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "System"
BEGIN
LTEXT "Normal User Welcome Message",IDC_STATIC,5,7,130,8
- EDITTEXT IDM_USERMSG,5,20,340,50,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_USERMSG,5,20,340,50,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
LTEXT "New User Welcome Message",IDC_STATIC,5,75,130,8
- EDITTEXT IDM_NEWUSERMSG,5,89,340,65,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_NEWUSERMSG,5,89,340,65,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
LTEXT "Expert User Welcome Message",IDC_STATIC,5,159,130,8
- EDITTEXT IDM_EXPERTUSERMSG,5,172,340,12,ES_MULTILINE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_EXPERTUSERMSG,5,172,340,12,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
DEFPUSHBUTTON "Save",IDM_MSGSAVE,166,264,50,14,BS_CENTER | BS_VCENTER
- LTEXT "$U : Callsign of the user $I : First name of the user $X Messages for user $x Unread messages",
- IDC_STATIC,0,222,365,8
- LTEXT "$L : Number of the latest message $N : Number of active messages. $Z : Last message read by user",
- IDC_STATIC,0,234,365,10
+ LTEXT "$U : Callsign of the user $I : First name of the user $X Messages for user $x Unread messages",IDC_STATIC,0,222,365,8
+ LTEXT "$L : Number of the latest message $N : Number of active messages. $Z : Last message read by user",IDC_STATIC,0,234,365,10
LTEXT "Signoff Message",IDC_STATIC,5,190,130,8
- EDITTEXT IDM_SIGNOFF,5,202,340,12,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN
- LTEXT "$F : Number of mesages to be forwarded to user (if a BBS)",
- IDC_STATIC,0,246,365,10
+ EDITTEXT IDM_SIGNOFF,5,202,340,12,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
+ LTEXT "$F : Number of mesages to be forwarded to user (if a BBS)",IDC_STATIC,0,246,365,10
END
-BBSPROMPTS DIALOG DISCARDABLE 26, 5, 381, 266
-STYLE WS_CHILD | WS_VISIBLE
+BBSPROMPTS DIALOG 26, 5, 381, 266
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "System"
BEGIN
LTEXT "Normal User Prompt",IDC_STATIC,5,7,130,8
- EDITTEXT IDM_USERMSG,5,20,340,35,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_USERMSG,5,20,340,35,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
LTEXT "New User Prompt",IDC_STATIC,5,59,130,8
- EDITTEXT IDM_NEWUSERMSG,5,70,340,35,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_NEWUSERMSG,5,70,340,35,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
LTEXT "Expert User Prompt",IDC_STATIC,5,110,130,8
- EDITTEXT IDM_EXPERTUSERMSG,5,120,340,35,ES_MULTILINE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
- DEFPUSHBUTTON "Save",IDM_PROMPTSAVE,166,250,50,14,BS_CENTER |
- BS_VCENTER
- LTEXT "$U : Callsign of the user $I : First name of the user $X Messages for user $x Unread messages",
- IDC_STATIC,2,165,353,8
- LTEXT "$L : Number of the latest message $N : Number of active messages. $Z : Last message read by user",
- IDC_STATIC,3,175,347,10
+ EDITTEXT IDM_EXPERTUSERMSG,5,120,340,35,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
+ DEFPUSHBUTTON "Save",IDM_PROMPTSAVE,166,250,50,14,BS_CENTER | BS_VCENTER
+ LTEXT "$U : Callsign of the user $I : First name of the user $X Messages for user $x Unread messages",IDC_STATIC,2,165,353,8
+ LTEXT "$L : Number of the latest message $N : Number of active messages. $Z : Last message read by user",IDC_STATIC,3,175,347,10
END
-IDD_MAINTRESULTS DIALOG DISCARDABLE 0, 0, 181, 114
-STYLE DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
+IDD_MAINTRESULTS DIALOG 0, 0, 181, 114
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
CAPTION "Maintenance Results"
FONT 8, "System"
BEGIN
@@ -861,13 +608,12 @@ BEGIN
LTEXT "Static",IDC_BIDSLEFT,146,69,30,10
END
-IDD_EDITWP DIALOG DISCARDABLE 0, 0, 398, 265
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_EDITWP DIALOG 0, 0, 398, 265
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "EDIT WP Record"
FONT 8, "MS Sans Serif"
BEGIN
- COMBOBOX IDC_WP,9,9,76,190,CBS_SIMPLE | CBS_SORT | CBS_UPPERCASE |
- WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_WP,9,9,76,190,CBS_SIMPLE | CBS_SORT | CBS_UPPERCASE | WS_VSCROLL | WS_TABSTOP
LTEXT "Name",-1,100,11,47,10
EDITTEXT IDC_WPNAME,165,10,128,12,ES_AUTOHSCROLL
LTEXT "Home BBS 1",-1,100,26,53,10
@@ -892,13 +638,12 @@ BEGIN
LTEXT "Seen",-1,100,186,47,12
EDITTEXT IDC_CHANGED,165,170,59,12,ES_AUTOHSCROLL
EDITTEXT IDC_SEEN,165,185,59,12,ES_AUTOHSCROLL
- PUSHBUTTON "Delete",IDC_DELETEWP,106,215,56,17,BS_CENTER |
- BS_VCENTER
+ PUSHBUTTON "Delete",IDC_DELETEWP,106,215,56,17,BS_CENTER | BS_VCENTER
PUSHBUTTON "Save",IDC_SAVEWP,171,216,56,17,BS_CENTER | BS_VCENTER
END
-IDD_UICONFIG DIALOG DISCARDABLE 0, 0, 400, 151
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_UICONFIG DIALOG 0, 0, 400, 151
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "UI Configuration"
FONT 8, "System"
BEGIN
@@ -906,58 +651,48 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,342,98,50,14
LTEXT "Mailfor Header",IDC_STATIC,5,5,50,10
EDITTEXT IDC_MAILFOR,61,3,331,12,ES_AUTOHSCROLL
- LTEXT "Send: Mail For Headers Null Mailfor",IDC_STATIC,242,
- 25,127,10
- LTEXT "(use \\r to insert newline in message)",IDC_STATIC,62,
- 16,125,10
+ LTEXT "Send: Mail For Headers Null Mailfor",IDC_STATIC,242,25,127,10
+ LTEXT "(use \\r to insert newline in message)",IDC_STATIC,62,16,125,10
END
-IDD_CHATCOLCONFIG DIALOG DISCARDABLE 0, 0, 224, 120
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_CHATCOLCONFIG DIALOG 0, 0, 224, 120
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Chat Colour Configuration"
FONT 8, "System"
BEGIN
DEFPUSHBUTTON "Save",IDOK,50,95,50,14
PUSHBUTTON "Close",IDCANCEL,120,95,50,14
- COMBOBOX IDC_CHATCALLS,10,5,100,60,CBS_DROPDOWNLIST | CBS_SORT |
- WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_CHATCOLOURS,115,5,100,60,CBS_DROPDOWNLIST |
- CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_CHATCALLS,10,5,100,60,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_CHATCOLOURS,115,5,100,60,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP
END
-IDD_UPDATECHATMAP DIALOG DISCARDABLE 0, 0, 274, 146
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_UPDATECHATMAP DIALOG 0, 0, 274, 146
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Update Chat Map"
FONT 8, "System"
BEGIN
- LTEXT "Click Help for full information about the Chat Network Map",
- IDC_STATIC,5,10,195,15
+ LTEXT "Click Help for full information about the Chat Network Map",IDC_STATIC,5,10,195,15
DEFPUSHBUTTON "? Help",IDC_MAPHELP,220,10,33,11,BS_CENTER | BS_VCENTER
LTEXT "Position",IDC_STATIC,5,30,35,10
EDITTEXT IDC_MAPPOSITION,5,45,145,15,ES_AUTOHSCROLL
LTEXT "Popup Box Text. ",IDC_STATIC,5,65,70,9
- EDITTEXT IDC_POPUPTEXT,5,80,200,35,ES_MULTILINE | ES_AUTOHSCROLL |
- WS_HSCROLL
+ EDITTEXT IDC_POPUPTEXT,5,80,200,35,ES_MULTILINE | ES_AUTOHSCROLL | WS_HSCROLL
LTEXT "Popup Mode",IDC_STATIC,215,80,49,10
- CONTROL "Hover",IDC_HOVER,"Button",BS_AUTORADIOBUTTON,219,92,45,
- 10
- CONTROL "Click",IDC_CLICK,"Button",BS_AUTORADIOBUTTON,219,104,45,
- 10
+ CONTROL "Hover",IDC_HOVER,"Button",BS_AUTORADIOBUTTON,219,92,45,10
+ CONTROL "Click",IDC_CLICK,"Button",BS_AUTORADIOBUTTON,219,104,45,10
DEFPUSHBUTTON "Send to Map System",IDSENDTOMAP,5,125,90,14
DEFPUSHBUTTON "Save",IDOK,100,125,35,14
PUSHBUTTON "Cancel",IDCANCEL,140,125,40,14
END
IDD_MSGFROMCLIPBOARD DIALOGEX 0, 0, 442, 306
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Send Message"
FONT 8, "System", 0, 0, 0x1
BEGIN
PUSHBUTTON "Send",IDSEND,333,5,50,14
PUSHBUTTON "Cancel",IDCANCEL,333,25,50,14
- EDITTEXT IDC_EDIT1,4,57,431,245,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL,
- WS_EX_ACCEPTFILES
+ EDITTEXT IDC_EDIT1,4,57,431,245,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL,WS_EX_ACCEPTFILES
LTEXT "To:",IDC_STATIC,66,8,12,8
EDITTEXT IDC_MSGTO,83,7,147,12,ES_UPPERCASE | ES_AUTOHSCROLL
LTEXT "Title:",IDC_STATIC,8,26,22,8
@@ -965,43 +700,37 @@ BEGIN
LTEXT "BID:",IDC_STATIC,240,8,20,8
EDITTEXT IDC_MSGBID,262,7,65,12,ES_UPPERCASE | ES_AUTOHSCROLL
LTEXT "Type",IDC_STATIC,8,8,20,8
- COMBOBOX IDC_MSGTYPE,34,7,25,55,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
+ COMBOBOX IDC_MSGTYPE,34,7,25,55,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Select",IDSelectFiles,333,42,50,14
LTEXT "Attachments",IDC_STATIC,8,43,42,8
EDITTEXT IDC_ATTACHMENTS,50,41,277,12,ES_AUTOHSCROLL
END
-IDD_HRHELP DIALOG DISCARDABLE 0, 0, 415, 182
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_HRHELP DIALOG 0, 0, 415, 182
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Hierarchical Forwarding Help"
FONT 8, "System"
BEGIN
DEFPUSHBUTTON "OK",IDOK,182,158,50,14
- EDITTEXT IDC_HRTEXT,4,4,405,150,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
+ EDITTEXT IDC_HRTEXT,4,4,405,150,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
END
IDD_EDITMSGTEXT DIALOGEX 0, 0, 492, 356
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Edit Message"
FONT 8, "Fixedsys", 0, 0, 0x1
BEGIN
- EDITTEXT IDC_MESSAGE,4,25,480,327,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL,
- WS_EX_ACCEPTFILES
+ EDITTEXT IDC_MESSAGE,4,25,480,327,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL,WS_EX_ACCEPTFILES
PUSHBUTTON "Save",IDSAVE,5,5,40,17
PUSHBUTTON "Cancel",IDCANCEL,125,5,40,17
- PUSHBUTTON "Save Attachments",IDC_SAVEATTACHMENTS,50,5,70,17,
- WS_DISABLED
+ PUSHBUTTON "Save Attachments",IDC_SAVEATTACHMENTS,50,5,70,17,WS_DISABLED
END
-MAINT DIALOG DISCARDABLE 26, 5, 382, 298
-STYLE WS_CHILD | WS_VISIBLE
+MAINT DIALOG 26, 5, 382, 298
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "System"
BEGIN
- LTEXT "This sets the parameters for deleting old messages. Specify length of time (in days) for messages to be kept before being deleted",
- IDC_STATIC,149,13,226,22
+ LTEXT "This sets the parameters for deleting old messages. Specify length of time (in days) for messages to be kept before being deleted",IDC_STATIC,149,13,226,22
LTEXT "Read",IDC_STATIC,159,46,46,10
EDITTEXT IDM_PR,224,46,20,12,ES_CENTER | ES_AUTOHSCROLL
LTEXT "Unread",IDC_STATIC,159,61,46,10
@@ -1016,50 +745,36 @@ BEGIN
EDITTEXT IDM_BNF,324,61,20,12,ES_CENTER | ES_AUTOHSCROLL
GROUPBOX "Personals",IDC_STATIC,149,36,108,107
GROUPBOX "Bulletins",IDC_STATIC,259,36,103,44
- LTEXT "The following boxes allow you to specify different values for different Bulletin origins and destinations. Normally these apply to Sent Messages, to apply to unsent, check box below",
- IDC_STATIC,151,148,214,27
- LTEXT "Specify Call, Lifetime, eg ALL, 10",IDC_STATIC,151,176,
- 154,8
+ LTEXT "The following boxes allow you to specify different values for different Bulletin origins and destinations. Normally these apply to Sent Messages, to apply to unsent, check box below",IDC_STATIC,151,148,214,27
+ LTEXT "Specify Call, Lifetime, eg ALL, 10",IDC_STATIC,151,176,154,8
LTEXT "From",IDC_STATIC,176,189,28,9
- EDITTEXT IDM_LTFROM,151,202,64,55,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_LTFROM,151,202,64,55,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "To",IDC_STATIC,247,189,27,10
- EDITTEXT IDM_LTTO,221,202,64,55,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDM_LTTO,221,202,64,55,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "At",IDC_STATIC,316,189,15,8
- EDITTEXT IDM_LTAT,289,202,64,55,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
- DEFPUSHBUTTON "Save",IDM_MAINTSAVE,166,279,50,14,BS_CENTER |
- BS_VCENTER
+ EDITTEXT IDM_LTAT,289,202,64,55,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
+ DEFPUSHBUTTON "Save",IDM_MAINTSAVE,166,279,50,14,BS_CENTER | BS_VCENTER
GROUPBOX "Lifetimes",IDC_STATIC,144,0,231,275
GROUPBOX "Parameters",IDC_STATIC,3,3,133,275
LTEXT "Max Message Number",IDC_STATIC,7,68,77,10
LTEXT "BID Lifetime (Days)",IDC_STATIC,7,87,77,10
- LTEXT "Maintenance Time (UTC) Enter as HHMM",IDC_STATIC,7,21,
- 83,25
+ LTEXT "Maintenance Time (UTC) Enter as HHMM",IDC_STATIC,7,21,83,25
EDITTEXT IDC_MAXMSG,102,67,25,12,ES_CENTER
EDITTEXT IDC_BIDLIFETIME,102,86,25,12,ES_CENTER | ES_AUTOHSCROLL
EDITTEXT IDC_MAINTTIME,102,23,25,12,ES_CENTER | ES_AUTOHSCROLL
LTEXT "Log File Lifetime (Days)",IDC_STATIC,7,107,80,10
EDITTEXT IDC_LOGLIFETIME,102,105,25,12,ES_CENTER | ES_AUTOHSCROLL
- CONTROL "Delete Log and Message Files to Recycle Bin",
- IDC_DELETETORECYCLE,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,142,115,20
- CONTROL "Suppress Mailing of Housekeeping Results",
- IDC_MAINTNOMAIL,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT |
- BS_MULTILINE | WS_TABSTOP,5,182,115,20
- CONTROL "Generate Traffic Report",IDC_MAINTTRAFFIC,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,5,204,115,10
- CONTROL "Send Non-delivery Notifications for P and T messages",
- IDC_MAINTNONDELIVERY,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,162,115,20
+ CONTROL "Delete Log and Message Files to Recycle Bin",IDC_DELETETORECYCLE,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,142,115,20
+ CONTROL "Suppress Mailing of Housekeeping Results",IDC_MAINTNOMAIL,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,182,115,20
+ CONTROL "Generate Traffic Report",IDC_MAINTTRAFFIC,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,204,115,10
+ CONTROL "Send Non-delivery Notifications for P and T messages",IDC_MAINTNONDELIVERY,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,162,115,20
CONTROL "Apply Overrides to Unsent Bulls",IDC_OVERRIDEUNSENT,
- "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,153,261,195,10
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,153,261,195,10
LTEXT "Delete Inactive Users (Days)",IDC_STATIC,7,127,93,10
- EDITTEXT IDC_USERLIFETIME,102,125,25,12,ES_CENTER |
- ES_AUTOHSCROLL
+ EDITTEXT IDC_USERLIFETIME,102,125,25,12,ES_CENTER | ES_AUTOHSCROLL
GROUPBOX "NTS",IDC_STATIC,259,80,102,62
LTEXT "Forwarded",IDC_STATIC,264,109,49,10
EDITTEXT IDM_NTSF,324,108,20,12,ES_CENTER | ES_AUTOHSCROLL
@@ -1067,100 +782,69 @@ BEGIN
EDITTEXT IDM_NTSU,324,123,20,12,ES_CENTER | ES_AUTOHSCROLL
LTEXT "Delivered",IDC_STATIC,264,94,49,10
EDITTEXT IDM_NTSD,324,94,20,12,ES_CENTER | ES_AUTOHSCROLL
- CONTROL "Save Registry",IDC_MAINTSAVEREG2,"Button",
- BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE |
- WS_TABSTOP,5,222,115,10
+ CONTROL "Save Registry",IDC_MAINTSAVEREG2,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_MULTILINE | WS_TABSTOP,5,222,115,10
LTEXT "Maintenance Interval (Hrs)",IDC_STATIC,7,47,93,10
- EDITTEXT IDC_MAINTINTERVAL,102,45,25,12,ES_CENTER |
- ES_AUTOHSCROLL
+ EDITTEXT IDC_MAINTINTERVAL,102,45,25,12,ES_CENTER | ES_AUTOHSCROLL
END
-FILTERS DIALOG DISCARDABLE 26, 5, 382, 371
-STYLE WS_CHILD | WS_VISIBLE
+FILTERS DIALOG 26, 5, 382, 371
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "System"
BEGIN
LTEXT "Reject Messages:",IDC_STATIC,162,26,70,10
LTEXT "From",IDC_STATIC,83,137,28,10
- EDITTEXT IDC_HOLDFROM,58,149,64,83,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_HOLDFROM,58,149,64,83,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "To",IDC_STATIC,152,137,27,10
- EDITTEXT IDC_HOLDTO,126,149,64,83,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_HOLDTO,126,149,64,83,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "At",IDC_STATIC,223,137,15,10
- EDITTEXT IDC_HOLDAT,194,149,64,83,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
- DEFPUSHBUTTON "Save",IDC_FILTERSAVE,171,341,50,14,BS_CENTER |
- BS_VCENTER
+ EDITTEXT IDC_HOLDAT,194,149,64,83,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
+ DEFPUSHBUTTON "Save",IDC_FILTERSAVE,171,341,50,14,BS_CENTER | BS_VCENTER
LTEXT "From",IDC_STATIC,83,40,28,10
- EDITTEXT IDC_REJFROM,58,52,64,67,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_REJFROM,58,52,64,67,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "To",IDC_STATIC,154,40,27,10
- EDITTEXT IDC_REJTO,126,52,64,68,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_REJTO,126,52,64,68,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "At",IDC_STATIC,223,40,15,10
- EDITTEXT IDC_REJAT,194,52,64,68,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_REJAT,194,52,64,68,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "Message Filtering Setup.",IDC_STATIC,152,10,95,15
LTEXT "Hold Messages:",IDC_STATIC,166,128,60,9
- EDITTEXT IDC_REJBID,262,52,64,68,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
- EDITTEXT IDC_HOLDBID,262,149,64,83,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_REJBID,262,52,64,68,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
+ EDITTEXT IDC_HOLDBID,262,149,64,83,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "BID",IDC_STATIC,289,137,15,10
LTEXT "BID",IDC_STATIC,289,41,15,10
- EDITTEXT IDC_REJSYS,58,265,270,66,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_WANTRETURN
- LTEXT "Composite Rules (like fbb reject.sys)",IDC_STATIC,152,
- 236,134,9
- LTEXT "Action, Type, from, @BBS, to, BID, maximum size",
- IDC_STATIC,59,251,247,9
+ EDITTEXT IDC_REJSYS,58,265,270,66,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_WANTRETURN
+ LTEXT "Composite Rules (like fbb reject.sys)",IDC_STATIC,152,236,134,9
+ LTEXT "Action, Type, from, @BBS, to, BID, maximum size",IDC_STATIC,59,251,247,9
END
-WPUPDATE DIALOG DISCARDABLE 26, 5, 382, 287
-STYLE WS_CHILD | WS_VISIBLE
+WPUPDATE DIALOG 26, 5, 382, 287
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "System"
BEGIN
- CONTROL "Send WP Updates",IDC_SENDWP,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | WS_TABSTOP,90,18,71,10
- EDITTEXT IDC_WPTO,112,82,154,113,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
- COMBOBOX IDC_WPTYPE,193,17,19,55,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
+ CONTROL "Send WP Updates",IDC_SENDWP,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,90,18,71,10
+ EDITTEXT IDC_WPTO,112,82,154,113,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ COMBOBOX IDC_WPTYPE,193,17,19,55,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Type",IDC_STATIC,172,18,21,10
DEFPUSHBUTTON "Save",IDC_WPSAVE,165,204,50,14,BS_CENTER | BS_VCENTER
- CONTROL "Reject WP Bulls",IDC_FILTERWPB,"Button",BS_AUTOCHECKBOX |
- BS_LEFTTEXT | WS_TABSTOP,222,18,71,10
- LTEXT "Send To.\rBPQMail only automatically processes messages with TO of WP, so for P messages format should be WP@BBSCALL. ",
- IDC_STATIC,98,38,176,35
+ CONTROL "Reject WP Bulls",IDC_FILTERWPB,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,222,18,71,10
+ LTEXT "Send To.\rBPQMail only automatically processes messages with TO of WP, so for P messages format should be WP@BBSCALL. ",IDC_STATIC,98,38,176,35
END
-IDD_RMSBULLDLG DIALOG DISCARDABLE 0, 0, 277, 258
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_RMSBULLDLG DIALOG 0, 0, 277, 258
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "RMS Express Bull Configuration"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,66,237,50,14
PUSHBUTTON "Cancel",IDCANCEL,164,237,50,14
- EDITTEXT IDC_TOCALLS,82,76,54,112,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
- EDITTEXT IDC_TOCALLS2,144,76,54,112,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
- EDITTEXT IDC_TOCALLS3,208,76,54,112,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
- EDITTEXT IDC_TOCALLS4,18,76,54,112,ES_MULTILINE | ES_UPPERCASE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL
+ EDITTEXT IDC_TOCALLS,82,76,54,112,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ EDITTEXT IDC_TOCALLS2,144,76,54,112,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ EDITTEXT IDC_TOCALLS3,208,76,54,112,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ EDITTEXT IDC_TOCALLS4,18,76,54,112,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
LTEXT "Common",IDC_STATIC,63,47,48,8
LTEXT "User Specific",IDC_STATIC,174,47,48,8
LTEXT "TO AT",IDC_STATIC,39,62,79,8
- LTEXT "TO AT",IDC_STATIC,163,62,79,
- 8
- LTEXT "This defines Bulls that will be downloaded to RMS Express Users. There are two lists, one for all RMS Express users and one per User. The lists will be combined, Updating the Common list will affect all users.",
- IDC_STATIC,7,7,242,37
+ LTEXT "TO AT",IDC_STATIC,163,62,79,8
+ LTEXT "This defines Bulls that will be downloaded to RMS Express Users. There are two lists, one for all RMS Express users and one per User. The lists will be combined, Updating the Common list will affect all users.",IDC_STATIC,7,7,242,37
END
@@ -1170,8 +854,12 @@ END
//
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO MOVEABLE PURE
+GUIDELINES DESIGNINFO
BEGIN
+ "BPQMAIL", DIALOG
+ BEGIN
+ END
+
102, DIALOG
BEGIN
TOPMARGIN, 47
@@ -1286,7 +974,7 @@ END
// Menu
//
-IDC_BPQMailChat MENU DISCARDABLE
+IDC_BPQMailChat MENU
BEGIN
POPUP "Actions"
BEGIN
@@ -1306,7 +994,6 @@ BEGIN
MENUITEM "Housekeeping", IDM_HOUSEKEEPING
MENUITEM "Send Message", ID_ACTIONS_SENDMESSAGE
MENUITEM "Send Msg from Clipboard", ID_ACTIONS_SENDMSGFROMCLIPBOARD
-
MENUITEM "Rerun Message Routing", RESCANMSGS
MENUITEM "Import Messages", IDM_IMPORT
END
@@ -1331,7 +1018,7 @@ BEGIN
END
END
-CONSOLEMENU MENU DISCARDABLE
+CONSOLEMENU MENU
BEGIN
POPUP "Options"
BEGIN
@@ -1357,7 +1044,7 @@ BEGIN
END
END
-MENU_2 MENU DISCARDABLE
+MENU_2 MENU
BEGIN
POPUP "Monitor"
BEGIN
@@ -1371,7 +1058,7 @@ BEGIN
END
END
-MENU_3 MENU DISCARDABLE
+MENU_3 MENU
BEGIN
POPUP "Edit"
BEGIN
@@ -1380,7 +1067,7 @@ BEGIN
END
END
-MENU_1 MENU DISCARDABLE
+MENU_1 MENU
BEGIN
POPUP "Edit"
BEGIN
@@ -1395,7 +1082,7 @@ END
// Accelerator
//
-IDC_TELNETSERVER ACCELERATORS MOVEABLE PURE
+IDC_TELNETSERVER ACCELERATORS
BEGIN
"?", IDM_ABOUT, ASCII, ALT
"/", IDM_ABOUT, ASCII, ALT
@@ -1408,12 +1095,12 @@ END
// TEXTINCLUDE
//
-1 TEXTINCLUDE MOVEABLE PURE
+1 TEXTINCLUDE
BEGIN
"BPQMailrc.h\0"
END
-2 TEXTINCLUDE MOVEABLE PURE
+2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""AFXRES.h""\r\n"
@@ -1423,7 +1110,7 @@ BEGIN
"\0"
END
-3 TEXTINCLUDE MOVEABLE PURE
+3 TEXTINCLUDE
BEGIN
"#define MAIL\r\n"
"#include ""Versions.h""\r\n"
@@ -1431,7 +1118,7 @@ BEGIN
"\0"
END
-1 TEXTINCLUDE MOVEABLE PURE
+1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
@@ -1444,19 +1131,24 @@ END
// AFX_DIALOG_LAYOUT
//
-IDD_USEREDIT AFX_DIALOG_LAYOUT MOVEABLE PURE
+IDD_USEREDIT AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+IDD_FORWARDING AFX_DIALOG_LAYOUT
BEGIN
- 0x0000
+ 0
END
-IDD_FORWARDING AFX_DIALOG_LAYOUT MOVEABLE PURE
+FILTERS AFX_DIALOG_LAYOUT
BEGIN
- 0x0000
+ 0
END
-FILTERS AFX_DIALOG_LAYOUT MOVEABLE PURE
+BPQMAIL AFX_DIALOG_LAYOUT
BEGIN
- 0x0000
+ 0
END
@@ -1465,13 +1157,13 @@ END
// String Table
//
-STRINGTABLE DISCARDABLE
+STRINGTABLE
BEGIN
IDS_APP_TITLE "BPQMail"
IDC_BPQMailChat "BPQMail"
END
-#endif // English (U.K.) resources
+#endif // English (United Kingdom) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/BPQRemotePTT.cfg b/BPQRemotePTT.cfg
deleted file mode 100644
index 846bf91..0000000
--- a/BPQRemotePTT.cfg
+++ /dev/null
@@ -1,12 +0,0 @@
-main :
-{
- BPQHostIP = "192.168.1.64";
- COM1 = "COM43";
- COM2 = "";
- COM3 = "";
- COM4 = "";
- HamLibPort1 = 4534;
- HamLibPort2 = 0;
- HamLibPort3 = 0;
- HamLibPort4 = 0;
-};
diff --git a/Bpq32.c b/Bpq32.c
index 3bccd2f..9ca6ea5 100644
--- a/Bpq32.c
+++ b/Bpq32.c
@@ -1255,7 +1255,28 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Fix bug in RHP socket timeout code (65)
// Fix L4 RTT (66)
// Fix RigConrol with Chanxx but no other settings (66)
-
+// Add option to compress L2 frames (67)
+// Sort Routes displays (67)
+// Fix Ardop session premature close (70)
+// Add timestamps to log entries in Web Driver windows (70)
+// Generate stack backtrace if SIGSEGV or SIGABRT occur (Linux) (70)
+// Remove some debug logging from L2 code (70)
+// Fix compiling LinBPQ with nomqtt option (70)
+// Improve handling of binary data in RHP interface (70)
+// Fix sending KISS commands to multiport or multidropped TNCs (70)
+// Add MHUV and MHLV commands (Verbose listing with timestamps in clock time) (70)
+// Improvements to INP3 (71)
+// Improvements to KAM driver including support for GTOR connects (71)
+// Support IPv6 for Telnet outward connects (72)
+// Fix decaying NETROM routes (72)
+// Add OnlyVer2point0 config command (72)
+// Add option to allow AX/UDP on a network using NAT (72)
+// Include AGWAPI fixes from Martin KD6YAM to enable use with Paracon terminal (72)
+// Fix 64 bit compatiblility issues with AGWAPI (73)
+// Fix KAM Pactor Interlock (73)
+// Fix Node map reporting, broken in .73 (74)
+// Fixes to build on FreeBSD and NetBSD from jg1uaa (77)
+// Fix to L4Compress from Stece G7TAJ (77)
#define CKernel
@@ -2378,6 +2399,8 @@ FirstInit()
}
timeLoadedMS = GetTickCount();
+
+ srand(time(NULL));
INITIALISEPORTS();
@@ -6153,7 +6176,7 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile)
{
if (len > 76)
{
- len += sprintf(RegLine[len], "\\\r\n");
+ len += sprintf(&RegLine[len], "\\\r\n");
WriteFile(hFile, RegLine, len, &written, NULL);
strcpy(RegLine, " ");
len = 2;
@@ -6162,7 +6185,7 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile)
len += sprintf(&RegLine[len], "%02x,", Value[k]);
if (len > 76)
{
- len += sprintf(RegLine[len], "\\\r\n");
+ len += sprintf(&RegLine[len], "\\\r\n");
WriteFile(hFile, RegLine, len, &written, NULL);
strcpy(RegLine, " ");
}
diff --git a/CMSAuth.c b/CMSAuth.c
index ae63e4d..51a4b04 100644
--- a/CMSAuth.c
+++ b/CMSAuth.c
@@ -23,7 +23,6 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#ifdef LINBPQ
#include "compatbits.h"
-char * strlop(char * buf, char delim);
#define APIENTRY
#define VOID void
@@ -32,6 +31,8 @@ char * strlop(char * buf, char delim);
#include <windows.h>
#endif
+char * strlop(char * buf, char delim);
+
VOID APIENTRY md5 (char *arg, unsigned char * checksum);
diff --git a/ChatHTMLConfig.c b/ChatHTMLConfig.c
index c4071cf..604db8f 100644
--- a/ChatHTMLConfig.c
+++ b/ChatHTMLConfig.c
@@ -590,7 +590,7 @@ VOID SendChatStatusPage(char * Reply, int * ReplyLen, char * Key)
{
if (conn->Flags & CHATLINK)
{
- if (conn->BPQStream > 64 || conn->u.link == 0)
+ if (conn->BPQStream > 64 || conn->u.link == 0 || conn->u.link->alias == 0)
Len += sprintf(&Streams[Len], "<tr><td onclick= SelectRow(%d) id=cell_%d>** Corrupt ChatLink **</td>"
"<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>", i, i);
else
@@ -600,7 +600,7 @@ VOID SendChatStatusPage(char * Reply, int * ReplyLen, char * Key)
"", conn->OutputQueueLength - conn->OutputGetPointer);
}
else
- if ((conn->Flags & CHATMODE) && conn->topic)
+ if ((conn->Flags & CHATMODE) && conn->topic && conn->u.user && conn->u.user->call)
{
Len += sprintf(&Streams[Len], "<tr><td onclick='SelectRow(%d)' id='cell_%d'>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%d</td></tr>",
i, i, conn->u.user->name, conn->u.user->call, conn->BPQStream,
diff --git a/Cmd.c b/Cmd.c
index 6b1db1a..70a061e 100644
--- a/Cmd.c
+++ b/Cmd.c
@@ -70,6 +70,10 @@ void GetPortCTEXT(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, st
VOID WriteMiniDump();
int CheckKissInterlock(struct PORTCONTROL * PORT, int Exclusive);
int seeifInterlockneeded(struct PORTCONTROL * PORT);
+int CompareNode(const void *a, const void *b);
+int CompareAlias(const void *a, const void *b);
+int CompareRoutes(const void * a, const void * b);
+
extern VOID KISSTX(struct KISSINFO * KISS, PMESSAGE Buffer);
@@ -1225,38 +1229,81 @@ VOID CMDSTATS(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
}
+#define PFBIT 0x10 // POLL/FINAL BIT IN CONTROL BYTE
+
+VOID InformPartner(struct _LINKTABLE * LINK, int Reason);
+VOID L2SENDCOMMAND(struct _LINKTABLE * LINK, int CMD);
+BOOL FindLink(UCHAR * LinkCall, UCHAR * OurCall, int Port, struct _LINKTABLE ** REQLINK);
+
VOID CMDL00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CMDX * CMD)
{
// PROCESS 'LINKS' MESSAGE
struct _LINKTABLE * LINK = LINKS;
int n = MAXLINKS;
- int len;
+ int len, Count;
char Normcall[11] = "";
+ UCHAR DEST[7];
+ UCHAR ORIGIN[7];
+ int Port = 0;
+ char * ptr = 0, * Context;
- Bufferptr = Cmdprintf(Session, Bufferptr, "Links\r");
+ ptr = strtok_s(CmdTail, " ", &Context);
- while (n--)
+ if (ptr && _stricmp(ptr, "reset") == 0)
{
- if (LINK->LINKCALL[0])
- {
- len = ConvFromAX25(LINK->LINKCALL, Normcall);
+ ptr = strtok_s(NULL, " ", &Context);
+ if (ptr)
+ ConvToAX25(ptr, DEST);
+
+ ptr = strtok_s(NULL, " ", &Context);
+ if (ptr)
+ ConvToAX25(ptr, ORIGIN);
+
+ ptr = strtok_s(NULL, " ", &Context);
+ if (ptr)
+ Port = atoi(ptr);
- Bufferptr = Cmdprintf(Session, Bufferptr, "%s", Normcall);
+ if (FindLink(DEST, ORIGIN, Port, &LINK))
+ {
+ InformPartner(LINK, NORMALCLOSE); // TELL OTHER END ITS GONE
- len = ConvFromAX25(LINK->OURCALL, Normcall);
- Bufferptr = Cmdprintf(Session, Bufferptr, "%s", Normcall);
+ LINK->L2RETRIES -= 1; // Just send one DISC
+ LINK->L2STATE = 4; // CLOSING
- if (LINK->Ver2point2)
- Bufferptr = Cmdprintf(Session, Bufferptr, " S=%d P=%d T=%d V=2.2\r",
- LINK->L2STATE, LINK->LINKPORT->PORTNUMBER, LINK->LINKTYPE);
- else
- Bufferptr = Cmdprintf(Session, Bufferptr, " S=%d P=%d T=%d V=%d\r",
- LINK->L2STATE, LINK->LINKPORT->PORTNUMBER, LINK->LINKTYPE, 2 - LINK->VER1FLAG);
+ L2SENDCOMMAND(LINK, DISC | PFBIT);
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Link Reset\r");
}
- LINK++;
+ else
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Link Not Found\r");
+
}
+ else
+ {
+ Bufferptr = Cmdprintf(Session, Bufferptr, "Links\r");
+
+ while (n--)
+ {
+ if (LINK->LINKCALL[0])
+ {
+ len = ConvFromAX25(LINK->LINKCALL, Normcall);
+ Count = COUNT_AT_L2(LINK);
+
+ Bufferptr = Cmdprintf(Session, Bufferptr, "%s", Normcall);
+
+ len = ConvFromAX25(LINK->OURCALL, Normcall);
+ Bufferptr = Cmdprintf(Session, Bufferptr, "%s", Normcall);
+ if (LINK->Ver2point2)
+ Bufferptr = Cmdprintf(Session, Bufferptr, " S=%d P=%d T=%d V=2.2 Q=%d\r",
+ LINK->L2STATE, LINK->LINKPORT->PORTNUMBER, LINK->LINKTYPE, Count);
+ else
+ Bufferptr = Cmdprintf(Session, Bufferptr, " S=%d P=%d T=%d V=%d Q=%d\r",
+ LINK->L2STATE, LINK->LINKPORT->PORTNUMBER, LINK->LINKTYPE, 2 - LINK->VER1FLAG, Count);
+ }
+ LINK++;
+ }
+ }
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
}
@@ -1604,6 +1651,8 @@ VOID CMDR00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
int Port = 0;
char AXCALL[7];
BOOL Found;
+ int count, i, n = 0;
+ struct ROUTE * List[1000];
ptr = strtok_s(CmdTail, " ", &Context);
@@ -1623,15 +1672,32 @@ VOID CMDR00(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C
}
Bufferptr = Cmdprintf(Session, Bufferptr, "Routes\r");
-
- while (MaxRoutes--)
+
+ // Build and sort list of routes
+
+ for (count = 0; count < MaxRoutes; count++)
{
if (Routes->NEIGHBOUR_CALL[0] != 0)
- if (Port == 0 || Port == Routes->NEIGHBOUR_PORT)
- Bufferptr = DisplayRoute(Session, Bufferptr, Routes, Verbose);
+ {
+ List[n++] = Routes;
+
+ if (n > 999)
+ break;
+ }
Routes++;
}
+
+ if (n > 1)
+ qsort(List, n, sizeof(void *), CompareRoutes);
+
+ for (i = 0; i < n; i++)
+ {
+ Routes = List[i];
+
+ if (Port == 0 || Port == Routes->NEIGHBOUR_PORT)
+ Bufferptr = DisplayRoute(Session, Bufferptr, Routes, Verbose);
+ }
goto SendReply;
ROUTEUPDATE:
@@ -2817,15 +2883,12 @@ VOID LINKCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
}
-int CompareNode(const void *a, const void *b);
-int CompareAlias(const void *a, const void *b);
-
char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST * Dest)
{
char Normcall[10];
char Alias[10];
struct NR_DEST_ROUTE_ENTRY * NRRoute;
- struct DEST_ROUTE_ENTRY * Route;
+ struct INP3_DEST_ROUTE_ENTRY * Route;
struct ROUTE * Neighbour;
int i, Active, len;
@@ -2866,7 +2929,7 @@ char * DoOneNode(TRANSPORTENTRY * Session, char * Bufferptr, struct DEST_LIST *
// DISPLAY INP3 ROUTES
- Route = &Dest->ROUTE[0];
+ Route = &Dest->INP3ROUTE[0];
Active = Dest->DEST_ROUTE;
@@ -2923,17 +2986,17 @@ int DoINP3ViaEntry(struct DEST_LIST * Dest, int n, char * line, int cursor)
int len;
double srtt;
- if (Dest->ROUTE[n].ROUT_NEIGHBOUR != 0)
+ if (Dest->INP3ROUTE[n].ROUT_NEIGHBOUR != 0)
{
- srtt = Dest->ROUTE[n].SRTT/1000.0;
+ srtt = Dest->INP3ROUTE[n].SRTT/1000.0;
- len=ConvFromAX25(Dest->ROUTE[n].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Portcall);
+ len=ConvFromAX25(Dest->INP3ROUTE[n].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, Portcall);
Portcall[len]=0;
len=sprintf(&line[cursor],"%s %d %d %4.2fs ",
Portcall,
- Dest->ROUTE[n].ROUT_NEIGHBOUR->NEIGHBOUR_PORT,
- Dest->ROUTE[n].Hops, srtt);
+ Dest->INP3ROUTE[n].ROUT_NEIGHBOUR->NEIGHBOUR_PORT,
+ Dest->INP3ROUTE[n].Hops, srtt);
cursor+=len;
@@ -3221,7 +3284,7 @@ NODE_VIA:
{
Dest+=1;
- if (Dest->NRROUTE[0].ROUT_NEIGHBOUR == 0 && Dest->ROUTE[0].ROUT_NEIGHBOUR == 0)
+ if (Dest->NRROUTE[0].ROUT_NEIGHBOUR == 0 && Dest->INP3ROUTE[0].ROUT_NEIGHBOUR == 0)
continue;
@@ -3229,9 +3292,9 @@ NODE_VIA:
|| (Dest->NRROUTE[1].ROUT_NEIGHBOUR && CompareCalls(Dest->NRROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL))
|| (Dest->NRROUTE[2].ROUT_NEIGHBOUR && CompareCalls(Dest->NRROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL))
- || (Dest->ROUTE[0].ROUT_NEIGHBOUR && CompareCalls(Dest->ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL))
- || (Dest->ROUTE[1].ROUT_NEIGHBOUR && CompareCalls(Dest->ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL))
- || (Dest->ROUTE[2].ROUT_NEIGHBOUR && CompareCalls(Dest->ROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL)))
+ || (Dest->INP3ROUTE[0].ROUT_NEIGHBOUR && CompareCalls(Dest->INP3ROUTE[0].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL))
+ || (Dest->INP3ROUTE[1].ROUT_NEIGHBOUR && CompareCalls(Dest->INP3ROUTE[1].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL))
+ || (Dest->INP3ROUTE[2].ROUT_NEIGHBOUR && CompareCalls(Dest->INP3ROUTE[2].ROUT_NEIGHBOUR->NEIGHBOUR_CALL, AXCALL)))
{
len=ConvFromAX25(Dest->DEST_CALL,Normcall);
@@ -3602,7 +3665,7 @@ VOID MHCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CM
}
else
{
- if (CMD->String[2] == 'V') // MHV
+ if (CMD->String[2] == 'V' || CMD->String[3] == 'V') // MHV
{
Bufferptr = Cmdprintf(Session, Bufferptr, "MHeard List %s for Port %d\r", MYNODECALL, Port);
Bufferptr = Cmdprintf(Session, Bufferptr, "Callsign Last heard Pkts RX via Digi ;) \r");
@@ -4306,6 +4369,8 @@ struct CMDX COMMANDS[] =
"MHU ",3,MHCMD,0, // UTC Times
"MHL ",3,MHCMD,0, // Local Times
"MHV ",3,MHCMD,0,
+ "MHUV ",3,MHCMD,0, // UTC Times
+ "MHLV ",3,MHCMD,0, // Local Times
"MHEARD ",1,MHCMD,0,
"APRS ",2,APRSCMD,0,
"ATTACH ",1,ATTACHCMD,0,
@@ -5523,22 +5588,14 @@ VOID KISSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct
KISS = (struct KISSINFO *) PORT;
- if (KISS->FIRSTPORT != KISS)
- {
- Bufferptr = Cmdprintf(Session, Bufferptr, "Not first port of a Multidrop Set\r");
- SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
- return;
- }
-
// Send Command
KissLen = KissEncode(KissString, ENCBUFF, KissLen);
- PORT = (struct PORTCONTROL *)KISS->FIRSTPORT; // ALL FRAMES GO ON SAME Q
-
PORT->Session = Session;
PORT->LastKISSCmdTime = time(NULL);
+ PORT = (struct PORTCONTROL *)KISS->FIRSTPORT; // ALL FRAMES GO ON SAME Q
ASYSEND(PORT, ENCBUFF, KissLen);
Bufferptr = Cmdprintf(Session, Bufferptr, "Command Sent\r");
diff --git a/CommonCode.c b/CommonCode.c
index f00b8f6..9c0032d 100644
--- a/CommonCode.c
+++ b/CommonCode.c
@@ -77,6 +77,8 @@ char * stristr (char *ch1, char *ch2);
extern VOID * ENDBUFFERPOOL;
+extern int PoolBuilt;
+
// Read/Write length field in a buffer header
@@ -363,7 +365,7 @@ BOK1:
if (n > 1000)
{
- Debugprintf("Loop searching free chain - pointer = %p %p", debug, pointer);
+ Debugprintf("Releasebuffer Loop searching free chain - pointer = %p %p from %s Line %d", debug, pointer, File, Line);
return 0;
}
}
@@ -376,6 +378,11 @@ BOK1:
QCOUNT++;
+ if (PoolBuilt && QCOUNT > MAXBUFFS)
+ {
+ Debugprintf("Releasebuffer QCOUNT > MAXBUFFS - pointer = %p from %s Line %d", pointer, File, Line);
+ return 0;
+ }
return 0;
}
@@ -473,7 +480,7 @@ int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF)
next = Q[0];
while (next[0] != 0)
- next=next[0]; // Chain to end of queue
+ next = next[0]; // Chain to end of queue
next[0] = BUFF; // New one on end
@@ -1061,6 +1068,7 @@ BOOL ReadConfigFile(int Port, int ProcLine(char * buf, int Port))
WritetoConsoleLocal("\n");
WritetoConsoleLocal("Bad config record ");
WritetoConsoleLocal(errbuf);
+ WritetoConsoleLocal("\n");
}
}
}
@@ -1124,6 +1132,11 @@ int CompareNode(struct DEST_LIST ** a, struct DEST_LIST ** b)
return memcmp(a[0]->DEST_CALL, b[0]->DEST_CALL, 7);
}
+int CompareRoutes(struct ROUTE ** a, struct ROUTE ** b)
+{
+ return memcmp(a[0]->NEIGHBOUR_CALL, b[0]->NEIGHBOUR_CALL, 7);
+}
+
DllExport int APIENTRY CountFramesQueuedOnStream(int Stream)
{
BPQVECSTRUC * PORTVEC = &BPQHOSTVECTOR[Stream-1]; // API counts from 1
@@ -2129,7 +2142,16 @@ int CanPortDigi(int Port)
return TRUE;
}
-struct PORTCONTROL * APIENTRY GetPortTableEntryFromPortNum(int portnum)
+DllExport int APIENTRY GetPortHardwareType(struct PORTCONTROL *PORT)
+{
+ if (PORT)
+ return PORT->Hardware;
+
+ return 0;
+}
+
+
+DllExport struct PORTCONTROL * APIENTRY GetPortTableEntryFromPortNum(int portnum)
{
struct PORTCONTROL * PORTVEC = PORTTABLE;
diff --git a/Events.c b/Events.c
index 6d5f618..fdbb96b 100644
--- a/Events.c
+++ b/Events.c
@@ -168,6 +168,12 @@ void hookL2SessionDeleted(struct _LINKTABLE * LINK)
LINK->ConnectTime = 0;
}
+
+ if (LINK->Sent && LINK->Received && (LINK->SentAfterCompression || LINK->ReceivedAfterExpansion))
+ Debugprintf("L2 Compression Stats %s %s TX %d %d %d%% RX %d %d %d%%", LINK->callingCall, LINK->receivingCall,
+ LINK->Sent, LINK->SentAfterCompression, ((LINK->Sent - LINK->SentAfterCompression) * 100) / LINK->Sent,
+ LINK->Received, LINK->ReceivedAfterExpansion, ((LINK->ReceivedAfterExpansion - LINK->Received) * 100) / LINK->Received);
+
}
void hookL2SessionAttempt(int Port, char * ourcall, char * remotecall, struct _LINKTABLE * LINK)
diff --git a/FBBRoutines.c b/FBBRoutines.c
index 1810bf9..bc0a854 100644
--- a/FBBRoutines.c
+++ b/FBBRoutines.c
@@ -27,6 +27,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line);
+void DeleteRestartData(CIRCUIT * conn);
+
int32_t Encode(char * in, char * out, int32_t inlen, BOOL B1Protocol, int Compress);
void MQTTMessageEvent(void* message);
@@ -41,6 +43,130 @@ int B2RestartCount = 0;
extern char ProperBaseDir[];
+char RestartDir[MAX_PATH] = "";
+
+void GetRestartData()
+{
+ int i;
+ struct FBBRestartData Restart;
+ struct FBBRestartData * RestartRec;
+ char MsgFile[MAX_PATH];
+ FILE * hFile;
+ int FileSize;
+ struct stat STAT;
+ size_t ReadLen = 0;
+ time_t Age;
+
+ strcpy(RestartDir, MailDir);
+ strcat(RestartDir, "/Restart");
+
+ // Make sure RestartDir exists
+
+#ifdef WIN32
+ CreateDirectory(RestartDir, NULL); // Just in case
+#else
+ mkdir(RestartDir, S_IRWXU | S_IRWXG | S_IRWXO);
+ chmod(RestartDir, S_IRWXU | S_IRWXG | S_IRWXO);
+#endif
+
+ // look for restart files. These will be numbered from 1 up
+
+ for (i = 1; 1; i++)
+ {
+ sprintf_s(MsgFile, sizeof(MsgFile), "%s/%d", RestartDir, i);
+
+ if (stat(MsgFile, &STAT) == -1)
+ break;
+
+ FileSize = STAT.st_size;
+
+ Age = time(NULL) - STAT.st_ctime;
+
+ if (Age > 86400 * 2) // Max 2 days
+ continue;
+
+ hFile = fopen(MsgFile, "rb");
+
+ if (hFile == NULL)
+ break;
+
+ // Read Restart Record
+
+ fread(&Restart, 1, sizeof(struct FBBRestartData), hFile);
+
+ if ((Restart.MailBufferSize + sizeof(struct FBBRestartData)) != FileSize) // Duff file
+ {
+ fclose(hFile);
+ break;
+ }
+
+ RestartRec = zalloc(sizeof (struct FBBRestartData));
+
+ GetSemaphore(&AllocSemaphore, 0);
+
+ RestartData = realloc(RestartData,(++RestartCount+1) * sizeof(void *));
+ RestartData[RestartCount] = RestartRec;
+
+ FreeSemaphore(&AllocSemaphore);
+
+ memcpy(RestartRec, &Restart, sizeof(struct FBBRestartData));
+ RestartRec->MailBuffer = malloc(RestartRec->MailBufferSize);
+ ReadLen = fread(RestartRec->MailBuffer, 1, RestartRec->MailBufferSize, hFile);
+
+ Logprintf(LOG_BBS, 0, '?', "Restart Data for %s %s Len %d Loaded", RestartRec->Call, RestartRec->bid, RestartRec->length);
+ fclose(hFile);
+ }
+}
+
+
+void SaveRestartData()
+{
+ // Save restart data to file so we can reload on restart
+ // Restart data has pointers to buffers so we must save copy of data and reconstitue on restart
+
+ // Delete and resave all restart data to keep restart directory clean
+
+ int i, n = 1;
+ char MsgFile[MAX_PATH];
+ FILE * hFile;
+ size_t WriteLen=0;
+ struct FBBRestartData * RestartRec = NULL;
+ struct stat STAT;
+ time_t NOW = time(NULL);
+
+
+ for (i = 1; 1; i++)
+ {
+ sprintf_s(MsgFile, sizeof(MsgFile), "%s/%d", RestartDir, i);
+
+ if (stat(MsgFile, &STAT) == -1)
+ break;
+
+ DeleteFile(MsgFile);
+ }
+
+ for (i = 1; i <= RestartCount; i++)
+ {
+ RestartRec = RestartData[i];
+
+ if (RestartRec == 0)
+ return; // Shouldn't happen!
+
+ if ((NOW - RestartRec->TimeCreated) > 86400 * 2) // Max 2 days
+ continue;
+
+ sprintf_s(MsgFile, sizeof(MsgFile), "%s/%d", RestartDir, n++);
+
+ hFile = fopen(MsgFile, "wb");
+
+ if (hFile)
+ {
+ WriteLen = fwrite(RestartRec, 1, sizeof(struct FBBRestartData), hFile); // Save Header
+ WriteLen = fwrite(RestartRec->MailBuffer, 1, RestartRec->MailBufferSize, hFile); // Save Data
+ fclose(hFile);
+ }
+ }
+}
VOID FBBputs(CIRCUIT * conn, char * buf)
{
// Sends to user and logs
@@ -985,12 +1111,12 @@ loop:
{
RestartRec = RestartData[i];
- if ((RestartRec->UserPointer == conn->UserPointer)
- && (strcmp(RestartRec->TempMsg->bid, conn->TempMsg->bid) == 0))
+ if ((strcmp(RestartRec->Call, conn->UserPointer->Call) == 0)
+ && (strcmp(RestartRec->bid, conn->TempMsg->bid) == 0))
{
- if (RestartRec->TempMsg->length <= offset)
+ if (RestartRec->length <= offset)
{
- conn->TempMsg->length = RestartRec->TempMsg->length;
+ conn->TempMsg->length = RestartRec->length;
conn->MailBuffer = RestartRec->MailBuffer;
conn->MailBufferSize = RestartRec->MailBufferSize;
@@ -1019,6 +1145,7 @@ loop:
RestartData[n] = RestartData[n+1]; // move down all following entries
}
RestartCount--;
+ SaveRestartData();
}
}
@@ -1146,6 +1273,7 @@ loop:
{
#endif
conn->InputMode = 0; // So we won't save Restart data if decode fails
+ DeleteRestartData(conn);
Decode(conn, 0); // Setup Next Message will reset InputMode if needed
#ifndef LINBPQ
}
@@ -1845,14 +1973,14 @@ VOID SaveFBBBinary(CIRCUIT * conn)
{
RestartRec = RestartData[i];
- if ((RestartRec->UserPointer == conn->UserPointer)
- && (strcmp(RestartRec->TempMsg->bid, conn->TempMsg->bid) == 0))
+ if ((strcmp(RestartRec->Call, conn->UserPointer->Call) == 0)
+ && (strcmp(RestartRec->bid, conn->TempMsg->bid) == 0))
{
- // Fund it, so reuse
+ // Found it, so reuse
// If we have more data, reset retry count
- if (RestartRec->TempMsg->length < conn->TempMsg->length)
+ if (RestartRec->length < conn->TempMsg->length)
RestartRec->Count = 0;;
break;
@@ -1869,19 +1997,53 @@ VOID SaveFBBBinary(CIRCUIT * conn)
RestartData[RestartCount] = RestartRec;
FreeSemaphore(&AllocSemaphore);
+ RestartRec->TimeCreated = time(NULL);
}
- RestartRec->UserPointer = conn->UserPointer;
- RestartRec->TempMsg = conn->TempMsg;
+ strcpy(RestartRec->Call, conn->UserPointer->Call);
+ RestartRec->length = conn->TempMsg->length;
+ strcpy(RestartRec->bid, conn->TempMsg->bid);
RestartRec->MailBuffer = conn->MailBuffer;
RestartRec->MailBufferSize = conn->MailBufferSize;
len = sprintf_s(Msg, sizeof(Msg), "Disconnect received from %s during Binary Transfer - %d Bytes Saved for restart",
conn->Callsign, conn->TempMsg->length);
+ SaveRestartData();
+
WriteLogLine(conn, '|',Msg, len, LOG_BBS);
}
+void DeleteRestartData(CIRCUIT * conn)
+{
+ struct FBBRestartData * RestartRec = NULL;
+ int i, n;
+
+ if (conn->TempMsg == NULL)
+ return;
+
+ for (i = 1; i <= RestartCount; i++)
+ {
+ RestartRec = RestartData[i];
+
+ if ((strcmp(RestartRec->Call, conn->UserPointer->Call) == 0)
+ && (strcmp(RestartRec->bid, conn->TempMsg->bid) == 0))
+ {
+ // Remove restrt data
+
+ for (n = i; n < RestartCount; n++)
+ {
+ RestartData[n] = RestartData[n+1]; // move down all following entries
+ }
+
+ RestartCount--;
+ SaveRestartData();
+ return;
+ }
+ }
+}
+
+
BOOL LookupRestart(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader)
{
int i, n;
@@ -1895,15 +2057,15 @@ BOOL LookupRestart(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader)
{
RestartRec = RestartData[i];
- if ((RestartRec->UserPointer == conn->UserPointer)
- && (strcmp(RestartRec->TempMsg->bid, FBBHeader->BID) == 0))
+ if ((strcmp(RestartRec->Call, conn->UserPointer->Call) == 0)
+ && (strcmp(RestartRec->bid, FBBHeader->BID) == 0))
{
char Msg[120];
int len;
RestartRec->Count++;
- if (RestartRec->Count > 3)
+ if (RestartRec->Count > 10)
{
len = sprintf_s(Msg, sizeof(Msg), "Too many restarts for %s - Requesting restart from beginning",
FBBHeader->BID);
@@ -1918,15 +2080,16 @@ BOOL LookupRestart(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader)
}
RestartCount--;
+ SaveRestartData();
return FALSE;
}
len = sprintf_s(Msg, sizeof(Msg), "Restart Data found for %s - Requesting restart from %d",
- FBBHeader->BID, RestartRec->TempMsg->length);
+ FBBHeader->BID, RestartRec->length);
WriteLogLine(conn, '|',Msg, len, LOG_BBS);
- return (RestartRec->TempMsg->length);
+ return (RestartRec->length);
}
}
diff --git a/FLDigi64.c b/FLDigi64.c
new file mode 100644
index 0000000..4ca0a8d
--- /dev/null
+++ b/FLDigi64.c
@@ -0,0 +1,3860 @@
+/*
+Copyright 2001-2018 John Wiseman G8BPQ
+
+This file is part of LinBPQ/BPQ32.
+
+LinBPQ/BPQ32 is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+LinBPQ/BPQ32 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
+*/
+
+//
+// FLARQ Emulator/FLDIGI Interface for BPQ32
+//
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "CHeaders.h"
+
+int (WINAPI FAR *GetModuleFileNameExPtr)();
+int (WINAPI FAR *EnumProcessesPtr)();
+
+
+#include <stdio.h>
+#include <time.h>
+
+#include "tncinfo.h"
+
+#include "bpq32.h"
+
+#define VERSION_MAJOR 2
+#define VERSION_MINOR 0
+
+#define SD_RECEIVE 0x00
+#define SD_SEND 0x01
+#define SD_BOTH 0x02
+
+#define DLE 0x10
+#define SOH 1
+#define STX 2
+#define EOT 4
+
+#define FEND 0xC0
+#define FESC 0xDB
+#define TFEND 0xDC
+#define TFESC 0xDD
+
+#define TIMESTAMP 352
+
+#define CONTIMEOUT 1200
+
+#define AGWHDDRLEN sizeof(struct AGWHEADER)
+
+extern int (WINAPI FAR *GetModuleFileNameExPtr)();
+
+//int ResetExtDriver(int num);
+extern char * PortConfig[33];
+int SemHeldByAPI;
+
+struct TNCINFO * TNCInfo[34]; // Records are Malloc'd
+
+static void ConnecttoFLDigiThread(void * portptr);
+
+void CreateMHWindow();
+int Update_MH_List(struct in_addr ipad, char * call, char proto);
+
+static int ConnecttoFLDigi();
+static int ProcessReceivedData(int bpqport);
+static int ProcessLine(char * buf, int Port);
+int KillTNC(struct TNCINFO * TNC);
+static int RestartTNC(struct TNCINFO * TNC);
+VOID ProcessFLDigiPacket(struct TNCINFO * TNC, char * Message, int Len);
+VOID ProcessFLDigiKISSPacket(struct TNCINFO * TNC, char * Message, int Len);
+struct TNCINFO * GetSessionKey(char * key, struct TNCINFO * TNC);
+VOID SendARQData(struct TNCINFO * TNC, UINT * Buffer);
+static VOID DoMonitorHddr(struct TNCINFO * TNC, struct AGWHEADER * RXHeader, UCHAR * Msg);
+VOID SendRPBeacon(struct TNCINFO * TNC);
+VOID FLReleaseTNC(struct TNCINFO * TNC);
+unsigned int CalcCRC(UCHAR * ptr, int Len);
+VOID ARQTimer(struct TNCINFO * TNC);
+VOID QueueAndSend(struct TNCINFO * TNC, struct ARQINFO * ARQ, SOCKET sock, char * Msg, int MsgLen);
+VOID SaveAndSend(struct TNCINFO * TNC, struct ARQINFO * ARQ, SOCKET sock, char * Msg, int MsgLen);
+VOID ProcessARQStatus(struct TNCINFO * TNC, struct ARQINFO * ARQ, char *Input);
+VOID SendXMLPoll(struct TNCINFO * TNC);
+static int ProcessXMLData(int port);
+VOID CheckFLDigiData(struct TNCINFO * TNC);
+VOID SendPacket(struct TNCINFO * TNC, UCHAR * Msg, int MsgLen);
+int KissEncode(UCHAR * inbuff, UCHAR * outbuff, int len);
+VOID SendXMLCommand(struct TNCINFO * TNC, char * Command, char * Value, char ParamType);
+VOID FLSlowTimer(struct TNCINFO * TNC);
+VOID SendKISSCommand(struct TNCINFO * TNC, char * Msg);
+
+int DoScanLine(struct TNCINFO * TNC, char * Buff, int Len);
+VOID SuspendOtherPorts(struct TNCINFO * ThisTNC);
+VOID ReleaseOtherPorts(struct TNCINFO * ThisTNC);
+
+char * strlop(char * buf, char delim);
+
+extern UCHAR BPQDirectory[];
+
+#define MAXBPQPORTS 32
+#define MAXMPSKPORTS 16
+
+//LOGFONT LFTTYFONT ;
+
+//HFONT hFont ;
+
+static int MPSKChannel[MAXBPQPORTS+1]; // BPQ Port to MPSK Port
+static int BPQPort[MAXMPSKPORTS][MAXBPQPORTS+1]; // MPSK Port and Connection to BPQ Port
+//static int MPSKtoBPQ_Q[MAXBPQPORTS+1]; // Frames for BPQ, indexed by BPQ Port
+//static int BPQtoMPSK_Q[MAXBPQPORTS+1]; // Frames for MPSK. indexed by MPSK port. Only used it TCP session is blocked
+
+// Each port may be on a different machine. We only open one connection to each MPSK instance
+
+static char * MPSKSignon[MAXBPQPORTS+1]; // Pointer to message for secure signin
+
+static unsigned int MPSKInst = 0;
+static int AttachedProcesses=0;
+
+static HWND hResWnd,hMHWnd;
+static BOOL GotMsg;
+
+static HANDLE STDOUT=0;
+
+//SOCKET sock;
+
+static SOCKADDR_IN sinx;
+static SOCKADDR_IN rxaddr;
+static SOCKADDR_IN destaddr[MAXBPQPORTS+1];
+
+static int addrlen=sizeof(sinx);
+
+//static short MPSKPort=0;
+
+static time_t ltime,lasttime[MAXBPQPORTS+1];
+
+static BOOL CONNECTING[MAXBPQPORTS+1];
+static BOOL CONNECTED[MAXBPQPORTS+1];
+
+//HANDLE hInstance;
+
+static char WindowTitle[] = "FLDIGI";
+static char ClassName[] = "FLDIGISTATUS";
+static int RigControlRow = 165;
+
+static fd_set readfs;
+static fd_set writefs;
+static fd_set errorfs;
+static struct timeval timeout;
+
+int Blocksizes[10] = {0,2,4,8,16,32,64,128,256,512};
+
+
+static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
+{
+ PMSGWITHLEN buffptr;
+ char txbuff[500];
+ unsigned int txlen=0;
+ struct TNCINFO * TNC = TNCInfo[port];
+ int Stream = 0;
+ struct STREAMINFO * STREAM;
+ int TNCOK;
+
+ if (TNC == NULL)
+ return 0; // Port not defined
+
+ // Look for attach on any call
+
+// for (Stream = 0; Stream <= 1; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && TNC->Streams[Stream].Attached == 0)
+ {
+ char Cmd[80];
+
+ // New Attach
+
+ int calllen;
+ STREAM->Attached = TRUE;
+
+ TNC->FLInfo->RAW = FALSE;
+
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, STREAM->MyCall);
+ STREAM->MyCall[calllen] = 0;
+ STREAM->FramesOutstanding = 0;
+
+ SuspendOtherPorts(TNC); // Dont allow connects on interlocked ports
+
+ // Stop Scanning
+
+ sprintf(Cmd, "%d SCANSTOP", TNC->Port);
+ Rig_Command(-1, Cmd);
+
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+/* len = sprintf(Cmd, "%cSTOP_BEACON_ARQ_FAE\x1b", '\x1a');
+
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Cmd); // Savde till not transmitting
+ else
+ SendPacket(TNC->TCPDataSock, Cmd, len, 0);
+*/
+ }
+ }
+
+ switch (fn)
+ {
+ case 7:
+
+ // 100 mS Timer.
+
+ // See if waiting for busy to clear before sending a connect
+
+ if (TNC->BusyDelay)
+ {
+ // Still Busy?
+
+ if (InterlockedCheckBusy(TNC) == FALSE)
+ {
+ // No, so send connect
+
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ int SendLen;
+ char Reply[80];
+
+ SendLen = sprintf(Reply, "c%s:42 %s:24 %c 7 T60R5W10",
+ STREAM->MyCall, STREAM->RemoteCall, ARQ->OurStream);
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connecting");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ ARQ->ARQState = ARQ_ACTIVE;
+
+ ARQ->ARQTimerState = ARQ_CONNECTING;
+ SaveAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+
+ STREAM->Connecting = TRUE;
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", STREAM->MyCall, STREAM->RemoteCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connecting");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ TNC->BusyDelay = 0;
+ }
+ else
+ {
+ // Wait Longer
+
+ TNC->BusyDelay--;
+
+ if (TNC->BusyDelay == 0)
+ {
+ // Timed out - Send Error Response
+
+ UINT * buffptr = GetBuff();
+
+ if (buffptr == 0) return (0); // No buffers, so ignore
+
+ buffptr[1]=39;
+ memcpy(buffptr+2,"Sorry, Can't Connect - Channel is busy\r", 39);
+
+ C_Q_ADD(&TNC->Streams[0].PACTORtoBPQ_Q, buffptr);
+ free(TNC->ConnectCmd);
+
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ }
+ }
+ }
+
+
+
+ if (STREAM->NeedDisc)
+ {
+ STREAM->NeedDisc--;
+
+ if (STREAM->NeedDisc == 0)
+ {
+ // Send the DISCONNECT
+
+ TidyClose(TNC, 0);
+ }
+ }
+
+ ARQTimer(TNC);
+ SendXMLPoll(TNC);
+
+ TNC->SlowTimer--;
+
+ if (TNC->SlowTimer < 0)
+ {
+ 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
+
+ time( &ltime );
+ if (ltime-lasttime[port] >9 )
+ {
+ ConnecttoFLDigi(port);
+ lasttime[port]=ltime;
+ }
+ }
+
+ FD_ZERO(&readfs);
+
+ if (TNC->CONNECTED)
+ if (TNC->TCPSock)
+ FD_SET(TNC->TCPSock,&readfs);
+
+ if (TNC->CONNECTED || TNC->FLInfo->KISSMODE)
+ 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->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))
+ {
+ // data available
+
+ ProcessReceivedData(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;
+
+ sprintf(TNC->WEB_COMMSSTATE, "Connected to FLDIGI");
+ SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+
+ // If required, send signon
+
+// SendPacket(TNC->TCPDataSock,"\x1a", 1, 0);
+// SendPacket(TNC->TCPDataSock,"DIGITAL MODE ?", 14, 0);
+// SendPacket(TNC->TCPDataSock,"\x1b", 1, 0);
+
+// 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;
+
+ }
+
+ }
+
+
+
+ // See if any frames for this port
+
+ for (Stream = 0; Stream <= 1; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+
+ if (STREAM->Attached)
+ CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+
+ if (STREAM->ReportDISC)
+ {
+ STREAM->ReportDISC = FALSE;
+ buff->PORT = Stream;
+
+ 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
+ {
+ int datalen;
+
+ buffptr=Q_REM(&STREAM->PACTORtoBPQ_Q);
+
+ datalen = (int)buffptr->Len;
+
+ 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;
+
+ PutLengthinBuffer(buff, datalen);
+
+ ReleaseBuffer(buffptr);
+
+ 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;
+
+ 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
+
+
+ if (!TNC->CONNECTED) return 0; // Don't try if not connected to TNC
+
+ Stream = buff->PORT;
+
+ STREAM = &TNC->Streams[Stream];
+
+// txlen=(buff[6]<<8) + buff[5] - 8;
+
+ txlen = GetLengthfromBuffer((PDATAMESSAGE)buff) - 8;
+
+ if (STREAM->Connected)
+ {
+ buffptr = GetBuff();
+
+ if (buffptr == 0) return (0); // No buffers, so ignore
+
+ buffptr->Len = txlen;
+ memcpy(buffptr->Data, buff->L2DATA, txlen);
+
+ C_Q_ADD(&TNC->Streams[Stream].BPQtoPACTOR_Q, buffptr);
+
+ return (0);
+ }
+ else
+ {
+ buff->L2DATA[txlen] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ if (_memicmp(&buff->L2DATA[0], "D\r", 2) == 0)
+ {
+ if (STREAM->Connected)
+ TidyClose(TNC, buff->PORT);
+
+ STREAM->ReportDISC = TRUE; // Tell Node
+
+ TNC->FLInfo->MCASTMODE = FALSE;
+
+ return 0;
+ }
+
+ // See if Local command (eg RADIO)
+
+ if (_memicmp(&buff->L2DATA[0], "RADIO ", 6) == 0)
+ {
+ sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]);
+
+ if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0]))
+ {
+ }
+ else
+ {
+ PMSGWITHLEN buffptr = (PMSGWITHLEN)GetBuff();
+
+ if (buffptr == 0) return 1; // No buffers, so ignore
+
+ buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "%s", &buff->L2DATA[0]);
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+
+ }
+ return 1;
+ }
+
+ if (_memicmp(&buff->L2DATA[0], "MODEM ", 6) == 0)
+ {
+ buff->L2DATA[txlen -1] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ // If in KISS mode, send as a KISS command Frame
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ sprintf(txbuff, "MODEM:%s MODEM:", &buff->L2DATA[6]);
+ SendKISSCommand(TNC, txbuff);
+ }
+ else
+ {
+ SendXMLCommand(TNC, "modem.set_by_name", &buff->L2DATA[6], 'S');
+ }
+
+ TNC->InternalCmd = TRUE;
+ return 1;
+ }
+
+ if (_memicmp(buff->L2DATA, "FREQ ", 5) == 0)
+ {
+ buff->L2DATA[txlen - 1] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ // If in KISS mode, send as a KISS command Frame
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ sprintf(txbuff, "WFF:%s WFF:", &buff->L2DATA[5]);
+ SendKISSCommand(TNC, txbuff);
+ }
+ else
+ {
+ SendXMLCommand(TNC, "modem.set_carrier", atoi(&buff->L2DATA[5]), 'I');
+ }
+
+ TNC->InternalCmd = TRUE;
+ return 1;
+ }
+
+ if (_memicmp(buff->L2DATA, "SQUELCH ", 8) == 0)
+ {
+ buff->L2DATA[txlen - 1] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ // Only works in KISS
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ if (_memicmp(&buff->L2DATA[8], "ON", 2) == 0)
+ sprintf(txbuff, "KPSQL:ON KPSQL:");
+
+ else if (_memicmp(&buff->L2DATA[8], "OFF", 3) == 0)
+ sprintf(txbuff, "KPSQL:OFF KPSQL:");
+ else
+ txlen = sprintf(txbuff, "KPSQLS:%s KPSQLS:", &buff->L2DATA[8]);
+
+ SendKISSCommand(TNC, txbuff);
+ TNC->InternalCmd = TRUE;
+ }
+ return 1;
+ }
+
+ if (_memicmp(buff->L2DATA, "KPSATT ", 7) == 0)
+ {
+ buff->L2DATA[txlen - 1] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ // If in KISS mode, send as a KISS command Frame
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ sprintf(txbuff, "KPSATT:%s KPSATT:", &buff->L2DATA[7]);
+
+ SendKISSCommand(TNC, txbuff);
+ TNC->InternalCmd = TRUE;
+ }
+
+ return 1;
+ }
+
+ if (STREAM->Connecting && _memicmp(buff->L2DATA, "ABORT", 5) == 0)
+ {
+// len = sprintf(Command,"%cSTOP_SELECTIVE_CALL_ARQ_FAE\x1b", '\x1a');
+
+// if (TNC->MPSKInfo->TX)
+// TNC->CmdSet = TNC->CmdSave = _strdup(Command); // Save till not transmitting
+// else
+// SendPacket(TNC->TCPDataSock, Command, len, 0);
+
+// TNC->InternalCmd = TRUE;
+ return (0);
+ }
+
+ if (_memicmp(&buff->L2DATA[0], "MODE", 4) == 0)
+ {
+ PMSGWITHLEN buffptr = GetBuff();
+
+ buff->L2DATA[txlen - 1] = 0; // Remove CR
+
+ if (strstr(&buff->L2DATA[0], "RAW"))
+ TNC->FLInfo->RAW = TRUE;
+ else if (strstr(&buff->L2DATA[0], "KISS"))
+ TNC->FLInfo->RAW = FALSE;
+ else
+ {
+ buffptr->Len = sprintf(&buffptr->Data[0], "FLDigi} Error - Invalid Mode\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ return 1;
+ }
+
+ buffptr->Len = sprintf(&buffptr->Data[0], "FLDigi} Ok - Mode is %s\r",
+ (TNC->FLInfo->RAW)?"RAW":"KISS");
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ return 1;
+ }
+
+ if (_memicmp(&buff->L2DATA[0], "MCAST", 5) == 0)
+ {
+ UINT * buffptr = GetBuff();
+
+ TNC->FLInfo->MCASTMODE = TRUE;
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "FLDigi} Ok\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ return 1;
+ }
+
+ if (_memicmp(&buff->L2DATA[0], "INUSE?", 6) == 0)
+ {
+ // Return Error if in use, OK if not
+
+ UINT * buffptr = GetBuff();
+ int s = 0;
+
+ while(s <= 1)
+ {
+ if (s != Stream)
+ {
+ if (TNC->PortRecord->ATTACHEDSESSIONS[s])
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "FLDig} Error - In use\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ return 1; // Busy
+ }
+ }
+ s++;
+ }
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "FLDigi} Ok - Not in use\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ return 1;
+ }
+
+ // See if a Connect Command.
+
+ if (toupper(buff->L2DATA[0]) == 'C' && buff->L2DATA[1] == ' ' && txlen > 2) // Connect
+ {
+ char * ptr;
+ char * context;
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ int SendLen;
+ char Reply[80];
+
+ buff->L2DATA[txlen] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ memset(ARQ, 0, sizeof(struct ARQINFO)); // Reset ARQ State
+ ARQ->TXSeq = ARQ->TXLastACK = 63; // Last Sent
+ ARQ->RXHighest = ARQ->RXNoGaps = 63; // Last Received
+ ARQ->OurStream = (rand() % 78) + 49; // To give some protection against other stuff on channel
+ ARQ->FarStream = 48; // Not yet defined
+ TNC->FLInfo->FLARQ = FALSE;
+
+ memset(STREAM->RemoteCall, 0, 10);
+
+ ptr = strtok_s(&buff->L2DATA[2], " ,\r", &context);
+ strcpy(STREAM->RemoteCall, ptr);
+
+ // See if Busy
+
+ if (InterlockedCheckBusy(TNC))
+ {
+ // Channel Busy. Unless override set, wait
+
+ if (TNC->OverrideBusy == 0)
+ {
+ // Save Command, and wait up to 10 secs
+
+ sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs
+ return 0;
+ }
+ }
+
+ TNC->OverrideBusy = FALSE;
+
+//<SOH>00cG8BPQ:1025 G8BPQ:24 0 7 T60R5W10FA36<EOT>
+
+ SendLen = sprintf(Reply, "c%s:42 %s:24 %c 7 T60R5W10",
+ STREAM->MyCall, STREAM->RemoteCall, ARQ->OurStream);
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connecting");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ ARQ->ARQState = ARQ_ACTIVE;
+
+ ARQ->ARQTimerState = ARQ_CONNECTING;
+ SaveAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+
+ STREAM->Connecting = TRUE;
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", STREAM->MyCall, STREAM->RemoteCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connecting");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ return 0;
+ }
+
+ // Send any other command to FLDIGI
+
+ buff->L2DATA[txlen - 1] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ // If in KISS mode, send as a KISS command Frame
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ char outbuff[1000];
+ int newlen;
+
+ buff->L2DATA[-1] = 6; // KISS Control
+
+ newlen = KissEncode(&buff->L2DATA[-1], outbuff, txlen);
+ sendto(TNC->TCPDataSock, outbuff, newlen, 0, (struct sockaddr *)&TNC->Datadestaddr, sizeof(struct sockaddr));
+ }
+ else
+ {
+ SendXMLCommand(TNC, "modem.set_by_name", &buff->L2DATA[0], 'S');
+ }
+
+ TNC->InternalCmd = TRUE;
+ }
+
+ return (0);
+
+ case 3:
+
+ Stream = (int)(size_t)buff;
+
+ TNCOK = TNC->CONNECTED;
+
+ STREAM = &TNC->Streams[Stream];
+ {
+ // Busy if TX Window reached
+
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ int Outstanding;
+
+ Outstanding = ARQ->TXSeq - ARQ->TXLastACK;
+
+ if (Outstanding < 0)
+ Outstanding += 64;
+
+ TNC->PortRecord->FramesQueued = Outstanding + C_Q_COUNT(&TNC->Streams[0].BPQtoPACTOR_Q); // Save for Appl Level Queued Frames
+
+ if (Outstanding > ARQ->TXWindow)
+ return (1 | TNCOK << 8 | STREAM->Disconnecting << 15); // 3rd Nibble is frames unacked
+ else
+ return TNCOK << 8 | STREAM->Disconnecting << 15;
+
+ }
+ return TNCOK << 8 | STREAM->Disconnecting << 15; // OK, but lock attach if disconnecting
+
+ case 4: // reinit
+
+ shutdown(TNC->TCPSock, SD_BOTH);
+ shutdown(TNC->TCPDataSock, SD_BOTH);
+ Sleep(100);
+
+ closesocket(TNC->TCPSock);
+ closesocket(TNC->TCPDataSock);
+ TNC->CONNECTED = FALSE;
+
+ if (TNC->WeStartedTNC)
+ {
+ KillTNC(TNC);
+ RestartTNC(TNC);
+ }
+
+ return (0);
+
+ case 5: // Close
+
+ shutdown(TNC->TCPSock, SD_BOTH);
+ shutdown(TNC->TCPDataSock, SD_BOTH);
+ Sleep(100);
+
+ closesocket(TNC->TCPSock);
+ closesocket(TNC->TCPDataSock);
+
+ if (TNC->WeStartedTNC)
+ {
+ KillTNC(TNC);
+ }
+
+ return 0;
+ }
+
+ return 0;
+}
+
+#ifndef LINBPQ
+
+int FindFLDIGI(char * Path)
+{
+ HANDLE hProc;
+ char ExeName[256] = "";
+ char FLDIGIName[256];
+ DWORD Pid = 0;
+ DWORD Processes[1024], Needed, Count;
+ unsigned int i;
+
+ if (EnumProcessesPtr == NULL)
+ return 0; // Cant get PID
+
+ if (!EnumProcessesPtr(Processes, sizeof(Processes), &Needed))
+ return TRUE;
+
+ // Path is to .bat, so need to strip extension of both names
+
+ strcpy(FLDIGIName, Path);
+ strlop(FLDIGIName, '.');
+
+ // Calculate how many process identifiers were returned.
+
+ Count = Needed / sizeof(DWORD);
+
+ for (i = 0; i < Count; i++)
+ {
+ if (Processes[i] != 0)
+ {
+ hProc = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, Processes[i]);
+
+ if (hProc)
+ {
+ GetModuleFileNameExPtr(hProc, 0, ExeName, 255);
+ CloseHandle(hProc);
+
+ strlop(ExeName, '.');
+
+ if (_stricmp(ExeName, FLDIGIName) == 0)
+ return Processes[i];
+
+ }
+ }
+ }
+ return 0;
+}
+
+
+static KillTNC(struct TNCINFO * TNC)
+{
+ HANDLE hProc;
+
+ if (TNC->PTTMode)
+ Rig_PTT(TNC->RIG, FALSE); // Make sure PTT is down
+
+ if (TNC->ProgramPath)
+ TNC->PID = FindFLDIGI(TNC->ProgramPath);
+
+ if (TNC->PID == 0) return 0;
+
+ hProc = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, TNC->PID);
+
+ if (hProc)
+ {
+ TerminateProcess(hProc, 0);
+ CloseHandle(hProc);
+ }
+
+ TNC->WeStartedTNC = 0; // So we don't try again
+
+ return 0;
+}
+
+#endif
+
+static int RestartTNC(struct TNCINFO * TNC)
+{
+ if (TNC->ProgramPath == NULL)
+ return 0;
+
+ _strlwr(TNC->ProgramPath);
+
+ if (_memicmp(TNC->ProgramPath, "REMOTE:", 7) == 0)
+ {
+ int n;
+
+ // Try to start TNC on a remote host
+
+ SOCKET sock = socket(AF_INET,SOCK_DGRAM,0);
+ struct sockaddr_in destaddr;
+
+ Debugprintf("trying to restart FLDIGI %s", TNC->ProgramPath);
+
+ if (sock == INVALID_SOCKET)
+ return 0;
+
+ destaddr.sin_family = AF_INET;
+ destaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
+ destaddr.sin_port = htons(8500);
+
+ if (destaddr.sin_addr.s_addr == INADDR_NONE)
+ {
+ // Resolve name to address
+
+ struct hostent * HostEnt = gethostbyname (TNC->HostName);
+
+ if (!HostEnt)
+ return 0; // Resolve failed
+
+ memcpy(&destaddr.sin_addr.s_addr,HostEnt->h_addr,4);
+ }
+
+ n = sendto(sock, TNC->ProgramPath, (int)strlen(TNC->ProgramPath), 0, (struct sockaddr *)&destaddr, sizeof(destaddr));
+
+ Debugprintf("Restart FLDIGI - sento returned %d", n);
+
+ Sleep(100);
+ closesocket(sock);
+
+ return 1; // Cant tell if it worked, but assume ok
+ }
+#ifndef LINBPQ
+ {
+ STARTUPINFO SInfo; // pointer to STARTUPINFO
+ PROCESS_INFORMATION PInfo; // pointer to PROCESS_INFORMATION
+ char HomeDir[MAX_PATH];
+ int i, ret;
+
+ SInfo.cb=sizeof(SInfo);
+ SInfo.lpReserved=NULL;
+ SInfo.lpDesktop=NULL;
+ SInfo.lpTitle=NULL;
+ SInfo.dwFlags=0;
+ SInfo.cbReserved2=0;
+ SInfo.lpReserved2=NULL;
+
+ if (TNC->ProgramPath)
+ {
+ strcpy(HomeDir, TNC->ProgramPath);
+ i = strlen(HomeDir);
+
+ while(--i)
+ {
+ if (HomeDir[i] == '/' || HomeDir[i] == '\\')
+ {
+ HomeDir[i] = 0;
+ break;
+ }
+ }
+
+ // for some reason the program name must be lower case
+
+ _strlwr(TNC->ProgramPath);
+
+ ret = CreateProcess(TNC->ProgramPath, NULL, NULL, NULL, FALSE,0 ,NULL , NULL, &SInfo, &PInfo);
+ return ret;
+ }
+ }
+#endif
+ return 0;
+}
+
+
+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>FLDigi Status</title></head><body id=Text onload=\"ScrollOutput()\">"
+ "<h2>FLDIGI Status</h2>");
+
+
+ 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);
+ Len += sprintf(&Buff[Len], "<tr><td>Mode</td><td>%s</td></tr>", TNC->WEB_MODE);
+ Len += sprintf(&Buff[Len], "<tr><td>Channel State</td><td>%s</td></tr>", TNC->WEB_CHANSTATE);
+ Len += sprintf(&Buff[Len], "<tr><td>Proto State</td><td>%s</td></tr>", TNC->WEB_PROTOSTATE);
+ Len += sprintf(&Buff[Len], "<tr><td>Traffic</td><td>%s</td></tr>", TNC->WEB_TRAFFIC);
+// Len += sprintf(&Buff[Len], "<tr><td>TNC Restarts</td><td></td></tr>", TNC->WEB_RESTARTS);
+ Len += sprintf(&Buff[Len], "</table>");
+
+ Len += sprintf(&Buff[Len], "<textarea rows=10 style=\"width:500px; height:250px;\" id=textarea >%s</textarea>", TNC->WebBuffer);
+ Len = DoScanLine(TNC, Buff, Len);
+
+ return Len;
+}
+
+VOID FLDIGISuspendPort(struct TNCINFO * TNC)
+{
+ TNC->FLInfo->CONOK = FALSE;
+}
+
+VOID FLDIGIReleasePort(struct TNCINFO * TNC)
+{
+ TNC->FLInfo->CONOK = TRUE;
+}
+
+VOID SendKISSCommand(struct TNCINFO * TNC, char * Msg)
+{
+ int txlen, rc;
+ char txbuff[256];
+ char outbuff[256];
+
+ txlen = sprintf(txbuff, "%c%s", 6, Msg);
+ txlen = KissEncode(txbuff, outbuff, txlen);
+ rc = sendto(TNC->TCPDataSock, outbuff, txlen, 0, (struct sockaddr *)&TNC->Datadestaddr, sizeof(struct sockaddr));
+}
+
+VOID * FLDigiExtInit(EXTPORTDATA * PortEntry)
+{
+ int i, port;
+ char Msg[255];
+ struct TNCINFO * TNC;
+ char * ptr;
+
+ //
+ // The Socket to connect to is in IOBASE
+ //
+
+ srand((unsigned int)time(NULL));
+
+ port = PortEntry->PORTCONTROL.PORTNUMBER;
+
+ ReadConfigFile(port, ProcessLine);
+
+ TNC = TNCInfo[port];
+
+ if (TNC == NULL)
+ {
+ // Not defined in Config file
+
+ sprintf(Msg," ** Error - no info in BPQ32.cfg for this port\n");
+ WritetoConsole(Msg);
+
+ return ExtProc;
+ }
+
+ TNC->Port = port;
+
+ TNC->PortRecord = PortEntry;
+
+ if (PortEntry->PORTCONTROL.PORTCALL[0] == 0)
+ memcpy(TNC->NodeCall, MYNODECALL, 10);
+ else
+ ConvFromAX25(&PortEntry->PORTCONTROL.PORTCALL[0], TNC->NodeCall);
+
+ TNC->Interlock = PortEntry->PORTCONTROL.PORTINTERLOCK;
+
+
+ PortEntry->PORTCONTROL.PROTOCOL = 10;
+ PortEntry->PERMITGATEWAY = TRUE; // Can change ax.25 call on each stream
+ PortEntry->PORTCONTROL.UICAPABLE = 1; // Can send beacons
+ PortEntry->PORTCONTROL.PORTQUALITY = 0;
+ PortEntry->SCANCAPABILITIES = NONE; // Scan Control - None
+
+ TNC->FLInfo->CONOK = TRUE;
+
+ if (PortEntry->PORTCONTROL.PORTPACLEN == 0 || PortEntry->PORTCONTROL.PORTPACLEN > 128)
+ PortEntry->PORTCONTROL.PORTPACLEN = 64;
+
+ TNC->SuspendPortProc = FLDIGISuspendPort;
+ TNC->ReleasePortProc = FLDIGIReleasePort;
+
+ ptr=strchr(TNC->NodeCall, ' ');
+ if (ptr) *(ptr) = 0; // Null Terminate
+
+ TNC->Hardware = H_FLDIGI;
+
+ if (TNC->BusyWait == 0)
+ TNC->BusyWait = 10;
+
+ MPSKChannel[port] = PortEntry->PORTCONTROL.CHANNELNUM-65;
+
+ PortEntry->MAXHOSTMODESESSIONS = 1;
+
+ i=sprintf(Msg,"FLDigi Host %s Port %d \n",
+ TNC->HostName, TNC->TCPPort);
+
+ WritetoConsole(Msg);
+
+#ifndef LINBPQ
+
+ if (TNC->ProgramPath)
+ TNC->PID = FindFLDIGI(TNC->ProgramPath);
+
+ if (TNC->PID == 0) // Not running
+#endif
+ TNC->WeStartedTNC = RestartTNC(TNC); // Always try if Linux
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ // Open Datagram port
+
+ SOCKET sock;
+ u_long param=1;
+ BOOL bcopt=TRUE;
+ struct sockaddr_in sinx;
+ struct hostent * HostEnt = NULL;
+
+ TNC->FLInfo->CmdControl = 5; //Send params immediately
+
+ TNC->Datadestaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
+
+ if (TNC->Datadestaddr.sin_addr.s_addr == INADDR_NONE)
+ {
+ // Resolve name to address
+
+ HostEnt = gethostbyname (TNC->HostName);
+
+ if (HostEnt)
+ {
+ memcpy(&TNC->Datadestaddr.sin_addr.s_addr,HostEnt->h_addr,4);
+ }
+ }
+
+ TNC->TCPDataSock = sock = socket(AF_INET,SOCK_DGRAM,0);
+
+ ioctl(sock, FIONBIO, &param);
+
+ setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (const char FAR *)&bcopt,4);
+
+ sinx.sin_family = AF_INET;
+ sinx.sin_addr.s_addr = INADDR_ANY;
+ sinx.sin_port = htons(TNC->TCPPort + 1);
+
+ if (bind(sock, (struct sockaddr *) &sinx, sizeof(sinx)) != 0 )
+ {
+ // Bind Failed
+
+ int err = WSAGetLastError();
+ Consoleprintf("Bind Failed for UDP port %d - error code = %d", TNC->TCPPort, err);
+ }
+
+ TNC->Datadestaddr.sin_family = AF_INET;
+ TNC->Datadestaddr.sin_port = htons(TNC->TCPPort);
+ }
+ else
+ ConnecttoFLDigi(port);
+
+ time(&lasttime[port]); // Get initial time value
+
+ PortEntry->PORTCONTROL.TNC = TNC;
+
+ TNC->WebWindowProc = WebProc;
+ TNC->WebWinX = 520;
+ TNC->WebWinY = 500;
+ TNC->WebBuffer = zalloc(5000);
+
+ TNC->WEB_COMMSSTATE = zalloc(100);
+ TNC->WEB_TNCSTATE = zalloc(100);
+ TNC->WEB_CHANSTATE = zalloc(100);
+ TNC->WEB_BUFFERS = zalloc(100);
+ TNC->WEB_PROTOSTATE = zalloc(100);
+ TNC->WEB_RESTARTTIME = zalloc(100);
+ TNC->WEB_RESTARTS = zalloc(100);
+
+ TNC->WEB_MODE = zalloc(50);
+ TNC->WEB_TRAFFIC = zalloc(100);
+
+
+#ifndef LINBPQ
+
+ CreatePactorWindow(TNC, ClassName, WindowTitle, RigControlRow, PacWndProc, 500, 450, ForcedClose);
+
+ CreateWindowEx(0, "STATIC", "Comms State", WS_CHILD | WS_VISIBLE, 10,6,120,20, TNC->hDlg, NULL, hInstance, NULL);
+ TNC->xIDC_COMMSSTATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,6,386,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ CreateWindowEx(0, "STATIC", "TNC State", WS_CHILD | WS_VISIBLE, 10,28,106,20, TNC->hDlg, NULL, hInstance, NULL);
+ TNC->xIDC_TNCSTATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,28,520,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ CreateWindowEx(0, "STATIC", "Mode/CF", WS_CHILD | WS_VISIBLE, 10,50,80,20, TNC->hDlg, NULL, hInstance, NULL);
+ TNC->xIDC_MODE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,50,200,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ CreateWindowEx(0, "STATIC", "Channel State", WS_CHILD | WS_VISIBLE, 10,72,110,20, TNC->hDlg, NULL, hInstance, NULL);
+ TNC->xIDC_CHANSTATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,72,144,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ CreateWindowEx(0, "STATIC", "Proto State", WS_CHILD | WS_VISIBLE,10,94,80,20, TNC->hDlg, NULL, hInstance, NULL);
+ TNC->xIDC_PROTOSTATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE,116,94,374,20 , TNC->hDlg, NULL, hInstance, NULL);
+
+ CreateWindowEx(0, "STATIC", "Traffic", WS_CHILD | WS_VISIBLE,10,116,80,20, TNC->hDlg, NULL, hInstance, NULL);
+ TNC->xIDC_TRAFFIC = CreateWindowEx(0, "STATIC", "RX 0 TX 0 ACKED 0 Resent 0", WS_CHILD | WS_VISIBLE,116,116,374,20 , TNC->hDlg, NULL, hInstance, NULL);
+
+ TNC->hMonitor= CreateWindowEx(0, "LISTBOX", "", WS_CHILD | WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
+ LBS_DISABLENOSCROLL | WS_HSCROLL | WS_VSCROLL,
+ 0,170,250,300, TNC->hDlg, NULL, hInstance, NULL);
+
+ TNC->ClientHeight = 450;
+ TNC->ClientWidth = 500;
+
+ TNC->hMenu = CreatePopupMenu();
+
+ AppendMenu(TNC->hMenu, MF_STRING, WINMOR_KILL, "Kill FLDigi");
+ AppendMenu(TNC->hMenu, MF_STRING, WINMOR_RESTART, "Kill and Restart FLDigi");
+ AppendMenu(TNC->hMenu, MF_STRING, ARDOP_ABORT, "Abort Current Session");
+
+ MoveWindows(TNC);
+#endif
+
+ return ExtProc;
+
+}
+
+
+static int ProcessLine(char * buf, int Port)
+{
+ UCHAR * ptr,* p_cmd;
+ char * p_ipad = 0;
+ char * p_port = 0;
+ unsigned short WINMORport = 0;
+ int BPQport;
+ int len=510;
+ struct TNCINFO * TNC;
+ struct ARQINFO * ARQ;
+ struct FLINFO * FL;
+
+ char errbuf[256];
+
+ strcpy(errbuf, buf);
+
+ ptr = strtok(buf, " \t\n\r");
+
+ if(ptr == NULL) return (TRUE);
+
+ if(*ptr =='#') return (TRUE); // comment
+
+ if(*ptr ==';') return (TRUE); // comment
+
+ if (_stricmp(buf, "ADDR"))
+ return FALSE; // Must start with ADDR
+
+ ptr = strtok(NULL, " \t\n\r");
+
+ BPQport = Port;
+ p_ipad = ptr;
+
+ TNC = TNCInfo[BPQport] = zalloc(sizeof(struct TNCINFO));
+
+ ARQ = TNC->ARQInfo = zalloc(sizeof(struct ARQINFO));
+ FL = TNC->FLInfo = zalloc(sizeof(struct FLINFO));
+
+ TNC->Timeout = 50; // Default retry = 5 seconds
+ TNC->Retries = 6; // Default Retries
+ TNC->Window = 16;
+
+ TNC->FLInfo->KISSMODE = TRUE; // Default to KISS
+
+ TNC->InitScript = malloc(1000);
+ TNC->InitScript[0] = 0;
+
+ if (p_ipad == NULL)
+ p_ipad = strtok(NULL, " \t\n\r");
+
+ if (p_ipad == NULL) return (FALSE);
+
+ p_port = strtok(NULL, " \t\n\r");
+
+ if (p_port == NULL) return (FALSE);
+
+ TNC->TCPPort = atoi(p_port);
+
+ TNC->destaddr.sin_family = AF_INET;
+ TNC->destaddr.sin_port = htons(TNC->TCPPort + 40); // Defaults XML 7362 ARQ 7322
+
+ TNC->Datadestaddr.sin_family = AF_INET;
+ TNC->Datadestaddr.sin_port = htons(TNC->TCPPort);
+
+ TNC->HostName = malloc(strlen(p_ipad)+1);
+
+ if (TNC->HostName == NULL) return TRUE;
+
+ strcpy(TNC->HostName,p_ipad);
+
+ ptr = strtok(NULL, " \t\n\r");
+
+ if (ptr)
+ {
+ if (_memicmp(ptr, "PATH", 4) == 0)
+ {
+ p_cmd = strtok(NULL, "\n\r");
+ if (p_cmd) TNC->ProgramPath = _strdup(p_cmd);
+ }
+ }
+
+ // Read Initialisation lines
+
+ while(TRUE)
+ {
+ if (GetLine(buf) == 0)
+ return TRUE;
+
+ strcpy(errbuf, buf);
+
+ if (memcmp(buf, "****", 4) == 0)
+ return TRUE;
+
+ ptr = strchr(buf, ';');
+ if (ptr)
+ {
+ *ptr++ = 13;
+ *ptr = 0;
+ }
+
+ if (_memicmp(buf, "TIMEOUT", 7) == 0)
+ TNC->Timeout = atoi(&buf[8]) * 10;
+ else
+ if (_memicmp(buf, "RETRIES", 7) == 0)
+ TNC->Retries = atoi(&buf[8]);
+ else
+ if (_memicmp(buf, "WINDOW", 6) == 0)
+ TNC->Window = atoi(&buf[7]);
+ else
+ if (_memicmp(buf, "ARQMODE", 7) == 0)
+ TNC->FLInfo->KISSMODE = FALSE;
+ else
+ if (_memicmp(buf, "DEFAULTMODEM", 12) == 0) // Send Beacon after each session
+ {
+ // Check that freq is also specified
+
+ char * Freq = strchr(&buf[13], '/');
+
+ if (Freq)
+ {
+ *(Freq++) = 0;
+ strcpy(TNC->FLInfo->DefaultMode, &buf[13]);
+ TNC->FLInfo->DefaultFreq = atoi(Freq);
+ }
+ }
+ else
+
+ strcat (TNC->InitScript, buf);
+ }
+
+
+ return (TRUE);
+}
+
+static int ConnecttoFLDigi(int port)
+{
+ _beginthread(ConnecttoFLDigiThread, 0, (void *)(size_t)port);
+
+ return 0;
+}
+
+static VOID ConnecttoFLDigiThread(void * portptr)
+{
+ int port = (int)(size_t)portptr;
+ char Msg[255];
+ int err,i;
+ u_long param=1;
+ BOOL bcopt=TRUE;
+ struct hostent * HostEnt = NULL;
+ struct TNCINFO * TNC = TNCInfo[port];
+
+ Sleep(5000); // Allow init to complete
+
+ TNC->destaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
+ TNC->Datadestaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
+
+ if (TNC->destaddr.sin_addr.s_addr == INADDR_NONE)
+ {
+ // Resolve name to address
+
+ HostEnt = gethostbyname (TNC->HostName);
+
+ if (!HostEnt) return; // Resolve failed
+
+ memcpy(&TNC->destaddr.sin_addr.s_addr,HostEnt->h_addr,4);
+ memcpy(&TNC->Datadestaddr.sin_addr.s_addr,HostEnt->h_addr,4);
+ }
+
+ if (TNC->TCPSock)
+ {
+ Debugprintf("FLDIGI Closing Sock %d", TNC->TCPSock);
+ closesocket(TNC->TCPSock);
+ }
+
+ TNC->TCPSock = 0;
+
+
+ TNC->TCPSock=socket(AF_INET,SOCK_STREAM,0);
+
+ if (TNC->TCPSock == INVALID_SOCKET)
+ {
+ i=sprintf(Msg, "Socket Failed for FLDigi Control socket - error code = %d\n", WSAGetLastError());
+ WritetoConsole(Msg);
+ return;
+ }
+
+ setsockopt (TNC->TCPSock, 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;
+
+ TNC->CONNECTING = TRUE;
+
+ if (connect(TNC->TCPSock,(LPSOCKADDR) &TNC->destaddr,sizeof(TNC->destaddr)) == 0)
+ {
+ //
+ // Connected successful
+ //
+ }
+ else
+ {
+ if (TNC->Alerted == FALSE)
+ {
+ err=WSAGetLastError();
+ i=sprintf(Msg, "Connect Failed for FLDigi Control socket - error code = %d\n", err);
+ WritetoConsole(Msg);
+
+ sprintf(TNC->WEB_COMMSSTATE, "Connection to TNC failed");
+ MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ TNC->Alerted = TRUE;
+ }
+
+ closesocket(TNC->TCPSock);
+ TNC->TCPSock = 0;
+ TNC->CONNECTING = FALSE;
+ return;
+ }
+
+ TNC->LastFreq = 0;
+
+ if (TNC->TCPDataSock)
+ closesocket(TNC->TCPDataSock);
+
+ TNC->TCPDataSock = 0;
+
+ TNC->TCPDataSock=socket(AF_INET,SOCK_STREAM,0);
+
+ setsockopt (TNC->TCPDataSock, SOL_SOCKET, SO_REUSEADDR, (const char FAR *)&bcopt, 4);
+
+ if (TNC->TCPDataSock == INVALID_SOCKET)
+ {
+ i=sprintf(Msg, "Socket Failed for FLDigi socket - error code = %d\r\n", WSAGetLastError());
+ WritetoConsole(Msg);
+
+ closesocket(TNC->TCPSock);
+ closesocket(TNC->TCPDataSock);
+ TNC->TCPSock = 0;
+ TNC->CONNECTING = FALSE;
+
+ return;
+ }
+
+ if (bind(TNC->TCPDataSock, (LPSOCKADDR) &sinx, addrlen) != 0 )
+ {
+ //
+ // Bind Failed
+ //
+
+ i=sprintf(Msg, "Bind Failed for FLDigi Data socket - error code = %d\r\n", WSAGetLastError());
+ WritetoConsole(Msg);
+
+ closesocket(TNC->TCPSock);
+ closesocket(TNC->TCPDataSock);
+ TNC->TCPSock = 0;
+ TNC->TCPDataSock = 0;
+ TNC->CONNECTING = FALSE;
+ return;
+ }
+
+ if (connect(TNC->TCPDataSock,(LPSOCKADDR) &TNC->Datadestaddr,sizeof(TNC->Datadestaddr)) == 0)
+ {
+ ioctlsocket (TNC->TCPDataSock,FIONBIO,&param); // Set nonblocking
+ TNC->CONNECTED = TRUE;
+ TNC->CONNECTING = FALSE;
+
+ TNC->Alerted = TRUE;
+
+ sprintf(TNC->WEB_COMMSSTATE, "Connected to FLDIGI");
+ SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ }
+ else
+ {
+ sprintf(Msg, "Connect Failed for FLDigi Data socket Port %d - error code = %d\r\n", port, WSAGetLastError());
+ WritetoConsole(Msg);
+
+ closesocket(TNC->TCPSock);
+ closesocket(TNC->TCPDataSock);
+ TNC->TCPSock = 0;
+ TNC->TCPDataSock = 0;
+ TNC->CONNECTING = FALSE;
+ }
+
+ return;
+}
+
+VOID UpdateStatsLine(struct TNCINFO * TNC, struct STREAMINFO * STREAM)
+{
+ sprintf(TNC->WEB_TRAFFIC, "RX %d TX %d ACKED %d Resent %d Queued %d",
+ STREAM->BytesRXed, STREAM->BytesTXed, STREAM->BytesAcked, STREAM->BytesResent, STREAM->BytesOutstanding);
+ SetWindowText(TNC->xIDC_TRAFFIC, TNC->WEB_TRAFFIC);
+}
+
+VOID SendPacket(struct TNCINFO * TNC, UCHAR * Msg, int MsgLen)
+{
+ if (TNC->FLInfo->KISSMODE)
+ {
+ char KissMsg[1000];
+ char outbuff[1000];
+ int newlen;
+
+ if (TNC->FLInfo->RAW)
+ {
+ // KISS RAW
+
+ // Add CRC and Send
+
+ unsigned short CRC;
+ char crcstring[6];
+
+ KissMsg[0] = 7; // KISS Raw
+ KissMsg[1] = 1; // SOH
+ KissMsg[2] = '0'; // Version
+ KissMsg[3] = TNC->ARQInfo->FarStream;
+
+ Msg[MsgLen] = 0;
+
+ memcpy(&KissMsg[4], Msg, MsgLen +1 ); // Get terminating NULL
+
+ CRC = CalcCRC(KissMsg + 1, MsgLen + 3);
+
+ sprintf(crcstring, "%04X%c", CRC, 4);
+
+ strcat(KissMsg, crcstring);
+ MsgLen += 9;
+ }
+ else
+ {
+ // Normal KISS
+
+ KissMsg[0] = 0; // KISS Control
+ KissMsg[1] = TNC->ARQInfo->FarStream;
+ memcpy(&KissMsg[2], Msg, MsgLen);
+ MsgLen += 2;
+ }
+
+ newlen = KissEncode(KissMsg, outbuff, MsgLen);
+ sendto(TNC->TCPDataSock, outbuff, newlen, 0, (struct sockaddr *)&TNC->Datadestaddr, sizeof(struct sockaddr));
+
+ SendKISSCommand(TNC, "TXBUF:");
+
+ }
+ else
+ {
+ // ARQ Scoket
+
+ // Add Header, CRC and Send
+
+ unsigned short CRC;
+ char crcstring[6];
+ char outbuff[1000];
+
+ outbuff[0] = 1; // SOH
+ outbuff[1] = '0'; // Version
+ outbuff[2] = TNC->ARQInfo->FarStream;
+
+ Msg[MsgLen] = 0;
+
+ memcpy(&outbuff[3], Msg, MsgLen + 1);
+
+ CRC = CalcCRC(outbuff , MsgLen + 3);
+
+ sprintf(crcstring, "%04X%c", CRC, 4);
+
+ strcat(outbuff, crcstring);
+ MsgLen += 8;
+
+ send(TNC->TCPDataSock, outbuff, MsgLen, 0);
+ }
+}
+
+VOID ProcessFLDigiData(struct TNCINFO * TNC, UCHAR * Input, int Len, char Channel, BOOL RAW);
+
+static int ProcessReceivedData(int port)
+{
+ int bytes, used, bytesleft;
+ int i;
+ char ErrMsg[255];
+ unsigned char MessageBuff[1500];
+ unsigned char * Message = MessageBuff;
+ unsigned char * MessageBase = MessageBuff;
+
+ struct TNCINFO * TNC = TNCInfo[port];
+ struct FLINFO * FL = TNC->FLInfo;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ // If using KISS/UDP interface use recvfrom
+
+ if (FL->KISSMODE)
+ {
+ struct sockaddr_in rxaddr;
+ int addrlen = sizeof(struct sockaddr_in);
+ unsigned char * KissEnd;
+
+ bytesleft = recvfrom(TNC->TCPDataSock, Message, 1500, 0, (struct sockaddr *)&rxaddr, &addrlen);
+
+ if (bytesleft < 0)
+ {
+ int err = WSAGetLastError();
+ // if (err != 11)
+ // printf("KISS Error %d %d\n", nLength, err);
+ bytes = 0;
+ }
+
+ while (bytesleft > 0)
+ {
+ unsigned char * in;
+ unsigned char * out;
+ unsigned char c;
+
+ if (bytesleft < 3)
+ return 0;
+
+ if (Message[0] != FEND)
+ return 0; // Duff
+
+ Message = MessageBase;
+ in = out = &Message[2];
+
+ // We may have more than one KISS message in a packet
+
+ KissEnd = memchr(&Message[2], FEND, bytesleft );
+
+ if (KissEnd == 0)
+ return 0; // Duff
+
+ *(KissEnd) = 0;
+
+ used = (int)(KissEnd - Message + 1);
+
+ bytesleft -= used;
+ bytes = used;
+
+ MessageBase += used;
+
+ if (Message[1] == 6) // KISS Command
+ {
+ UCHAR * ptr = strchr(&Message[2], FEND);
+
+ if (ptr) *ptr = 0; // Null Terminate
+
+ if (bytes > 250)
+ Message[250] = 0;
+
+ FL->Responding = 5;
+
+ if (TNC->TNCOK == 0)
+ {
+ TNC->TNCOK = TRUE;
+ TNC->CONNECTED = TRUE;
+
+ sprintf(TNC->WEB_COMMSSTATE, "Connected to FLDIGI");
+ SetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+ }
+
+ // Trap BUSY fiest - there are lots of them, and they are likely to be confused
+ // with tesponses to Interactive commands
+
+ if (memcmp(&Message[2], "BUSY", 4) == 0)
+ {
+ BOOL Changed = FALSE;
+
+ if (Message[7] == 'T' && FL->Busy == FALSE)
+ {
+ TNC->Busy = FL->Busy = TRUE;
+ Changed = TRUE;
+ }
+ else
+ {
+ if (Message[7] == 'F' && FL->Busy == TRUE)
+ {
+ TNC->Busy = FL->Busy = FALSE;
+ Changed = TRUE;
+ }
+ }
+
+ if (Changed)
+ {
+ if (FL->TX)
+ strcpy(TNC->WEB_CHANSTATE, "TX");
+ else
+ if (FL->Busy)
+ strcpy(TNC->WEB_CHANSTATE, "Busy");
+ else
+ strcpy(TNC->WEB_CHANSTATE, "Idle");
+
+ SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ }
+
+ continue;
+ }
+
+ if (TNC->InternalCmd)
+ {
+ ULONG * buffptr = GetBuff();
+
+ TNC->InternalCmd = FALSE;
+
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "FLDIGI} Ok %s\r", &Message[2]);
+ C_Q_ADD(&TNC->Streams[0].PACTORtoBPQ_Q, buffptr);
+ }
+
+ // Drop through in case need to extract info from command
+ }
+
+ // Auto Command
+
+// Debugprintf("%d %s", TNC->PortRecord->PORTCONTROL.PORTNUMBER, &Message[2]);
+
+ if (memcmp(&Message[2], "FLSTAT", 4) == 0)
+ {
+ if (strstr(&Message[2], "FLSTAT:INIT"))
+ {
+ // FLDIGI Reloaded - set parmas
+ SendKISSCommand(TNC, "RSIDBCAST:ON TRXSBCAST:ON TXBEBCAST:ON KISSRAW:ON");
+ }
+ continue;
+ }
+
+ if (memcmp(&Message[2], "TRXS", 4) == 0)
+ {
+ char * ptr1, * context;
+ BOOL Changed = FALSE;
+
+ ptr1 = strtok_s(&Message[7], ",", &context);
+
+ if (strstr(ptr1, "TX"))
+ {
+ if (TNC->FLInfo->TX == FALSE)
+ {
+ TNC->FLInfo->TX = TRUE;
+ Changed = TRUE;
+ }
+ }
+ else
+ {
+ if (TNC->FLInfo->TX)
+ {
+ TNC->FLInfo->TX = FALSE;
+ Changed = TRUE;
+ }
+ }
+
+ if (Changed)
+ {
+ if (FL->TX)
+ strcpy(TNC->WEB_CHANSTATE, "TX");
+ else
+ if (FL->Busy)
+ strcpy(TNC->WEB_CHANSTATE, "Busy");
+ else
+ strcpy(TNC->WEB_CHANSTATE, "Idle");
+
+ SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ }
+
+ continue;
+ }
+
+ if (memcmp(&Message[2], "TXBUF:", 6) == 0)
+ {
+ char * ptr1, * context;
+
+ ptr1 = strtok_s(&Message[8], ",", &context);
+ STREAM->BytesOutstanding = atoi(ptr1);
+ UpdateStatsLine(TNC, STREAM);
+ continue;
+ }
+
+ if (memcmp(&Message[2], "TXBE:", 5) == 0)
+ {
+ STREAM->BytesOutstanding = 0;
+ UpdateStatsLine(TNC, STREAM);
+ continue;
+ }
+
+ if (memcmp(&Message[2], "RSIDN:", 6) == 0)
+ {
+ char * ptr1, * context;
+
+ ptr1 = strtok_s(&Message[8], ",", &context);
+
+ TNC->FLInfo->CenterFreq = atoi(ptr1);
+ ptr1 = strtok_s(NULL, ",", &context);
+ if (strlen(ptr1) > 19)
+ ptr1[19] = 0;
+
+ strcpy(TNC->FLInfo->CurrentMode, ptr1);
+ }
+
+ if (memcmp(&Message[2], "MODEM:", 6) == 0)
+ {
+ char * ptr1, * context;
+
+ ptr1 = strtok_s(&Message[8], ",", &context);
+ if (strlen(ptr1) > 19)
+ ptr1[19] = 0;
+
+ strcpy(TNC->FLInfo->CurrentMode, ptr1);
+ }
+
+ if (memcmp(&Message[2], "WFF:", 4) == 0)
+ {
+ char * ptr1, * context;
+
+ ptr1 = strtok_s(&Message[6], ",", &context);
+ TNC->FLInfo->CenterFreq = atoi(ptr1);
+ }
+
+ sprintf(TNC->WEB_MODE, "%s/%d", TNC->FLInfo->CurrentMode, TNC->FLInfo->CenterFreq);
+ SetWindowText(TNC->xIDC_MODE, TNC->WEB_MODE);
+
+ continue;
+ }
+
+ if (Message[1] == 7) // Not Normal Data
+ {
+ // "RAW" Mode. Just process as if received from TCP Socket Interface
+
+ ProcessFLDigiPacket(TNC, &Message[2] , bytes - 3); // Data may be for another port
+ continue;
+ }
+
+ bytes -= 3; // Two FEND and Control
+
+ // Undo KISS
+
+ while (bytes)
+ {
+ bytes--;
+
+ c = *(in++);
+
+ if (c == FESC)
+ {
+ c = *(in++);
+ bytes--;
+
+ if (c == TFESC)
+ c = FESC;
+ else if (c == TFEND)
+ c = FEND;
+ }
+ *(out++) = c;
+ }
+ ProcessFLDigiData(TNC, &Message[3], (int)(out - &Message[3]), Message[2], FALSE); // KISS not RAW
+ }
+ return 0;
+ }
+
+ // Need to extract messages from byte stream
+
+ bytes = recv(TNC->TCPDataSock, Message, 500, 0);
+
+ if (bytes == SOCKET_ERROR)
+ {
+// i=sprintf(ErrMsg, "Read Failed for MPSK socket - error code = %d\r\n", WSAGetLastError());
+// WritetoConsole(ErrMsg);
+
+ closesocket(TNC->TCPDataSock);
+
+ TNC->CONNECTED = FALSE;
+ if (TNC->Streams[0].Attached)
+ TNC->Streams[0].ReportDISC = TRUE;
+
+ return (0);
+ }
+
+ if (bytes == 0)
+ {
+ // zero bytes means connection closed
+
+ i=sprintf(ErrMsg, "FlDigi Connection closed for BPQ Port %d\n", port);
+ WritetoConsole(ErrMsg);
+
+ TNC->CONNECTED = FALSE;
+ if (TNC->Streams[0].Attached)
+ TNC->Streams[0].ReportDISC = TRUE;
+
+ return (0);
+ }
+
+ // Have some data
+
+ ProcessFLDigiPacket(TNC, Message, bytes); // Data may be for another port
+
+ return (0);
+
+}
+
+
+VOID ProcessFLDigiPacket(struct TNCINFO * TNC, char * Message, int Len)
+{
+ char * MPTR = Message;
+ char c;
+ struct FLINFO * FL = TNC->FLInfo;
+
+
+ if (TNC->FLInfo->MCASTMODE)
+ {
+ if (TNC->Streams[0].Attached == 0)
+ return;
+
+ while(Len)
+ {
+ c = *(MPTR++);
+
+ if (TNC->InPacket)
+ {
+ TNC->DataBuffer[TNC->DataLen++] = c;
+
+ // Sanity Check
+
+ if (TNC->DataLen == 6)
+ {
+ char * ptr = &TNC->DataBuffer[1];
+
+ if (memcmp(ptr, "DATA ", 5) == 0 ||
+ memcmp(ptr, "PROG ", 5) == 0 ||
+ memcmp(ptr, "FILE ", 5) == 0 ||
+ memcmp(ptr, "SIZE ", 5) == 0 ||
+ memcmp(ptr, "DESC ", 5) == 0 ||
+ memcmp(ptr, "CNTL ", 5) == 0 ||
+ memcmp(ptr, "ID ", 3) == 0)
+
+ {
+ }
+ else
+ {
+ // False Trigger, try again
+
+ TNC->InPacket = FALSE;
+ }
+
+ }
+ else
+ {
+ if (TNC->InData)
+ {
+ if (--TNC->MCASTLen == 0)
+ {
+ // Got a packet
+
+ UINT * buffptr;
+ int Stream = 0;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ buffptr = GetBuff();
+
+ if (buffptr)
+ {
+ TNC->DataBuffer[TNC->DataLen++] = 13; // Keep Tidy
+
+ buffptr[1] = TNC->DataLen;
+ memcpy(&buffptr[2], &TNC->DataBuffer[0], TNC->DataLen);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+
+ TNC->InPacket = FALSE;
+ }
+ }
+ else
+ {
+ // Looking for >
+
+ if (TNC->DataLen == 16)
+ {
+ // Not found it
+
+ TNC->InPacket = FALSE;
+ }
+ else
+ {
+ if (c == '>')
+ {
+ // Got Header - extract Length
+
+ char * ptr;
+ int len;
+
+ ptr = strchr(TNC->DataBuffer, ' ');
+
+ if (ptr)
+ {
+ len = atoi(ptr);
+
+ if (len)
+ {
+ TNC->InData = TRUE;
+ TNC->MCASTLen = len;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (TNC->DataLen > 520)
+ TNC->DataLen--; // Protect Buffer
+ }
+ else
+ {
+ // Look for '<'
+
+ if (c == '<')
+ {
+ TNC->DataBuffer[0] = c;
+ TNC->DataLen = 1;
+ TNC->InPacket = TRUE;
+ TNC->InData = FALSE;
+ }
+ }
+ Len--;
+ }
+ return;
+ }
+ // Look for SOH/EOT delimiters. May Have several SOH before EOTTNC->FL
+
+ while(Len)
+ {
+ c = *(MPTR++);
+
+ switch (c)
+ {
+ case 01: // New Packet
+
+ if (TNC->InPacket)
+ CheckFLDigiData(TNC);
+
+ TNC->DataBuffer[0] = 1;
+ TNC->DataLen = 1;
+ TNC->InPacket = TRUE;
+ break;
+
+ case 04:
+
+ if (TNC->InPacket)
+ CheckFLDigiData(TNC);
+ TNC->DataLen = 0;
+ TNC->InPacket = FALSE;
+
+ break;
+
+ default:
+
+ if (TNC->InPacket)
+ {
+ if (TNC->DataLen == 1)
+ {
+ if (c != '0' && c != '1')
+ {
+ // Drop if not Protocol '0' or '1' - this should eliminate almost all noise packets
+
+ TNC->InPacket = 0;
+ break;
+ }
+ }
+ TNC->DataBuffer[TNC->DataLen++] = c;
+ }
+
+ if (TNC->DataLen > 520)
+ TNC->DataLen--; // Protect Buffer
+
+ }
+ Len--;
+ }
+}
+VOID CheckFLDigiData(struct TNCINFO * TNC)
+{
+ UCHAR * Input = &TNC->DataBuffer[0];
+ int Len = TNC->DataLen - 4; // Not including CRC
+ unsigned short CRC;
+ char crcstring[6];
+
+ if (Len < 0)
+ return;
+
+ TNC->DataBuffer[TNC->DataLen] = 0;
+
+ // RAW format message, either from ARQ Scoket or RAW KISS
+
+ // Check Checksum
+
+ CRC = CalcCRC(Input , Len);
+
+ sprintf(crcstring, "%04X", CRC);
+
+ if (memcmp(&Input[Len], crcstring, 4) !=0)
+ {
+ // CRC Error - could just be noise
+
+// Debugprintf("%s %s", crcstring, Input);
+ return;
+ }
+ ProcessFLDigiData(TNC, &Input[3], Len - 3, Input[2], TRUE); // From RAW
+}
+/*
+VOID ProcessARQPacket(struct PORTCONTROL * PORT, MESSAGE * Buffer)
+{
+ // ARQ Packet from KISS-Like Hardware
+
+ struct TNCINFO * TNC = TNCInfo[PORT->PORTNUMBER];
+ UCHAR * Input;
+ int Len;
+
+ if (TNC == NULL)
+ {
+ // Set up TNC info
+
+ TNC = TNCInfo[PORT->PORTNUMBER] = zalloc(sizeof(struct TNCINFO));
+ TNC->ARQInfo = zalloc(sizeof(struct ARQINFO));
+ TNC->FLInfo = zalloc(sizeof(struct FLINFO));
+
+ TNC->Timeout = 50; // Default retry = 10 seconds
+ TNC->Retries = 6; // Default Retries
+ TNC->Window = 16;
+ }
+
+ Input = &Buffer->DEST[0];
+ Len = Buffer->LENGTH - 7; // Not including CRC
+
+ // Look for attach on any call
+
+ ProcessFLDigiData(TNC, Input, Len);
+}
+*/
+static int Stuff(UCHAR * inbuff, UCHAR * outbuff, int len)
+{
+ int i, txptr = 0;
+ UCHAR c;
+ UCHAR * ptr = inbuff;
+
+ // DLE Escape DLE, SOH, EOT
+
+ for (i = 0; i < len; i++)
+ {
+ c = *(ptr++);
+
+// if (c == 0 || c == DLE || c == SOH || c == EOT)
+ if (c < 32 && c != 10 && c != 13 && c != 8)
+ {
+ outbuff[txptr++] = DLE;
+
+ // if between 0 and 0x1F, Add 40,
+ // if > x80 and less than 0xa0 subtract 20
+
+ c += 0x40;
+ }
+ outbuff[txptr++]=c;
+ }
+
+ return txptr;
+}
+
+
+static int UnStuff(UCHAR * inbuff, int len)
+{
+ int i, txptr = 0;
+ UCHAR c;
+ UCHAR * outbuff = inbuff;
+ UCHAR * ptr = inbuff;
+
+ // This unstuffs into the input buffer
+
+ for (i = 0; i < len; i++)
+ {
+ c = *(ptr++);
+
+ if (c == DLE)
+ {
+ c = *(ptr++);
+ i++;
+
+ // if between 0x40 and 0x5F, subtract 0x40,
+ // else add 0x20 (so we can send chars 80-9f without a double DLE)
+
+ if (c < 0x60)
+ c -= 0x40;
+ else
+ c += 0x20;
+ }
+ outbuff[txptr++] = c;
+ }
+
+ return txptr;
+}
+
+unsigned int crcval = 0xFFFF;
+
+void update(char c)
+{
+ int i;
+
+ crcval ^= c & 255;
+ for (i = 0; i < 8; ++i)
+ {
+ if (crcval & 1)
+ crcval = (crcval >> 1) ^ 0xA001;
+ else
+ crcval = (crcval >> 1);
+ }
+}
+
+unsigned int CalcCRC(UCHAR * ptr, int Len)
+{
+ int i;
+
+ crcval = 0xFFFF;
+ for (i = 0; i < Len; i++)
+ {
+ update(*ptr++);
+ }
+ return crcval;
+}
+/*
+
+<SOH>00cG8BPQ:1025 G8BPQ:24 0 8 T60R6W108E06<EOT>
+<SOH>00kG8BPQ:24 G8BPQ 4 85F9B<EOT>
+
+<SOH>00cG8BPQ:1025 GM8BPQ:24 0 7 T60R5W1051D5<EOT> (128, 5)
+
+,<SOH>00cG8BPQ:1025 G8BPQ:24 0 7 T60R5W10FA36<EOT>
+<SOH>00kG8BPQ:24 G8BPQ 5 89FCA<EOT>
+
+First no sees to be a connection counter. Next may be stream
+
+
+<SOH>08s___ABFC<EOT>
+<SOH>08tG8BPQ:73 xxx 33FA<EOT>
+<SOH>00tG8BPQ:73 yyy 99A3<EOT>
+<SOH>08dG8BPQ:90986C<EOT>
+<SOH>00bG8BPQ:911207<EOT>
+
+call:90 for dis 91 for dis ack 73<sp> for chat)
+
+<SOH>08pG8BPQ<SUB>?__645E<EOT>
+<SOH>00s_??4235<EOT>
+
+<SOH>08pG8BPQ<SUB>?__645E<EOT>
+<SOH>00s_??4235<EOT>
+
+i Ident
+c Connect
+k Connect Ack
+r Connect NAK
+d Disconnect req
+s Data Ack/ Retransmit Req )status)
+p Poll
+f Format Fail
+b dis ack
+t talk
+
+a Abort
+o Abort ACK
+
+
+<SOH>00cG8BPQ:1025 G8BPQ:24 0 7 T60R5W10FA36<EOT>
+<SOH>00kG8BPQ:24 G8BPQ 6 49A3A<EOT>
+<SOH>08s___ABFC<EOT>
+<SOH>08 ARQ:FILE::flarqmail-1.eml
+ARQ:EMAIL::
+ARQ:SIZE::90
+ARQ::STX
+//FLARQ COMPOSER
+Date: 09/01/2014 23:24:42
+To: gm8bpq
+From:
+SubjectA0E0<SOH>
+<SOH>08!: Test
+
+Test Message
+
+ARQ::ETX
+F0F2<SOH>
+<SOH>08pG8BPQ<SUB>!__623E<EOT>
+<SOH>08pG8BPQ<SUB>!__623E<EOT>
+<SOH>08pG8BPQ<SUB>!__623E<EOT>
+
+
+
+
+*/
+VOID ProcessFLDigiData(struct TNCINFO * TNC, UCHAR * Input, int Len, char Channel, BOOL RAW)
+{
+ UINT * buffptr;
+ int Stream = 0;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+ char CTRL = Input[0];
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ struct FLINFO * FL = TNC->FLInfo;
+
+ int SendLen;
+ char Reply[80];
+
+
+ // Process Message
+
+ // This processes eitrher message from the KISS or RAW interfaces.
+ // Headers and RAW checksum have been removed, so packet starts with Control Byte
+
+ // Only a connect request is allowed with no session, so check first
+
+ if (CTRL == 'c')
+ {
+ // Connect Request
+
+ char * call1;
+ char * call2;
+ char * port1;
+ char * port2;
+ char * ptr;
+ char * context;
+ char FarStream = 0;
+ int BlockSize = 6; // 64 default
+ int Window = TNC->Window;
+ APPLCALLS * APPL;
+ char * ApplPtr = APPLS;
+ int App;
+ char Appl[10];
+ struct WL2KInfo * WL2K = TNC->WL2K;
+ TRANSPORTENTRY * SESS;
+
+ if (FL->CONOK == FALSE)
+ return;
+
+ call1 = strtok_s(&Input[1], " ", &context);
+ call2 = strtok_s(NULL, " ", &context);
+
+ port1 = strlop(call1, ':');
+ port2 = strlop(call2, ':');
+
+ // See if for us
+
+ for (App = 0; App < 32; App++)
+ {
+ APPL=&APPLCALLTABLE[App];
+ memcpy(Appl, APPL->APPLCALL_TEXT, 10);
+ ptr=strchr(Appl, ' ');
+
+ if (ptr) *ptr = 0;
+
+ if (_stricmp(call2, Appl) == 0)
+ break;
+ }
+
+ if (App > 31)
+ if (strcmp(TNC->NodeCall, call2) !=0)
+ return; // Not Appl or Port/Node Call
+
+ ptr = strtok_s(NULL, " ", &context);
+ FarStream = *ptr;
+ ptr = strtok_s(NULL, " ", &context);
+ BlockSize = atoi(ptr);
+
+ if (ARQ->ARQState)
+ {
+ // We have already received a connect request - just ACK it
+
+ goto AckConnectRequest;
+ }
+
+ // Get a Session
+
+ SuspendOtherPorts(TNC);
+
+ ProcessIncommingConnect(TNC, call1, 0, FALSE);
+
+ SESS = TNC->PortRecord->ATTACHEDSESSIONS[0];
+
+ strcpy(STREAM->MyCall, call2);
+ STREAM->ConnectTime = time(NULL);
+ STREAM->BytesRXed = STREAM->BytesTXed = STREAM->BytesAcked = STREAM->BytesResent = 0;
+
+ if (TNC->RIG && TNC->RIG != &TNC->DummyRig && strcmp(TNC->RIG->RigName, "PTT"))
+ {
+ sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Inbound Freq %s", TNC->Streams[0].RemoteCall, call2, TNC->RIG->Valchar);
+ SESS->Frequency = (atof(TNC->RIG->Valchar) * 1000000.0) + 1500; // Convert to Centre Freq
+ SESS->Mode = TNC->WL2KMode;
+ }
+ else
+ {
+ sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Inbound", TNC->Streams[0].RemoteCall, call2);
+ if (WL2K)
+ {
+ SESS->Frequency = WL2K->Freq;
+ SESS->Mode = WL2K->mode;
+ }
+ }
+
+ if (WL2K)
+ strcpy(SESS->RMSCall, WL2K->RMSCall);
+
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connect Pending");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ memset(ARQ, 0, sizeof(struct ARQINFO)); // Reset ARQ State
+ ARQ->FarStream = FarStream;
+ ARQ->TXSeq = ARQ->TXLastACK = 63; // Last Sent
+ ARQ->RXHighest = ARQ->RXNoGaps = 63; // Last Received
+ ARQ->ARQState = ARQ_ACTIVE;
+ ARQ->OurStream = (rand() % 78) + 49; // To give some protection against other stuff on channel
+ ARQ->FarStream = FarStream; // Not Yet defined
+ if (strcmp(port1, "1025") == 0)
+ {
+ FL->FLARQ = TRUE; // From FLARQ
+ ARQ->OurStream = '8'; // FLARQ Ignores what we send
+ }
+ else
+ FL->FLARQ = FALSE; // From other app (eg BPQ)
+
+ FL->RAW = RAW;
+
+ STREAM->NeedDisc = 0;
+
+ if (App < 32)
+ {
+ char AppName[13];
+
+ memcpy(AppName, &ApplPtr[App * sizeof(CMDX)], 12);
+ AppName[12] = 0;
+
+ // Make sure app is available
+
+ if (CheckAppl(TNC, AppName))
+ {
+ char Buffer[32];
+ int MsgLen = sprintf(Buffer, "%s\r", AppName);
+
+ buffptr = GetBuff();
+
+ if (buffptr == 0)
+ {
+ return; // No buffers, so ignore
+ }
+
+ buffptr[1] = MsgLen;
+ memcpy(buffptr+2, Buffer, MsgLen);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ TNC->SwallowSignon = TRUE;
+
+ // Save Appl Call in case needed for
+
+ }
+ else
+ {
+ STREAM->NeedDisc = 50; // 1 sec
+ }
+ }
+
+ ARQ->TXWindow = Window;
+
+ if (BlockSize < 4) BlockSize = 4;
+ if (BlockSize < 9) BlockSize = 9;
+
+ ARQ->MaxBlock = Blocksizes[BlockSize];
+
+
+ ARQ->ARQTimer = 10; // To force CTEXT to be Queued
+
+ if (App == 32)
+ {
+ // Connect to Node - send CTEXT
+
+ if (HFCTEXTLEN > 1)
+ {
+ buffptr = GetBuff();
+ if (buffptr)
+ {
+ buffptr[1] = HFCTEXTLEN;
+ memcpy(&buffptr[2], HFCTEXT, HFCTEXTLEN);
+ SendARQData(TNC, buffptr);
+ }
+ }
+ }
+
+ if (STREAM->NeedDisc)
+ {
+ // Send Not Avail
+
+ buffptr = GetBuff();
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((char *)&buffptr[2], "Application Not Available\n");
+ SendARQData(TNC, buffptr);
+ }
+ }
+
+AckConnectRequest:
+
+ SendLen = sprintf(Reply, "k%s:24 %s %c 7", call2, call1, ARQ->OurStream);
+
+ SaveAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+ ARQ->ARQTimerState = ARQ_CONNECTACK;
+
+ return;
+ }
+
+ // All others need a session
+
+// if (!STREAM->Connected && !STREAM->Connecting)
+// return;
+
+ if (CTRL == 'k')
+ {
+ // Connect ACK
+
+ char * call1;
+ char * call2;
+ char * port1;
+ char * port2;
+ char * ptr;
+ char * context;
+ char FarStream = 0;
+ int BlockSize = 6; // 64 default
+ int Window = 16;
+
+ char Reply[80];
+ int ReplyLen;
+
+ call1 = strtok_s(&Input[1], " ", &context);
+ call2 = strtok_s(NULL, " ", &context);
+
+ port1 = strlop(call1, ':');
+ port2 = strlop(call2, ':');
+
+ if (strcmp(call1, STREAM->RemoteCall) != 0)
+ return;
+
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+ ptr = strtok_s(NULL, " ", &context);
+ if (ptr)
+ FarStream = *ptr;
+ ptr = strtok_s(NULL, " ", &context);
+ if (ptr)
+ BlockSize = atoi(ptr);
+
+ if (STREAM->Connected)
+ goto SendKReply; // Repeated ACK
+
+ STREAM->ConnectTime = time(NULL);
+ STREAM->BytesRXed = STREAM->BytesTXed = STREAM->BytesAcked = STREAM->BytesResent = 0;
+ STREAM->Connected = TRUE;
+
+ ARQ->ARQTimerState = 0;
+ ARQ->ARQTimer = 0;
+
+ if (TNC->RIG)
+ sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Outbound Freq %s", STREAM->MyCall, STREAM->RemoteCall, TNC->RIG->Valchar);
+ else
+ sprintf(TNC->WEB_TNCSTATE, "%s Connected to %s Outbound", STREAM->MyCall, STREAM->RemoteCall);
+
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ UpdateMH(TNC, STREAM->RemoteCall, '+', 'Z');
+
+ ARQ->ARQTimerState = 0;
+ ARQ->FarStream = FarStream;
+ ARQ->TXWindow = TNC->Window;
+ ARQ->MaxBlock = Blocksizes[BlockSize];
+
+ ARQ->ARQState = ARQ_ACTIVE;
+
+ STREAM->NeedDisc = 0;
+
+ buffptr = GetBuff();
+
+ if (buffptr)
+ {
+ ReplyLen = sprintf(Reply, "*** Connected to %s\r", STREAM->RemoteCall);
+
+ buffptr[1] = ReplyLen;
+ memcpy(buffptr+2, Reply, ReplyLen);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connected");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+SendKReply:
+
+ // Reply with status
+
+ SendLen = sprintf(Reply, "s%c%c%c", ARQ->TXSeq + 32, ARQ->RXNoGaps + 32, ARQ->RXHighest + 32);
+
+ if (ARQ->RXHighest != ARQ->RXNoGaps)
+ {
+ int n = ARQ->RXNoGaps + 1;
+ n &= 63;
+
+ while (n != ARQ->RXHighest)
+ {
+ if (ARQ->RXHOLDQ[n] == 0) // Dont have it
+ SendLen += sprintf(&Reply[SendLen], "%c", n + 32);
+
+ n++;
+ n &= 63;
+ }
+ }
+
+ QueueAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+ return;
+ }
+
+ // All others need a session
+
+ //if (!STREAM->Connected)
+ // return;
+
+
+ if (CTRL == 's')
+ {
+ // Status
+
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+ ARQ->ARQTimer = 0; // Stop retry timer
+ Input[Len] = 0;
+ ProcessARQStatus(TNC, ARQ, &Input[1]);
+
+ return;
+ }
+
+ if (CTRL == 'p')
+ {
+ // Poll
+
+ char * call1;
+ char * context;
+
+ call1 = strtok_s(&Input[1], " \x1A", &context);
+
+ if (strcmp(call1, STREAM->RemoteCall) != 0)
+ return;
+
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+ SendLen = sprintf(Reply, "s%c%c%c", ARQ->TXSeq + 32, ARQ->RXNoGaps + 32, ARQ->RXHighest + 32);
+
+ if (ARQ->RXHighest != ARQ->RXNoGaps)
+ {
+ int n = ARQ->RXNoGaps + 1;
+ n &= 63;
+
+ while (n != ARQ->RXHighest)
+ {
+ if (ARQ->RXHOLDQ[n] == 0) // Dont have it
+ SendLen += sprintf(&Reply[SendLen], "%c", n + 32);
+
+ n++;
+ n &= 63;
+ }
+ }
+ else
+ ARQ->TurnroundTimer = 15; // Allow us to send it all acked
+
+ QueueAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+
+ return;
+ }
+
+
+ if (CTRL == 'a')
+ {
+ // Abort. Send Abort ACK - same as
+
+ char * call1;
+ char * context;
+
+ call1 = strtok_s(&Input[1], " :", &context);
+
+ if (strcmp(call1, STREAM->RemoteCall) != 0)
+ return;
+
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+ SendLen = sprintf(Reply, "o%c%c%c", ARQ->TXSeq + 32, ARQ->RXNoGaps + 32, ARQ->RXHighest + 32);
+
+ if (ARQ->RXHighest != ARQ->RXNoGaps)
+ {
+ int n = ARQ->RXNoGaps + 1;
+ n &= 63;
+
+ while (n != ARQ->RXHighest)
+ {
+ if (ARQ->RXHOLDQ[n] == 0) // Dont have it
+ SendLen += sprintf(&Reply[SendLen], "%c", n + 32);
+
+ n++;
+ n &= 63;
+ }
+ }
+
+ QueueAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+ return;
+ }
+
+ if (CTRL == 'i')
+ {
+ // Ident
+
+ return;
+ }
+
+ if (CTRL == 't')
+ {
+ // Talk - not sure what to do with these
+
+ return;
+ }
+
+ if (CTRL == 'd')
+ {
+ // Disconnect Request
+
+ char * call1;
+ char * context;
+
+ call1 = strtok_s(&Input[1], " ", &context);
+ strlop(call1, ':');
+
+ if (strcmp(STREAM->RemoteCall, call1))
+ return;
+
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+
+ // As the Disc ACK isn't repeated, we have to clear session now
+
+ STREAM->Connected = FALSE;
+ STREAM->Connecting = FALSE;
+ STREAM->ReportDISC = TRUE;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Disconncted");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ ARQ->ARQState = 0;
+
+ SendLen = sprintf(Reply, "b%s:91", STREAM->MyCall);
+
+ ARQ->ARQTimerState = ARQ_WAITACK;
+ SaveAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+ ARQ->Retries = 2;
+ return;
+ }
+
+ if (CTRL == 'b')
+ {
+ // Disconnect ACK
+
+ char * call1;
+ char * context;
+
+ call1 = strtok_s(&Input[1], " ", &context);
+ strlop(call1, ':');
+
+ if (strcmp(STREAM->RemoteCall, call1))
+ return;
+
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+ ARQ->ARQTimer = 0;
+ ARQ->ARQTimerState = 0;
+ ARQ->ARQState = 0;
+
+ if (STREAM->Connected)
+ {
+ // Create a traffic record
+
+ char logmsg[120];
+ time_t Duration;
+
+ Duration = time(NULL) - STREAM->ConnectTime;
+
+ if (Duration == 0)
+ Duration = 1;
+
+ sprintf(logmsg,"Port %2d %9s Bytes Sent %d BPS %d Bytes Received %d BPS %d Time %d Seconds",
+ TNC->Port, STREAM->RemoteCall,
+ STREAM->BytesTXed, (int)(STREAM->BytesTXed/Duration),
+ STREAM->BytesRXed, (int)(STREAM->BytesRXed/Duration), (int)Duration);
+
+ Debugprintf(logmsg);
+ }
+
+ STREAM->Connecting = FALSE;
+ STREAM->Connected = FALSE; // Back to Command Mode
+ STREAM->ReportDISC = TRUE; // Tell Node
+
+ if (STREAM->Disconnecting) //
+ FLReleaseTNC(TNC);
+
+ STREAM->Disconnecting = FALSE;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Disconncted");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ return;
+ }
+
+ if (CTRL == 'u')
+ {
+ // Beacon
+
+ //>00uGM8BPQ:72 GM8BPQ TestingAD67
+
+ char * Call = &Input[1];
+ strlop(Call, ':');
+
+ UpdateMH(TNC, Call, '!', 0);
+ return;
+ }
+
+ if (STREAM->Connected)
+ {
+ if (Channel != ARQ->OurStream)
+ return; // Wrong Session
+
+ if (CTRL >= ' ' && CTRL < 96)
+ {
+ // ARQ Data
+
+ int Seq = CTRL - 32;
+ int Work;
+
+// if (rand() % 5 == 2)
+// {
+// Debugprintf("Dropping %d", Seq);
+// return;
+// }
+
+ buffptr = GetBuff();
+
+ if (buffptr == NULL)
+ return; // Sould never run out, but cant do much else
+
+ // Remove any DLE transparency
+
+ if (TNC->FLInfo->KISSMODE)
+ Len -= 1;
+ else
+ Len = UnStuff(&Input[1], Len - 1);
+
+ buffptr[1] = Len;
+ memcpy(&buffptr[2], &Input[1], Len);
+ STREAM->BytesRXed += Len;
+
+ UpdateStatsLine(TNC, STREAM);
+
+ // Safest always to save, then see what we can process
+
+ if (ARQ->RXHOLDQ[Seq])
+ {
+ // Wot! Shouldn't happen
+
+ ReleaseBuffer(ARQ->RXHOLDQ[Seq]);
+// Debugprintf("ARQ Seq %d Duplicate");
+ }
+
+ ARQ->RXHOLDQ[Seq] = buffptr;
+// Debugprintf("ARQ saving %d", Seq);
+
+ // If this is higher that highest received, save. But beware of wrap'
+
+ // Hi = 2, Seq = 60 dont save s=h = 58
+ // Hi = 10 Seq = 12 save s-h = 2
+ // Hi = 14 Seq = 10 dont save s-h = -4
+ // Hi = 60 Seq = 2 save s-h = -58
+
+ Work = Seq - ARQ->RXHighest;
+
+ if ((Work > 0 && Work < 32) || Work < -32)
+ ARQ->RXHighest = Seq;
+
+ // We may now be able to process some
+
+ Work = (ARQ->RXNoGaps + 1) & 63; // The next one we need
+
+ while (ARQ->RXHOLDQ[Work])
+ {
+ // We have it
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, ARQ->RXHOLDQ[Work]);
+// ReleaseBuffer(ARQ->RXHOLDQ[Work]);
+
+ ARQ->RXHOLDQ[Work] = NULL;
+// Debugprintf("Processing %d from Q", Work);
+
+ ARQ->RXNoGaps = Work;
+ Work = (Work + 1) & 63; // The next one we need
+ }
+
+ ARQ->TurnroundTimer = 200; // Delay before allowing reply. Will normally be reset by the poll following data
+ return;
+ }
+ }
+}
+
+
+VOID SendARQData(struct TNCINFO * TNC, UINT * Buffer)
+{
+ // Send Data, saving a copy until acked.
+
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ struct FLINFO * FL = TNC->FLInfo;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+
+ UCHAR TXBuffer[300];
+ SOCKET sock = TNC->TCPDataSock;
+ int SendLen;
+ UCHAR * ptr;
+ int Origlen = Buffer[1];
+ int Stuffedlen;
+
+ ARQ->TXSeq++;
+ ARQ->TXSeq &= 63;
+
+ SendLen = sprintf(TXBuffer, "%c", ARQ->TXSeq + 32);
+
+ ptr = (UCHAR *)&Buffer[2]; // Start of data;
+
+ ptr[Buffer[1]] = 0;
+
+ if (memcmp(ptr, "ARQ:", 4) == 0)
+ {
+ // FLARQ Mail/FIle transfer. Turn off CR > LF translate (used for terminal mode)
+
+ FL->FLARQ = FALSE;
+ }
+
+ if (FL->FLARQ)
+ {
+ // Terminal Mode. Need to convert CR to LF so it displays in FLARQ Window
+
+ ptr = strchr(ptr, 13);
+
+ while (ptr)
+ {
+ *(ptr++) = 10; // Replace CR with LF
+ ptr = strchr(ptr, 13);
+ }
+ }
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ memcpy(&TXBuffer[SendLen], (UCHAR *)&Buffer[2], Origlen);
+ SendLen += Origlen;
+ }
+ else
+ {
+ Stuffedlen = Stuff((UCHAR *)&Buffer[2], &TXBuffer[SendLen], Origlen);
+ SendLen += Stuffedlen;
+ }
+
+ TXBuffer[SendLen] = 0;
+
+// if (rand() % 5 == 2)
+// Debugprintf("Dropping %d", ARQ->TXSeq);
+// else
+
+ ARQ->TXHOLDQ[ARQ->TXSeq] = Buffer;
+
+ STREAM->BytesTXed += Origlen;
+
+ UpdateStatsLine(TNC, STREAM);
+
+ // if waiting for ack, don't send, just queue. Will be sent when ack received
+
+ if (ARQ->ARQTimer == 0 || ARQ->ARQTimerState == ARQ_WAITDATA)
+ {
+ SendPacket(TNC, TXBuffer, SendLen);
+ ARQ->ARQTimer = 15; // wait up to 1.5 sec for more data before polling
+ ARQ->Retries = 1;
+ ARQ->ARQTimerState = ARQ_WAITDATA;
+ }
+ else
+ STREAM->BytesResent -= Origlen; // So wont be included in resent bytes
+}
+
+VOID TidyClose(struct TNCINFO * TNC, int Stream)
+{
+ char Reply[80];
+ int SendLen;
+
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+
+ SendLen = sprintf(Reply, "d%s:90", TNC->Streams[0].MyCall);
+
+ SaveAndSend(TNC, ARQ, TNC->TCPDataSock, Reply, SendLen);
+ ARQ->ARQTimerState = ARQ_DISC;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Disconncting");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+}
+
+VOID ForcedClose(struct TNCINFO * TNC, int Stream)
+{
+ TidyClose(TNC, Stream); // I don't think Hostmode has a DD
+}
+
+VOID CloseComplete(struct TNCINFO * TNC, int Stream)
+{
+ FLReleaseTNC(TNC);
+}
+
+VOID FLReleaseTNC(struct TNCINFO * TNC)
+{
+ // Set mycall back to Node or Port Call, and Start Scanner
+
+ UCHAR TXMsg[1000];
+
+ strcpy(TNC->WEB_TNCSTATE, "Free");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ // if a default Modem is defined, select it
+
+ if (TNC->FLInfo->DefaultMode[0])
+ {
+ char txbuff[80];
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ sprintf(txbuff, "WFF:%d MODEM:%s MODEM: WFF:", TNC->FLInfo->DefaultFreq, TNC->FLInfo->DefaultMode);
+ SendKISSCommand(TNC, txbuff);
+ }
+ else
+ {
+ SendXMLCommand(TNC, "modem.set_by_name", TNC->FLInfo->DefaultMode, 'S');
+ SendXMLCommand(TNC, "modem.set_carrier", (char *)TNC->FLInfo->DefaultFreq, 'I');
+ }
+ }
+ // Start Scanner
+
+ sprintf(TXMsg, "%d SCANSTART 15", TNC->Port);
+
+ Rig_Command(-1, TXMsg);
+
+ ReleaseOtherPorts(TNC);
+
+}
+VOID QueueAndSend(struct TNCINFO * TNC, struct ARQINFO * ARQ, SOCKET sock, char * Msg, int MsgLen)
+{
+ // Queue to be sent after TXDELAY
+
+ memcpy(ARQ->TXMsg, Msg, MsgLen + 1);
+ ARQ->TXLen = MsgLen;
+ ARQ->TXDelay = 15; // Try 1500 ms
+}
+
+VOID SaveAndSend(struct TNCINFO * TNC, struct ARQINFO * ARQ, SOCKET sock, char * Msg, int MsgLen)
+{
+ // Used for Messages that need a reply. Save, send and set timeout
+
+ memcpy(ARQ->LastMsg, Msg, MsgLen + 1); // Include Null
+ ARQ->LastLen = MsgLen;
+
+ // Delay the send for a short while Just use the timeout code
+
+// SendPacket(sock, Msg, MsgLen, 0);
+ ARQ->ARQTimer = 1; // Try 500 ms
+ ARQ->Retries = TNC->Retries + 1; // First timout is rthe real send
+
+ return;
+}
+
+
+VOID ARQTimer(struct TNCINFO * TNC)
+{
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ UINT * buffptr;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+ int SendLen;
+ char Reply[80];
+ struct FLINFO * FL = TNC->FLInfo;
+
+ //Send frames, unless held by TurnroundTimer or Window
+
+ int Outstanding;
+
+ // Use new BUSY: poll to detect busy state
+
+ if (FL->TX == FALSE)
+ if (TNC->FLInfo->KISSMODE)
+ SendKISSCommand(TNC, "BUSY:"); // Send every poll for now - may need to optimize later
+
+
+/*
+// Use Received chars as a rough channel active indicator
+
+ FL->BusyTimer++;
+
+ if (FL->BusyTimer > 4)
+ {
+ FL->BusyTimer = 0;
+
+ if (FL->BusyCounter > 2) // 2 chars in last .3 secs
+ FL->Busy = TRUE;
+ else
+ FL->Busy = FALSE;
+
+ if (FL->TX)
+ strcpy(TNC->WEB_CHANSTATE, "TX");
+ else
+ if (FL->Busy)
+ strcpy(TNC->WEB_CHANSTATE, "Busy");
+ else
+ strcpy(TNC->WEB_CHANSTATE, "Idle");
+
+ FL->BusyCounter = 0;
+
+ SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ }
+
+*/ // TXDelay is used as a turn round delay for frames that don't have to be retried. It doesn't
+ // need to check for busy (or anything else (I think!)
+
+ if (ARQ->TXDelay)
+ {
+ ARQ->TXDelay--;
+
+ if (ARQ->TXDelay)
+ return;
+
+ SendPacket(TNC, ARQ->TXMsg, ARQ->TXLen);
+ }
+
+ // if We are alredy sending (State = ARQ_WAITDATA) we should allow it to send more (and the Poll at end)
+
+ if (ARQ->ARQTimerState == ARQ_WAITDATA)
+ {
+ while (STREAM->BPQtoPACTOR_Q)
+ {
+ Outstanding = ARQ->TXSeq - ARQ->TXLastACK;
+
+ if (Outstanding < 0)
+ Outstanding += 64;
+
+ TNC->PortRecord->FramesQueued = Outstanding + C_Q_COUNT(&STREAM->BPQtoPACTOR_Q); // Save for Appl Level Queued Frames
+
+ if (Outstanding > ARQ->TXWindow)
+ break;
+
+ buffptr = Q_REM(&STREAM->BPQtoPACTOR_Q);
+ SendARQData(TNC, buffptr);
+ }
+
+ ARQ->ARQTimer--;
+
+ if (ARQ->ARQTimer > 0)
+ return; // Timer Still Running
+
+ // No more data available - send poll
+
+ SendLen = sprintf(Reply, "p%s", TNC->Streams[0].MyCall);
+
+ ARQ->ARQTimerState = ARQ_WAITACK;
+
+ // This is one message that should not be queued so it is sent straiget after data
+
+// Debugprintf("Sending Poll");
+
+ memcpy(ARQ->LastMsg, Reply, SendLen + 1);
+ ARQ->LastLen = SendLen;
+
+ SendPacket(TNC, Reply, SendLen);
+
+ ARQ->ARQTimer = TNC->Timeout;
+ ARQ->Retries = TNC->Retries;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Wait ACK");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ return;
+
+ }
+
+ // TrunroundTimer is used to allow time for far end to revert to RX
+
+ if (ARQ->TurnroundTimer && !FL->Busy)
+ ARQ->TurnroundTimer--;
+
+ if (ARQ->TurnroundTimer == 0)
+ {
+ while (STREAM->BPQtoPACTOR_Q)
+ {
+ Outstanding = ARQ->TXSeq - ARQ->TXLastACK;
+
+ if (Outstanding < 0)
+ Outstanding += 64;
+
+ TNC->PortRecord->FramesQueued = Outstanding + C_Q_COUNT(&STREAM->BPQtoPACTOR_Q) + 1; // Make sure busy is reported to BBS
+
+ if (Outstanding > ARQ->TXWindow)
+ break;
+
+ buffptr = Q_REM(&STREAM->BPQtoPACTOR_Q);
+ SendARQData(TNC, buffptr);
+ }
+ }
+
+ if (ARQ->ARQTimer)
+ {
+ if (FL->TX || FL->Busy)
+ {
+ // Only decrement if running send poll timer
+
+ if (ARQ->ARQTimerState != ARQ_WAITDATA)
+ return;
+ }
+
+ ARQ->ARQTimer--;
+ {
+ if (ARQ->ARQTimer)
+ return; // Timer Still Running
+ }
+
+ ARQ->Retries--;
+
+ if (ARQ->Retries)
+ {
+ // Retry Current Message
+
+ SendPacket(TNC, ARQ->LastMsg, ARQ->LastLen);
+ ARQ->ARQTimer = TNC->Timeout + (rand() % 30);
+
+ return;
+ }
+
+ // Retried out.
+
+ switch (ARQ->ARQTimerState)
+ {
+ case ARQ_WAITDATA:
+
+ // No more data available - send poll
+
+ SendLen = sprintf(Reply, "p%s", TNC->Streams[0].MyCall);
+
+ ARQ->ARQTimerState = ARQ_WAITACK;
+
+ // This is one message that should not be queued so it is sent straiget after data
+
+ memcpy(ARQ->LastMsg, Reply, SendLen + 1);
+ ARQ->LastLen = SendLen;
+
+ SendPacket(TNC, Reply, SendLen);
+
+ ARQ->ARQTimer = TNC->Timeout;
+ ARQ->Retries = TNC->Retries;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Wait ACK");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ return;
+
+ case ARQ_CONNECTING:
+
+ // Report Connect Failed, and drop back to command mode
+
+ buffptr = GetBuff();
+
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "FLDigi} Failure with %s\r", STREAM->RemoteCall);
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+
+ // Send Disc to TNC in case it got the Connects, but we missed the ACKs
+
+ TidyClose(TNC, 0);
+ ARQ->Retries = 2; // First timout is the real send, only send once
+ STREAM->Connecting = FALSE; // Back to Command Mode
+ ARQ->ARQState = FALSE;
+
+ break;
+
+ case ARQ_WAITACK:
+ case ARQ_CONNECTACK:
+ case ARQ_DISC:
+
+ STREAM->Connected = FALSE; // Back to Command Mode
+ STREAM->ReportDISC = TRUE;
+ ARQ->ARQState = FALSE;
+
+ while (STREAM->PACTORtoBPQ_Q)
+ ReleaseBuffer(Q_REM(&STREAM->PACTORtoBPQ_Q));
+
+ while (STREAM->BPQtoPACTOR_Q)
+ ReleaseBuffer(Q_REM(&STREAM->BPQtoPACTOR_Q));
+
+ strcpy(TNC->WEB_TNCSTATE, "Free");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ strcpy(TNC->WEB_PROTOSTATE, "Disconncted");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ break;
+
+ }
+ }
+}
+
+VOID ProcessARQStatus(struct TNCINFO * TNC, struct ARQINFO * ARQ, char * Input)
+{
+ // Release any acked frames and resend any outstanding
+
+ int LastInSeq = Input[1] - 32;
+ int LastRXed = Input[2] - 32;
+ int FirstUnAcked = ARQ->TXLastACK;
+ int n = (int)strlen(Input) - 3;
+ char * ptr;
+ int NexttoResend;
+ int First, Last, Outstanding;
+ UINT * Buffer;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+ int Acked = 0;
+
+ // First status is an ack of Connect ACK
+
+ if (ARQ->ARQTimerState == ARQ_CONNECTACK)
+ {
+ ARQ->Retries = 0;
+ ARQ->ARQTimer = 0;
+ ARQ->ARQTimerState = 0;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connected");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+ }
+
+ // Release all up to LastInSeq
+
+ while (FirstUnAcked != LastInSeq)
+ {
+ FirstUnAcked++;
+ FirstUnAcked &= 63;
+
+ Buffer = ARQ->TXHOLDQ[FirstUnAcked];
+
+ if (Buffer)
+ {
+// Debugprintf("Acked %d", FirstUnAcked);
+ STREAM->BytesAcked += Buffer[1];
+ ReleaseBuffer(Buffer);
+ ARQ->TXHOLDQ[FirstUnAcked] = NULL;
+ Acked++;
+ }
+ }
+
+ ARQ->TXLastACK = FirstUnAcked;
+
+ Outstanding = ARQ->TXSeq - ARQ->TXLastACK;
+
+ if (Outstanding < 0)
+ Outstanding += 64;
+
+ TNC->PortRecord->FramesQueued = Outstanding + C_Q_COUNT(&STREAM->BPQtoPACTOR_Q); // Save for Appl Level Queued Frames
+
+ if (FirstUnAcked == ARQ->TXSeq)
+ {
+ UpdateStatsLine(TNC, STREAM);
+ ARQ->NoAckRetries = 0;
+
+ strcpy(TNC->WEB_PROTOSTATE, "Connected");
+ SetWindowText(TNC->xIDC_PROTOSTATE, TNC->WEB_PROTOSTATE);
+
+ return; // All Acked
+ }
+ // Release any not in retry list up to LastRXed.
+
+ ptr = &Input[3];
+
+ while (n)
+ {
+ NexttoResend = *(ptr++) - 32;
+
+ FirstUnAcked++;
+ FirstUnAcked &= 63;
+
+ while (FirstUnAcked != NexttoResend)
+ {
+ Buffer = ARQ->TXHOLDQ[FirstUnAcked];
+
+ if (Buffer)
+ {
+// Debugprintf("Acked %d", FirstUnAcked);
+ STREAM->BytesAcked += Buffer[1];
+ ReleaseBuffer(Buffer);
+ ARQ->TXHOLDQ[FirstUnAcked] = NULL;
+ Acked++;
+ }
+
+ FirstUnAcked++;
+ FirstUnAcked &= 63;
+ }
+
+ // We don't ACK this one. Process any more resend values, then release up to LastRXed.
+
+ n--;
+ }
+
+ // Release rest up to LastRXed
+
+ while (FirstUnAcked != LastRXed)
+ {
+ FirstUnAcked++;
+ FirstUnAcked &= 63;
+
+ Buffer = ARQ->TXHOLDQ[FirstUnAcked];
+
+ if (Buffer)
+ {
+// Debugprintf("Acked %d", FirstUnAcked);
+ STREAM->BytesAcked += Buffer[1];
+ ReleaseBuffer(Buffer);
+ ARQ->TXHOLDQ[FirstUnAcked] = NULL;
+ Acked++;
+ }
+ }
+
+ // Resend anything in TX Buffer (From LastACK to TXSeq
+
+ Last = ARQ->TXSeq + 1;
+ Last &= 63;
+
+ First = LastInSeq;
+
+ while (First != Last)
+ {
+ First++;
+ First &= 63;
+
+ if(ARQ->TXHOLDQ[First])
+ {
+ UINT * Buffer = ARQ->TXHOLDQ[First];
+ UCHAR TXBuffer[300];
+ SOCKET sock = TNC->TCPDataSock;
+ int SendLen;
+
+// Debugprintf("Resend %d", First);
+
+ STREAM->BytesResent += Buffer[1];
+
+ SendLen = sprintf(TXBuffer, "%c", First + 32);
+
+ if (TNC->FLInfo->KISSMODE)
+ {
+ memcpy(&TXBuffer[SendLen], (UCHAR *)&Buffer[2], Buffer[1]);
+ SendLen += Buffer[1];
+ }
+ else
+ SendLen += Stuff((UCHAR *)&Buffer[2], &TXBuffer[SendLen], Buffer[1]);
+
+ TXBuffer[SendLen] = 0;
+
+ SendPacket(TNC, TXBuffer, SendLen);
+
+ ARQ->ARQTimer = 10; // wait up to 1 sec for more data before polling
+ ARQ->Retries = 1;
+ ARQ->ARQTimerState = ARQ_WAITDATA;
+
+ if (Acked == 0)
+ {
+ // Nothing acked by this statis message
+
+ Acked = 0; // Dont count more thna once
+ ARQ->NoAckRetries++;
+ if (ARQ->NoAckRetries > TNC->Retries)
+ {
+ // Too many retries - just disconnect
+
+ TidyClose(TNC, 0);
+ return;
+ }
+ }
+ }
+ }
+
+ UpdateStatsLine(TNC, STREAM);
+}
+
+VOID FLSlowTimer(struct TNCINFO * TNC)
+{
+ struct FLINFO * FL = TNC->FLInfo;
+
+ // Entered every 10 secs
+
+ // if in MCAST mode, clear KILL timer (MCAST RX can run for a long time
+
+ if (TNC->FLInfo->MCASTMODE)
+ {
+ TRANSPORTENTRY * SESS = TNC->PortRecord->ATTACHEDSESSIONS[0];
+
+ if (SESS)
+ SESS->L4KILLTIMER = 0;
+ }
+
+ if (FL->KISSMODE)
+ {
+ if (FL->Responding)
+ FL->Responding--;
+
+ 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);
+
+ // Set basic params till it responds
+ }
+
+ FL->CmdControl++;
+
+ if (FL->CmdControl > 5) // Every Minute
+ {
+ FL->CmdControl = 0;
+
+ SendKISSCommand(TNC, "FLSTAT: MODEM: WFF:");
+ }
+
+ SendKISSCommand(TNC, "TRXS: TXBUF:"); // In case TX/RX report is missed
+ }
+}
+
+static int ProcessXMLData(int port)
+{
+ unsigned int bytes;
+ int i;
+ char ErrMsg[255];
+ char Message[500];
+ struct TNCINFO * TNC = TNCInfo[port];
+ struct FLINFO * FL = TNC->FLInfo;
+ char * ptr1, * ptr2, *ptr3;
+
+ // Need to extract messages from byte stream
+
+ bytes = recv(TNC->TCPSock,(char *)&Message, 500, 0);
+
+ if (bytes == SOCKET_ERROR)
+ {
+// i=sprintf(ErrMsg, "Read Failed for FLDigi socket - error code = %d\r\n", WSAGetLastError());
+// WritetoConsole(ErrMsg);
+
+ closesocket(TNC->TCPSock);
+
+ TNC->CONNECTED = FALSE;
+ if (TNC->Streams[0].Attached)
+ TNC->Streams[0].ReportDISC = TRUE;
+
+ return (0);
+ }
+
+ if (bytes == 0)
+ {
+ // zero bytes means connection closed
+
+ i=sprintf(ErrMsg, "FlDigi Connection closed for BPQ Port %d\n", port);
+ WritetoConsole(ErrMsg);
+
+ TNC->CONNECTED = FALSE;
+ if (TNC->Streams[0].Attached)
+ TNC->Streams[0].ReportDISC = TRUE;
+
+ return (0);
+ }
+
+ // Have some data. Assume for now we get a whole packet
+
+ if (TNC->InternalCmd)
+ {
+ ULONG * buffptr = GetBuff();
+
+ TNC->InternalCmd = FALSE;
+
+ ptr1 = strstr(Message, "<value>");
+
+ if (ptr1)
+ {
+ ptr1 += 7;
+ ptr2 = strstr(ptr1, "</value>");
+ if (ptr2) *ptr2 = 0;
+
+ ptr3 = strstr(ptr1, "<i4>");
+
+ if (ptr3)
+ {
+ ptr1 = ptr3 + 4;
+ ptr2 = strstr(ptr1, "</i4>");
+ if (ptr2) *ptr2 = 0;
+ }
+
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "FLDIGI} Ok Was %s\r", ptr1);
+ C_Q_ADD(&TNC->Streams[0].PACTORtoBPQ_Q, buffptr);
+ }
+ }
+
+ return 0;
+ }
+
+
+ ptr1 = strstr(Message, "<value>");
+
+ if (ptr1)
+ {
+ ptr1 += 7;
+ ptr2 = strstr(ptr1, "</value>");
+ if (ptr2) *ptr2 = 0;
+
+ ptr2 = strstr(ptr1, "<string>");
+
+ if (ptr2)
+ {
+ ptr2 += 8;
+ ptr1 = ptr2;
+ ptr2 = strstr(ptr1, "</string>");
+ if (ptr2) *ptr2 = 0;
+ }
+
+ if (strcmp(FL->LastXML, "modem.get_name") == 0)
+ {
+ strcpy(TNC->WEB_MODE, ptr1);
+ SetWindowText(TNC->xIDC_MODE, ptr1);
+ }
+ else if (strcmp(FL->LastXML, "main.get_trx_state") == 0)
+ {
+ if (strcmp(ptr1, "TX") == 0)
+ FL->TX = TRUE;
+ else
+ FL->TX = FALSE;
+
+
+ if (FL->TX)
+ strcpy(TNC->WEB_CHANSTATE, "TX");
+ else
+ if (FL->Busy)
+ strcpy(TNC->WEB_CHANSTATE, "Busy");
+ else
+ strcpy(TNC->WEB_CHANSTATE, "Idle");
+
+ SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ }
+ else if (strcmp(FL->LastXML, "main.get_squelch") == 0)
+ {
+/*
+ if (_memicmp(Buffer, "BUSY TRUE", 9) == 0)
+ {
+ TNC->BusyFlags |= CDBusy;
+ TNC->Busy = TNC->BusyHold * 10; // BusyHold delay
+
+ SetWindowText(TNC->xIDC_CHANSTATE, "Busy");
+ strcpy(TNC->WEB_CHANSTATE, "Busy");
+
+ TNC->WinmorRestartCodecTimer = time(NULL);
+*/
+ return 0;
+ }
+/*
+ if (_memicmp(Buffer, "BUSY FALSE", 10) == 0)
+ {
+ TNC->BusyFlags &= ~CDBusy;
+ if (TNC->BusyHold)
+ strcpy(TNC->WEB_CHANSTATE, "BusyHold");
+ else
+ strcpy(TNC->WEB_CHANSTATE, "Clear");
+
+ SetWindowText(TNC->xIDC_CHANSTATE, TNC->WEB_CHANSTATE);
+ TNC->WinmorRestartCodecTimer = time(NULL);
+ return;
+ }
+*/
+
+ }
+
+ return (0);
+
+}
+
+
+
+char MsgHddr[] = "POST /RPC2 HTTP/1.1\r\n"
+ "User-Agent: XMLRPC++ 0.8\r\n"
+ "Host: 127.0.0.1:7362\r\n"
+ "Content-Type: text/xml\r\n"
+ "Content-length: %d\r\n"
+ "\r\n%s";
+
+char Req[] = "<?xml version=\"1.0\"?>\r\n"
+ "<methodCall><methodName>%s</methodName>\r\n"
+ "%s"
+ "</methodCall>\r\n";
+
+
+VOID SendXMLCommand(struct TNCINFO * TNC, char * Command, char * Value, char ParamType)
+{
+ int Len;
+ char ReqBuf[512];
+ char SendBuff[512];
+ struct FLINFO * FL = TNC->FLInfo;
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+ char ValueString[256] ="";
+
+ if (!TNC->CONNECTED || TNC->FLInfo->KISSMODE)
+ return;
+
+ if (Value)
+ if (ParamType == 'S')
+ sprintf(ValueString, "<params><param><value><string>%s</string></value></param></params\r\n>", Value);
+ else
+ sprintf(ValueString, "<params><param><value><i4>%d</i4></value></param></params\r\n>", Value);
+
+ strcpy(FL->LastXML, Command);
+ Len = sprintf(ReqBuf, Req, FL->LastXML, ValueString);
+ Len = sprintf(SendBuff, MsgHddr, Len, ReqBuf);
+ send(TNC->TCPSock, SendBuff, Len, 0);
+ return;
+}
+
+VOID SendXMLPoll(struct TNCINFO * TNC)
+{
+ int Len;
+ char ReqBuf[256];
+ char SendBuff[256];
+ struct FLINFO * FL = TNC->FLInfo;
+ struct ARQINFO * ARQ = TNC->ARQInfo;
+
+ if (!TNC->CONNECTED)
+ return;
+
+ if (TNC->FLInfo->KISSMODE)
+ return;
+
+ if (ARQ->ARQTimer)
+ {
+ // if timer is running, poll fot TX State
+
+ strcpy(FL->LastXML, "main.get_trx_state");
+ Len = sprintf(ReqBuf, Req, FL->LastXML, "");
+ Len = sprintf(SendBuff, MsgHddr, Len, ReqBuf);
+ send(TNC->TCPSock, SendBuff, Len, 0);
+ return;
+ }
+
+ FL->XMLControl++;
+
+
+ if (FL->XMLControl > 9)
+ {
+ FL->XMLControl = 0;
+ strcpy(FL->LastXML, "modem.get_name");
+ }
+ else
+ {
+ if (FL->XMLControl == 5)
+ strcpy(FL->LastXML, "main.get_trx_state");
+ else
+ return;
+ }
+
+ Len = sprintf(ReqBuf, Req, FL->LastXML, "");
+ Len = sprintf(SendBuff, MsgHddr, Len, ReqBuf);
+ send(TNC->TCPSock, SendBuff, Len, 0);
+}
+
+// sudo add-apt-repository ppa:kamalmostafa/fldigi
+
+
diff --git a/FreeDATA.c b/FreeDATA.c
index 9e4b349..ac1cb65 100644
--- a/FreeDATA.c
+++ b/FreeDATA.c
@@ -452,6 +452,11 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
TNC->lasttime = ltime;
ConnecttoFreeData(port);
}
+ while (TNC->PortRecord->UI_Q)
+ {
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+ ReleaseBuffer(buffptr);
+ }
}
diff --git a/HALDriver64.c b/HALDriver64.c
new file mode 100644
index 0000000..7c60f9f
--- /dev/null
+++ b/HALDriver64.c
@@ -0,0 +1,1907 @@
+/*
+Copyright 2001-2018 John Wiseman G8BPQ
+
+This file is part of LinBPQ/BPQ32.
+
+LinBPQ/BPQ32 is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+LinBPQ/BPQ32 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
+*/
+
+//
+// DLL to inteface HAL Communications Corp Clover/Pacor controllers to BPQ32 switch
+//
+// Uses BPQ EXTERNAL interface
+//
+
+#define _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "time.h"
+
+#include "CHeaders.h"
+#include "tncinfo.h"
+
+#include "bpq32.h"
+
+#define HAL 1
+
+#define SetMYCALL 0x13
+#define ConnectEnable 0x52
+#define ConnectDisable 0x42
+#define SetEAS 0x59 // Echo as Sent
+#define SetTones 0xec
+#define ClearOnDisc 0x57
+
+static char ClassName[]="HALSTATUS";
+
+static char WindowTitle[] = "HAL";
+static int RigControlRow = 185;
+
+struct TNCINFO * TNCInfo[34]; // Records are Malloc'd
+
+#define SOH 0x01 // CONTROL CODES
+#define ETB 0x17
+#define DLE 0x10
+
+//int MaxStreams = 0;
+
+#ifndef LINBPQ
+extern HFONT hFont;
+#endif
+
+static char status[23][50] = {"IDLE", "TFC", "RQ", "ERR", "PHS", "OVER", "FSK TX",
+ "FSK RX", "P-MODE100", "P-MODE200", "HUFMAN ON", "HUFMAN OFF", "P-MODE SBY(LISTEN ON)",
+ "P-MODE SBY(LISTEN OFF)", "ISS", "IRS",
+ "AMTOR SBY(LISTEN ON)", "AMTOR SBY(LISTEN OFF)", "AMTOR FEC TX", "AMTOR FEC RX", "P-MODE FEC TX",
+ "FREE SIGNAL TX (AMTOR)", "FREE SIGNAL TX TIMED OUT (AMTOR)"};
+
+struct TNCINFO * CreateTTYInfo(int port, int speed);
+BOOL OpenConnection(int);
+BOOL SetupConnection(int);
+static BOOL WriteCommBlock(struct TNCINFO * TNC);
+static void CheckRX(struct TNCINFO * TNC);
+VOID HALPoll(int Port);
+VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * rxbuff, int len);
+VOID ProcessTermModeResponse(struct TNCINFO * TNC);
+static VOID DoTNCReinit(struct TNCINFO * TNC);
+VOID DoTermModeTimeout(struct TNCINFO * TNC);
+VOID ProcessHALBuffer(struct TNCINFO * TNC, int Length);
+VOID ProcessHALCmd(struct TNCINFO * TNC);
+VOID ProcessHALData(struct TNCINFO * TNC);
+VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * rxbuffer, int Len);
+VOID ProcessKNormCommand(struct TNCINFO * TNC, UCHAR * rxbuffer);
+VOID ProcessHostFrame(struct TNCINFO * TNC, UCHAR * rxbuffer, int Len);
+VOID DoMonitor(struct TNCINFO * TNC, UCHAR * Msg, int Len);
+
+BOOL HALConnected(struct TNCINFO * TNC, char * Call);
+VOID HALDisconnected(struct TNCINFO * TNC);
+
+static VOID EncodeAndSend(struct TNCINFO * TNC, UCHAR * txbuffer, int Len);
+VOID SendCmd(struct TNCINFO * TNC, UCHAR * txbuffer, int Len);
+int DLEEncode(UCHAR * inbuff, UCHAR * outbuff, int len);
+int DLEDecode(UCHAR * inbuff, UCHAR * outbuff, int len);
+
+VOID COMClearDTR(HANDLE fd);
+VOID COMClearRTS(HANDLE fd);
+int DoScanLine(struct TNCINFO * TNC, char * Buff, int Len);
+
+
+
+//static HANDLE LogHandle[4] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE};
+
+//char * Logs[4] = {"1", "2", "3", "4"};
+
+//char BaseDir[]="c:";
+
+static VOID CloseLogfile(int Flags)
+{
+// CloseHandle(LogHandle[Flags]);
+// LogHandle[Flags] = INVALID_HANDLE_VALUE;
+}
+
+static VOID OpenLogfile(int Flags)
+{
+/*
+UCHAR FN[MAX_PATH];
+ time_t T;
+ struct tm * tm;
+
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ sprintf(FN,"%s\\HALLog_%02d%02d%02d_%s.bin", BaseDir, tm->tm_mday, tm->tm_hour, tm->tm_min, Logs[Flags]);
+
+ LogHandle[Flags] = CreateFile(FN,
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ SetFilePointer(LogHandle[Flags], 0, 0, FILE_END);
+
+ return (LogHandle[Flags] != INVALID_HANDLE_VALUE);
+*/
+}
+
+static void WriteLogLine(int Flags, char * Msg, int MsgLen)
+{
+// int cnt;
+// WriteFile(LogHandle[Flags] ,Msg , MsgLen, &cnt, NULL);
+}
+
+
+
+int ProcessLine(char * buf, int Port)
+{
+ UCHAR * ptr,* p_cmd;
+ char * p_ipad = 0;
+ char * p_port = 0;
+ unsigned short WINMORport = 0;
+ int BPQport;
+ int len=510;
+ struct TNCINFO * TNC;
+ char errbuf[256];
+
+ strcpy(errbuf, buf);
+
+ ptr = strtok(buf, " \t\n\r");
+
+ if(ptr == NULL) return (TRUE);
+
+ if(*ptr =='#') return (TRUE); // comment
+
+ if(*ptr ==';') return (TRUE); // comment
+
+ ptr = strtok(NULL, " \t\n\r");
+
+ if (_stricmp(buf, "APPL") == 0) // Using BPQ32 COnfig
+ {
+ BPQport = Port;
+ p_cmd = ptr;
+ }
+ else
+ if (_stricmp(buf, "PORT") != 0) // Using Old Config
+ {
+ // New config without a PORT or APPL - this is a Config Command
+
+ strcpy(buf, errbuf);
+ strcat(buf, "\r");
+
+ BPQport = Port;
+
+ TNC = TNCInfo[BPQport] = zalloc(sizeof(struct TNCINFO));
+
+ TNC->InitScript = malloc(1000);
+ TNC->InitScript[0] = 0;
+ goto ConfigLine;
+ }
+ else
+
+ {
+
+ // Old Config from file
+
+ BPQport=0;
+ BPQport = atoi(ptr);
+
+ p_cmd = strtok(NULL, " \t\n\r");
+
+ if (Port && Port != BPQport)
+ {
+ // Want a particular port, and this isn't it
+
+ while(TRUE)
+ {
+ if (GetLine(buf) == 0)
+ return TRUE;
+
+ if (memcmp(buf, "****", 4) == 0)
+ return TRUE;
+
+ }
+ }
+ }
+ if(BPQport > 0 && BPQport < 33)
+ {
+ TNC = TNCInfo[BPQport] = zalloc(sizeof(struct TNCINFO));
+ TNC->InitScript = malloc(1000);
+ TNC->InitScript[0] = 0;
+
+ if (p_cmd != NULL)
+ {
+ if (p_cmd[0] != ';' && p_cmd[0] != '#')
+ TNC->ApplCmd=_strdup(p_cmd);
+ }
+
+ // Read Initialisation lines
+
+ while(TRUE)
+ {
+ if (GetLine(buf) == 0)
+ return TRUE;
+ConfigLine:
+ strcpy(errbuf, buf);
+
+ if (memcmp(buf, "****", 4) == 0)
+ return TRUE;
+
+ ptr = strchr(buf, ';');
+ if (ptr)
+ {
+ *ptr++ = 13;
+ *ptr = 0;
+ }
+
+ if (_memicmp(buf, "WL2KREPORT", 10) == 0)
+ {
+ TNC->WL2K = DecodeWL2KReportLine(buf);
+ continue;
+ }
+ if (_memicmp(buf, "NEEDXONXOFF", 10) == 0)
+ {
+ TNC->XONXOFF = TRUE;
+ continue;
+ }
+
+ if (_memicmp(buf, "TONES", 5) == 0)
+ {
+ int tone1 = 0, tone2 = 0;
+
+ ptr = strtok(&buf[6], " ,/\t\n\r");
+ if (ptr)
+ {
+ tone1 = atoi(ptr);
+ ptr = strtok(NULL, " ,/\t\n\r");
+ if (ptr)
+ {
+ tone2 = atoi(ptr);
+ ptr = &TNC->InitScript[TNC->InitScriptLen];
+
+ // Try putting into FSK mode first
+
+ *(ptr++) = 0x84;
+ *(ptr++) = SetTones; // Set Tones (Mark, Space HI byte first)
+ *(ptr++) = tone1 >> 8;
+ *(ptr++) = tone1 & 0xff;
+ *(ptr++) = tone2 >> 8;
+ *(ptr++) = tone2 & 0xff;
+
+ TNC->InitScriptLen += 6;
+
+ continue;
+ }
+ }
+ goto BadLine;
+ }
+ if (_memicmp(buf, "DEFAULTMODE ", 12) == 0)
+ {
+
+ ptr = strtok(&buf[12], " ,\t\n\r");
+ if (ptr)
+ {
+ if (_stricmp(ptr, "CLOVER") == 0)
+ TNC->DefaultMode = Clover;
+ else if (_stricmp(ptr, "PACTOR") == 0)
+ TNC->DefaultMode = Pactor;
+ else if (_stricmp(ptr, "AMTOR") == 0)
+ TNC->DefaultMode = AMTOR;
+ else goto BadLine;
+
+ continue;
+ }
+ goto BadLine;
+ }
+ }
+ BadLine:
+ WritetoConsole(" Bad config record ");
+ WritetoConsole(errbuf);
+ WritetoConsole("\r\n");
+ }
+
+ return (TRUE);
+}
+
+static size_t ExtProc(int fn, int port , PDATAMESSAGE buff)
+{
+ int txlen = 0;
+ PMSGWITHLEN buffptr;
+ struct TNCINFO * TNC = TNCInfo[port];
+ struct STREAMINFO * STREAM;
+ int Stream;
+
+ if (TNC == NULL)
+ return 0;
+
+ if (fn < 4 || fn > 5)
+ if (TNC->hDevice == 0)
+ return 0; // Port not open
+
+ STREAM = &TNC->Streams[0];
+
+ switch (fn)
+ {
+ case 1: // poll
+
+ while (TNC->PortRecord->UI_Q) // Release anything accidentally put on UI_Q
+ {
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+ ReleaseBuffer(buffptr);
+ }
+
+ //for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (STREAM->ReportDISC)
+ {
+ STREAM->ReportDISC = FALSE;
+ buff->PORT = 0;
+
+ return -1;
+ }
+ }
+
+ CheckRX(TNC);
+ HALPoll(port);
+
+ //for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (STREAM->PACTORtoBPQ_Q !=0)
+ {
+ int datalen;
+
+ buffptr=Q_REM(&STREAM->PACTORtoBPQ_Q);
+
+ datalen = (int)buffptr->Len;
+
+ buff->PORT = 0; // 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;
+
+ PutLengthinBuffer(buff, datalen);
+
+
+ ReleaseBuffer(buffptr);
+
+ return (1);
+ }
+ }
+
+ return 0;
+
+ case 2: // send
+
+ buffptr = GetBuff();
+
+ if (buffptr == 0) return (0); // No buffers, so ignore
+
+ // Find TNC Record
+
+ Stream = buff->PORT;
+
+ if (!TNC->TNCOK)
+ {
+ // Send Error Response
+
+ PMSGWITHLEN buffptr = (PMSGWITHLEN)GetBuff();
+
+ if (buffptr == 0) return (0); // No buffers, so ignore
+
+ buffptr->Len = 27;
+ memcpy(&buffptr->Data[0], "No Connection to PACTOR TNC\r", 27);
+
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+ return 0;
+ }
+
+ txlen = GetLengthfromBuffer(buff) - (sizeof(void *) + 4);
+
+ buffptr->Len = txlen;
+ memcpy(&buffptr->Data[0], &buff->L2DATA[0], txlen);
+
+ C_Q_ADD(&STREAM->BPQtoPACTOR_Q, buffptr);
+
+ STREAM->FramesQueued++;
+
+ return (0);
+
+
+ case 3: // CHECK IF OK TO SEND. Also used to check if TNC is responding
+
+ Stream = (int)(size_t)buff;
+
+ if (STREAM->FramesQueued > 4)
+ return (1 | TNC->HostMode << 8);
+
+ return TNC->HostMode << 8 | STREAM->Disconnecting << 15; // OK, but lock attach if disconnecting
+
+ case 4: // reinit
+
+ return (0);
+
+ case 5: // Close
+
+ CloseCOMPort(TNCInfo[port]->hDevice);
+ return (0);
+
+ case 6: // Scan Control
+
+ return 0; // None Yet
+
+ }
+ return 0;
+
+}
+
+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>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>");
+
+ Len += sprintf(&Buff[Len], "<tr><td width=90px>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);
+ Len += sprintf(&Buff[Len], "<tr><td>Mode</td><td>%s</td></tr>", TNC->WEB_MODE);
+ Len += sprintf(&Buff[Len], "<tr><td>Status</td><td>%s</td></tr>", TNC->WEB_STATE);
+ Len += sprintf(&Buff[Len], "<tr><td>TX/RX State</td><td>%s</td></tr>", TNC->WEB_TXRX);
+ Len += sprintf(&Buff[Len], "<tr><td>Traffic</td><td>%s</td></tr>", TNC->WEB_TRAFFIC);
+ Len += sprintf(&Buff[Len], "<tr><td>LEDS</td><td>STBY CALL LINK ERROR TX RX</td></tr>");
+ Len += sprintf(&Buff[Len], "<tr><td> </td><td>%s</td></tr>", TNC->WEB_LEDS);
+ Len += sprintf(&Buff[Len], "</table>");
+
+ Len = DoScanLine(TNC, Buff, Len);
+
+ return Len;
+}
+
+
+VOID * HALExtInit(EXTPORTDATA * PortEntry)
+{
+ char msg[500];
+ struct TNCINFO * TNC;
+ int port;
+ char * ptr;
+ int len;
+ char Msg[80];
+#ifndef LINBPQ
+ HWND x;
+#endif
+ //
+ // Will be called once for each Pactor Port
+ // The COM port number is in IOBASE
+ //
+
+ sprintf(msg,"HAL Driver %s", PortEntry->PORTCONTROL.SerialPortName);
+ WritetoConsole(msg);
+
+ port=PortEntry->PORTCONTROL.PORTNUMBER;
+
+ ReadConfigFile(port, ProcessLine);
+ TNC = TNCInfo[port];
+
+ if (TNC == NULL)
+ {
+ // Not defined in Config file
+
+ sprintf(msg," ** Error - no info in BPQ32.cfg for this port");
+ WritetoConsole(msg);
+
+ return ExtProc;
+ }
+
+ TNC->Port = port;
+
+ TNC->Hardware = H_HAL;
+
+ TNC->Interlock = PortEntry->PORTCONTROL.PORTINTERLOCK;
+
+ PortEntry->MAXHOSTMODESESSIONS = 1; // Default
+
+ TNC->PortRecord = PortEntry;
+
+ if (PortEntry->PORTCONTROL.PORTCALL[0] == 0)
+ {
+ memcpy(TNC->NodeCall, MYNODECALL, 10);
+ }
+ else
+ {
+ ConvFromAX25(&PortEntry->PORTCONTROL.PORTCALL[0], TNC->NodeCall);
+ }
+
+ PortEntry->PORTCONTROL.PROTOCOL = 10;
+ PortEntry->PORTCONTROL.PORTQUALITY = 0;
+
+ if (PortEntry->PORTCONTROL.PORTPACLEN == 0)
+ PortEntry->PORTCONTROL.PORTPACLEN = 100;
+
+ ptr=strchr(TNC->NodeCall, ' ');
+ if (ptr) *(ptr) = 0; // Null Terminate
+
+ if (TNC->DefaultMode)
+ TNC->CurrentMode = TNC->DefaultMode;
+ else
+ TNC->CurrentMode = Clover;
+
+ TNC->PollDelay = 999999999;
+
+ // Set Disable +?, ExpandedStatus , Channel Stats Off, ClearOnDisc, EAS and MYCALL
+
+ len = sprintf(Msg, "%c%c%c%c%c%c%s", 0xcc, 0x56, 0x41, ClearOnDisc, SetEAS, SetMYCALL, TNC->NodeCall);
+ len++; // We include the NULL
+
+ memcpy(&TNC->InitScript[TNC->InitScriptLen], Msg, len);
+ TNC->InitScriptLen += len;
+
+ PortEntry->PORTCONTROL.TNC = TNC;
+
+ TNC->WebWindowProc = WebProc;
+ TNC->WebWinX = 510;
+ TNC->WebWinY = 280;
+
+ TNC->WEB_COMMSSTATE = zalloc(100);
+ TNC->WEB_TNCSTATE = zalloc(100);
+ strcpy(TNC->WEB_TNCSTATE, "Free");
+ TNC->WEB_MODE = zalloc(100);
+ TNC->WEB_TRAFFIC = zalloc(100);
+ TNC->WEB_BUFFERS = zalloc(100);
+ TNC->WEB_STATE = zalloc(100);
+ TNC->WEB_TXRX = zalloc(100);
+ TNC->WEB_LEDS = zalloc(100);
+ strcpy(TNC->WEB_LEDS, " X X X X X X");
+
+#ifndef LINBPQ
+
+ CreatePactorWindow(TNC, ClassName, WindowTitle, RigControlRow, PacWndProc, 500, 233, ForcedClose);
+
+ x = CreateWindowEx(0, "STATIC", "Comms State", WS_CHILD | WS_VISIBLE, 10,6,120,20, TNC->hDlg, NULL, hInstance, NULL);
+ x = TNC->xIDC_COMMSSTATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,6,386,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ x = CreateWindowEx(0, "STATIC", "TNC State", WS_CHILD | WS_VISIBLE, 10,28,106,20, TNC->hDlg, NULL, hInstance, NULL);
+ x = TNC->xIDC_TNCSTATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,28,520,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ x = CreateWindowEx(0, "STATIC", "Mode", WS_CHILD | WS_VISIBLE, 10,50,80,20, TNC->hDlg, NULL, hInstance, NULL);
+ x = TNC->xIDC_MODE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,50,200,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ x = CreateWindowEx(0, "STATIC", "Status", WS_CHILD | WS_VISIBLE, 10,72,110,20, TNC->hDlg, NULL, hInstance, NULL);
+ x = TNC->xIDC_STATE = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 116,72,144,20, TNC->hDlg, NULL, hInstance, NULL);
+
+ x = CreateWindowEx(0, "STATIC", "TX/RX State", WS_CHILD | WS_VISIBLE,10,94,80,20, TNC->hDlg, NULL, hInstance, NULL);
+ x = TNC->xIDC_TXRX = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE,116,94,374,20 , TNC->hDlg, NULL, hInstance, NULL);
+
+ x = CreateWindowEx(0, "STATIC", "Traffic", WS_CHILD | WS_VISIBLE,10,116,80,20, TNC->hDlg, NULL, hInstance, NULL);
+ x = TNC->xIDC_TRAFFIC = CreateWindowEx(0, "STATIC", "RX 0 TX 0 ACKED 0", WS_CHILD | WS_VISIBLE,116,116,374,20 , TNC->hDlg, NULL, hInstance, NULL);
+
+ x = CreateWindowEx(0, "STATIC", "LEDS", WS_CHILD | WS_VISIBLE,10,138,60,20, TNC->hDlg, NULL, hInstance, NULL);
+ SendMessage(x, WM_SETFONT, (WPARAM)hFont, 0);
+ x = CreateWindowEx(0, "STATIC", "STBY CALL LINK ERROR TX RX", WS_CHILD | WS_VISIBLE,116,138,280,20, TNC->hDlg, NULL, hInstance, NULL);
+ SendMessage(x, WM_SETFONT, (WPARAM)hFont, 0);
+ x = TNC->xIDC_LEDS = CreateWindowEx(0, "STATIC", " X X X X X X", WS_CHILD | WS_VISIBLE,116,158,280,20 , TNC->hDlg, NULL, hInstance, NULL);
+ SendMessage(x, WM_SETFONT, (WPARAM)hFont, 0);
+
+ TNC->ClientHeight = 233;
+ TNC->ClientWidth = 500;
+
+ MoveWindows(TNC);
+#endif
+
+ OpenCOMMPort(TNC, PortEntry->PORTCONTROL.SerialPortName, PortEntry->PORTCONTROL.BAUDRATE, FALSE);
+
+ SendCmd(TNC, "\x09" , 1); // Reset
+
+ WritetoConsole("\n");
+
+ return ExtProc;
+}
+
+
+
+static VOID KISSCLOSE(int Port)
+{
+ struct TNCINFO * conn = TNCInfo[Port];
+
+ // drop DTR and RTS
+
+ COMClearDTR(conn->hDevice);
+ COMClearRTS(conn->hDevice);
+
+ // purge any outstanding reads/writes and close device handle
+
+ CloseCOMPort(conn->hDevice);
+
+ return;
+}
+
+
+static void CheckRX(struct TNCINFO * TNC)
+{
+ int Length, Len;
+ UCHAR * Xptr;
+
+ // only try to read number of bytes in queue
+
+ if (TNC->RXLen == 500)
+ TNC->RXLen = 0;
+
+ Len = ReadCOMBlock(TNC->hDevice, &TNC->RXBuffer[TNC->RXLen], 500 - TNC->RXLen);
+
+ if (Len == 0)
+ return;
+
+ TNC->RXLen += Len;
+
+ Length = TNC->RXLen;
+
+ // We need to konw whether data is received or echoed, so we can't split commands and data here.
+ // Pass everything to the Command Handler. It will check that there are enough bytes for the command,
+ // and wait for more if not.
+
+ // The USB version also uses 0x91 0x31 to eacape 0x11, 0x91 0x33 for 0x13 and 0x91 0xB1 for 0x91
+
+ // If USB version, we might get unescaped xon and xoff, which we must ignore
+
+ if (TNC->XONXOFF)
+ {
+ Xptr = memchr(&TNC->RXBuffer, 0x11, Length);
+
+ while(Xptr)
+ {
+ Debugprintf("XON Port %d", TNC->Port);
+ memmove(Xptr, Xptr + 1, Length-- - (TNC->RXBuffer - Xptr));
+ Xptr = memchr(&TNC->RXBuffer, 0x11, Length);
+ }
+
+ Xptr = memchr(&TNC->RXBuffer, 0x13, Length);
+
+ while(Xptr)
+ {
+ Debugprintf("XOFF Port %d", TNC->Port);
+ memmove(Xptr, Xptr + 1, Length-- - (TNC->RXBuffer - Xptr));
+ Xptr = memchr(&TNC->RXBuffer, 0x13, Length);
+ }
+
+ Xptr = memchr(&TNC->RXBuffer, 0x91, Length); // See if packet contains 0x91 escape
+
+ if (Xptr)
+
+ // Make sure we have the escaped char as well
+
+ if ((Xptr - &TNC->RXBuffer[0]) == Length - 1) // x91 is last char
+ return;
+ }
+
+ ProcessHALBuffer(TNC, Length);
+
+ TNC->RXLen = 0;
+
+ return;
+
+}
+
+
+
+static BOOL WriteCommBlock(struct TNCINFO * TNC)
+{
+ WriteCOMBlock(TNC->hDevice, TNC->TXBuffer, TNC->TXLen);
+ return TRUE;
+}
+
+VOID HALPoll(int Port)
+{
+ struct TNCINFO * TNC = TNCInfo[Port];
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ UCHAR * Poll = TNC->TXBuffer;
+ char Status[80];
+ UCHAR TXMsg[1000];
+ int datalen;
+
+ if (TNC->Timeout)
+ {
+ TNC->Timeout--;
+
+ if (TNC->Timeout) // Still waiting
+ return;
+
+ // Timed Out
+
+ TNC->TNCOK = FALSE;
+ TNC->HostMode = 0;
+
+ sprintf(TNC->WEB_COMMSSTATE,"%s Open but TNC not responding", TNC->PortRecord->PORTCONTROL.SerialPortName);
+ MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
+
+ //for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (TNC->PortRecord->ATTACHEDSESSIONS[0]) // Connected
+ {
+ STREAM->Connected = FALSE; // Back to Command Mode
+ STREAM->ReportDISC = TRUE; // Tell Node
+ }
+ }
+
+ }
+
+ // if we have just restarted or TNC appears to be in terminal mode, run Initialisation Sequence
+
+ if (TNC->TNCOK)
+ if (!TNC->HostMode)
+ {
+ DoTNCReinit(TNC);
+ return;
+ }
+
+ if (TNC->PortRecord->ATTACHEDSESSIONS[0] && STREAM->Attached == 0)
+ {
+ // New Attach
+
+ int calllen;
+ char Msg[80];
+
+ STREAM->Attached = TRUE;
+
+ STREAM->BytesRXed = STREAM->BytesTXed = STREAM->BytesAcked = 0;
+
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4USER, STREAM->MyCall);
+ STREAM->MyCall[calllen] = 0;
+
+ datalen = sprintf(TXMsg, "%c%s", SetMYCALL, STREAM->MyCall);
+ 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);
+
+ // Stop Scanning
+
+ sprintf(Msg, "%d SCANSTOP", TNC->Port);
+
+ Rig_Command(-1, Msg);
+
+ SendCmd(TNC, "\x42", 1); // Connect Enable off
+
+ return;
+
+ }
+
+ //for (Stream = 0; Stream <= MaxStreams; Stream++)
+
+ if (STREAM->Attached)
+ CheckForDetach(TNC, 0, STREAM, TidyClose, ForcedClose, CloseComplete);
+
+ if (TNC->NeedPACTOR)
+ {
+ TNC->NeedPACTOR--;
+
+ if (TNC->NeedPACTOR == 0)
+ {
+ int datalen;
+
+ UCHAR TXMsg[80];
+
+ datalen = sprintf(TXMsg, "%c%s", SetMYCALL, TNC->NodeCall);
+ SendCmd(TNC, TXMsg, datalen + 1); // Send the NULL
+
+ // Set Listen Mode
+
+ switch (TNC->CurrentMode)
+ {
+ case Pactor:
+
+ SendCmd(TNC, "\x84", 1); // FSK
+ SendCmd(TNC, "\x83", 1); // Select P-MODE Standby
+ SendCmd(TNC, "\x58", 1); // Listen
+
+ break;
+
+ case Clover:
+
+ SendCmd(TNC, "\x80", 1); // Clover
+ SendCmd(TNC, "\x54", 1); // Enable adaptive Clover format
+ SendCmd(TNC, "\x41", 1); // No Statistics
+ SendCmd(TNC, "\x60\x09", 2); // Robust Retries
+ SendCmd(TNC, "\x61\x09", 2); // Normal Retries
+
+ break;
+ }
+
+ SendCmd(TNC, "\x52", 1); // ConnectEnable
+
+ // Restart Scanning
+
+ sprintf(Status, "%d SCANSTART 15", TNC->Port);
+
+ Rig_Command(-1, Status);
+
+ return;
+ }
+ }
+
+#define MAXHALTX 256
+
+ //for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (TNC->TNCOK && STREAM->BPQtoPACTOR_Q && (STREAM->BytesTXed - STREAM->BytesAcked < 600))
+ {
+ int datalen;
+ UINT * buffptr;
+ UCHAR * MsgPtr;
+ unsigned char TXMsg[500];
+
+ buffptr = (UINT * )STREAM->BPQtoPACTOR_Q;
+ datalen=buffptr[1];
+ MsgPtr = (UCHAR *)&buffptr[2];
+
+ if (STREAM->Connected)
+ {
+ if (TNC->SwallowSignon)
+ {
+ TNC->SwallowSignon = FALSE;
+ if (strstr(MsgPtr, "Connected")) // Discard *** connected
+ {
+ ReleaseBuffer(buffptr);
+ STREAM->FramesQueued--;
+ return;
+ }
+ }
+
+ // Must send data in small chunks - the Hal has limited buffer space
+
+ // If in IRS force a turnround
+
+ if (TNC->TXRXState == 'R' && TNC->CurrentMode != Clover)
+ {
+ if (TNC->TimeInRX++ > 15)
+ SendCmd(TNC, "\x87", 1); // Changeover to ISS
+ else
+ goto Poll;
+ }
+
+ TNC->TimeInRX = 0;
+
+ EncodeAndSend(TNC, MsgPtr, datalen);
+ buffptr=Q_REM(&STREAM->BPQtoPACTOR_Q);
+ ReleaseBuffer(buffptr);
+ WriteLogLine(2, MsgPtr, datalen);
+
+ STREAM->BytesTXed += datalen;
+ STREAM->FramesQueued--;
+
+ ShowTraffic(TNC);
+
+ return;
+ }
+ else
+ {
+ buffptr=Q_REM(&STREAM->BPQtoPACTOR_Q);
+ STREAM->FramesQueued--;
+
+ // Command. Do some sanity checking and look for things to process locally
+
+ datalen--; // Exclude CR
+ MsgPtr[datalen] = 0; // Null Terminate
+ _strupr(MsgPtr);
+
+ if (memcmp(MsgPtr, "RADIO ", 6) == 0)
+ {
+ sprintf(&MsgPtr[40], "%d %s", TNC->Port, &MsgPtr[6]);
+ if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &MsgPtr[40]))
+ {
+ ReleaseBuffer(buffptr);
+ }
+ else
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "%s", &MsgPtr[40]);
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+ return;
+ }
+
+ if (memcmp(MsgPtr, "MODE CLOVER", 11) == 0)
+ {
+ TNC->CurrentMode = Clover;
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2],"HAL} Ok\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ MySetWindowText(TNC->xIDC_MODE, "Clover");
+ strcpy(TNC->WEB_MODE, "Clover");
+
+ SendCmd(TNC, "\x80", 1); // Clover
+ SendCmd(TNC, "\x54", 1); // Enable adaptive Clover format
+ SendCmd(TNC, "\x41", 1); // No Statistics
+
+ return;
+ }
+
+ if (memcmp(MsgPtr, "MODE PACTOR", 11) == 0)
+ {
+ TNC->CurrentMode = Pactor;
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2],"HAL} Ok\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ SendCmd(TNC, "\x84", 1); // FSK
+ SendCmd(TNC, "\x83", 1); // Select P-MODE Standby
+ SendCmd(TNC, "\x48", 1); // Listen Off
+
+ return;
+ }
+ if (memcmp(MsgPtr, "MODE AMTOR", 11) == 0)
+ {
+ TNC->CurrentMode = AMTOR;
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2],"HAL} Ok\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ return;
+ }
+
+ if (MsgPtr[0] == 'C' && MsgPtr[1] == ' ' && datalen > 2) // Connect
+ {
+ memcpy(STREAM->RemoteCall, &MsgPtr[2], 9);
+
+ switch (TNC->CurrentMode)
+ {
+ case Pactor:
+
+ SendCmd(TNC, "\x84", 1); // FSK
+ SendCmd(TNC, "\x83", 1); // Select P-MODE Standby
+
+ datalen = sprintf(TXMsg, "\x19%s", STREAM->RemoteCall);
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s - PACTOR", STREAM->MyCall, STREAM->RemoteCall);
+
+ // DOnt set connecting till we get the 19 response so we can trap listen as a fail
+ break;
+
+ case Clover:
+
+ SendCmd(TNC, "\x54", 1); // Enable adaptive Clover format
+ SendCmd(TNC, "\x57", 1); // Enable TX buffer clear on disconnect
+
+ datalen = sprintf(TXMsg, "\x11%s", STREAM->RemoteCall);
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s - CLOVER", STREAM->MyCall, STREAM->RemoteCall);
+
+ break;
+ }
+
+ MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ SendCmd(TNC, TXMsg, datalen + 1); // Include NULL
+
+ ReleaseBuffer(buffptr);
+
+ return;
+ }
+
+ if (memcmp(MsgPtr, "CLOVER ", 7) == 0)
+ {
+ memcpy(STREAM->RemoteCall, &MsgPtr[2], 9);
+
+ SendCmd(TNC, "\x54", 1); // Enable adaptive Clover format
+ SendCmd(TNC, "\x57", 1); // Enable TX buffer clear on disconnect
+
+ datalen = sprintf(TXMsg, "\x11%s", STREAM->RemoteCall);
+ SendCmd(TNC, TXMsg, datalen + 1); // Include NULL
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s - CLOVER",
+ STREAM->MyCall, STREAM->RemoteCall);
+ MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ ReleaseBuffer(buffptr);
+
+ return;
+ }
+
+ if (memcmp(MsgPtr, "DISCONNECT", datalen) == 0) // Disconnect
+ {
+ SendCmd(TNC, "\x07", 1); // Normal Disconnect
+ TNC->NeedPACTOR = 50;
+
+ STREAM->Connecting = FALSE;
+ STREAM->ReportDISC = TRUE;
+ ReleaseBuffer(buffptr);
+
+ return;
+ }
+
+ // Other Command ?? Treat as HEX string
+
+ datalen = sscanf(MsgPtr, "%X %X %X %X %X %X %X %X %X %X %X %X %X %X %X %X",
+ (UINT *)&TXMsg[0], (UINT *)&TXMsg[1], (UINT *)&TXMsg[2], (UINT *)&TXMsg[3], (UINT *)&TXMsg[4],
+ (UINT *)&TXMsg[5], (UINT *)&TXMsg[6], (UINT *)&TXMsg[7], (UINT *)&TXMsg[8], (UINT *)&TXMsg[9],
+ (UINT *)&TXMsg[10], (UINT *)&TXMsg[11], (UINT *)&TXMsg[12], (UINT *)&TXMsg[13],
+ (UINT *)&TXMsg[14], (UINT *)&TXMsg[15]);
+
+// SendCmd(TNC, TXMsg, datalen);
+ ReleaseBuffer(buffptr);
+ TNC->InternalCmd = 0;
+ }
+ }
+ }
+Poll:
+ // Nothing doing - send Poll (but not too often)
+
+ TNC->PollDelay++;
+
+ if (TNC->PollDelay < 20)
+ return;
+
+ TNC->PollDelay = 0;
+
+ if (TNC->TNCOK)
+ SendCmd(TNC, "\x7d" , 1); // Use Get LEDS as Poll
+ else
+ SendCmd(TNC, "\x09" , 1); // Reset
+
+ TNC->Timeout = 100;
+
+ return;
+}
+
+static VOID DoTNCReinit(struct TNCINFO * TNC)
+{
+ // TNC Has Restarted, send init commands (can probably send all at once)
+
+// TNC->TXBuffer[0] = 0x1b;
+// TNC->TXLen = 1;
+
+ WriteCommBlock(TNC);
+
+ SendCmd(TNC, TNC->InitScript, TNC->InitScriptLen);
+
+ TNC->HostMode = TRUE; // Should now be in Host Mode
+ TNC->NeedPACTOR = 20; // Need to set Calls and start scan
+
+ TNC->DataMode = RXDATA; // Start with RX Data
+
+ SendCmd(TNC, "\x7d" , 1); // Use Get LEDS as Poll
+// SendCmd(TNC, "\xc9" , 1); // Huffman Off
+ SendCmd(TNC, "\x57", 1); // Enable TX buffer clear on disconnect
+
+ SendCmd(TNC, "\x60\x06", 2); // Robust Mode Retries
+
+// SendCmd(TNC, "\x6f\x03" , 2); // Undocumented XON/XOFF On - used to see if old or new style modem
+
+ TNC->Timeout = 50;
+
+ return;
+
+}
+
+VOID ProcessHALData(struct TNCINFO * TNC)
+{
+ // Received Data just pass to Appl
+
+ UINT * buffptr;
+ int Len = TNC->DataLen;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ TNC->DataLen = 0;
+
+ if (TNC->DataMode == TXDATA)
+ {
+ STREAM->BytesAcked += Len;
+// Debugprintf("Acked %d", Len);
+
+ if (STREAM->BytesAcked > STREAM->BytesTXed)
+ Debugprintf("Too Much Acked");
+
+ if ((STREAM->BPQtoPACTOR_Q == 0) && STREAM->BytesAcked >= STREAM->BytesTXed)
+ {
+ // All sent
+
+ if (STREAM->Disconnecting)
+ TidyClose(TNC, 0);
+ else
+ if (TNC->CurrentMode != Clover)
+
+ // turn round link
+
+ SendCmd(TNC, "\x0c" , 1); // Turnround
+
+ }
+ }
+ else
+ {
+ if (TNC->DataMode == RXDATA)
+ {
+// Debugprintf("RXed %d", Len);
+ buffptr = GetBuff();
+ if (buffptr == NULL)
+ return; // No buffers, so ignore
+
+ buffptr[1] = Len; // Length
+
+ WriteLogLine(1, TNC->DataBuffer, Len);
+
+ STREAM->BytesRXed += Len;
+
+ memcpy(&buffptr[2], TNC->DataBuffer, Len);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+ }
+
+ ShowTraffic(TNC);
+
+ return;
+}
+
+
+
+VOID ProcessHALBuffer(struct TNCINFO * TNC, int Length)
+{
+ UCHAR Char;
+ UCHAR * inptr;
+ UCHAR * cmdptr;
+ UCHAR * dataptr;
+ BOOL CmdEsc, DataEsc;
+
+ inptr = TNC->RXBuffer;
+
+ cmdptr = &TNC->CmdBuffer[TNC->CmdLen];
+ dataptr = &TNC->DataBuffer[TNC->DataLen];
+ CmdEsc = TNC->CmdEsc;
+ DataEsc = TNC->DataEsc;
+
+ // HAL uses HEX 80 as a command escape, 81 to ESCAPE 80 and 81
+
+ // The USB version also uses 0x91 0x31 to eacape 0x11, 0x91 0x33 for 0x13 and 0x91 0xB1 for 0x91
+
+ // Command Responses can be variable length
+
+ // Command Handler will check for each command/response if it has enough - if not it will wait till more arrives
+
+ while(Length--)
+ {
+ Char = *(inptr++);
+
+ if (CmdEsc)
+ {
+ CmdEsc = FALSE;
+
+ if (TNC->XONXOFF && Char == 0x91)
+ {
+ // XON/XOFF escape. We ensured above that data follows so we can process it inline
+
+ Length--;
+ Char = *(inptr++) - 0x20;
+ }
+ *(cmdptr++) = Char;
+ }
+ else if (DataEsc)
+ {
+ DataEsc = FALSE;
+ goto DataChar;
+ }
+ else
+NotData:
+ if (Char == 0x80) // Next Char is Command
+ CmdEsc = TRUE;
+ else if (Char == 0x81) // Next Char is escaped data (80 or 81)
+ DataEsc = TRUE;
+ else
+ {
+ // This is a Data Char. We must process any Commands received so far, so we know the type of data
+
+ DataChar:
+
+ TNC->CmdLen = (int)(cmdptr - TNC->CmdBuffer);
+ ProcessHALCmd(TNC);
+ cmdptr = &TNC->CmdBuffer[TNC->CmdLen];
+ dataptr = &TNC->DataBuffer[TNC->DataLen];
+
+ *(dataptr++) = Char; // Normal Data
+
+ // Now process any other data chars
+
+ while(Length--)
+ {
+ Char = *(inptr++);
+
+ if (TNC->XONXOFF && Char == 0x91)
+ {
+ // XON/XOFF escape within data. We ensured above that data follows so we
+ // can process it here
+
+ Length--;
+ Char = *(inptr++) - 0x20;
+ }
+
+ if (Char == 0x80 || Char == 0x81)
+ {
+ // Process any data we have, then loop back
+
+ TNC->DataLen = (int)(dataptr - TNC->DataBuffer);
+ ProcessHALData(TNC);
+
+ goto NotData;
+ }
+ *(dataptr++) = Char; // Normal Data
+ }
+
+ // Used all data
+
+ TNC->DataLen = (int)(dataptr - TNC->DataBuffer);
+
+ ProcessHALData(TNC);
+ TNC->CmdEsc = CmdEsc;
+ TNC->DataEsc = DataEsc;
+
+ return;
+ }
+ }
+
+ // Save State
+
+ TNC->CmdLen = (int)(cmdptr - TNC->CmdBuffer);
+
+ TNC->CmdEsc = CmdEsc;
+ TNC->DataEsc = DataEsc;
+
+ if (TNC->DataLen)
+ ProcessHALData(TNC);
+
+ if (TNC->CmdLen)
+ ProcessHALCmd(TNC);
+}
+
+VOID mySetWindowText(struct TNCINFO * TNC, char * Msg)
+{
+ MySetWindowText(TNC->xIDC_STATE, Msg);
+ strcpy(TNC->WEB_STATE, Msg);
+}
+
+VOID ProcessHALCmd(struct TNCINFO * TNC)
+{
+ char * Call;
+ int Stream = 0;
+ int Opcode;
+ int StatusByte;
+ int Leds;
+ int Len;
+ int Used;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+CmdLoop:
+
+ Opcode = TNC->CmdBuffer[0];
+ Len = TNC->CmdLen;
+
+ if (Len == 0)
+ return;
+
+ TNC->TNCOK = TRUE;
+ TNC->Timeout = 0;
+
+ sprintf(TNC->WEB_COMMSSTATE,"%s TNC link OK", TNC->PortRecord->PORTCONTROL.SerialPortName);
+ MySetWindowText(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
+
+ switch(Opcode)
+ {
+ case 0x09: //Hardware Reset - equivalent to power on reset
+
+ // Hardware has reset - need to reinitialise
+
+ TNC->HostMode = 0; // Force Reinit
+
+ Used = 1;
+ break;
+
+ case 0x7a: // FSK Modes Status
+
+ // Mixture of mode and state - eg listen huffman on/off irs/iss, so cant just display
+
+ if (Len < 2) return; // Wait for more
+
+ StatusByte = TNC->CmdBuffer[1];
+
+ switch (StatusByte)
+ {
+ case 0x06: // FSK TX (RTTY)
+ case 0x07: // FSK RX (RTTY)
+ case 0x10: // AMTOR STANDBY (LISTEN ON)
+ case 0x11: // AMTOR STANDBY (LISTEN OFF)
+ case 0x12: // AMTOR FEC TX (AMTOR)
+ case 0x13: // AMTOR FEC RX (AMTOR)
+ case 0x14: // P-MODE FEC TX (P-MODE)
+ case 0x15: // FREE SIGNAL TX (AMTOR)
+ case 0x16: // FREE SIGNAL TX TIMED OUT (AMTOR)
+
+ // Diaplay Linke Status
+
+ MySetWindowText(TNC->xIDC_MODE, status[StatusByte]);
+ strcpy(TNC->WEB_MODE, status[StatusByte]);
+
+ break;
+
+ case 0x0C: // P-MODE STANDBY (LISTEN ON)
+ case 0x0D: // P-MODE STANDBY (LISTEN OFF)
+
+ // if we were connecting, this means connect failed.
+
+ MySetWindowText(TNC->xIDC_MODE, status[StatusByte]);
+ strcpy(TNC->WEB_MODE, status[StatusByte]);
+
+ if (STREAM->Connecting)
+ HALDisconnected(TNC);
+
+ break;
+
+ case 0x0E: // ISS (AMTOR/P-MODE)
+
+ MySetWindowText(TNC->xIDC_TXRX,"ISS");
+ strcpy(TNC->WEB_TXRX, "ISS");
+ TNC->TXRXState = 'S';
+ break;
+
+ case 0x0F: // IRS (AMTOR/P-MODE)
+
+ MySetWindowText(TNC->xIDC_TXRX,"IRS");
+ strcpy(TNC->WEB_TXRX, "IRS");
+ TNC->TXRXState = 'R';
+ break;
+
+ case 0x00: // IDLE (AMTOR/P-MODE)
+ case 0x01: // TFC (AMTOR/P-MODE)
+ case 0x02: // RQ (AMTOR/P-MODE)
+ case 0x03: // ERR (AMTOR/P-MODE)
+ case 0x04: // PHS (AMTOR/P-MODE)
+ case 0x05: // OVER (AMTOR/P-MODE) (not implemented)
+
+ MySetWindowText(TNC->xIDC_STATE, status[StatusByte]);
+ strcpy(TNC->WEB_MODE, status[StatusByte]);
+
+
+
+//$807A $8008 P-MODE100 (P-MODE)
+//$807A $8009 P-MODE200 (P-MODE)
+//$807A $800A HUFFMAN ON (P-MODE)
+//$807A $800B HUFFMAN OFF (P-MODE)
+ ;
+ }
+ Used = 2;
+ break;
+
+
+ case 0x7d: // Get LED Status
+
+ // We use Get LED Status as a Poll
+
+ if (Len < 2) return; // Wait for more
+
+ Leds = TNC->CmdBuffer[1];
+ sprintf(TNC->WEB_LEDS," %c %c %c %c %c %c ",
+ (Leds & 0x20)? 'X' : ' ',
+ (Leds & 0x10)? 'X' : ' ',
+ (Leds & 0x08)? 'X' : ' ',
+ (Leds & 0x04)? 'X' : ' ',
+ (Leds & 0x02)? 'X' : ' ',
+ (Leds & 0x01)? 'X' : ' ');
+
+// STBY CALL LINK ERROR TX RX
+ MySetWindowText(TNC->xIDC_LEDS, TNC->WEB_LEDS);
+
+ Used = 2;
+ break;
+
+ case 0x21: // Monitored FEC CCB
+ case 0x22: // Monitored ARQ CCB
+
+ // As the reply is variable, make sure we have the terminating NULL
+
+ if (memchr(TNC->CmdBuffer, 0, Len) == NULL)
+ return; // Wait for more
+
+ Call = &TNC->CmdBuffer[1];
+ Used = (int)strlen(Call) + 2; // Opcode and Null
+
+ UpdateMH(TNC, Call, '!', 0);
+
+ break;
+
+ case 0x27: // Clover ARQ LINK REQUEST status message
+
+ //indicates an incoming link request to either MYCALL ($8027 $8000), or MYALTCALL ($8027 $8001).
+
+ if (Len < 2) return; // Wait for more
+
+ // Don't need to do anything (but may eventally use ALTCALL as an APPLCALL
+ Used = 2;
+ break;
+
+ case 0x2D: // FSK ARQ Link Request status message
+
+ // $802D $8001 $8000 CLOVER Link Request (not implemented)
+ // $802D $8002 $8000 AMTOR CCIR-476 Link Request
+ // $802D $8003 $8000 AMTOR CCIR-625 Link Request
+ // $802D $8004 $8000 P-MODE Link Request
+
+ if (Len < 3) return; // Wait for more
+
+ // Don't need to do anything (but may save Session type later
+
+ Used = 3;
+ break;
+
+
+ case 0x28: // Monitored Call
+
+ // As the reply is variable, make sure we have the terminating NULL
+
+ if (memchr(TNC->CmdBuffer, 0, Len) == NULL)
+ return; // Wait for more
+
+ Call = &TNC->CmdBuffer[1];
+ Used = strlen(Call) + 2; // Opcode and Null
+
+ // Could possibly be used for APPLCALLS by changing MYCALL when we see a call to one of our calls
+
+ break;
+
+
+ case 0x20: // Clover Linked with - Call Connected
+ case 0x29: // The Linked 476 message indicates the start of a CCIR 476 linked session.
+ case 0x2A: // The Linked 625 message indicates the start of a CCIR 625 linked session to <CALL>.
+ case 0x2B: // P-MODE link to
+
+ // As the reply is variable, make sure we have the terminating NULL
+
+ if (memchr(TNC->CmdBuffer, 0, Len) == NULL)
+ return; // Wait for more
+
+ Call = &TNC->CmdBuffer[1];
+ Used = (int)strlen(Call) + 2; // Opcode and Null
+
+ HALConnected(TNC, Call);
+
+ break;
+
+ case 0x23: // Normal Disconnected - followed by $8000
+ case 0x24: // Link failed (any of the link errors)
+ case 0x25: // Signal Lost (LOS)
+
+ if (Len < 2) return; // Wait for more
+
+ HALDisconnected(TNC);
+
+ Used = 2;
+ break;
+
+
+ // Stream Switch Reports - we will need to do something with these if Echo as Sent is set
+ // or we do something with the secondary port
+
+ case 0x30: // Switch to Receive Data characters
+ case 0x31: // Switch to Transmit Data characters
+ case 0x32: // Switch to RX data from secondary port
+
+ TNC->DataMode = Opcode;
+ Used = 1;
+ break;
+
+ case 0x33: // Send TX data to modem
+ case 0x34: // Send TX data to secondary port
+
+ TNC->TXMode = Opcode;
+ Used = 1;
+ break;
+
+ case 0x70: // Channel Spectra Data
+ // $807F $80xx $8030 Invalid or unimplemented command code
+ if (Len < 9) return; // Wait for more
+
+ Used = 9;
+ break;
+
+ case 0x71: // SelCall On/Off
+
+ if (Len < 2) return; // Wait for more
+
+ Used = 2;
+ break;
+
+ case 0x72: // Channel Spectra Data
+ // $807F $80xx $8030 Invalid or unimplemented command code
+ if (Len < 15) return; // Wait for more
+
+ Used = 15;
+ break;
+
+ case 0x73: // Clover Link state
+
+ if (Len < 2) return; // Wait for more
+
+ StatusByte = TNC->CmdBuffer[1];
+
+ 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;
+ }
+
+ Used = 2;
+ break;
+
+ case 0x75: // Clover waveform format
+
+ if (Len < 5) return; // Wait for more
+
+ Used = 5;
+ break;
+
+ case 0x7F: // Error $80xx $80yy Error in command $80xx of type $80yy
+ // $807F $80xx $8030 Invalid or unimplemented command code
+ // $807F $80xx $8031 Invalid parameter value
+ // $807F $80xx $8032 Not allowed when connected
+ // $807F $80xx $8033 Not allowed when disconnected
+ // $807F $80xx $8034 Not valid in this mode
+ // $807F $80xx $8035 Not valid in this code
+ // $807F $8096 $8036 EEPROM write error
+
+ if (Len < 3) return; // Wait for more
+
+ if (TNC->CmdBuffer[1] == 0x6f && TNC->CmdBuffer[2] == 0x31)
+ {
+ // Reject of XON/XOFF enable
+
+// TNC->XONXOFF = FALSE;
+// Debugprintf("BPQ32 HAL Port %d - Disabling XON/XOFF mode", TNC->Port);
+ }
+ else
+ Debugprintf("HAL Port %d Command Error Cmd %X Error %X", TNC->Port, TNC->CmdBuffer[1], TNC->CmdBuffer[2]);
+
+ Used = 3;
+ break;
+
+ // Following are all immediate commands - response is echo of command
+
+ case 0x6f: // XON/XOFF on
+
+// TNC->XONXOFF = TRUE; // And drop through
+// Debugprintf("BPQ32 HAL Port %d - Enabling XON/XOFF mode", TNC->Port);
+
+ case 0x19: // Call P-MODE to <CALL>
+ case 0x10: // Robust Link to <CALL> using MYCALL
+ case 0x11: // Normal Link to <CALL> using MYCALL
+
+ STREAM->Connecting = TRUE;
+
+ case 0x00: // P Load LOD file
+ case 0x01: // P Load S28 file
+ case 0x02: //Check Unit Error Status
+ case 0x03: //F Check System Clock
+ case 0x04: //C Close PTT and transmit Clover waveform
+ case 0x05: //Open PTT and stop transmit test
+ case 0x06: //Immediate Abort (Panic Kill)
+ case 0x07: //Normal disconnect (wait for ACK)
+ case 0x08: //Software reset - restore all program defaults
+ case 0x0A: //Send CW ID
+ case 0x0B: //Close PTT and transmit Single Tone
+ case 0x0C: //F Normal OVER (AMTOR,P-MODE)
+ case 0x0D: //F Force RTTY TX (Baudot/ASCII)
+ case 0x0E: //F Go to RTTY RX (Baudot/ASCII)
+ case 0x0F: //Go to LOD/S28 file loader
+ case SetMYCALL: // Set MYCALL Response
+
+ case 0x1E: // Set MYALTCALL Response
+
+ case 0x41:
+ case 0x42:
+ case 0x46:
+ case 0x47:
+ case 0x48:
+ case 0x4d:
+ case 0x52: // Enable adaptive Clover format
+ case 0x54: // Enable adaptive Clover format
+
+ case 0x56: // Expanded Link State Reports OFF/ON
+ case 0x57: // Clear buffers on disc
+ case 0x58:
+ case 0x59:
+ case 0x60: // Robust Mode Retries
+ case 0x61: // Normal Mode Retries
+ case 0x80: //Switch to CLOVER mode
+ case 0x81: //Select AMTOR Standby
+ case 0x82: //Select AMTOR FEC
+ case 0x83: //Select P-MODE Standby
+ case 0x84: //Switch to FSK modes
+ case 0x85: //Select Baudot
+ case 0x86: //Select ASCII
+ case 0x87: //Forced OVER (AMTOR, P-MODE)
+ case 0x88: //Forced END (AMTOR, P-MODE)
+ case 0x89: //Force LTRS shift
+ case 0x8A: //Force FIGS shift
+ case 0x8B: //Send MARK tone
+ case 0x8C: //Send SPACE tone
+ case 0x8D: //Send MARK/SPACE tones
+ case 0x8E: //Received first character on line
+ case 0x8F: //Close PTT only (no tones)
+
+ case 0xC9: //Huffman Off/On
+ case 0xCC:
+ case 0xD9: //Close PTT only (no tones)
+
+ case SetTones:
+
+ Used = 1;
+ break;
+
+ case 0x91: // ????
+
+// if (Len < 2) return; // Wait for more
+
+ Used = 1;
+ break;
+
+ default:
+
+ // We didn't recognise command, so don't know how long it is - disaster!
+
+ Debugprintf("HAL Port %d Unrecognised Command %x", TNC->Port, Opcode);
+ TNC->CmdLen = 0;
+
+ return;
+ }
+
+ if (Used == Len)
+ {
+ // All used - most likely case
+
+ TNC->CmdLen = 0;
+ return;
+ }
+
+ // Move Command Down buffer, and reenter
+
+ TNC->CmdLen -= Used;
+
+ memmove(TNC->CmdBuffer, &TNC->CmdBuffer[Used], TNC->CmdLen);
+
+ goto CmdLoop;
+
+
+}
+
+
+VOID HALDisconnected(struct TNCINFO * TNC)
+{
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ CloseLogfile(0);
+ CloseLogfile(1);
+ CloseLogfile(2);
+
+ if ((STREAM->Connecting | STREAM->Connected) == 0)
+ {
+ // Not connected or Connecting. Probably response to going into Pactor Listen Mode
+
+ return;
+ }
+
+ if (STREAM->Connecting && STREAM->Disconnecting == FALSE)
+ {
+ UINT * buffptr;
+
+ // Connect Failed - actually I think HAL uses another code for connect failed, but leave here for now
+
+ buffptr = GetBuff();
+
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "*** Failure with %s\r", STREAM->RemoteCall);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+
+ STREAM->Connecting = FALSE;
+ STREAM->Connected = FALSE; // In case!
+ STREAM->FramesQueued = 0;
+
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", STREAM->MyCall);
+ MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ return;
+ }
+
+ // Connected, or Disconnecting - Release Session
+
+ STREAM->Connecting = FALSE;
+ STREAM->Connected = FALSE; // Back to Command Mode
+ STREAM->FramesQueued = 0;
+
+ if (STREAM->Disconnecting == FALSE)
+ STREAM->ReportDISC = TRUE; // Tell Node
+
+ STREAM->Disconnecting = FALSE;
+
+ // Need to reset Pactor Call in case it was changed
+
+ TNC->NeedPACTOR = 20;
+}
+
+BOOL HALConnected(struct TNCINFO * TNC, char * Call)
+{
+ char Msg[80];
+ UINT * buffptr;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+ char CallCopy[80];
+
+ strcpy(CallCopy, Call);
+ strcat(CallCopy, " "); // Some routines expect 10 char calls
+
+ STREAM->BytesRXed = STREAM->BytesTXed = STREAM->BytesAcked = 0;
+ STREAM->ConnectTime = time(NULL);
+
+ // Stop Scanner
+
+ sprintf(Msg, "%d SCANSTOP", TNC->Port);
+
+ Rig_Command(-1, Msg);
+
+ ShowTraffic(TNC);
+
+ TNC->DataMode = RXDATA;
+
+ OpenLogfile(0);
+ OpenLogfile(1);
+ OpenLogfile(2);
+
+ if (TNC->PortRecord->ATTACHEDSESSIONS[0] == 0)
+ {
+ // Incoming Connect
+
+ 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);
+
+ if (TNC->CurrentMode != Clover)
+ SendCmd(TNC, "\x87", 1); // Changeover to ISS
+
+ // If an autoconnect APPL is defined, send it
+
+ if (TNC->ApplCmd)
+ {
+ buffptr = GetBuff();
+ if (buffptr == 0) return TRUE; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "%s\r", TNC->ApplCmd);
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ TNC->SwallowSignon = TRUE;
+
+ return TRUE;
+ }
+
+ if (FULL_CTEXT && HFCTEXTLEN == 0)
+ {
+ EncodeAndSend(TNC, CTEXTMSG, CTEXTLEN);
+ WriteLogLine(2, CTEXTMSG, CTEXTLEN);
+
+ STREAM->BytesTXed += CTEXTLEN;
+ }
+ return TRUE;
+ }
+
+ // Connect Complete
+
+ buffptr = GetBuff();
+ if (buffptr == 0) return TRUE; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "*** Connected to %s\r", Call);;
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ STREAM->Connecting = FALSE;
+ 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);
+
+ UpdateMH(TNC, CallCopy, '+', 'O');
+
+
+ return TRUE;
+}
+
+
+static VOID EncodeAndSend(struct TNCINFO * TNC, UCHAR * txbuffer, int Len)
+{
+ // Send A Packet With DLE Encoding Encoding
+
+ TNC->TXLen = DLEEncode(txbuffer, TNC->TXBuffer, Len);
+
+ WriteCommBlock(TNC);
+}
+
+VOID SendCmd(struct TNCINFO * TNC, UCHAR * txbuffer, int Len)
+{
+ // Send A Packet With Command Encoding (preceed each with 0x80
+
+ int i,txptr=0;
+ UCHAR * outbuff = TNC->TXBuffer;
+
+ for (i=0; i<Len; i++)
+ {
+ outbuff[txptr++] = 0x80;
+ outbuff[txptr++] = txbuffer[i];
+ }
+
+ TNC->TXLen = txptr;
+ WriteCommBlock(TNC);
+}
+
+int DLEEncode(UCHAR * inbuff, UCHAR * outbuff, int len)
+{
+ int i, txptr = 0;
+ UCHAR c;
+
+ // Escape x80 and x81 with x81
+
+// outbuff[0] = 0x80;
+// outbuff[1] = 0x33; // Send data to modem
+
+ for (i=0;i<len;i++)
+ {
+ c=inbuff[i];
+
+ switch (c)
+ {
+ case 0x80:
+ case 0x81:
+
+ outbuff[txptr++] = 0x81;
+ }
+ outbuff[txptr++] = c;
+ }
+
+ return txptr;
+
+}
+
+VOID TidyClose(struct TNCINFO * TNC, int Stream)
+{
+ SendCmd(TNC, "\x07", 1); // Tidy Disconnect
+}
+
+VOID ForcedClose(struct TNCINFO * TNC, int Stream)
+{
+ SendCmd(TNC, "\x06", 1); // Hard Disconnect
+}
+
+VOID CloseComplete(struct TNCINFO * TNC, int Stream)
+{
+ TNC->NeedPACTOR = 30;
+}
+
+
+
+
diff --git a/HFCommon.c b/HFCommon.c
index 1ecd775..7aa274c 100644
--- a/HFCommon.c
+++ b/HFCommon.c
@@ -1866,9 +1866,6 @@ static char ** SeparateMultiString(char * MultiString)
return Value;
}
-
-
-
extern int nextDummyInterlock;
int standardParams(struct TNCINFO * TNC, char * buf)
@@ -1917,7 +1914,7 @@ int standardParams(struct TNCINFO * TNC, char * buf)
TNC->ActiveTXFreq = atof(&buf[13]);
else if (_memicmp(buf, "ActiveRXFreq", 12) == 0) // Set at start of session
TNC->ActiveRXFreq = atof(&buf[13]);
- else if (_memicmp(buf, "DisconnectScript", 16) == 0) // Set at start of session
+ else if (_memicmp(buf, "DisconnectScript", 16) == 0) // Set at end of session
TNC->DisconnectScript = SeparateMultiString(&buf[17]);
else if (_memicmp(buf, "PTTONHEX", 8) == 0)
{
diff --git a/HTTPcode.c b/HTTPcode.c
index 245ab3d..3145d80 100644
--- a/HTTPcode.c
+++ b/HTTPcode.c
@@ -105,9 +105,13 @@ extern int NumberofPorts;
extern UCHAR ConfigDirectory[260];
+extern struct AXIPPORTINFO * Portlist[];
+
VOID sendandcheck(SOCKET sock, const char * Buffer, int Len);
int CompareNode(const void *a, const void *b);
int CompareAlias(const void *a, const void *b);
+int CompareRoutes(const void * a, const void * b);
+
void ProcessMailHTTPMessage(struct HTTPConnectionInfo * Session, char * Method, char * URL, char * input, char * Reply, int * RLen, int InputLen, char * Token);
void ProcessChatHTTPMessage(struct HTTPConnectionInfo * Session, char * Method, char * URL, char * input, char * Reply, int * RLen);
struct PORTCONTROL * APIENTRY GetPortTableEntryFromSlot(int portslot);
@@ -3794,12 +3798,82 @@ doHeader:
*/
+ // AXIP Partners
+
+ if (_stricmp(NodeURL, "/Node/AXIP.html") == 0)
+ {
+ int i;
+ char Normcall[10];
+ int Width = 5;
+ int x = 0, n = 0, nd = 0;
+ struct arp_table_entry * List[1000];
+ struct arp_table_entry * ListD[1000];
+ char AXIPList[10000] = "";
+ int ListLen = 0;
+
+ struct AXIPPORTINFO * AXPORT = Portlist[0];
+ struct PORTCONTROL * PORT = PORTTABLE;
+ struct arp_table_entry * arp;
+ time_t NOW = time(NULL);
+
+ char AXIPHeader[] =
+ "<table align='center' bgcolor='ffffff' border=2 cellpadding=10 cellspacing=2 style=font-family:monospace>"
+ "<tr><td align='center'>AXIP Up</td><td align='center'>AXIP Down</td></tr><tr><td valign='top'>%s";
+
+
+ while (PORT)
+ {
+ AXPORT = Portlist[PORT->PORTNUMBER];
+
+ if (AXPORT)
+ {
+ // Get ARP entries
+
+ for (i = 0; i < AXPORT->arp_table_len; i++)
+ {
+ arp = &AXPORT->arp_table[i];
+
+ if (arp->LastHeard == 0 || (NOW - arp->LastHeard) > 3600) // Considered down
+ ListD[nd++] = arp;
+ else
+ List[n++] = arp;
+ }
+ }
+ PORT = PORT->PORTPOINTER;
+ }
+
+ if (n > 1)
+ qsort(List, n, sizeof(void *), CompareNode);
+ if (nd > 1)
+ qsort(ListD, nd, sizeof(void *), CompareNode);
+
+ for (i = 0; i < n; i++)
+ {
+ int len = ConvFromAX25(List[i]->callsign, Normcall);
+ Normcall[len]=0;
+
+ ListLen += sprintf(&AXIPList[ListLen], "%02d - %s %d<br>", i + 1, Normcall, (List[i]->LastHeard)?(NOW - List[i]->LastHeard):0);
+ }
+
+ ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], AXIPHeader, AXIPList);
+
+ ListLen = 0;
+
+ for (i = 0; i < nd; i++)
+ {
+ int len = ConvFromAX25(ListD[i]->callsign, Normcall);
+ Normcall[len]=0;
+ ListLen += sprintf(&AXIPList[ListLen], "%02d - %s %d<br>", i + 1, Normcall, (ListD[i]->LastHeard)?(NOW - ListD[i]->LastHeard):0);
+ }
+ ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "</td><td valign='top'>%s", AXIPList);
+ ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "</td></tr></table></body></html>");
+ }
if (_stricmp(NodeURL, "/Node/Routes.html") == 0)
{
struct ROUTE * Routes = NEIGHBOURS;
int MaxRoutes = MAXNEIGHBOURS;
- int count;
+ int count, i;
char Normcall[10];
char locked[4] = " ";
int NodeCount;
@@ -3807,13 +3881,35 @@ doHeader:
int Iframes, Retries;
char Active[10];
int Queued;
+
+ int x = 0, n = 0;
+ struct ROUTE * List[1000];
+
ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", RouteHddr);
- for (count=0; count<MaxRoutes; count++)
+ // Build and sort list of routes
+
+ for (count = 0; count < MaxRoutes; count++)
{
if (Routes->NEIGHBOUR_CALL[0] != 0)
{
+ List[n++] = Routes;
+
+ if (n > 999)
+ break;
+ }
+
+ Routes++;
+ }
+
+ if (n > 1)
+ qsort(List, n, sizeof(void *), CompareRoutes);
+
+ for (i = 0; i < n; i++)
+ {
+ Routes = List[i];
+ {
int len = ConvFromAX25(Routes->NEIGHBOUR_CALL, Normcall);
Normcall[len]=0;
diff --git a/IPCode.c b/IPCode.c
index f340d4b..4d9abca 100644
--- a/IPCode.c
+++ b/IPCode.c
@@ -100,7 +100,10 @@ TODo ?Multiple Adapters
#ifdef WIN32
int pcap_sendpacket(pcap_t *p, u_char *buf, int size);
#else
- PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int);
+#ifndef PCAP_API
+#define PCAP_API extern
+#endif
+PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int);
#endif
#ifndef LINBPQ
@@ -387,7 +390,7 @@ char * FormatIP(uint32_t Addr)
return FormatIPWork;
}
-int CompareRoutes (const VOID * a, const VOID * b)
+int CompareIPRoutes (const VOID * a, const VOID * b)
{
PROUTEENTRY x;
PROUTEENTRY y;
@@ -4972,7 +4975,7 @@ VOID SHOWIPROUTE(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, str
Bufferptr = Cmdprintf(Session, Bufferptr, "%d Entries\r", NumberofRoutes);
if (NumberofRoutes)
- qsort(RouteRecords, NumberofRoutes, sizeof(void *), CompareRoutes);
+ qsort(RouteRecords, NumberofRoutes, sizeof(void *), CompareIPRoutes);
for (i=0; i < NumberofRoutes; i++)
{
diff --git a/KAMPactor.c b/KAMPactor.c
index 318c6e0..239b183 100644
--- a/KAMPactor.c
+++ b/KAMPactor.c
@@ -70,6 +70,8 @@ static RECT Rect;
int DoScanLine(struct TNCINFO * TNC, char * Buff, int Len);
VOID WritetoTrace(struct TNCINFO * TNC, char * Msg, int Len);
+VOID SuspendOtherPorts(struct TNCINFO * ThisTNC);
+VOID ReleaseOtherPorts(struct TNCINFO * ThisTNC);
static FILE * LogHandle[32] = {0};
@@ -517,6 +519,28 @@ ok:
return 0;
}
+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);
+
+// STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
+// sprintf(STREAM->CmdSet, "I%s\r", "SCSPTC"); // Should prevent connects
+
+}
+
+VOID KAMReleasePort(struct TNCINFO * TNC)
+{
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+
+ strcpy(TNC->WEB_TNCSTATE, "Free");
+ MySetWindowText(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>"
@@ -595,6 +619,11 @@ void * KAMExtInit(EXTPORTDATA * PortEntry)
PortEntry->PORTCONTROL.PORTSTARTCODE = KAMStartPort;
PortEntry->PORTCONTROL.PORTSTOPCODE = KAMStopPort;
+// TNC->SuspendPortProc = KAMSuspendPort;
+// TNC->ReleasePortProc = KAMReleasePort;
+
+
+
ptr=strchr(TNC->NodeCall, ' ');
if (ptr) *(ptr) = 0; // Null Terminate
@@ -886,24 +915,39 @@ VOID KAMPoll(int Port)
calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4USER, TNC->Streams[0].MyCall);
TNC->Streams[0].MyCall[calllen] = 0;
- EncodeAndSend(TNC, "X", 1); // ??Return to packet mode??
- if (TNC->VeryOldMode)
- datalen = sprintf(TXMsg, "C20MYCALL %s", TNC->Streams[0].MyCall);
- else
- datalen = sprintf(TXMsg, "C20MYPTCALL %s", TNC->Streams[0].MyCall);
+ EncodeAndSend(TNC, "X", 1); // ??Return to packet mode??
+
+ if (TNC->VeryOldMode)
+ {
+ datalen = sprintf(TXMsg, "C20MYCALL %s", TNC->Streams[0].MyCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+ }
+ else
+ {
+ datalen = sprintf(TXMsg, "C20MYPTCALL %s", TNC->Streams[0].MyCall);
EncodeAndSend(TNC, TXMsg, datalen);
- TNC->InternalCmd = 'M';
+
+ if (TNC->OldMode == 0)
+ {
+ EncodeAndSend(TNC, TXMsg, datalen);
+ datalen = sprintf(TXMsg, "C20MYGTCALL %s", TNC->Streams[0].MyCall);
+ }
+ }
+
+ TNC->InternalCmd = 'M';
- TNC->NeedPACTOR = 0; // Cancel enter Pactor
+ TNC->NeedPACTOR = 0; // Cancel enter Pactor
- sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
- SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ SuspendOtherPorts(TNC);
+
+ sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall);
+ SetWindowText(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);
}
}
@@ -1036,9 +1080,22 @@ VOID KAMPoll(int Port)
UCHAR TXMsg[80] = "D20";
if (TNC->VeryOldMode)
+ {
datalen = sprintf(TXMsg, "C20MYCALL %s", TNC->NodeCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+ }
else
+ {
datalen = sprintf(TXMsg, "C20MYPTCALL %s", TNC->NodeCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+
+ if (TNC->OldMode == 0)
+ {
+ datalen = sprintf(TXMsg, "C20MYGTCALL %s", TNC->NodeCall);
+ EncodeAndSend(TNC, TXMsg, datalen);
+ }
+ }
+
EncodeAndSend(TNC, TXMsg, datalen);
if (TNC->OldMode)
@@ -1046,6 +1103,7 @@ VOID KAMPoll(int Port)
else
EncodeAndSend(TNC, "C20TOR", 6); // Back to Listen
+
TNC->InternalCmd = 'T';
TNC->Timeout = 50;
TNC->IntCmdDelay--;
@@ -1266,6 +1324,51 @@ VOID KAMPoll(int Port)
return;
}
+ if (memcmp(MsgPtr, "GTOR ", 5) == 0) // GTOR Connect
+ {
+ memcpy(STREAM->RemoteCall, &MsgPtr[5], 9);
+ STREAM->Connecting = TRUE;
+
+ // If Stream 0, Convert C CALL to PACTOR CALL
+
+ if (Stream == 0)
+ {
+ datalen = sprintf(TXMsg, "C20GTOR %s", TNC->Streams[0].RemoteCall);
+
+ // If Pactor, check busy detecters on any interlocked ports
+
+ if (TNC->HFPacket == 0 && InterlockedCheckBusy(TNC) && TNC->OverrideBusy == 0)
+ {
+ // Channel Busy. Wait
+
+ TNC->ConnectCmd = _strdup(TXMsg);
+
+ sprintf(TNC->WEB_TNCSTATE, "Waiting for clear channel");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ TNC->BusyDelay = TNC->BusyWait * 10;
+
+ return;
+ }
+
+ TNC->OverrideBusy = FALSE;
+
+ sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s",
+ TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+ }
+ else
+ datalen = sprintf(TXMsg, "C1%cC %s", Stream + '@', STREAM->RemoteCall);
+
+ EncodeAndSend(TNC, TXMsg, datalen);
+ TNC->Timeout = 50;
+ TNC->InternalCmd = 'C'; // So we dont send the reply to the user.
+ ReleaseBuffer(buffptr);
+ STREAM->Connecting = TRUE;
+
+ return;
+ }
+
if (memcmp(MsgPtr, "DISCONNECT", datalen) == 0) // Disconnect
{
if (Stream == 0)
@@ -1644,6 +1747,10 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len)
return;
}
+
+ WritetoTrace(TNC, Buffer, Len);
+
+
// Pass to Appl
Stream = TNC->CmdStream;
@@ -1680,6 +1787,76 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len)
if (Msg[0] == '?') // Status
{
TNC->Timeout = 0;
+
+/*
+ The response frame from the TNC will be:
+ <FEND>?0MSXY<FEND> - where MSXY are coded as follows:
+ M One byte indicating the current mode of operation.
+ A=Packet
+ B=RTTY
+ C=ASCII
+ D=AMTOR
+ E=FEC
+ F=SELFEC
+ G=LAMTOR
+ H=PACTOR
+ I=PTLISTEN
+ J=GTOR
+ K=NAVTEX
+ L=CW
+ M=TOR Standby
+ N=GMON
+ O=PSK31
+ S One byte indicating a sub-mode of operation. The byte
+ contains an ASCII character as follows:
+ 0=Standby
+ 1=Phasing
+ 2=Connected
+ 3=Disconnecting
+ 4=FEC
+ 5=SELFEC
+ 6=PTFEC
+ X One byte (called status byte X). This byte is bit-
+ encoded to indicate specific conditions as follows:
+ Bit 0 = (IDLE) set to 1 when receiving IDLE
+ characters in a frame.
+ Bit 1 = (ERR) set to 1 to indicate the received frame
+ failed CRC check, or was not a valid CS
+ response frame.
+ Bit 2 = (Combined receive) set to 1 to indicate that
+ the data was constructed through the use of
+ error correction (i.e. Golay error correction
+ for G-TOR or Memory ARQ for Pactor).
+ Bit 3 = (RQ) set to 1 to indicate an RQ frame. If you
+ are the ISS, it indicates that the receiving
+ station has asked for a repeat of the last
+ data due to received errors. When you are the
+ IRS, it indicates that the transmitting
+ station has sent the same data that you have
+ already received. This means that the sending
+ station did not properly copy your
+ acknowledgement (CS code).
+ Bit 4 = (Huffman) set to 1 to indicate that this
+ frame contains data which uses Huffman
+ compression.
+ Bit 5 = (ISS) set to 1 to indicate that your station
+ is currently the ISS.
+ Bit 6&7 = (Speed) these two bits indicate the current
+ speed of an ARQ link or the PSK31 mode. The
+ coding of the bits is:
+ 00 = 100 baud or BPSK31
+ 01 = 200 baud or QPSK31
+ 10 = 300 baud
+ Y One byte (called status byte Y). This byte is bit-
+ encoded to indicate specific conditions as follows:
+ Bit 0 = reserved (set to 0).
+ Bit 1 = (PTT) PTT is active.
+ Bit 2 = (Changeover) changeover in progress
+ Bits 3-7 = reserved (set to 0).
+*/
+
+
+
return;
}
@@ -1790,6 +1967,10 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len)
if (Msg[1] == '2' && Msg[2] == 'A')
TNC->HFPacket = TRUE;
+ // Stop other ports in same group
+
+ SuspendOtherPorts(TNC);
+
ProcessIncommingConnect(TNC, Call, Stream, TRUE);
SESS = TNC->PortRecord->ATTACHEDSESSIONS[Stream];
@@ -2047,7 +2228,11 @@ VOID ForcedClose(struct TNCINFO * TNC, int Stream)
VOID CloseComplete(struct TNCINFO * TNC, int Stream)
{
- TNC->NeedPACTOR = 50;
+ sprintf(TNC->WEB_TNCSTATE, "Free");
+ SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE);
+
+ ReleaseOtherPorts(TNC);
+ TNC->NeedPACTOR = 50;
}
diff --git a/L2Code.c b/L2Code.c
index f4c83e5..76924bf 100644
--- a/L2Code.c
+++ b/L2Code.c
@@ -33,6 +33,15 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include "cheaders.h"
#include "tncinfo.h"
+// This is needed to link with a lib built from source
+
+#ifdef WIN32
+#define ZEXPORT __stdcall
+#endif
+
+#include <zlib.h>
+
+
#define PFBIT 0x10 // POLL/FINAL BIT IN CONTROL BYTE
#define REJSENT 1 // SET WHEN FIRST REJ IS SENT IN REPLY
@@ -111,7 +120,8 @@ int CheckKissInterlock(struct PORTCONTROL * MYPORT, int Exclusive);
void hookL2SessionAccepted(int Port, char * fromCall, char * toCall, struct _LINKTABLE * LINK);
void hookL2SessionDeleted(struct _LINKTABLE * LINK);
void hookL2SessionAttempt(int Port, char * fromCall, char * toCall, struct _LINKTABLE * LINK);
-
+int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len);
+VOID DeleteINP3Routes(struct ROUTE * Route);
extern int REALTIMETICKS;
@@ -126,7 +136,9 @@ extern int REALTIMETICKS;
#define SDINVC 1 // INVALID COMMAND
#define SDNRER 8 // INVALID N(R)
-
+extern int L2Compress;
+extern int L2CompMaxframe;
+extern int L2CompPaclen;
UCHAR NO_CTEXT = 0;
UCHAR ALIASMSG = 0;
@@ -142,6 +154,8 @@ extern BOOL LogAllConnects;
APPLCALLS * APPL;
+int SUPPORT2point2 = 1;
+
void SendL2ToMonMap(struct PORTCONTROL * PORT, char * ReportCall, char Mode, char Direction)
{
@@ -842,6 +856,7 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
while (xidlen > 0)
{
+ unsigned char * typeptr = ptr;
Type = *ptr++;
Len = *ptr++;
@@ -889,6 +904,23 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
case 8: //RX Window
break;
+
+ case 16:
+
+ // Compression
+
+ if (L2Compress)
+ {
+ LINK->AllowCompress = 1;
+ // return as 17
+ *typeptr = 17;
+ }
+ else
+ {
+ ptr = &ADJBUFFER->PID;
+ ptr[3] -= 2; // Length field - remove compress option
+ Buffer->LENGTH -=2;
+ }
}
}
@@ -900,6 +932,8 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
LINK->LINKPORT = PORT;
+ LINK->KILLTIMER = L2KILLTIME - 60*3; // Time out after 60 secs if SABM not received
+
// save calls so we can match up SABM when it comes
memcpy(LINK->LINKCALL, Buffer->ORIGIN, 7);
@@ -999,6 +1033,7 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
// MESSAGE ON AN ACTIVE LINK
int CTLlessPF = CTL & ~PFBIT;
+ unsigned char * ptr;
PORT->L2FRAMESFORUS++;
@@ -1054,7 +1089,7 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
LINK->L2STATE = 2;
LINK->Ver2point2 = FALSE;
- LINK->L2TIMER = 1; // USe retry to send SABM
+ LINK->L2TIMER = 1; // Use retry to send SABM
}
else if (CTLlessPF == XID)
{
@@ -1062,7 +1097,49 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
LINK->L2STATE = 2;
LINK->Ver2point2 = TRUE;// Must support 2.2 if responded to XID
- LINK->L2TIMER = 1; // USe retry to send SABM
+
+ // if Compress enabled set it
+
+ ptr = &ADJBUFFER->PID;
+
+ if (*ptr++ == 0x82 && *ptr++ == 0x80)
+ {
+ int Type;
+ int Len;
+ unsigned int value;
+ int xidlen = *(ptr++) << 8;
+ xidlen += *ptr++;
+
+ // XID is set of Type, Len, Value n-tuples
+
+ while (xidlen > 0)
+ {
+ Type = *ptr++;
+ Len = *ptr++;
+
+ value = 0;
+ xidlen -= (Len + 2);
+
+ while (Len--)
+ {
+ value <<=8;
+ value += *ptr++;
+ }
+ switch(Type)
+ {
+ case 17:
+
+ // Compression
+
+ if (L2Compress)
+ LINK->AllowCompress = 1;
+
+ }
+ }
+
+ }
+
+ LINK->L2TIMER = 1; // Use retry to send SABM
}
ReleaseBuffer(Buffer);
@@ -1110,8 +1187,9 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
// 2. OTHER END THINKS LINK HAS DIED
// 3. RECOVERY FROM FRMR CONDITION
// 4. REPEAT OF ORIGINAL SABM COS OTHER END MISSED UA
+ // 5. Other end has reloaded
- // FOR 1-3 IT IS REASONABLE TO FULLY RESET THE CIRCUIT, BUT IN 4
+ // FOR 1-3 and 5 IT IS REASONABLE TO FULLY RESET THE CIRCUIT, BUT IN 4
// SUCH ACTION WILL LOSE THE INITIAL SIGNON MSG IF CONNECTING TO A
// BBS. THE PROBLEM IS TELLING THE DIFFERENCE. I'M GOING TO SET A FLAG
// WHEN FIRST INFO RECEIVED - IF SABM REPEATED BEFORE THIS, I'LL ASSUME
@@ -1124,7 +1202,7 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
return;
}
- InformPartner(LINK, NORMALCLOSE); // SEND DISC TO OTHER END
+ InformPartner(LINK, NORMALCLOSE); // SEND DISC TO OTHER END
LINK->CIRCUITPOINTER = 0;
L2SABM(LINK, PORT, Buffer, ADJBUFFER, MSGFLAG); // Process the SABM
@@ -1141,6 +1219,8 @@ VOID L2SABM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
TRANSPORTENTRY * Session;
int CONERROR;
+ struct ROUTE * ROUTE = NULL;
+
char toCall[12], fromCall[12];
@@ -1198,6 +1278,18 @@ VOID L2SABM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
if (PORT->TNC && PORT->TNC->Hardware == H_KISSHF)
AttachKISSHF(PORT, Buffer);
+ // if it is an INP3 connection tell INP3 it is up
+
+
+ if (FindNeighbour(LINK->LINKCALL, PORT->PORTNUMBER, &ROUTE))
+ {
+ if (ROUTE->INP3Node)
+ {
+ Debugprintf("INP3 Incoming connect from %s", fromCall);
+ DeleteINP3Routes(ROUTE);
+ }
+ }
+
if (NO_CTEXT == 1)
return;
@@ -1721,9 +1813,9 @@ BOOL InternalL2SETUPCROSSLINK(PROUTE ROUTE, int Retries)
else
LINK->LINKWINDOW = PORT->PORTWINDOW;
-// if (SUPPORT2point2)
-// LINK->L2STATE = 1; // Send XID
-// else
+ if (SUPPORT2point2)
+ LINK->L2STATE = 1; // Send XID
+ else
LINK->L2STATE = 2;
memcpy(LINK->LINKCALL, ROUTE->NEIGHBOUR_CALL, 7);
@@ -1881,11 +1973,23 @@ VOID L2_PROCESS(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * B
// RESPONSE TO SABM - SET LINK UP
char fromCall[12];
+ struct ROUTE * ROUTE;
fromCall[ConvFromAX25(Buffer->ORIGIN, fromCall)] = 0;
RESET2X(LINK); // LEAVE QUEUED STUFF
+ // See if INP3 route setup
+
+ if (FindNeighbour(Buffer->ORIGIN, PORT->PORTNUMBER, &ROUTE))
+ {
+ if (ROUTE->INP3Node)
+ {
+ Debugprintf("INP3 Route to %s connected", fromCall);
+ }
+ }
+
+
SendL2ToMonMap(PORT, fromCall, '+', 'O');
LINK->L2STATE = 5;
@@ -2018,7 +2122,6 @@ VOID SDUFRM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
SDFRMR(LINK, PORT); // PROCESS FRAME REJECT CONDITION
}
-
ReleaseBuffer(Buffer);
}
@@ -2358,12 +2461,11 @@ CheckNSLoop:
{
// Already have a copy, so discard old and keep this
- Debugprintf ("Frame %d out of seq but already have copy - release it", NS);
ReleaseBuffer(Q_REM(&LINK->RXFRAMES[NS]));
}
else
{
- Debugprintf ("Frame %d out of seq - save", NS);
+// Debugprintf ("Frame %d out of seq - save", NS);
}
Buffer->CHAIN = 0;
@@ -2450,6 +2552,8 @@ CheckPF:
}
+int doinflate(unsigned char * source, unsigned char * dest, int Len, int destlen, int * outLen);
+
VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffer)
{
@@ -2479,6 +2583,7 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
Info = &Buffer->PID;
LINK->bytesRXed += Length;
+ LINK->Received += Length - 1; // Exclude PID
// Adjust for DIGIS
@@ -2495,6 +2600,111 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
switch(PID)
{
+ case 0xf2:
+
+ // Intermediate fragment of compressed. Save
+
+ // Length and Info include pid
+
+ Length--;
+ Info++;
+
+ if (LINK->unCompress == 0)
+ LINK->unCompress = malloc(8192);
+
+ // Save data
+
+ memcpy(&LINK->unCompress[LINK->unCompressLen], Info, Length);
+ LINK->unCompressLen += Length;
+
+ ReleaseBuffer(Buffer);
+
+ LINK->L2ACKREQ = PORT->PORTT2; // SET RR NEEDED
+ LINK->KILLTIMER = 0; // RESET IDLE LINK TIMER
+ return;
+
+
+ case 0xf1:
+
+ // Compressed last or only
+
+ {
+ char exBuffer[8192];
+ int Len;
+ int outLen;
+ int sendLen;
+ char * sendptr = exBuffer;
+
+ Length--;
+ Info++;
+
+ // we may have previous fragments
+
+ if (LINK->unCompressLen)
+ {
+ memcpy(&LINK->unCompress[LINK->unCompressLen], Info, Length);
+ LINK->unCompressLen += Length;
+ Len = doinflate(LINK->unCompress, exBuffer, LINK->unCompressLen, 8192, &outLen);
+ LINK->ReceivedAfterExpansion += outLen - 1;
+
+ LINK->unCompressLen = 0;
+ }
+ else
+ {
+ Len = doinflate(Info, exBuffer, Length, 8192, &outLen);
+ LINK->ReceivedAfterExpansion += outLen - 1;
+ }
+ sendLen = outLen;
+
+ // Send first bit in input buffer. If still some left get new buffers for it
+
+ if (sendLen > 257)
+ sendLen = 257;
+
+ // First byte is original PID
+
+ memcpy(&Msg->PID, exBuffer, sendLen);
+ Msg->LENGTH = sendLen + MSGHDDRLEN;
+
+ C_Q_ADD(&LINK->RX_Q, Msg);
+
+ outLen -= sendLen;
+ sendptr += sendLen;
+
+ while (outLen > 0)
+ {
+ sendLen = outLen;
+
+ if (sendLen > 236)
+ sendLen = 236;
+
+ Msg = GetBuff();
+
+ if (Msg)
+ {
+ // Just ignore if no buffers - shouldn't happen
+
+ Msg->PID = exBuffer[0];
+ Msg->PORT = LINK->LINKPORT->PORTNUMBER;
+
+ memcpy(Msg->L2DATA, sendptr, sendLen);
+ Length = sendLen + 1;
+
+ Msg->LENGTH = Length + MSGHDDRLEN;
+ C_Q_ADD(&LINK->RX_Q, Msg);
+ }
+
+ outLen -= sendLen;
+ sendptr += sendLen;
+ }
+
+ LINK->L2ACKREQ = PORT->PORTT2; // SET RR NEEDED
+ LINK->KILLTIMER = 0; // RESET IDLE LINK TIMER
+
+ return;
+ }
+
+
case 0xcc:
case 0xcd:
@@ -2544,6 +2754,7 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
// Copy Data back over
memmove(&Msg->PID, Info, Length);
+ LINK->ReceivedAfterExpansion += Length - 1;
Buffer->LENGTH = Length + MSGHDDRLEN;
@@ -2611,7 +2822,7 @@ VOID RESETNS(struct _LINKTABLE * LINK, UCHAR NS)
int COUNT_AT_L2(struct _LINKTABLE * LINK)
{
- // COUNTS FRAMES QUEUED ON AN L2 SESSION (IN BX)
+ // COUNTS FRAMES QUEUED ON AN L2 SESSION (IN LINK)
int count = 0, abovelink = 0;
int n = 0;
@@ -2758,7 +2969,7 @@ VOID SDETX(struct _LINKTABLE * LINK)
UCHAR * ptr1, * ptr2;
UCHAR CTL;
int count;
- MESSAGE * Msg;
+ struct DATAMESSAGE * Msg;
MESSAGE * Buffer;
// DONT SEND IF RESEQUENCING RECEIVED FRAMES - CAN CAUSE FRMR PROBLEMS
@@ -2766,11 +2977,6 @@ VOID SDETX(struct _LINKTABLE * LINK)
// if (LINK->L2RESEQ_Q)
// return;
- if (LINK->LINKPORT->PORTNUMBER == 19)
- {
- int i = 0;
- }
-
Outstanding = LINK->LINKNS - LINK->LINKOWS; // Was WS not NS
if (Outstanding < 0)
@@ -2783,13 +2989,150 @@ VOID SDETX(struct _LINKTABLE * LINK)
while (LINK->TX_Q && LINK->FRAMES[LINK->SDTSLOT] == NULL)
{
+ // Try compressing here. Only Compress PID 0xF0 frames - NETROM doesn't treat L2 session as a byte stream
+
Msg = Q_REM(&LINK->TX_Q);
Msg->CHAIN = NULL;
- LINK->FRAMES[LINK->SDTSLOT] = Msg;
- LINK->SDTSLOT ++;
- LINK->SDTSLOT &= 7;
- }
+
+ if (LINK->AllowCompress && Msg->LENGTH > 20 && LINK->TX_Q && Msg->PID == 240) // if short and no more not worth trying compression
+ {
+ int complen = 0;
+ int dataLen;
+ int savePort = Msg->PORT;
+ int savePID = Msg->PID;
+ unsigned char Compressed[8192];
+ unsigned char toCompress[8192];
+ int toCompressLen = 0;
+
+ int slots = 0;
+ int n = LINK->SDTSLOT;
+ int maxcompsize;
+ int PACLEN = LINK->LINKPORT->PORTPACLEN;
+ unsigned char * compdata;
+ int sendLen = complen;
+ int uncompressed = 0;
+
+ if (PACLEN == 0)
+ PACLEN = 256;
+
+ // I think I need to know how many slots are available, so I don't compress too much
+ // Then collect data, compressing after each frame to make sure will fit in available space
+
+ while (LINK->FRAMES[n] == NULL && slots < 8)
+ {
+ slots++;
+ n++;
+ n &= 7;
+ }
+
+ maxcompsize = slots * PACLEN;
+
+ // Save first packet, then see if more on TX_Q
+
+ toCompressLen = 0;
+
+ dataLen = Msg->LENGTH - MSGHDDRLEN;
+
+ LINK->Sent += dataLen;
+
+ memcpy(&toCompress[toCompressLen], &Msg->PID, dataLen);
+ toCompressLen += dataLen;
+
+ complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
+
+ ReleaseBuffer(Msg);
+
+ while (LINK->TX_Q)
+ {
+ Msg = LINK->TX_Q; // Leave on queue until sure it will fit
+ dataLen = Msg->LENGTH - MSGHDDRLEN -1; // PID only on 1st fragment
+
+ memcpy(&toCompress[toCompressLen], &Msg->L2DATA, dataLen);
+ toCompressLen += dataLen;
+
+ // Need to make sure we don't go over maxcompsize
+
+ complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
+
+ if (complen > maxcompsize)
+ {
+ // Remove last fragment and compress again
+
+ toCompressLen -= dataLen;
+ complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
+ break;
+ }
+ else
+ {
+ LINK->Sent += dataLen;
+ Msg = Q_REM(&LINK->TX_Q);
+ Msg->CHAIN = NULL;
+
+ ReleaseBuffer(Msg);
+ }
+ }
+
+ if (complen >= toCompressLen)
+ {
+ // Won't compress, so just send original data
+ // May still need to fragment
+
+ memcpy(Compressed, toCompress, toCompressLen);
+ complen = toCompressLen - 1; // Remove leading PID
+ uncompressed = 1;
+ compdata = &Compressed[1];
+ }
+ else
+ compdata = Compressed;
+
+ // We now need to packetize and add to FRAMES
+
+ LINK->SentAfterCompression += complen;
+
+ sendLen = PACLEN;
+ while (complen > 0)
+ {
+ int PID = 0xF1;
+
+ if (complen > sendLen)
+ PID = 0xF2; // More to come
+ else
+ sendLen = complen;
+
+ if (uncompressed)
+ PID = Compressed[0];
+
+ Msg = GetBuff();
+
+ if (!Msg)
+ return;
+
+ Msg->PORT = savePort;
+ Msg->PID = PID;
+
+ memcpy(&Msg->L2DATA, compdata, sendLen);
+ Msg->LENGTH = sendLen + MSGHDDRLEN + 1;
+
+ LINK->FRAMES[LINK->SDTSLOT] = Msg;
+ LINK->SDTSLOT ++;
+ LINK->SDTSLOT &= 7;
+
+ compdata += sendLen;
+ complen -= sendLen;
+ }
+
+ toCompressLen = 0;
+
+ }
+ else
+ {
+ LINK->FRAMES[LINK->SDTSLOT] = Msg;
+ LINK->SDTSLOT ++;
+ LINK->SDTSLOT &= 7;
+ }
+ }
+
// dont send while poll outstanding
while ((LINK->L2FLAGS & POLLSENT) == 0)
@@ -2901,7 +3244,7 @@ VOID L2TimerProc()
if (PORT == NULL)
{
LINK++;
- continue; // just ion case!!
+ continue; // just in case!!
}
if (LINK->L2TIMER)
@@ -3000,13 +3343,25 @@ VOID L2TimerProc()
{
// CIRCUIT HAS BEEN IDLE TOO LONG - SHUT IT DOWN
- LINK->KILLTIMER = 0;
- LINK->L2TIMER = 1; // TO FORCE DISC
- LINK->L2STATE = 4; // DISCONNECTING
+ // if in XID received state session was never established so don't send DISC
+
+ if (LINK->L2STATE == 1)
+ {
+ if (PORT->TNC && PORT->TNC->Hardware == H_KISSHF)
+ DetachKISSHF(PORT);
+
+ CLEAROUTLINK(LINK);
+ }
+ else
+ {
+ LINK->KILLTIMER = 0;
+ LINK->L2TIMER = 1; // TO FORCE DISC
+ LINK->L2STATE = 4; // DISCONNECTING
- // TELL OTHER LEVELS
+ // TELL OTHER LEVELS
- InformPartner(LINK, NORMALCLOSE);
+ InformPartner(LINK, NORMALCLOSE);
+ }
}
LINK++;
}
@@ -3311,6 +3666,9 @@ VOID CLEAROUTLINK(struct _LINKTABLE * LINK)
CLEARL2QUEUES(LINK); // TO RELEASE ANY BUFFERS
+ if (LINK->unCompress)
+ free(LINK->unCompress);
+
memset(LINK, 0, sizeof(struct _LINKTABLE));
}
@@ -3345,7 +3703,11 @@ VOID L2SENDXID(struct _LINKTABLE * LINK)
*ptr++ = 0x82; // FI
*ptr++ = 0x80; // GI
*ptr++ = 0x0;
- *ptr++ = 0x10; // Length 16
+
+ if (L2Compress)
+ *ptr++ = 0x12; // Length 18
+ else
+ *ptr++ = 0x10; // Length 16
*ptr++ = 0x02; // Classes of Procedures
*ptr++ = 0x02; // Length
@@ -3375,6 +3737,14 @@ VOID L2SENDXID(struct _LINKTABLE * LINK)
*ptr++ = 0x01; // Len
*ptr++ = 0x07; // 7
+ // if L2Compress Enabled request it
+
+ if (L2Compress)
+ {
+ *ptr++ = 0x10; // Compress
+ *ptr++ = 0x00; // Len
+ }
+
Buffer->LENGTH = (int)(ptr - (UCHAR *)Buffer); // SET LENGTH
LINK->L2TIMER = ONEMINUTE; // (RE)SET TIMER
@@ -3578,7 +3948,6 @@ CheckNSLoop2:
struct PORTCONTROL * PORT = LINK->LINKPORT;
MESSAGE * OldBuffer = Q_REM(&LINK->RXFRAMES[LINK->LINKNR]);
- Debugprintf("L2 about to send REJ - process saved Frame %d", LINK->LINKNR);
PROC_I_FRAME(LINK, PORT, OldBuffer); // Passes on or releases Buffer
// NR has been updated.
@@ -3636,7 +4005,9 @@ VOID CONNECTREFUSED(struct _LINKTABLE * LINK)
ConnectFailedOrRefused(LINK, "Busy from");
}
-VOID L3CONNECTFAILED(struct _LINKTABLE * LINK);
+
+VOID L3LINKSETUPFAILED(struct _LINKTABLE * LINK);
+
VOID ConnectFailedOrRefused(struct _LINKTABLE * LINK, char * Msg)
{
@@ -3651,7 +4022,7 @@ VOID ConnectFailedOrRefused(struct _LINKTABLE * LINK, char * Msg)
if (LINK->LINKTYPE == 3)
{
- L3CONNECTFAILED(LINK); // REPORT TO LEVEL 3
+ L3LINKSETUPFAILED(LINK); // REPORT TO LEVEL 3
return;
}
@@ -4178,6 +4549,33 @@ int seeifUnlockneeded(struct _LINKTABLE * LINK)
return 0;
}
+int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len)
+{
+ z_stream defstream;
+ int maxSize;
+
+ defstream.zalloc = Z_NULL;
+ defstream.zfree = Z_NULL;
+ defstream.opaque = Z_NULL;
+
+ defstream.avail_in = Len; // size of input
+ defstream.next_in = (Bytef *)In; // input char array
+
+ deflateInit(&defstream, Z_BEST_COMPRESSION);
+ maxSize = deflateBound(&defstream, Len);
+
+ if (maxSize > OutSize)
+ return 0;
+
+ defstream.avail_out = maxSize; // size of output
+ defstream.next_out = (Bytef *)Out; // output char array
+
+ deflate(&defstream, Z_FINISH);
+ deflateEnd(&defstream);
+
+ return defstream.total_out;
+}
+
diff --git a/L3Code.c b/L3Code.c
index b4f3d65..48f71bc 100644
--- a/L3Code.c
+++ b/L3Code.c
@@ -67,6 +67,8 @@ extern dest_list * CURRENTNODE;
int L3_10SECS = 10;
+extern int PREFERINP3ROUTES;
+
VOID L3BG()
{
@@ -135,12 +137,14 @@ VOID L3BG()
// Drop through to Activate
}
+ // No Active Route
+
if (ACTIVATE_DEST(DEST) == FALSE)
{
// Node has no routes - get rid of it
REMOVENODE(DEST);
- return; // Avoid riskof looking at lod entries
+ return; // Avoid risk of looking at old entries
}
}
}
@@ -154,22 +158,32 @@ BOOL ACTIVATE_DEST(struct DEST_LIST * DEST)
{
int n = MAXDESTS;
struct PORTCONTROL * PORT = PORTTABLE;
- struct ROUTE * ROUTE;
+ struct ROUTE * ROUTE = NULL;
struct _LINKTABLE * LINK;
struct TNCINFO * TNC;
int ActiveRoute;
- if (DEST->DEST_ROUTE == 0) // ALREADY HAVE A SELECTED ROUTE?
- DEST->DEST_ROUTE = 1; // TRY TO ACTIVATE FIRST
+ if (DEST->DEST_ROUTE == 0) // Don't ALREADY HAVE A SELECTED ROUTE?
+ {
+ DEST->DEST_ROUTE = 1;
+ if (PREFERINP3ROUTES)
+ {
+ // if we have any INP3 routes use the first. It will always be the fastest. The others are there for fallback if the first fails.
+
+ if (ROUTE = DEST->INP3ROUTE[0].ROUT_NEIGHBOUR)
+ DEST->DEST_ROUTE = 4; // TRY TO ACTIVATE FIRST
+ }
+ }
+
ActiveRoute = DEST->DEST_ROUTE - 1;
ROUTE = DEST->NRROUTE[ActiveRoute].ROUT_NEIGHBOUR;
if (ROUTE == 0)
{
- // Currnet Route not present
+ // Current Route not present
// If current route is 1, then we must have INP3 routes (or entry is corrupt)
if (DEST->DEST_ROUTE != 1)
@@ -177,13 +191,17 @@ BOOL ACTIVATE_DEST(struct DEST_LIST * DEST)
// Current Route is 1
- if (DEST->ROUTE[0].ROUT_NEIGHBOUR == 0)
+ if (DEST->INP3ROUTE[0].ROUT_NEIGHBOUR == 0)
return FALSE; // No INP3 so No Routes
DEST->DEST_ROUTE = 4; // First INP3
- ROUTE = DEST->ROUTE[0].ROUT_NEIGHBOUR;
+ ROUTE = DEST->INP3ROUTE[0].ROUT_NEIGHBOUR;
}
+ if (ROUTE == 0) // Shouldn't happen
+ return FALSE;
+
+
// if NetROM over VARA conection is made by the driver
TNC = TNCInfo[ROUTE->NEIGHBOUR_PORT];
@@ -204,7 +222,7 @@ BOOL ACTIVATE_DEST(struct DEST_LIST * DEST)
return L2SETUPCROSSLINK(ROUTE);
}
- // We mst be waiting for link to come up
+ // We umst be waiting for link to come up
return TRUE;
@@ -707,11 +725,11 @@ int COUNTNODES(struct ROUTE * ROUTE)
count++;
else if (DEST->NRROUTE[2].ROUT_NEIGHBOUR == ROUTE)
count++;
- else if (DEST->ROUTE[0].ROUT_NEIGHBOUR == ROUTE)
+ else if (DEST->INP3ROUTE[0].ROUT_NEIGHBOUR == ROUTE)
count++;
- else if (DEST->ROUTE[1].ROUT_NEIGHBOUR == ROUTE)
+ else if (DEST->INP3ROUTE[1].ROUT_NEIGHBOUR == ROUTE)
count++;
- else if (DEST->ROUTE[2].ROUT_NEIGHBOUR == ROUTE)
+ else if (DEST->INP3ROUTE[2].ROUT_NEIGHBOUR == ROUTE)
count++;
DEST++;
@@ -845,7 +863,7 @@ VOID SENDNEXTNODESFRAGMENT()
if (DEST->DEST_CALL[0] != 0x40 && DEST->NRROUTE[0].ROUT_QUALITY >= TXMINQUAL &&
DEST->NRROUTE[0].ROUT_OBSCOUNT >= OBSMIN &&
- (NODE == 1 || DEST->DEST_STATE & 0x80)) // Only send appl nodes if DEST = 0;
+ (NODE == 1 || DEST->DEST_STATE & 0x80)) // Only send appl nodes if NODE = 0;
{
// Send it
@@ -878,6 +896,9 @@ VOID SENDNEXTNODESFRAGMENT()
*(ptr1++) = (UCHAR)Qual;
+ if (Qual == 0)
+ continue;
+
Count--;
}
DEST++;
@@ -924,7 +945,7 @@ VOID L3LINKCLOSED(struct _LINKTABLE * LINK, int Reason)
VOID CLEARACTIVEROUTE(struct ROUTE * ROUTE, int Reason)
{
- // FIND ANY DESINATIONS WITH [ESI] AS ACTIVE NEIGHBOUR, AND
+ // FIND ANY DESINATIONS WITH ROUTE AS ACTIVE NEIGHBOUR, AND
// SET INACTIVE
dest_list * DEST;
@@ -945,7 +966,7 @@ VOID CLEARACTIVEROUTE(struct ROUTE * ROUTE, int Reason)
if (DEST->DEST_ROUTE == 0)
continue;
- if (DEST->ROUTE[DEST->DEST_ROUTE].ROUT_NEIGHBOUR == ROUTE) // Is this the active route
+ if (DEST->INP3ROUTE[DEST->DEST_ROUTE].ROUT_NEIGHBOUR == ROUTE) // Is this the active route
{
// Yes, so clear
@@ -1120,7 +1141,7 @@ UPDEST000:
{
// Any INP3 Routes?
- if (DEST->ROUTE[0].ROUT_NEIGHBOUR == 0)
+ if (DEST->INP3ROUTE[0].ROUT_NEIGHBOUR == 0)
{
// NO ROUTES LEFT TO DEST - REMOVE IT
@@ -1292,19 +1313,25 @@ VOID REMOVENODE(dest_list * DEST)
NUMBEROFNODES--;
}
-VOID L3CONNECTFAILED(struct _LINKTABLE * LINK)
+VOID L3LINKSETUPFAILED(struct _LINKTABLE * LINK)
{
// L2 LINK SETUP HAS FAILED - SEE IF ANOTHER NEIGHBOUR CAN BE USED
struct PORTCONTROL * PORT = PORTTABLE;
struct ROUTE * ROUTE;
-
ROUTE = LINK->NEIGHBOUR; // TO NEIGHBOUR
if (ROUTE == NULL)
return; // NOTHING ???
-
+
+ if (ROUTE->INP3Node)
+ {
+ char Normcall[10];
+ Normcall[ConvFromAX25(ROUTE->NEIGHBOUR_CALL, Normcall)] = 0;
+ Debugprintf("INP3 Route to %s connect failed", Normcall);
+ }
+
TellINP3LinkSetupFailed(ROUTE);
ROUTE->NEIGHBOUR_LINK = 0; // CLEAR IT
@@ -1313,9 +1340,10 @@ VOID L3CONNECTFAILED(struct _LINKTABLE * LINK)
}
+
VOID L3TRYNEXTDEST(struct ROUTE * ROUTE)
{
- // FIND ANY DESINATIONS WITH [ESI] AS ACTIVE NEIGHBOUR, AND
+ // FIND ANY DESINATIONS WITH ROUTE AS ACTIVE NEIGHBOUR, AND
// SET NEXT BEST NEIGHBOUR (IF ANY) ACTIVE
int n = MAXDESTS;
@@ -1328,7 +1356,7 @@ VOID L3TRYNEXTDEST(struct ROUTE * ROUTE)
if (ActiveRoute)
{
- ActiveRoute --; // Routes numbered 1 - 6, idex from 0
+ ActiveRoute --; // Routes numbered 1 - 6, index from 0
if (DEST->NRROUTE[ActiveRoute].ROUT_NEIGHBOUR == ROUTE)
{
diff --git a/L4Code.c b/L4Code.c
index 1c92cb4..703168a 100644
--- a/L4Code.c
+++ b/L4Code.c
@@ -67,18 +67,23 @@ VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len
VOID FRAMEFORUS(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG, int ApplMask, UCHAR * ApplCall);
void WriteConnectLog(char * fromCall, char * toCall, UCHAR * Mode);
void SendVARANetromMsg(struct TNCINFO * TNC, PL3MESSAGEBUFFER MSG);
-unsigned char * Compressit(unsigned char * In, int Len, int * OutLen);
int doinflate(unsigned char * source, unsigned char * dest, int Len, int destlen, int * outLen);
-
+int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len);
static UINT APPLMASK;
extern BOOL LogL4Connects;
extern BOOL LogAllConnects;
+
extern int L4Compress;
extern int L4CompMaxframe;
extern int L4CompPaclen;
+
+extern int L2Compress;
+extern int L2CompMaxframe;
+extern int L2CompPaclen;
+
// L4 Flags Values
#define DISCPENDING 8 // SEND DISC WHEN ALL DATA ACK'ED
@@ -299,6 +304,7 @@ VOID SENDL4MESSAGE(TRANSPORTENTRY * L4, struct DATAMESSAGE * Msg)
return;
}
+
L3MSG = GetBuff();
if (L3MSG == 0)
@@ -567,6 +573,55 @@ void sendChunk(TRANSPORTENTRY * L4, unsigned char * Compressed, int complen, int
}
}
+void sendL2Chunk(struct _LINKTABLE * LINK, unsigned char * Compressed, int complen, int sendPacLen)
+{
+ unsigned char * compdata;
+ struct DATAMESSAGE * Msg;
+ int sendLen = complen;
+ int fragments;
+
+ LINK->SentAfterCompression += complen;
+
+ if (complen > L2CompPaclen)
+ {
+ fragments = (complen / sendPacLen); // Split to roughly equal sized fraagments
+
+ if (fragments * sendPacLen != complen)
+ fragments++;
+
+ sendLen = (complen / fragments) + 1;
+ }
+
+ Debugprintf("L2 Chunk %d Bytes %d PACLEN %d Fragments %d FragSize", complen, sendPacLen, fragments, sendLen);
+
+ compdata = Compressed;
+
+ while (complen > 0)
+ {
+ int PID = 0xF1;
+
+ if (complen > sendLen)
+ PID = 0xF2; // More to come
+
+ Msg = GetBuff();
+
+ if (!Msg)
+ return;
+
+ Msg->PORT = LINK->LINKPORT->PORTNUMBER;
+
+ memcpy(Msg->L2DATA, compdata, sendLen);
+ Msg->LENGTH = sendLen + MSGHDDRLEN + 1; // 1 for pid field
+ Msg->PID = PID; // Not sent so use as a flag for compressed msg
+
+ compdata += sendLen;
+ complen -= sendLen;
+
+ C_Q_ADD(&LINK->TX_Q, Msg);
+ }
+}
+
+
VOID L4BG()
{
// PROCESS DATA QUEUED ON SESSIONS
@@ -628,7 +683,7 @@ VOID L4BG()
LINK = L4->L4TARGET.LINK;
- if (COUNT_AT_L2(LINK) > 8)
+ if (COUNT_AT_L2(LINK) > 64)
break;
}
@@ -666,36 +721,32 @@ VOID L4BG()
if (L4->AllowCompress)
{
int complen = 0;
- unsigned char * Compressed;
+ unsigned char Compressed[8192];
+ unsigned char toCompress[8192];
+ int toCompressLen = 0;
int dataLen;
int savePort = Msg->PORT;
int maxCompSendLen;
// Save first packet, then see if more on TX_Q
- L4->toCompress = malloc(8192);
- L4->toCompressLen = 0;
-
dataLen = Msg->LENGTH - MSGHDDRLEN - 1; // No header or pid
L4->Sent += dataLen;
- memcpy(&L4->toCompress[L4->toCompressLen], Msg->L2DATA, dataLen);
- L4->toCompressLen += dataLen;
+ memcpy(&toCompress[toCompressLen], Msg->L2DATA, dataLen);
+ toCompressLen += dataLen;
// See if first will compress. If not assume too short or already compressed data and just send
- Compressed = Compressit(L4->toCompress, L4->toCompressLen, &complen);
+ complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
if (complen >= dataLen)
{
- free(Compressed);
L4->SentAfterCompression += dataLen;
SENDL4MESSAGE(L4, Msg);
ReleaseBuffer(Msg);
- free(L4->toCompress);
- L4->toCompress = 0;
- L4->toCompressLen = 0;
+ toCompressLen = 0;
continue;
}
@@ -705,7 +756,7 @@ VOID L4BG()
{
// no more, so just send the stuff we've just compressed. Compressed data will fit in input packet
-// Debugprintf("%d %d %d%%", L4->toCompressLen, complen, ((L4->toCompressLen - complen) * 100) / L4->toCompressLen);
+// Debugprintf("%d %d %d%%", toCompressLen, complen, ((toCompressLen - complen) * 100) / toCompressLen);
memcpy(Msg->L2DATA, Compressed, complen);
@@ -716,17 +767,13 @@ VOID L4BG()
SENDL4MESSAGE(L4, Msg);
ReleaseBuffer(Msg);
- free(L4->toCompress);
- L4->toCompressLen = 0;
- L4->toCompress = 0;
- free(Compressed);
+ toCompressLen = 0;
continue;
}
- free(Compressed);
ReleaseBuffer(Msg); // Not going to use it
- while (L4->L4TX_Q && L4->toCompressLen < (8192 - 256)) // Make sure can't overrin buffer
+ while (L4->L4TX_Q && toCompressLen < (8192 - 256)) // Make sure can't overrin buffer
{
// Collect the data from L4TX_Q
@@ -734,23 +781,22 @@ VOID L4BG()
dataLen = Msg->LENGTH - MSGHDDRLEN - 1; // No header or pid
L4->Sent += dataLen;
- memcpy(&L4->toCompress[L4->toCompressLen], Msg->L2DATA, dataLen);
- L4->toCompressLen += dataLen;
+ memcpy(&toCompress[toCompressLen], Msg->L2DATA, dataLen);
+ toCompressLen += dataLen;
ReleaseBuffer(Msg);
}
- L4->toCompress[L4->toCompressLen] = 0;
+ toCompress[toCompressLen] = 0;
- Compressed = Compressit(L4->toCompress, L4->toCompressLen, &complen);
-// Debugprintf("%d %d %d%%", L4->toCompressLen, complen, ((L4->toCompressLen - complen) * 100) / L4->toCompressLen);
+ complen = L2Compressit(Compressed, 8192, toCompress, toCompressLen);
+
+ Debugprintf("%d %d %d%%", toCompressLen, complen, ((toCompressLen - complen) * 100) / toCompressLen);
// Send compressed
// Fragment if more than L4CompPaclen
- // Entered with original first fragment in saveMsg;
-
// Check for too big a compressed frame size. Bigger compresses better but adds latency to link
maxCompSendLen = L4CompPaclen * L4CompMaxframe;
@@ -762,8 +808,8 @@ VOID L4BG()
int Fragments;
int ChunkSize;
- unsigned char * CompressPtr = L4->toCompress;
- int bytesleft = L4->toCompressLen;
+ unsigned char * CompressPtr = toCompress;
+ int bytesleft = toCompressLen;
// Assume 10% worse compression on smaller input
@@ -771,7 +817,7 @@ VOID L4BG()
Fragments = j / maxCompSendLen;
Fragments++;
- ChunkSize = (L4->toCompressLen / Fragments) + 1; // 1 for rounding
+ ChunkSize = (toCompressLen / Fragments) + 1; // 1 for rounding
while (bytesleft > 0)
{
@@ -779,9 +825,9 @@ VOID L4BG()
if (Len > ChunkSize)
Len = ChunkSize;
- free (Compressed);
- Compressed = Compressit(CompressPtr, Len, &complen);
-// Debugprintf("Chunked %d %d %d%%", Len, complen, ((Len - complen) * 100) / Len);
+ complen = L2Compressit(Compressed, 8192, toCompress, Len);
+
+ Debugprintf("Chunked %d %d %d%%", Len, complen, ((Len - complen) * 100) / Len);
sendChunk(L4, Compressed, complen, savePort);
@@ -793,10 +839,7 @@ VOID L4BG()
else
sendChunk(L4, Compressed, complen,savePort);
- free(L4->toCompress);
- L4->toCompressLen = 0;
- L4->toCompress = 0;
- free(Compressed);
+ toCompressLen = 0;
}
else
{
@@ -808,6 +851,8 @@ VOID L4BG()
continue;
}
+ // L2 Link
+
LINK = L4->L4TARGET.LINK;
// If we want to enforce PACLEN this may be a good place to do it
@@ -936,9 +981,6 @@ VOID CLEARSESSIONENTRY(TRANSPORTENTRY * Session)
if (Session->PARTCMDBUFFER)
ReleaseBuffer(Session->PARTCMDBUFFER);
- if (Session->toCompress)
- free(Session->toCompress);
-
if (Session->unCompress)
free(Session->unCompress);
diff --git a/LinBPQ.c b/LinBPQ.c
index 295afd8..689b5f4 100644
--- a/LinBPQ.c
+++ b/LinBPQ.c
@@ -381,41 +381,48 @@ BOOL CtrlHandler(DWORD fdwCtrlType)
#include <signal.h>
// Linux Signal Handlers
-
static void segvhandler(int sig)
{
- void *array[10];
- size_t size;
- char msg[] = "SIGSEGV Received\n";
+ void *array[10];
+ size_t size;
+ char msg[] = "\nSIGSEGV Received\n";
+
+ write(STDERR_FILENO, msg, strlen(msg));
- write(STDERR_FILENO, msg, strlen(msg));
+ // get void*'s for all entries on the stack
+ size = backtrace(array, 10);
- // get void*'s for all entries on the stack
- size = backtrace(array, 10);
+ // print out all the frames to stderr
- // print out all the frames to stderr
+ backtrace_symbols_fd(array, size, STDERR_FILENO);
- backtrace_symbols_fd(array, size, STDERR_FILENO);
+ write(STDOUT_FILENO, msg, strlen(msg));
+ backtrace_symbols_fd(array, size, STDOUT_FILENO);
- exit(1);
+ exit(1);
}
static void abrthandler(int sig)
{
- void *array[10];
- size_t size;
- char msg[] = "SIGABRT Received\n";
+ void *array[10];
+ size_t size;
+ char msg[] = "\nSIGABRT Received\n";
+
+ write(STDERR_FILENO, msg, strlen(msg));
+ write(STDOUT_FILENO, msg, strlen(msg));
- write(STDERR_FILENO, msg, strlen(msg));
+ // get void*'s for all entries on the stack
- // get void*'s for all entries on the stack
+ size = backtrace(array, 10);
+ backtrace_symbols_fd(array, size, STDERR_FILENO);
- size = backtrace(array, 10);
- backtrace_symbols_fd(array, size, STDERR_FILENO);
+ write(STDOUT_FILENO, msg, strlen(msg));
+ backtrace_symbols_fd(array, size, STDOUT_FILENO);
- exit(1);
+ exit(1);
}
+
static void sigterm_handler(int sig)
{
syslog(LOG_INFO, "terminating on SIGTERM\n");
@@ -787,6 +794,8 @@ int Redirected = 0;
static void segvhandler(int sig);
static void abrthandler(int sig);
+void GetRestartData();
+
int main(int argc, char * argv[])
{
@@ -845,6 +854,8 @@ int main(int argc, char * argv[])
printf("G8BPQ AX25 Packet Switch System Version %s %s\n", TextVerstring, Datestring);
printf("%s\n", VerCopyright);
+ srand(time(NULL));
+
// look for optarg format parameters
@@ -902,7 +913,10 @@ int main(int argc, char * argv[])
Debugprintf("G8BPQ AX25 Packet Switch System Version %s %s", TextVerstring, Datestring);
-#ifndef MACBPQ
+#if defined(MACBPQ) || defined(FREEBSD)
+ time_t dummy;
+ _MYTIMEZONE = -localtime(&dummy)->tm_gmtoff;
+#else
_MYTIMEZONE = _timezone;
#endif
@@ -1174,6 +1188,8 @@ int main(int argc, char * argv[])
chmod(MailDir, S_IRWXU | S_IRWXG | S_IRWXO);
#endif
+
+
// Make backup copies of Databases
// CopyConfigFile(ConfigName);
@@ -1195,6 +1211,7 @@ int main(int argc, char * argv[])
GetBadWordFile();
GetHTMLForms();
GetPGConfig();
+ GetRestartData();
// Make sure there is a user record for the BBS, with BBS bit set.
@@ -1442,6 +1459,7 @@ int main(int argc, char * argv[])
SaveMessageDatabase();
SaveBIDDatabase();
SaveConfig(ConfigName);
+ SaveRestartData();
}
KEEPGOING--; // Give time for links to close
diff --git a/MHSave.txt b/MHSave.txt
deleted file mode 100644
index e69de29..0000000
--- a/MHSave.txt
+++ /dev/null
diff --git a/MULTIPSK64.c b/MULTIPSK64.c
new file mode 100644
index 0000000..8fe6a84
--- /dev/null
+++ b/MULTIPSK64.c
@@ -0,0 +1,1543 @@
+/*
+Copyright 2001-2018 John Wiseman G8BPQ
+
+This file is part of LinBPQ/BPQ32.
+
+LinBPQ/BPQ32 is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+LinBPQ/BPQ32 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
+*/
+
+//
+// DLL to provide interface to allow G8BPQ switch to use MultoPSK ALE400 Mode
+//
+// Uses BPQ EXTERNAL interface
+//
+
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "CHeaders.h"
+#include <stdio.h>
+#include <time.h>
+
+#include "tncinfo.h"
+
+#include "bpq32.h"
+
+#define VERSION_MAJOR 2
+#define VERSION_MINOR 0
+
+#define SD_RECEIVE 0x00
+#define SD_SEND 0x01
+#define SD_BOTH 0x02
+
+#define TIMESTAMP 352
+
+#define CONTIMEOUT 1200
+
+
+
+#define AGWHDDRLEN sizeof(struct AGWHEADER)
+
+extern int (WINAPI FAR *GetModuleFileNameExPtr)();
+
+//int ResetExtDriver(int num);
+extern char * PortConfig[33];
+
+struct TNCINFO * TNCInfo[34]; // Records are Malloc'd
+
+static void ConnecttoMPSKThread(void * portptr);
+
+void CreateMHWindow();
+int Update_MH_List(struct in_addr ipad, char * call, char proto);
+
+static int ConnecttoMPSK();
+static int ProcessReceivedData(int bpqport);
+static int ProcessLine(char * buf, int Port);
+int KillTNC(struct TNCINFO * TNC);
+int RestartTNC(struct TNCINFO * TNC);
+VOID ProcessMPSKPacket(struct TNCINFO * TNC, char * Message, int Len);
+struct TNCINFO * GetSessionKey(char * key, struct TNCINFO * TNC);
+static VOID SendData(struct TNCINFO * TNC, char * Msg, int MsgLen);
+static VOID DoMonitorHddr(struct TNCINFO * TNC, struct AGWHEADER * RXHeader, UCHAR * Msg);
+VOID SendRPBeacon(struct TNCINFO * TNC);
+
+char * strlop(char * buf, char delim);
+
+extern UCHAR BPQDirectory[];
+
+#define MAXBPQPORTS 32
+#define MAXMPSKPORTS 16
+
+//LOGFONT LFTTYFONT ;
+
+//HFONT hFont ;
+
+static int MPSKChannel[MAXBPQPORTS+1]; // BPQ Port to MPSK Port
+static int BPQPort[MAXMPSKPORTS][MAXBPQPORTS+1]; // MPSK Port and Connection to BPQ Port
+
+static int MasterPort[MAXBPQPORTS+1]; // Pointer to first BPQ port for a specific MPSK host
+
+// Each port may be on a different machine. We only open one connection to each MPSK instance
+
+static char * MPSKSignon[MAXBPQPORTS+1]; // Pointer to message for secure signin
+
+static unsigned int MPSKInst = 0;
+static int AttachedProcesses=0;
+
+static HWND hResWnd,hMHWnd;
+static BOOL GotMsg;
+
+static HANDLE STDOUT=0;
+
+//SOCKET sock;
+
+static SOCKADDR_IN sinx;
+static SOCKADDR_IN rxaddr;
+static SOCKADDR_IN destaddr[MAXBPQPORTS+1];
+
+static int addrlen=sizeof(sinx);
+
+//static short MPSKPort=0;
+
+static time_t ltime,lasttime[MAXBPQPORTS+1];
+
+static BOOL CONNECTING[MAXBPQPORTS+1];
+static BOOL CONNECTED[MAXBPQPORTS+1];
+
+//HANDLE hInstance;
+
+
+static fd_set readfs;
+static fd_set writefs;
+static fd_set errorfs;
+static struct timeval timeout;
+
+#ifndef LINBPQ
+
+static BOOL CALLBACK EnumTNCWindowsProc(HWND hwnd, LPARAM lParam)
+{
+ char wtext[200];
+ struct TNCINFO * TNC = (struct TNCINFO *)lParam;
+ UINT ProcessId;
+ char FN[MAX_PATH] = "";
+
+ if (TNC->ProgramPath == NULL)
+ return FALSE;
+
+ GetWindowText(hwnd, wtext, 199);
+
+ if (strstr(wtext,"* MULTIPSK"))
+ {
+ GetWindowThreadProcessId(hwnd, &ProcessId);
+
+ TNC->PID = ProcessId;
+ return FALSE;
+ }
+
+ return (TRUE);
+}
+
+#endif
+
+static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
+{
+ PMSGWITHLEN buffptr;
+
+ unsigned int txlen=0;
+ struct TNCINFO * TNC = TNCInfo[port];
+ int Stream = 0;
+ struct STREAMINFO * STREAM;
+ int TNCOK;
+
+ if (TNC == NULL)
+ return 0; // Port not defined
+
+ // Look for attach on any call
+
+ for (Stream = 0; Stream <= TNC->MPSKInfo->MaxSessions; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && TNC->Streams[Stream].Attached == 0)
+ {
+ char Cmd[80];
+ int len;
+
+ // New Attach
+
+ int calllen;
+ STREAM->Attached = TRUE;
+
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, STREAM->MyCall);
+ STREAM->MyCall[calllen] = 0;
+ STREAM->FramesOutstanding = 0;
+
+ // Stop Scanning
+
+ sprintf(Cmd, "%d SCANSTOP", TNC->Port);
+ Rig_Command(-1, Cmd);
+
+ len = sprintf(Cmd, "%cSTOP_BEACON_ARQ_FAE\x1b", '\x1a');
+
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Cmd); // Savde till not transmitting
+ else
+ send(TNC->TCPSock, Cmd, len, 0);
+
+ }
+ }
+
+ switch (fn)
+ {
+ case 1: // poll
+
+ if (MasterPort[port] == port)
+ {
+ // Only on first port using a host
+
+ if (TNC->CONNECTED == FALSE && TNC->CONNECTING == FALSE)
+ {
+ // See if time to reconnect
+
+ time( &ltime );
+ if (ltime-lasttime[port] >9 )
+ {
+ ConnecttoMPSK(port);
+ 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
+
+ if (TNC->BPQtoWINMOR_Q) FD_SET(TNC->TCPSock,&writefs); // Need notification of busy clearing
+
+
+
+ FD_ZERO(&errorfs);
+
+ if (TNC->CONNECTING ||TNC->CONNECTED) FD_SET(TNC->TCPSock,&errorfs);
+
+ if (select((int)TNC->TCPSock+ 1, &readfs, &writefs, &errorfs, &timeout) > 0)
+ {
+ // See what happened
+
+ if (FD_ISSET(TNC->TCPSock,&readfs))
+ {
+ // data available
+
+ ProcessReceivedData(port);
+ }
+
+ if (FD_ISSET(TNC->TCPSock,&writefs))
+ {
+ // Connect success
+
+ TNC->CONNECTED = TRUE;
+ 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);
+ }
+
+ 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);
+// }
+
+ 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->Connecting)
+ {
+ STREAM->Connecting--;
+
+ if (STREAM->Connecting == 0)
+ {
+ // Report Connect Failed, and drop back to command mode
+
+ buffptr = GetBuff();
+
+ if (buffptr)
+ {
+ 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;
+
+ // Send Disc to TNC
+
+ TidyClose(TNC, Stream);
+ }
+ }
+
+ if (STREAM->Attached)
+ CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+
+ if (STREAM->ReportDISC)
+ {
+ STREAM->ReportDISC = FALSE;
+ buff->PORT = Stream;
+
+ 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
+ {
+ int datalen;
+
+ buffptr=Q_REM(&STREAM->PACTORtoBPQ_Q);
+
+ datalen = buffptr->Len;
+
+ buff->PORT = Stream;
+ buff->PID = 0xf0;
+ memcpy(buff->L2DATA, buffptr->Data, datalen); // Data goes to +7, but we have an extra byte
+ datalen += MSGHDDRLEN + 1;
+
+ PutLengthinBuffer((PDATAMESSAGE)buff, datalen);
+
+ ReleaseBuffer(buffptr);
+
+ return (1);
+ }
+ }
+
+ if (TNC->PortRecord->UI_Q)
+ {
+ struct _MESSAGE * buffptr;
+
+ SOCKET Sock;
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+
+ Sock = TNCInfo[MasterPort[port]]->TCPSock;
+
+ ReleaseBuffer((UINT *)buffptr);
+ }
+
+
+ return (0);
+
+
+
+ case 2: // send
+
+
+ if (!TNCInfo[MasterPort[port]]->CONNECTED) return 0; // Don't try if not connected to TNC
+
+ Stream = buff->PORT;
+
+ STREAM = &TNC->Streams[Stream];
+
+// txlen=(buff[6]<<8) + buff[5] - 8;
+
+ txlen = GetLengthfromBuffer((PDATAMESSAGE)buff) - 8;
+
+ if (STREAM->Connected)
+ {
+ SendData(TNC, buff->L2DATA, txlen);
+ }
+ else
+ {
+ char Command[80];
+ int len;
+
+ buff->L2DATA[txlen] = 0;
+ _strupr(buff->L2DATA);
+
+ if (_memicmp(&buff[8], "D\r", 2) == 0)
+ {
+ TidyClose(TNC, buff->PORT);
+ STREAM->ReportDISC = TRUE; // Tell Node
+ return 0;
+ }
+
+ // See if Local command (eg RADIO)
+
+ if (_memicmp(buff->L2DATA, "RADIO ", 6) == 0)
+ {
+ sprintf(buff->L2DATA, "%d %s", TNC->Port, &buff->L2DATA[6]);
+
+ if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, buff->L2DATA))
+ {
+ }
+ else
+ {
+ buffptr = (PMSGWITHLEN)GetBuff();
+
+ if (buffptr == 0) return 1; // No buffers, so ignore
+
+ buffptr->Len= sprintf((UCHAR *)&buffptr->Data, "%s", buff->L2DATA);
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+ return 1;
+ }
+
+ if (STREAM->Connecting && _memicmp(&buff[8], "ABORT", 5) == 0)
+ {
+ len = sprintf(Command,"%cSTOP_SELECTIVE_CALL_ARQ_FAE\x1b", '\x1a');
+
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Command); // Save till not transmitting
+ else
+ send(TNC->TCPSock, Command, len, 0);
+
+ TNC->InternalCmd = TRUE;
+ return (0);
+ }
+
+ if (_memicmp(&buff[8], "MODE", 4) == 0)
+ {
+ buff->L2DATA[txlen - 1] = 0; // Remove CR
+
+ len = sprintf(Command,"%cDIGITAL MODE %s\x1b", '\x1a', &buff->L2DATA[5]);
+
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Command); // Save till not transmitting
+ else
+ send(TNC->TCPSock, Command, len, 0);
+
+ TNC->InternalCmd = TRUE;
+ return (0);
+ }
+
+
+ if (_memicmp(&buff[8], "INUSE?", 6) == 0)
+ {
+ // Return Error if in use, OK if not
+
+ UINT * buffptr = GetBuff();
+ int s = 0;
+
+ while(s <= TNC->MPSKInfo->MaxSessions)
+ {
+ if (s != Stream)
+ {
+ if (TNC->PortRecord->ATTACHEDSESSIONS[s])
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "MPSK} Error - In use\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ return 1; // Busy
+ }
+ }
+ s++;
+ }
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "MPSK} Ok - Not in use\r");
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ return 1;
+ }
+
+ // See if a Connect Command.
+
+ if (toupper(buff->L2DATA[0]) == 'C' && buff->L2DATA[1] == ' ' && txlen > 2) // Connect
+ {
+ char * ptr;
+ char * context;
+
+ buff->L2DATA[txlen] = 0;
+ _strupr(buff->L2DATA);
+
+ memset(STREAM->RemoteCall, 0, 10);
+
+ ptr = strtok_s(&buff->L2DATA[2], " ,\r", &context);
+ strcpy(STREAM->RemoteCall, ptr);
+
+ len = sprintf(Command,"%cCALLSIGN_TO_CALL_ARQ_FAE %s%c%cSELECTIVE_CALL_ARQ_FAE\x1b",
+ '\x1a', STREAM->RemoteCall, '\x1b', '\x1a');
+
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Command); // Save till not transmitting
+ else
+ send(TNC->TCPSock, Command, len, 0);
+
+ STREAM->Connecting = TNC->MPSKInfo->ConnTimeOut; // It doesn't report failure
+
+// sprintf(Status, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall);
+// SetDlgItemText(TNC->hDlg, IDC_TNCSTATE, Status);
+
+ return 0;
+ }
+
+ // Send any other command to Multipsk
+
+ buff->L2DATA[txlen - 1] = 0;
+ _strupr(&buff->L2DATA[0]);
+
+ len = sprintf(Command,"%c%s\x1b", '\x1a', buff->L2DATA);
+
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Command); // Save till not transmitting
+ else
+ send(TNC->TCPSock, Command, len, 0);
+
+ TNC->InternalCmd = TRUE;
+
+ }
+
+ return (0);
+
+ case 3:
+
+ Stream = buff->PORT;
+
+ TNCOK = TNCInfo[MasterPort[port]]->CONNECTED;
+
+ STREAM = &TNC->Streams[Stream];
+
+ if (STREAM->FramesOutstanding > 8)
+ return (1 | TNCOK << 8 | STREAM->Disconnecting << 15);
+
+ return TNCOK << 8 | STREAM->Disconnecting << 15; // OK, but lock attach if disconnecting
+
+ break;
+
+ case 4: // reinit
+
+ shutdown(TNC->TCPSock, SD_BOTH);
+ Sleep(100);
+
+ closesocket(TNC->TCPSock);
+ TNC->CONNECTED = FALSE;
+
+ if (TNC->PID && TNC->WeStartedTNC)
+ {
+ KillTNC(TNC);
+ RestartTNC(TNC);
+ }
+
+ return (0);
+
+ case 5: // Close
+
+ shutdown(TNC->TCPSock, SD_BOTH);
+ Sleep(100);
+
+ closesocket(TNC->TCPSock);
+
+ if (TNC->PID && TNC->WeStartedTNC)
+ {
+ KillTNC(TNC);
+ }
+
+ return 0;
+ }
+
+ return 0;
+}
+
+#ifndef LINBPQ
+
+static KillTNC(struct TNCINFO * TNC)
+{
+ HANDLE hProc;
+
+ if (TNC->PTTMode)
+ Rig_PTT(TNC->RIG, FALSE); // Make sure PTT is down
+
+ if (TNC->PID == 0) return 0;
+
+ hProc = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, TNC->PID);
+
+ if (hProc)
+ {
+ TerminateProcess(hProc, 0);
+ CloseHandle(hProc);
+ }
+
+ TNC->PID = 0; // So we don't try again
+
+ return 0;
+}
+
+static RestartTNC(struct TNCINFO * TNC)
+{
+ STARTUPINFO SInfo; // pointer to STARTUPINFO
+ PROCESS_INFORMATION PInfo; // pointer to PROCESS_INFORMATION
+ char HomeDir[MAX_PATH];
+ int i, ret;
+
+ SInfo.cb=sizeof(SInfo);
+ SInfo.lpReserved=NULL;
+ SInfo.lpDesktop=NULL;
+ SInfo.lpTitle=NULL;
+ SInfo.dwFlags=0;
+ SInfo.cbReserved2=0;
+ SInfo.lpReserved2=NULL;
+
+ if (TNC->ProgramPath)
+ {
+ strcpy(HomeDir, TNC->ProgramPath);
+ i = strlen(HomeDir);
+
+ while(--i)
+ {
+ if (HomeDir[i] == '/' || HomeDir[i] == '\\')
+ {
+ HomeDir[i] = 0;
+ break;
+ }
+ }
+ ret = CreateProcess(TNC->ProgramPath, "MultiPSK TCP_IP_ON", NULL, NULL, FALSE,0 ,NULL ,HomeDir, &SInfo, &PInfo);
+
+ if (ret)
+ TNC->PID = PInfo.dwProcessId;
+
+ return ret;
+ }
+ return 0;
+}
+#endif
+
+UINT MPSKExtInit(EXTPORTDATA * PortEntry)
+{
+ int i, port;
+ char Msg[255];
+ struct TNCINFO * TNC;
+ char * ptr;
+
+ //
+ // Will be called once for each MPSK port to be mapped to a BPQ Port
+ // The MPSK port number is in CHANNEL - A=0, B=1 etc
+ //
+ // The Socket to connect to is in IOBASE
+ //
+
+ port = PortEntry->PORTCONTROL.PORTNUMBER;
+
+ ReadConfigFile(port, ProcessLine);
+
+ TNC = TNCInfo[port];
+
+ if (TNC == NULL)
+ {
+ // Not defined in Config file
+
+ sprintf(Msg," ** Error - no info in BPQ32.cfg for this port\n");
+ WritetoConsole(Msg);
+
+ return ExtProc;
+ }
+
+ TNC->Port = port;
+
+ TNC->PortRecord = PortEntry;
+
+ if (PortEntry->PORTCONTROL.PORTCALL[0] == 0)
+ memcpy(TNC->NodeCall, MYNODECALL, 10);
+ else
+ ConvFromAX25(&PortEntry->PORTCONTROL.PORTCALL[0], TNC->NodeCall);
+
+ TNC->Interlock = PortEntry->PORTCONTROL.PORTINTERLOCK;
+
+ PortEntry->PORTCONTROL.PROTOCOL = 10;
+ PortEntry->PERMITGATEWAY = TRUE; // Can change ax.25 call on each stream
+ PortEntry->PORTCONTROL.PORTQUALITY = 0;
+ PortEntry->SCANCAPABILITIES = NONE; // Scan Control - None
+
+ if (PortEntry->PORTCONTROL.PORTPACLEN == 0)
+ PortEntry->PORTCONTROL.PORTPACLEN = 64;
+
+ ptr=strchr(TNC->NodeCall, ' ');
+ if (ptr) *(ptr) = 0; // Null Terminate
+
+ TNC->Hardware = H_MPSK;
+
+ MPSKChannel[port] = PortEntry->PORTCONTROL.CHANNELNUM-65;
+
+ PortEntry->MAXHOSTMODESESSIONS = 1;
+
+ i=sprintf(Msg,"MPSK Host %s Port %d \n",
+ TNC->HostName, TNC->TCPPort);
+
+ WritetoConsole(Msg);
+
+ // See if we already have a port for this host
+
+ MasterPort[port] = port;
+
+ for (i = 1; i < port; i++)
+ {
+ if (i == port) continue;
+
+ if (TNCInfo[i] && TNCInfo[i]->TCPPort == TNC->TCPPort &&
+ _stricmp(TNCInfo[i]->HostName, TNC->HostName) == 0)
+ {
+ MasterPort[port] = i;
+ break;
+ }
+ }
+
+ BPQPort[PortEntry->PORTCONTROL.CHANNELNUM-65][MasterPort[port]] = port;
+
+#ifndef LINBPQ
+ if (MasterPort[port] == port)
+ {
+ if (EnumWindows(EnumTNCWindowsProc, (LPARAM)TNC))
+ if (TNC->ProgramPath)
+ TNC->WeStartedTNC = RestartTNC(TNC);
+
+ ConnecttoMPSK(port);
+ }
+#endif
+ time(&lasttime[port]); // Get initial time value
+
+// SendMessage(0x40eaa, WM_COMMAND, 0x03000eaa, 0x40eaa);
+
+ return ExtProc;
+
+}
+
+
+static int ProcessLine(char * buf, int Port)
+{
+ UCHAR * ptr,* p_cmd;
+ char * p_ipad = 0;
+ char * p_port = 0;
+ unsigned short WINMORport = 0;
+ int BPQport;
+ int len=510;
+ struct TNCINFO * TNC;
+ struct MPSKINFO * AGW;
+
+ char errbuf[256];
+
+ strcpy(errbuf, buf);
+
+ ptr = strtok(buf, " \t\n\r");
+
+ if(ptr == NULL) return (TRUE);
+
+ if(*ptr =='#') return (TRUE); // comment
+
+ if(*ptr ==';') return (TRUE); // comment
+
+ if (_stricmp(buf, "ADDR"))
+ return FALSE; // Must start with ADDR
+
+ ptr = strtok(NULL, " \t\n\r");
+
+ BPQport = Port;
+ p_ipad = ptr;
+
+ TNC = TNCInfo[BPQport] = zalloc(sizeof(struct TNCINFO));
+ AGW = TNC->MPSKInfo = zalloc(sizeof(struct MPSKINFO)); // AGW Sream Mode Specific Data
+
+ AGW->MaxSessions = 10;
+ AGW->ConnTimeOut = CONTIMEOUT;
+
+ TNC->InitScript = malloc(1000);
+ TNC->InitScript[0] = 0;
+
+ if (p_ipad == NULL)
+ p_ipad = strtok(NULL, " \t\n\r");
+
+ if (p_ipad == NULL) return (FALSE);
+
+ p_port = strtok(NULL, " \t\n\r");
+
+ if (p_port == NULL) return (FALSE);
+
+ TNC->TCPPort = atoi(p_port);
+
+ TNC->destaddr.sin_family = AF_INET;
+ TNC->destaddr.sin_port = htons(TNC->TCPPort);
+ TNC->HostName = malloc(strlen(p_ipad)+1);
+
+ if (TNC->HostName == NULL) return TRUE;
+
+ strcpy(TNC->HostName,p_ipad);
+
+ ptr = strtok(NULL, " \t\n\r");
+
+ if (ptr)
+ {
+ if (_memicmp(ptr, "PATH", 4) == 0)
+ {
+ p_cmd = strtok(NULL, "\n\r");
+ if (p_cmd) TNC->ProgramPath = _strdup(p_cmd);
+ }
+ }
+
+ // Read Initialisation lines
+
+ while(TRUE)
+ {
+ if (GetLine(buf) == 0)
+ return TRUE;
+
+ strcpy(errbuf, buf);
+
+ if (memcmp(buf, "****", 4) == 0)
+ return TRUE;
+
+ ptr = strchr(buf, ';');
+ if (ptr)
+ {
+ *ptr++ = 13;
+ *ptr = 0;
+ }
+
+ if (_memicmp(buf, "CONTIMEOUT", 10) == 0)
+ AGW->ConnTimeOut = atoi(&buf[11]) * 10;
+ else
+ if (_memicmp(buf, "UPDATEMAP", 9) == 0)
+ TNC->PktUpdateMap = TRUE;
+ else
+ if (_memicmp(buf, "ALEBEACON", 9) == 0) // Send Beacon after each session
+ TNC->MPSKInfo->Beacon = TRUE;
+ else
+ if (_memicmp(buf, "DEFAULTMODE", 11) == 0) // Send Beacon after each session
+ strcpy(TNC->MPSKInfo->DefaultMode, &buf[12]);
+ else
+
+ strcat (TNC->InitScript, buf);
+ }
+
+
+ return (TRUE);
+}
+
+static int ConnecttoMPSK(int port)
+{
+ _beginthread(ConnecttoMPSKThread, 0, (void *)(size_t)port);
+
+ return 0;
+}
+
+VOID ConnecttoMPSKThread(void * portptr)
+{
+
+ int port = (int)(size_t)portptr;
+ char Msg[255];
+ int err,i;
+ u_long param=1;
+ BOOL bcopt=TRUE;
+ struct hostent * HostEnt;
+ struct TNCINFO * TNC = TNCInfo[port];
+
+ Sleep(5000); // Allow init to complete
+
+ TNC->destaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
+
+ if (TNC->destaddr.sin_addr.s_addr == INADDR_NONE)
+ {
+ // Resolve name to address
+
+ HostEnt = gethostbyname (TNC->HostName);
+
+ if (!HostEnt) return; // Resolve failed
+
+ memcpy(&TNC->destaddr.sin_addr.s_addr,HostEnt->h_addr,4);
+ memcpy(&TNC->Datadestaddr.sin_addr.s_addr,HostEnt->h_addr,4);
+
+ }
+
+ if (TNC->TCPSock)
+ closesocket(TNC->TCPSock);
+
+ TNC->TCPSock = 0;
+
+ TNC->TCPSock=socket(AF_INET,SOCK_STREAM,0);
+
+ if (TNC->TCPSock == INVALID_SOCKET)
+ {
+ i=sprintf(Msg, "Socket Failed for MPSK socket - error code = %d\n", WSAGetLastError());
+ WritetoConsole(Msg);
+
+ return;
+ }
+
+ sinx.sin_family = AF_INET;
+ sinx.sin_addr.s_addr = INADDR_ANY;
+ sinx.sin_port = 0;
+
+ TNC->CONNECTING = TRUE;
+
+ if (connect(TNC->TCPSock,(LPSOCKADDR) &TNC->destaddr,sizeof(TNC->destaddr)) == 0)
+ {
+ //
+ // Connected successful
+ //
+
+ TNC->CONNECTED=TRUE;
+ }
+ else
+ {
+ if (TNC->Alerted == FALSE)
+ {
+ 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");
+
+ TNC->Alerted = TRUE;
+ }
+
+ TNC->CONNECTING = FALSE;
+ return;
+ }
+
+ TNC->LastFreq = 0; // so V4 display will be updated
+
+ MySetWindowText(TNC->xIDC_COMMSSTATE, "Connected to MPSK TNC");
+
+ return;
+
+}
+
+static int ProcessReceivedData(int port)
+{
+ unsigned int bytes;
+ int i;
+ char ErrMsg[255];
+ char Message[500];
+ struct TNCINFO * TNC = TNCInfo[port];
+
+ // Need to extract messages from byte stream
+
+ bytes = recv(TNC->TCPSock,(char *)&Message, 500, 0);
+
+ if (bytes == SOCKET_ERROR)
+ {
+// i=sprintf(ErrMsg, "Read Failed for MPSK socket - error code = %d\r\n", WSAGetLastError());
+// WritetoConsole(ErrMsg);
+
+ closesocket(TNC->TCPSock);
+
+ TNC->CONNECTED = FALSE;
+ if (TNC->Streams[0].Attached)
+ TNC->Streams[0].ReportDISC = TRUE;
+
+ return (0);
+ }
+
+ if (bytes == 0)
+ {
+ // zero bytes means connection closed
+
+ i=sprintf(ErrMsg, "MPSK Connection closed for BPQ Port %d\n", port);
+ WritetoConsole(ErrMsg);
+
+ TNC->CONNECTED = FALSE;
+ if (TNC->Streams[0].Attached)
+ TNC->Streams[0].ReportDISC = TRUE;
+
+ return (0);
+ }
+
+ // Have some data
+
+ ProcessMPSKPacket(TNC, Message, bytes); // Data may be for another port
+
+ return (0);
+
+}
+
+VOID ProcessMSPKCmd(struct TNCINFO * TNC);
+VOID ProcessMSPKComment(struct TNCINFO * TNC);
+VOID ProcessMSPKData(struct TNCINFO * TNC);
+
+VOID ProcessMPSKPacket(struct TNCINFO * TNC, char * Message, int Len)
+{
+ char * MPTR = Message;
+
+/*
+3) each text character transmitted by the client to the server (for the Multipsk TX text editor) must be preceded by the character CHR(25) or CHR(22) in the case of a special link (KISS in Packet or Pax, for example).
+
+4) each command string transmitted by the client to the server must be preceded by the character CHR(26) and finished by CHR(27),
+
+5) each character effectively transmitted by Multipsk to the transceiver and transmitted to the client is preceded by the character CHR(28),
+
+6) each character received by Multipsk and transmitted to the client is preceded by the character CHR(29),
+
+7) each command string transmitted by the server to the client must be preceded by the character CHR(30) and finished by CHR(31),
+
+8) all commands (written in readable text ) will have an answer (see further for details),
+
+9) each server comment (Call ID or RS ID reception, switch to RX or to TX) string transmitted by the server to the client must be preceded by a string: "CHR(23)RX CALL ID=", "CHR(23)RX RS ID=", "CHR(23)SWITCH=RX", "CHR(23) SWITCH=TX", and finished by CHR(24).
+
+10) each server command, for the transceiver control, transmitted by the server to the client must be preceded by the string "CHR(23) XCVR=" and finished by CHR(24).
+
+Data
+
+End of TX] ARQ FAE CQ[End of TX] ARQ FAE CQ[End of TX] call "THIS I[End of TX] end of link to GM8BPQ[End of TX] sounding "THIS WAS"[End of TX] ARQ FAE CQ[End of TX] ARQ FAE CQ[End of TX] ARQ FAE CQ[End of TX] ARQ FAE CQFAE BEACON OH5RM Kouvola KP30JR
+[End of TX] ARQ FAE selective callGM8BPQ DE OH5RM
+
+[Connection made with OH5RM]
+
+
+18103 but I have to go out to change antenna
+
+[End of connection with OH5RM]FAE BEACON OH5RM Kouvola KP30JR
+S" to GM8BPQ
+
+10:23:55 AM Comment: SWITCH=RX
+10:24:00 AM Comment: RX RS ID=10:24:00 UTC ALE400 1609 Hz 0 MHz
+10:24:19 AM Comment: RX RS ID=10:24:19 UTC ALE400 1604 Hz 0 MHz
+10:25:04 AM Comment: SWITCH=TX
+10:25:07 AM Comment: SWITCH=RX
+10:25:15 AM Comment: SWITCH=TX
+:30:22 AM Comment: SWITCH=RX
+10:30:25 AM Comment: SWITCH=TX
+10:30:27 AM Comment: SWITCH=RX
+10:30:35 AM Comment: RX RS ID=10:30:35 UTC ALE400 1598 Hz 0 MHz
+
+
+*/
+
+ // Reuse the HAL CMD and Data Buffers to build messages from TCP stream
+
+ // See if sequence split over a packet boundary
+
+ if (TNC->CmdEsc == 23)
+ {
+ TNC->CmdEsc = 0;
+ goto CommentEsc;
+ }
+
+ if (TNC->CmdEsc == 29)
+ {
+ TNC->CmdEsc = 0;
+ goto DataEsc;
+ }
+
+ if (TNC->CmdEsc == 30)
+ {
+ TNC->CmdEsc = 0;
+ goto CmdEsc;
+ }
+
+ // No Split
+
+ while(Len)
+ {
+ switch (*(MPTR++))
+ {
+ case 29: // Data Char
+
+ Len--;
+ DataEsc:
+ if (Len)
+ {
+ TNC->DataBuffer[TNC->DataLen++] = *MPTR;
+ MPTR++;
+ Len--;
+ goto OuterLoop;
+ }
+
+ TNC->CmdEsc = 29;
+
+ if (TNC->DataLen)
+ ProcessMSPKData(TNC);
+
+
+ return; // Nothing left
+
+ case 30:
+
+ Len --;
+ CmdEsc:
+ while (Len)
+ {
+ if (*MPTR == 31) // End of String
+ {
+ ProcessMSPKCmd(TNC);
+ TNC->CmdLen = 0;
+
+ // Process any data left in buffer
+
+ MPTR++;
+ Len--;
+ goto OuterLoop;
+ }
+
+ TNC->CmdBuffer[TNC->CmdLen++] = *MPTR;
+ MPTR++;
+ Len--;
+ }
+
+ TNC->CmdEsc = 30;
+ return; // Nothing left
+
+ case 23: // Server Comment
+
+ Len --;
+ CommentEsc:
+ while (Len)
+ {
+ if (*MPTR == 24) // End of String
+ {
+ // Process Comment
+
+ ProcessMSPKCmd(TNC);
+ TNC->CmdLen = 0;
+
+ // Process any data left in buffer
+
+ MPTR++;
+ Len--;
+ goto OuterLoop;
+ }
+
+ TNC->CmdBuffer[TNC->CmdLen++] = *MPTR;
+ MPTR++;
+ Len--;
+ }
+
+ TNC->CmdEsc = 23;
+ return; // Nothing left
+
+ default:
+
+ Len--;
+
+ }
+OuterLoop:;
+ }
+
+ if (TNC->DataLen)
+ ProcessMSPKData(TNC);
+}
+
+VOID ProcessMSPKCmd(struct TNCINFO * TNC)
+{
+ TNC->CmdBuffer[TNC->CmdLen] = 0;
+
+ if (strcmp(TNC->CmdBuffer, "SWITCH=TX") == 0)
+ TNC->MPSKInfo->TX = TRUE;
+ else
+ {
+ if (strcmp(TNC->CmdBuffer, "SWITCH=RX") == 0)
+ {
+ TNC->MPSKInfo->TX = FALSE;
+
+ // See if a command was queued while busy
+
+ if (TNC->CmdSet)
+ {
+ send(TNC->TCPSock, TNC->CmdSet, (int)strlen(TNC->CmdSet), 0);
+ free (TNC->CmdSet);
+ TNC->CmdSet = NULL;
+ }
+ }
+ else
+ {
+ Debugprintf("MPSK CMD %s", TNC->CmdBuffer);
+
+ if (TNC->InternalCmd)
+ {
+ ULONG * buffptr = GetBuff();
+ char * ptr = strstr(TNC->CmdBuffer, "OK");
+
+ if (ptr)
+ *(ptr+2) = 0; // Convert OKn to OK for BBS Connect Script
+
+ TNC->InternalCmd = FALSE;
+
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "MPSK} %s\r", TNC->CmdBuffer);
+ C_Q_ADD(&TNC->Streams[0].PACTORtoBPQ_Q, buffptr);
+ }
+
+ if (strstr(TNC->CmdBuffer, "STOP_SELECTIVE_CALL_ARQ_FAE OK"))
+ TNC->Streams[0].Connecting = FALSE;
+
+ }
+ }
+ }
+}
+
+VOID ProcessMSPKComment(struct TNCINFO * TNC)
+{
+ TNC->CmdBuffer[TNC->CmdLen] = 0;
+ Debugprintf("MPSK Comment %s", TNC->CmdBuffer);
+}
+
+static int UnStuff(UCHAR * inbuff, int len)
+{
+ int i,txptr=0;
+ UCHAR c;
+ UCHAR * outbuff = inbuff;
+
+ for (i = 0; i < len; i++)
+ {
+ c = inbuff[i];
+
+ if (c == 0xc0)
+ c = inbuff[++i] - 0x20;
+
+ outbuff[txptr++]=c;
+ }
+
+ return txptr;
+}
+
+VOID ProcessMSPKData(struct TNCINFO * TNC)
+{
+ UINT * buffptr;
+ int Stream = 0;
+ struct STREAMINFO * STREAM = &TNC->Streams[0];
+ char * ptr;
+ int Len = TNC->DataLen;
+
+ TNC->DataBuffer[TNC->DataLen] = 0;
+
+ // Process Data
+
+ if (STREAM->Connected)
+ {
+ ptr = strstr(TNC->DataBuffer, "[End of connection");
+
+ if (ptr)
+ {
+ // Disconnect
+
+ TNC->DataLen = 0;
+
+ if (STREAM->DiscWhenAllSent)
+ return; // Already notified
+
+ if (STREAM->Connecting)
+ {
+ // Report Connect Failed, and drop back to command mode
+
+ STREAM->Connecting = FALSE;
+ buffptr = GetBuff();
+
+ if (buffptr == 0) return; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "MPSK} Failure with %s\r", STREAM->RemoteCall);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ STREAM->DiscWhenAllSent = 10;
+
+ return;
+ }
+
+ // Release Session
+
+ STREAM->Connecting = FALSE;
+ STREAM->Connected = FALSE; // Back to Command Mode
+ STREAM->ReportDISC = TRUE; // Tell Node
+
+ STREAM->Disconnecting = FALSE;
+ STREAM->DiscWhenAllSent = 10;
+ STREAM->FramesOutstanding = 0;
+
+ return;
+ }
+
+ // Pass to Application. Remove any transparency (hex 0xc0 used as an escape)
+
+ buffptr = GetBuff();
+
+ if (TNC->DataBuffer[TNC->DataLen - 1] == 0xc0)
+ return; // Last char is an escape, so wait for the escaped char to arrive
+
+ if (buffptr)
+ {
+ if (memchr(TNC->DataBuffer, 0xc0, TNC->DataLen))
+ TNC->DataLen = UnStuff(TNC->DataBuffer, TNC->DataLen);
+
+ buffptr[1] = TNC->DataLen;
+ memcpy(&buffptr[2], TNC->DataBuffer, TNC->DataLen);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ STREAM->BytesRXed += TNC->DataLen;
+ }
+
+ TNC->DataLen = 0;
+ return;
+ }
+
+ // Not Connected. We get various status messages, including Connection made,
+ // but they may be split across packets, or have more that one to a packet.
+ // I think they are all CR/LF terminated . No they aren't!
+
+ // Look for [] this seems to be what is important
+
+DataLoop:
+
+ if (memcmp(TNC->DataBuffer, "[End of TX] ARQ FAE CQ", 22) == 0)
+ {
+ // Remove string from buffer
+
+ if (Len == 22) // Most Likely
+ {
+ TNC->DataLen = 0;
+ return;
+ }
+
+ TNC->DataLen -= 22;
+ memmove(TNC->DataBuffer, &TNC->DataBuffer[22], Len - 21); //Copy Null
+ Len -= 22;
+ goto DataLoop;
+
+ }
+
+ ptr = strchr(TNC->DataBuffer, '[');
+
+ if (ptr)
+ {
+ // Start of a significant Message
+
+ char * eptr = strchr(TNC->DataBuffer, ']');
+ char CallFrom[20];
+ char * cptr ;
+
+ if (eptr == 0)
+ return; // wait for matching []
+
+ cptr = strstr(TNC->DataBuffer, "[Connection made with ");
+
+ // TNC->DataLen -= LineLen;
+ // memmove(TNC->DataBuffer, &TNC->DataBuffer[LineLen], 1 + Len - LineLen); //Copy Null
+ // Len -= LineLen;
+ // goto DataLoop;
+
+
+ if (cptr) // Have a connection
+ {
+
+ // Connected
+
+ memcpy(CallFrom, &cptr[22], 18);
+ cptr = strchr(CallFrom, ']');
+ if (cptr)
+ *cptr = 0;
+
+ if (STREAM->Connecting)
+ {
+ // Connect Complete
+
+ STREAM->Connected = TRUE;
+ STREAM->Connecting = FALSE;
+ STREAM->ConnectTime = time(NULL);
+ STREAM->BytesRXed = STREAM->BytesTXed = 0;
+
+ buffptr = GetBuff();
+ if (buffptr)
+ {
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "*** Connected to %s\r", CallFrom);
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ }
+ }
+ else
+ {
+ // Incoming. Look for a free Stream
+
+ STREAM->Connected = TRUE;
+ STREAM->ConnectTime = time(NULL);
+ STREAM->BytesRXed = STREAM->BytesTXed = 0;
+
+ UpdateMH(TNC, CallFrom, '+', 'I');
+
+ ProcessIncommingConnect(TNC, CallFrom, Stream, FALSE);
+
+ if (HFCTEXTLEN)
+ {
+ if (HFCTEXTLEN > 1)
+ SendData(TNC, HFCTEXT, HFCTEXTLEN);
+ }
+ else
+ {
+ if (FULL_CTEXT)
+ {
+ int Len = CTEXTLEN, CTPaclen = 50;
+ int Next = 0;
+
+ while (Len > CTPaclen) // CTEXT Paclen
+ {
+ SendData(TNC, &CTEXTMSG[Next], CTPaclen);
+ Next += CTPaclen;
+ Len -= CTPaclen;
+ }
+ SendData(TNC, &CTEXTMSG[Next], Len);
+ }
+ }
+ }
+ }
+
+ }
+
+ // Doesnt contain [ - just discard
+
+ TNC->DataLen = 0;
+ Debugprintf(TNC->DataBuffer);
+ return;
+
+}
+
+
+
+/*
+ buffptr = GetBuff();
+ if (buffptr == 0) return; // No buffers, so ignore
+
+ buffptr[1] = RXHeader->DataLength;
+ memcpy(&buffptr[2], Message, RXHeader->DataLength);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+ return;
+
+ return;
+
+
+ case 'd': // Disconnected
+
+
+
+ case 'C':
+
+ // Connect. Can be Incoming or Outgoing
+
+ // "*** CONNECTED To Station [CALLSIGN]" When the other station starts the connection
+ // "*** CONNECTED With [CALLSIGN]" When we started the connection
+
+ */
+
+
+VOID SendData(struct TNCINFO * TNC, char * Msg, int MsgLen)
+{
+ // Preceed each data byte with 25 (decimal)
+
+ char * NewMsg = malloc (MsgLen * 4);
+ int n;
+ UCHAR c;
+ int ExtraLen = 0;
+ char * ptr = NewMsg;
+ char * inptr = Msg;
+ SOCKET sock = TNCInfo[MasterPort[TNC->Port]]->TCPSock;
+
+ TNC->Streams[0].BytesTXed += MsgLen;
+
+ for (n = 0; n < MsgLen; n++)
+ {
+ *(ptr++) = 25;
+ c = *inptr++;
+
+ if (c < 0x20 || c == 0xc0)
+ {
+ if (c != 0x0d)
+ {
+ *ptr++ = 0x0c0;
+ *(ptr++) = 25;
+ *ptr++ = c + 0x20;
+ ExtraLen += 2;
+ continue;
+ }
+ }
+
+ *ptr++ = c;
+ }
+
+ send(sock, NewMsg, MsgLen * 2 + ExtraLen, 0);
+
+ free(NewMsg);
+}
+
+VOID TidyClose(struct TNCINFO * TNC, int Stream)
+{
+ char Command[80];
+ int len;
+
+ len = sprintf(Command,"%cSTOP_SELECTIVE_CALL_ARQ_FAE\x1b", '\x1a');
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Command); // Savde till not transmitting
+ else
+ send(TNC->TCPSock, Command, len, 0);
+}
+
+VOID ForcedClose(struct TNCINFO * TNC, int Stream)
+{
+ TidyClose(TNC, Stream); // I don't think Hostmode has a DD
+}
+
+VOID CloseComplete(struct TNCINFO * TNC, int Stream)
+{
+ char Cmd[80];
+ int Len;
+
+ sprintf(Cmd, "%d SCANSTART 15", TNC->Port);
+ Rig_Command(-1, Cmd);
+
+ Cmd[0] = 0;
+
+ if (TNC->MPSKInfo->DefaultMode[0])
+ sprintf(Cmd, "%cDIGITAL MODE %s\x1b", '\x1a', TNC->MPSKInfo->DefaultMode);
+
+ if (TNC->MPSKInfo->Beacon)
+ sprintf(Cmd, "%s%cBEACON_ARQ_FAE\x1b", Cmd, '\x1a');
+
+ Len = (int)strlen(Cmd);
+
+ if(Len)
+ {
+ if (TNC->MPSKInfo->TX)
+ TNC->CmdSet = TNC->CmdSave = _strdup(Cmd); // Savde till not transmitting
+ else
+ send(TNC->TCPSock, Cmd, Len, 0);
+ }
+}
+
diff --git a/Moncode.c b/Moncode.c
index 1de165b..b539f1f 100644
--- a/Moncode.c
+++ b/Moncode.c
@@ -535,6 +535,16 @@ KC6OAR*>ID:
Output += sprintf((char *)Output, " RX Window=%d", value);
break;
+
+ case 16:
+
+ Output += sprintf((char *)Output, " Can Compress");
+ break;
+
+ case 17:
+
+ Output += sprintf((char *)Output, " Compress ok");
+ break;
}
}
}
@@ -551,6 +561,15 @@ KC6OAR*>ID:
switch (ADJBUFFER->PID)
{
+ case 0xF1:
+ case 0xF2:
+
+ // Compressed L2 Data
+
+ Output += sprintf((char *)Output, " <%d Bytes of Compressed L2 Data>", MsgLen - (19 + sizeof(void *)));
+
+ break;
+
case 0xF0: // Normal Data
{
char Infofield[257];
diff --git a/MultiConsole.c b/MultiConsole.c
index 81b3530..f574b53 100644
--- a/MultiConsole.c
+++ b/MultiConsole.c
@@ -919,6 +919,9 @@ LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
DoRefresh(Cinfo);
+ Cinfo->Console->bytesRxed += Cinfo->kbptr+1;
+
+
if (Cinfo->Console->SysopChatStream)
SendUnbuffered(Cinfo->Console->SysopChatStream->BPQStream, &Cinfo->kbbuf[0], Cinfo->kbptr+1);
else
diff --git a/RHP.c b/RHP.c
index 18b933d..a82b091 100644
--- a/RHP.c
+++ b/RHP.c
@@ -451,8 +451,13 @@ int processRHCPSend(SOCKET Socket, char * Msg, char * ReplyBuffer)
int ID;
char * Data;
char * ptr;
+ unsigned char * uptr;
int c;
int Len;
+ unsigned int HexCode1;
+ unsigned int HexCode2;
+
+ int n;
int Handle = 1;
@@ -470,9 +475,10 @@ int processRHCPSend(SOCKET Socket, char * Msg, char * ReplyBuffer)
RHPSession = RHPSessions[Handle - 1];
- // Look for \ escapes
+ // Look for \ escapes, Can now also get \u00c3
ptr = Data;
+ Len = strlen(Data); // in case no escapes
while (ptr = strchr(ptr, '\\'))
{
@@ -483,23 +489,60 @@ int processRHCPSend(SOCKET Socket, char * Msg, char * ReplyBuffer)
case 'r':
*ptr = 13;
+ memmove(ptr + 1, ptr + 2, strlen(ptr + 1));
break;
+
+ case 'u':
+
+ HexCode1 = HexCode2 = 0;
+
+ n = toupper(ptr[2]) - '0';
+ if (n > 9) n = n - 7;
+ HexCode1 |= n << 4;
+
+ n = toupper(ptr[3]) - '0';
+ if (n > 9) n = n - 7;
+ HexCode1 |= n;
+
+ n = toupper(ptr[4]) - '0';
+ if (n > 9) n = n - 7;
+ HexCode2 |= n << 4;
+
+ n = toupper(ptr[5]) - '0';
+ if (n > 9) n = n - 7;
+ HexCode2 |= n;
+
+ if (HexCode1 == 0 || HexCode1 == 0xC2)
+ {
+ uptr = ptr;
+ *uptr = HexCode2;
+ }
+ else if (HexCode1 == 0xc2)
+ {
+ uptr = ptr;
+ *uptr = HexCode2 + 0x40;
+ }
+
+ memmove(ptr + 1, ptr + 6, strlen(ptr + 5));
+ break;
+
case '\\':
*ptr = '\\';
+ memmove(ptr + 1, ptr + 2, strlen(ptr + 1));
break;
case '"':
*ptr = '"';
+ memmove(ptr + 1, ptr + 2, strlen(ptr + 1));
break;
}
- memmove(ptr + 1, ptr + 2, strlen(ptr + 1));
ptr++;
+ Len = ptr - Data;
}
- Len = strlen(Data);
ptr = Data;
while (Len > RHPPaclen)
@@ -640,7 +683,7 @@ void RHPPoll()
// Message is JSON so Convert CR to \r, \ to \\ " to \"
- // Looks like I need to escape everything not between 0x20 and 0x7f eg \U00c3
+ // Looks like I need to escape everything not between 0x20 and 0x7f eg \u00c3
while (c = *(ptr))
diff --git a/RTKnown.txt b/RTKnown.txt
deleted file mode 100644
index e69de29..0000000
--- a/RTKnown.txt
+++ /dev/null
diff --git a/RigControl.c b/RigControl.c
index 90349fe..c2b7c4d 100644
--- a/RigControl.c
+++ b/RigControl.c
@@ -5293,6 +5293,7 @@ BOOL DecodeModePtr(char * Param, double * Dwell, double * Freq, char * Mode,
if (ptr == NULL || strlen(ptr) > 8)
return FALSE; // Mode Missing
+ // If channel, dont need mode
if (*MemoryNumber == 0)
{
diff --git a/SCSTrackeMulti64.c b/SCSTrackeMulti64.c
new file mode 100644
index 0000000..a7dc3bf
--- /dev/null
+++ b/SCSTrackeMulti64.c
@@ -0,0 +1,1714 @@
+/*
+Copyright 2001-2018 John Wiseman G8BPQ
+
+This file is part of LinBPQ/BPQ32.
+
+LinBPQ/BPQ32 is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+LinBPQ/BPQ32 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
+*/
+
+//
+// DLL to inteface DED Host Mode TNCs to BPQ32 switch
+//
+// Uses BPQ EXTERNAL interface
+
+#define _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "time.h"
+
+#define MaxStreams 10
+
+#include "CHeaders.h"
+#include "tncinfo.h"
+
+#include "bpq32.h"
+
+static char ClassName[]="TRACKERSTATUS";
+static char WindowTitle[] = "SCS Tracker";
+static int RigControlRow = 140;
+
+#define NARROWMODE 30
+#define WIDEMODE 30 // PIII only
+
+extern UCHAR BPQDirectory[];
+
+extern char * PortConfig[33];
+
+static RECT Rect;
+
+struct TNCINFO * TNCInfo[34]; // Records are Malloc'd
+
+VOID __cdecl Debugprintf(const char * format, ...);
+char * strlop(char * buf, char delim);
+BOOL KAMStartPort(struct PORTCONTROL * PORT);
+BOOL KAMStopPort(struct PORTCONTROL * PORT);
+
+char NodeCall[11]; // Nodecall, Null Terminated
+void WriteDebugLogLine(int Port, char Dirn, char * Msg, int MsgLen);
+
+static int ProcessLine(char * buf, int Port)
+{
+ UCHAR * ptr;
+ char * p_port = 0;
+ int BPQport;
+ int len=510;
+ struct TNCINFO * TNC;
+ char errbuf[256];
+
+ strcpy(errbuf, buf);
+
+ BPQport = Port;
+
+ TNC = TNCInfo[BPQport] = malloc(sizeof(struct TNCINFO));
+ memset(TNC, 0, sizeof(struct TNCINFO));
+
+ TNC->InitScript = malloc(1000);
+ TNC->InitScript[0] = 0;
+
+ TNC->PacketChannels = 10; // Default
+
+ goto ConfigLine;
+
+ while(TRUE)
+ {
+ if (GetLine(buf) == 0)
+ return TRUE;
+ConfigLine:
+ strcpy(errbuf, buf);
+
+ if (memcmp(buf, "****", 4) == 0)
+ return TRUE;
+
+ ptr = strchr(buf, ';');
+
+ if (ptr)
+ {
+ *ptr++ = 13;
+ *ptr = 0;
+ }
+
+ if (_memicmp(buf, "APPL", 4) == 0)
+ {
+ }
+ else
+ if (_memicmp(buf, "RIGCONTROL", 10) == 0)
+ {
+ }
+ else
+
+ if (_memicmp(buf, "SWITCHMODES", 11) == 0)
+ {
+ }
+ else
+ if (_memicmp(buf, "USEAPPLCALLS", 12) == 0)
+ {
+// TNC->UseAPPLCalls = TRUE;
+ }
+ else if (_memicmp(buf, "DEBUGLOG", 8) == 0) // Write Debug Log
+ TNC->WRITELOG = atoi(&buf[8]);
+ else
+ if (_memicmp(buf, "DEFAULT ROBUST", 14) == 0)
+ {
+ }
+ else
+
+ if (_memicmp(buf, "WL2KREPORT", 10) == 0)
+ {
+ }
+ else
+ if (_memicmp(buf, "UPDATEMAP", 9) == 0)
+ TNC->PktUpdateMap = TRUE;
+ else
+ if (_memicmp(buf, "PACKETCHANNELS", 14) == 0)
+
+ // Packet Channels
+
+ TNC->PacketChannels = atoi(&buf[14]);
+ else
+ strcat (TNC->InitScript, buf);
+ }
+ return (TRUE);
+
+}
+
+struct TNCINFO * CreateTTYInfo(int port, int speed);
+BOOL OpenConnection(int);
+BOOL SetupConnection(int);
+BOOL CloseConnection(struct TNCINFO * conn);
+static BOOL WriteCommBlock(struct TNCINFO * TNC);
+BOOL DestroyTTYInfo(int port);
+static void DEDCheckRX(struct TNCINFO * TNC);
+static VOID DEDPoll(int Port);
+VOID StuffAndSend(struct TNCINFO * TNC, UCHAR * Msg, int Len);
+unsigned short int compute_crc(unsigned char *buf,int len);
+int Unstuff(UCHAR * MsgIn, UCHAR * MsgOut, int len);
+static VOID ProcessDEDFrame(struct TNCINFO * TNC);
+static VOID ProcessTermModeResponse(struct TNCINFO * TNC);
+static VOID ExitHost(struct TNCINFO * TNC);
+static VOID DoTNCReinit(struct TNCINFO * TNC);
+static VOID DoTermModeTimeout(struct TNCINFO * TNC);
+VOID DoMonitorHddr(struct TNCINFO * TNC, UCHAR * Msg, int Len, int Type);
+VOID DoMonitorData(struct TNCINFO * TNC, UCHAR * Msg, int Len);
+int Switchmode(struct TNCINFO * TNC, int Mode);
+VOID SwitchToRPacket(struct TNCINFO * TNC);
+VOID SwitchToNormPacket(struct TNCINFO * TNC);
+
+
+static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
+{
+ PMSGWITHLEN buffptr;
+ unsigned int txlen = 0;
+
+ struct TNCINFO * TNC = TNCInfo[port];
+ int Stream = 0;
+ struct STREAMINFO * STREAM;
+ int TNCOK;
+
+ if (TNC == NULL)
+ return 0;
+
+ if (TNC->hDevice == 0)
+ {
+ // Clear anything from UI_Q
+
+ while (TNC->PortRecord->UI_Q)
+ {
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+ ReleaseBuffer(buffptr);
+ }
+
+ if (fn > 3 && fn < 6)
+ goto ok;
+
+ // Try to reopen every 30 secs
+
+ TNC->ReopenTimer++;
+
+ if (TNC->ReopenTimer < 300)
+ return 0;
+
+ TNC->ReopenTimer = 0;
+
+ if (TNC->PortRecord->PORTCONTROL.PortStopped == 0)
+ OpenCOMMPort(TNC, TNC->PortRecord->PORTCONTROL.SerialPortName, TNC->PortRecord->PORTCONTROL.BAUDRATE, TRUE);
+
+ if (TNC->hDevice == 0)
+ return 0;
+ }
+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;
+ }
+ }
+
+ DEDCheckRX(TNC);
+ DEDPoll(port);
+ DEDCheckRX(TNC);
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ STREAM = &TNC->Streams[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
+ }
+ }
+ else
+ {
+ int datalen;
+
+ buffptr=Q_REM(&STREAM->PACTORtoBPQ_Q);
+
+ datalen = (int)buffptr->Len;
+
+ 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;
+
+ PutLengthinBuffer((PDATAMESSAGE)buff, datalen); // Neded for arm5 portability
+
+ // buff[5]=(datalen & 0xff);
+ // buff[6]=(datalen >> 8);
+
+ ReleaseBuffer(buffptr);
+
+ return (1);
+ }
+ }
+
+
+ return 0;
+
+ case 2: // send
+
+ buffptr = GetBuff();
+
+ if (buffptr == 0) return (0); // No buffers, so ignore
+
+ Stream = buff->PORT;
+
+ if (!TNC->TNCOK)
+ {
+ // Send Error Response
+
+ buffptr->Len = 21;
+ memcpy(&buffptr->Data[0], "No Connection to TNC\r", 21);
+
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+
+ return 0;
+ }
+
+ txlen = GetLengthfromBuffer(buff) - (sizeof(void *) + 4);
+
+ buffptr->Len = txlen;
+ memcpy(&buffptr->Data[0], &buff->L2DATA[0], txlen);
+
+ C_Q_ADD(&TNC->Streams[Stream].BPQtoPACTOR_Q, buffptr);
+
+ TNC->Streams[Stream].FramesOutstanding++;
+
+ return (0);
+
+
+ case 3: // CHECK IF OK TO SEND. Also used to check if TNC is responding
+
+ Stream = (int)(size_t)buff;
+
+ TNCOK = (TNC->HostMode == 1 && TNC->ReinitState != 10);
+
+ STREAM = &TNC->Streams[Stream];
+
+ if (Stream == 0)
+ {
+ if (STREAM->FramesOutstanding > 4)
+ return (1 | TNCOK << 8 | STREAM->Disconnecting << 15);
+ }
+ else
+ {
+ if (STREAM->FramesOutstanding > 3 || TNC->Buffers < 200)
+ return (1 | TNCOK << 8 | STREAM->Disconnecting << 15); }
+
+ return TNCOK << 8 | STREAM->Disconnecting << 15; // OK, but lock attach if disconnecting
+
+
+ case 4: // reinit
+
+ ExitHost(TNC);
+ Sleep(50);
+ CloseCOMPort(TNC->hDevice);
+ TNC->hDevice =(HANDLE) 0;
+ TNC->ReopenTimer = 250;
+ TNC->HostMode = FALSE;
+
+ return (0);
+
+ case 5: // Close
+
+ // Ensure in Pactor
+
+ ExitHost(TNC);
+
+ Sleep(25);
+
+ CloseCOMPort(TNCInfo[port]->hDevice);
+ return (0);
+
+ case 6:
+
+ return 0; // No scan interface
+}
+ return 0;
+}
+
+void * TrackerMExtInit(EXTPORTDATA * PortEntry)
+{
+ char msg[500];
+ struct TNCINFO * TNC;
+ int port;
+ char * ptr;
+ int Stream = 0;
+ char * TempScript;
+ char YCmd[10];
+
+ //
+ // Will be called once for each DED Host TNC Port
+ // The COM port number is in IOBASE
+ //
+
+ sprintf(msg,"SCSTRK M %s", PortEntry->PORTCONTROL.SerialPortName);
+
+ WritetoConsole(msg);
+
+ port=PortEntry->PORTCONTROL.PORTNUMBER;
+
+ ReadConfigFile(port, ProcessLine);
+
+ TNC = TNCInfo[port];
+
+ if (TNC == NULL)
+ {
+ // Not defined in Config file
+
+ sprintf(msg," ** Error - no info in BPQ32.cfg for this port\n");
+ WritetoConsole(msg);
+
+ return ExtProc;
+ }
+
+ TNC->Port = port;
+ TNC->Hardware = H_TRKM;
+
+ // Set up DED addresses for streams
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ TNC->Streams[Stream].DEDStream = Stream; // DED Stream = BPQ Stream (We don't use Stream 0)
+ }
+
+ if (TNC->PacketChannels > MaxStreams)
+ TNC->PacketChannels = MaxStreams;
+
+ PortEntry->MAXHOSTMODESESSIONS = TNC->PacketChannels + 1; //TNC->PacketChannels + 1;
+ PortEntry->PERMITGATEWAY = TRUE; // Can change ax.25 call on each stream
+ PortEntry->SCANCAPABILITIES = NONE; // Scan Control 3 stage/conlock
+
+ TNC->PortRecord = PortEntry;
+
+ if (PortEntry->PORTCONTROL.PORTCALL[0] == 0)
+ memcpy(TNC->NodeCall, MYNODECALL, 10);
+ else
+ ConvFromAX25(&PortEntry->PORTCONTROL.PORTCALL[0], TNC->NodeCall);
+
+ PortEntry->PORTCONTROL.PROTOCOL = 10;
+ PortEntry->PORTCONTROL.PORTQUALITY = 0;
+ PortEntry->PORTCONTROL.UICAPABLE = 1;
+
+ if (PortEntry->PORTCONTROL.PORTPACLEN == 0)
+ PortEntry->PORTCONTROL.PORTPACLEN = 100;
+
+ PortEntry->PORTCONTROL.PORTSTARTCODE = KAMStartPort;
+ PortEntry->PORTCONTROL.PORTSTOPCODE = KAMStopPort;
+
+ ptr=strchr(TNC->NodeCall, ' ');
+ if (ptr) *(ptr) = 0; // Null Terminate
+
+ // get NODECALL for RP tests
+
+ memcpy(NodeCall, MYNODECALL, 10);
+
+ ptr=strchr(NodeCall, ' ');
+ if (ptr) *(ptr) = 0; // Null Terminate
+
+ TempScript = malloc(1000);
+
+ strcpy(TempScript, "M UISC\r");
+ strcat(TempScript, "F 200\r"); // Sets SABM retry time to about 5 secs
+ strcat(TempScript, "%F 1500\r"); // Tones may be changed but I want this as standard
+
+ strcat(TempScript, TNC->InitScript);
+
+ free(TNC->InitScript);
+ TNC->InitScript = TempScript;
+
+ // Others go on end so they can't be overriden
+
+ strcat(TNC->InitScript, "Z 0\r"); // No Flow Control
+ sprintf(YCmd, "Y %d\r", TNC->PacketChannels);
+ strcat(TNC->InitScript, YCmd);
+ strcat(TNC->InitScript, "E 1\r"); // Echo - Restart process needs echo
+
+ sprintf(msg, "I %s\r", TNC->NodeCall);
+ strcat(TNC->InitScript, msg);
+
+ OpenCOMMPort(TNC,PortEntry->PORTCONTROL.SerialPortName, PortEntry->PORTCONTROL.BAUDRATE, FALSE);
+
+ TNC->InitPtr = TNC->InitScript;
+
+ WritetoConsole("\n");
+
+ return ExtProc;
+}
+
+static void DEDCheckRX(struct TNCINFO * TNC)
+{
+ int Length, Len;
+ UCHAR * ptr;
+ UCHAR character;
+ UCHAR * CURSOR;
+
+ Len = ReadCOMBlock(TNC->hDevice, &TNC->RXBuffer[TNC->RXLen], 500 - TNC->RXLen);
+
+ if (Len == 0)
+ return; // Nothing doing
+
+ TNC->RXLen += Len;
+
+ Length = TNC->RXLen;
+
+ ptr = TNC->RXBuffer;
+
+ CURSOR = &TNC->DEDBuffer[TNC->InputLen];
+
+ if ((TNC->HostMode == 0 || TNC->ReinitState == 10) && Length > 80)
+ {
+ // Probably Signon Message
+
+ if (TNC->WRITELOG)
+ WriteDebugLogLine(TNC->Port, 'R', ptr, Length);
+
+ ptr[Length] = 0;
+ Debugprintf("TRK %s", ptr);
+ TNC->RXLen = 0;
+ return;
+ }
+
+ if (TNC->HostMode == 0)
+ {
+ // If we are just restarting, and TNC is in host mode, we may get "Invalid Channel" Back
+
+ if (memcmp(ptr, "\x18\x02INVALID", 9) == 0)
+ {
+ if (TNC->WRITELOG)
+ WriteDebugLogLine(TNC->Port, 'R', ptr, Length);
+
+ TNC->HostMode = TRUE;
+ TNC->HOSTSTATE = 0;
+ TNC->Timeout = 0;
+ TNC->RXLen = 0;
+ return;
+ }
+
+ // Command is echoed as * command *
+
+ if (strstr(ptr, "*") || TNC->ReinitState == 5) // 5 is waiting for reponse to JHOST1
+ {
+ ProcessTermModeResponse(TNC);
+ TNC->RXLen = 0;
+ TNC->HOSTSTATE = 0;
+
+ return;
+ }
+ }
+
+ if (TNC->ReinitState == 10)
+ {
+ if (Length == 1 && *(ptr) == '.') // 01 echoed as .
+ {
+ // TNC is in Term Mode
+
+ if (TNC->WRITELOG)
+ WriteDebugLogLine(TNC->Port, 'R', ptr, Length);
+ TNC->ReinitState = 0;
+ TNC->HostMode = 0;
+
+ return;
+ }
+ }
+
+ while (Length--)
+ {
+ character = *(ptr++);
+
+ if (TNC->HostMode)
+ {
+ // n 0 Success (nothing follows)
+ // n 1 Success (message follows, null terminated)
+ // n 2 Failure (message follows, null terminated)
+ // n 3 Link Status (null terminated)
+ // n 4 Monitor Header (null terminated)
+ // n 5 Monitor Header (null terminated)
+ // n 6 Monitor Information (preceeded by length-1)
+ // n 7 Connect Information (preceeded by length-1)
+
+
+ switch(TNC->HOSTSTATE)
+ {
+ case 0: // SETCHANNEL
+
+ TNC->MSGCHANNEL = character;
+ TNC->HOSTSTATE++;
+ break;
+
+ case 1: // SETMSGTYPE
+
+ TNC->MSGTYPE = character;
+
+ if (character == 0)
+ {
+ // Success, no more info
+
+ ProcessDEDFrame(TNC);
+
+ TNC->HOSTSTATE = 0;
+ break;
+ }
+
+ if (character > 0 && character < 6)
+ {
+ // Null Terminated Response)
+
+ TNC->HOSTSTATE = 5;
+ CURSOR = &TNC->DEDBuffer[0];
+ break;
+ }
+
+ if (character > 5 && character < 8)
+ {
+ TNC->HOSTSTATE = 2; // Get Length
+ break;
+ }
+
+ // Invalid
+
+ Debugprintf("TRK - Invalid MsgType %d %x %x %x", character, *(ptr), *(ptr+1), *(ptr+2));
+ break;
+
+ case 2: // Get Length
+
+ TNC->MSGCOUNT = character;
+ TNC->MSGCOUNT++; // Param is len - 1
+ TNC->MSGLENGTH = TNC->MSGCOUNT;
+ CURSOR = &TNC->DEDBuffer[0];
+ TNC->HOSTSTATE = 3; // Get Data
+
+ break;
+
+ case 5: // Collecting Null Terminated Response
+
+ *(CURSOR++) = character;
+
+ if (character)
+ continue; // MORE TO COME
+
+ ProcessDEDFrame(TNC);
+
+ TNC->HOSTSTATE = 0;
+ TNC->InputLen = 0;
+
+ break;
+
+ default:
+
+ // RECEIVING Counted Response
+
+ *(CURSOR++) = character;
+ TNC->MSGCOUNT--;
+
+ if (TNC->MSGCOUNT)
+ continue; // MORE TO COME
+
+ TNC->InputLen = (int)(CURSOR - TNC->DEDBuffer);
+ ProcessDEDFrame(TNC);
+
+ TNC->HOSTSTATE = 0;
+ TNC->InputLen = 0;
+ }
+ }
+ }
+
+ // End of Input - Save buffer position
+
+ TNC->InputLen = (int)(CURSOR - TNC->DEDBuffer);
+ TNC->RXLen = 0;
+}
+
+static BOOL WriteCommBlock(struct TNCINFO * TNC)
+{
+ WriteCOMBlock(TNC->hDevice, TNC->TXBuffer, TNC->TXLen);
+
+ if (TNC->WRITELOG)
+ WriteDebugLogLine(TNC->Port, 'T', TNC->TXBuffer, TNC->TXLen);
+
+ TNC->Timeout = 20; // 2 secs
+ return TRUE;
+}
+
+static VOID DEDPoll(int Port)
+{
+ struct TNCINFO * TNC = TNCInfo[Port];
+ UCHAR * Poll = TNC->TXBuffer;
+ int Stream = 0;
+ int nn;
+ struct STREAMINFO * STREAM;
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] && TNC->Streams[Stream].Attached == 0)
+ {
+ // New Attach. Set call my session callsign
+
+ int calllen=0;
+
+ TNC->Streams[Stream].Attached = TRUE;
+
+ TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER[6] |= 0x60; // Ensure P or T aren't used on ax.25
+ calllen = ConvFromAX25(TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4USER, TNC->Streams[Stream].MyCall);
+ TNC->Streams[Stream].MyCall[calllen] = 0;
+
+ if (Stream) //Leave Stream 0 call alone
+ {
+ TNC->Streams[Stream].CmdSet = TNC->Streams[Stream].CmdSave = zalloc(100);
+ sprintf(TNC->Streams[Stream].CmdSet, "%c%c%cI%s", Stream, 1, 1, TNC->Streams[Stream].MyCall);
+ }
+ }
+ }
+
+ if (TNC->Timeout)
+ {
+ TNC->Timeout--;
+
+ if (TNC->Timeout) // Still waiting
+ return;
+
+ // Can't use retries, as we have no way of detecting lost chars. Have to re-init on timeout
+
+ if (TNC->HostMode == 0 || TNC->ReinitState == 10) // 10 is Recovery Mode
+ {
+ DoTermModeTimeout(TNC);
+ return;
+ }
+
+ // Timed out in host mode - Clear any connection and reinit the TNC
+
+ Debugprintf("DEDHOST - Link to TNC Lost Port %d", TNC->Port);
+ TNC->TNCOK = FALSE;
+
+ TNC->HostMode = 0;
+ TNC->ReinitState = 0;
+
+ CloseCOMPort(TNC->hDevice);
+ OpenCOMMPort(TNC, TNC->PortRecord->PORTCONTROL.SerialPortName, TNC->PortRecord->PORTCONTROL.BAUDRATE, TRUE);
+
+ TNC->InitPtr = TNC->InitScript;
+ TNC->HOSTSTATE = 0;
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream]) // Connected
+ {
+ TNC->Streams[Stream].Connected = FALSE; // Back to Command Mode
+ TNC->Streams[Stream].ReportDISC = TRUE; // Tell Node
+ }
+ }
+ }
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ STREAM = &TNC->Streams[Stream];
+
+ if (STREAM->Attached)
+ CheckForDetach(TNC, Stream, STREAM, TidyClose, ForcedClose, CloseComplete);
+
+ if (TNC->Timeout)
+ return; // We've sent something
+ }
+
+ // if we have just restarted or TNC appears to be in terminal mode, run Initialisation Sequence
+
+ if (!TNC->HostMode)
+ {
+ DoTNCReinit(TNC);
+ return;
+ }
+
+ if (TNC->InitPtr)
+ {
+ char * start, * end;
+ int len;
+
+ start = TNC->InitPtr;
+
+ if (*(start) == 0) // End of Script
+ {
+ TNC->InitPtr = NULL;
+ Debugprintf("TRK - Init Complete Port %d", TNC->Port);
+ }
+ else
+ {
+ end = strchr(start, 13);
+ len = (int)(++end - start - 1); // exclude cr
+
+ TNC->InitPtr = end;
+
+ Poll[0] = 0; // Channel
+ Poll[1] = 1; // Command
+ Poll[2] = len - 1;
+ memcpy(&Poll[3], start, len);
+
+ StuffAndSend(TNC, Poll, len + 3);
+
+ return;
+
+ }
+ }
+
+ for (Stream = 0; Stream <= MaxStreams; Stream++)
+ {
+ if (TNC->Streams[Stream].CmdSet)
+ {
+ char * start, * end;
+ int len;
+
+ start = TNC->Streams[Stream].CmdSet;
+
+ if (*(start + 2) == 0) // End of Script
+ {
+ free(TNC->Streams[Stream].CmdSave);
+ TNC->Streams[Stream].CmdSet = NULL;
+ }
+ else
+ {
+ end = strchr(start + 3, 0);
+ len = (int)(++end - start - 1); // exclude cr
+ TNC->Streams[Stream].CmdSet = end;
+
+ memcpy(&Poll[0], start, len);
+ Poll[2] = len - 4;
+
+ StuffAndSend(TNC, Poll, len);
+
+ return;
+ }
+ }
+ }
+
+ for (nn = 0; nn <= MaxStreams; nn++)
+ {
+ Stream = TNC->LastStream++;
+
+ if (TNC->LastStream > MaxStreams) TNC->LastStream = 0;
+
+ if (TNC->TNCOK && TNC->Streams[Stream].BPQtoPACTOR_Q)
+ {
+ int datalen;
+ UINT * buffptr;
+ char * Buffer;
+
+ buffptr=Q_REM(&TNC->Streams[Stream].BPQtoPACTOR_Q);
+
+ datalen=buffptr[1];
+ Buffer = (char *)&buffptr[2]; // Data portion of frame
+
+ Poll[0] = TNC->Streams[Stream].DEDStream; // Channel
+
+ if (TNC->Streams[Stream].Connected)
+ {
+ if (TNC->SwallowSignon && Stream == 0)
+ {
+ TNC->SwallowSignon = FALSE;
+ if (strstr(Buffer, "Connected")) // Discard *** connected
+ {
+ ReleaseBuffer(buffptr);
+ return;
+ }
+ }
+
+ Poll[1] = 0; // Data
+ TNC->Streams[Stream].BytesTXed += datalen;
+
+ Poll[2] = datalen - 1;
+ memcpy(&Poll[3], buffptr+2, datalen);
+
+ ReleaseBuffer(buffptr);
+
+ StuffAndSend(TNC, Poll, datalen + 3);
+
+ TNC->Streams[Stream].InternalCmd = TNC->Streams[Stream].Connected;
+
+ if (STREAM->Disconnecting && TNC->Streams[Stream].BPQtoPACTOR_Q == 0)
+ TidyClose(TNC, 0);
+
+ return;
+ }
+
+ // Command. Do some sanity checking and look for things to process locally
+
+ Poll[1] = 1; // Command
+ datalen--; // Exclude CR
+
+ if (datalen == 0) // Null Command
+ {
+ ReleaseBuffer(buffptr);
+ return;
+ }
+
+ Buffer[datalen] = 0; // Null Terminate
+ _strupr(Buffer);
+
+ if (_memicmp(Buffer, "D", 1) == 0)
+ {
+ TNC->Streams[Stream].ReportDISC = TRUE; // Tell Node
+ ReleaseBuffer(buffptr);
+ return;
+ }
+
+ if (Buffer[0] == 'C' && datalen > 2) // Connect
+ {
+ if (Stream == 0)
+ {
+ // No connects on Stream zero - for mgmt only
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "TRK} Can't Connect after ATTACH\r");
+ C_Q_ADD(&TNC->Streams[0].PACTORtoBPQ_Q, buffptr);
+
+ return;
+
+ }
+
+ if (*(++Buffer) == ' ') Buffer++; // Space isn't needed
+
+ memcpy(TNC->Streams[Stream].RemoteCall, Buffer, 9);
+
+ TNC->Streams[Stream].Connecting = TRUE;
+
+ TNC->Streams[Stream].CmdSet = TNC->Streams[Stream].CmdSave = zalloc(100);
+
+ sprintf(TNC->Streams[Stream].CmdSet, "%c%c%cI%s%c%c%c%c%s", Stream, 1, 1,
+ TNC->Streams[Stream].MyCall, 0, Stream, 1, 1, (char *)buffptr+8);
+
+ ReleaseBuffer(buffptr);
+
+ TNC->Streams[Stream].InternalCmd = FALSE;
+ return;
+ }
+
+ Poll[2] = datalen - 1;
+ memcpy(&Poll[3], buffptr+2, datalen);
+
+ ReleaseBuffer(buffptr);
+
+ StuffAndSend(TNC, Poll, datalen + 3);
+
+ TNC->Streams[Stream].InternalCmd = TNC->Streams[Stream].Connected;
+
+ return;
+ }
+ }
+
+ if (TNC->TNCOK && TNC->PortRecord->UI_Q)
+ {
+ int datalen;
+ char * Buffer;
+ char CCMD[80] = "C";
+ char Call[12] = " ";
+ struct _MESSAGE * buffptr;
+
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+
+ datalen = buffptr->LENGTH - 7;
+ Buffer = &buffptr->DEST[0]; // Raw Frame
+ Buffer[datalen] = 0;
+
+ TNC->Streams[0].CmdSet = TNC->Streams[0].CmdSave = zalloc(500);
+
+// sprintf(TNC->Streams[Stream].CmdSet, "I%s\r%s\r", TNC->Streams[Stream].MyCall, buffptr+2);
+
+ // Buffer has an ax.25 header, which we need to pick out and set as channel 0 Connect address
+ // before sending the beacon
+
+ ConvFromAX25(Buffer, &Call[1]); // Dest
+ strlop(&Call[1], ' ');
+ strcat(CCMD, Call);
+ Buffer += 14; // Skip Origin
+ datalen -= 7;
+
+ while ((Buffer[-1] & 1) == 0)
+ {
+ ConvFromAX25(Buffer, &Call[1]);
+ strlop(&Call[1], ' ');
+ strcat(CCMD, Call);
+ Buffer += 7; // End of addr
+ datalen -= 7;
+ }
+
+ if (Buffer[0] == 3) // UI
+ {
+ Buffer += 2;
+ datalen -= 2;
+
+ Poll[0] = 0; // UI Channel
+ Poll[1] = 1; // Data
+ Poll[2] = (int)strlen(CCMD) - 1;
+ strcpy(&Poll[3], CCMD);
+ StuffAndSend(TNC, Poll, Poll[2] + 4);
+
+ sprintf(TNC->Streams[0].CmdSet, "%c%c%c%s", 0, 0, 1, Buffer);
+ }
+
+ ReleaseBuffer((UINT *)buffptr);
+ return;
+ }
+
+ // if frames outstanding, issue a poll (but not too often)
+
+ TNC->IntCmdDelay++;
+
+ if (TNC->IntCmdDelay > 10)
+ {
+ TNC->IntCmdDelay = 0;
+
+ Poll[0] = TNC->Streams[0].DEDStream;
+ Poll[1] = 0x1; // Command
+ TNC->Streams[0].InternalCmd = TRUE;
+
+ Poll[2] = 1; // Len-1
+ Poll[3] = '@';
+ Poll[4] = 'B'; // Buffers
+ StuffAndSend(TNC, Poll, 5);
+ return;
+ }
+
+ // Need to poll all channels . Just Poll zero here, the ProcessMessage will poll next
+
+ Poll[0] = 0; // Channel
+ Poll[1] = 0x1; // Command
+ Poll[2] = 0; // Len-1
+ Poll[3] = 'G'; // Poll
+
+ StuffAndSend(TNC, Poll, 4);
+
+ return;
+
+
+ Stream = TNC->StreamtoPoll;
+
+ STREAM = &TNC->Streams[Stream];
+
+ STREAM->IntCmdDelay++;
+
+ if (STREAM->IntCmdDelay > 10)
+ {
+ STREAM->IntCmdDelay = 0;
+
+ if (STREAM->FramesOutstanding)
+ {
+ Poll[0] = STREAM->DEDStream;
+ Poll[1] = 0x1; // Command
+ STREAM->InternalCmd = TRUE;
+
+ Poll[2] = 0; // Len-1
+ Poll[3] = 'L'; // Status
+ StuffAndSend(TNC, Poll, 4);
+
+ return;
+ }
+ }
+
+
+ Poll[0] = Stream; // Channel
+ Poll[1] = 0x1; // Command
+ Poll[2] = 0; // Len-1
+ Poll[3] = 'G'; // Poll
+
+ StuffAndSend(TNC, Poll, 4);
+ STREAM->InternalCmd = FALSE;
+
+ return;
+
+}
+
+static VOID DoTNCReinit(struct TNCINFO * TNC)
+{
+ UCHAR * Poll = TNC->TXBuffer;
+
+ if (TNC->ReinitState == 0)
+ {
+ // Just Starting - Send a TNC Mode Command to see if in Terminal or Host Mode
+
+ TNC->TNCOK = FALSE;
+
+ memcpy(&TNC->TXBuffer[0], "\x18\x1b\r", 2);
+ TNC->TXLen = 2;
+
+ if (WriteCommBlock(TNC) == FALSE)
+ {
+ CloseCOMPort(TNC->hDevice);
+ OpenCOMMPort(TNC, TNC->PortRecord->PORTCONTROL.SerialPortName, TNC->PortRecord->PORTCONTROL.BAUDRATE, TRUE);
+ }
+
+ return;
+ }
+
+ if (TNC->ReinitState == 1) // Forcing back to Term
+ TNC->ReinitState = 0;
+
+ if (TNC->ReinitState == 2) // In Term State, Sending Initialisation Commands
+ {
+ // Put into Host Mode
+
+ memcpy(Poll, "\x18\x1bJHOST1\r", 9);
+
+ TNC->TXLen = 9;
+ WriteCommBlock(TNC);
+
+ TNC->ReinitState = 5;
+ return;
+ }
+
+ if (TNC->ReinitState == 5)
+ TNC->ReinitState = 0;
+
+}
+
+static VOID DoTermModeTimeout(struct TNCINFO * TNC)
+{
+ UCHAR * Poll = TNC->TXBuffer;
+
+ if (TNC->ReinitState == 0)
+ {
+ //Checking if in Terminal Mode - Try to set back to Term Mode
+
+ TNC->ReinitState = 1;
+ ExitHost(TNC);
+
+ return;
+ }
+
+ if (TNC->ReinitState == 1)
+ {
+ // No Response to trying to enter term mode - do error recovery
+
+ Debugprintf("TRK - Starting Resync Port %d", TNC->Port);
+
+ TNC->ReinitState = 10;
+ TNC->ReinitCount = 256;
+ TNC->HostMode = TRUE; // Must be in Host Mode if we need recovery
+
+ Poll[0] = 1;
+ TNC->TXLen = 1;
+ WriteCommBlock(TNC);
+ TNC->Timeout = 10; // 2 secs
+
+ return;
+ }
+
+ if (TNC->ReinitState == 10)
+ {
+ // Continue error recovery
+
+ TNC->ReinitCount--;
+
+ if (TNC->ReinitCount)
+ {
+ Poll[0] = 1;
+ TNC->TXLen = 1;
+ WriteCommBlock(TNC);
+ TNC->Timeout = 3; // 0.3 secs
+
+ return;
+ }
+
+ // Try Again
+
+ Debugprintf("TRK Continuing recovery Port %d", TNC->Port);
+
+ TNC->ReinitState = 0;
+
+ // Close and re-open TNC
+
+ ExitHost(TNC);
+ Sleep(50);
+ CloseCOMPort(TNC->hDevice);
+ TNC->hDevice =(HANDLE) 0;
+ TNC->ReopenTimer = 290;
+ TNC->HostMode = FALSE;
+
+ return;
+ }
+ if (TNC->ReinitState == 3)
+ {
+ // Entering Host Mode
+
+ // Assume ok
+
+ TNC->HostMode = TRUE;
+ TNC->IntCmdDelay = 10;
+
+ return;
+ }
+}
+
+
+static VOID ExitHost(struct TNCINFO * TNC)
+{
+ UCHAR * Poll = TNC->TXBuffer;
+
+ // Try to exit Host Mode
+
+ TNC->TXBuffer[0] = 1;
+ TNC->TXBuffer[1] = 1;
+ TNC->TXBuffer[2] = 1;
+ memcpy(&TNC->TXBuffer[3], "%R", 2);
+
+ StuffAndSend(TNC, Poll, 5);
+
+ return;
+}
+
+static VOID ProcessTermModeResponse(struct TNCINFO * TNC)
+{
+ UCHAR * Poll = TNC->TXBuffer;
+
+ if (TNC->WRITELOG)
+ WriteDebugLogLine(TNC->Port, 'R', TNC->RXBuffer, TNC->RXLen);
+
+ if (TNC->ReinitState == 0)
+ {
+ // Testing if in Term Mode. It is, so can now send Init Commands
+
+ TNC->InitPtr = TNC->InitScript;
+ TNC->ReinitState = 2;
+ }
+
+ if (TNC->ReinitState == 1)
+ {
+ // trying to set term mode
+
+ // If already in Term Mode, TNC echos command, with control chars replaced with '.'
+
+ if (memcmp(TNC->RXBuffer, "....%R", 6) == 0)
+ {
+ // In term mode, Need to put into Host Mode
+
+ TNC->ReinitState = 2;
+ DoTNCReinit(TNC);
+ return;
+ }
+ }
+
+ if (TNC->ReinitState == 2)
+ {
+ // Sending Init Commands
+
+ DoTNCReinit(TNC); // Send Next Command
+ return;
+ }
+
+ if (TNC->ReinitState == 5) // Waiting for response to JHOST1
+ {
+ if (TNC->RXBuffer[TNC->RXLen-1] == 10 || TNC->RXBuffer[TNC->RXLen-1] == 13) // NewLine
+ {
+ TNC->HostMode = TRUE;
+ TNC->Timeout = 0;
+ }
+ return;
+ }
+}
+
+static VOID ProcessDEDFrame(struct TNCINFO * TNC)
+{
+ UINT * buffptr;
+ char * Buffer; // Data portion of frame
+ UINT Stream = 0;
+ UCHAR * Msg = TNC->DEDBuffer;
+ int framelen = TNC->InputLen;
+ struct STREAMINFO * STREAM;
+
+ if (TNC->WRITELOG)
+ WriteDebugLogLine(TNC->Port, 'R', Msg, framelen);
+
+ if (TNC->ReinitState == 10)
+ {
+ // Recovering from Sync Failure
+
+ // Any Response indicates we are in host mode, and back in sync
+
+ TNC->HostMode = TRUE;
+ TNC->Timeout = 0;
+ TNC->ReinitState = 0;
+ TNC->RXLen = 0;
+ TNC->HOSTSTATE = 0;
+ return;
+ }
+
+ // Any valid frame is an ACK
+
+ TNC->Timeout = 0;
+ TNC->TNCOK = TRUE;
+
+ if (TNC->InitPtr) // Response to Init Script
+ return;
+
+ if (TNC->MSGCHANNEL > 26)
+ return;
+
+ Stream = TNC->MSGCHANNEL;
+
+ // See if Poll Reply or Data
+
+ if (TNC->MSGTYPE == 0)
+ {
+ // Success - Nothing Follows
+
+ if (TNC->Streams[Stream].CmdSet)
+ return; // Response to Command Set or Init Script
+
+ if ((TNC->TXBuffer[1] & 1) == 0) // Data
+ return;
+
+ // If the response to a Command, then we should convert to a text "Ok" for forward scripts, etc
+
+ if (TNC->TXBuffer[3] == 'G') // Poll
+ {
+ UCHAR * Poll = TNC->TXBuffer;
+
+ // Poll Next Channel (we need to scan all channels every DEDPOLL cycle
+
+ Stream++;
+
+ if (Stream > MaxStreams)
+ return;
+
+ STREAM = &TNC->Streams[Stream];
+
+ STREAM->IntCmdDelay++;
+
+ if (STREAM->IntCmdDelay > 10)
+ {
+ STREAM->IntCmdDelay = 0;
+
+ if (STREAM->FramesOutstanding)
+ {
+ Poll[0] = STREAM->DEDStream;
+ Poll[1] = 0x1; // Command
+ STREAM->InternalCmd = TRUE;
+
+ Poll[2] = 0; // Len-1
+ Poll[3] = 'L'; // Status
+ StuffAndSend(TNC, Poll, 4);
+ return;
+ }
+ }
+
+ Poll[0] = Stream; // Channel
+ Poll[1] = 0x1; // Command
+ Poll[2] = 0; // Len-1
+ Poll[3] = 'G'; // Poll
+
+ StuffAndSend(TNC, Poll, 4);
+ STREAM->InternalCmd = FALSE;
+
+ return;
+ }
+
+ if (TNC->TXBuffer[3] == 'C') // Connect - reply we need is async
+ return;
+
+ if (TNC->TXBuffer[3] == 'L') // Shouldnt happen!
+ return;
+
+
+ if (TNC->TXBuffer[3] == 'J') // JHOST
+ {
+ if (TNC->TXBuffer[8] == '0') // JHOST0
+ {
+ TNC->Timeout = 1; //
+ return;
+ }
+ }
+
+ if (TNC->MSGCHANNEL == 0) // Unproto Channel
+ return;
+
+ buffptr = GetBuff();
+
+ if (buffptr == NULL) return; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2],"TRK} Ok\r");
+
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+
+ return;
+ }
+
+ if (TNC->MSGTYPE > 0 &&TNC->MSGTYPE < 6)
+ {
+ // Success with message - null terminated
+
+ char * ptr;
+ int len;
+
+ Buffer = Msg;
+
+ ptr = strchr(Buffer, 0);
+
+ if (ptr == 0)
+ return;
+
+ *(ptr++) = 13;
+ *(ptr) = 0;
+
+ len = (int)(ptr - Buffer);
+
+ if (len > 256)
+ return;
+
+ // See if we need to process locally (Response to our command, Incoming Call, Disconencted, etc
+
+ if (TNC->MSGTYPE < 3) // 1 or 2 - Success or Fail
+ {
+ // See if a response to internal command
+
+ if (TNC->Streams[Stream].InternalCmd)
+ {
+ // Process it
+
+ char LastCmd = TNC->TXBuffer[3];
+
+ if (LastCmd == 'L') // Status
+ {
+ int s1, s2, s3, s4, s5, s6, num;
+
+ num = sscanf(Buffer, "%d %d %d %d %d %d", &s1, &s2, &s3, &s4, &s5, &s6);
+
+ TNC->Streams[Stream].FramesOutstanding = s3;
+ return;
+ }
+
+ if (LastCmd == '@') // @ Commands
+ {
+ if (TNC->TXBuffer[4]== 'B') // Buffer Status
+ {
+ TNC->Buffers = atoi(Buffer);
+// SetDlgItemText(TNC->hDlg, IDC_BUFFERS, Buffer);
+ return;
+ }
+ }
+
+ return;
+ }
+
+ // Not Internal Command, so send to user
+
+ if (TNC->Streams[Stream].CmdSet)
+ return; // Response to Command Set
+
+ if ((TNC->TXBuffer[1] & 1) == 0) // Data
+ return;
+
+ // If the response to a Command, then we should convert to a text "Ok" for forward scripts, etc
+
+ if (TNC->TXBuffer[3] == 'G') // Poll
+ return;
+
+ if (TNC->TXBuffer[3] == 'C') // Connect - reply we need is async
+ return;
+
+ if (TNC->TXBuffer[3] == 'L') // Shouldnt happen!
+ return;
+
+ if (TNC->TXBuffer[3] == 'J') // JHOST
+ {
+ if (TNC->TXBuffer[8] == '0') // JHOST0
+ {
+ TNC->Timeout = 1; //
+ return;
+ }
+ }
+
+ if (TNC->MSGCHANNEL == 0) // Unproto Channel
+ return;
+
+ buffptr = GetBuff();
+
+ if (buffptr == NULL) return; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2],"TRK} %s", Buffer);
+
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+
+ return;
+ }
+
+ if (TNC->MSGTYPE == 3) // Status
+ {
+ struct STREAMINFO * STREAM = &TNC->Streams[Stream];
+
+ if (strstr(Buffer, "DISCONNECTED") || strstr(Buffer, "LINK FAILURE") || strstr(Buffer, "BUSY"))
+ {
+ if ((STREAM->Connecting | STREAM->Connected) == 0)
+ return;
+
+ if (STREAM->Connecting && STREAM->Disconnecting == FALSE)
+ {
+ // Connect Failed
+
+ buffptr = GetBuff();
+ if (buffptr == 0) return; // No buffers, so ignore
+
+ if (strstr(Buffer, "BUSY"))
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "*** Busy from %s\r", TNC->Streams[Stream].RemoteCall);
+ else
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "*** Failure with %s\r", TNC->Streams[Stream].RemoteCall);
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ STREAM->Connecting = FALSE;
+ STREAM->Connected = FALSE; // In case!
+ STREAM->FramesOutstanding = 0;
+
+ STREAM->DiscWhenAllSent = 15; // Dont want to leave session attached. Causes too much confusion
+
+ return;
+ }
+
+ // Must Have been connected or disconnecting - Release Session
+
+ STREAM->Connecting = FALSE;
+ STREAM->Connected = FALSE; // Back to Command Mode
+ STREAM->FramesOutstanding = 0;
+
+ if (STREAM->Disconnecting == FALSE)
+ STREAM->ReportDISC = TRUE; // Tell Node
+
+ STREAM->Disconnecting = FALSE;
+ return;
+ }
+
+ if (strstr(Buffer, "CONNECTED"))
+ {
+ char * Call = strstr(Buffer, " to ");
+ char * ptr;
+ char MHCall[30];
+
+ Call += 4;
+
+ if (Call[1] == ':')
+ Call +=2;
+
+ ptr = strchr(Call, ' ');
+ if (ptr) *ptr = 0;
+
+ ptr = strchr(Call, 13);
+ if (ptr) *ptr = 0;
+
+ STREAM->Connected = TRUE; // Subsequent data to data channel
+ STREAM->Connecting = FALSE;
+
+ STREAM->BytesRXed = STREAM->BytesTXed = 0;
+
+ memcpy(MHCall, Call, 9);
+ MHCall[9] = 0;
+
+ if (TNC->PortRecord->ATTACHEDSESSIONS[Stream] == 0)
+ {
+ // Incoming Connect
+
+// APPLCALLS * APPL;
+// char * ApplPtr = &APPLS;
+// int App;
+// char Appl[10];
+// char DestCall[10];
+
+ UpdateMH(TNC, MHCall, '+', 'I');
+
+ ProcessIncommingConnect(TNC, Call, Stream, TRUE);
+
+ if (FULL_CTEXT && HFCTEXTLEN == 0)
+ {
+ int Len = CTEXTLEN, CTPaclen = 100;
+ int Next = 0;
+
+ while (Len > CTPaclen) // CTEXT Paclen
+ {
+ buffptr = GetBuff();
+ if (buffptr == 0) return; // No buffers, so ignore
+
+ buffptr[1] = CTPaclen;
+ memcpy(&buffptr[2], &CTEXTMSG[Next], CTPaclen);
+ C_Q_ADD(&STREAM->BPQtoPACTOR_Q, buffptr);
+
+ Next += CTPaclen;
+ Len -= CTPaclen;
+ }
+
+ buffptr = GetBuff();
+ if (buffptr == 0) return; // No buffers, so ignore
+
+ buffptr[1] = Len;
+ memcpy(&buffptr[2], &CTEXTMSG[Next], Len);
+ C_Q_ADD(&STREAM->BPQtoPACTOR_Q, buffptr);
+ }
+
+ return;
+ }
+ else
+ {
+ // Connect Complete
+
+ buffptr = GetBuff();
+ if (buffptr == 0) return; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2], "*** Connected to %s\r", Call);;
+
+ C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr);
+
+ }
+ }
+ return;
+ }
+
+ if (TNC->MSGTYPE == 4 || TNC->MSGTYPE == 5)
+ {
+ struct STREAMINFO * STREAM = &TNC->Streams[0]; // RP Stream
+
+ // Monitor
+
+/*
+ if (TNC->UseAPPLCalls && strstr(&Msg[4], "SABM") && STREAM->Attached == FALSE)
+ {
+ // See if a call to Nodecall or one of our APPLCALLS - if so, stop scan and switch MYCALL
+
+ char DestCall[10] = "NOCALL ";
+ char * ptr1 = strstr(&Msg[7], "to ");
+ int i;
+ APPLCALLS * APPL;
+ char Appl[11];
+ char Status[80];
+
+ if (ptr1) memcpy(DestCall, &ptr1[3], 10);
+
+ ptr1 = strchr(DestCall, ' ');
+ if (ptr1) *(ptr1) = 0; // Null Terminate
+
+ Debugprintf("RP SABM Received for %s" , DestCall);
+
+ if (strcmp(TNC->NodeCall, DestCall) != 0)
+ {
+ // Not Calling NodeCall/Portcall
+
+ if (strcmp(NodeCall, DestCall) == 0)
+ goto SetThisCall;
+
+ // See if to one of our ApplCalls
+
+ for (i = 0; i < 32; i++)
+ {
+ APPL=&APPLCALLTABLE[i];
+
+ if (APPL->APPLCALL_TEXT[0] > ' ')
+ {
+ char * ptr;
+ memcpy(Appl, APPL->APPLCALL_TEXT, 10);
+ ptr=strchr(Appl, ' ');
+
+ if (ptr) *ptr = 0;
+
+ if (strcmp(Appl, DestCall) == 0)
+ {
+ SetThisCall:
+ Debugprintf("RP SABM is for NODECALL or one of our APPLCalls - setting MYCALL to %s and pausing scan", DestCall);
+
+ sprintf(Status, "%d SCANSTART 60", TNC->Port); // Pause scan for 60 secs
+ Rig_Command(-1, Status);
+ TNC->SwitchToPactor = 600; // Don't change modes for 60 secs
+
+ strcpy(STREAM->MyCall, DestCall);
+ STREAM->CmdSet = STREAM->CmdSave = zalloc(100);
+ sprintf(STREAM->CmdSet, "I%s\r", DestCall);
+ break;
+ }
+ }
+ }
+ }
+ }
+*/
+ DoMonitorHddr(TNC, Msg, framelen, TNC->MSGTYPE);
+ return;
+
+ }
+
+ // 1, 2, 4, 5 - pass to Appl
+
+ if (TNC->MSGCHANNEL == 0) // Unproto Channel
+ return;
+
+ buffptr = GetBuff();
+
+ if (buffptr == NULL) return; // No buffers, so ignore
+
+ buffptr[1] = sprintf((UCHAR *)&buffptr[2],"Trk} %s", &Msg[4]);
+
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+
+ return;
+ }
+
+ if (TNC->MSGTYPE == 6)
+ {
+ // Monitor Data With length)
+
+ DoMonitorData(TNC, Msg, framelen);
+ return;
+ }
+
+ if (TNC->MSGTYPE == 7)
+ {
+ //char StatusMsg[60];
+ //int Status, ISS, Offset;
+
+ // Connected Data
+
+ buffptr = GetBuff();
+
+ if (buffptr == NULL) return; // No buffers, so ignore
+
+ buffptr[1] = framelen; // Length
+ TNC->Streams[Stream].BytesRXed += buffptr[1];
+ memcpy(&buffptr[2], Msg, buffptr[1]);
+
+ C_Q_ADD(&TNC->Streams[Stream].PACTORtoBPQ_Q, buffptr);
+
+ return;
+ }
+}
+
+VOID TidyClose(struct TNCINFO * TNC, int Stream)
+{
+ // Queue it as we may have just sent data
+
+ TNC->Streams[Stream].CmdSet = TNC->Streams[Stream].CmdSave = zalloc(100);
+ sprintf(TNC->Streams[Stream].CmdSet, "%c%c%cD", Stream, 1, 1);
+}
+
+
+VOID ForcedClose(struct TNCINFO * TNC, int Stream)
+{
+ TidyClose(TNC, Stream); // I don't think Hostmode has a DD
+}
+
+VOID CloseComplete(struct TNCINFO * TNC, int Stream)
+{
+}
+
+
diff --git a/TNCCode.c b/TNCCode.c
index 37cd8e2..5103cfe 100644
--- a/TNCCode.c
+++ b/TNCCode.c
@@ -322,7 +322,10 @@ Dll VOID APIENTRY Send_AX(UCHAR * Block, DWORD Len, UCHAR Port)
EXTPORTDATA * EXTPORT = (EXTPORTDATA *) PORT;
- C_Q_ADD(&EXTPORT->UI_Q, Copy);
+ if (EXTPORT->UI_Q)
+ C_Q_ADD(&EXTPORT->UI_Q, Copy);
+ else
+ C_Q_ADD(&EXTPORT->UI_Q, Copy);
return;
}
diff --git a/TNCEmulators.c b/TNCEmulators.c
index 135d318..7fce453 100644
--- a/TNCEmulators.c
+++ b/TNCEmulators.c
@@ -241,8 +241,14 @@ typedef struct _SERIAL_STATUS {
#ifndef WIN32
-#ifdef MACBPQ
+#if defined(MACBPQ)
#include <util.h>
+#elif defined(FREEBSD)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#include <libutil.h>
+#else
+#include <util.h>
+#endif
#endif
extern int posix_openpt (int __oflag);
@@ -262,7 +268,7 @@ HANDLE LinuxOpenPTY(char * Name)
u_long param=1;
struct termios term;
-#ifdef MACBPQ
+#if defined(MACBPQ) || defined(FREEBSD)
// Create a pty pair
diff --git a/TelnetV6.c b/TelnetV6.c
index 62b0885..a0a0272 100644
--- a/TelnetV6.c
+++ b/TelnetV6.c
@@ -1498,6 +1498,8 @@ void * TelnetExtInit(EXTPORTDATA * PortEntry)
PortEntry->PORTCONTROL.TNC = TNC;
+ PortEntry->PORTCONTROL.Hardware = TNC->Hardware;
+
TNC->WebWindowProc = WebProc;
TNC->WebWinX = 260;
TNC->WebWinY = 325;
@@ -6342,77 +6344,101 @@ int TCPConnect(struct TNCINFO * TNC, struct TCPINFO * TCP, struct STREAMINFO * S
struct ConnectionInfo * sockptr;
SOCKET sock;
struct sockaddr_in sinx;
- struct sockaddr_in destaddr;
int addrlen=sizeof(sinx);
- int i;
+ char PortString[20];
+ struct addrinfo hints, *res = 0, *saveres;
- sockptr = STREAM->ConnectionInfo;
-
- sock = sockptr->socket = socket(AF_INET, SOCK_STREAM, 0);
- if (sock == INVALID_SOCKET)
- {
- ReportError(STREAM, "Create Socket Failed");
- return FALSE;
- }
-
- sockptr->SocketActive = TRUE;
- sockptr->InputLen = 0;
- sockptr->LoginState = 2;
- sockptr->UserPointer = 0;
- sockptr->DoEcho = FALSE;
+ sprintf(PortString, "%d", Port);
- sockptr->FBBMode = FBB; // Raw Data
+ // get host info, make socket, and connect it
- if (sockptr->ADIF == NULL)
- sockptr->ADIF = malloc(sizeof(struct ADIF));
+ memset(&hints, 0, sizeof hints);
- memset(sockptr->ADIF, 0, sizeof(struct ADIF));
+ if (TCP->IPV6 == 0 && TCP->IPV4)
+ hints.ai_family = AF_INET;
+ else if (TCP->IPV4 == 0 && TCP->IPV6)
+ hints.ai_family = AF_INET6;
+ else if (TCP->IPV4 && TCP->IPV6)
+ hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever
-
- // Resolve Name if needed
+ else
+ {
+ ReportError(STREAM, "Neither IPv4 nor IPv5 are enabled");
+ return FALSE; // Resolve failed
+ }
- sockptr->sin.sin_family = AF_INET;
- sockptr->sin.sin_port = htons(Port);
- sockptr->sin.sin_addr.s_addr = inet_addr(Host);
+ hints.ai_socktype = SOCK_STREAM;
+ getaddrinfo(Host, PortString, &hints, &res);
- if (sockptr->sin.sin_addr.s_addr == INADDR_NONE)
+ if (!res)
{
- struct hostent * HostEnt;
+ char Msg[256];
+ err = WSAGetLastError();
+ sprintf(Msg, "Resolve HostName Failed - Error %d", err);
+ ReportError(STREAM, Msg);
+ return FALSE; // Resolve failed
+ }
- // Resolve name to address
+ // Step thorough the list of hosts
- HostEnt = gethostbyname(Host);
-
- if (!HostEnt)
+ saveres = res; // Save for free
+
+/* if (res->ai_next) // More than one
+ {
+ int n = ISHostIndex;
+
+ while (n && res->ai_next)
{
- ReportError(STREAM, "Resolve HostName Failed");
- return FALSE; // Resolve failed
+ res = res->ai_next;
+ n--;
}
- i = 0;
- while (HostEnt->h_addr_list[i] != 0)
+
+ if (n)
{
- struct in_addr addr;
- addr.s_addr = *(u_long *) HostEnt->h_addr_list[i++];
+ // We have run off the end of the list
+
+ ISHostIndex = 0; // Back to start
+ res = saveres;
}
- memcpy(&sockptr->sin.sin_addr.s_addr, HostEnt->h_addr, 4);
+ else
+ ISHostIndex++;
+
}
+*/
+// getnameinfo(res->ai_addr, (int)res->ai_addrlen, RealISHost, 256, serv, 256, 0);
- ioctl (sockptr->socket, FIONBIO, &param);
-
- setsockopt (sockptr->socket, SOL_SOCKET, SO_REUSEADDR, (const char FAR *)&bcopt,4);
+ sockptr = STREAM->ConnectionInfo;
+
+ sock = sockptr->socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- sinx.sin_family = AF_INET;
- sinx.sin_addr.s_addr = INADDR_ANY;
- sinx.sin_port = 0;
+ sockptr->SocketActive = TRUE;
+ sockptr->InputLen = 0;
+ sockptr->LoginState = 2;
+ sockptr->UserPointer = 0;
+ sockptr->DoEcho = FALSE;
+ sockptr->FBBMode = FBB; // Raw Data
- if (bind(sockptr->socket, (struct sockaddr *) &sinx, addrlen) != 0 )
+ if (sockptr->ADIF == NULL)
+ sockptr->ADIF = malloc(sizeof(struct ADIF));
+
+ memset(sockptr->ADIF, 0, sizeof(struct ADIF));
+
+
+ if (sock == INVALID_SOCKET)
{
- ReportError(STREAM, "Bind Failed");
- return FALSE;
+ ReportError(STREAM, "Create Socket Failed");
+ return FALSE;
}
+ ioctl (sock, FIONBIO, &param);
+
+ setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (const char FAR *)&bcopt,4);
+
+// memcpy(work, res->ai_addr->sa_data, 4);
+
+
if (LogEnabled)
{
char logmsg[512];
@@ -6421,21 +6447,21 @@ int TCPConnect(struct TNCINFO * TNC, struct TCPINFO * TCP, struct STREAMINFO * S
WriteLog (logmsg);
}
-
- if (connect(sockptr->socket,(struct sockaddr *) &sockptr->sin, sizeof(destaddr)) == 0)
+ if (connect(sock, res->ai_addr, (int)res->ai_addrlen) == 0)
{
//
// Connected successful
//
ReportError(STREAM, "*** Connected");
-
- // Get Send Buffer Size
+ freeaddrinfo(saveres);
return TRUE;
}
else
{
+ freeaddrinfo(saveres);
+
err=WSAGetLastError();
if (err == 10035 || err == 115 || err == 36) //EWOULDBLOCK
@@ -6461,7 +6487,6 @@ int TCPConnect(struct TNCINFO * TNC, struct TCPINFO * TCP, struct STREAMINFO * S
}
return FALSE;
-
}
diff --git a/UZ7HODrv.c b/UZ7HODrv.c
index 8c36e2b..ac33278 100644
--- a/UZ7HODrv.c
+++ b/UZ7HODrv.c
@@ -685,6 +685,11 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff)
ConnecttoUZ7HO(port);
lasttime[port] = ltime;
}
+ while (TNC->PortRecord->UI_Q)
+ {
+ buffptr = Q_REM(&TNC->PortRecord->UI_Q);
+ ReleaseBuffer(buffptr);
+ }
}
else
{
diff --git a/VARA.c b/VARA.c
index 4d46984..4574fa4 100644
--- a/VARA.c
+++ b/VARA.c
@@ -1720,7 +1720,6 @@ VConnected:
GetSemaphore(&Semaphore, 52);
VARAProcessReceivedControl(TNC);
FreeSemaphore(&Semaphore);
- Debugprintf("VARA Returned from processing control packet");
}
if (FD_ISSET(TNC->TCPDataSock, &readfs))
diff --git a/Versions.h b/Versions.h
index bf6fb8a..061e9eb 100644
--- a/Versions.h
+++ b/Versions.h
@@ -10,14 +10,15 @@
#endif
-#define KVers 6,0,24,66
-#define KVerstring "6.0.24.66\0"
+#define KVers 6,0,24,77
+#define KVerstring "6.0.24.77\0"
+
#ifdef CKernel
#define Vers KVers
#define Verstring KVerstring
-#define Datestring "February 2025"
+#define Datestring "July 2025"
#define VerComments "G8BPQ Packet Switch (C Version)" KVerstring
#define VerCopyright "Copyright © 2001-2025 John Wiseman G8BPQ\0"
#define VerDesc "BPQ32 Switch\0"
diff --git a/WINMOR.c b/WINMOR.c
index f0f9d98..2a3d766 100644
--- a/WINMOR.c
+++ b/WINMOR.c
@@ -139,6 +139,10 @@ VOID WritetoTraceSupport(struct TNCINFO * TNC, char * Msg, int Len)
int LineLen, i;
UCHAR Save;
int SaveLen = Len;
+ char Time[16];
+ time_t T;
+ struct tm * tm;
+
if (Len < 0)
return;
@@ -206,10 +210,16 @@ lineloop:
#endif
// Write to Web Buffer
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ sprintf_s(Time, sizeof(Time),"%02d:%02d ", tm->tm_hour, tm->tm_min);
+
+ strcat(TNC->WebBuffer, Time);
strcat(TNC->WebBuffer, Line);
strcat(TNC->WebBuffer, "\r\n");
if (strlen(TNC->WebBuffer) > 4500)
- memmove(TNC->WebBuffer, &TNC->WebBuffer[500], 4490); // Make sure null is moved
+ memmove(TNC->WebBuffer, &TNC->WebBuffer[500], strlen(&TNC->WebBuffer[500]) + 1); // Make sure null is moved
Skip:
ptr1 = ptr2;
@@ -248,10 +258,16 @@ lineloop:
#else
index=SendMessage(TNC->hMonitor, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) ptr1 );
#endif
+ T = time(NULL);
+ tm = gmtime(&T);
+
+ sprintf_s(Time, sizeof(Time),"%02d:%02d ", tm->tm_hour, tm->tm_min);
+ strcat(TNC->WebBuffer, Time);
+
strcat(TNC->WebBuffer, ptr1);
strcat(TNC->WebBuffer, "\r\n");
if (strlen(TNC->WebBuffer) > 4500)
- memmove(TNC->WebBuffer, &TNC->WebBuffer[500], 4490); // Make sure null is moved
+ memmove(TNC->WebBuffer, &TNC->WebBuffer[500], strlen(&TNC->WebBuffer[500]) + 1); // Make sure null is moved
}
}
diff --git a/WPRoutines.c b/WPRoutines.c
index 0658ecc..f703662 100644
--- a/WPRoutines.c
+++ b/WPRoutines.c
@@ -37,6 +37,7 @@ VOID Do_Save_WPRec(HWND hDlg);
VOID SaveInt64Value(config_setting_t * group, char * name, long long value);
VOID SaveIntValue(config_setting_t * group, char * name, int value);
VOID SaveStringValue(config_setting_t * group, char * name, char * value);
+BOOL GetStringValue(config_setting_t * group, char * name, char * value, int maxlen);
void MQTTMessageEvent(void* message);
WPRec * AllocateWPRecord()
diff --git a/WebMail.c b/WebMail.c
index a3ff5b1..2c97f84 100644
--- a/WebMail.c
+++ b/WebMail.c
@@ -1446,7 +1446,12 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL
// Neither do js or file downloads
- if (_memicmp(NodeURL, "/WebMail/WMFile/", 16) == 0)
+ // This could be a request for a Template file
+ // WebMail/Local_Templates/My Forms/inc/logo_ad63.png
+ // WebMail/Standard Templates/
+
+
+ if (_memicmp(NodeURL, "/WebMail/Local", 14) == 0 || (_memicmp(NodeURL, "/WebMail/Standard", 17) == 0))
{
int FileSize;
char * MsgBytes;
@@ -1456,9 +1461,10 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL
char TimeString[64];
char FileTimeString[64];
struct stat STAT;
- char * FN = &NodeURL[16];
+ char * FN = &NodeURL[9];
char * fileBit = FN;
char * ext;
+ char Type[64] = "Content-Type: text/html\r\n";
UndoTransparency(FN);
ext = strchr(FN, '.');
@@ -1491,27 +1497,112 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL
FormatTime2(FileTimeString, STAT.st_ctime);
FormatTime2(TimeString, time(NULL));
- if (_stricmp(ext, ".htm") == 0 || _stricmp(ext, ".html") == 0 || _stricmp(ext, ".css") == 0 || _stricmp(ext, ".js") == 0)
- {
- *RLen = sprintf(Reply, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n"
- "Content-Type: text/css\r\n"
+ ext++;
+
+ if (_stricmp(ext, "js") == 0)
+ strcpy(Type, "Content-Type: text/javascript\r\n");
+
+ if (_stricmp(ext, "css") == 0)
+ strcpy(Type, "Content-Type: text/css\r\n");
+
+ if (_stricmp(ext, "pdf") == 0)
+ strcpy(Type, "Content-Type: application/pdf\r\n");
+
+ if (_stricmp(ext, "jpg") == 0 || _stricmp(ext, "jpeg") == 0 || _stricmp(ext, "png") == 0 ||
+ _stricmp(ext, "gif") == 0 || _stricmp(ext, "bmp") == 0 || _stricmp(ext, "ico") == 0)
+ strcpy(Type, "Content-Type: image\r\n");
+
+ // File may be binary so output header then copy in message
+
+ *RLen = sprintf(Reply, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n"
+ "%s"
"Date: %s\r\n"
"Last-Modified: %s\r\n"
- "\r\n%s", FileSize, TimeString, FileTimeString, MsgBytes);
+ "\r\n", FileSize, Type,TimeString, FileTimeString);
+
+ memcpy(&Reply[*RLen], MsgBytes, FileSize);
+ *RLen += FileSize;
+ free (MsgBytes);
+ return;
+ }
+
+ //
+
+ if (_memicmp(NodeURL, "/WebMail/WMFile/", 16) == 0)
+ {
+ int FileSize;
+ char * MsgBytes;
+ char MsgFile[512];
+ FILE * hFile;
+ size_t ReadLen;
+ char TimeString[64];
+ char FileTimeString[64];
+ struct stat STAT;
+ char * FN = &NodeURL[16];
+ char * fileBit = FN;
+ char * ext;
+ char Type[64] = "Content-Type: text/html\r\n";
+
+
+ UndoTransparency(FN);
+ ext = strchr(FN, '.');
+
+ sprintf(MsgFile, "%s/%s", BPQDirectory, FN);
+
+ while (strchr(fileBit, '/'))
+ fileBit = strlop(fileBit, '/');
+
+ if (stat(MsgFile, &STAT) == -1)
+ {
+ *RLen = sprintf(Reply, "HTTP/1.1 404 Not Found\r\nContent-Length: 16\r\n\r\nPage not found\r\n");
+ return;
}
- else
+
+ hFile = fopen(MsgFile, "rb");
+
+ if (hFile == 0)
{
- *RLen = sprintf(Reply, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n"
- "Content-Type: application/octet-stream\r\n"
- "Content-Disposition: attachment; filename=\"%s\"\r\n"
+ *RLen = sprintf(Reply, "HTTP/1.1 404 Not Found\r\nContent-Length: 16\r\n\r\nPage not found\r\n");
+ return;
+ }
+
+ FileSize = STAT.st_size;
+ MsgBytes = malloc(FileSize + 1);
+ ReadLen = fread(MsgBytes, 1, FileSize, hFile);
+
+ fclose(hFile);
+
+ FormatTime2(FileTimeString, STAT.st_ctime);
+ FormatTime2(TimeString, time(NULL));
+
+ ext++;
+
+ if (_stricmp(ext, "js") == 0)
+ strcpy(Type, "Content-Type: text/javascript\r\n");
+
+ if (_stricmp(ext, "css") == 0)
+ strcpy(Type, "Content-Type: text/css\r\n");
+
+ if (_stricmp(ext, "pdf") == 0)
+ strcpy(Type, "Content-Type: application/pdf\r\n");
+
+ if (_stricmp(ext, "jpg") == 0 || _stricmp(ext, "jpeg") == 0 || _stricmp(ext, "png") == 0 ||
+ _stricmp(ext, "gif") == 0 || _stricmp(ext, "bmp") == 0 || _stricmp(ext, "ico") == 0)
+ strcpy(Type, "Content-Type: image\r\n");
+
+ // File may be binary so output header then copy in message
+
+ *RLen = sprintf(Reply, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n"
+ "%s"
"Date: %s\r\n"
"Last-Modified: %s\r\n"
- "\r\n%s", FileSize, fileBit, TimeString, FileTimeString, MsgBytes);
+ "\r\n", FileSize, Type,TimeString, FileTimeString);
- }
+ memcpy(&Reply[*RLen], MsgBytes, FileSize);
+ *RLen += FileSize;
free (MsgBytes);
return;
- }
+ }
Session = NULL;
@@ -2731,6 +2822,18 @@ VOID SaveNewMessage(struct HTTPConnectionInfo * Session, char * MsgPtr, char * R
strcpy(Msg->via, ToUser->HomeBBS);
sprintf(Prompt, "%s added from HomeBBS. Message Saved", Msg->via);
}
+ else
+ {
+ // No HomeBBS - check WP
+
+ WPRecP WP = LookupWP(Msg->to);
+
+ if (WP)
+ {
+ strcpy(Msg->via, WP->first_homebbs);
+ sprintf(Prompt, "%s added from WP", Msg->via);
+ }
+ }
}
else
{
@@ -2883,7 +2986,7 @@ VOID SaveNewMessage(struct HTTPConnectionInfo * Session, char * MsgPtr, char * R
// RMS Express Forms Support
-char * GetHTMLViewerTemplate(char * FN)
+char * GetHTMLViewerTemplate(char * FN, struct HtmlFormDir ** FormDir)
{
int i, j, k, l;
@@ -2897,6 +3000,7 @@ char * GetHTMLViewerTemplate(char * FN)
{
if (strcmp(FN, Dir->Forms[j]->FileName) == 0)
{
+ *FormDir = Dir;
return CheckFile(Dir, FN);
}
}
@@ -2917,6 +3021,7 @@ char * GetHTMLViewerTemplate(char * FN)
{
if (_stricmp(FN, SDir->Forms[k]->FileName) == 0)
{
+ *FormDir = SDir;
return CheckFile(SDir, SDir->Forms[k]->FileName);
}
}
@@ -2980,6 +3085,13 @@ VOID GetPage(struct HTTPConnectionInfo * Session, char * NodeURL)
ptr = strchr(&NodeURL[17], ',');
Dir = HtmlFormDirs[DirNo];
+
+ if (DirNo == -1)
+ {
+ *WebMail->RLen = sprintf(WebMail->Reply, "<html><script>alert(\"No Page Selected. \");window.location.href = '/Webmail/NewMsg?%s';</script></html>", Session->Key);
+ return;
+ }
+
SubDir = strlop(&NodeURL[17], ':');
if (SubDir)
{
@@ -3293,6 +3405,13 @@ BOOL ParseXML(WebMailInfo * WebMail, char * XMLOrig)
// Extract Fields (stuff between < and >. Ignore Whitespace between fields
+ // Add FormFolder Key with our folder
+
+// XMLKeys->Key = "FormFolder";
+// XMLKeys->Value = _strdup(FormDir);
+
+// XMLKeys++;
+
ptr1 = strstr(XML, "<xml_file_version>");
while (ptr1)
@@ -3396,6 +3515,8 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch
size_t varlen, xmllen;
char var[100] = "<";
KeyValues * KeyValue;
+ struct HtmlFormDir * Dir;
+ char FormDir[MAX_PATH];
if (ParseXML(WebMail, XML))
ptr = FindXMLVariable(WebMail, "display_form");
@@ -3409,7 +3530,11 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch
strcpy(FN, ptr);
- Form = GetHTMLViewerTemplate(FN);
+ Form = GetHTMLViewerTemplate(FN, &Dir);
+
+ sprintf(FormDir, "WMFile/%s/%s/", Dir->FormSet, Dir->DirName);
+
+
if (Form == NULL)
{
@@ -3425,6 +3550,15 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch
// Don't know why, but {MsgOriginalBody} is sent instead of {var MsgOriginalBody}
+ // So is {FormFolder} instread of {var FormFolder}
+
+ // As a fiddle replace {FormFolder} with {var Folder} and look for that
+
+ while (varptr = stristr(Form, "{FormFolder}"))
+ {
+ memcpy(varptr, "{var ", 5);
+ }
+
varptr = stristr(Form, "{MsgOriginalBody}");
{
char * temp, * tempsave;
@@ -3564,6 +3698,23 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch
while (KeyValue->Key)
{
+ if (_stricmp(var, "Folder") == 0)
+ {
+ // Local form folder, not senders
+
+ xmllen = strlen(FormDir);
+
+ // Ok, we have the position of the variable and the substitution text.
+ // Copy message up to variable to Result, then copy value
+
+ memcpy(Reply, formptr, varptr - formptr - 5); // omit "{var "
+ Reply += (varptr - formptr - 5);
+
+ strcpy(Reply, FormDir);
+ Reply += xmllen;
+ break;
+ }
+
if (_stricmp(var, KeyValue->Key) == 0)
{
xmllen = strlen(KeyValue->Value);
@@ -3579,6 +3730,8 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch
break;
}
+ KeyValue++;
+
if (KeyValue->Key == NULL)
{
// Not found in XML
@@ -3588,7 +3741,7 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch
sprintf(Err, VarNotFoundMsg, var, "%s");
return ReturnRawMessage(User, Msg, Key, SaveReply, RawMessage, (int)(XML - RawMessage), Err);
}
- KeyValue++;
+
}
formptr = endptr + 1;
@@ -4098,6 +4251,18 @@ VOID SaveTemplateMessage(struct HTTPConnectionInfo * Session, char * MsgPtr, cha
strcpy(Msg->via, ToUser->HomeBBS);
sprintf(Prompt, "%s added from HomeBBS. Message Saved", Msg->via);
}
+ else
+ {
+ // No HomeBBS - Check WP
+
+ WPRecP WP = LookupWP(Msg->to);
+
+ if (WP)
+ {
+ strcpy(Msg->via, WP->first_homebbs);
+ sprintf(Prompt, "%s added from WP", Msg->via);
+ }
+ }
}
else
{
@@ -4318,6 +4483,18 @@ VOID BuildMessageFromHTMLInput(struct HTTPConnectionInfo * Session, char * Reply
strcpy(Msg->via, ToUser->HomeBBS);
sprintf(Prompt, "%s added from HomeBBS", Msg->via);
}
+ else
+ {
+ // No HomeBBS - Check WP
+
+ WPRecP WP = LookupWP(Msg->to);
+
+ if (WP)
+ {
+ strcpy(Msg->via, WP->first_homebbs);
+ sprintf(Prompt, "%s added from WP", Msg->via);
+ }
+ }
}
else
{
@@ -5448,8 +5625,6 @@ char * CheckFile(struct HtmlFormDir * Dir, char * FN)
#endif
- printf("%s\n", MsgFile);
-
if (stat(MsgFile, &STAT) != -1)
{
hFile = fopen(MsgFile, "rb");
@@ -5466,8 +5641,6 @@ char * CheckFile(struct HtmlFormDir * Dir, char * FN)
MsgBytes[FileSize] = 0;
fclose(hFile);
- printf("%d %s\n", strlen(MsgBytes), MsgBytes);
-
return MsgBytes;
}
return NULL;
diff --git a/WinRPR.c b/WinRPR.c
index fd4fb94..f2d8791 100644
--- a/WinRPR.c
+++ b/WinRPR.c
@@ -1580,8 +1580,6 @@ TNCRunning:
// Send INIT script
- // VARA needs each command in a separate send
-
ptr1 = &TNC->InitScript[0];
GetSemaphore(&Semaphore, 52);
@@ -1606,7 +1604,6 @@ TNCRunning:
c = *(ptr2 + 1); // Save next char
*(ptr2 + 1) = 0; // Terminate string
}
-// VARASendCommand(TNC, ptr1, TRUE);
if (ptr2)
*(1 + ptr2++) = c; // Put char back
diff --git a/asmstrucs.h b/asmstrucs.h
index 343ea83..79e9a26 100644
--- a/asmstrucs.h
+++ b/asmstrucs.h
@@ -176,8 +176,6 @@ typedef struct _TRANSPORTENTRY
// We collect as much data as possible before compressing and re-packetizing
int AllowCompress;
- unsigned char * toCompress; // Data being saved to compress
- int toCompressLen;
unsigned char * unCompress; // Data being saved to uncompress
int unCompressLen;
@@ -255,6 +253,7 @@ typedef struct ROUTE
#define GotRTTResponse 2 // Other end has sent us a RTT Response
#define GotRIF 4 // Other end has sent RIF, so is probably an INP3 Node
// (could just be monitoring RTT for some reason
+#define SentRTTRequest 8
#define SentOurRIF 16 // Set when we have sent a rif for our Call and any ApplCalls
// (only sent when we have seen both a request and response)
@@ -462,16 +461,18 @@ typedef struct _APPLCALLS
// This way our times adjust to changes of neighbour SRTT. We can't cater for changes to other hop RTTs,
// But if these are significant (say 25% or 100 ms) they will be retransmitted
+// 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 ROUTE * ROUT_NEIGHBOUR; // POINTER TO NEXT NODE IN PATH
UCHAR ROUT_QUALITY; // QUALITY
UCHAR ROUT_OBSCOUNT;
UCHAR ROUT_LOCKED;
- UCHAR Padding[4]; // SO Entries are the same length
+ UCHAR Padding[4]; // So Entries are the same length
} *PNR_DEST_ROUTE_ENTRY;
-typedef struct DEST_ROUTE_ENTRY
+typedef struct INP3_DEST_ROUTE_ENTRY
{
struct ROUTE * ROUT_NEIGHBOUR; // POINTER TO NEXT NODE IN PATH
USHORT LastRTT; // Last Value Reported
@@ -495,8 +496,8 @@ typedef struct DEST_LIST
UCHAR DEST_ROUTE; // CURRENTY ACTIVE DESTINATION
UCHAR INP3FLAGS;
- struct NR_DEST_ROUTE_ENTRY NRROUTE[3];// Best 3 NR neighbours for this dest
- struct DEST_ROUTE_ENTRY ROUTE[3]; // Best 3 INP neighbours for this dest
+ struct NR_DEST_ROUTE_ENTRY NRROUTE[3]; // Best 3 NR neighbours for this dest
+ struct INP3_DEST_ROUTE_ENTRY INP3ROUTE[3]; // Best 3 INP neighbours for this dest
void * DEST_Q; // QUEUE OF FRAMES FOR THIS DESTINATION
@@ -700,6 +701,7 @@ typedef struct PORTCONTROL
BOOL NormalizeQuality; // Normalise Node Qualities
BOOL IgnoreUnlocked; // Ignore Unlocked routes
BOOL INP3ONLY; // Default to INP3 and disallow NODES
+ BOOL ALLOWINP3;
void (* UIHook)(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffer, MESSAGE * ADJBUFFER, UCHAR CTL, UCHAR MSGFLAG); // Used for KISSARQ
struct PORTCONTROL * HookPort;
@@ -725,6 +727,9 @@ typedef struct PORTCONTROL
UCHAR * TX; // % Sending
UCHAR * BUSY; // % Active (Normally DCD active or TX)
+ int Hardware; // TNC H_TYPE. Copied here for access from application context
+
+
} PORTCONTROLX, *PPORTCONTROL;
typedef struct FULLPORTDATA
@@ -959,6 +964,21 @@ typedef struct _LINKTABLE
int bytesRXed; // Info bytes only
int bytesTXed;
+ // Now support compressing L2 Sessions.
+ // We collect as much data as possible before compressing and re-packetizing
+
+ int AllowCompress;
+
+ unsigned char * unCompress; // Data being saved to uncompress
+ int unCompressLen;
+
+ int Sent;
+ int SentAfterCompression;
+
+ int Received;
+ int ReceivedAfterExpansion;
+
+
} LINKTABLE;
#pragma pack(1)
@@ -1067,7 +1087,11 @@ struct SEM
int Gets;
int Rels;
DWORD SemProcessID;
+#ifdef WIN32
DWORD SemThreadID;
+#else
+ pthread_t SemThreadID;
+#endif
int Line; // caller file and line
char File[MAX_PATH];
};
@@ -1354,6 +1378,8 @@ struct arp_table_entry
// SOCKET SourceSocket;
struct AXIPPORTINFO * PORT;
BOOL noUpdate; // Don't update dest address from incoming packet
+ BOOL replytoSourcePort; // Update map entry dest port from source port of each packet.
+ time_t LastHeard; // Last Packet received from this ststiom
};
diff --git a/bpq32.h b/bpq32.h
index bdc5a20..2bab90a 100644
--- a/bpq32.h
+++ b/bpq32.h
@@ -22,6 +22,8 @@ count on BPQ32.dll gets messed up, and the code will not unload cleanly.
struct PORTCONTROL * APIENTRY GetPortTableEntryFromPortNum(int portslot);
struct PORTCONTROL * APIENTRY GetPortTableEntryFromSlot(int portslot);
+int APIENTRY GetPortHardwareType(struct PORTCONTROL *PORT);
+
// Returns number of free buffers
// (BPQHOST function 7 (part)).
diff --git a/bpqaxip.c b/bpqaxip.c
index 07083dd..d5afb62 100644
--- a/bpqaxip.c
+++ b/bpqaxip.c
@@ -204,7 +204,7 @@ int Update_MH_KeepAlive(struct AXIPPORTINFO * PORT, struct in_addr ipad, char pr
unsigned short int compute_crc(unsigned char *buf,int l);
unsigned int find_arp(unsigned char * call);
BOOL add_arp_entry(struct AXIPPORTINFO * PORT, unsigned char * call, UCHAR * ip, int len, int port,unsigned char * name,
-int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPMode, int SourcePort, BOOL IPv6, int noUpdate);
+ int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPMode, int SourcePort, BOOL IPv6, int noUpdate, int useSourcePort);
BOOL add_bc_entry(struct AXIPPORTINFO * PORT, unsigned char * call, int len);
BOOL convtoax25(unsigned char * callsign, unsigned char * ax25call, int * calllen);
static BOOL ReadConfigFile(int Port);
@@ -213,7 +213,7 @@ int CheckKeepalives(struct AXIPPORTINFO * PORT);
BOOL CopyScreentoBuffer(char * buff, struct AXIPPORTINFO * PORT);
int DumpFrameInHex(unsigned char * msg, int len);
VOID SendFrame(struct AXIPPORTINFO * PORT, struct arp_table_entry * arp_table, UCHAR * buff, int txlen);
-BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port, VOID * rxaddr);
+BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int FromPort, VOID * rxaddr, int ToPort);
int DataSocket_Read(struct arp_table_entry * sockptr, SOCKET sock);
int GetMessageFromBuffer(struct AXIPPORTINFO * PORT, char * Buffer);
int KissEncode(UCHAR * inbuff, UCHAR * outbuff, int len);
@@ -429,7 +429,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
if (PORT->Checkifcanreply)
{
- if (CheckSourceisResolvable(PORT, call, 0, &RXaddr))
+ if (CheckSourceisResolvable(PORT, call, 0, &RXaddr, 0))
return 1;
@@ -437,7 +437,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
// Can't reply. If AutoConfig is set, add to table and accept, else reject
if (PORT->AutoAddARP)
- return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, 0, inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, 0, FALSE, 0);
+ return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, 0, inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, 0, FALSE, 0, 0);
else
{
char From[11] = "|";
@@ -536,7 +536,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
if (PORT->Checkifcanreply)
{
- if (CheckSourceisResolvable(PORT, call, htons(RXaddr.rxaddr.sin_port), &RXaddr))
+ if (CheckSourceisResolvable(PORT, call, htons(RXaddr.rxaddr.sin_port), &RXaddr, PORT->udpport[i]))
return 1;
else
{
@@ -547,10 +547,10 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff)
{
char Addr[80];
Format_Addr((UCHAR *)&RXaddr.rxaddr6.sin6_addr, Addr, TRUE);
- return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr6.sin6_addr, 7, htons(RXaddr.rxaddr6.sin6_port), Addr, 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], TRUE, 0);
+ return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr6.sin6_addr, 7, htons(RXaddr.rxaddr6.sin6_port), Addr, 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], TRUE, 0, 0);
}
else
- return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, htons(RXaddr.rxaddr.sin_port), inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], FALSE, 0);
+ return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, htons(RXaddr.rxaddr.sin_port), inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], FALSE, 0, 0);
else
{
char From[11] = "|";
@@ -733,7 +733,7 @@ VOID SendFrame(struct AXIPPORTINFO * PORT, struct arp_table_entry * arp_table, U
return;
}
- // Seelcte source port by choosing right socket
+ // Select source port by choosing right socket
// First Set Default for Protocol
@@ -1343,6 +1343,7 @@ LRESULT FAR PASCAL ConfigWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lPa
char axcall[7];
BOOL UDPFlag, BCFlag;
struct AXIPPORTINFO * PORT;
+ int useSourcePort = 0;
for (i=1; i <= MAXBPQPORTS; i++)
{
@@ -1391,7 +1392,7 @@ LRESULT FAR PASCAL ConfigWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lPa
{
if (convtoax25(call,axcall,&calllen))
{
- add_arp_entry(PORT, axcall,0,calllen,port,host,Interval, BCFlag, FALSE, 0, port, FALSE, 0);
+ add_arp_entry(PORT, axcall,0,calllen,port,host,Interval, BCFlag, FALSE, 0, port, FALSE, 0, useSourcePort);
ResolveDelay = 2;
return(DestroyWindow(hWnd));
}
@@ -2147,6 +2148,7 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT)
int Interval;
int noUpdate=FALSE;
int TCPMode;
+ int useSourcePort = 0;
ptr = strtok(buf, " \t\n\r");
@@ -2234,6 +2236,7 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT)
bcflag=0;
TCPMode=0;
SourcePort = 0;
+ useSourcePort = 0;
//
// Look for (optional) KEEPALIVE, DYNAMIC, UDP or BROADCAST params
@@ -2264,7 +2267,14 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT)
if (p_udpport == NULL) return (FALSE);
- port = atoi(p_udpport);
+ if (_stricmp(p_udpport,"FROMPORT") == 0)
+ {
+ useSourcePort = TRUE;
+ port = 0;
+ }
+ else
+ port = atoi(p_udpport);
+
p_UDP = strtok(NULL, " \t\n\r");
continue;
}
@@ -2327,7 +2337,7 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT)
if (SourcePort == 0)
SourcePort = port;
- add_arp_entry(PORT, axcall, 0, calllen, port, p_ipad, Interval, bcflag, FALSE, TCPMode, SourcePort, FALSE, noUpdate);
+ add_arp_entry(PORT, axcall, 0, calllen, port, p_ipad, Interval, bcflag, FALSE, TCPMode, SourcePort, FALSE, noUpdate, useSourcePort);
return (TRUE);
}
} // End of Process MAP
@@ -2438,7 +2448,7 @@ BOOL convtoax25(unsigned char * callsign, unsigned char * ax25call,int * calllen
}
BOOL add_arp_entry(struct AXIPPORTINFO * PORT, UCHAR * call, UCHAR * ip, int len, int port,
- UCHAR * name, int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPFlag, int SourcePort, BOOL IPv6, int noUpdate)
+ UCHAR * name, int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPFlag, int SourcePort, BOOL IPv6, int noUpdate, int useSourcePort)
{
struct arp_table_entry * arp;
@@ -2457,7 +2467,8 @@ BOOL add_arp_entry(struct AXIPPORTINFO * PORT, UCHAR * call, UCHAR * ip, int len
arp->PORT = PORT;
- if (port == 0) PORT->needip = 1; // Enable Raw IP Mode
+ if (port == 0 && arp->replytoSourcePort == 0)
+ PORT->needip = 1; // Enable Raw IP Mode
arp->ResolveFlag=TRUE;
PORT->NeedResolver=TRUE;
@@ -2476,6 +2487,7 @@ BOOL add_arp_entry(struct AXIPPORTINFO * PORT, UCHAR * call, UCHAR * ip, int len
arp->TCPMode = TCPFlag;
arp->noUpdate = noUpdate;
PORT->arp_table_len++;
+ arp->replytoSourcePort = useSourcePort;
if (PORT->MaxResWindowlength < (PORT->arp_table_len * 14) + 70)
PORT->MaxResWindowlength = (PORT->arp_table_len * 14) + 70;
@@ -2576,7 +2588,7 @@ int CheckKeepalives(struct AXIPPORTINFO * PORT)
return (0);
}
-BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port, VOID * rxaddr)
+BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int FromPort, VOID * rxaddr, int ToPort)
{
// Makes sure we can reply to call before accepting message
@@ -2606,10 +2618,17 @@ BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port,
struct sockaddr_in * SA = rxaddr;
memcpy(&arp->destaddr.sin_addr.s_addr, &SA->sin_addr, 4);
}
- // Dont think I should update port
+ // Dont think I should update port unless using source port for dest
- //arp->port = Port;
+ if (arp->replytoSourcePort)
+ {
+ arp->port = FromPort;
+ arp->destaddr.sin_port = htons(arp->port);
+ if (arp->SourcePort == 0)
+ arp->SourcePort = ToPort;
+ }
}
+ arp->LastHeard = time(NULL);
return 1; // Ok to process
}
index++;
diff --git a/bpqmail.h b/bpqmail.h
index 0a8bf06..a2d85b3 100644
--- a/bpqmail.h
+++ b/bpqmail.h
@@ -290,6 +290,9 @@ typedef struct ConnectionInfo_S
struct ConnectionInfo_S * SysopChatStream; // Stream sysop is chatting to
+ int bytesSent;
+ int bytesRxed;
+
} ConnectionInfo, CIRCUIT;
// Flags Equates
@@ -336,11 +339,13 @@ typedef struct ConnectionInfo_S
struct FBBRestartData
{
- struct MsgInfo * TempMsg; // Header while message is being received
- struct UserInfo * UserPointer;
+ char Call[10];
+ char bid[13];
+ int length;
UCHAR * MailBuffer; // Mail Message being received
int MailBufferSize; // Total Malloc'ed size. Actual size in in Msg Struct
int Count; // Give up if too many restarts
+ time_t TimeCreated;
};
// We need to keep the B2Message file for B2 messages we are sending until the messages is acked, so
@@ -1387,6 +1392,7 @@ BOOL CheckBBSHElements(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSFo
BOOL CheckBBSHElementsFlood(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS, char ** HElements);
int CheckBBSToForNTS(struct MsgInfo * Msg, struct BBSForwardingInfo * ForwardingInfo);
int CheckBBSATListWildCarded(struct MsgInfo * Msg, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS);
+void SaveRestartData();
VOID ReRouteMessages();
diff --git a/cMain.c b/cMain.c
index f370490..c87fac2 100644
--- a/cMain.c
+++ b/cMain.c
@@ -144,6 +144,12 @@ int L4Compress = 0;
int L4CompMaxframe = 3;
int L4CompPaclen = 236;
+int L2Compress = 0;
+int L2CompMaxframe = 3;
+int L2CompPaclen = 236;
+
+int PREFERINP3ROUTES = 0;
+
BOOL LogL4Connects = FALSE;
BOOL LogAllConnects = FALSE;
BOOL AUTOSAVEMH = TRUE;
@@ -161,6 +167,8 @@ char MQTT_PASS[80] = "";
int MQTT_Connecting = 0;
int MQTT_Connected = 0;
+int PoolBuilt = 0;
+
//TNCTABLE DD 0
//NUMBEROFSTREAMS DD 0
@@ -836,6 +844,23 @@ BOOL Start()
if (L4CompPaclen < 64 || L4CompPaclen > 236)
L4CompPaclen = 236;
+
+ L2Compress = cfg->C_L2Compress;
+ L2CompMaxframe = cfg->C_L2CompMaxframe;
+ L2CompPaclen = cfg->C_L2CompPaclen;
+
+ if (L2CompMaxframe < 1 || L2CompMaxframe > 16)
+ L2CompMaxframe = 3;
+
+ if (L2CompPaclen < 64 || L2CompPaclen > 236)
+ L2CompPaclen = 236;
+
+
+ PREFERINP3ROUTES = cfg->C_PREFERINP3ROUTES;
+
+ if (cfg->C_OnlyVer2point0)
+ SUPPORT2point2 = 0;
+
// Get pointers to PASSWORD and APPL1 commands
@@ -962,6 +987,7 @@ BOOL Start()
PORT->NormalizeQuality = !PortRec->NoNormalize;
PORT->IgnoreUnlocked = PortRec->IGNOREUNLOCKED;
PORT->INP3ONLY = PortRec->INP3ONLY;
+ PORT->ALLOWINP3 = PortRec->AllowINP3;
PORT->PORTWINDOW = (UCHAR)PortRec->MAXFRAME;
@@ -986,6 +1012,9 @@ BOOL Start()
PORT->PORTPACLEN = (UCHAR)PortRec->PACLEN;
PORT->QUAL_ADJUST = (UCHAR)PortRec->QUALADJUST;
+ if (PORT->QUAL_ADJUST < 0 || PORT->QUAL_ADJUST > 100)
+ PORT->QUAL_ADJUST = 100;
+
PORT->DIGIFLAG = PortRec->DIGIFLAG;
if (PortRec->DIGIPORT && CanPortDigi(PortRec->DIGIPORT))
PORT->DIGIPORT = PortRec->DIGIPORT;
@@ -1443,6 +1472,8 @@ BOOL Start()
ENDBUFFERPOOL = NEXTFREEDATA;
+ PoolBuilt = 1;
+
// Copy Bridge Map
@@ -1560,6 +1591,7 @@ BOOL FindNeighbour(UCHAR * Call, int Port, struct ROUTE ** REQROUTE)
struct ROUTE * ROUTE = NEIGHBOURS;
struct ROUTE * FIRSTSPARE = NULL;
int n = MAXNEIGHBOURS;
+ char Normcall[10];
while (n--)
{
@@ -1572,6 +1604,10 @@ BOOL FindNeighbour(UCHAR * Call, int Port, struct ROUTE ** REQROUTE)
ROUTE++;
continue;
}
+
+
+ Normcall[ConvFromAX25(ROUTE->NEIGHBOUR_CALL, Normcall)] = 0;
+
if (CompareCalls(ROUTE->NEIGHBOUR_CALL, Call))
{
*REQROUTE = ROUTE;
diff --git a/cheaders.h b/cheaders.h
index 4b765a2..4951cac 100644
--- a/cheaders.h
+++ b/cheaders.h
@@ -105,7 +105,7 @@ VOID CLOSECURRENTSESSION(TRANSPORTENTRY * Session);
VOID SendCommandReply(TRANSPORTENTRY * Session, struct DATAMESSAGE * Buffer, int Len);
-struct PORTCONTROL * APIENTRY GetPortTableEntryFromPortNum(int portnum);
+DllExport struct PORTCONTROL * APIENTRY GetPortTableEntryFromPortNum(int portnum);
int cCOUNT_AT_L2(struct _LINKTABLE * LINK);
VOID SENDL4CONNECT(TRANSPORTENTRY * Session);
@@ -202,8 +202,6 @@ int TrytoGuessCode(unsigned char * Char, int Len);
#define XID 0xAF
#define TEST 0xE3
-#define SUPPORT2point2 1
-
// XID Optional Functions
#define OPMustHave 0x02A080 // Sync TEST 16 bit FCS Extended Address
@@ -438,6 +436,9 @@ extern int MQTT_PORT;
extern char MQTT_USER[80];
extern char MQTT_PASS[80];
+extern int SUPPORT2point2;
+
+
DllExport uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqStringMhz);
diff --git a/config.c b/config.c
index 8ca9b68..a1b39a2 100644
--- a/config.c
+++ b/config.c
@@ -308,7 +308,8 @@ static char *keywords[] =
"BTEXT:", "NETROMCALL", "C_IS_CHAT", "MAXRTT", "MAXHOPS", // IPGATEWAY= no longer allowed
"LogL4Connects", "LogAllConnects", "SAVEMH", "ENABLEADIFLOG", "ENABLEEVENTS", "SAVEAPRSMSGS",
"EnableM0LTEMap", "MQTT", "MQTT_HOST", "MQTT_PORT", "MQTT_USER", "MQTT_PASS",
-"L4Compress", "L4CompMaxframe", "L4CompPaclen"
+"L4Compress", "L4CompMaxframe", "L4CompPaclen", "L2Compress", "L2CompMaxframe",
+"L2CompPaclen", "PREFERINP3ROUTES", "OnlyVer2point0"
}; /* parameter keywords */
static void * offset[] =
@@ -330,7 +331,8 @@ static void * offset[] =
&xxcfg.C_BTEXT, &xxcfg.C_NETROMCALL, &xxcfg.C_C, &xxcfg.C_MAXRTT, &xxcfg.C_MAXHOPS, // IPGATEWAY= no longer allowed
&xxcfg.C_LogL4Connects, &xxcfg.C_LogAllConnects, &xxcfg.C_SaveMH, &xxcfg.C_ADIF, &xxcfg.C_EVENTS, &xxcfg.C_SaveAPRSMsgs,
&xxcfg.C_M0LTEMap, &xxcfg.C_MQTT, &xxcfg.C_MQTT_HOST, &xxcfg.C_MQTT_PORT, &xxcfg.C_MQTT_USER, &xxcfg.C_MQTT_PASS,
-&xxcfg.C_L4Compress, &xxcfg.C_L4CompMaxframe, &xxcfg.C_L4CompPaclen}; /* offset for corresponding data in config file */
+&xxcfg.C_L4Compress, &xxcfg.C_L4CompMaxframe, &xxcfg.C_L4CompPaclen, &xxcfg.C_L2Compress, &xxcfg.C_L2CompMaxframe,
+&xxcfg.C_L2CompPaclen, &xxcfg.C_PREFERINP3ROUTES, &xxcfg.C_OnlyVer2point0}; /* offset for corresponding data in config file */
static int routine[] =
{
@@ -351,6 +353,7 @@ static int routine[] =
15, 0, 2, 9, 9,
2, 2, 1, 2, 2, 2,
2, 2, 0, 1, 20, 20,
+1, 1, 1, 1, 1,
1, 1, 1} ; // Routine to process param
int PARAMLIM = sizeof(routine)/sizeof(int);
@@ -373,7 +376,7 @@ static char *pkeywords[] =
"BCALL", "DIGIMASK", "NOKEEPALIVES", "COMPORT", "DRIVER", "WL2KREPORT", "UIONLY",
"UDPPORT", "IPADDR", "I2CBUS", "I2CDEVICE", "UDPTXPORT", "UDPRXPORT", "NONORMALIZE",
"IGNOREUNLOCKEDROUTES", "INP3ONLY", "TCPPORT", "RIGPORT", "PERMITTEDAPPLS", "HIDE",
-"SMARTID", "KISSCOMMAND", "SendtoM0LTEMap", "PortFreq", "M0LTEMapInfo", "QTSMPort"}; /* parameter keywords */
+"SMARTID", "KISSCOMMAND", "SendtoM0LTEMap", "PortFreq", "M0LTEMapInfo", "QTSMPort", "ALLOWINP3"}; /* parameter keywords */
static void * poffset[] =
{
@@ -387,7 +390,7 @@ static void * poffset[] =
&xxp.BCALL, &xxp.DIGIMASK, &xxp.DefaultNoKeepAlives, &xxp.IOADDR, &xxp.DLLNAME, &xxp.WL2K, &xxp.UIONLY,
&xxp.IOADDR, &xxp.IPADDR, &xxp.INTLEVEL, &xxp.IOADDR, &xxp.IOADDR, &xxp.ListenPort, &xxp.NoNormalize,
&xxp.IGNOREUNLOCKED, &xxp.INP3ONLY, &xxp.TCPPORT, &xxp.RIGPORT, &xxp.PERMITTEDAPPLS, &xxp.Hide,
-&xxp.SmartID, &xxp.KissParams, &xxp.SendtoM0LTEMap, &xxp.PortFreq, &xxp.M0LTEMapInfo, &xxp.QtSMPort}; /* offset for corresponding data in config file */
+&xxp.SmartID, &xxp.KissParams, &xxp.SendtoM0LTEMap, &xxp.PortFreq, &xxp.M0LTEMapInfo, &xxp.QtSMPort, &xxp.AllowINP3}; /* offset for corresponding data in config file */
static int proutine[] =
{
@@ -401,7 +404,7 @@ static int proutine[] =
0, 1, 2, 18, 15, 16, 2,
1, 17, 1, 1, 1, 1, 2,
2, 2, 1, 1, 19, 2,
-1, 20, 1, 21, 22, 1}; /* routine to process parameter */
+1, 20, 1, 21, 22, 1, 1}; /* routine to process parameter */
int PPARAMLIM = sizeof(proutine)/sizeof(int);
@@ -535,6 +538,8 @@ BOOL ProcessConfig()
// xxcfg.SaveMH = TRUE; // Default to save
+ xxcfg.C_PREFERINP3ROUTES = 0; // Default to false
+
GetNextLine(rec);
while (rec[0])
@@ -621,7 +626,11 @@ BOOL ProcessConfig()
paramok[86]=1; // L4Compress
paramok[87]=1; // L4Compress Maxframe
paramok[88]=1; // L4Compress Paclen
-
+ paramok[89]=1; // L2Compress
+ paramok[90]=1; // L2Compress Maxframe
+ paramok[91]=1; // L2Compress Paclen
+ paramok[92]=1; // PREFERINP3ROUTES
+ paramok[93]=1; // C_ONLYVer2point0
for (i=0; i < PARAMLIM; i++)
{
diff --git a/configstructs.h b/configstructs.h
index a7e51a8..9fb75cf 100644
--- a/configstructs.h
+++ b/configstructs.h
@@ -81,6 +81,7 @@ struct PORTCONFIG
uint64_t PortFreq;
char * M0LTEMapInfo;
int QtSMPort;
+ int AllowINP3;
};
struct ROUTECONFIG
@@ -173,6 +174,11 @@ struct CONFIGTABLE
int C_L4Compress;
int C_L4CompMaxframe;
int C_L4CompPaclen;
+ int C_L2Compress;
+ int C_L2CompMaxframe;
+ int C_L2CompPaclen;
+ int C_PREFERINP3ROUTES;
+ int C_OnlyVer2point0;
//#define ApplOffset 80000 // Applications offset in config buffer
diff --git a/kiss.c b/kiss.c
index b511296..2f2f071 100644
--- a/kiss.c
+++ b/kiss.c
@@ -2294,7 +2294,7 @@ VOID QtSMThread(struct PORTCONTROL * PORT)
char Msg[64];
int Len;
- // We need tp send a QtSMPort message for each Channel sharing thia connection
+ // We need to send a QtSMPort message for each Channel sharing this connection
// Note struct KISSINFO and struct PORTCONTROL are different mappings of the same data
struct KISSINFO * KISS = (struct KISSINFO *)PORT;
diff --git a/linether.c b/linether.c
index fb3410c..b354465 100644
--- a/linether.c
+++ b/linether.c
@@ -22,17 +22,29 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Normally uses a Raw socket, but that can't send to other apps on same machine.
// so can use a TAP device instead (or maybe as well??)
+
+// Not suported on BSD based systems
+
+#ifndef FREEBSD
#ifndef MACBPQ
-#include <stdio.h>
-#include "cheaders.h"
+#if !(defined(MACBPQ) || defined(FREEBSD))
+#include <stdio.h>
+#include "cheaders.h"
#include <sys/socket.h>
+
+#if !(defined(FREEBSD))
+
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
+#endif
+#endif
+
+
extern int tap_fd;
typedef struct PCAPStruct
@@ -489,5 +501,11 @@ static int ProcessLine(char * buf, int Port, BOOL CheckPort)
return (FALSE);
}
+
+
+//
+
+#endif // MACBPQ
+#endif // FREEBSD
-#endif
+
diff --git a/lzhuf32.c b/lzhuf32.c
index f1ef0a4..c1aea82 100644
--- a/lzhuf32.c
+++ b/lzhuf32.c
@@ -1406,7 +1406,7 @@ File: 5566 NEWBOAT.HOMEPORT.JPG
if (SendBBStoSYSOPCall)
if (_stricmp(FullTo, BBSName) == 0)
- strcpy(Msg->to, SYSOPCall);
+ strcpy(FullTo, SYSOPCall);
if ((Msg->via[0] == 0 || strcmp(Msg->via, "BPQ") == 0 || strcmp(Msg->via, "BBS") == 0)
&& (conn->Paclink || conn->RMSExpress))
diff --git a/makefile b/makefile
index 7f870ff..cdb6298 100644
--- a/makefile
+++ b/makefile
@@ -17,22 +17,44 @@ OBJS = pngwtran.o pngrtran.o pngset.o pngrio.o pngwio.o pngtrans.o pngrutil.o pn
# Configuration:
-CC = gcc
-
-all: CFLAGS = -DLINBPQ -MMD -g -rdynamic -fcommon
-all: LDFLAGS = -l:libpaho-mqtt3a.a -l:libjansson.a
+#Default to Linux
+ CC = gcc
+ EXTRA_LDFLAGS = -Xlinker -Map=output.map -lrt -l:libpaho-mqtt3a.a -l:libjansson.a
+
+#other OS
+
+OS_NAME = $(shell uname -s)
+ifeq ($(OS_NAME),NetBSD)
+ CC = cc
+ EXTRA_CFLAGS = -DFREEBSD -DNOMQTT -I/usr/pkg/include
+ EXTRA_LDFLAGS = -Xlinker -Map=output.map -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lrt -lutil -lexecinfo
+endif
+ifeq ($(OS_NAME),FreeBSD)
+ CC = cc
+ EXTRA_CFLAGS = -DFREEBSD -DNOMQTT -I/usr/local/include
+ EXTRA_LDFLAGS = -Xlinker -Map=output.map -L/usr/local/lib -lrt -liconv -lutil -lexecinfo
+endif
+ifeq ($(OS_NAME),Darwin)
+ CC = gcc
+ EXTRA_CFLAGS = -DMACBPQ -DNOMQTT
+ EXTRA_LDFLAGS = -liconv
+endif
+
+$(info OS_NAME is $(OS_NAME))
+
+all: CFLAGS = -DLINBPQ -MMD -g -fcommon -fasynchronous-unwind-tables $(EXTRA_CFLAGS)
all: linbpq
-nomqtt: CFLAGS = -DLINBPQ -MMD -fcommon -g -rdynamic -DNOMQTT
+nomqtt: CFLAGS = -DLINBPQ -MMD -fcommon -g -rdynamic -DNOMQTT -fasynchronous-unwind-tables
nomqtt: linbpq
-noi2c: CFLAGS = -DLINBPQ -MMD -DNOI2C -g -rdynamic -fcommon
+noi2c: CFLAGS = -DLINBPQ -MMD -DNOI2C -g -rdynamic -fcommon -fasynchronous-unwind-tables
noi2c: linbpq
linbpq: $(OBJS)
- gcc $(OBJS) -Xlinker -Map=output.map -l:libminiupnpc.a -lrt -lm -lz $(LDFLAGS) -lpthread -lconfig -lpcap -o linbpq
+ cc $(OBJS) $(EXTRA_LDFLAGS) -lminiupnpc -lm -lz $(LDFLAGS) -lpthread -lconfig -lpcap -o linbpq
sudo setcap "CAP_NET_ADMIN=ep CAP_NET_RAW=ep CAP_NET_BIND_SERVICE=ep" linbpq
-include *.d
diff --git a/mqtt.c b/mqtt.c
index ff1c716..a9e91b4 100644
--- a/mqtt.c
+++ b/mqtt.c
@@ -429,6 +429,6 @@ void MQTTKISSRX(void *message) {};
void MQTTKISSRX_RAW(char* buffer, int bufferLength, void* PORT) {};
void MQTTTimer() {};
void MQTTReportSession(char * Msg) {};
+void MQTTMessageEvent(void* message) {};
#endif
-
diff --git a/templatedefs.c b/templatedefs.c
index 47bdfc3..2fa2e13 100644
--- a/templatedefs.c
+++ b/templatedefs.c
@@ -520,7 +520,8 @@ char * MainConfigtxt()
"<textarea cols=\"8\" rows=\"5\" name=\"Hat\">%s</textarea>\r\n"
"<textarea cols=\"8\" rows=\"5\" name=\"HBID\">%s</textarea>\r\n"
"<p></p>"
- "&nbsp;FBB reject.sys type filters (all fields must match, wildcards allowed)\r\n"
+ "&nbsp;FBB reject.sys type filters (all fields must match, wildcards allowed)<br>"
+ "&nbsp;'A' action accepts message if all fields match without checking following lines\r\n"
"<p></p>"
"<div style='position: absolute; left: 20px;height: 120px; overflow:auto;'>%s</div>"
"<div style='position: absolute; top: 1120px;left: 300px; overflow:auto;'>"
diff --git a/upnp.c b/upnp.c
index 96cb9d3..714e04d 100644
--- a/upnp.c
+++ b/upnp.c
@@ -93,7 +93,11 @@ int i;
const char * rootdescurl = 0;
const char * multicastif = 0;
const char * minissdpdpath = 0;
+#ifdef UPNP_LOCAL_PORT_ANY
int localport = UPNP_LOCAL_PORT_ANY;
+#else
+int localport = 0;
+#endif
int retcode = 0;
int error = 0;
int ipv6 = 0;
@@ -119,15 +123,18 @@ int upnpInit()
{
if (devlist == NULL)
{
+#if MINIUPNPC_API_VERSION == 10
+ devlist = upnpDiscover(2000, multicastif, minissdpdpath, localport, ipv6, &error);
+#else
devlist = upnpDiscover(2000, multicastif, minissdpdpath, localport, ipv6, ttl, &error);
-
+#endif
if (devlist == NULL)
{
Consoleprintf("Failed to find a UPNP device");
return 0;
}
-#if MINIUPNPC_API_VERSION == 18
+#if MINIUPNPC_API_VERSION >= 18
i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), wanaddr, sizeof(wanaddr));
#else
i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
@@ -150,15 +157,18 @@ int upnpClose()
{
if (devlist == NULL)
{
+#if MINIUPNPC_API_VERSION == 10
+ devlist = upnpDiscover(2000, multicastif, minissdpdpath, localport, ipv6, &error);
+#else
devlist = upnpDiscover(2000, multicastif, minissdpdpath, localport, ipv6, ttl, &error);
-
+#endif
if (devlist == NULL)
{
Consoleprintf("Failed to find a UPNP device");
return 0;
}
-#if MINIUPNPC_API_VERSION == 18
+#if MINIUPNPC_API_VERSION >= 18
i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), wanaddr, sizeof(wanaddr));
#else
i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));