using System.ComponentModel.DataAnnotations;
namespace LTEMvcApp.Models
{
///
/// 日志层配置
///
public class LogLayerConfig
{
///
/// 日志级别
///
[Required]
public string Level { get; set; } = "warn";
///
/// 最大大小
///
public int MaxSize { get; set; } = 1;
///
/// 是否包含负载
///
public bool Payload { get; set; } = false;
///
/// 过滤器(用于兼容性)
///
public string Filter { get; set; } = "warn";
///
/// 颜色代码
///
public string Color { get; set; } = "#000000";
///
/// 方向配置
///
public Dictionary Direction { get; set; } = new();
///
/// 是否为EPC相关
///
public bool EPC { get; set; } = false;
///
/// 调试配置
///
public DebugConfig? Debug { get; set; }
///
/// 最大配置
///
public MaxConfig? Max { get; set; }
}
///
/// 调试配置
///
public class DebugConfig
{
public string Level { get; set; } = "debug";
public int MaxSize { get; set; } = 1;
}
///
/// 最大配置
///
public class MaxConfig
{
public int MaxSize { get; set; } = 32;
}
///
/// 日志层类型枚举
///
public static class LogLayerTypes
{
public const string PHY = "PHY";
public const string MAC = "MAC";
public const string RLC = "RLC";
public const string PDCP = "PDCP";
public const string RRC = "RRC";
public const string NAS = "NAS";
public const string S1AP = "S1AP";
public const string NGAP = "NGAP";
public const string GTPU = "GTPU";
public const string GTPC = "GTPC";
public const string IP = "IP";
public const string X2AP = "X2AP";
public const string XnAP = "XnAP";
public const string M2AP = "M2AP";
public const string IMS = "IMS";
public const string CX = "CX";
public const string RX = "RX";
public const string COM = "COM";
public const string SIP = "SIP";
public const string MEDIA = "MEDIA";
public const string RTP = "RTP";
public const string PROD = "PROD";
public const string S6 = "S6";
public const string S13 = "S13";
public const string SGsAP = "SGsAP";
public const string SBcAP = "SBcAP";
public const string N8 = "N8";
public const string N12 = "N12";
public const string N13 = "N13";
public const string N17 = "N17";
public const string N50 = "N50";
public const string MMS = "MMS";
public const string HTTP2 = "HTTP2";
public const string LCSAP = "LCSAP";
public const string LPPa = "LPPa";
public const string NL1 = "NL1";
public const string NRPPa = "NRPPa";
public const string IKEV2 = "IKEV2";
public const string SWU = "SWU";
public const string NWU = "NWU";
public const string IPSEC = "IPSEC";
public const string N3IWF = "N3IWF";
public const string TRX = "TRX";
public const string MON = "MON";
public const string EVENT = "EVENT";
public const string ALARM = "ALARM";
public const string LIC = "LIC";
public const string OTS = "OTS";
public const string ERROR = "ERROR";
///
/// 获取所有日志层类型
///
public static readonly string[] NEWAllLayers = new[]
{
PHY, MAC, RLC, PDCP, RRC, NAS, S1AP, NGAP, GTPU, GTPC, IP, X2AP, XnAP, M2AP,
IMS, CX, RX, COM, SIP, MEDIA, RTP, PROD, S6, S13, SGsAP, SBcAP, N8, N12, N13,
N17, N50, MMS, HTTP2, LCSAP, LPPa, NL1, NRPPa, IKEV2, SWU, NWU, IPSEC, N3IWF,
TRX, MON, EVENT, ALARM, LIC, OTS, ERROR
};
///
/// 获取所有日志层类型
///
public static readonly string[] AllLayers = new[]
{
PHY, MAC, RLC, PDCP, RRC, NAS, S1AP, NGAP, GTPU, X2AP, XnAP, M2AP
};
///
/// 获取日志级别选项
///
public static readonly string[] LogLevels = new[]
{
"debug", "info", "warn", "error"
};
///
/// 获取默认日志级别
///
public static string GetDefaultLevel(string layer)
{
return layer switch
{
NAS or RRC or S1AP or NGAP or X2AP => "debug",
EVENT or M2AP => "info",
_ => "warn"
};
}
///
/// 获取层配置
///
/// 层配置字典
public static Dictionary GetLayerConfigs()
{
return new Dictionary
{
[PHY] = new() { Color = "#606070", Direction = new() { ["UE"] = 2, ["PROBE"] = 3, ["ENB"] = 1 }, Debug = new() { Level = "debug", MaxSize = 1 } },
[MAC] = new() { Color = "#10A0FF", Direction = new() { ["UE"] = 2, ["PROBE"] = 3, ["ENB"] = 1 }, Debug = new() { Level = "debug", MaxSize = 1 } },
[RLC] = new() { Color = "#FFFF80", Direction = new() { ["UE"] = 2, ["PROBE"] = 3, ["ENB"] = 1 } },
[PDCP] = new() { Color = "#B0D0B0", Direction = new() { ["UE"] = 2, ["PROBE"] = 3, ["ENB"] = 1 } },
[RRC] = new() { Color = "#00FF60", Direction = new() { ["UE"] = 2, ["PROBE"] = 3, ["ENB"] = 1 }, Debug = new() { Level = "debug", MaxSize = 1 } },
[NAS] = new() { Color = "#90FFC0", Direction = new() { ["UE"] = 2, ["PROBE"] = 3, ["ENB"] = 3, ["N3IWF"] = 3, ["MME"] = 1 }, Debug = new() { Level = "debug", MaxSize = 1 } },
[GTPU] = new() { Color = "#FF80FF", Direction = new() { ["ENB"] = 2, ["N3IWF"] = 2, ["MME"] = 1, ["MBMSGW"] = 1, ["UE"] = 1, ["RUE"] = 2 }, EPC = true, Max = new() { MaxSize = 32 } },
[GTPC] = new() { Color = "#FFC0FF", Direction = new() { ["MME"] = 2 }, EPC = true },
[IP] = new() { Color = "#E0E0E0", Direction = new() { ["RUE"] = 2, ["UE"] = 2, ["N3IWF"] = 3, ["PROBE"] = 3, ["MME"] = 3 }, Max = new() { MaxSize = 32 } },
[S1AP] = new() { Color = "#80FF00", Direction = new() { ["ENB"] = 2, ["MME"] = 1 }, EPC = true, Debug = new() { Level = "debug", MaxSize = 1 } },
[NGAP] = new() { Color = "#5DD122", Direction = new() { ["ENB"] = 2, ["MME"] = 1, ["N3IWF"] = 2 }, EPC = true, Debug = new() { Level = "debug", MaxSize = 1 } },
[X2AP] = new() { Color = "#FF8000", Direction = new() { ["ENB"] = 2 } },
[XnAP] = new() { Color = "#FFB020", Direction = new() { ["ENB"] = 2 } },
[M2AP] = new() { Color = "#7F675B", Direction = new() { ["ENB"] = 2, ["MBMSGW"] = 1 }, EPC = true },
[IMS] = new() { Color = "#C0FF80", Direction = new() { ["MME"] = 2, ["IMS"] = 1 }, Debug = new() { Level = "debug", MaxSize = 1 }, EPC = true },
[CX] = new() { Color = "#F49542", Direction = new() { ["MME"] = 2, ["IMS"] = 1 }, EPC = true },
[RX] = new() { Color = "#D4A190", Direction = new() { ["MME"] = 2, ["IMS"] = 1 }, EPC = true },
[COM] = new() { Color = "#C000FF", Direction = new() { ["*"] = 2 } },
[SIP] = new() { Color = "#C080FF", Direction = new() { ["IMS"] = 1 }, EPC = true, Debug = new() { Level = "debug", MaxSize = 1 } },
[MEDIA] = new() { Color = "#800040", Direction = new() { ["IMS"] = 1 }, EPC = true },
[RTP] = new() { Color = "#FF00C0", Direction = new() { ["IMS"] = 1 }, EPC = true },
[PROD] = new() { Color = "#80C0FF", Direction = new() { } },
[S6] = new() { Color = "#F44B42", Direction = new() { ["MME"] = 2 }, EPC = true },
[S13] = new() { Color = "#D6F953", Direction = new() { ["MME"] = 2 }, EPC = true },
[SGsAP] = new() { Color = "#FF7DB8", Direction = new() { ["MME"] = 2 }, EPC = true },
[SBcAP] = new() { Color = "#8FA00F", Direction = new() { ["MME"] = 2 }, EPC = true },
[N8] = new() { Color = "#106020", Direction = new() { ["MME"] = 2 }, EPC = true },
[N12] = new() { Color = "#602020", Direction = new() { ["MME"] = 2 }, EPC = true },
[N13] = new() { Color = "#202060", Direction = new() { ["MME"] = 2 }, EPC = true },
[N17] = new() { Color = "#D6F953", Direction = new() { ["MME"] = 2 }, EPC = true },
[N50] = new() { Color = "#8FA00F", Direction = new() { ["MME"] = 2 }, EPC = true },
[MMS] = new() { Color = "#B4D98F", Direction = new() { ["MME"] = 2 }, EPC = true },
[HTTP2] = new() { Color = "#644824", Direction = new() { ["MME"] = 2 }, EPC = true },
[LCSAP] = new() { Color = "#cfd50d", Direction = new() { ["MME"] = 2 }, EPC = true },
[LPPa] = new() { Color = "#0dcfd5", Direction = new() { ["ENB"] = 2, ["MME"] = 3 }, EPC = true },
[NL1] = new() { Color = "#d040cf", Direction = new() { ["MME"] = 2 }, EPC = true },
[NRPPa] = new() { Color = "#0dd5cf", Direction = new() { ["ENB"] = 2, ["MME"] = 3 }, EPC = true },
[IKEV2] = new() { Color = "#C0B732", Direction = new() { ["UE"] = 2, ["MME"] = 1, ["N3IWF"] = 1 } },
[SWU] = new() { Color = "#101080", Direction = new() { ["UE"] = 2, ["MME"] = 1 } },
[NWU] = new() { Color = "#2080B8", Direction = new() { ["UE"] = 2, ["MME"] = 1 } },
[IPSEC] = new() { Color = "#F04010", Direction = new() { ["UE"] = 2, ["IMS"] = 1, ["N3IWF"] = 1, ["MME"] = 1 }, EPC = true, Max = new() { MaxSize = 32 } },
[N3IWF] = new() { Color = "#C080C0", Direction = new() { ["UE"] = 2, ["N3IWF"] = 1 } },
[TRX] = new() { Color = "#42C0a0", Direction = new() { ["UE"] = 2, ["ENB"] = 1 }, Debug = new() { Level = "debug" } },
[MON] = new() { Color = "#C0C080", Direction = new() { } },
[EVENT] = new() { Color = "#80C0FF", Direction = new() { } },
[ALARM] = new() { Color = "#FF8040", Direction = new() { } },
[LIC] = new() { Color = "#ff80c0", Direction = new() { ["LICENSE"] = 1 } },
[OTS] = new() { Color = "#8080FF", Direction = new() { } },
[ERROR] = new() { Color = "#ff0000", Direction = new() { } }
};
}
///
/// 获取层配置
///
/// 层名称
/// 层配置
public static LogLayerConfig? GetLayerConfig(string layerName)
{
var configs = GetLayerConfigs();
return configs.TryGetValue(layerName, out var config) ? config : null;
}
///
/// 验证层名称是否有效
///
/// 层名称
/// 是否有效
public static bool IsValidLayer(string layerName)
{
return AllLayers.Contains(layerName);
}
}
}