From 933e6c5b86d989cd13e9694fe53f910b5963c955 Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Sat, 6 Apr 2024 02:10:08 +0100 Subject: [PATCH] New upstream version 6.0.24.34 --- BPQChat.vcproj.LAPTOP-Q6S4RP5Q.johnw.user | 65 +++++++++ BPQChat.vcproj.SKIGACER.johnw.user | 65 +++++++++ BPQMail.vcproj.NOTTSDESKTOP.John.user | 65 +++++++++ BPQTermMDI.c | 5 +- BPQWinAPP.vcproj.LAPTOP-Q6S4RP5Q.johnw.user | 65 +++++++++ Bpq32.c | 3 +- CBPQ32.vcproj.LAPTOP-Q6S4RP5Q.johnw.user | 65 +++++++++ ...32.vcproj.NOTTSDESKTOP.John-notpi4-64.user | 65 +++++++++ CBPQ32.vcproj.NOTTSDESKTOP.John.user | 65 +++++++++ CBPQ32.vcproj.SKIGACER.johnw-notpi4-64.user | 65 +++++++++ CBPQ32.vcproj.SKIGACER.johnw.user | 65 +++++++++ CHeaders.h | 2 + CommonCode.c | 70 ++++++++++ HTTPcode.c | 2 +- IPCode.c | 129 ++++++++++-------- L2Code.c | 54 +------- MailNode.vcproj.NOTTSDESKTOP.John.user | 65 +++++++++ MailTCP.c | 5 + TelnetV6.c | 72 ++++++++++ Versions.h | 4 +- ...rControl.vcproj.LAPTOP-Q6S4RP5Q.johnw.user | 65 +++++++++ asmstrucs.h | 1 + bpq32.h | 2 + cMain.c | 1 + config.c | 18 ++- configstructs.h | 1 + nodeapi.c | 51 +++++-- tncinfo.h | 2 + 28 files changed, 1011 insertions(+), 126 deletions(-) create mode 100644 BPQChat.vcproj.LAPTOP-Q6S4RP5Q.johnw.user create mode 100644 BPQChat.vcproj.SKIGACER.johnw.user create mode 100644 BPQMail.vcproj.NOTTSDESKTOP.John.user create mode 100644 BPQWinAPP.vcproj.LAPTOP-Q6S4RP5Q.johnw.user create mode 100644 CBPQ32.vcproj.LAPTOP-Q6S4RP5Q.johnw.user create mode 100644 CBPQ32.vcproj.NOTTSDESKTOP.John-notpi4-64.user create mode 100644 CBPQ32.vcproj.NOTTSDESKTOP.John.user create mode 100644 CBPQ32.vcproj.SKIGACER.johnw-notpi4-64.user create mode 100644 CBPQ32.vcproj.SKIGACER.johnw.user create mode 100644 MailNode.vcproj.NOTTSDESKTOP.John.user create mode 100644 WinmorControl.vcproj.LAPTOP-Q6S4RP5Q.johnw.user diff --git a/BPQChat.vcproj.LAPTOP-Q6S4RP5Q.johnw.user b/BPQChat.vcproj.LAPTOP-Q6S4RP5Q.johnw.user new file mode 100644 index 0000000..0cd9a72 --- /dev/null +++ b/BPQChat.vcproj.LAPTOP-Q6S4RP5Q.johnw.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/BPQChat.vcproj.SKIGACER.johnw.user b/BPQChat.vcproj.SKIGACER.johnw.user new file mode 100644 index 0000000..b5b0536 --- /dev/null +++ b/BPQChat.vcproj.SKIGACER.johnw.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/BPQMail.vcproj.NOTTSDESKTOP.John.user b/BPQMail.vcproj.NOTTSDESKTOP.John.user new file mode 100644 index 0000000..fa82c00 --- /dev/null +++ b/BPQMail.vcproj.NOTTSDESKTOP.John.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/BPQTermMDI.c b/BPQTermMDI.c index d07eb39..447cde3 100644 --- a/BPQTermMDI.c +++ b/BPQTermMDI.c @@ -4817,6 +4817,7 @@ BOOL CreateMonitorWindow(char * MonSize) Cinfo->hConsole = ChildWnd; // return if its not possible to create the child window + if(NULL == ChildWnd) { return 0; @@ -4839,8 +4840,8 @@ BOOL CreateMonitorWindow(char * MonSize) Cinfo = &MonWindow; -// MoveWindow(Cinfo->hConsole, Rect.left - (OffsetW /2), Rect.top - OffsetH, -// Rect.right-Rect.left, Rect.bottom-Rect.top, TRUE); + MoveWindow(ChildWnd, Rect.left - (OffsetW /2), Rect.top - OffsetH, Rect.right - Rect.left, Rect.bottom - Rect.top, TRUE); + MoveWindows(Cinfo); diff --git a/BPQWinAPP.vcproj.LAPTOP-Q6S4RP5Q.johnw.user b/BPQWinAPP.vcproj.LAPTOP-Q6S4RP5Q.johnw.user new file mode 100644 index 0000000..0cd9a72 --- /dev/null +++ b/BPQWinAPP.vcproj.LAPTOP-Q6S4RP5Q.johnw.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Bpq32.c b/Bpq32.c index c7b939c..ea24778 100644 --- a/Bpq32.c +++ b/Bpq32.c @@ -1211,6 +1211,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses // Fix possible crash in SCSPactor PTCPORT code (29) // Add NodeAPI call sendLinks and remove get from other calls (32) // Improve validation of Web Beacon Config (33) +// Support SNMP via host ip stack as well as IPGateway (34) #define CKernel @@ -6477,7 +6478,7 @@ VOID SaveBPQ32Windows() SaveMDIWindowPos(StatusWnd, "", "StatusWindowSize", StatusMinimized); SaveMDIWindowPos(hConsWnd, "", "WindowSize", ConsoleMinimized); - for (i=0;iPORTCONTROL.PORTTYPE == 0x10) // External { diff --git a/CBPQ32.vcproj.LAPTOP-Q6S4RP5Q.johnw.user b/CBPQ32.vcproj.LAPTOP-Q6S4RP5Q.johnw.user new file mode 100644 index 0000000..ddedde2 --- /dev/null +++ b/CBPQ32.vcproj.LAPTOP-Q6S4RP5Q.johnw.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/CBPQ32.vcproj.NOTTSDESKTOP.John-notpi4-64.user b/CBPQ32.vcproj.NOTTSDESKTOP.John-notpi4-64.user new file mode 100644 index 0000000..f4ba73a --- /dev/null +++ b/CBPQ32.vcproj.NOTTSDESKTOP.John-notpi4-64.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/CBPQ32.vcproj.NOTTSDESKTOP.John.user b/CBPQ32.vcproj.NOTTSDESKTOP.John.user new file mode 100644 index 0000000..f4ba73a --- /dev/null +++ b/CBPQ32.vcproj.NOTTSDESKTOP.John.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/CBPQ32.vcproj.SKIGACER.johnw-notpi4-64.user b/CBPQ32.vcproj.SKIGACER.johnw-notpi4-64.user new file mode 100644 index 0000000..03fb73a --- /dev/null +++ b/CBPQ32.vcproj.SKIGACER.johnw-notpi4-64.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/CBPQ32.vcproj.SKIGACER.johnw.user b/CBPQ32.vcproj.SKIGACER.johnw.user new file mode 100644 index 0000000..03fb73a --- /dev/null +++ b/CBPQ32.vcproj.SKIGACER.johnw.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/CHeaders.h b/CHeaders.h index caf288b..163cab5 100644 --- a/CHeaders.h +++ b/CHeaders.h @@ -426,3 +426,5 @@ extern char Message[MaxBPQPortNo + 1][1000]; // Beacon Text extern int MinCounter[MaxBPQPortNo + 1]; // Interval Countdown extern BOOL SendFromFile[MaxBPQPortNo + 1]; + +DllExport uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqStringMhz); \ No newline at end of file diff --git a/CommonCode.c b/CommonCode.c index da9b2d7..29555b8 100644 --- a/CommonCode.c +++ b/CommonCode.c @@ -4753,6 +4753,7 @@ LRESULT CALLBACK UIWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam extern struct DATAMESSAGE * REPLYBUFFER; char * __cdecl Cmdprintf(TRANSPORTENTRY * Session, char * Bufferptr, const char * format, ...); + void GetPortCTEXT(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CMD) { char FN[250]; @@ -4816,6 +4817,75 @@ void GetPortCTEXT(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CM Debugprintf("CTEXT Read for ports %s\r", &PortList[1]); } +// Get the current frequency for a port. This can get a bit complicated, especially if looking for centre freq +// rather than dial freq (as this depends on mode). +// +// Used for various reporting functions - MH, Maps, BBS New User message, + +// I think I'll try PORT "PortFreq" setting first then if that isn't available via rigcontrol. +// +// For now at least will report dial freq if using RIGCONTROL + +DllExport uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqString) +{ + struct PORTCONTROL * PORT = GetPortTableEntryFromPortNum(PortNo); + double freq = 0.0; + uint64_t freqint = 0; + + char * ptr; + int n = 3; + + FreqString[0] = 0; + + if (PORT == 0) + return 0; + + if (PORT->PortFreq) + { + freqint = PORT->PortFreq; + freq = freqint / 1000000.0; + } + else + { + // Try rigcontrol + + + struct TNCINFO * TNC; + struct RIGINFO * RIG = 0; + int RigPort; + + if (PORT->RIGPort) + TNC = TNCInfo[PORT->RIGPort]; + else + TNC = TNCInfo[PortNo]; + + if (TNC) + RIG = TNC->RIG; + + if (RIG == 0) + return 0; + + // Frequency should be in valchar + + if (RIG->Valchar[0] == 0) + return 0; + + freq = atof(TNC->RIG->Valchar); + freqint = (int64_t)(freq * 1000000.0); + } + + sprintf(FreqString, "%.6f", freq); + + // Return 3 digits after . (KHz) unless more are significant + + ptr = &FreqString[strlen(FreqString) - 1]; + + while (n-- && *(ptr) == '0') + *ptr-- = 0; + + return freqint; +} + SOCKET OpenHTTPSock(char * Host) { SOCKET sock = 0; diff --git a/HTTPcode.c b/HTTPcode.c index 0e62928..367146d 100644 --- a/HTTPcode.c +++ b/HTTPcode.c @@ -2482,7 +2482,7 @@ doHeader: UIUIDigi[Slot] = _strdup(&Param[0]); GetParam(input, "File=", &Param[0]); - strcpy(FN[Slot], &Param[1]); + strcpy(FN[Slot], &Param[0]); GetParam(input, "Text=", &Param[0]); strcpy(Message[Slot], &Param[0]); diff --git a/IPCode.c b/IPCode.c index 7958b73..808840c 100644 --- a/IPCode.c +++ b/IPCode.c @@ -5179,33 +5179,17 @@ int BuildReply(UCHAR * Buffer, int Offset, UCHAR * OID, int OIDLen, UCHAR * Valu // snmpget -v1 -c jnos [ve4klm.ampr.org | www.langelaar.net] 1.3.6.1.2.1.2.2.1.16.5 - -VOID ProcessSNMPMessage(PIPMSG IPptr) +int ProcessSNMPPayload(UCHAR * Msg, int Len, UCHAR * Reply, int * OffPtr) { - int Len; - PUDPMSG UDPptr = (PUDPMSG)&IPptr->Data; char Community[256]; UCHAR OID[256]; int OIDLen; - UCHAR * Msg; int Type; int Length, ComLen; int IntVal; int ReqID; int RequestType; - Len = ntohs(IPptr->IPLENGTH); - Len-=20; - - Check_Checksum(UDPptr, Len); - - // 4 bytes version - // Null Terminated Community - - Msg = (char *) UDPptr; - - Msg += 8; // Over UDP Header - Len -= 8; // ASN 1 Encoding - Type, Len, Data @@ -5217,7 +5201,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) // First should be a Sequence if (Type != 0x30) - return; + return 0; Len -= 2; @@ -5228,7 +5212,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) // Should be Integer - SNMP Version - We support V1, identified by zero if (Type != 2 || Length != 1 || IntVal != 0) - return; + return 0; Len -= 3; @@ -5238,7 +5222,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) // Should Be String (community) if (Type != 4) - return; + return 0; memcpy(Community, Msg, ComLen); Community[ComLen] = 0; @@ -5264,23 +5248,23 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Length = *(Msg++); if (Type != 2) - return; + return 0; ReqID = ASNGetInt(Msg, Length); - + Len -= (2 + Length); Msg += Length; // Two more Integers - error status, error index - + Type = *(Msg++); Length = *(Msg++); if (Type != 2) - return; + return 0; ASNGetInt(Msg, Length); - + Len -= (2 + Length); Msg += Length; @@ -5288,10 +5272,10 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Length = *(Msg++); if (Type != 2) - return; + return 0; ASNGetInt(Msg, Length); - + Len -= (2 + Length); Msg += Length; @@ -5303,7 +5287,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Len -= 2; if (Type != 0x30) - return; + return 0; Type = *(Msg++); Length = *(Msg++); @@ -5311,7 +5295,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Len -= 2; if (Type != 0x30) - return; + return 0; // Next is OID @@ -5319,7 +5303,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Length = *(Msg++); if (Type != 6) // Object ID - return; + return 0; memcpy(OID, Msg, Length); OID[Length] = 0; @@ -5328,16 +5312,16 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Len -=2; // Header Len -= Length; - + Msg += Length; // Should Just have a null value left - + Type = *(Msg++); Length = *(Msg++); if (Type != 5 || Length != 0) - return; + return 0; Len -=2; // Header @@ -5346,12 +5330,11 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) if (RequestType = 160) { - UCHAR Reply[256]; int Offset = 255; - int PDULen, SendLen; + int PDULen = 0; char Value[256]; int ValLen; - + // Only Support Get if (memcmp(OID, sysName, sysNameLen) == 0) @@ -5360,7 +5343,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Value[0] = 4; // String Value[1] = ValLen; memcpy(&Value[2], MYNODECALL, ValLen); - + PDULen = BuildReply(Reply, Offset, sysName, sysNameLen, Value, ReqID); } else if (memcmp(OID, sysUpTime, sysUpTimeLen) == 0) @@ -5390,7 +5373,7 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) } else - return; + return 0; Offset -= PDULen; Offset -= ComLen; @@ -5408,25 +5391,59 @@ VOID ProcessSNMPMessage(PIPMSG IPptr) Reply[--Offset] = PDULen + ComLen + 5; Reply[--Offset] = 48; - SendLen = PDULen + ComLen + 7; + *OffPtr = Offset; - memcpy(UDPptr->UDPData, &Reply[Offset], SendLen); - - // Swap Dest to Origin - - IPptr->IPDEST = IPptr->IPSOURCE; - - IPptr->IPSOURCE.addr = OurIPAddr; - - UDPptr->DESTPORT = UDPptr->SOURCEPORT; - UDPptr->SOURCEPORT = htons(161); - SendLen += 8; // UDP Header - UDPptr->LENGTH = htons(SendLen); - IPptr->IPLENGTH = htons(SendLen + 20); - - CheckSumAndSendUDP(IPptr, UDPptr, SendLen); + return PDULen + ComLen + 7; } - - // Ingnore others + return 0; } +VOID ProcessSNMPMessage(PIPMSG IPptr) +{ + int Len; + PUDPMSG UDPptr = (PUDPMSG)&IPptr->Data; + UCHAR * Msg; + int Type; + int Length, ComLen; + int IntVal; + UCHAR Reply[256]; + int PDULen, SendLen; + int Offset = 0; + + Len = ntohs(IPptr->IPLENGTH); + Len-=20; + + Check_Checksum(UDPptr, Len); + + // 4 bytes version + // Null Terminated Community + + Msg = (char *) UDPptr; + + Msg += 8; // Over UDP Header + Len -= 8; + + SendLen = ProcessSNMPPayload(Msg, Len, Reply, &Offset); + + if (SendLen == 0) + return; + + memcpy(UDPptr->UDPData, &Reply[Offset], SendLen); + + // Swap Dest to Origin + + IPptr->IPDEST = IPptr->IPSOURCE; + + IPptr->IPSOURCE.addr = OurIPAddr; + + UDPptr->DESTPORT = UDPptr->SOURCEPORT; + UDPptr->SOURCEPORT = htons(161); + SendLen += 8; // UDP Header + UDPptr->LENGTH = htons(SendLen); + IPptr->IPLENGTH = htons(SendLen + 20); + + CheckSumAndSendUDP(IPptr, UDPptr, SendLen); +} + + + diff --git a/L2Code.c b/L2Code.c index 37a8aff..718f012 100644 --- a/L2Code.c +++ b/L2Code.c @@ -470,61 +470,15 @@ VOID MHPROC(struct PORTCONTROL * PORT, MESSAGE * Buffer) PMHSTRUC MHBASE = MH; int i; int OldCount = 0; - char Freq[16] = ""; + char Freq[64] = ""; char DIGI = '*'; double ReportFreq = 0; - // if port has Rigcontrol associated with it, get frequency + // if port has a freq associated with it use it - struct TNCINFO * TNC = PORT->TNC; + GetPortFrequency(PORT->PORTNUMBER, Freq); - if (TNC && TNC->RIG && TNC->RIG->Valchar[0]) - { - if (TNC->Hardware == H_UZ7HO) - { - // See if we have Center Freq Info - if (TNC->AGWInfo->CenterFreq) - { - ReportFreq = atof(TNC->RIG->Valchar) + ((TNC->AGWInfo->CenterFreq * 1.0) / 1000000.0); - } -#ifdef WIN32 - else if (TNC->AGWInfo->hFreq) - { - char Centre[16]; - double ModemFreq; - - SendMessage(TNC->AGWInfo->hFreq, WM_GETTEXT, 15, (LPARAM)Centre); - - ModemFreq = atof(Centre); - - ReportFreq = atof(TNC->RIG->Valchar) + (ModemFreq / 1000000); - } -#endif - else - ReportFreq = atof(TNC->RIG->Valchar) + 0.0015; // Assume 1500 - } - else - - // Not UZ7HO or Linux - - ReportFreq = atof(TNC->RIG->Valchar) + 0.0015; - - _gcvt(ReportFreq, 9, Freq); - } - else - { - if (PORT->RIGPort) - { - struct TNCINFO * TNC = TNCInfo[PORT->RIGPort]; - - if (TNC && TNC->RIG) - { - strcpy(Freq, TNC->RIG->Valchar); - Freq[11] = 0; - } - } - } -// if (Buffer->ORIGIN[6] & 1) + // if (Buffer->ORIGIN[6] & 1) DIGI = 0; // DOn't think we want to do this // See if in list diff --git a/MailNode.vcproj.NOTTSDESKTOP.John.user b/MailNode.vcproj.NOTTSDESKTOP.John.user new file mode 100644 index 0000000..fa82c00 --- /dev/null +++ b/MailNode.vcproj.NOTTSDESKTOP.John.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/MailTCP.c b/MailTCP.c index 74f2727..a08632d 100644 --- a/MailTCP.c +++ b/MailTCP.c @@ -859,6 +859,11 @@ BOOL CheckforMIME(SocketConn * sockptr, char * Msg, char ** Body, int * MsgLen) int Files = 0; + if (*MsgLen > 5000000) + { + int xxx = 1; + } + ptr = Msg; while(*ptr != 13) diff --git a/TelnetV6.c b/TelnetV6.c index efec041..a80a325 100644 --- a/TelnetV6.c +++ b/TelnetV6.c @@ -85,6 +85,7 @@ void processDRATSFrame(unsigned char * Message, int Len, struct ConnectionInfo * void DRATSConnectionLost(struct ConnectionInfo * sockptr); int BuildRigCtlPage(char * _REPLYBUFFER); void ProcessWebmailWebSockThread(void * conn); +int ProcessSNMPPayload(UCHAR * Msg, int Len, UCHAR * Reply, int * OffPtr); #ifndef LINBPQ extern HKEY REGTREE; @@ -540,6 +541,9 @@ int ProcessLine(char * buf, int Port) else if (_stricmp(param,"SYNCPORT") == 0) TCP->SyncPort = atoi(value); + else if (_stricmp(param,"SNMPPORT") == 0) + TCP->SNMPPort = atoi(value); + else if ((_stricmp(param,"CMDPORT") == 0) || (_stricmp(param,"LINUXPORT") == 0)) { int n = 0; @@ -1562,6 +1566,46 @@ void * TelnetExtInit(EXTPORTDATA * PortEntry) return ExtProc; } +SOCKET OpenUDPSocket(struct TNCINFO * TNC) +{ + u_long param = 1; + struct sockaddr_in sinx; + int err, ret; + struct TCPINFO * TCP = TNC->TCPInfo; + char Msg[80]; + + TCP->SNMPsock = socket(AF_INET,SOCK_DGRAM,0); + + if (TCP->SNMPsock == INVALID_SOCKET) + { + WritetoConsoleLocal("Failed to create SNMP UDP socket"); + return 0; + } + + ioctl (TCP->SNMPsock, FIONBIO, ¶m); + + sinx.sin_family = AF_INET; + sinx.sin_addr.s_addr = INADDR_ANY; + + sinx.sin_port = htons(TCP->SNMPPort); + + ret = bind(TCP->SNMPsock, (struct sockaddr *) &sinx, sizeof(sinx)); + + if (ret != 0) + { + // Bind Failed + + err = WSAGetLastError(); + sprintf(Msg, "Bind Failed for SNMP UDP socket %d - error code = %d", TCP->SNMPPort, err); + WritetoConsoleLocal(Msg); + return 0; + } + + return TCP->SNMPsock; +} + + + SOCKET OpenSocket4(struct TNCINFO * xTNC, int port) { struct sockaddr_in local_sin; /* Local socket - internet style */ @@ -1658,6 +1702,9 @@ BOOL OpenSockets(struct TNCINFO * TNC) if (TCP->DRATSPort) TCP->DRATSsock = OpenSocket4(TNC, TCP->DRATSPort); + if (TCP->SNMPPort) + TCP->SNMPsock = OpenUDPSocket(TNC); + CMSUser.UserName = _strdup("CMS"); TriModeUser.Secure = TRUE; @@ -2181,6 +2228,31 @@ VOID TelnetPoll(int Port) nosocks: + // Try SNMP + + if (TCP->SNMPsock) + { + struct sockaddr_in rxaddr; + char rxbuff[500]; + int addrlen = sizeof(struct sockaddr_in); + int Offset = 0; + + int len = recvfrom(TCP->SNMPsock, rxbuff, 500, 0,(struct sockaddr *)&rxaddr, &addrlen); + + if (len > 0) + { + UCHAR Reply[256]; + int SendLen; + + SendLen = ProcessSNMPPayload(rxbuff, len, Reply, &Offset); + + if (SendLen == 0) + return; + + sendto(TCP->SNMPsock, &Reply[Offset], SendLen, 0, (struct sockaddr *)&rxaddr, addrlen); + return; + } + } while (TELNETMONVECPTR->HOSTTRACEQ) { int len; diff --git a/Versions.h b/Versions.h index b83cbbe..ebcdca1 100644 --- a/Versions.h +++ b/Versions.h @@ -10,8 +10,8 @@ #endif -#define KVers 6,0,24,33 -#define KVerstring "6.0.24.33\0" +#define KVers 6,0,24,34 +#define KVerstring "6.0.24.34\0" #ifdef CKernel diff --git a/WinmorControl.vcproj.LAPTOP-Q6S4RP5Q.johnw.user b/WinmorControl.vcproj.LAPTOP-Q6S4RP5Q.johnw.user new file mode 100644 index 0000000..0cd9a72 --- /dev/null +++ b/WinmorControl.vcproj.LAPTOP-Q6S4RP5Q.johnw.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/asmstrucs.h b/asmstrucs.h index 60f5853..1b56291 100644 --- a/asmstrucs.h +++ b/asmstrucs.h @@ -690,6 +690,7 @@ typedef struct PORTCONTROL time_t SmartIDNeeded; // Time to send next smart ID time_t SmartIDInterval; // Smart ID Interval (Secs) int SendtoM0LTEMap; + uint64_t PortFreq; // Configured freq } PORTCONTROLX, *PPORTCONTROL; diff --git a/bpq32.h b/bpq32.h index dd06288..bdc5a20 100644 --- a/bpq32.h +++ b/bpq32.h @@ -264,6 +264,8 @@ int APIENTRY CountFramesQueuedOnStream(int Stream); char * APIENTRY GetLOC(); +DllExport uint64_t APIENTRY GetPortFrequency(int PortNo, char * FreqString); + #else struct PORTCONTROL * (FAR WINAPI * GetPortTableEntryFromPortNum) (int portnum); diff --git a/cMain.c b/cMain.c index 7ca9e2e..eb529f6 100644 --- a/cMain.c +++ b/cMain.c @@ -1079,6 +1079,7 @@ BOOL Start() } PORT->SendtoM0LTEMap = PortRec->SendtoM0LTEMap; + PORT->PortFreq = PortRec->PortFreq; if (PortRec->BBSFLAG) // Appl 1 not permitted - BBSFLAG=NOBBS PORT->PERMITTEDAPPLS &= 0xfffffffe; // Clear bottom bit diff --git a/config.c b/config.c index 42d85f4..74473ce 100644 --- a/config.c +++ b/config.c @@ -251,6 +251,8 @@ int tnctypes(int i,char *value,char *rec); int do_kiss(char *value,char *rec); int decode_ded_rec(char *rec); int simple(int i); +int64_t int64_value(int64_t * val, char value[], char rec[]); + int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF); int doSerialPortName(int i, char * value, char * rec); @@ -364,7 +366,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"}; /* parameter keywords */ +"SMARTID", "KISSCOMMAND", "SendtoM0LTEMap", "PortFreq"}; /* parameter keywords */ static void * poffset[] = { @@ -378,7 +380,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}; /* offset for corresponding data in config file */ +&xxp.SmartID, &xxp.KissParams, &xxp.SendtoM0LTEMap, &xxp.PortFreq}; /* offset for corresponding data in config file */ static int proutine[] = { @@ -392,7 +394,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}; /* routine to process parameter */ +1, 20, 1, 21}; /* routine to process parameter */ int PPARAMLIM = sizeof(proutine)/sizeof(int); @@ -1326,6 +1328,11 @@ int int_value(short * val, char value[], char rec[]) return(1); } +int64_t int64_value(int64_t * val, char value[], char rec[]) +{ + *val = strtoll(value, NULL, 10); + return(1); +} /************************************************************************/ /* VALIDATE HEX INT VALUES */ @@ -2227,6 +2234,11 @@ int decode_port_rec(char * rec) cn = doKissCommand(i, value, rec); // Permitted Apps break; + case 21: + cn = int64_value(poffset[i], value, rec); /* INTEGER VALUES */ + break; + + case 9: diff --git a/configstructs.h b/configstructs.h index 9dae4fb..231cfd8 100644 --- a/configstructs.h +++ b/configstructs.h @@ -78,6 +78,7 @@ struct PORTCONFIG int SmartID; unsigned char * KissParams; int SendtoM0LTEMap; + uint64_t PortFreq; }; struct ROUTECONFIG diff --git a/nodeapi.c b/nodeapi.c index eef71e8..395f9f9 100644 --- a/nodeapi.c +++ b/nodeapi.c @@ -41,8 +41,9 @@ int sendNodeList(char * response, char * token,int Flags); int sendUserList(char * response, char * token,int Flags); int sendInfo(char * response, char * token, int Flags); int sendLinks(char * response, char * token, int Flags); -int sendPortMHList(char * response, char * token, int Flags); +int sendPortMHList(char * response, char * token, int param); +void BuildPortMH(char * MHJSON, struct PORTCONTROL * PORT); DllExport struct PORTCONTROL * APIENTRY GetPortTableEntryFromSlot(int portslot); // Token list @@ -67,17 +68,43 @@ int APIProcessHTTPMessage(char * response, char * Method, char * URL, char * req char * token_begin = strstr(request, auth_header); char token[TOKEN_SIZE + 1]= ""; int Flags = 0; - char * Tok = strlop(URL, '?'); - char * param = strlop(Tok, '&'); - if (param) - Flags = atoi(param); + // Node Flags isn't currently used - if (Tok && strlen(Tok) == TOKEN_SIZE) + char * Tok; + char * param; + + if (token_begin) { - // assume auth token + // Using Auth Header - strcpy(token, Tok); + // Extract the token from the request (assuming it's present in the request headers) + + if (token_begin == NULL) + { + Debugprintf("Invalid request: No authentication token provided.\n"); + return send_http_response(response, "403 (Forbidden)"); + } + + token_begin += strlen(auth_header); // Move to the beginning of the token + strncpy(token, token_begin, TOKEN_SIZE); + token[TOKEN_SIZE] = '\0'; // Null-terminate the token + + param = strlop(URL, '?'); + } + else + { + // Token must be first param of URL + + Tok = strlop(URL, '?'); + param = strlop(Tok, '&'); + + if (Tok && strlen(Tok) == TOKEN_SIZE) + { + // assume auth token + + strcpy(token, Tok); + } } remove_expired_tokens(); // Tidy up @@ -123,7 +150,7 @@ int APIProcessHTTPMessage(char * response, char * Method, char * URL, char * req else if (_stricmp(URL, "/api/links") == 0) return sendLinks(response, token, Flags); else if (strstr(URL, "/api/mheardport") != 0) - return sendPortMHList(response, token, Flags); + return sendPortMHList(response, token, atoi(param)); return send_http_response(response, "401 Invalid API Call"); } @@ -145,6 +172,7 @@ int request_token(char * response) Token * generate_token() { // Generate a random authentication token + int i; Token * token = malloc(sizeof(Token)); @@ -159,6 +187,7 @@ Token * generate_token() } // Function to add the token to the token_list + void add_token_to_list(Token* token) { if (token_list == NULL) @@ -706,9 +735,9 @@ int sendLinks(char * response, char * token, int Flags) return ReplyLen; } -int sendPortMHList(char * response, char * token, int Flags) +int sendPortMHList(char * response, char * token, int param) { - struct PORTCONTROL * PORTVEC = GetPortTableEntryFromPortNum(Flags); + struct PORTCONTROL * PORTVEC = GetPortTableEntryFromPortNum(param); response[0] = 0; diff --git a/tncinfo.h b/tncinfo.h index 9b9cb54..fa8f4c9 100644 --- a/tncinfo.h +++ b/tncinfo.h @@ -113,6 +113,7 @@ struct TCPINFO int APIPort; int TriModePort; int SyncPort; + int SNMPPort; int DRATSPort; int CMDPort[33]; char RELAYHOST[64]; @@ -165,6 +166,7 @@ struct TCPINFO SOCKET TriModeDataSock; SOCKET Syncsock; SOCKET DRATSsock; + SOCKET SNMPsock; struct ConnectionInfo * TriModeControlSession; SOCKET sock6;