You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
4.1 KiB
71 lines
4.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CoreAgent.ProtocolClient.Context
|
|
{
|
|
/// <summary>
|
|
/// 协议日志相关常量与正则表达式,便于全局统一管理和调用。
|
|
/// </summary>
|
|
public static class ProtocolLogPatterns
|
|
{
|
|
#region 常量定义
|
|
|
|
/// <summary>
|
|
/// HFN回绕阈值
|
|
/// </summary>
|
|
public const int HFN_WRAP_THRESHOLD = 512;
|
|
|
|
/// <summary>
|
|
/// 最大日志数量
|
|
/// </summary>
|
|
public const int LOGS_MAX = 2000000;
|
|
|
|
/// <summary>
|
|
/// BSR表 - 对应JavaScript中的_bsr_table
|
|
/// </summary>
|
|
public static readonly int[] BsrTable = {
|
|
0, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91, 107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, 706, 826, 967, 1132, 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995, 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099, 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255, 68201, 79846, 93479, 109439, 128125, 150000, 500000
|
|
};
|
|
|
|
#endregion
|
|
|
|
#region 正则表达式
|
|
|
|
public static readonly Regex RegExpPhy = new(@"^([a-f0-9\-]+)\s+([a-f0-9\-]+)\s+([\d\.\-]+) (\w+): (.+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpInfo1 = new(@"^([\w\-]+): (.+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpInfo2 = new(@"^([\w]+) (.+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpIP = new(@"^(len=\d+)\s+(\S+)\s+(.*)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpIPsec = new(@"^len=(\d+)\s+(.*)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpSDULen = new(@"SDU_len=(\d+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpSIP = new(@"^([:\.\[\]\da-f]+)\s+(\S+) (.+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpMediaReq = new(@"^(\S+) (.+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpSignalRecord = new(@"Link:\s([\w\d]+)@(\d+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpCellID = new(@"^([a-f0-9\-]+) (.+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpRRC_UE_ID = new(@"Changing UE_ID to 0x(\d+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpRRC_TMSI = new(@"(5G|m)-TMSI '([\dA-F]+)'H", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpRRC_NEW_ID = new(@"newUE-Identity (['\dA-FH]+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpRRC_CRNTI = new(@"c-RNTI '([\dA-F]+)'H", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpNAS_TMSI = new(@"[Mm]-TMSI = 0x([\da-f]+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpNAS_5GTMSI = new(@"5G-TMSI = 0x([\da-f]+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpRRC_BC = new(@"(EUTRA|MRDC|NR|NRDC) band combinations", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpPDCCH = new(@"^\s*(.+)=(\d+)$", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpS1NGAP = new(@"^([\da-f\-]+)\s+([\da-f\-]+) (([^\s]+) .+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegExpHexDump = new(@"^[\da-f]+:(\s+[\da-f]{2}){1,16}\s+.{1,16}$", RegexOptions.Compiled);
|
|
public static readonly Regex RegMccPattern = new Regex(@"MCC\s*=\s*(\d+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegMncPattern = new Regex(@"MNC\s*=\s*(\d+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegMSINPattern = new Regex(@"MSIN\s*=\s*(\d+)", RegexOptions.Compiled);
|
|
public static readonly Regex RegIMSIPattern = new Regex(@"IMSI = \s*(\d+)", RegexOptions.Compiled);
|
|
|
|
public static Match? FindData(this Regex regex, List<string> data)
|
|
{
|
|
return data?.FirstOrDefault(line => regex.IsMatch(line)) is string matchedLine
|
|
? regex.Match(matchedLine)
|
|
: null;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|