//..............................................................................
//
// UDP Flow Monitor log representer
//

import "log_Representation.jnc"
import "io_base.jncx"
import "io_SocketAddress.jnc"
import "UdpFlowLogRecordCode.jnc"

//..............................................................................

bool representUdpFlowLog(
	log.Representation* representation,
	uint64_t recordCode,
	void const* p,
	size_t size,
	uint_t foldFlags
	)
{
	switch (recordCode)
	{
	case UdpFlowLogRecordCode.Packet:
		UdpFlowPacketParams const* params = (UdpFlowPacketParams const*) p;
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Packet;
		representation.m_lineAttr.m_backColor = ui.StdColor.PastelGray;

		char const* text = $"From \e[34m%1\e[m to \e[34m%2\e[m (%3 bytes)" (
			params.m_srcAddress.getString(),
			params.m_dstAddress.getString(),
			params.m_size
			);

		if (params.m_isFragmented)
			text = $"$text \e[31mfragmented";

		representation.addHyperText(text);
		break;

	default:
		return false;
	}

	return true;
}

//..............................................................................
