From e724d86edc6892fde64c25fbe0db23e4987b84ac Mon Sep 17 00:00:00 2001 From: Ayoub Kaanich Date: Sun, 2 Mar 2025 14:37:11 +0100 Subject: [PATCH] Fix remote PCAP detection logic (#564) --- SharpPcap/LibPcap/LibPcapLiveDevice.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SharpPcap/LibPcap/LibPcapLiveDevice.cs b/SharpPcap/LibPcap/LibPcapLiveDevice.cs index d0b4ad64..edffc1a4 100644 --- a/SharpPcap/LibPcap/LibPcapLiveDevice.cs +++ b/SharpPcap/LibPcap/LibPcapLiveDevice.cs @@ -109,8 +109,11 @@ public override void Open(DeviceConfiguration configuration) immediateMode = true; } + var remote_pcap = pcapInterface.Name.StartsWith("rpcap://") + || pcapInterface.Name.StartsWith("rpcaps://") + || credentials != null; // Some configurations can only be used with pcap_create - var use_pcap_create = credentials == null && (short)otherModes == 0; + var use_pcap_create = !remote_pcap && (short)otherModes == 0; if (use_pcap_create) { Handle = LibPcapSafeNativeMethods.pcap_create(