From ac7e6b99beace1e002246436175581d01b02a117 Mon Sep 17 00:00:00 2001 From: g8bpq Date: Tue, 16 May 2023 16:40:12 +0100 Subject: [PATCH] 6.0.23.66 --- AEAPactor.c | 8 +- APRSCode.c | 12 +- ARDOP.c | 12 +- BBSUtilities.c | 89 +++- BPQMail.c | 3 + Bpq32.c | 12 +- ChatUtilities.c | 2 + Cmd.c | 91 +++- CommonCode.c | 7 +- FLDigi.c | 6 +- FreeDATA.c | 6 +- HALDriver.c | 8 +- HFCommon.c | 41 ++ HSMODEM.c | 6 +- HanksRT.c | 2 +- KAMPactor.c | 8 +- KISSHF.c | 6 +- L3Code.c | 54 ++- L4Code.c | 23 +- MULTIPSK.c | 6 +- MailNode.vcproj.DESKTOP-TGEL8RC.John.user | 4 +- Moncode.c | 2 +- RTKnown.txt | 52 +-- RigControl.c | 528 +++++++++++++++++++--- SCSPactor.c | 14 +- SCSTrackeMulti.c | 2 +- SCSTracker.c | 10 +- SerialPort.c | 6 +- TelnetV6.c | 9 +- UZ7HODrv.c | 298 ++++++------ V4.c | 4 +- VARA.c | 404 +++++++++++++++-- Versions.h | 4 +- WINMOR.c | 10 +- bpqmail.h | 3 + cMain.c | 30 +- chatconfig.cfg | 6 +- config.c | 7 + datadefs.c | 2 +- makefile_mac | 39 ++ rigcontrol.h | 1 + tncinfo.h | 16 +- 42 files changed, 1454 insertions(+), 399 deletions(-) create mode 100644 makefile_mac diff --git a/AEAPactor.c b/AEAPactor.c index 16f0468..f6add0f 100644 --- a/AEAPactor.c +++ b/AEAPactor.c @@ -731,7 +731,7 @@ VOID AEAPoll(int Port) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); // Shouldn't we also take out of standby mode?? PN is Pactor Listen, for monitoring @@ -795,7 +795,7 @@ VOID AEAPoll(int Port) sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); return; } @@ -910,7 +910,7 @@ VOID AEAPoll(int Port) if ((Stream == 0) && 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])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &MsgPtr[40])) { ReleaseBuffer(buffptr); } @@ -1434,7 +1434,7 @@ static VOID ProcessAEAPacket(struct TNCINFO * TNC, UCHAR * Msg, size_t Len) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); ShowTraffic(TNC); diff --git a/APRSCode.c b/APRSCode.c index 74a17ba..cda7bb5 100644 --- a/APRSCode.c +++ b/APRSCode.c @@ -4386,6 +4386,7 @@ Lost: } } +int GPSDAlerted = 0; static VOID GPSDConnect(void * unused) { @@ -4426,7 +4427,8 @@ static VOID GPSDConnect(void * unused) printf("GPSD Connected\n"); #else Debugprintf("GPSD Connected"); -#endif +#endif + GPSDAlerted = 0; ioctl(TCPSock, FIONBIO, ¶m); // Request data @@ -4436,11 +4438,13 @@ static VOID GPSDConnect(void * unused) else { err=WSAGetLastError(); + if (GPSDAlerted == 0) #ifdef LINBPQ - printf("GPSD Connect Failed - error code = %d\n", err); + printf("GPSD Connect Failed - error code = %d\n", err); #else - Debugprintf("GPSD Connect Failed - error code = %d", err); -#endif + Debugprintf("GPSD Connect Failed - error code = %d", err); +#endif + GPSDAlerted = 1; closesocket(TCPSock); GPSDOK = FALSE; diff --git a/ARDOP.c b/ARDOP.c index f7d7c9e..df38e25 100644 --- a/ARDOP.c +++ b/ARDOP.c @@ -1216,7 +1216,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } else { @@ -1468,7 +1468,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -1863,11 +1863,11 @@ VOID ARDOPReleaseTNC(struct TNCINFO * TNC) if (TNC->DefaultRadioCmd) { sprintf(TXMsg, "%d %s", TNC->Port, TNC->DefaultRadioCmd); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); } sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); ReleaseOtherPorts(TNC); @@ -3116,7 +3116,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); Debugprintf("ARDOP Call from %s rejected", Call); return; } @@ -3141,7 +3141,7 @@ VOID ARDOPProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); Debugprintf("ARDOP Call from %s not in ValidCalls - rejected", Call); return; } diff --git a/BBSUtilities.c b/BBSUtilities.c index 151a6e1..255aa97 100644 --- a/BBSUtilities.c +++ b/BBSUtilities.c @@ -122,7 +122,7 @@ int decode_quoted_printable(char *ptr, int len); void decodeblock( unsigned char in[4], unsigned char out[3]); int encode_quoted_printable(char *s, char * out, int Len); int32_t Encode(char * in, char * out, int32_t inlen, BOOL B1Protocol, int Compress); - +int APIENTRY ChangeSessionCallsign(int Stream, unsigned char * AXCall); config_t cfg; config_setting_t * group; @@ -7890,6 +7890,31 @@ BOOL ConnecttoBBS (struct UserInfo * user) ConnectUsingAppl(conn->BPQStream, BBSApplMask); FreeSemaphore(&ConSemaphore); + // If we are sending to a dump pms we may need to connect using the message sender's callsign. + // But we wont know until we run the connect script, which is a bit late to change call. Could add + // flag to forwarding config, but easier to look for SETCALLTOSENDER in the connect script. + + if (strstr(ForwardingInfo->ConnectScript[0], "SETCALLTOSENDER")) + { + conn->SendB = conn->SendP = conn->SendT = conn->DoReverse = TRUE; + conn->MaxBLen = conn->MaxPLen = conn->MaxTLen = 99999999; + + if (FindMessagestoForward(conn) && conn->FwdMsg) + { + // We have a message to send + + struct MsgInfo * Msg; + unsigned char AXCall[7]; + + Msg = conn->FwdMsg; + ConvToAX25(Msg->from, AXCall); + ChangeSessionCallsign(p, AXCall); + + conn->BBSFlags |= TEXTFORWARDING | SETCALLTOSENDER | NEWPACCOM; + conn->NextMessagetoForward = 0; // was set by FindMessages + } + conn->SendB = conn->SendP = conn->SendT = conn->DoReverse = FALSE; + } #ifdef LINBPQ { BPQVECSTRUC * SESS; @@ -8136,7 +8161,7 @@ InBand: char * Cmd; - if (strcmp(Buffer, "*** CONNECTED TO SYNC ") != 0) + if (strstr(Buffer, "*** CONNECTED TO SYNC")) { char * IPAddr = &Buffer[22]; char * Port = strlop(IPAddr, ':'); @@ -8287,6 +8312,12 @@ InBand: goto CheckForEnd; } + if (_memicmp(Cmd, "SETCALLTOSENDER", 15) == 0) + { + conn->BBSFlags |= TEXTFORWARDING | SETCALLTOSENDER; + goto CheckForEnd; + } + if (_memicmp(Cmd, "RADIOONLY", 9) == 0) { conn->BBSFlags |= WINLINKRO; @@ -8626,7 +8657,11 @@ CheckForSID: Msg = conn->FwdMsg; - nodeprintf(conn, "S%c %s @ %s < %s $%s\r", Msg->type, Msg->to, + if ((conn->BBSFlags & SETCALLTOSENDER)) + nodeprintf(conn, "S%c %s @ %s \r", Msg->type, Msg->to, + (Msg->via[0]) ? Msg->via : conn->UserPointer->Call); + else + nodeprintf(conn, "S%c %s @ %s < %s $%s\r", Msg->type, Msg->to, (Msg->via[0]) ? Msg->via : conn->UserPointer->Call, Msg->from, Msg->bid); } @@ -8834,6 +8869,12 @@ VOID Parse_SID(CIRCUIT * conn, char * SID, int len) conn->OpenBCM = TRUE; } + if (_memicmp(SID, "PMS-3.2", 7) == 0) + { + // Paccom TNC that doesn't send newline prompt ater receiving subject + + conn->BBSFlags |= NEWPACCOM; + } // See if BPQ for selective forwarding @@ -11262,8 +11303,12 @@ VOID ProcessTextFwdLine(ConnectionInfo * conn, struct UserInfo * user, char * Bu Buffer[len] = 0; // Debugprintf(Buffer); - if (len == 1 && Buffer[0] == 13) - return; + // With TNC2 body prompt is a single CR, so that shouldn't be ignored. + + // If thia causes problems with other TNC PMS implementations I'll have to revisit this + +// if (len == 1 && Buffer[0] == 13) +// return; if (conn->Flags & SENDTITLE) { @@ -11275,7 +11320,10 @@ VOID ProcessTextFwdLine(ConnectionInfo * conn, struct UserInfo * user, char * Bu conn->Flags &= ~SENDTITLE; conn->Flags |= SENDBODY; - return; + + // New Paccom PMS (V3.2) doesn't prompt for body so drop through and send it + if ((conn->BBSFlags & NEWPACCOM) == 0) + return; } @@ -11390,13 +11438,34 @@ VOID ProcessTextFwdLine(ConnectionInfo * conn, struct UserInfo * user, char * Bu if (FindMessagestoForward(conn) && conn->FwdMsg) { struct MsgInfo * Msg; - + + // If we are using SETCALLTOSENDER make sure this message is from the same sender + +#ifdef LINBPQ + BPQVECSTRUC * SESS = &BPQHOSTVECTOR[0]; +#else + BPQVECSTRUC * SESS = (BPQVECSTRUC *)BPQHOSTVECPTR; +#endif + unsigned char AXCall[7]; + + Msg = conn->FwdMsg; + ConvToAX25(Msg->from, AXCall); + if (memcmp(SESS[conn->BPQStream - 1].HOSTSESSION->L4USER, AXCall, 7) != 0) + { + Disconnect(conn->BPQStream); + return; + } + // Send S line and wait for response - SB WANT @ USA < W8AAA $1029_N0XYZ conn->Flags |= SENDTITLE; - Msg = conn->FwdMsg; - - nodeprintf(conn, "S%c %s @ %s < %s $%s\r", Msg->type, Msg->to, + + + if ((conn->BBSFlags & SETCALLTOSENDER)) + nodeprintf(conn, "S%c %s @ %s \r", Msg->type, Msg->to, + (Msg->via[0]) ? Msg->via : conn->UserPointer->Call); + else + nodeprintf(conn, "S%c %s @ %s < %s $%s\r", Msg->type, Msg->to, (Msg->via[0]) ? Msg->via : conn->UserPointer->Call, Msg->from, Msg->bid); } diff --git a/BPQMail.c b/BPQMail.c index 954b0d7..23b02d3 100644 --- a/BPQMail.c +++ b/BPQMail.c @@ -1110,6 +1110,9 @@ // Fix Webmail auto-refresh when page exceeds 64K bytes (54) // Fix Webmail send when using both headers/footers and attachmonts (55) // Fix R: line corruption on some 64 bit builds +// Dont drop empty lines inm TEXTFORWARDING (61) +// Dont wait for body prompt for TEXTFORWARDING for SID [PMS-3.2-C$] (62) +// Add forwarding mode SETCALLTOSENDER for PMS Systems that don't accept < in SP (63) #include "bpqmail.h" #define MAIL diff --git a/Bpq32.c b/Bpq32.c index 5625325..fcbf015 100644 --- a/Bpq32.c +++ b/Bpq32.c @@ -1153,8 +1153,14 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses // Fix TNC Emulator Monitoring (53) // Fix attach and connect on Telnet port bug introduced in .55 (56) // Fix stopping WinRPR TNC and Start/Stop UZ7HO TNCX on Linux (57) -// Fix stack size in beginthread for MAC - +// Fix stack size in beginthread for MAC (58) +// Add NETROM over VARA (60) +// Add Disconnect Script (64) +// Add node commands to set UZ7HO modem mode and freq (64) +// Trap empty NODECALL or NETROMCALL(65) +// Trap NODES messages with empty From Call (65) +// Add RigControl for SDRConsole (66) +// Fix FLRig crash (66) #define CKernel @@ -6605,5 +6611,3 @@ char * stristr (char *ch1, char *ch2) return chRet; } - - diff --git a/ChatUtilities.c b/ChatUtilities.c index a255faf..9a32436 100644 --- a/ChatUtilities.c +++ b/ChatUtilities.c @@ -346,6 +346,8 @@ char * ReadInfoFile(char * File) // First remove cr from crlf + ptr1 = MsgBytes; + while(ptr2 = strstr(ptr1, "\r\n")) { memmove(ptr2, ptr2 + 1, strlen(ptr2)); diff --git a/Cmd.c b/Cmd.c index 6a8c581..bb3f473 100644 --- a/Cmd.c +++ b/Cmd.c @@ -170,6 +170,8 @@ void ListExcludedCalls(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTai VOID APRSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CMD); VOID RECONFIGTELNET (TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CMD); VOID HELPCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CMD); +VOID UZ7HOCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * UserCMD); + @@ -3662,13 +3664,13 @@ VOID MHCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CM SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); } -int Rig_Command(int Session, char * Command); +int Rig_Command(TRANSPORTENTRY * Session, char * Command); VOID RADIOCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * UserCMD) { char * ptr; - if (Rig_Command(Session->CIRCUITINDEX, CmdTail)) + if (Rig_Command(Session, CmdTail)) { ReleaseBuffer((UINT *)REPLYBUFFER); return; @@ -4071,7 +4073,7 @@ checkattachandcall: char Msg[128]; sprintf(Msg, "R%d %f", TNC->RXRadio, TNC->ActiveRXFreq); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (TNC && TNC->ActiveTXFreq && TNC->TXRadio && TNC->TXRadio != TNC->RXRadio) @@ -4079,7 +4081,7 @@ checkattachandcall: char Msg[128]; sprintf(Msg, "R%d %f", TNC->TXRadio, TNC->ActiveTXFreq); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (ptr) @@ -4261,6 +4263,8 @@ CMDX COMMANDS[] = "ARP ",3,SHOWARP,0, "NAT ",3,SHOWNAT,0, "IPROUTE ",3,SHOWIPROUTE,0, + "UZ7HO ",5,UZ7HOCMD,0, + "..FLMSG ",7,FLMSG,0 }; @@ -4508,6 +4512,10 @@ VOID InnerCommandHandler(TRANSPORTENTRY * Session, struct DATAMESSAGE * Buffer) if (Session->UNPROTO) { +// char LongMsg[512] = +// "VeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessage" +// "VeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessageVeryLongMessage"; + DIGIMESSAGE Msg; int Port = Session->UNPROTO; int Len = Buffer->LENGTH - (MSGHDDRLEN -1); // Need PID @@ -4540,9 +4548,12 @@ VOID InnerCommandHandler(TRANSPORTENTRY * Session, struct DATAMESSAGE * Buffer) memcpy(Msg.ORIGIN, Session->L4USER, 7); memcpy(Msg.DIGIS, &Session->UADDRESS[7], Session->UAddrLen - 7); memcpy(&Msg.PID, &Buffer->PID, Len); - Send_AX_Datagram(&Msg, Len, Port); // Len is Payload - CTL, PID and Data +// memcpy(&Msg.PID + 1, LongMsg, 260); +// Send_AX_Datagram(&Msg, 241, Port); // Len is Payload - CTL, PID and Data + + // SendUIModeFrame(Session, (PMESSAGE)Buffer, Session->UNPROTO); ReleaseBuffer((UINT *)Buffer); // Not using buffer for reply @@ -5614,6 +5625,76 @@ VOID HELPCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); } +int UZ7HOSetFreq(int port, struct TNCINFO * TNC, struct AGWINFO * AGW, PDATAMESSAGE buff, PMSGWITHLEN buffptr); +int UZ7HOSetModem(int port, struct TNCINFO * TNC, struct AGWINFO * AGW, PDATAMESSAGE buff, PMSGWITHLEN buffptr); + + +VOID UZ7HOCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CMD) +{ + char * Cmd; + int port; + struct TNCINFO * TNC; + struct AGWINFO * AGW = 0; + PDATAMESSAGE buff; + PMSGWITHLEN buffptr; + + Cmd = strlop(CmdTail, ' '); + port = atoi(CmdTail); + + // remove trailing spaces + + while(strlen(Cmd) && Cmd[strlen(Cmd) - 1] == ' ') + Cmd[strlen(Cmd) - 1] = 0; + + TNC = TNCInfo[port]; + + if (TNC) + AGW = TNC->AGWInfo; + + if (TNC == 0 || AGW == 0) + { + Bufferptr = Cmdprintf(Session, Bufferptr, "Error - %d is not UZ7HO port\r", port); + SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); + return; + } + + if (_memicmp(Cmd, "FREQ", 4) == 0 || _memicmp(Cmd, "MODEM", 5) == 0) + { + // Pass to procesing code in UZ7HO driver. This expects command in a PDATAMESSAGE amd places response in a PMSGWITHLEN buffer + + buff = (PDATAMESSAGE)GetBuff(); + buffptr = (PMSGWITHLEN)GetBuff(); + + if (buffptr == 0) + { + Bufferptr = Cmdprintf(Session, Bufferptr, "UZ7HO Command Failed - no buffers\r"); + if (buff) + ReleaseBuffer(buff); + SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); + return; + } + + buff->LENGTH = sprintf(buff->L2DATA, "%s\r", Cmd) + MSGHDDRLEN + 1; + + if (_memicmp(Cmd, "FREQ", 4) == 0) + UZ7HOSetFreq(port, TNC, AGW, buff, buffptr); + else + UZ7HOSetModem(port, TNC, AGW, buff, buffptr); + + + Bufferptr = Cmdprintf(Session, Bufferptr, buffptr->Data); + + ReleaseBuffer(buff); + ReleaseBuffer(buffptr); + } + else + Bufferptr = Cmdprintf(Session, Bufferptr, "Invalid UZ7HO Command (not Freq Mode Modem)\r"); + + SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); + return; +} + + diff --git a/CommonCode.c b/CommonCode.c index f7e1685..1ec3989 100644 --- a/CommonCode.c +++ b/CommonCode.c @@ -72,6 +72,7 @@ extern BOOL LogAllConnects; extern VOID * ENDBUFFERPOOL; + // Read/Write length field in a buffer header // Needed for Big/LittleEndian and ARM5 (unaligned operation problem) portability @@ -777,7 +778,7 @@ NotConnected: char Msg[128]; sprintf(Msg, "R%d %f", TNC->RXRadio, TNC->DefaultRXFreq); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (TNC->DefaultTXFreq && TNC->TXRadio && TNC->TXRadio != TNC->RXRadio) @@ -785,7 +786,7 @@ NotConnected: char Msg[128]; sprintf(Msg, "R%d %f", TNC->TXRadio, TNC->DefaultTXFreq); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } while(STREAM->BPQtoPACTOR_Q) @@ -927,7 +928,7 @@ BOOL ProcessIncommingConnectEx(struct TNCINFO * TNC, char * Call, int Stream, BO sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); UpdateMH(TNC, Call, '+', 'I'); } diff --git a/FLDigi.c b/FLDigi.c index f7ad646..31c8926 100644 --- a/FLDigi.c +++ b/FLDigi.c @@ -200,7 +200,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) // Stop Scanning sprintf(Cmd, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Cmd); + Rig_Command( (TRANSPORTENTRY *) -1, Cmd); sprintf(TNC->WEB_TNCSTATE, "In Use by %s", TNC->Streams[0].MyCall); SetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE); @@ -536,7 +536,7 @@ pollloop: { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -3214,7 +3214,7 @@ VOID FLReleaseTNC(struct TNCINFO * TNC) sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); ReleaseOtherPorts(TNC); diff --git a/FreeDATA.c b/FreeDATA.c index a5a3133..7065eeb 100644 --- a/FreeDATA.c +++ b/FreeDATA.c @@ -614,7 +614,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (STREAM->Attached) @@ -774,7 +774,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -1095,7 +1095,7 @@ VOID FreeDataReleaseTNC(struct TNCINFO * TNC) sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); FreeDataReleasePort(TNC); ReleaseOtherPorts(TNC); diff --git a/HALDriver.c b/HALDriver.c index 0282457..69c573d 100644 --- a/HALDriver.c +++ b/HALDriver.c @@ -765,7 +765,7 @@ VOID HALPoll(int Port) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); SendCmd(TNC, "\x42", 1); // Connect Enable off @@ -820,7 +820,7 @@ VOID HALPoll(int Port) sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); return; } @@ -894,7 +894,7 @@ VOID HALPoll(int Port) 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])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &MsgPtr[40])) { ReleaseBuffer(buffptr); } @@ -1764,7 +1764,7 @@ BOOL HALConnected(struct TNCINFO * TNC, char * Call) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); ShowTraffic(TNC); diff --git a/HFCommon.c b/HFCommon.c index 0ef6145..0b18dcf 100644 --- a/HFCommon.c +++ b/HFCommon.c @@ -67,6 +67,7 @@ BOOL ToLOC(double Lat, double Lon , char * Locator); int GetPosnFromAPRS(char * Call, double * Lat, double * Lon); char * stristr (char *ch1, char *ch2); + static RECT Rect; extern struct TNCINFO * TNCInfo[41]; // Records are Malloc'd @@ -1834,6 +1835,42 @@ BOOL UpdateWL2KSYSOPInfo(char * Call, char * SQL) // Process config lines that are common to a number of HF modes +static char ** SeparateMultiString(char * MultiString) +{ + char ** Value; + int Count = 0; + char * ptr, * ptr1; + + // Convert to string array + + Value = zalloc(sizeof(void *)); // always NULL entry on end even if no values + Value[0] = NULL; + + strlop(MultiString, 13); + ptr = MultiString; + + while (ptr && strlen(ptr)) + { + ptr1 = strchr(ptr, '|'); + + if (ptr1) + *(ptr1++) = 0; + + if (strlen(ptr)) + { + Value = realloc(Value, (Count+2) * sizeof(void *)); + Value[Count++] = _strdup(ptr); + } + ptr = ptr1; + } + + Value[Count] = NULL; + return Value; +} + + + + extern int nextDummyInterlock; int standardParams(struct TNCINFO * TNC, char * buf) @@ -1855,6 +1892,8 @@ int standardParams(struct TNCINFO * TNC, char * buf) TNC->LISTENCALLS = _strdup(&buf[8]); strlop(TNC->LISTENCALLS, '\r'); } + else if (_memicmp(buf, "NRNEIGHBOUR", 11) == 0) + TNC->NRNeighbour = _strdup(&buf[12]); else if (_memicmp(buf, "MAXCONREQ", 9) == 0) // Hold Time for Busy Detect TNC->MaxConReq = atoi(&buf[9]); @@ -1878,6 +1917,8 @@ 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 + TNC->DisconnectScript = SeparateMultiString(&buf[17]); else if (_memicmp(buf, "PTTONHEX", 8) == 0) { // Hex String to use for PTT on for this port diff --git a/HSMODEM.c b/HSMODEM.c index fe05fed..1787d8a 100644 --- a/HSMODEM.c +++ b/HSMODEM.c @@ -567,7 +567,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (STREAM->Attached) @@ -685,7 +685,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -890,7 +890,7 @@ VOID HSMODEMReleaseTNC(struct TNCINFO * TNC) sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); ReleaseOtherPorts(TNC); diff --git a/HanksRT.c b/HanksRT.c index ab34b66..1e9330b 100644 --- a/HanksRT.c +++ b/HanksRT.c @@ -775,7 +775,7 @@ VOID ProcessChatLine(ChatCIRCUIT * conn, struct UserInfo * user, char* OrigBuffe return; } - if (_memicmp(&Buffer[1], "History", cmdLen) == 0) + if (cmdLen > 1 && _memicmp(&Buffer[1], "History", cmdLen) == 0) // Accept Hi but not H { // Param is number of minutes to go back (max 24 hours) diff --git a/KAMPactor.c b/KAMPactor.c index 0806478..e629351 100644 --- a/KAMPactor.c +++ b/KAMPactor.c @@ -900,7 +900,7 @@ VOID KAMPoll(int Port) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } } @@ -1051,7 +1051,7 @@ VOID KAMPoll(int Port) sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); return; } @@ -1189,7 +1189,7 @@ VOID KAMPoll(int Port) if ((Stream == 0) && 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])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &MsgPtr[40])) { ReleaseBuffer(buffptr); } @@ -1770,7 +1770,7 @@ VOID ProcessKHOSTPacket(struct TNCINFO * TNC, UCHAR * Msg, int Len) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); sprintf(TNC->WEB_TRAFFIC, "RX %d TX %d ACKED %d ", TNC->Streams[0].BytesRXed, TNC->Streams[0].BytesTXed, TNC->Streams[0].BytesAcked); diff --git a/KISSHF.c b/KISSHF.c index 0155f0d..09db1b5 100644 --- a/KISSHF.c +++ b/KISSHF.c @@ -346,7 +346,7 @@ ok: sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (STREAM->Attached) @@ -460,7 +460,7 @@ ok: { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &txbuff[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -717,7 +717,7 @@ VOID KISSHFReleaseTNC(struct TNCINFO * TNC) // Start Scanner sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); strcpy(TNC->WEB_TNCSTATE, "Free"); MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE); diff --git a/L3Code.c b/L3Code.c index 1838f16..6e14c2d 100644 --- a/L3Code.c +++ b/L3Code.c @@ -50,6 +50,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses #include #include "CHeaders.h" +#include "tncinfo.h" VOID UPDATEDESTLIST(); VOID MOVEALL(dest_list * DEST); @@ -57,11 +58,15 @@ VOID MOVE3TO2(dest_list * DEST); VOID CLEARTHIRD(dest_list * DEST); VOID L3TRYNEXTDEST(struct ROUTE * ROUTE); VOID SendNETROMRoute(struct PORTCONTROL * PORT, unsigned char * axcall); +void SendVARANetromNodes(struct TNCINFO * TNC, MESSAGE *Buffer); +void SendVARANetromMsg(struct TNCINFO * TNC,L3MESSAGEBUFFER * Buffer); extern BOOL NODESINPROGRESS ;; PPORTCONTROL L3CURRENTPORT; extern dest_list * CURRENTNODE; +extern struct TNCINFO * TNCInfo[41]; + int L3_10SECS = 10; @@ -73,6 +78,7 @@ VOID L3BG() struct DEST_LIST * DEST = DESTS; // NODE LIST struct PORTCONTROL * PORT = PORTTABLE; struct ROUTE * ROUTE; + struct TNCINFO * TNC; struct _LINKTABLE * LINK; @@ -87,6 +93,20 @@ VOID L3BG() if (ActiveRoute) { ROUTE = DEST->NRROUTE[ActiveRoute - 1].ROUT_NEIGHBOUR; + + // if NetROM over VARA pass direct to the driver + + if (ROUTE) + { + TNC = TNCInfo[ROUTE->NEIGHBOUR_PORT]; + + if (TNC && TNC->NetRomMode) + { + PL3MESSAGEBUFFER MSG = (PL3MESSAGEBUFFER)Q_REM(&DEST->DEST_Q); + SendVARANetromMsg(TNC, MSG); + return; + } + } if (ROUTE) LINK = ROUTE->NEIGHBOUR_LINK; else @@ -138,6 +158,7 @@ BOOL ACTIVATE_DEST(struct DEST_LIST * DEST) struct PORTCONTROL * PORT = PORTTABLE; struct ROUTE * ROUTE; struct _LINKTABLE * LINK; + struct TNCINFO * TNC; int ActiveRoute; @@ -165,6 +186,15 @@ BOOL ACTIVATE_DEST(struct DEST_LIST * DEST) ROUTE = DEST->ROUTE[0].ROUT_NEIGHBOUR; } + // if NetROM over VARA conection is made by the driver + + TNC = TNCInfo[ROUTE->NEIGHBOUR_PORT]; + + if (TNC && TNC->NetRomMode) + { + return TRUE; + } + LINK = ROUTE->NEIGHBOUR_LINK; if (LINK == 0) @@ -236,6 +266,12 @@ VOID PROCESSNODEMESSAGE(MESSAGE * Msg, struct PORTCONTROL * PORT) } Msg->ORIGIN[6] &= 0x1E; // MASK OFF LAST ADDR BIT + + // Trap Empty Call + + if (Msg->ORIGIN[0] == 0x40) + return; + /* // validate call ptr = &Buffer->ORIGIN[0]; n = 6; @@ -726,8 +762,9 @@ VOID SENDNEXTNODESFRAGMENT() fragmentCount = 0; + // Don't send NODES to Shared TX or INP3 Port + while (PORT->PORTQUALITY == 0 || PORT->TXPORT || PORT->INP3ONLY) - // Don't send NODES to Shared TX or INP3 Port { // No NODES to this port, so go to next @@ -808,7 +845,7 @@ VOID SENDNEXTNODESFRAGMENT() goto Sendit; } - if (DEST->NRROUTE[0].ROUT_QUALITY >= TXMINQUAL && + 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; { @@ -856,7 +893,11 @@ Sendit: if (Buffer->LENGTH > 35 || fragmentCount == 0) // Always send first even if no other nodes { - PUT_ON_PORT_Q(PORT, Buffer); + if (PORT->TNC && PORT->TNC->Hardware == H_VARA) + SendVARANetromNodes(PORT->TNC, Buffer); + else + PUT_ON_PORT_Q(PORT, Buffer); + fragmentCount++; } else @@ -1020,10 +1061,15 @@ VOID L3FastTimer() // ID MESSAGE SEQUENCE MESSAGE * Msg; - struct PORTCONTROL * PORT ; + struct PORTCONTROL * PORT = PORTTABLE; INP3TIMER(); + // Send Node faster if VARA + + if (NODESINPROGRESS && L3CURRENTPORT->TNC && L3CURRENTPORT->TNC->NetRomMode) + SENDNEXTNODESFRAGMENT(); + L3_10SECS--; if (L3_10SECS == 0) diff --git a/L4Code.c b/L4Code.c index 20430dd..6f19652 100644 --- a/L4Code.c +++ b/L4Code.c @@ -32,6 +32,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses #include #include "CHeaders.h" +#include "tncinfo.h" extern BPQVECSTRUC BPQHOSTVECTOR[]; #define BPQHOSTSTREAMS 64 @@ -65,6 +66,7 @@ VOID ProcessINP3RIF(struct ROUTE * Route, UCHAR * ptr1, int msglen, int Port); VOID ProcessRTTMsg(struct ROUTE * Route, struct _L3MESSAGEBUFFER * Buff, int Len, int Port); 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); extern UINT APPLMASK; @@ -440,7 +442,7 @@ VOID SENDL4CONNECT(TRANSPORTENTRY * Session) if (DEST->DEST_CALL[0] == 0) { - Debugprintf("Trying to send L4CREEQ to NULL Destination"); + Debugprintf("Trying to send L4CREQ to NULL Destination"); ReleaseBuffer(MSG); return; } @@ -593,7 +595,7 @@ VOID L4BG() { SENDL4MESSAGE(L4, Msg); ReleaseBuffer(Msg); - break; + continue; } LINK = L4->L4TARGET.LINK; @@ -1387,6 +1389,8 @@ VOID SendConACK(struct _LINKTABLE * LINK, TRANSPORTENTRY * L4, L3MESSAGEBUFFER * { // SEND CONNECT ACK + struct TNCINFO * TNC; + L4CONNECTSIN++; L3MSG->L4TXNO = L4->CIRCUITINDEX; @@ -1457,7 +1461,12 @@ VOID SendConACK(struct _LINKTABLE * LINK, TRANSPORTENTRY * L4, L3MESSAGEBUFFER * L3MSG->LENGTH++; } - C_Q_ADD(&LINK->TX_Q, L3MSG); + TNC = LINK->LINKPORT->TNC; + + if (TNC && TNC->NetRomMode) + SendVARANetromMsg(TNC, L3MSG); + else + C_Q_ADD(&LINK->TX_Q, L3MSG); } int FINDCIRCUIT(L3MESSAGEBUFFER * L3MSG, TRANSPORTENTRY ** REQL4, int * NewIndex) @@ -1697,6 +1706,7 @@ VOID FRAMEFORUS(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG, int ApplMask, L3MESSAGEBUFFER * Saved; L3MESSAGEBUFFER ** Prev; char Call[10]; + struct TNCINFO * TNC; L4FRAMESRX++; @@ -1838,7 +1848,12 @@ VOID FRAMEFORUS(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG, int ApplMask, L3SWAPADDRESSES(L3MSG); // EXCHANGE SOURCE AND DEST L3MSG->L3TTL = L3LIVES; - C_Q_ADD(&LINK->TX_Q, L3MSG); + TNC = LINK->LINKPORT->TNC; + + if (TNC && TNC->NetRomMode) + SendVARANetromMsg(TNC, L3MSG); + else + C_Q_ADD(&LINK->TX_Q, L3MSG); CloseSessionPartner(L4); // SEND CLOSE TO PARTNER (IF PRESENT) return; diff --git a/MULTIPSK.c b/MULTIPSK.c index 84dbbab..89e2e3b 100644 --- a/MULTIPSK.c +++ b/MULTIPSK.c @@ -187,7 +187,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) // Stop Scanning sprintf(Cmd, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Cmd); + Rig_Command( (TRANSPORTENTRY *) -1, Cmd); len = sprintf(Cmd, "%cSTOP_BEACON_ARQ_FAE\x1b", '\x1a'); @@ -415,7 +415,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(buff->L2DATA, "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, buff->L2DATA)) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, buff->L2DATA)) { } else @@ -1537,7 +1537,7 @@ VOID CloseComplete(struct TNCINFO * TNC, int Stream) int Len; sprintf(Cmd, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Cmd); + Rig_Command( (TRANSPORTENTRY *) -1, Cmd); Cmd[0] = 0; diff --git a/MailNode.vcproj.DESKTOP-TGEL8RC.John.user b/MailNode.vcproj.DESKTOP-TGEL8RC.John.user index 40182c4..7a49481 100644 --- a/MailNode.vcproj.DESKTOP-TGEL8RC.John.user +++ b/MailNode.vcproj.DESKTOP-TGEL8RC.John.user @@ -10,7 +10,7 @@ > ID: Port &= 0x7F; - if (((1ll << (Port - 1)) & Mask) == 0) // Check MMASK + if (((1 << (Port - 1)) & Mask) == 0) // Check MMASK return 0; diff --git a/RTKnown.txt b/RTKnown.txt index 74d3f7d..5827f30 100644 --- a/RTKnown.txt +++ b/RTKnown.txt @@ -1,26 +1,26 @@ -G8BPQ-1 1669106746 -GM8BPQ-3 1669106749 -KB8UVN-6 1669106746 -N8BHL-6 1669106746 -KF8MZ-6 1669106746 -W8BAP-6 1669106746 -G8BPQ-4 1669106746 -EI2GYB-4 1669106746 -IZ4FVW-10 1669106746 -PE1NNZ-5 1669106746 -PI1LAP-4 1669106746 -K8OPG-14 1669106746 -KB9PVH-11 1669106746 -N0NJY-11 1669106746 -N3MEL-3 1669106746 -K5DAT-11 1669106746 -N2UEM-11 1669106746 -W9IKU-11 1669106746 -WA3WLH-11 1669106746 -WA3WLH-14 1669106746 -PE1RRR-4 1669106746 -MS0HFI-4 1669106746 -AE5E-2 1669106746 -G0BMH-4 1669106746 -OH5RM-8 1669106746 -GM8BPQ-4 1669106746 +G8BPQ-1 1681280155 +GM8BPQ-3 1681280155 +KB8UVN-6 1681280155 +N8BHL-6 1681280155 +KF8MZ-6 1681280155 +W8BAP-6 1681280155 +G8BPQ-4 1681280155 +EI2GYB-4 1681280155 +IZ4FVW-10 1681280155 +PE1NNZ-5 1681280155 +PI1LAP-4 1681280155 +K8OPG-14 1681280155 +KB9PVH-11 1681280155 +N0NJY-11 1681280155 +N3MEL-3 1681280155 +K5DAT-11 1681280155 +N2UEM-11 1681280155 +W9IKU-11 1681280155 +WA3WLH-11 1681280155 +WA3WLH-14 1681280155 +PE1RRR-4 1681280155 +MS0HFI-4 1681280155 +AE5E-2 1681280155 +G0BMH-4 1681280155 +OH5RM-8 1681280155 +GM8BPQ-4 1681280155 diff --git a/RigControl.c b/RigControl.c index a864c1e..9314705 100644 --- a/RigControl.c +++ b/RigControl.c @@ -122,6 +122,9 @@ VOID FLRIGPoll(struct RIGPORTINFO * PORT); void ProcessFLRIGFrame(struct RIGPORTINFO * PORT); VOID FLRIGSendCommand(struct RIGPORTINFO * PORT, char * Command, char * Value); +VOID ProcessSDRRadioFrame(struct RIGPORTINFO * PORT, int Length); +VOID SDRRadioPoll(struct RIGPORTINFO * PORT); + VOID SetupPortRIGPointers(); VOID PTTCATThread(struct RIGINFO *RIG); VOID ConnecttoHAMLIB(struct RIGPORTINFO * PORT); @@ -682,9 +685,9 @@ void saveNewFreq(struct RIGINFO * RIG, double Freq, char * Mode) // Need version that doesn't need Port Number -int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, char * Command); +int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTRY * Session, char * Command); -int Rig_Command(int Session, char * Command) +int Rig_Command(TRANSPORTENTRY * Session, char * Command) { char * ptr; int i, n, p, Port; @@ -705,8 +708,7 @@ int Rig_Command(int Session, char * Command) { if (CheckOneTimePassword(&Command[5], AuthPassword)) { - L4 += Session; - L4->Secure_Session = 1; + Session->Secure_Session = 1; sprintf(Command, "Ok\r"); @@ -720,11 +722,9 @@ int Rig_Command(int Session, char * Command) return FALSE; } - if (Session != -1) // Used for internal Stop/Start + if (Session != (TRANSPORTENTRY *) -1) // Used for internal Stop/Start { - L4 += Session; - - if (L4->Secure_Session == 0) + if (Session->Secure_Session == 0) { sprintf(Command, "Sorry - you are not allowed to use this command\r"); return FALSE; @@ -802,7 +802,7 @@ static char Req[] = "\r\n" -int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, char * Command) +int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, TRANSPORTENTRY * Session, char * Command) { int n, ModeNo, Filter, Port = 0; double Freq = 0.0; @@ -833,8 +833,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, { if (CheckOneTimePassword(&Command[5], AuthPassword)) { - L4 += Session; - L4->Secure_Session = 1; + Session->Secure_Session = 1; sprintf(Command, "Ok\r"); @@ -848,11 +847,9 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, return FALSE; } - if (Session != -1) // Used for internal Stop/Start + if (Session != (TRANSPORTENTRY *) -1) // Used for internal Stop/Start { - L4 += Session; - - if (L4->Secure_Session == 0) + if (Session->Secure_Session == 0) { sprintf(Command, "Sorry - you are not allowed to use this command\r"); return FALSE; @@ -903,7 +900,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, { RIG->ScanStopped &= (0xffffffff ^ (1 << Port)); - if (Session != -1) // Used for internal Stop/Start + if (Session != (TRANSPORTENTRY *) -1) // Used for internal Stop/Start RIG->ScanStopped &= 0xfffffffe; // Clear Manual Stopped Bit if (n > 2) @@ -933,7 +930,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, { RIG->ScanStopped |= (1 << Port); - if (Session != -1) // Used for internal Stop/Start + if (Session != (TRANSPORTENTRY *) -1) // Used for internal Stop/Start RIG->ScanStopped |= 1; // Set Manual Stopped Bit MySetWindowText(RIG->hSCAN, ""); @@ -954,7 +951,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, if (RIG->RIGOK == 0) { - if (Session != -1) + if (Session != (TRANSPORTENTRY *) -1) { if (PORT->Closed) sprintf(Command, "Sorry - Radio port closed\r"); @@ -982,8 +979,15 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, return FALSE; } - RIG->Session = Session; // BPQ Stream - RIG->PollCounter = 50; // Dont read freq for 5 secs in case clash with Poll + if (Session != (void *)-1) + { + if (Session->CIRCUITINDEX == 255) + RIG->Session = -1; + else + RIG->Session = Session->CIRCUITINDEX; // BPQ Stream + + RIG->PollCounter = 50; // Dont read freq for 5 secs in case clash with Poll + } if (_stricmp(FreqString, "TUNE") == 0) { @@ -1834,10 +1838,7 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, return TRUE; - case KENWOOD: - case FT2000: - case FT991A: - case FLEX: + case SDRRADIO: if (n < 3) { @@ -1845,6 +1846,49 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, return FALSE; } + for (ModeNo = 0; ModeNo < 16; ModeNo++) + { + if (_stricmp(KenwoodModes[ModeNo], Mode) == 0) + break; + } + + if (ModeNo > 15) + { + sprintf(Command, "Sorry -Invalid Mode\r"); + return FALSE; + } + + buffptr = GetBuff(); + + if (buffptr == 0) + { + sprintf(Command, "Sorry - No Buffers available\r"); + return FALSE; + } + + // Build a ScanEntry in the buffer + + FreqPtr = (struct ScanEntry *)buffptr->Data; + memset(FreqPtr, 0, sizeof(struct ScanEntry)); + + FreqPtr->Freq = Freq; + FreqPtr->Bandwidth = Bandwidth; + FreqPtr->Antenna = Antenna; + + Poll = FreqPtr->Cmd1 = FreqPtr->Cmd1Msg; + + FreqPtr->Cmd1Len = sprintf(Poll, "F%c00%s;MD%d;F%c;MD;", RIG->RigAddr, FreqString, ModeNo, RIG->RigAddr); + + C_Q_ADD(&RIG->BPQtoRADIO_Q, buffptr); + + return TRUE; + + if (n < 3) + { + strcpy(Command, "Sorry - Invalid Format - should be Port Freq Mode\r"); + return FALSE; + } + for (ModeNo = 0; ModeNo < 16; ModeNo++) { if (PORT->PortType == FT2000) @@ -1907,6 +1951,8 @@ int Rig_CommandEx(struct RIGPORTINFO * PORT, struct RIGINFO * RIG, int Session, return TRUE; + + case NMEA: if (n < 3) @@ -2570,6 +2616,11 @@ BOOL Rig_Poll() KenwoodPoll(PORT); break; + + case SDRRADIO: + SDRRadioPoll(PORT); + break; + case HAMLIB: HAMLIBPoll(PORT); break; @@ -2580,10 +2631,7 @@ BOOL Rig_Poll() case FLRIG: FLRIGPoll(PORT); - break; - - - } + break; } } // Build page for Web Display @@ -2858,6 +2906,25 @@ void CheckRX(struct RIGPORTINFO * PORT) PORT->RXLen = 0; // Ready for next frame return; + case SDRRADIO: + + if (Length < 2) // Minimum Frame Sise + return; + + if (Length > 50) // Garbage + { + PORT->RXLen = 0; // Ready for next frame + return; + } + + if (PORT->RXBuffer[Length-1] != ';') + return; + + ProcessSDRRadioFrame(PORT, Length); + + PORT->RXLen = 0; // Ready for next frame + return; + case NMEA: ptr = memchr(PORT->RXBuffer, 0x0a, Length); @@ -3576,7 +3643,7 @@ SetFinished: // Set Mode Response - if scanning read freq, else return OK to user - if (RIG->ScanStopped == 0) + if (RIG->ScanStopped == 0 && PORT->AutoPoll) { ReleasePermission(RIG); // Release Perrmission @@ -4353,6 +4420,134 @@ VOID ProcessNMEA(struct RIGPORTINFO * PORT, char * Msg, int Length) //FA00014103000;MD2; + +VOID ProcessSDRRadioFrame(struct RIGPORTINFO * PORT, int Length) +{ + UCHAR * Poll = PORT->TXBuffer; + UCHAR * Msg = PORT->RXBuffer; + struct RIGINFO * RIG = &PORT->Rigs[0]; + UCHAR * ptr; + int CmdLen; + int i; + + Msg[Length] = 0; + + Debugprintf(Msg); + + if (PORT->PORTOK == FALSE) + { + // Just come up + PORT->PORTOK = TRUE; + } + + if (!PORT->AutoPoll) + { + // Response to a RADIO Command + + if (Msg[0] == '?') + SendResponse(RIG->Session, "Sorry - Command Rejected"); + else if (Msg[0] == 'A' && Msg[1] == 'C') + SendResponse(RIG->Session, "TUNE OK"); + else if (Msg[0] == 'P' && Msg[1] == 'C') + SendResponse(RIG->Session, "Power Set OK"); + else + SendResponse(RIG->Session, "Mode and Frequency Set OK"); + + PORT->AutoPoll = TRUE; + return; + } + + +LoopR: + + ptr = strchr(Msg, ';'); + CmdLen = (int)(ptr - Msg + 1); + + // Find Device. FA to FF for frequency + + // Note. SDRConsole reports the same mode for all receivers, so don't rely on reported mode + + if (Msg[0] == 'F') + { + for (i = 0; i < PORT->ConfiguredRigs; i++) + { + RIG = &PORT->Rigs[i]; + if (Msg[1] == RIG->RigAddr) + goto ok; + } + return; +ok: + + if (CmdLen > 9) + { + char CharMHz[16] = ""; + char CharHz[16] = ""; + + int i; + long long Freq; + long long MHz, Hz; + + RIG->RIGOK = TRUE; + + Freq = strtoll(&Msg[2], NULL, 10) + RIG->rxOffset; + + RIG->RigFreq = Freq / 1000000.0; + + // If we convert to float to display we get rounding errors, so convert to MHz and Hz to display + + MHz = Freq / 1000000; + + Hz = Freq - MHz * 1000000; + + sprintf(CharMHz, "%lld", MHz); + sprintf(CharHz, "%06lld", Hz); + + for (i = 5; i > 2; i--) + { + if (CharHz[i] == '0') + CharHz[i] = 0; + else + break; + } + + + sprintf(RIG->WEB_FREQ,"%lld.%s", MHz, CharHz); + SetWindowText(RIG->hFREQ, RIG->WEB_FREQ); + strcpy(RIG->Valchar, RIG->WEB_FREQ); + + PORT->Timeout = 0; + } + } + else if (Msg[0] == 'M' && Msg[1] == 'D') + { + int Mode; + + Mode = Msg[2] - 48; + if (Mode > 7) Mode = 7; + SetWindowText(RIG->hMODE, KenwoodModes[Mode]); + strcpy(RIG->WEB_MODE, KenwoodModes[Mode]); + strcpy(RIG->ModeString, RIG->WEB_MODE); + + } + + if (CmdLen < Length) + { + // Another Message in Buffer + + ptr++; + Length -= (int)(ptr - Msg); + + if (Length <= 0) + return; + + memmove(Msg, ptr, Length +1); + + goto LoopR; + } +} + + + VOID ProcessKenwoodFrame(struct RIGPORTINFO * PORT, int Length) { UCHAR * Poll = PORT->TXBuffer; @@ -4388,7 +4583,6 @@ VOID ProcessKenwoodFrame(struct RIGPORTINFO * PORT, int Length) return; } - Loop: if (PORT->PortType == FLEX) @@ -4643,6 +4837,162 @@ VOID KenwoodPoll(struct RIGPORTINFO * PORT) return; } +VOID SDRRadioPoll(struct RIGPORTINFO * PORT) +{ + UCHAR * Poll = PORT->TXBuffer; + struct RIGINFO * RIG; + int i; + + for (i=0; i< PORT->ConfiguredRigs; i++) + { + RIG = &PORT->Rigs[i]; + + if (RIG->ScanStopped == 0) + if (RIG->ScanCounter) + RIG->ScanCounter--; + } + + if (PORT->Timeout) + { + PORT->Timeout--; + + if (PORT->Timeout) // Still waiting + return; + + PORT->Retries--; + + if(PORT->Retries) + { + RigWriteCommBlock(PORT); // Retransmit Block + return; + } + + SetWindowText(RIG->hFREQ, "------------------"); + SetWindowText(RIG->hMODE, "----------"); + strcpy(RIG->WEB_FREQ, "-----------");; + strcpy(RIG->WEB_MODE, "------"); + + RIG->RIGOK = FALSE; + + return; + } + + // Send Data if avail, else send poll + + + PORT->CurrentRig++; + + if (PORT->CurrentRig >= PORT->ConfiguredRigs) + PORT->CurrentRig = 0; + + RIG = &PORT->Rigs[PORT->CurrentRig]; + + + if (RIG->NumberofBands && RIG->RIGOK && (RIG->ScanStopped == 0)) + { + if (RIG->ScanCounter <= 0) + { + // Send Next Freq + + if (GetPermissionToChange(PORT, RIG)) + { + if (RIG->RIG_DEBUG) + Debugprintf("BPQ32 Change Freq to %9.4f", PORT->FreqPtr->Freq); + + memcpy(PORT->TXBuffer, PORT->FreqPtr->Cmd1, PORT->FreqPtr->Cmd1Len); + PORT->TXLen = PORT->FreqPtr->Cmd1Len; + + _gcvt(PORT->FreqPtr->Freq / 1000000.0, 9, RIG->Valchar); // For MH + + RigWriteCommBlock(PORT); + PORT->CmdSent = 1; + PORT->Retries = 0; + PORT->Timeout = 0; + PORT->AutoPoll = TRUE; + + // There isn't a response to a set command, so clear Scan Lock here + + ReleasePermission(RIG); // Release Perrmission + + return; + } + } + } + + if (RIG->RIGOK && RIG->BPQtoRADIO_Q) + { + struct MSGWITHOUTLEN * buffptr; + + buffptr = Q_REM(&RIG->BPQtoRADIO_Q); + + // Copy the ScanEntry struct from the Buffer to the PORT Scanentry + + memcpy(&PORT->ScanEntry, buffptr->Data, sizeof(struct ScanEntry)); + + PORT->FreqPtr = &PORT->ScanEntry; // Block we are currently sending. + + if (RIG->RIG_DEBUG) + Debugprintf("BPQ32 Change Freq to %9.4f", PORT->FreqPtr->Freq); + + DoBandwidthandAntenna(RIG, &PORT->ScanEntry); + + _gcvt(PORT->FreqPtr->Freq / 1000000.0, 9, RIG->Valchar); // For MH + + memcpy(Poll, PORT->FreqPtr->Cmd1, PORT->FreqPtr->Cmd1Len); + + PORT->TXLen = PORT->FreqPtr->Cmd1Len; + RigWriteCommBlock(PORT); + PORT->CmdSent = Poll[4]; + PORT->Timeout = 0; + RIG->PollCounter = 10; + + ReleaseBuffer(buffptr); + PORT->AutoPoll = FALSE; + + return; + } + + if (RIG->PollCounter) + { + RIG->PollCounter--; + if (RIG->PollCounter > 1) + return; + } + + if (RIG->RIGOK && RIG->ScanStopped == 0 && RIG->NumberofBands && + RIG->ScanCounter && RIG->ScanCounter < 30) + return; // no point in reading freq if we are about to change it + + // Need to make sure we don't poll multiple rigs on port at the same time + + if (RIG->RIGOK) + { + PORT->Retries = 2; + RIG->PollCounter = 10 / PORT->ConfiguredRigs; // Once Per Sec + } + else + { + PORT->Retries = 1; + RIG->PollCounter = 100 / PORT->ConfiguredRigs; // Slow Poll if down + } + + RIG->PollCounter += PORT->CurrentRig * 3; + + // Read Frequency + + PORT->TXLen = RIG->PollLen; + strcpy(Poll, RIG->Poll); + + RigWriteCommBlock(PORT); + PORT->Retries = 1; + PORT->Timeout = 10; + PORT->CmdSent = 0; + + PORT->AutoPoll = TRUE; + + return; +} + VOID DummyPoll(struct RIGPORTINFO * PORT) { UCHAR * Poll = PORT->TXBuffer; @@ -5185,7 +5535,7 @@ struct RIGINFO * RigConfig(struct TNCINFO * TNC, char * buf, int Port) else COMPort = ptr; - // See if port is already defined. We may be adding another radio (ICOM only) or updating an existing one + // See if port is already defined. We may be adding another radio (ICOM or SDRRADIO only) or updating an existing one // Unless CM108 - they must be on separate Ports @@ -5278,6 +5628,8 @@ PortFound: PORT->PortType = YAESU; else if (strcmp(ptr, "KENWOOD") == 0) PORT->PortType = KENWOOD; + else if (strcmp(ptr, "SDRRADIO") == 0) + PORT->PortType = SDRRADIO; // Varient of KENWOOD that supports multiple devices on one serial port else if (strcmp(ptr, "FLEX") == 0) PORT->PortType = FLEX; else if (strcmp(ptr, "NMEA") == 0) @@ -5378,14 +5730,18 @@ PortFound: } - // If ICOM, we may be adding a new Rig + // If ICOM or SDRRADIO, we may be adding a new Rig ptr = strtok_s(NULL, " \t\n\r", &Context); - if (PORT->PortType == ICOM || PORT->PortType == NMEA) + if (PORT->PortType == ICOM || PORT->PortType == NMEA || PORT->PortType == SDRRADIO) { if (ptr == NULL) return (FALSE); - sscanf(ptr, "%x", &RigAddr); + + if (PORT->PortType == SDRRADIO) + RigAddr = ptr[0]; + else + sscanf(ptr, "%x", &RigAddr); // See if already defined @@ -5884,7 +6240,29 @@ CheckOtherParams: RIG->PTTOffLen = (int)strlen(RIG->PTTOff); } - else if (PORT->PortType == FLEX) + else if (PORT->PortType == SDRRADIO) + { + RIG->PollLen = sprintf(RIG->Poll, "F%c;MD;", RIG->RigAddr); + +/* if (PTTControlsInputMUX) + { + sprintf(RIG->PTTOn, "EX%03d00001;TX1;", RIG->TSMenu); // Select USB before PTT + sprintf(RIG->PTTOff, "RX;EX%03d00000;", RIG->TSMenu); // Select ACC after dropping PTT + } + else + { + strcpy(RIG->PTTOff, "RX;"); + + if (DataPTT) + strcpy(RIG->PTTOn, "TX1;"); + else + strcpy(RIG->PTTOn, "TX;"); + } +*/ + RIG->PTTOnLen = (int)strlen(RIG->PTTOn); + RIG->PTTOffLen = (int)strlen(RIG->PTTOff); + + } else if (PORT->PortType == FLEX) { RIG->PollLen = 10; strcpy(RIG->Poll, "ZZFA;ZZMD;"); @@ -7234,21 +7612,22 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) Length = PORT->RXLen; msg[Length] = 0; + ptr1 = strstr(msg, "Content-length:"); if (ptr1 == NULL) return; - Len = atoi(&ptr1[15]); ptr2 = strstr(ptr1, "\r\n\r\n"); - if (ptr2) - { - TotalLen = ptr2 +4 + Len - msg; - if (TotalLen > Length) // Don't have it all - return; - } - else + if (ptr2 == NULL) + return; + + Len = atoi(&ptr1[15]); + + TotalLen = ptr2 + 4 + Len - msg; + + if (TotalLen > Length) // Don't have it all return; val = strstr(ptr2, ""); @@ -7260,8 +7639,6 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) RIG->RIGOK = 1; PORT->RXLen -= TotalLen; - memmove(PORT->RXBuffer, &PORT->RXBuffer[TotalLen], PORT->RXLen); - // It is quite difficult to corrolate responses with commands, but we only poll for freq, mode and bandwidth // and the responses can be easily identified @@ -7282,7 +7659,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) FLRIGSendCommand(PORT, "rig.set_bandwidth", cmd); PORT->ScanEntry.Cmd3Msg[0] = 0; } - + else if (!PORT->AutoPoll) { GetSemaphore(&Semaphore, 61); @@ -7319,7 +7696,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) sprintf(RIG->WEB_MODE, "%s/%d:%d", RIG->ModeString, b1, b2); else sprintf(RIG->WEB_MODE, "%s/%d", RIG->ModeString, b1); - + MySetWindowText(RIG->hMODE, RIG->WEB_MODE); } } @@ -7328,7 +7705,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) // Either freq or mode. See if numeric double freq; - + strlop(val, '<'); freq = atof(val) / 1000000.0; @@ -7363,7 +7740,7 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) } else SetWindowText(RIG->hMODE, RIG->WEB_MODE); - + MySetWindowText(RIG->hMODE, RIG->WEB_MODE); Len = sprintf(ReqBuf, Req, "rig.get_bw", ""); @@ -7456,32 +7833,37 @@ void ProcessFLRIGFrame(struct RIGPORTINFO * PORT) } */ - } - - PORT->Timeout = 0; } - /* - POST /RPC2 HTTP/1.1 - User-Agent: XMLRPC++ 0.8 - Host: 127.0.0.1:12345 - Content-type: text/xml - Content-length: 89 + if (PORT->RXLen > 0) + memmove(PORT->RXBuffer, &PORT->RXBuffer[TotalLen], PORT->RXLen); + else + PORT->RXLen = 0; - - rig.get_vfoA - - HTTP/1.1 200 OK - Server: XMLRPC++ 0.8 - Content-Type: text/xml - Content-length: 118 + PORT->Timeout = 0; + } + + /* + POST /RPC2 HTTP/1.1 + User-Agent: XMLRPC++ 0.8 + Host: 127.0.0.1:12345 + Content-type: text/xml + Content-length: 89 + + + rig.get_vfoA + + HTTP/1.1 200 OK + Server: XMLRPC++ 0.8 + Content-Type: text/xml + Content-length: 118 + + + + 14070000 + + */ - - - 14070000 - - */ - } @@ -7509,7 +7891,7 @@ void HLSetMode(SOCKET Sock, struct RIGINFO * RIG, unsigned char * Msg, char sep) sprintf(Resp, "%d %s %s\n", 0, RIG->Valchar, mode); GetSemaphore(&Semaphore, 60); - Rig_CommandEx(RIG->PORT, RIG, -1, Resp); + Rig_CommandEx(RIG->PORT, RIG, (TRANSPORTENTRY *) -1, Resp); FreeSemaphore(&Semaphore); if (sep) @@ -7531,7 +7913,7 @@ void HLSetFreq(SOCKET Sock, struct RIGINFO * RIG, unsigned char * Msg, char sep) sprintf(Resp, "%d %f\n", 0, freq/1000000.0); GetSemaphore(&Semaphore, 60); - Rig_CommandEx(RIG->PORT, RIG, -1, Resp); + Rig_CommandEx(RIG->PORT, RIG, (TRANSPORTENTRY *) -1, Resp); FreeSemaphore(&Semaphore); if (sep) diff --git a/SCSPactor.c b/SCSPactor.c index f42dfcb..5e57b91 100644 --- a/SCSPactor.c +++ b/SCSPactor.c @@ -1340,7 +1340,7 @@ VOID SCSPoll(int Port) sprintf(Status, "%d SCANSTOP", TNC->Port); TNC->SwitchToPactor = 0; // Cancel any RP to Pactor switch - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); } else { @@ -1927,7 +1927,7 @@ VOID SCSPoll(int Port) { sprintf(&Buffer[40], "%d %s", TNC->Port, &Buffer[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &Buffer[40])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &Buffer[40])) { ReleaseBuffer(buffptr); } @@ -3368,7 +3368,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen) TNC->SwitchToPactor = 0; // Cancel any RP to Pactor switch sprintf(Status, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); SuspendOtherPorts(TNC); // Prevent connects on other ports in same scan gruop @@ -3394,7 +3394,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen) { TidyClose(TNC, Stream); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); Debugprintf("SCS Call from %s rejected", MHCall); return; } @@ -3422,7 +3422,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); Debugprintf("Pactor Call from %s not in ValidCalls - rejected", Call); return; } @@ -3557,7 +3557,7 @@ VOID ProcessDEDFrame(struct TNCINFO * TNC, UCHAR * Msg, int framelen) Debugprintf("RP SABM is for NODECALL or one of our APPLCalls - setting MYCALL to %s and pausing scan", DestCall); sprintf(Status, "%d SCANSTART 30", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); TNC->SwitchToPactor = 0; // Stay in RP strcpy(STREAM->MyCall, DestCall); @@ -4120,7 +4120,7 @@ VOID CloseComplete(struct TNCINFO * TNC, int Stream) SetWindowText(TNC->xIDC_TNCSTATE, "Free"); strcpy(TNC->WEB_TNCSTATE, "Free"); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); if (TNC->Dragon) { diff --git a/SCSTrackeMulti.c b/SCSTrackeMulti.c index 4872ead..ddf4b07 100644 --- a/SCSTrackeMulti.c +++ b/SCSTrackeMulti.c @@ -1629,7 +1629,7 @@ static VOID ProcessDEDFrame(struct TNCINFO * TNC) 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); + Rig_Command( (TRANSPORTENTRY *) -1, Status); TNC->SwitchToPactor = 600; // Don't change modes for 60 secs strcpy(STREAM->MyCall, DestCall); diff --git a/SCSTracker.c b/SCSTracker.c index b08e5a6..bda8c21 100644 --- a/SCSTracker.c +++ b/SCSTracker.c @@ -1037,7 +1037,7 @@ VOID DEDPoll(int Port) TNC->SwitchToPactor = 0; // Cancel any RP to Pactor switch sprintf(Status, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); SuspendOtherPorts(TNC); // Prevent connects on other ports in same scan gruop } @@ -1314,7 +1314,7 @@ reinit: { sprintf(&Buffer[40], "%d %s", TNC->Port, &Buffer[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &Buffer[40])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &Buffer[40])) { ReleaseBuffer(buffptr); } @@ -2027,7 +2027,7 @@ VOID TrkProcessDEDFrame(struct TNCINFO * TNC) TNC->SwitchToPactor = 0; // Cancel any RP to Pactor switch sprintf(Status, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); memcpy(MHCall, Call, 9); MHCall[9] = 0; @@ -2315,7 +2315,7 @@ VOID TrkProcessDEDFrame(struct TNCINFO * TNC) 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); + Rig_Command( (TRANSPORTENTRY *) -1, Status); if ((TNC->RIG == &TNC->DummyRig || TNC->RIG == NULL) && TNC->RobustTime) TNC->SwitchToPactor = 600; // Don't change modes for 60 secs @@ -2576,7 +2576,7 @@ VOID TrkCloseComplete(struct TNCINFO * TNC, int Stream) TNC->WEB_CHANGED = TRUE; - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); if (TNC->RIG == &TNC->DummyRig) // Not using Rig control TNC->SwitchToPactor = TNC->RobustTime; diff --git a/SerialPort.c b/SerialPort.c index 6de9d05..02afba7 100644 --- a/SerialPort.c +++ b/SerialPort.c @@ -390,7 +390,7 @@ ok: sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (STREAM->Attached) @@ -519,7 +519,7 @@ ok: { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -724,7 +724,7 @@ VOID SerialReleaseTNC(struct TNCINFO * TNC) sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); ReleaseOtherPorts(TNC); diff --git a/TelnetV6.c b/TelnetV6.c index 61ed0fd..98fd395 100644 --- a/TelnetV6.c +++ b/TelnetV6.c @@ -4970,7 +4970,7 @@ int DataSocket_ReadHTTP(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, S char RigCMD[64]; sprintf(RigCMD, "%s PTT", &MsgPtr[6]); - Rig_Command(-1, RigCMD); + Rig_Command( (TRANSPORTENTRY *) -1, RigCMD); } else if (memcmp(sockptr->WebURL, "WMRefresh", 9) == 0) { @@ -5521,8 +5521,11 @@ int Telnet_Connected(struct TNCINFO * TNC, struct ConnectionInfo * sockptr, SOCK } else { - buffptr->Len = sprintf(&buffptr->Data[0], "Connected to %s\r", - TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4CROSSLINK->APPL); + if (TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4CROSSLINK->APPL[0]) + buffptr->Len = sprintf(&buffptr->Data[0], "*** Connected to %s\r", + TNC->PortRecord->ATTACHEDSESSIONS[Stream]->L4CROSSLINK->APPL); + else + buffptr->Len = sprintf(&buffptr->Data[0], "*** Connected to APPL\r"); if (sockptr->NoCallsign == FALSE) send(sockptr->socket, Signon, sprintf(Signon, "%s\r\n", TNC->Streams[Stream].MyCall), 0); diff --git a/UZ7HODrv.c b/UZ7HODrv.c index f81294c..1814ba6 100644 --- a/UZ7HODrv.c +++ b/UZ7HODrv.c @@ -357,6 +357,147 @@ VOID UZ7HOReleasePort(struct TNCINFO * TNC) RegisterAPPLCalls(TNC, FALSE); } +int UZ7HOSetFreq(int port, struct TNCINFO * TNC, struct AGWINFO * AGW, PDATAMESSAGE buff, PMSGWITHLEN buffptr) +{ + int txlen = GetLengthfromBuffer(buff) - (MSGHDDRLEN + 1); + + // May be read or set frequency + + if (txlen == 5) + { + // Read Freq + + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Freqency %d\r", AGW->CenterFreq); + return 1; + } + + AGW->CenterFreq = atoi(&buff->L2DATA[5]); + + if (AGW->CenterFreq == 0) + { + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Invalid Modem Freqency\r"); + return 1; + } + + if (TNCInfo[MasterPort[port]]->AGWInfo->isQTSM == 3) + { + // QtSM so can send Set Freq Command + + char Buffer[32] = ""; + int MsgLen = 32; + + memcpy(Buffer, &AGW->CenterFreq, 4); + + AGW->TXHeader.Port = UZ7HOChannel[port]; + AGW->TXHeader.DataKind = 'g'; + memset(AGW->TXHeader.callfrom, 0, 10); + memset(AGW->TXHeader.callto, 0, 10); +#ifdef __BIG_ENDIAN__ + AGW->TXHeader.DataLength = reverse(MsgLen); +#else + AGW->TXHeader.DataLength = MsgLen; +#endif + send(TNCInfo[MasterPort[port]]->TCPSock, (char *)&AGW->TXHeader, AGWHDDRLEN, 0); + send(TNCInfo[MasterPort[port]]->TCPSock, Buffer, MsgLen, 0); + } +#ifdef WIN32 + else if (AGW->hFreq) + { + //Using real UZ7HO on Windows + + char Freq[16]; + sprintf(Freq, "%d", AGW->CenterFreq - 1); + + SendMessage(AGW->hFreq, WM_SETTEXT, 0, (LPARAM)Freq); + SendMessage(AGW->hSpin, WM_LBUTTONDOWN, 1, 1); + SendMessage(AGW->hSpin, WM_LBUTTONUP, 0, 1); + } +#endif + else + { + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Sorry Setting UZ7HO params not supported on this system\r"); + return 1; + } + + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Freq Set Ok\r"); + return 1; +} + +int UZ7HOSetModem(int port, struct TNCINFO * TNC, struct AGWINFO * AGW, PDATAMESSAGE buff, PMSGWITHLEN buffptr ) +{ + int txlen = GetLengthfromBuffer(buff) - (MSGHDDRLEN + 1); + + if (txlen == 6) + { + // Read Modem + + if (AGW->ModemName[0]) + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem %s\r", AGW->ModemName); + else + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Number %d\r", AGW->Modem); + + return 1; + } + else if (TNCInfo[MasterPort[port]]->AGWInfo->isQTSM == 3) + { + // Can send modem name to QTSM + + char Buffer[32] = ""; + int MsgLen = 32; + + strlop(buff->L2DATA, '\r'); + strlop(buff->L2DATA, '\n'); + + if (strlen(&buff->L2DATA[6]) > 20) + buff->L2DATA[26] = 0; + + strcpy(&Buffer[4], &buff->L2DATA[6]); + + AGW->TXHeader.Port = UZ7HOChannel[port]; + AGW->TXHeader.DataKind = 'g'; + memset(AGW->TXHeader.callfrom, 0, 10); + memset(AGW->TXHeader.callto, 0, 10); +#ifdef __BIG_ENDIAN__ + AGW->TXHeader.DataLength = reverse(MsgLen); +#else + AGW->TXHeader.DataLength = MsgLen; +#endif + send(TNCInfo[MasterPort[port]]->TCPSock, (char *)&AGW->TXHeader, AGWHDDRLEN, 0); + send(TNCInfo[MasterPort[port]]->TCPSock, Buffer, MsgLen, 0); + } +#ifdef WIN32 + else if (AGW->cbinfo.cbSize) + { + // Real QTSM on Windows + + AGW->Modem = atoi(&buff->L2DATA[6]); + + if (AGW->cbinfo.cbSize && AGW->cbinfo.hwndCombo) + { + // Set it + + LRESULT ret = SendMessage(AGW->cbinfo.hwndCombo, CB_SETCURSEL, AGW->Modem, 0); + int pos = 13 * AGW->Modem + 7; + + ret = SendMessage(AGW->cbinfo.hwndCombo, WM_LBUTTONDOWN, 1, 1); + ret = SendMessage(AGW->cbinfo.hwndCombo, WM_LBUTTONUP, 0, 1); + ret = SendMessage(AGW->cbinfo.hwndList, WM_LBUTTONDOWN, 1, pos << 16); + ret = SendMessage(AGW->cbinfo.hwndList, WM_LBUTTONUP, 0, pos << 16); + ret = 0; + } + } +#endif + else + { + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Sorry Setting UZ7HO params not supported this system\r"); + return 1; + } + + buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Set Ok\r"); + return 1; +} + + static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { PMSGWITHLEN buffptr; @@ -396,7 +537,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) // Stop Scanning sprintf(Cmd, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Cmd); + Rig_Command( (TRANSPORTENTRY *) -1, Cmd); SuspendOtherPorts(TNC); // Prevent connects on other ports in same scan gruop @@ -761,7 +902,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -819,167 +960,20 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { PMSGWITHLEN buffptr = (PMSGWITHLEN)GetBuff(); - // May be read or set frequency - - if (txlen == 5) - { - // Read Freq - - if (buffptr) - { - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Freqency %d\r", AGW->CenterFreq); - C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); - } - return 1; - } - - AGW->CenterFreq = atoi(&buff->L2DATA[5]); - - if (AGW->CenterFreq == 0) - { - if (buffptr) - { - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Invalid Modem Freqency\r"); - C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); - } - return 1; - } - - if (TNCInfo[MasterPort[port]]->AGWInfo->isQTSM == 3) - { - // QtSM so can send Set Freq Command - - char Buffer[32] = ""; - int MsgLen = 32; - - memcpy(Buffer, &AGW->CenterFreq, 4); - - AGW->TXHeader.Port = UZ7HOChannel[port]; - AGW->TXHeader.DataKind = 'g'; - memset(AGW->TXHeader.callfrom, 0, 10); - memset(AGW->TXHeader.callto, 0, 10); -#ifdef __BIG_ENDIAN__ - AGW->TXHeader.DataLength = reverse(MsgLen); -#else - AGW->TXHeader.DataLength = MsgLen; -#endif - send(TNCInfo[MasterPort[port]]->TCPSock, (char *)&AGW->TXHeader, AGWHDDRLEN, 0); - send(TNCInfo[MasterPort[port]]->TCPSock, Buffer, MsgLen, 0); - } -#ifdef WIN32 - else if (AGW->hFreq) - { - //Using real UZ7HO on Windows - - char Freq[16]; - sprintf(Freq, "%d", AGW->CenterFreq - 1); - - SendMessage(AGW->hFreq, WM_SETTEXT, 0, (LPARAM)Freq); - SendMessage(AGW->hSpin, WM_LBUTTONDOWN, 1, 1); - SendMessage(AGW->hSpin, WM_LBUTTONUP, 0, 1); - } -#endif - else - { - if (buffptr) - { - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Sorry Setting UZ7HO params not supported on this system\r"); - C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); - } - - return 1; - } - if (buffptr) { - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Freq Set Ok\r"); + UZ7HOSetFreq(port, TNC, AGW, buff, buffptr); C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); } - return 1; } if (_memicmp(&buff->L2DATA[0], "MODEM", 5) == 0) { PMSGWITHLEN buffptr = (PMSGWITHLEN)GetBuff(); - - if (txlen == 6) - { - // Read Modem - - if (buffptr) - { - if (AGW->ModemName[0]) - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem %s\r", AGW->ModemName); - else - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Number %d\r", AGW->Modem); - - C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); - } - return 1; - } - else if (TNCInfo[MasterPort[port]]->AGWInfo->isQTSM == 3) - { - // Can send modem name to QTSM - - char Buffer[32] = ""; - int MsgLen = 32; - - strlop(buff->L2DATA, '\r'); - strlop(buff->L2DATA, '\n'); - - if (strlen(&buff->L2DATA[6]) > 20) - buff->L2DATA[26] = 0; - - strcpy(&Buffer[4], &buff->L2DATA[6]); - - AGW->TXHeader.Port = UZ7HOChannel[port]; - AGW->TXHeader.DataKind = 'g'; - memset(AGW->TXHeader.callfrom, 0, 10); - memset(AGW->TXHeader.callto, 0, 10); -#ifdef __BIG_ENDIAN__ - AGW->TXHeader.DataLength = reverse(MsgLen); -#else - AGW->TXHeader.DataLength = MsgLen; -#endif - send(TNCInfo[MasterPort[port]]->TCPSock, (char *)&AGW->TXHeader, AGWHDDRLEN, 0); - send(TNCInfo[MasterPort[port]]->TCPSock, Buffer, MsgLen, 0); - } -#ifdef WIN32 - else if (AGW->cbinfo.cbSize) - { - // Real QTSM on Windows - - AGW->Modem = atoi(&buff->L2DATA[6]); - - if (AGW->cbinfo.cbSize && AGW->cbinfo.hwndCombo) - { - // Set it - - LRESULT ret = SendMessage(AGW->cbinfo.hwndCombo, CB_SETCURSEL, AGW->Modem, 0); - int pos = 13 * AGW->Modem + 7; - - ret = SendMessage(AGW->cbinfo.hwndCombo, WM_LBUTTONDOWN, 1, 1); - ret = SendMessage(AGW->cbinfo.hwndCombo, WM_LBUTTONUP, 0, 1); - ret = SendMessage(AGW->cbinfo.hwndList, WM_LBUTTONDOWN, 1, pos << 16); - ret = SendMessage(AGW->cbinfo.hwndList, WM_LBUTTONUP, 0, pos << 16); - ret = 0; - } - } -#endif - else - { - if (buffptr) - { - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Sorry Setting UZ7HO params not supported this system\r"); - C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); - } - return 1; - } - if (buffptr) { - buffptr->Len = sprintf((UCHAR *)&buffptr->Data[0], "UZ7HO} Modem Set Ok\r"); + UZ7HOSetModem(port, TNC, AGW, buff, buffptr); C_Q_ADD(&STREAM->PACTORtoBPQ_Q, buffptr); } return 1; @@ -2870,7 +2864,7 @@ VOID CloseComplete(struct TNCINFO * TNC, int Stream) ReleaseOtherPorts(TNC); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); } static MESSAGE Monframe; // I frames come in two parts. diff --git a/V4.c b/V4.c index d8df3f9..af14636 100644 --- a/V4.c +++ b/V4.c @@ -467,7 +467,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } @@ -628,7 +628,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(buff->L2DATA, "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, buff->L2DATA)) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, buff->L2DATA)) { } else diff --git a/VARA.c b/VARA.c index 73b4b11..5273ac9 100644 --- a/VARA.c +++ b/VARA.c @@ -50,6 +50,11 @@ extern int (WINAPI FAR *EnumProcessesPtr)(); #define WSA_DATA WM_USER + 2 #define WSA_CONNECT WM_USER + 3 +#define FEND 0xC0 +#define FESC 0xDB +#define TFEND 0xDC +#define TFESC 0xDD + static int Socket_Data(int sock, int error, int eventcode); int KillTNC(struct TNCINFO * TNC); @@ -64,6 +69,9 @@ int VARASendData(struct TNCINFO * TNC, UCHAR * Buff, int Len); VOID VARASendCommand(struct TNCINFO * TNC, char * Buff, BOOL Queue); VOID VARAProcessDataPacket(struct TNCINFO * TNC, UCHAR * Data, int Length); void CountRestarts(struct TNCINFO * TNC); +int KissEncode(UCHAR * inbuff, UCHAR * outbuff, int len); +VOID PROCESSNODEMESSAGE(MESSAGE * Msg, struct PORTCONTROL * PORT); +VOID NETROMMSG(struct _LINKTABLE * LINK, L3MESSAGEBUFFER * L3MSG); #ifndef LINBPQ BOOL CALLBACK EnumVARAWindowsProc(HWND hwnd, LPARAM lParam); @@ -88,6 +96,7 @@ static RECT Rect; extern struct TNCINFO * TNCInfo[41]; // Records are Malloc'd +extern void * TRACE_Q; BOOL VARAStopPort(struct PORTCONTROL * PORT) { @@ -490,7 +499,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } if (TNC->Streams[0].Attached) @@ -608,7 +617,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(buff->L2DATA, "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, buff->L2DATA)) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, buff->L2DATA)) { } else @@ -763,10 +772,12 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) if (TNC->CONNECTED) { + if (TNC->Streams[0].Connected) + VARASendCommand(TNC, "ABORT\r", TRUE); // GetSemaphore(&Semaphore, 52); // VARASendCommand(TNC, "CLOSE", FALSE); // FreeSemaphore(&Semaphore); -// Sleep(100); + Sleep(100); } shutdown(TNC->TCPSock, SD_BOTH); @@ -984,12 +995,12 @@ void * VARAExtInit(EXTPORTDATA * PortEntry) int i, port; char Msg[255]; char * ptr; + int line; APPLCALLS * APPL; struct TNCINFO * TNC; int AuxCount = 0; char Appl[11]; char * TempScript; - int line; struct PORTCONTROL * PORT = &PortEntry->PORTCONTROL; // // Will be called once for each VARA port @@ -1043,7 +1054,6 @@ void * VARAExtInit(EXTPORTDATA * PortEntry) TNC->RXRadio = TNC->TXRadio = PortEntry->PORTCONTROL.PORTINTERLOCK; PortEntry->PORTCONTROL.PROTOCOL = 10; - PortEntry->PORTCONTROL.PORTQUALITY = 0; PortEntry->MAXHOSTMODESESSIONS = 1; PortEntry->SCANCAPABILITIES = SIMPLE; // Scan Control - pending connect only @@ -1060,6 +1070,19 @@ void * VARAExtInit(EXTPORTDATA * PortEntry) TNC->ModemCentre = 1500; // WINMOR is always 1500 Offset + if (TNC->NRNeighbour) + { + // NETROM over VARA Link + + TNC->NetRomMode = 1; + TNC->LISTENCALLS = MYNETROMCALL; + PORT->PortNoKeepAlive = 1; + TNC->DummyLink = zalloc(sizeof(struct _LINKTABLE)); + TNC->DummyLink->LINKPORT = &TNC->PortRecord->PORTCONTROL; + } + else + PORT->PORTQUALITY = 0; + ptr=strchr(TNC->NodeCall, ' '); if (ptr) *(ptr) = 0; // Null Terminate @@ -1904,7 +1927,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TNC->HadConnect = TRUE; - if (TNC->PortRecord->ATTACHEDSESSIONS[0] == 0) + if (TNC->PortRecord->ATTACHEDSESSIONS[0] == 0 || (TNC->NetRomMode && STREAM->Connecting == 0)) { TRANSPORTENTRY * SESS; @@ -1916,7 +1939,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TNC->SessionTimeLimit = TNC->DefaultSessionTimeLimit; // Reset Limit - ProcessIncommingConnectEx(TNC, Call, 0, TRUE, TRUE); + ProcessIncommingConnectEx(TNC, Call, 0, (TNC->NetRomMode == 0), TRUE); SESS = TNC->PortRecord->ATTACHEDSESSIONS[0]; @@ -1961,7 +1984,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); Debugprintf("VARA Call from %s rejected", Call); return; } @@ -1986,13 +2009,33 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command((TRANSPORTENTRY *) -1, Status); Debugprintf("VARA Call from %s not in ValidCalls - rejected", Call); return; } } } + if (TNC->NetRomMode) + { + // send any queued data + + int bytes; + + if (TNC->NetRomTxLen) + { + + STREAM->PacketsSent++; + + bytes = send(TNC->TCPDataSock, TNC->NetRomTxBuffer, TNC->NetRomTxLen, 0); + STREAM->BytesTXed += TNC->NetRomTxLen; + + free(TNC->NetRomTxBuffer); + TNC->NetRomTxBuffer = NULL; + TNC->NetRomTxLen = 0; + } + return; + } // See which application the connect is for @@ -2075,18 +2118,39 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) char Reply[80]; int ReplyLen; - buffptr = GetBuff(); - if (buffptr == 0) + if (TNC->NetRomMode) { - return; // No buffers, so ignore + // send any queued data + + int bytes; + + if (TNC->NetRomTxLen) + { + + STREAM->PacketsSent++; + + bytes = send(TNC->TCPDataSock, TNC->NetRomTxBuffer, TNC->NetRomTxLen, 0); + STREAM->BytesTXed += TNC->NetRomTxLen; + free(TNC->NetRomTxBuffer); + TNC->NetRomTxBuffer = NULL; + TNC->NetRomTxLen = 0; + } } - ReplyLen = sprintf(Reply, "*** Connected to %s\r", TNC->TargetCall); + else + { + buffptr = GetBuff(); - buffptr->Len = ReplyLen; - memcpy(buffptr->Data, Reply, ReplyLen); + if (buffptr == 0) + return; // No buffers, so ignore - C_Q_ADD(&TNC->WINMORtoBPQ_Q, buffptr); + ReplyLen = sprintf(Reply, "*** Connected to %s\r", TNC->TargetCall); + + buffptr->Len = ReplyLen; + memcpy(buffptr->Data, Reply, ReplyLen); + + C_Q_ADD(&TNC->WINMORtoBPQ_Q, buffptr); + } TNC->Streams[0].Connecting = FALSE; TNC->Streams[0].Connected = TRUE; // Subsequent data to data channel @@ -2239,11 +2303,13 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) C_Q_ADD(&TNC->WINMORtoBPQ_Q, buffptr); } + + VOID VARAProcessReceivedData(struct TNCINFO * TNC) { int InputLen; - InputLen = recv(TNC->TCPDataSock, TNC->ARDOPDataBuffer, 8192, 0); + InputLen = recv(TNC->TCPDataSock, &TNC->ARDOPDataBuffer[TNC->DataInputLen], 8192 - TNC->DataInputLen, 0); if (InputLen == 0 || InputLen == SOCKET_ERROR) { @@ -2265,18 +2331,159 @@ VOID VARAProcessReceivedData(struct TNCINFO * TNC) TNC->Streams[0].Disconnecting = FALSE; - closesocket(TNC->TCPDataSock); TNC->TCPSock = 0; - return; } TNC->DataInputLen += InputLen; + + if (TNC->NetRomMode) + { + // Unpack KISS frames from data stream + + unsigned char c; + int n = 0; + int Len = TNC->DataInputLen; + unsigned char KISSBuffer[600]; + int KissLen = 0; + + while (Len) + { + Len--; + + c = TNC->ARDOPDataBuffer[n++]; + + if (TNC->ESCFLAG) + { + // + // FESC received - next should be TFESC or TFEND + + TNC->ESCFLAG = FALSE; + + if (c == TFESC) + c = FESC; + + if (c == TFEND) + c = FEND; + + } + else + { + switch (c) + { + case FEND: + + // + // Either start of message or message complete + // + + if (KissLen == 0) + { + // Start of Message. + + continue; + } + + // Have a complete KISS frame - remove from buffer and process + + if (KISSBuffer[0] == 255) + { + // NODE Message + + MESSAGE * Msg = GetBuff(); + + if (Msg) + { + // Set up header + + Msg->LENGTH = KissLen + (Msg->L2DATA - (unsigned char *)Msg); + memcpy(Msg->L2DATA, KISSBuffer, KissLen); + ConvToAX25(TNC->NRNeighbour, Msg->ORIGIN); + memcpy(Msg->DEST, NETROMCALL, 7); + + PROCESSNODEMESSAGE(Msg, &TNC->PortRecord->PORTCONTROL); + + Msg->PID = 0xcf; + Msg->PORT = TNC->Port | 0x80; + Msg->CTL = 3; + Msg->ORIGIN[6] |= 1; // set end of address + time(&Msg->Timestamp); + BPQTRACE(Msg, FALSE); + } + } + else + { + // Netrom Message + + L3MESSAGEBUFFER * L3MSG = GetBuff(); + MESSAGE * Buffer = GetBuff(); + + if (L3MSG) + { + // Set up header + + L3MSG->LENGTH = KissLen + (L3MSG->L3SRCE - (unsigned char *)L3MSG); + memcpy(L3MSG->L3SRCE, KISSBuffer, KissLen); + L3MSG->L3PID = 0xcf; + + // Create copy to pass to monitor + // To trace we need to reformat as MESSAGE + + Buffer->PID = 0xcf; + Buffer->PORT = TNC->Port; + Buffer->CTL = 3; + Buffer->LENGTH = KissLen + (Buffer->L2DATA - (unsigned char *)Buffer); + memcpy(Buffer->L2DATA, KISSBuffer, KissLen); + + ConvToAX25(TNC->NRNeighbour, Buffer->DEST); + memcpy(Buffer->ORIGIN, NETROMCALL, 7); + Buffer->ORIGIN[6] |= 1; // set end of address + time(&Buffer->Timestamp); + BPQTRACE(Buffer, FALSE); // TRACE + NETROMMSG(TNC->DummyLink, L3MSG); + } + } + + if (Len == 0) // All used + { + TNC->DataInputLen = 0; + } + else + { + memmove(TNC->ARDOPDataBuffer, &TNC->ARDOPDataBuffer[n], Len); + TNC->DataInputLen = Len; + KissLen = 0; + n = 0; + } + + continue; + + case FESC: + + TNC->ESCFLAG = TRUE; + continue; + + } + } + + // Ok, a normal char + + KISSBuffer[KissLen++] = c; + + if (KissLen > 590) + KissLen = 0; + + } + + // End of input - if there is stuff left in the input buffer we will add the next block to it + + return; + } VARAProcessDataPacket(TNC, TNC->ARDOPDataBuffer, TNC->DataInputLen); - TNC->DataInputLen=0; + TNC->DataInputLen = 0; return; } @@ -2303,7 +2510,9 @@ VOID VARAProcessReceivedControl(struct TNCINFO * TNC) TNC->TCPSock = 0; TNC->CONNECTED = FALSE; - TNC->Streams[0].ReportDISC = TRUE; + + if (TNC->Streams[0].Connecting || TNC->Streams[0].Connected) + TNC->Streams[0].ReportDISC = TRUE; TNC->Streams[0].Disconnecting = FALSE; @@ -2434,23 +2643,6 @@ static VOID CloseComplete(struct TNCINFO * TNC, int Stream) else if (TNC->DefaultMode == 54) VARASendCommand(TNC, "BW2750\r", TRUE); - // If a default frequency is specified, set it - - if (TNC->DefaultTXFreq && TNC->TXRadio) - { - char Msg[128]; - - sprintf(Msg, "R%d %f", TNC->TXRadio, TNC->DefaultTXFreq); - Rig_Command(-1, Msg); - } - - if (TNC->DefaultRXFreq && TNC->RXRadio && TNC->TXRadio != TNC->RXRadio) - { - char Msg[128]; - - sprintf(Msg, "R%d %f", TNC->RXRadio, TNC->DefaultRXFreq); - Rig_Command(-1, Msg); - } } @@ -2555,15 +2747,147 @@ VOID VARAReleaseTNC(struct TNCINFO * TNC) if (TNC->DefaultRadioCmd) { sprintf(TXMsg, "%d %s", TNC->Port, TNC->DefaultRadioCmd); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); } sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); ReleaseOtherPorts(TNC); } +void SendVARANetrom(struct TNCINFO * TNC, unsigned char * Data, int Len) +{ + // Check that PID is 0xcf, then just send the data portion of packet + + // We need to delimit packets, and KISS encoding seems as good as any. Also + // need to buffer to avoid sending lots of small packets and maybe to wait for + // link to connect + + unsigned char Kiss[600]; + int KissLen; + struct STREAMINFO * STREAM = &TNC->Streams[0]; + + if (TNC->CONNECTED == 0) + return; // Don't Queue if no connection to TNC + + KissLen = KissEncode(Data, Kiss, Len); + + TNC->NetRomTxBuffer = realloc(TNC->NetRomTxBuffer, TNC->NetRomTxLen + KissLen); + memcpy(&TNC->NetRomTxBuffer[TNC->NetRomTxLen], Kiss, KissLen); + TNC->NetRomTxLen += KissLen; + + if (STREAM->Connected) + { + int bytes; + + STREAM->PacketsSent++; + + bytes = send(TNC->TCPDataSock, TNC->NetRomTxBuffer, TNC->NetRomTxLen, 0); + STREAM->BytesTXed += TNC->NetRomTxLen; + + free(TNC->NetRomTxBuffer); + TNC->NetRomTxBuffer = NULL; + TNC->NetRomTxLen = 0; + return; + } + + if (TNC->Streams[0].Connecting == 0 && TNC->Streams[0].Connected == 0) + { + // Try to connect to Neighbour + + char Connect[32]; + + TNC->NetRomMode = 1; + + sprintf(Connect, "CONNECT %s %s\r", MYNETROMCALL, TNC->NRNeighbour); + + // Need to set connecting here as if we delay for busy we may incorrectly process OK response + + TNC->Streams[0].Connecting = TRUE; + + // 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"); + MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE); + + TNC->ConnectCmd = _strdup(Connect); + TNC->BusyDelay = TNC->BusyWait * 10; // BusyWait secs + return; + } + } + TNC->OverrideBusy = FALSE; + + VARASendCommand(TNC, Connect, TRUE); + TNC->Streams[0].ConnectTime = time(NULL); + + memset(TNC->Streams[0].RemoteCall, 0, 10); + strcpy(TNC->Streams[0].RemoteCall, MYNETROMCALL); + + sprintf(TNC->WEB_TNCSTATE, "%s Connecting to %s", TNC->Streams[0].MyCall, TNC->Streams[0].RemoteCall); + MySetWindowText(TNC->xIDC_TNCSTATE, TNC->WEB_TNCSTATE); + } +} + +void SendVARANetromNodes(struct TNCINFO * TNC, MESSAGE *Buffer) +{ + // Check that PID is 0xcf, then just send the data portion of packet + + int Len = Buffer->LENGTH - (Buffer->L2DATA - (unsigned char *)Buffer); + + if (Buffer->PID != 0xcf) + { + ReleaseBuffer(Buffer); + return; + } + + SendVARANetrom(TNC, Buffer->L2DATA, Len); + time(&Buffer->Timestamp); + + C_Q_ADD(&TRACE_Q, Buffer); + +} + +void SendVARANetromMsg(struct TNCINFO * TNC, L3MESSAGEBUFFER * MSG) +{ + MESSAGE * Buffer = (MESSAGE *)MSG; + + int Len = MSG->LENGTH - (MSG->L3SRCE - (unsigned char *)MSG); + + if (MSG->L3PID != 0xcf) + { + ReleaseBuffer(MSG); + return; + } + + SendVARANetrom(TNC, MSG->L3SRCE, Len); + + memmove(Buffer->L2DATA, MSG->L3SRCE, Len); + + // To trace we need to reformat as MESSAGE + + Buffer->PID = 0xcf; + Buffer->PORT = TNC->Port | 0x80; + Buffer->CTL = 3; + Buffer->LENGTH = Len + (Buffer->L2DATA - (unsigned char *)Buffer); + ConvToAX25(TNC->NRNeighbour, Buffer->DEST); + memcpy(Buffer->ORIGIN, NETROMCALL, 7); + Buffer->ORIGIN[6] |= 1; // set end of address + + time(&Buffer->Timestamp); + + C_Q_ADD(&TRACE_Q, Buffer); + +} + diff --git a/Versions.h b/Versions.h index 9dee428..d334e6a 100644 --- a/Versions.h +++ b/Versions.h @@ -10,8 +10,8 @@ #endif -#define KVers 6,0,23,59 -#define KVerstring "6.0.23.59\0" +#define KVers 6,0,23,66 +#define KVerstring "6.0.23.66\0" #ifdef CKernel diff --git a/WINMOR.c b/WINMOR.c index e84d200..6bdc70d 100644 --- a/WINMOR.c +++ b/WINMOR.c @@ -803,7 +803,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) sprintf(Msg, "%d SCANSTOP", TNC->Port); - Rig_Command(-1, Msg); + Rig_Command( (TRANSPORTENTRY *) -1, Msg); } @@ -992,7 +992,7 @@ static size_t ExtProc(int fn, int port, PDATAMESSAGE buff) { sprintf(&buff->L2DATA[0], "%d %s", TNC->Port, &buff->L2DATA[6]); - if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK->CIRCUITINDEX, &buff->L2DATA[0])) + if (Rig_Command(TNC->PortRecord->ATTACHEDSESSIONS[0]->L4CROSSLINK, &buff->L2DATA[0])) { } else @@ -1327,7 +1327,7 @@ VOID ReleaseTNC(struct TNCINFO * TNC) sprintf(TXMsg, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, TXMsg); + Rig_Command( (TRANSPORTENTRY *) -1, TXMsg); ReleaseOtherPorts(TNC); @@ -2176,7 +2176,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); Debugprintf("WINMOR Call from %s rejected", Call); return; } @@ -2201,7 +2201,7 @@ VOID ProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen) TidyClose(TNC, 0); sprintf(Status, "%d SCANSTART 15", TNC->Port); - Rig_Command(-1, Status); + Rig_Command( (TRANSPORTENTRY *) -1, Status); Debugprintf("WINMOR Call from %s not in ValidCalls - rejected", Call); return; } diff --git a/bpqmail.h b/bpqmail.h index ef2e78d..eb7323a 100644 --- a/bpqmail.h +++ b/bpqmail.h @@ -324,6 +324,9 @@ typedef struct ConnectionInfo_S #define WINLINKRO 0x020000 // WL2K RO (no J in SID) #define SYNCMODE 0x040000 // RMS RELAY SYNC #define MFJMODE 0x080000 // MFJ PMS +#define NEWPACCOM 0x100000 // PACCOM PMS 3.2 +#define SETCALLTOSENDER 0x200000 // Set calling call to message sender + struct FBBRestartData { diff --git a/cMain.c b/cMain.c index 7758eac..a0a0e24 100644 --- a/cMain.c +++ b/cMain.c @@ -428,7 +428,33 @@ Loop: if (Session) { + struct TNCINFO * TNC = PORTVEC->PORTCONTROL.TNC; + CloseSessionPartner(Session); + + // is this the place to run DisconnectScript? + + if (TNC->DisconnectScript) + { + int n = 0; + char command[256]; + struct DATAMESSAGE * Buffer; + + TRANSPORTENTRY Session = {0}; // = TNC->PortRecord->ATTACHEDSESSIONS[Sessno]; + + while (TNC->DisconnectScript[n]) + { + Buffer = GetBuff(); + if (Buffer) + { + Session.Secure_Session = 1; + Session.CIRCUITINDEX = -1; + Buffer->LENGTH = sprintf(Buffer->L2DATA, "%s\r", TNC->DisconnectScript[n++]) + (sizeof(void *) + 4); + CommandHandler(&Session, Buffer); + }; + } + } + PORTVEC->ATTACHEDSESSIONS[Sessno] = NULL; } return; @@ -698,9 +724,11 @@ BOOL Start() // if NETROMCALL Defined, use it - if (cfg->C_NETROMCALL[0]) + if (cfg->C_NETROMCALL[0] && cfg->C_NETROMCALL[0] != ' ') memcpy(MYNETROMCALL, cfg->C_NETROMCALL, 10); + strlop(MYNETROMCALL, ' '); + APPLCALLTABLE[0].APPLQUAL = BBSQUAL; if (cfg->C_WASUNPROTO == 0 && cfg->C_BTEXT) diff --git a/chatconfig.cfg b/chatconfig.cfg index 9a144ca..1533ced 100644 --- a/chatconfig.cfg +++ b/chatconfig.cfg @@ -2,7 +2,7 @@ Chat : { ApplNum = 2; MaxStreams = 11; - OtherChatNodes = "\r\n"; + OtherChatNodes = "RDGCHT:GB7RDG-1|C STHGTE|C 1 MB7NCR-2|C RDGCHT\r\nRDGCHT:GB7RDG-1|C STHGTE|C 1 MB7NCR-2|C RDGCHT\r\n\r\n"; ChatWelcomeMsg = "G8BPQ Chat Server.$WType /h for command summary.$WBringing up links to other nodes.$WThis may take a minute or two.$WThe /p command shows what nodes are linked.$W"; MapPosition = "MapPosition=5259.04N, 00107.01W"; MapPopup = "MapPopup=G8BPQ Nottingham

BPQ32 Home Page