diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index 0cd15588..1f0831c7 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -1651,6 +1651,41 @@ bool FNENetwork::writePeerACK(uint32_t peerId, const uint8_t* data, uint32_t len return writePeer(peerId, { NET_FUNC_ACK, NET_SUBFUNC_NOP }, buffer, length + 10U, RTP_END_OF_CALL_SEQ, false, true); } +/// +/// Helper to log a warning specifying which NAK reason is being sent a peer. +/// +/// +/// +/// +void FNENetwork::logPeerNAKReason(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason) +{ + switch (reason) { + case NET_CONN_NAK_MODE_NOT_ENABLED: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; digital mode not enabled on FNE", peerId, tag, (uint16_t)reason); + break; + case NET_CONN_NAK_ILLEGAL_PACKET: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; illegal/unknown packet", peerId ,tag, (uint16_t)reason); + break; + case NET_CONN_NAK_FNE_UNAUTHORIZED: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; unauthorized", peerId, tag, (uint16_t)reason); + break; + case NET_CONN_NAK_BAD_CONN_STATE: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; bad connection state", peerId ,tag, (uint16_t)reason); + break; + case NET_CONN_NAK_INVALID_CONFIG_DATA: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; invalid configuration data", peerId, tag, (uint16_t)reason); + break; + case NET_CONN_NAK_FNE_MAX_CONN: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; FNE has reached maximum permitted connections", peerId, tag, (uint16_t)reason); + break; + + case NET_CONN_NAK_GENERAL_FAILURE: + default: + LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u; general failure", peerId, tag, (uint16_t)reason); + break; + } +} + /// /// Helper to send a NAK response to the specified peer. /// @@ -1668,7 +1703,7 @@ bool FNENetwork::writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REA __SET_UINT32(peerId, buffer, 6U); // Peer ID __SET_UINT16B((uint16_t)reason, buffer, 10U); // Reason - LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u", peerId, tag, (uint16_t)reason); + logPeerNAKReason(peerId, tag, reason); return writePeer(peerId, { NET_FUNC_NAK, NET_SUBFUNC_NOP }, buffer, 10U, RTP_END_OF_CALL_SEQ, false, true); } @@ -1691,7 +1726,7 @@ bool FNENetwork::writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REA __SET_UINT32(peerId, buffer, 6U); // Peer ID __SET_UINT16B((uint16_t)reason, buffer, 10U); // Reason - LogWarning(LOG_NET, "PEER %u NAK %s, reason = %u", peerId, tag, (uint16_t)reason); + logPeerNAKReason(peerId, tag, reason); return m_frameQueue->write(buffer, 12U, createStreamId(), peerId, m_peerId, { NET_FUNC_NAK, NET_SUBFUNC_NOP }, 0U, addr, addrLen); } diff --git a/src/fne/network/FNENetwork.h b/src/fne/network/FNENetwork.h index 8be68499..78610c14 100644 --- a/src/fne/network/FNENetwork.h +++ b/src/fne/network/FNENetwork.h @@ -362,6 +362,8 @@ namespace network /// Helper to send a ACK response to the specified peer. bool writePeerACK(uint32_t peerId, const uint8_t* data = nullptr, uint32_t length = 0U); + /// Helper to log a warning specifying which NAK reason is being sent a peer. + void logPeerNAKReason(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason); /// Helper to send a NAK response to the specified peer. bool writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason = NET_CONN_NAK_GENERAL_FAILURE); /// Helper to send a NAK response to the specified peer.