Add arp socket traffic debug category

This commit is contained in:
Simon Stürz 2021-06-08 13:10:20 +02:00
parent 4065a471b7
commit cbeac35059
3 changed files with 11 additions and 11 deletions

View File

@ -51,6 +51,7 @@
#include <QDataStream>
NYMEA_LOGGING_CATEGORY(dcArpSocket, "ArpSocket")
NYMEA_LOGGING_CATEGORY(dcArpSocketTraffic, "ArpSocketTraffic")
#define ETHER_PROTOCOL_LEN 4 // Length of the IPv4 address
#define ETHER_HEADER_LEN sizeof(struct ether_header)
@ -240,7 +241,7 @@ bool ArpSocket::openSocket()
QHostAddress targetHostAddress = getHostAddressString(arpPacket->arp_tpa);
uint16_t etherType = htons(etherHeader->ether_type);
if (etherType != ETHERTYPE_ARP) {
qCWarning(dcArpSocket()) << "Received ARP socket data header with invalid type" << etherType;
qCWarning(dcArpSocketTraffic()) << "Received ARP socket data header with invalid type" << etherType;
return;
}
@ -257,27 +258,27 @@ bool ArpSocket::openSocket()
return;
}
qCDebug(dcArpSocket()) << "ARP response from" << senderMacAddress << senderHostAddress.toString() << "on" << networkInterface.name();
qCDebug(dcArpSocketTraffic()) << "ARP response from" << senderMacAddress << senderHostAddress.toString() << "on" << networkInterface.name();
emit arpResponse(networkInterface, senderHostAddress, senderMacAddress.toLower());
break;
}
case ARPOP_RREQUEST:
//qCDebug(dcArpSocket()) << "RARP request from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
qCDebug(dcArpSocketTraffic()) << "RARP request from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
break;
case ARPOP_RREPLY:
//qCDebug(dcArpSocket()) << "PARP response from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
qCDebug(dcArpSocketTraffic()) << "PARP response from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
break;
case ARPOP_InREQUEST:
//qCDebug(dcArpSocket()) << "InARP request from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
qCDebug(dcArpSocketTraffic()) << "InARP request from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
break;
case ARPOP_InREPLY:
//qCDebug(dcArpSocket()) << "InARP response from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
qCDebug(dcArpSocketTraffic()) << "InARP response from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
break;
case ARPOP_NAK:
//qCDebug(dcArpSocket()) << "(ATM)ARP NAK from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
qCDebug(dcArpSocketTraffic()) << "(ATM)ARP NAK from" << senderMacAddress << senderHostAddress.toString() << "-->" << targetMacAddress << targetHostAddress.toString();
break;
default:
qCWarning(dcArpSocket()) << "Received unhandled ARP operation code" << arpOperationCode << "from" << senderMacAddress << senderHostAddress.toString();
qCWarning(dcArpSocketTraffic()) << "Received unhandled ARP operation code" << arpOperationCode << "from" << senderMacAddress << senderHostAddress.toString();
break;
}
}

View File

@ -244,12 +244,11 @@ void NetworkDeviceDiscovery::updateOrAddNetworkDeviceArp(const QNetworkInterface
void NetworkDeviceDiscovery::onArpResponseRceived(const QNetworkInterface &interface, const QHostAddress &address, const QString &macAddress)
{
if (!m_currentReply) {
qCDebug(dcNetworkDeviceDiscovery()) << "Received ARP reply but there is no discovery running.";
qCDebug(dcNetworkDeviceDiscovery()) << "Received ARP reply from" << address.toString() << macAddress << "but there is no discovery running.";
return;
}
qCDebug(dcNetworkDeviceDiscovery()) << "ARP reply received" << address.toString() << macAddress << interface.name();
// Lookup the mac address vendor if possible
if (m_macAddressDatabase->available()) {
MacAddressDatabaseReply *reply = m_macAddressDatabase->lookupMacAddress(macAddress);

View File

@ -292,7 +292,7 @@ void Ping::onSocketReadyRead(int socketDescriptor)
{
// We must read all data otherwise the socket notifier does not work as expected
while (true) {
// Read the socket data...
// Read the socket data and give some extra space for nested pakets...
int receiveBufferSize = 2 * ICMP_PACKET_SIZE + sizeof(struct iphdr);
char receiveBuffer[receiveBufferSize];
memset(&receiveBuffer, 0, sizeof(receiveBufferSize));