complete logging of unknown packets

pull/3/head
Tom Early 5 years ago
parent 830edf8bc2
commit 2ef2b0462e

@ -219,3 +219,49 @@ void CBuffer::DebugDumpAscii(std::ofstream &debugout) const
}
}
}
void CBuffer::Dump(const std::string &title)
{
std::cout << title << ":" << std::endl;
unsigned int offset = 0U;
unsigned int length = m_data.size();
while (length > 0U) {
std::string output;
unsigned int bytes = (length > 16U) ? 16U : length;
char temp[10U];
for (unsigned i = 0U; i < bytes; i++) {
::sprintf(temp, "%02X ", m_data[offset + i]);
output += temp;
}
for (unsigned int i = bytes; i < 16U; i++)
output += " ";
output += " *";
for (unsigned i = 0U; i < bytes; i++) {
unsigned char c = m_data[offset + i];
if (::isprint(c))
output += c;
else
output += '.';
}
output += '*';
::sprintf(temp, "%04X: ", offset);
std::cout << offset << output << std::endl;
offset += 16U;
if (length >= 16U)
length -= 16U;
else
length = 0U;
}
}

@ -67,6 +67,7 @@ public:
// debug
void DebugDump(std::ofstream &) const;
void DebugDumpAscii(std::ofstream &) const;
void Dump(const std::string &title);
// pass through
void clear() { m_data.clear(); }

@ -165,7 +165,9 @@ void CDcsProtocol::Task(void)
else
{
// invalid packet
std::cout << "DCS packet (" << Buffer.size() << ") from " << Ip << std::endl;
std::string title("Unknown DCS packet from ");
title += Ip.GetAddress();
Buffer.Dump(title);
}
}

@ -188,8 +188,9 @@ void CDextraProtocol::Task(void)
}
else
{
std::cout << "DExtra packet (" << Buffer.size() << ")" << std::endl;
//std::cout << Buffer.data() << std::endl;
std::string title("Unknown DExtra packet from ");
title += Ip.GetAddress();
Buffer.Dump(title);
}
}

@ -234,8 +234,8 @@ void CDmrmmdvmProtocol::Task(void)
}
else if ( Buffer.size() != 55 )
{
std::cout << "DMRmmdvm packet (" << Buffer.size() << ")" << std::endl;
//std::cout << Buffer << std::endl;
std::string title("Unknown DMRMMDVM packet from ");
title += Ip.GetAddress();
}
}

@ -156,6 +156,12 @@ void CDmrplusProtocol::Task(void)
}
g_Reflector.ReleaseClients();
}
else
{
std::string title("Unknown DMR+ packet from ");
title += Ip.GetAddress();
Buffer.Dump(title);
}
}
// handle end of streaming timeout

@ -153,7 +153,9 @@ void CDplusProtocol::Task(void)
}
else
{
std::cout << "DPlus packet (" << Buffer.size() << ")" << std::endl;
std::string title("Unknown DPlus packet from ");
title += Ip.GetAddress();
Buffer.Dump(title);
}
}

@ -189,7 +189,9 @@ void CXlxProtocol::Task(void)
}
else
{
std::cout << "XLX packet (" << Buffer.size() << ")" << std::endl;
std::string title("Unknown XLX packet from ");
title += Ip.GetAddress();
Buffer.Dump(title);
}
}

@ -195,9 +195,9 @@ void CYsfProtocol::Task(void)
}
else
{
// invalid packet
//std::cout << "YSF packet (" << Buffer.size() << ") from " << Callsign << " at " << Ip << std::endl;
//Buffer.DebugDump(g_Reflector.m_DebugFile);
std::string title("Unknown YSF packet from ");
title += Ip.GetAddress();
Buffer.Dump(title);
}
}

@ -66,7 +66,7 @@
#define VERSION_MAJOR 2
#define VERSION_MINOR 4
#define VERSION_REVISION 28
#define VERSION_REVISION 29
// global ------------------------------------------------------

Loading…
Cancel
Save

Powered by TurnKey Linux.