add separate packet dumping option to the network stack, to allow for less-verbose debugging messaging (debugigng where packet dump/trace is not required);

r05a04_dev
Bryan Biedenkapp 1 month ago
parent 40ef37179b
commit e5d8eed40c

@ -52,6 +52,8 @@ network:
# Flag indicating whether or not the host diagnostic log will be sent to the network.
allowDiagnosticTransfer: true
# Flag indicating whether or not packet dumping is enabled.
packetDump: false
# Flag indicating whether or not verbose debug logging is enabled.
debug: false

@ -76,6 +76,8 @@ network:
# Flag indicating whether or not the host status will be sent to the network.
allowStatusTransfer: true
# Flag indicating whether or not packet dumping is enabled.
packetDump: false
# Flag indicating whether or not verbose debug logging is enabled.
debug: false

@ -47,6 +47,8 @@ master:
password: RPT1234
# Flag indicating whether or not verbose logging is enabled.
verbose: true
# Flag indicating whether or not packet dumping is enabled.
packetDump: false
# Flag indicating whether or not verbose debug logging is enabled.
debug: false
@ -262,6 +264,8 @@ peers:
# Textual location for this host.
location: Anywhere, USA
# Flag indicating whether or not packet dumping is enabled.
packetDump: false
# Flag indicating whether or not verbose debug logging is enabled.
debug: false

@ -52,6 +52,8 @@ network:
# Flag indicating whether or not the host diagnostic log will be sent to the network.
allowDiagnosticTransfer: true
# Flag indicating whether or not packet dumping is enabled.
packetDump: false
# Flag indicating whether or not verbose debug logging is enabled.
debug: false

@ -1032,6 +1032,7 @@ bool HostBridge::createNetwork()
uint32_t id = networkConf["id"].as<uint32_t>(1000U);
std::string password = networkConf["password"].as<std::string>();
bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false);
bool packetDump = networkConf["packetDump"].as<bool>(false);
bool debug = networkConf["debug"].as<bool>(false);
m_udpAudio = networkConf["udpAudio"].as<bool>(false);
@ -1224,6 +1225,10 @@ bool HostBridge::createNetwork()
LogInfo(" Reset Call if Source ID Changes from UDP Audio: %s", m_resetCallForSourceIdChange ? "yes" : "no");
}
if (packetDump) {
LogInfo(" Packet Dump: yes");
}
if (debug) {
LogInfo(" Debug: yes");
}
@ -1244,6 +1249,7 @@ bool HostBridge::createNetwork()
// initialize networking
m_network = new PeerNetwork(address, port, local, id, password, true, debug, dmr, p25, false, analog, true, true, true, allowDiagnosticTransfer, true, false);
m_network->setPacketDump(packetDump);
m_network->setMetadata(m_identity, 0U, 0U, 0.0F, 0.0F, 0, 0, 0, 0.0F, 0.0F, 0, "");
m_network->setConventional(true);
m_network->setKeyResponseCallback([=](p25::kmm::KeyItem ki, uint8_t algId, uint8_t keyLength) {

@ -48,6 +48,7 @@ BaseNetwork::BaseNetwork(uint32_t peerId, bool duplex, bool debug, bool slot1, b
m_useAlternatePortForDiagnostics(false),
m_allowActivityTransfer(allowActivityTransfer),
m_allowDiagnosticTransfer(allowDiagnosticTransfer),
m_packetDump(false),
m_debug(debug),
m_socket(nullptr),
m_frameQueue(nullptr),
@ -1023,7 +1024,7 @@ UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t strea
// pack raw DMR message bytes
data.getData(buffer + 20U);
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createDMR_Message(), Message", buffer, (DMR_PACKET_LENGTH + PACKET_PAD));
length = (DMR_PACKET_LENGTH + PACKET_PAD);
@ -1080,7 +1081,7 @@ void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E du
::memset(mi, 0x00U, MI_LENGTH_BYTES);
control.getMI(mi);
if (m_debug) {
if (m_packetDump) {
Utils::dump(1U, "BaseNetwork::createP25_Message(), HDU MI", mi, MI_LENGTH_BYTES);
}
@ -1158,7 +1159,7 @@ UInt8Array BaseNetwork::createP25_LDU1Message(uint32_t& length, const p25::lc::L
buffer[23U] = count;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createP25_LDU1Message(), Message, LDU1", buffer, (P25_LDU1_PACKET_LENGTH + PACKET_PAD));
length = (P25_LDU1_PACKET_LENGTH + PACKET_PAD);
@ -1233,7 +1234,7 @@ UInt8Array BaseNetwork::createP25_LDU2Message(uint32_t& length, const p25::lc::L
buffer[23U] = count;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createP25_LDU2Message(), Message, LDU2", buffer, (P25_LDU2_PACKET_LENGTH + PACKET_PAD));
length = (P25_LDU2_PACKET_LENGTH + PACKET_PAD);
@ -1254,7 +1255,7 @@ UInt8Array BaseNetwork::createP25_TDUMessage(uint32_t& length, const p25::lc::LC
buffer[14U] = controlByte;
buffer[23U] = MSG_HDR_SIZE;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createP25_TDUMessage(), Message, TDU", buffer, (MSG_HDR_SIZE + PACKET_PAD));
length = (MSG_HDR_SIZE + PACKET_PAD);
@ -1280,7 +1281,7 @@ UInt8Array BaseNetwork::createP25_TSDUMessage(uint32_t& length, const p25::lc::L
buffer[23U] = P25_TSDU_FRAME_LENGTH_BYTES;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createP25_TSDUMessage(), Message, TDSU", buffer, (P25_TSDU_PACKET_LENGTH + PACKET_PAD));
length = (P25_TSDU_PACKET_LENGTH + PACKET_PAD);
@ -1306,7 +1307,7 @@ UInt8Array BaseNetwork::createP25_TDULCMessage(uint32_t& length, const p25::lc::
buffer[23U] = P25_TDULC_FRAME_LENGTH_BYTES;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createP25_TDULCMessage(), Message, TDULC", buffer, (P25_TDULC_PACKET_LENGTH + PACKET_PAD));
length = (P25_TDULC_PACKET_LENGTH + PACKET_PAD);
@ -1354,7 +1355,7 @@ UInt8Array BaseNetwork::createP25_PDUMessage(uint32_t& length, const p25::data::
buffer[23U] = count;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createP25_PDUMessage(), Message, PDU", buffer, (count + PACKET_PAD));
length = (count + PACKET_PAD);
@ -1393,7 +1394,7 @@ UInt8Array BaseNetwork::createNXDN_Message(uint32_t& length, const nxdn::lc::RTC
buffer[23U] = count;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createNXDN_Message(), Message", buffer, (NXDN_PACKET_LENGTH + PACKET_PAD));
length = (NXDN_PACKET_LENGTH + PACKET_PAD);
@ -1428,7 +1429,7 @@ UInt8Array BaseNetwork::createAnalog_Message(uint32_t& length, const uint32_t st
// pack raw audio message bytes
data.getAudio(buffer + 20U);
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "BaseNetwork::createAnalog_Message(), Message", buffer, (ANALOG_PACKET_LENGTH + PACKET_PAD));
length = (ANALOG_PACKET_LENGTH + PACKET_PAD);

@ -394,6 +394,12 @@ namespace network
*/
FrameQueue* getFrameQueue() const { return m_frameQueue; }
/**
* @brief Helper to enable or disable packet dump logging.
* @param enable Flag indicating whether packet dump logging is enabled.
*/
void setPacketDump(bool enable) { m_packetDump = enable; }
/**
* @brief Writes a grant request to the network.
* \code{.unparsed}
@ -926,6 +932,7 @@ namespace network
bool m_allowActivityTransfer;
bool m_allowDiagnosticTransfer;
bool m_packetDump;
bool m_debug;
udp::Socket* m_socket;

@ -389,7 +389,7 @@ void Network::clock(uint32_t ms)
}
}
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, DMR", buffer.get(), length);
if (length > (int)(DMR_PACKET_LENGTH + PACKET_PAD))
LogError(LOG_NET, "DMR Stream %u, frame oversized? this shouldn't happen, pktSeq = %u, len = %u", streamId, m_pktSeq, length);
@ -474,7 +474,7 @@ void Network::clock(uint32_t ms)
}
}
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, P25", buffer.get(), length);
if (length > 512)
LogError(LOG_NET, "P25 Stream %u, frame oversized? this shouldn't happen, pktSeq = %u, len = %u", streamId, m_pktSeq, length);
@ -568,7 +568,7 @@ void Network::clock(uint32_t ms)
}
}
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, NXDN", buffer.get(), length);
if (length > (int)(NXDN_PACKET_LENGTH + PACKET_PAD))
LogError(LOG_NET, "NXDN Stream %u, frame oversized? this shouldn't happen, pktSeq = %u, len = %u", streamId, m_pktSeq, length);
@ -653,7 +653,7 @@ void Network::clock(uint32_t ms)
}
}
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, Analog", buffer.get(), length);
if (length < (int)ANALOG_PACKET_LENGTH) {
LogError(LOG_NET, "Analog Stream %u, frame too short? this shouldn't happen, pktSeq = %u, len = %u", streamId, m_pktSeq, length);
@ -687,7 +687,7 @@ void Network::clock(uint32_t ms)
case NET_SUBFUNC::MASTER_SUBFUNC_WL_RID: // Radio ID Whitelist
{
if (m_enabled && m_updateLookup) {
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, WL RID", buffer.get(), length);
if (m_ridLookup != nullptr) {
@ -713,7 +713,7 @@ void Network::clock(uint32_t ms)
case NET_SUBFUNC::MASTER_SUBFUNC_BL_RID: // Radio ID Blacklist
{
if (m_enabled && m_updateLookup) {
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, BL RID", buffer.get(), length);
if (m_ridLookup != nullptr) {
@ -740,7 +740,7 @@ void Network::clock(uint32_t ms)
case NET_SUBFUNC::MASTER_SUBFUNC_ACTIVE_TGS: // Talkgroup Active IDs
{
if (m_enabled && m_updateLookup) {
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, ACTIVE TGS", buffer.get(), length);
if (m_tidLookup != nullptr) {
@ -790,7 +790,7 @@ void Network::clock(uint32_t ms)
case NET_SUBFUNC::MASTER_SUBFUNC_DEACTIVE_TGS: // Talkgroup Deactivated IDs
{
if (m_enabled && m_updateLookup) {
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, DEACTIVE TGS", buffer.get(), length);
if (m_tidLookup != nullptr) {
@ -824,7 +824,7 @@ void Network::clock(uint32_t ms)
case NET_SUBFUNC::MASTER_HA_PARAMS: // HA Parameters
{
if (m_enabled) {
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, HA PARAMS", buffer.get(), length);
m_haIPs.clear();
@ -1120,7 +1120,7 @@ void Network::clock(uint32_t ms)
case NET_FUNC::PONG: // Master Ping Response
m_timeoutTimer.start();
if (length >= 14) {
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::clock(), Network Rx, PONG", buffer.get(), length);
ulong64_t serverNow = 0U;
@ -1332,7 +1332,7 @@ bool Network::writeLogin()
::memcpy(buffer + 0U, TAG_REPEATER_LOGIN, 4U);
SET_UINT32(m_peerId, buffer, 4U); // Peer ID
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::writeLogin(), Message, Login", buffer, 8U);
m_loginStreamId = createStreamId();
@ -1365,7 +1365,7 @@ bool Network::writeAuthorisation()
delete[] in;
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network::writeAuthorisation(), Message, Authorisation", out, 40U);
return writeMaster({ NET_FUNC::RPTK, NET_SUBFUNC::NOP }, out, 40U, pktSeq(), m_loginStreamId);
@ -1426,7 +1426,7 @@ bool Network::writeConfig()
::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U);
::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str());
if (m_debug) {
if (m_packetDump) {
Utils::dump(1U, "Network::writeConfig(), Message, Configuration", (uint8_t*)buffer, json.length() + 8U);
}
@ -1440,7 +1440,7 @@ bool Network::writePing()
uint8_t buffer[1U];
::memset(buffer, 0x00U, 1U);
if (m_debug)
if (m_packetDump)
Utils::dump(1U, "Network Message, Ping", buffer, 11U);
return writeMaster({ NET_FUNC::PING, NET_SUBFUNC::NOP }, buffer, 1U, RTP_END_OF_CALL_SEQ, createStreamId());

@ -550,6 +550,7 @@ bool HostFNE::createMasterNetwork()
uint32_t id = masterConf["peerId"].as<uint32_t>(1001U);
std::string password = masterConf["password"].as<std::string>();
bool verbose = masterConf["verbose"].as<bool>(false);
bool packetDump = masterConf["packetDump"].as<bool>(false);
bool debug = masterConf["debug"].as<bool>(false);
bool kmfDebug = masterConf["kmfDebug"].as<bool>(false);
uint16_t workerCnt = (uint16_t)masterConf["workers"].as<uint32_t>(16U);
@ -635,6 +636,10 @@ bool HostFNE::createMasterNetwork()
LogInfo(" Verbose: yes");
}
if (packetDump) {
LogInfo(" Packet Dump: yes");
}
if (debug) {
LogInfo(" Debug: yes");
}
@ -649,6 +654,7 @@ bool HostFNE::createMasterNetwork()
parrotDelay, parrotGrantDemand, m_allowActivityTransfer, m_allowDiagnosticTransfer,
m_pingTime, m_updateLookupTime, workerCnt);
m_network->setOptions(masterConf, true);
m_network->setPacketDump(packetDump);
m_network->setLookups(m_ridLookup, m_tidLookup, m_peerListLookup, m_cryptoLookup, m_adjSiteMapLookup);
@ -671,6 +677,7 @@ bool HostFNE::createMasterNetwork()
// setup alternate port for diagnostics/activity logging
if (m_useAlternatePortForDiagnostics) {
m_diagNetwork = new DiagNetwork(this, m_network, address, port + 1U, workerCnt);
m_diagNetwork->setPacketDump(packetDump);
bool ret = m_diagNetwork->open();
if (!ret) {
@ -820,6 +827,7 @@ bool HostFNE::createPeerNetworks()
uint16_t masterPort = (uint16_t)peerConf["masterPort"].as<uint32_t>(TRAFFIC_DEFAULT_PORT);
std::string password = peerConf["password"].as<std::string>();
uint32_t id = peerConf["peerId"].as<uint32_t>(1001U);
bool packetDump = peerConf["packetDump"].as<bool>(false);
bool debug = peerConf["debug"].as<bool>(false);
bool encrypted = peerConf["encrypted"].as<bool>(false);
@ -874,6 +882,7 @@ bool HostFNE::createPeerNetworks()
// initialize networking
network::PeerNetwork* network = new PeerNetwork(masterAddress, masterPort, 0U, id, password, true, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, m_analogEnabled, true, true,
m_allowActivityTransfer, m_allowDiagnosticTransfer, false, false);
network->setPacketDump(packetDump);
network->setMetadata(identity, 0U, 0U, 0.0F, 0.0F, 0, 0, 0, latitude, longitude, 0, location);
network->setLookups(m_ridLookup, m_tidLookup);
network->setMasterPeerId(masterPeerId);

@ -831,6 +831,7 @@ bool Host::createNetwork()
bool allowStatusTransfer = networkConf["allowStatusTransfer"].as<bool>(true);
bool updateLookup = networkConf["updateLookups"].as<bool>(false);
bool saveLookup = networkConf["saveLookups"].as<bool>(false);
bool packetDump = networkConf["packetDump"].as<bool>(false);
bool debug = networkConf["debug"].as<bool>(false);
m_allowStatusTransfer = allowStatusTransfer;
@ -920,6 +921,10 @@ bool Host::createNetwork()
LogInfo(" Encrypted: %s", encrypted ? "yes" : "no");
if (packetDump) {
LogInfo(" Packet Dump: yes");
}
if (debug) {
LogInfo(" Debug: yes");
}
@ -943,6 +948,7 @@ bool Host::createNetwork()
m_network = new Network(address, port, local, id, password, m_duplex, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, false, slot1, slot2,
allowActivityTransfer, allowDiagnosticTransfer, updateLookup, saveLookup);
m_network->setPacketDump(packetDump);
m_network->setLookups(m_ridLookup, m_tidLookup);
m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo,
m_power, m_latitude, m_longitude, m_height, m_location);

@ -371,6 +371,7 @@ bool HostPatch::createNetwork()
uint32_t id = networkConf["id"].as<uint32_t>(1000U);
std::string password = networkConf["password"].as<std::string>();
bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false);
bool packetDump = networkConf["packetDump"].as<bool>(false);
bool debug = networkConf["debug"].as<bool>(false);
m_srcTGId = (uint32_t)networkConf["sourceTGID"].as<uint32_t>(1U);
@ -550,6 +551,10 @@ bool HostPatch::createNetwork()
LogInfo(" Two-Way Patch: %s", m_twoWayPatch ? "yes" : "no");
if (packetDump) {
LogInfo(" Packet Dump: yes");
}
if (debug) {
LogInfo(" Debug: yes");
}
@ -567,6 +572,7 @@ bool HostPatch::createNetwork()
// initialize networking
m_network = new PeerNetwork(address, port, local, id, password, true, debug, dmr, p25, false, true, true, true, allowDiagnosticTransfer, true, false);
m_network->setPacketDump(packetDump);
m_network->setMetadata(m_identity, 0U, 0U, 0.0F, 0.0F, 0, 0, 0, 0.0F, 0.0F, 0, "");
m_network->setConventional(true);
m_network->setKeyResponseCallback([=](p25::kmm::KeyItem ki, uint8_t algId, uint8_t keyLength) {

Loading…
Cancel
Save

Powered by TurnKey Linux.