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 // debug
void DebugDump(std::ofstream &) const; void DebugDump(std::ofstream &) const;
void DebugDumpAscii(std::ofstream &) const; void DebugDumpAscii(std::ofstream &) const;
void Dump(const std::string &title);
// pass through // pass through
void clear() { m_data.clear(); } void clear() { m_data.clear(); }

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

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

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

@ -153,7 +153,9 @@ void CDplusProtocol::Task(void)
} }
else 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 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 else
{ {
// invalid packet std::string title("Unknown YSF packet from ");
//std::cout << "YSF packet (" << Buffer.size() << ") from " << Callsign << " at " << Ip << std::endl; title += Ip.GetAddress();
//Buffer.DebugDump(g_Reflector.m_DebugFile); Buffer.Dump(title);
} }
} }

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

Loading…
Cancel
Save

Powered by TurnKey Linux.