diff --git a/src/cdmrmmdvmprotocol.cpp b/src/cdmrmmdvmprotocol.cpp index 3e8868e..2f6c84c 100644 --- a/src/cdmrmmdvmprotocol.cpp +++ b/src/cdmrmmdvmprotocol.cpp @@ -130,8 +130,8 @@ void CDmrmmdvmProtocol::Task(void) //std::cout << "DMRmmdvm DV last frame" << std::endl; OnDvLastFramePacketIn(LastFrame, &Ip); - } - else if ( IsValidConnectPacket(Buffer, &Callsign) ) + } + else if ( IsValidConnectPacket(Buffer, &Callsign, Ip) ) { std::cout << "DMRmmdvm connect packet from " << Callsign << " at " << Ip << std::endl; @@ -150,7 +150,7 @@ void CDmrmmdvmProtocol::Task(void) } } - else if ( IsValidAuthenticationPacket(Buffer, &Callsign) ) + else if ( IsValidAuthenticationPacket(Buffer, &Callsign, Ip) ) { std::cout << "DMRmmdvm authentication packet from " << Callsign << " at " << Ip << std::endl; @@ -203,7 +203,7 @@ void CDmrmmdvmProtocol::Task(void) } g_Reflector.ReleaseClients(); } - else if ( IsValidConfigPacket(Buffer, &Callsign) ) + else if ( IsValidConfigPacket(Buffer, &Callsign, Ip) ) { std::cout << "DMRmmdvm configuration packet from " << Callsign << " at " << Ip << std::endl; @@ -517,7 +517,7 @@ bool CDmrmmdvmProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign return valid; } -bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign) +bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip) { uint8 tag[] = { 'R','P','T','L' }; @@ -530,13 +530,13 @@ bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *c valid = callsign->IsValid(); if ( !valid) { - std::cout << "DMRmmdvm connect packet from unrecognized id " << (int)callsign->GetDmrid() << std::endl; + std::cout << "DMRmmdvm connect packet from IP address " << Ip << " / unrecognized id " << (int)callsign->GetDmrid() << std::endl; } } return valid; } -bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCallsign *callsign) +bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip) { uint8 tag[] = { 'R','P','T','K' }; @@ -547,6 +547,11 @@ bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCall callsign->SetDmrid(uiRptrId, true); callsign->SetModule('B'); valid = callsign->IsValid(); + if ( !valid) + { + std::cout << "DMRmmdvm authnetication packet from IP address " << Ip << " / unrecognized id " << (int)callsign->GetDmrid() << std::endl; + } + } return valid; } @@ -566,7 +571,7 @@ bool CDmrmmdvmProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign return valid; } -bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *callsign) +bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip) { uint8 tag[] = { 'R','P','T','C' }; @@ -577,6 +582,11 @@ bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *ca callsign->SetDmrid(uiRptrId, true); callsign->SetModule('B'); valid = callsign->IsValid(); + if ( !valid) + { + std::cout << "DMRmmdvm config packet from IP address " << Ip << " / unrecognized id " << (int)callsign->GetDmrid() << std::endl; + } + } return valid; } @@ -671,7 +681,7 @@ bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, CDvHeaderPa } // build DVHeader - CCallsign csMY = CCallsign("", uiSrcId); + CCallsign csMY = CCallsign("", uiSrcId); CCallsign rpt1 = CCallsign("", uiRptrId); rpt1.SetModule('B'); CCallsign rpt2 = m_ReflectorCallsign; diff --git a/src/cdmrmmdvmprotocol.h b/src/cdmrmmdvmprotocol.h index 2f221c5..c7acd98 100644 --- a/src/cdmrmmdvmprotocol.h +++ b/src/cdmrmmdvmprotocol.h @@ -86,10 +86,10 @@ protected: bool OnDvHeaderPacketIn(CDvHeaderPacket *, const CIp &, uint8, uint8); // packet decoding helpers - bool IsValidConnectPacket(const CBuffer &, CCallsign *); - bool IsValidAuthenticationPacket(const CBuffer &, CCallsign *); + bool IsValidConnectPacket(const CBuffer &, CCallsign *, const CIp &); + bool IsValidAuthenticationPacket(const CBuffer &, CCallsign *, const CIp &); bool IsValidDisconnectPacket(const CBuffer &, CCallsign *); - bool IsValidConfigPacket(const CBuffer &, CCallsign *); + bool IsValidConfigPacket(const CBuffer &, CCallsign *, const CIp &); bool IsValidOptionPacket(const CBuffer &, CCallsign *); bool IsValidKeepAlivePacket(const CBuffer &, CCallsign *); bool IsValidRssiPacket(const CBuffer &, CCallsign *, int *); diff --git a/src/cdmrplusprotocol.cpp b/src/cdmrplusprotocol.cpp index fb4f270..4106471 100644 --- a/src/cdmrplusprotocol.cpp +++ b/src/cdmrplusprotocol.cpp @@ -125,7 +125,7 @@ void CDmrplusProtocol::Task(void) delete Header; } } - else if ( IsValidConnectPacket(Buffer, &Callsign, &ToLinkModule) ) + else if ( IsValidConnectPacket(Buffer, &Callsign, &ToLinkModule, Ip) ) { //std::cout << "DMRplus keepalive/connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; @@ -404,7 +404,7 @@ void CDmrplusProtocol::HandleKeepalives(void) //////////////////////////////////////////////////////////////////////////////////////// // packet decoding helpers -bool CDmrplusProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, char *reflectormodule) +bool CDmrplusProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, char *reflectormodule, const CIp &Ip) { bool valid = false; if ( Buffer.size() == 31 ) @@ -421,7 +421,7 @@ bool CDmrplusProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *ca valid = (callsign->IsValid() && (std::isupper(*reflectormodule) || (*reflectormodule == ' ')) ); if ( !valid) { - std::cout << "DMRplus connect packet from unrecognized id " << (int)callsign->GetDmrid() << std::endl; + std::cout << "DMRplus connect packet from IP address " << Ip << " / unrecognized id " << (int)callsign->GetDmrid() << std::endl; } } return valid; diff --git a/src/cdmrplusprotocol.h b/src/cdmrplusprotocol.h index 430f741..4b9bb52 100644 --- a/src/cdmrplusprotocol.h +++ b/src/cdmrplusprotocol.h @@ -78,7 +78,7 @@ protected: bool OnDvHeaderPacketIn(CDvHeaderPacket *, const CIp &); // packet decoding helpers - bool IsValidConnectPacket(const CBuffer &, CCallsign *, char *); + bool IsValidConnectPacket(const CBuffer &, CCallsign *, char *, const CIp &); bool IsValidDisconnectPacket(const CBuffer &, CCallsign *, char *); bool IsValidDvHeaderPacket(const CIp &, const CBuffer &, CDvHeaderPacket **); bool IsValidDvFramePacket(const CIp &, const CBuffer &, CDvFramePacket **);