be a little less obtuse about the NAK reason in the FNE log;

pull/55/head
Bryan Biedenkapp 2 years ago
parent cbb0af42ba
commit 0ad47a1989

@ -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); return writePeer(peerId, { NET_FUNC_ACK, NET_SUBFUNC_NOP }, buffer, length + 10U, RTP_END_OF_CALL_SEQ, false, true);
} }
/// <summary>
/// Helper to log a warning specifying which NAK reason is being sent a peer.
/// </summary>
/// <param name="peerId"></param>
/// <param name="tag"></param>
/// <param name="reason"></param>
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;
}
}
/// <summary> /// <summary>
/// Helper to send a NAK response to the specified peer. /// Helper to send a NAK response to the specified peer.
/// </summary> /// </summary>
@ -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_UINT32(peerId, buffer, 6U); // Peer ID
__SET_UINT16B((uint16_t)reason, buffer, 10U); // Reason __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); 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_UINT32(peerId, buffer, 6U); // Peer ID
__SET_UINT16B((uint16_t)reason, buffer, 10U); // Reason __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, return m_frameQueue->write(buffer, 12U, createStreamId(), peerId, m_peerId,
{ NET_FUNC_NAK, NET_SUBFUNC_NOP }, 0U, addr, addrLen); { NET_FUNC_NAK, NET_SUBFUNC_NOP }, 0U, addr, addrLen);
} }

@ -362,6 +362,8 @@ namespace network
/// <summary>Helper to send a ACK response to the specified peer.</summary> /// <summary>Helper to send a ACK response to the specified peer.</summary>
bool writePeerACK(uint32_t peerId, const uint8_t* data = nullptr, uint32_t length = 0U); bool writePeerACK(uint32_t peerId, const uint8_t* data = nullptr, uint32_t length = 0U);
/// <summary>Helper to log a warning specifying which NAK reason is being sent a peer.</summary>
void logPeerNAKReason(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason);
/// <summary>Helper to send a NAK response to the specified peer.</summary> /// <summary>Helper to send a NAK response to the specified peer.</summary>
bool writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason = NET_CONN_NAK_GENERAL_FAILURE); bool writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason = NET_CONN_NAK_GENERAL_FAILURE);
/// <summary>Helper to send a NAK response to the specified peer.</summary> /// <summary>Helper to send a NAK response to the specified peer.</summary>

Loading…
Cancel
Save

Powered by TurnKey Linux.