20 lines
584 B
C#
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);
|
|
|
|
} |