Commit b291c846 authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 8926ae19
...@@ -18,13 +18,13 @@ namespace WinPcapDotNet.Console ...@@ -18,13 +18,13 @@ namespace WinPcapDotNet.Console
static void Main(string[] args) static void Main(string[] args)
{ {
System.Console.WriteLine("Start"); System.Console.WriteLine("Start");
IList<PcapLiveDevice> devices = PcapLiveDevice.AllLocalMachine; IList<LivePacketDevice> devices = LivePacketDevice.AllLocalMachine;
if (devices.Count == 0) if (devices.Count == 0)
return; return;
for (int i = 0; i != devices.Count; ++i) for (int i = 0; i != devices.Count; ++i)
{ {
PcapLiveDevice device = devices[i]; LivePacketDevice device = devices[i];
System.Console.WriteLine(i+1 + ". " + device.Name); System.Console.WriteLine(i+1 + ". " + device.Name);
} }
int index; int index;
...@@ -38,7 +38,7 @@ namespace WinPcapDotNet.Console ...@@ -38,7 +38,7 @@ namespace WinPcapDotNet.Console
const string filename = @"c:\tmp.pcap"; const string filename = @"c:\tmp.pcap";
const string filter = "port 80"; const string filter = "port 80";
IPcapDevice chosenDevice = devices[index]; IPacketDevice chosenDevice = devices[index];
System.Console.WriteLine("Start GetNextPackets"); System.Console.WriteLine("Start GetNextPackets");
GetNextPackets(chosenDevice, filter); GetNextPackets(chosenDevice, filter);
...@@ -65,9 +65,9 @@ namespace WinPcapDotNet.Console ...@@ -65,9 +65,9 @@ namespace WinPcapDotNet.Console
System.Console.WriteLine("Finished Transmitting packets"); System.Console.WriteLine("Finished Transmitting packets");
} }
private static void GetNextPackets(IPcapDevice device, string filter) private static void GetNextPackets(IPacketDevice device, string filter)
{ {
using (PcapDeviceHandler deviceHandler = device.Open(PcapDevice.DefaultSnapshotLength, PcapDeviceOpenFlags.Promiscuous, 10 * 1000)) using (PacketCommunicator deviceHandler = device.Open(PacketDevice.DefaultSnapshotLength, PacketDeviceOpenFlags.Promiscuous, 10 * 1000))
{ {
System.Console.WriteLine("datalink = " + deviceHandler.DataLink.Name + " description = " + deviceHandler.DataLink.Description); System.Console.WriteLine("datalink = " + deviceHandler.DataLink.Name + " description = " + deviceHandler.DataLink.Description);
//foreach (PcapDataLink datalink in deviceHandler.SupportedDataLinks) //foreach (PcapDataLink datalink in deviceHandler.SupportedDataLinks)
...@@ -80,21 +80,21 @@ namespace WinPcapDotNet.Console ...@@ -80,21 +80,21 @@ namespace WinPcapDotNet.Console
" timestamp and " + packet.Length + " size"), " timestamp and " + packet.Length + " size"),
out numPacketsGot); out numPacketsGot);
PcapTotalStatistics statistics = deviceHandler.TotalStatistics; PacketTotalStatistics statistics = deviceHandler.TotalStatistics;
System.Console.WriteLine(statistics.ToString()); System.Console.WriteLine(statistics.ToString());
} }
} }
private static void StatisticsMode(IPcapDevice device, string filter) private static void StatisticsMode(IPacketDevice device, string filter)
{ {
using (PcapDeviceHandler deviceHandler = device.Open()) using (PacketCommunicator deviceHandler = device.Open())
{ {
deviceHandler.SetFilter(filter); deviceHandler.SetFilter(filter);
deviceHandler.Mode = DeviceHandlerMode.Statistics; deviceHandler.Mode = DeviceHandlerMode.Statistics;
for (int i = 0; i != 10; ++i) for (int i = 0; i != 10; ++i)
{ {
PcapSampleStatistics statistics; PacketSampleStatistics statistics;
DeviceHandlerResult result = deviceHandler.GetNextStatistics(out statistics); DeviceHandlerResult result = deviceHandler.GetNextStatistics(out statistics);
switch (result) switch (result)
{ {
...@@ -111,12 +111,12 @@ namespace WinPcapDotNet.Console ...@@ -111,12 +111,12 @@ namespace WinPcapDotNet.Console
} }
} }
private static void TransmitPacketsFromFile(string filename, IPcapDevice liveDevice) private static void TransmitPacketsFromFile(string filename, IPacketDevice liveDevice)
{ {
IPcapDevice offlineDevice = new PcapOfflineDevice(filename); IPacketDevice offlineDevice = new OfflinePacketDevice(filename);
using (PcapSendQueue sendQueue = new PcapSendQueue(1024 * 1024)) using (PacketSendQueue sendQueue = new PacketSendQueue(1024 * 1024))
{ {
using (PcapDeviceHandler offlineHandler = offlineDevice.Open()) using (PacketCommunicator offlineHandler = offlineDevice.Open())
{ {
for (int i = 0; i != 100; ++i) for (int i = 0; i != 100; ++i)
{ {
...@@ -136,19 +136,19 @@ namespace WinPcapDotNet.Console ...@@ -136,19 +136,19 @@ namespace WinPcapDotNet.Console
} }
} }
using (PcapDeviceHandler liveHandler = liveDevice.Open()) using (PacketCommunicator liveHandler = liveDevice.Open())
{ {
sendQueue.Transmit(liveHandler, true); sendQueue.Transmit(liveHandler, true);
} }
} }
} }
private static void SendPacketsFromFile(string filename, IPcapDevice liveDevice) private static void SendPacketsFromFile(string filename, IPacketDevice liveDevice)
{ {
IPcapDevice offlineDevice = new PcapOfflineDevice(filename); IPacketDevice offlineDevice = new OfflinePacketDevice(filename);
using (PcapDeviceHandler liveHandler = liveDevice.Open()) using (PacketCommunicator liveHandler = liveDevice.Open())
{ {
using (PcapDeviceHandler offlineHandler = offlineDevice.Open()) using (PacketCommunicator offlineHandler = offlineDevice.Open())
{ {
for (int i = 0; i != 100; ++i) for (int i = 0; i != 100; ++i)
{ {
...@@ -170,12 +170,12 @@ namespace WinPcapDotNet.Console ...@@ -170,12 +170,12 @@ namespace WinPcapDotNet.Console
} }
} }
private static void CapturePacketsToFile(IPcapDevice device, string filter, string filename) private static void CapturePacketsToFile(IPacketDevice device, string filter, string filename)
{ {
using (PcapDeviceHandler liveHandler = device.Open()) using (PacketCommunicator liveHandler = device.Open())
{ {
liveHandler.SetFilter(filter); liveHandler.SetFilter(filter);
PcapDumpFile dumpFile = liveHandler.OpenDump(filename); PacketDumpFile dumpFile = liveHandler.OpenDump(filename);
for (int i = 0; i != 100; ++i) for (int i = 0; i != 100; ++i)
{ {
Packet packet; Packet packet;
......
...@@ -66,7 +66,7 @@ namespace PcapDotNet.Core.Test ...@@ -66,7 +66,7 @@ namespace PcapDotNet.Core.Test
const string DestinationMac = "77:88:99:AA:BB:CC"; const string DestinationMac = "77:88:99:AA:BB:CC";
const int NumPacketsToSend = 10; const int NumPacketsToSend = 10;
using (PcapDeviceHandler deviceHandler = OpenLiveDevice()) using (PacketCommunicator deviceHandler = OpenLiveDevice())
{ {
deviceHandler.SetFilter("ether src " + SourceMac + " and ether dst " + DestinationMac); deviceHandler.SetFilter("ether src " + SourceMac + " and ether dst " + DestinationMac);
...@@ -93,17 +93,17 @@ namespace PcapDotNet.Core.Test ...@@ -93,17 +93,17 @@ namespace PcapDotNet.Core.Test
} }
} }
private static PcapDeviceHandler OpenLiveDevice() private static PacketCommunicator OpenLiveDevice()
{ {
IList<PcapLiveDevice> devices = PcapLiveDevice.AllLocalMachine; IList<LivePacketDevice> devices = LivePacketDevice.AllLocalMachine;
MoreAssert.IsBiggerOrEqual(1, devices.Count); MoreAssert.IsBiggerOrEqual(1, devices.Count);
PcapLiveDevice device = devices[0]; LivePacketDevice device = devices[0];
Assert.AreEqual("Network adapter 'Atheros AR8121/AR8113 PCI-E Ethernet Controller (Microsoft's Packet Scheduler) ' on local host", device.Description); Assert.AreEqual("Network adapter 'Atheros AR8121/AR8113 PCI-E Ethernet Controller (Microsoft's Packet Scheduler) ' on local host", device.Description);
Assert.AreEqual(DeviceFlags.None, device.Flags); Assert.AreEqual(DeviceFlags.None, device.Flags);
Assert.AreEqual(1, device.Addresses.Count); Assert.AreEqual(1, device.Addresses.Count);
PcapAddress address = device.Addresses[0]; DeviceAddress address = device.Addresses[0];
Assert.AreEqual("Address: INET 10.0.0.2 Netmask: INET 255.0.0.0 Broadcast: INET 255.255.255.255", address.ToString()); Assert.AreEqual("Address: INET 10.0.0.2 Netmask: INET 255.0.0.0 Broadcast: INET 255.255.255.255", address.ToString());
PcapDeviceHandler deviceHandler = device.Open(); PacketCommunicator deviceHandler = device.Open();
try try
{ {
Assert.AreEqual(DataLinkKind.Ethernet, deviceHandler.DataLink.Kind); Assert.AreEqual(DataLinkKind.Ethernet, deviceHandler.DataLink.Kind);
...@@ -112,8 +112,8 @@ namespace PcapDotNet.Core.Test ...@@ -112,8 +112,8 @@ namespace PcapDotNet.Core.Test
Assert.IsTrue(deviceHandler.IsFileSystemByteOrder); Assert.IsTrue(deviceHandler.IsFileSystemByteOrder);
Assert.AreEqual(DeviceHandlerMode.Capture, deviceHandler.Mode); Assert.AreEqual(DeviceHandlerMode.Capture, deviceHandler.Mode);
Assert.IsFalse(deviceHandler.NonBlocking); Assert.IsFalse(deviceHandler.NonBlocking);
Assert.AreEqual(PcapDevice.DefaultSnapshotLength, deviceHandler.SnapshotLength); Assert.AreEqual(PacketDevice.DefaultSnapshotLength, deviceHandler.SnapshotLength);
Assert.AreEqual(new PcapTotalStatistics(0, 0, 0, 0), deviceHandler.TotalStatistics); Assert.AreEqual(new PacketTotalStatistics(0, 0, 0, 0), deviceHandler.TotalStatistics);
return deviceHandler; return deviceHandler;
} }
catch (Exception) catch (Exception)
......
#include "BpfFilter.h" #include "BerkeleyPacketFilter.h"
#include "Pcap.h" #include "Pcap.h"
#include "MarshalingServices.h" #include "MarshalingServices.h"
#include "PcapError.h" #include "PcapError.h"
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using namespace System; using namespace System;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
BpfFilter::BpfFilter(pcap_t* pcapDescriptor, String^ filterString, IpV4SocketAddress^ netmask) BerkeleyPacketFilter::BerkeleyPacketFilter(pcap_t* pcapDescriptor, String^ filterString, IpV4SocketAddress^ netmask)
{ {
std::string unmanagedFilterString = MarshalingServices::ManagedToUnmanagedString(filterString); std::string unmanagedFilterString = MarshalingServices::ManagedToUnmanagedString(filterString);
...@@ -30,14 +30,14 @@ BpfFilter::BpfFilter(pcap_t* pcapDescriptor, String^ filterString, IpV4SocketAdd ...@@ -30,14 +30,14 @@ BpfFilter::BpfFilter(pcap_t* pcapDescriptor, String^ filterString, IpV4SocketAdd
} }
} }
void BpfFilter::SetFilter(pcap_t* pcapDescriptor) void BerkeleyPacketFilter::SetFilter(pcap_t* pcapDescriptor)
{ {
if (pcap_setfilter(pcapDescriptor, _bpf) != 0) if (pcap_setfilter(pcapDescriptor, _bpf) != 0)
throw PcapError::BuildInvalidOperation("Failed setting bpf filter", pcapDescriptor); throw PcapError::BuildInvalidOperation("Failed setting bpf filter", pcapDescriptor);
} }
BpfFilter::~BpfFilter() BerkeleyPacketFilter::~BerkeleyPacketFilter()
{ {
pcap_freecode(_bpf); pcap_freecode(_bpf);
delete _bpf; delete _bpf;
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class BpfFilter : System::IDisposable public ref class BerkeleyPacketFilter : System::IDisposable
{ {
public: public:
BpfFilter(pcap_t* pcapDescriptor, System::String^ filterString, IpV4SocketAddress^ netmask); BerkeleyPacketFilter(pcap_t* pcapDescriptor, System::String^ filterString, IpV4SocketAddress^ netmask);
void SetFilter(pcap_t* pcapDescriptor); void SetFilter(pcap_t* pcapDescriptor);
~BpfFilter(); // IDisposable ~BerkeleyPacketFilter(); // IDisposable
private: private:
bpf_program* _bpf; bpf_program* _bpf;
......
#include "PcapAddress.h" #include "DeviceAddress.h"
#include "IpV4SocketAddress.h" #include "IpV4SocketAddress.h"
#include "Pcap.h" #include "Pcap.h"
...@@ -6,7 +6,7 @@ using namespace System; ...@@ -6,7 +6,7 @@ using namespace System;
using namespace System::Text; using namespace System::Text;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
PcapAddress::PcapAddress(pcap_addr_t* pcapAddress) DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress)
{ {
SocketAddressFamily family = safe_cast<SocketAddressFamily>(pcapAddress->addr->sa_family); SocketAddressFamily family = safe_cast<SocketAddressFamily>(pcapAddress->addr->sa_family);
...@@ -53,27 +53,27 @@ PcapAddress::PcapAddress(pcap_addr_t* pcapAddress) ...@@ -53,27 +53,27 @@ PcapAddress::PcapAddress(pcap_addr_t* pcapAddress)
} }
} }
SocketAddress^ PcapAddress::Address::get() SocketAddress^ DeviceAddress::Address::get()
{ {
return _address; return _address;
} }
SocketAddress^ PcapAddress::Netmask::get() SocketAddress^ DeviceAddress::Netmask::get()
{ {
return _netmask; return _netmask;
} }
SocketAddress^ PcapAddress::Broadcast::get() SocketAddress^ DeviceAddress::Broadcast::get()
{ {
return _broadcast; return _broadcast;
} }
SocketAddress^ PcapAddress::Destination::get() SocketAddress^ DeviceAddress::Destination::get()
{ {
return _destination; return _destination;
} }
String^ PcapAddress::ToString() String^ DeviceAddress::ToString()
{ {
StringBuilder^ result = gcnew StringBuilder(); StringBuilder^ result = gcnew StringBuilder();
...@@ -86,7 +86,7 @@ String^ PcapAddress::ToString() ...@@ -86,7 +86,7 @@ String^ PcapAddress::ToString()
} }
// static // static
void PcapAddress::AppendSocketAddressString(StringBuilder^ stringBuilder, SocketAddress^ socketAddress, String^ title) void DeviceAddress::AppendSocketAddressString(StringBuilder^ stringBuilder, SocketAddress^ socketAddress, String^ title)
{ {
if (socketAddress != nullptr) if (socketAddress != nullptr)
{ {
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapAddress public ref class DeviceAddress
{ {
public: public:
PcapAddress(pcap_addr_t *pcapAddress); DeviceAddress(pcap_addr_t *pcapAddress);
property SocketAddress^ Address property SocketAddress^ Address
{ {
......
#pragma once #pragma once
#include "PcapAddress.h" #include "DeviceAddress.h"
#include "PcapDeviceHandler.h" #include "PacketCommunicator.h"
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
...@@ -12,14 +12,14 @@ namespace PcapDotNet { namespace Core ...@@ -12,14 +12,14 @@ namespace PcapDotNet { namespace Core
LoopBack = 0x00000001 LoopBack = 0x00000001
}; };
public interface class IPcapDevice public interface class IPacketDevice
{ {
property System::String^ Name { System::String^ get(); }; property System::String^ Name { System::String^ get(); };
property System::String^ Description { System::String^ get(); }; property System::String^ Description { System::String^ get(); };
property DeviceFlags^ Flags { DeviceFlags^ get(); }; property DeviceFlags^ Flags { DeviceFlags^ get(); };
property System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ Addresses property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
{ {
System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ get(); System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get();
} }
/// <summary> /// <summary>
...@@ -28,12 +28,12 @@ namespace PcapDotNet { namespace Core ...@@ -28,12 +28,12 @@ namespace PcapDotNet { namespace Core
/// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param> /// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param>
/// <param name="flags">keeps several flags that can be needed for capturing packets.</param> /// <param name="flags">keeps several flags that can be needed for capturing packets.</param>
/// <param name="flags">read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</param> /// <param name="flags">read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</param>
PcapDeviceHandler^ Open(int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout); PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout);
/// <summary> /// <summary>
/// Open a generic source in order to capture / send (WinPcap only) traffic. /// Open a generic source in order to capture / send (WinPcap only) traffic.
/// Uses maxmimum snapshotLength (65536), promiscuous mode and 1 second read timeout. /// Uses maxmimum snapshotLength (65536), promiscuous mode and 1 second read timeout.
/// </summary> /// </summary>
PcapDeviceHandler^ Open(); PacketCommunicator^ Open();
}; };
}} }}
\ No newline at end of file
#include "PcapLiveDevice.h" #include "LivePacketDevice.h"
#include <string> #include <string>
...@@ -11,7 +11,7 @@ using namespace System::Collections::ObjectModel; ...@@ -11,7 +11,7 @@ using namespace System::Collections::ObjectModel;
using namespace BPacket; using namespace BPacket;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
ReadOnlyCollection<PcapLiveDevice^>^ PcapLiveDevice::AllLocalMachine::get() ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get()
{ {
pcap_if_t *alldevs; pcap_if_t *alldevs;
char errbuf[PCAP_ERRBUF_SIZE]; char errbuf[PCAP_ERRBUF_SIZE];
...@@ -26,23 +26,23 @@ ReadOnlyCollection<PcapLiveDevice^>^ PcapLiveDevice::AllLocalMachine::get() ...@@ -26,23 +26,23 @@ ReadOnlyCollection<PcapLiveDevice^>^ PcapLiveDevice::AllLocalMachine::get()
try try
{ {
List<PcapLiveDevice^>^ result = gcnew List<PcapLiveDevice^>(); List<LivePacketDevice^>^ result = gcnew List<LivePacketDevice^>();
for (pcap_if_t *d = alldevs; d != NULL; d = d->next) for (pcap_if_t *d = alldevs; d != NULL; d = d->next)
{ {
// IP addresses // IP addresses
List<PcapAddress^>^ addresses = gcnew List<PcapAddress^>(); List<DeviceAddress^>^ addresses = gcnew List<DeviceAddress^>();
for (pcap_addr_t *a = d->addresses; a; a = a->next) for (pcap_addr_t *a = d->addresses; a; a = a->next)
{ {
PcapAddress^ deviceAddress = gcnew PcapAddress(a); DeviceAddress^ deviceAddress = gcnew DeviceAddress(a);
addresses->Add(deviceAddress); addresses->Add(deviceAddress);
} }
result->Add(gcnew PcapLiveDevice(gcnew String(d->name), result->Add(gcnew LivePacketDevice(gcnew String(d->name),
gcnew String(d->description), gcnew String(d->description),
safe_cast<DeviceFlags>(d->flags), safe_cast<DeviceFlags>(d->flags),
gcnew ReadOnlyCollection<PcapAddress^>(addresses))); gcnew ReadOnlyCollection<DeviceAddress^>(addresses)));
} }
return gcnew ReadOnlyCollection<PcapLiveDevice^>(result); return gcnew ReadOnlyCollection<LivePacketDevice^>(result);
} }
finally finally
{ {
...@@ -51,27 +51,27 @@ ReadOnlyCollection<PcapLiveDevice^>^ PcapLiveDevice::AllLocalMachine::get() ...@@ -51,27 +51,27 @@ ReadOnlyCollection<PcapLiveDevice^>^ PcapLiveDevice::AllLocalMachine::get()
} }
} }
String^ PcapLiveDevice::Name::get() String^ LivePacketDevice::Name::get()
{ {
return _name; return _name;
} }
String^ PcapLiveDevice::Description::get() String^ LivePacketDevice::Description::get()
{ {
return _description; return _description;
} }
DeviceFlags^ PcapLiveDevice::Flags::get() DeviceFlags^ LivePacketDevice::Flags::get()
{ {
return _flags; return _flags;
} }
ReadOnlyCollection<PcapAddress^>^ PcapLiveDevice::Addresses::get() ReadOnlyCollection<DeviceAddress^>^ LivePacketDevice::Addresses::get()
{ {
return gcnew ReadOnlyCollection<PcapAddress^>(_addresses); return gcnew ReadOnlyCollection<DeviceAddress^>(_addresses);
} }
PcapDeviceHandler^ PcapLiveDevice::Open(int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout) PacketCommunicator^ LivePacketDevice::Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout)
{ {
std::string deviceName = MarshalingServices::ManagedToUnmanagedString(Name); std::string deviceName = MarshalingServices::ManagedToUnmanagedString(Name);
...@@ -81,12 +81,12 @@ PcapDeviceHandler^ PcapLiveDevice::Open(int snapshotLength, PcapDeviceOpenFlags ...@@ -81,12 +81,12 @@ PcapDeviceHandler^ PcapLiveDevice::Open(int snapshotLength, PcapDeviceOpenFlags
netmask = Addresses[0]->Netmask; netmask = Addresses[0]->Netmask;
// Open the device // Open the device
return gcnew PcapDeviceHandler(deviceName.c_str(), snapshotLength, flags, readTimeout, NULL, netmask); return gcnew PacketCommunicator(deviceName.c_str(), snapshotLength, flags, readTimeout, NULL, netmask);
} }
// Private Methods // Private Methods
PcapLiveDevice::PcapLiveDevice(String^ name, String^ description, DeviceFlags^ flags, ReadOnlyCollection<PcapAddress^>^ addresses) LivePacketDevice::LivePacketDevice(String^ name, String^ description, DeviceFlags^ flags, ReadOnlyCollection<DeviceAddress^>^ addresses)
{ {
_name = name; _name = name;
_description = description; _description = description;
......
#pragma once #pragma once
#include "PcapDevice.h" #include "PacketDevice.h"
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapLiveDevice : PcapDevice public ref class LivePacketDevice : PacketDevice
{ {
public: public:
static property System::Collections::ObjectModel::ReadOnlyCollection<PcapLiveDevice^>^ AllLocalMachine static property System::Collections::ObjectModel::ReadOnlyCollection<LivePacketDevice^>^ AllLocalMachine
{ {
System::Collections::ObjectModel::ReadOnlyCollection<PcapLiveDevice^>^ get(); System::Collections::ObjectModel::ReadOnlyCollection<LivePacketDevice^>^ get();
} }
virtual property System::String^ Name virtual property System::String^ Name
...@@ -27,9 +27,9 @@ namespace PcapDotNet { namespace Core ...@@ -27,9 +27,9 @@ namespace PcapDotNet { namespace Core
DeviceFlags^ get() override; DeviceFlags^ get() override;
} }
virtual property System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ Addresses virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
{ {
System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ get() override; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() override;
} }
/// <summary> /// <summary>
...@@ -38,15 +38,15 @@ namespace PcapDotNet { namespace Core ...@@ -38,15 +38,15 @@ namespace PcapDotNet { namespace Core
/// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param> /// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param>
/// <param name="flags">keeps several flags that can be needed for capturing packets.</param> /// <param name="flags">keeps several flags that can be needed for capturing packets.</param>
/// <param name="flags">read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</param> /// <param name="flags">read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</param>
virtual PcapDeviceHandler^ Open(int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout) override; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) override;
private: private:
PcapLiveDevice(System::String^ name, System::String^ description, DeviceFlags^ flags, System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ addresses); LivePacketDevice(System::String^ name, System::String^ description, DeviceFlags^ flags, System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ addresses);
private: private:
System::String^ _name; System::String^ _name;
System::String^ _description; System::String^ _description;
DeviceFlags^ _flags; DeviceFlags^ _flags;
System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ _addresses; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ _addresses;
}; };
}} }}
\ No newline at end of file
#include "PcapOfflineDevice.h" #include "OfflinePacketDevice.h"
#include <string> #include <string>
...@@ -10,32 +10,32 @@ using namespace System::Collections::Generic; ...@@ -10,32 +10,32 @@ using namespace System::Collections::Generic;
using namespace System::Collections::ObjectModel; using namespace System::Collections::ObjectModel;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
PcapOfflineDevice::PcapOfflineDevice(System::String^ filename) OfflinePacketDevice::OfflinePacketDevice(System::String^ filename)
{ {
_filename = filename; _filename = filename;
} }
String^ PcapOfflineDevice::Name::get() String^ OfflinePacketDevice::Name::get()
{ {
return _filename; return _filename;
} }
String^ PcapOfflineDevice::Description::get() String^ OfflinePacketDevice::Description::get()
{ {
return String::Empty; return String::Empty;
} }
DeviceFlags^ PcapOfflineDevice::Flags::get() DeviceFlags^ OfflinePacketDevice::Flags::get()
{ {
return DeviceFlags::None; return DeviceFlags::None;
} }
ReadOnlyCollection<PcapAddress^>^ PcapOfflineDevice::Addresses::get() ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get()
{ {
return gcnew ReadOnlyCollection<PcapAddress^>(gcnew List<PcapAddress^>()); return gcnew ReadOnlyCollection<DeviceAddress^>(gcnew List<DeviceAddress^>());
} }
PcapDeviceHandler^ PcapOfflineDevice::Open(int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout) PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout)
{ {
std::string unamangedFilename = MarshalingServices::ManagedToUnmanagedString(_filename); std::string unamangedFilename = MarshalingServices::ManagedToUnmanagedString(_filename);
...@@ -53,5 +53,5 @@ PcapDeviceHandler^ PcapOfflineDevice::Open(int snapshotLength, PcapDeviceOpenFla ...@@ -53,5 +53,5 @@ PcapDeviceHandler^ PcapOfflineDevice::Open(int snapshotLength, PcapDeviceOpenFla
throw gcnew InvalidOperationException("Error creating a source string from filename " + _filename + " Error: " + gcnew String(errbuf)); throw gcnew InvalidOperationException("Error creating a source string from filename " + _filename + " Error: " + gcnew String(errbuf));
} }
return gcnew PcapDeviceHandler(source, snapshotLength, flags, readTimeout, NULL, nullptr); return gcnew PacketCommunicator(source, snapshotLength, flags, readTimeout, NULL, nullptr);
} }
#pragma once #pragma once
#include "PcapDevice.h" #include "PacketDevice.h"
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapOfflineDevice : PcapDevice public ref class OfflinePacketDevice : PacketDevice
{ {
public: public:
PcapOfflineDevice(System::String^ filename); OfflinePacketDevice(System::String^ filename);
virtual property System::String^ Name virtual property System::String^ Name
{ {
...@@ -24,12 +24,12 @@ namespace PcapDotNet { namespace Core ...@@ -24,12 +24,12 @@ namespace PcapDotNet { namespace Core
DeviceFlags^ get() override; DeviceFlags^ get() override;
} }
virtual property System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ Addresses virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
{ {
System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ get() override; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() override;
} }
virtual PcapDeviceHandler^ Open(int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout) override; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) override;
private: private:
System::String^ _filename; System::String^ _filename;
......
#pragma once #pragma once
#include "PcapAddress.h" #include "DeviceAddress.h"
#include "BpfFilter.h" #include "BerkeleyPacketFilter.h"
#include "PcapDumpFile.h" #include "PacketDumpFile.h"
#include "PcapDeviceOpenFlags.h" #include "PacketDeviceOpenFlags.h"
#include "PcapSampleStatistics.h" #include "PacketSampleStatistics.h"
#include "PcapTotalStatistics.h" #include "PacketTotalStatistics.h"
#include "PcapDataLink.h" #include "PcapDataLink.h"
#include "PcapSendQueue.h" #include "PacketSendQueue.h"
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
...@@ -27,10 +27,10 @@ namespace PcapDotNet { namespace Core ...@@ -27,10 +27,10 @@ namespace PcapDotNet { namespace Core
KernelDump = 0x10 // Kernel dump working mode. KernelDump = 0x10 // Kernel dump working mode.
}; };
public ref class PcapDeviceHandler : System::IDisposable public ref class PacketCommunicator : System::IDisposable
{ {
public: public:
PcapDeviceHandler(const char* source, int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout, pcap_rmtauth *auth, PacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth *auth,
SocketAddress^ netmask); SocketAddress^ netmask);
property PcapDataLink DataLink property PcapDataLink DataLink
...@@ -64,9 +64,9 @@ namespace PcapDotNet { namespace Core ...@@ -64,9 +64,9 @@ namespace PcapDotNet { namespace Core
int get(); int get();
} }
property PcapTotalStatistics^ TotalStatistics property PacketTotalStatistics^ TotalStatistics
{ {
PcapTotalStatistics^ get(); PacketTotalStatistics^ get();
} }
property DeviceHandlerMode Mode property DeviceHandlerMode Mode
...@@ -86,23 +86,23 @@ namespace PcapDotNet { namespace Core ...@@ -86,23 +86,23 @@ namespace PcapDotNet { namespace Core
DeviceHandlerResult GetSomePackets(int maxPackets, HandlePacket^ callBack, [System::Runtime::InteropServices::Out] int% numPacketsGot); DeviceHandlerResult GetSomePackets(int maxPackets, HandlePacket^ callBack, [System::Runtime::InteropServices::Out] int% numPacketsGot);
DeviceHandlerResult GetPackets(int numPackets, HandlePacket^ callBack); DeviceHandlerResult GetPackets(int numPackets, HandlePacket^ callBack);
delegate void HandleStatistics(PcapSampleStatistics^ statistics); delegate void HandleStatistics(PacketSampleStatistics^ statistics);
DeviceHandlerResult GetNextStatistics([System::Runtime::InteropServices::Out] PcapSampleStatistics^% statistics); DeviceHandlerResult GetNextStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics);
void SendPacket(BPacket::Packet^ packet); void SendPacket(BPacket::Packet^ packet);
void Transmit(PcapSendQueue^ sendQueue, bool isSync); void Transmit(PacketSendQueue^ sendQueue, bool isSync);
BpfFilter^ CreateFilter(System::String^ filterString); BerkeleyPacketFilter^ CreateFilter(System::String^ filterString);
void SetFilter(BpfFilter^ filter); void SetFilter(BerkeleyPacketFilter^ filter);
void SetFilter(System::String^ filterString); void SetFilter(System::String^ filterString);
PcapDumpFile^ OpenDump(System::String^ filename); PacketDumpFile^ OpenDump(System::String^ filename);
~PcapDeviceHandler(); ~PacketCommunicator();
private: private:
static BPacket::Packet^ CreatePacket(const pcap_pkthdr& packetHeader, const unsigned char* packetData, BPacket::IDataLink^ dataLink); static BPacket::Packet^ CreatePacket(const pcap_pkthdr& packetHeader, const unsigned char* packetData, BPacket::IDataLink^ dataLink);
static PcapSampleStatistics^ PcapDeviceHandler::CreateStatistics(const pcap_pkthdr& packetHeader, const unsigned char* packetData); static PacketSampleStatistics^ PacketCommunicator::CreateStatistics(const pcap_pkthdr& packetHeader, const unsigned char* packetData);
DeviceHandlerResult RunPcapNextEx(pcap_pkthdr** packetHeader, const unsigned char** packetData); DeviceHandlerResult RunPcapNextEx(pcap_pkthdr** packetHeader, const unsigned char** packetData);
......
#include "PacketDevice.h"
using namespace PcapDotNet::Core;
PacketCommunicator^ PacketDevice::Open()
{
return Open(DefaultSnapshotLength, PacketDeviceOpenFlags::Promiscuous, 1000);
}
#pragma once #pragma once
#include "IPcapDevice.h" #include "IPacketDevice.h"
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapDevice abstract : IPcapDevice public ref class PacketDevice abstract : IPacketDevice
{ {
public: public:
static const int DefaultSnapshotLength = 65536; static const int DefaultSnapshotLength = 65536;
...@@ -24,13 +24,13 @@ namespace PcapDotNet { namespace Core ...@@ -24,13 +24,13 @@ namespace PcapDotNet { namespace Core
DeviceFlags^ get() = 0; DeviceFlags^ get() = 0;
} }
virtual property System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ Addresses virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
{ {
System::Collections::ObjectModel::ReadOnlyCollection<PcapAddress^>^ get() = 0; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() = 0;
} }
virtual PcapDeviceHandler^ Open(int snapshotLength, PcapDeviceOpenFlags flags, int readTimeout) = 0; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) = 0;
virtual PcapDeviceHandler^ Open(); virtual PacketCommunicator^ Open();
}; };
}} }}
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
[System::Flags] [System::Flags]
public enum class PcapDeviceOpenFlags : System::Int32 public enum class PacketDeviceOpenFlags : System::Int32
{ {
None = 0, None = 0,
Promiscuous = 1, // Defines if the adapter has to go in promiscuous mode. Promiscuous = 1, // Defines if the adapter has to go in promiscuous mode.
......
#include "PcapDumpFile.h" #include "PacketDumpFile.h"
#include "Timestamp.h" #include "Timestamp.h"
#include "PacketHeader.h" #include "PacketHeader.h"
#include "MarshalingServices.h" #include "MarshalingServices.h"
...@@ -9,7 +9,7 @@ using namespace System; ...@@ -9,7 +9,7 @@ using namespace System;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
using namespace BPacket; using namespace BPacket;
void PcapDumpFile::Dump(Packet^ packet) void PacketDumpFile::Dump(Packet^ packet)
{ {
pcap_pkthdr header; pcap_pkthdr header;
PacketHeader::GetPcapHeader(header, packet); PacketHeader::GetPcapHeader(header, packet);
...@@ -19,13 +19,13 @@ void PcapDumpFile::Dump(Packet^ packet) ...@@ -19,13 +19,13 @@ void PcapDumpFile::Dump(Packet^ packet)
pcap_dump(reinterpret_cast<unsigned char*>(_pcapDumper), &header, unamangedPacketBytes); pcap_dump(reinterpret_cast<unsigned char*>(_pcapDumper), &header, unamangedPacketBytes);
} }
void PcapDumpFile::Flush() void PacketDumpFile::Flush()
{ {
if (pcap_dump_flush(_pcapDumper) != 0) if (pcap_dump_flush(_pcapDumper) != 0)
throw gcnew InvalidOperationException("Failed flusing to file " + _filename); throw gcnew InvalidOperationException("Failed flusing to file " + _filename);
} }
long PcapDumpFile::Position::get() long PacketDumpFile::Position::get()
{ {
long position = pcap_dump_ftell(_pcapDumper); long position = pcap_dump_ftell(_pcapDumper);
if (position == -1) if (position == -1)
...@@ -33,14 +33,14 @@ long PcapDumpFile::Position::get() ...@@ -33,14 +33,14 @@ long PcapDumpFile::Position::get()
return position; return position;
} }
PcapDumpFile::~PcapDumpFile() PacketDumpFile::~PacketDumpFile()
{ {
pcap_dump_close(_pcapDumper); pcap_dump_close(_pcapDumper);
} }
// internal // internal
PcapDumpFile::PcapDumpFile(pcap_t* pcapDescriptor, System::String^ filename) PacketDumpFile::PacketDumpFile(pcap_t* pcapDescriptor, System::String^ filename)
{ {
_filename = filename; _filename = filename;
std::string unmanagedString = MarshalingServices::ManagedToUnmanagedString(_filename); std::string unmanagedString = MarshalingServices::ManagedToUnmanagedString(_filename);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapDumpFile : System::IDisposable public ref class PacketDumpFile : System::IDisposable
{ {
public: public:
void Dump(BPacket::Packet^ packet); void Dump(BPacket::Packet^ packet);
...@@ -16,10 +16,10 @@ namespace PcapDotNet { namespace Core ...@@ -16,10 +16,10 @@ namespace PcapDotNet { namespace Core
long get(); long get();
} }
~PcapDumpFile(); ~PacketDumpFile();
internal: internal:
PcapDumpFile(pcap_t* pcapDescriptor, System::String^ filename); PacketDumpFile(pcap_t* pcapDescriptor, System::String^ filename);
private: private:
pcap_dumper_t* _pcapDumper; pcap_dumper_t* _pcapDumper;
......
#include "PcapSampleStatistics.h" #include "PacketSampleStatistics.h"
using namespace System; using namespace System;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
PcapSampleStatistics::PcapSampleStatistics(DateTime timestamp, unsigned long acceptedPackets, unsigned long acceptedBytes) PacketSampleStatistics::PacketSampleStatistics(DateTime timestamp, unsigned long acceptedPackets, unsigned long acceptedBytes)
{ {
_timestamp = timestamp; _timestamp = timestamp;
_acceptedPackets = acceptedPackets; _acceptedPackets = acceptedPackets;
_acceptedBytes = acceptedBytes; _acceptedBytes = acceptedBytes;
} }
DateTime PcapSampleStatistics::Timestamp::get() DateTime PacketSampleStatistics::Timestamp::get()
{ {
return _timestamp; return _timestamp;
} }
unsigned long PcapSampleStatistics::AcceptedPackets::get() unsigned long PacketSampleStatistics::AcceptedPackets::get()
{ {
return _acceptedPackets; return _acceptedPackets;
} }
unsigned long PcapSampleStatistics::AcceptedBytes::get() unsigned long PacketSampleStatistics::AcceptedBytes::get()
{ {
return _acceptedBytes; return _acceptedBytes;
} }
System::String^ PcapSampleStatistics::ToString() System::String^ PacketSampleStatistics::ToString()
{ {
return _timestamp + ": " + AcceptedPackets + " packets. " + AcceptedBytes + " bytes."; return _timestamp + ": " + AcceptedPackets + " packets. " + AcceptedBytes + " bytes.";
} }
\ No newline at end of file
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapSampleStatistics public ref class PacketSampleStatistics
{ {
public: public:
PcapSampleStatistics(System::DateTime timestamp, unsigned long acceptedPackets, unsigned long acceptedBytes); PacketSampleStatistics(System::DateTime timestamp, unsigned long acceptedPackets, unsigned long acceptedBytes);
property System::DateTime Timestamp property System::DateTime Timestamp
{ {
......
#include "PcapSendQueue.h" #include "PacketSendQueue.h"
#include "PacketHeader.h" #include "PacketHeader.h"
#include "PcapError.h" #include "PcapError.h"
#include "Pcap.h" #include "Pcap.h"
...@@ -7,12 +7,12 @@ using namespace System; ...@@ -7,12 +7,12 @@ using namespace System;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
using namespace BPacket; using namespace BPacket;
PcapSendQueue::PcapSendQueue(unsigned int capacity) PacketSendQueue::PacketSendQueue(unsigned int capacity)
{ {
_pcapSendQueue = pcap_sendqueue_alloc(capacity); _pcapSendQueue = pcap_sendqueue_alloc(capacity);
} }
void PcapSendQueue::Enqueue(Packet^ packet) void PacketSendQueue::Enqueue(Packet^ packet)
{ {
pcap_pkthdr pcapHeader; pcap_pkthdr pcapHeader;
PacketHeader::GetPcapHeader(pcapHeader, packet); PacketHeader::GetPcapHeader(pcapHeader, packet);
...@@ -21,12 +21,12 @@ void PcapSendQueue::Enqueue(Packet^ packet) ...@@ -21,12 +21,12 @@ void PcapSendQueue::Enqueue(Packet^ packet)
throw gcnew InvalidOperationException("Failed enqueueing to SendQueue"); throw gcnew InvalidOperationException("Failed enqueueing to SendQueue");
} }
PcapSendQueue::~PcapSendQueue() PacketSendQueue::~PacketSendQueue()
{ {
pcap_sendqueue_destroy(_pcapSendQueue); pcap_sendqueue_destroy(_pcapSendQueue);
} }
void PcapSendQueue::Transmit(pcap_t* pcapDescriptor, bool isSync) void PacketSendQueue::Transmit(pcap_t* pcapDescriptor, bool isSync)
{ {
unsigned int numBytesTransmitted = pcap_sendqueue_transmit(pcapDescriptor, _pcapSendQueue, isSync); unsigned int numBytesTransmitted = pcap_sendqueue_transmit(pcapDescriptor, _pcapSendQueue, isSync);
if (numBytesTransmitted < _pcapSendQueue->len) if (numBytesTransmitted < _pcapSendQueue->len)
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapSendQueue : System::IDisposable public ref class PacketSendQueue : System::IDisposable
{ {
public: public:
PcapSendQueue(unsigned int capacity); PacketSendQueue(unsigned int capacity);
void Enqueue(BPacket::Packet^ packet); void Enqueue(BPacket::Packet^ packet);
~PcapSendQueue(); ~PacketSendQueue();
internal: internal:
void Transmit(pcap_t* pcapDescriptor, bool isSync); void Transmit(pcap_t* pcapDescriptor, bool isSync);
......
#include "PcapTotalStatistics.h" #include "PacketTotalStatistics.h"
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
PcapTotalStatistics::PcapTotalStatistics(unsigned int packetsReceived, unsigned int packetsDroppedByDriver, unsigned int packetsDroppedByInterface, unsigned int packetsCaptured) PacketTotalStatistics::PacketTotalStatistics(unsigned int packetsReceived, unsigned int packetsDroppedByDriver, unsigned int packetsDroppedByInterface, unsigned int packetsCaptured)
{ {
_packetsReceived = packetsReceived; _packetsReceived = packetsReceived;
_packetsDroppedByDriver = packetsDroppedByDriver; _packetsDroppedByDriver = packetsDroppedByDriver;
...@@ -10,27 +10,27 @@ PcapTotalStatistics::PcapTotalStatistics(unsigned int packetsReceived, unsigned ...@@ -10,27 +10,27 @@ PcapTotalStatistics::PcapTotalStatistics(unsigned int packetsReceived, unsigned
_packetsCaptured = packetsCaptured; _packetsCaptured = packetsCaptured;
} }
unsigned int PcapTotalStatistics::PacketsReceived::get() unsigned int PacketTotalStatistics::PacketsReceived::get()
{ {
return _packetsReceived; return _packetsReceived;
} }
unsigned int PcapTotalStatistics::PacketsDroppedByDriver::get() unsigned int PacketTotalStatistics::PacketsDroppedByDriver::get()
{ {
return _packetsDroppedByDriver; return _packetsDroppedByDriver;
} }
unsigned int PcapTotalStatistics::PacketsDroppedByInterface::get() unsigned int PacketTotalStatistics::PacketsDroppedByInterface::get()
{ {
return _packetsDroppedByInterface; return _packetsDroppedByInterface;
} }
unsigned int PcapTotalStatistics::PacketsCaptured::get() unsigned int PacketTotalStatistics::PacketsCaptured::get()
{ {
return _packetsCaptured; return _packetsCaptured;
} }
bool PcapTotalStatistics::Equals(PcapTotalStatistics^ other) bool PacketTotalStatistics::Equals(PacketTotalStatistics^ other)
{ {
if (other == nullptr) if (other == nullptr)
return false; return false;
...@@ -41,7 +41,7 @@ bool PcapTotalStatistics::Equals(PcapTotalStatistics^ other) ...@@ -41,7 +41,7 @@ bool PcapTotalStatistics::Equals(PcapTotalStatistics^ other)
PacketsCaptured == other->PacketsCaptured); PacketsCaptured == other->PacketsCaptured);
} }
bool PcapTotalStatistics::Equals(Object^ other) bool PacketTotalStatistics::Equals(Object^ other)
{ {
return Equals(dynamic_cast<PcapTotalStatistics^>(other)); return Equals(dynamic_cast<PacketTotalStatistics^>(other));
} }
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class PcapTotalStatistics public ref class PacketTotalStatistics
{ {
public: public:
PcapTotalStatistics(unsigned int packetsReceived, unsigned int packetsDroppedByDriver, unsigned int packetsDroppedByInterface, unsigned int packetsCaptured); PacketTotalStatistics(unsigned int packetsReceived, unsigned int packetsDroppedByDriver, unsigned int packetsDroppedByInterface, unsigned int packetsCaptured);
property unsigned int PacketsReceived property unsigned int PacketsReceived
{ {
...@@ -27,7 +27,7 @@ namespace PcapDotNet { namespace Core ...@@ -27,7 +27,7 @@ namespace PcapDotNet { namespace Core
unsigned int get(); unsigned int get();
} }
bool Equals(PcapTotalStatistics^ other); bool Equals(PacketTotalStatistics^ other);
virtual bool Equals(System::Object^ other) override; virtual bool Equals(System::Object^ other) override;
private: private:
......
#include "PcapDevice.h"
using namespace PcapDotNet::Core;
PcapDeviceHandler^ PcapDevice::Open()
{
return Open(DefaultSnapshotLength, PcapDeviceOpenFlags::Promiscuous, 1000);
}
...@@ -200,151 +200,151 @@ ...@@ -200,151 +200,151 @@
</File> </File>
</Filter> </Filter>
<File <File
RelativePath=".\BpfFilter.cpp" RelativePath=".\BerkeleyPacketFilter.cpp"
> >
</File> </File>
<File <File
RelativePath=".\BpfFilter.h" RelativePath=".\BerkeleyPacketFilter.h"
> >
</File> </File>
<File <File
RelativePath=".\IPcapDevice.h" RelativePath=".\DeviceAddress.cpp"
> >
</File> </File>
<File <File
RelativePath=".\IpV4SocketAddress.cpp" RelativePath=".\DeviceAddress.h"
> >
</File> </File>
<File <File
RelativePath=".\IpV4SocketAddress.h" RelativePath=".\IPacketDevice.h"
> >
</File> </File>
<File <File
RelativePath=".\MarshalingServices.cpp" RelativePath=".\IpV4SocketAddress.cpp"
> >
</File> </File>
<File <File
RelativePath=".\MarshalingServices.h" RelativePath=".\IpV4SocketAddress.h"
> >
</File> </File>
<File <File
RelativePath=".\PacketHeader.cpp" RelativePath=".\LivePacketDevice.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PacketHeader.h" RelativePath=".\LivePacketDevice.h"
> >
</File> </File>
<File <File
RelativePath=".\Pcap.h" RelativePath=".\MarshalingServices.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapAddress.cpp" RelativePath=".\MarshalingServices.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapAddress.h" RelativePath=".\OfflinePacketDevice.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapDataLink.cpp" RelativePath=".\OfflinePacketDevice.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapDataLink.h" RelativePath=".\PacketCommunicator.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapDeclarations.cpp" RelativePath=".\PacketCommunicator.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapDeclarations.h" RelativePath=".\PacketDevice.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapDevice.cpp" RelativePath=".\PacketDevice.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapDevice.h" RelativePath=".\PacketDeviceOpenFlags.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapDeviceHandler.cpp" RelativePath=".\PacketDumpFile.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapDeviceHandler.h" RelativePath=".\PacketDumpFile.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapDeviceOpenFlags.h" RelativePath=".\PacketHeader.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapDumpFile.cpp" RelativePath=".\PacketHeader.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapDumpFile.h" RelativePath=".\PacketSampleStatistics.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapError.cpp" RelativePath=".\PacketSampleStatistics.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapError.h" RelativePath=".\PacketSendQueue.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapLibrary.cpp" RelativePath=".\PacketSendQueue.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapLibrary.h" RelativePath=".\PacketTotalStatistics.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapLiveDevice.cpp" RelativePath=".\PacketTotalStatistics.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapLiveDevice.h" RelativePath=".\Pcap.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapOfflineDevice.cpp" RelativePath=".\PcapDataLink.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapOfflineDevice.h" RelativePath=".\PcapDataLink.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapSampleStatistics.cpp" RelativePath=".\PcapDeclarations.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapSampleStatistics.h" RelativePath=".\PcapDeclarations.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapSendQueue.cpp" RelativePath=".\PcapError.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapSendQueue.h" RelativePath=".\PcapError.h"
> >
</File> </File>
<File <File
RelativePath=".\PcapTotalStatistics.cpp" RelativePath=".\PcapLibrary.cpp"
> >
</File> </File>
<File <File
RelativePath=".\PcapTotalStatistics.h" RelativePath=".\PcapLibrary.h"
> >
</File> </File>
<File <File
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment