parsing-packets/Helpers/RawCaptureExtensions.cs
2024-02-03 17:30:01 -07:00

20 lines
584 B
C#

using PacketDotNet;
using SharpPcap;
using System.Reflection;
namespace Parsing_Packets.Helpers;
public static class RawCaptureExtensions
{
private static readonly MethodInfo? _GetLinkLayerType;
static RawCaptureExtensions()
{
PropertyInfo? propertyInfo = typeof(RawCapture).GetProperty("LinkLayerType", BindingFlags.Public | BindingFlags.Instance);
_GetLinkLayerType = propertyInfo?.GetMethod;
}
public static LinkLayers GetLinkLayers(this RawCapture rawCapture) =>
(LinkLayers)(_GetLinkLayerType?.Invoke(rawCapture, null) ?? 0);
}