Commit 02c6b4dc authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 611dfbbe
...@@ -405,7 +405,7 @@ namespace PcapDotNet.Core.Test ...@@ -405,7 +405,7 @@ namespace PcapDotNet.Core.Test
using (PacketCommunicator communicator = OpenLiveDevice()) using (PacketCommunicator communicator = OpenLiveDevice())
{ {
communicator.SetFilter("ether src " + SourceMac + " and ether dst " + DestinationMac); communicator.SetFilter("ether src " + SourceMac + " and ether dst " + DestinationMac);
communicator.SetSamplingMethod(new SamplingMethodOneEveryN(5)); communicator.SetSamplingMethod(new SamplingMethodOneEveryCount(5));
for (int i = 0; i != 20; ++i) for (int i = 0; i != 20; ++i)
{ {
Packet expectedPacket = MoreRandom.BuildRandomPacket(SourceMac, DestinationMac, 60 * (i + 1)); Packet expectedPacket = MoreRandom.BuildRandomPacket(SourceMac, DestinationMac, 60 * (i + 1));
...@@ -466,7 +466,7 @@ namespace PcapDotNet.Core.Test ...@@ -466,7 +466,7 @@ namespace PcapDotNet.Core.Test
{ {
using (PacketCommunicator communicator = OpenLiveDevice()) using (PacketCommunicator communicator = OpenLiveDevice())
{ {
communicator.SetSamplingMethod(new SamplingMethodOneEveryN(0)); communicator.SetSamplingMethod(new SamplingMethodOneEveryCount(0));
} }
} }
...@@ -638,7 +638,7 @@ namespace PcapDotNet.Core.Test ...@@ -638,7 +638,7 @@ namespace PcapDotNet.Core.Test
MoreAssert.IsBiggerOrEqual(1, devices.Count); MoreAssert.IsBiggerOrEqual(1, devices.Count);
LivePacketDevice 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(DeviceAttributes.None, device.Attributes);
Assert.AreEqual(1, device.Addresses.Count); Assert.AreEqual(1, device.Addresses.Count);
DeviceAddress 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());
......
...@@ -206,7 +206,7 @@ namespace PcapDotNet.Core.Test ...@@ -206,7 +206,7 @@ namespace PcapDotNet.Core.Test
Packet expectedPacket = MoreRandom.BuildRandomPacket(100); Packet expectedPacket = MoreRandom.BuildRandomPacket(100);
using (PacketCommunicator communicator = OpenOfflineDevice(101, expectedPacket)) using (PacketCommunicator communicator = OpenOfflineDevice(101, expectedPacket))
{ {
communicator.SetSamplingMethod(new SamplingMethodOneEveryN(10)); communicator.SetSamplingMethod(new SamplingMethodOneEveryCount(10));
PacketCommunicatorReceiveResult result; PacketCommunicatorReceiveResult result;
Packet packet; Packet packet;
for (int i = 0; i != 10; ++i) for (int i = 0; i != 10; ++i)
...@@ -353,7 +353,7 @@ namespace PcapDotNet.Core.Test ...@@ -353,7 +353,7 @@ namespace PcapDotNet.Core.Test
IPacketDevice device = new OfflinePacketDevice(dumpFilename); IPacketDevice device = new OfflinePacketDevice(dumpFilename);
Assert.AreEqual(0, device.Addresses.Count); Assert.AreEqual(0, device.Addresses.Count);
Assert.AreEqual(string.Empty, device.Description); Assert.AreEqual(string.Empty, device.Description);
Assert.AreEqual(DeviceFlags.None, device.Flags); Assert.AreEqual(DeviceAttributes.None, device.Attributes);
Assert.AreEqual(dumpFilename, device.Name); Assert.AreEqual(dumpFilename, device.Name);
communicator = device.Open(); communicator = device.Open();
try try
......
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,14 @@
<Word>pcap</Word> <Word>pcap</Word>
<Word>eof</Word> <Word>eof</Word>
<Word>netmask</Word> <Word>netmask</Word>
<Word>firefox</Word>
<Word>sna</Word>
<Word>ipx</Word>
<Word>osi</Word>
<Word>tcn</Word>
<Word>datakit</Word>
<Word>ccitt</Word>
<Word>iclfxbm</Word>
</Recognized> </Recognized>
<Deprecated> <Deprecated>
<!--Term PreferredAlternate="EnterpriseServices">complus</Term--> <!--Term PreferredAlternate="EnterpriseServices">complus</Term-->
......
...@@ -12,7 +12,7 @@ DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress) ...@@ -12,7 +12,7 @@ DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress)
switch (family) switch (family)
{ {
case SocketAddressFamily::INET: case SocketAddressFamily::Internet:
if (pcapAddress->addr) if (pcapAddress->addr)
_address = gcnew IpV4SocketAddress(pcapAddress->addr); _address = gcnew IpV4SocketAddress(pcapAddress->addr);
if (pcapAddress->netmask) if (pcapAddress->netmask)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
[System::Flags] [System::Flags]
public enum class DeviceFlags : System::Int32 public enum class DeviceAttributes : System::Int32
{ {
None = 0x00000000, None = 0x00000000,
Loopback = 0x00000001 Loopback = 0x00000001
...@@ -16,7 +16,7 @@ namespace PcapDotNet { namespace Core ...@@ -16,7 +16,7 @@ namespace PcapDotNet { namespace Core
{ {
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 DeviceAttributes^ Attributes { DeviceAttributes^ get(); };
property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
{ {
System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get(); System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get();
...@@ -26,9 +26,9 @@ namespace PcapDotNet { namespace Core ...@@ -26,9 +26,9 @@ namespace PcapDotNet { namespace Core
/// Open a generic source in order to capture / send (WinPcap only) traffic. /// Open a generic source in order to capture / send (WinPcap only) traffic.
/// </summary> /// </summary>
/// <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="attributes">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="readTimeout">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>
PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout); PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenAttributes attributes, 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.
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
LivePacketCommunicator::LivePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth* auth, SocketAddress^ netmask) LivePacketCommunicator::LivePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth, SocketAddress^ netmask)
: PacketCommunicator(source, snapshotLength, flags, readTimeout, auth, netmask) : PacketCommunicator(source, snapshotLength, attributes, readTimeout, auth, netmask)
{ {
} }
......
...@@ -18,7 +18,7 @@ namespace PcapDotNet { namespace Core ...@@ -18,7 +18,7 @@ namespace PcapDotNet { namespace Core
virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override; virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override;
internal: internal:
LivePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth* auth, LivePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth,
SocketAddress^ netmask); SocketAddress^ netmask);
}; };
......
...@@ -41,7 +41,7 @@ ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get() ...@@ -41,7 +41,7 @@ ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get()
result->Add(gcnew LivePacketDevice(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<DeviceAttributes>(d->flags),
gcnew ReadOnlyCollection<DeviceAddress^>(addresses))); gcnew ReadOnlyCollection<DeviceAddress^>(addresses)));
} }
return gcnew ReadOnlyCollection<LivePacketDevice^>(result); return gcnew ReadOnlyCollection<LivePacketDevice^>(result);
...@@ -63,9 +63,9 @@ String^ LivePacketDevice::Description::get() ...@@ -63,9 +63,9 @@ String^ LivePacketDevice::Description::get()
return _description; return _description;
} }
DeviceFlags^ LivePacketDevice::Flags::get() DeviceAttributes^ LivePacketDevice::Attributes::get()
{ {
return _flags; return _attributes;
} }
ReadOnlyCollection<DeviceAddress^>^ LivePacketDevice::Addresses::get() ReadOnlyCollection<DeviceAddress^>^ LivePacketDevice::Addresses::get()
...@@ -73,7 +73,7 @@ ReadOnlyCollection<DeviceAddress^>^ LivePacketDevice::Addresses::get() ...@@ -73,7 +73,7 @@ ReadOnlyCollection<DeviceAddress^>^ LivePacketDevice::Addresses::get()
return gcnew ReadOnlyCollection<DeviceAddress^>(_addresses); return gcnew ReadOnlyCollection<DeviceAddress^>(_addresses);
} }
PacketCommunicator^ LivePacketDevice::Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) PacketCommunicator^ LivePacketDevice::Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout)
{ {
std::string deviceName = MarshalingServices::ManagedToUnmanagedString(Name); std::string deviceName = MarshalingServices::ManagedToUnmanagedString(Name);
...@@ -83,15 +83,15 @@ PacketCommunicator^ LivePacketDevice::Open(int snapshotLength, PacketDeviceOpenF ...@@ -83,15 +83,15 @@ PacketCommunicator^ LivePacketDevice::Open(int snapshotLength, PacketDeviceOpenF
netmask = Addresses[0]->Netmask; netmask = Addresses[0]->Netmask;
// Open the device // Open the device
return gcnew LivePacketCommunicator(deviceName.c_str(), snapshotLength, flags, readTimeout, NULL, netmask); return gcnew LivePacketCommunicator(deviceName.c_str(), snapshotLength, attributes, readTimeout, NULL, netmask);
} }
// Private Methods // Private Methods
LivePacketDevice::LivePacketDevice(String^ name, String^ description, DeviceFlags^ flags, ReadOnlyCollection<DeviceAddress^>^ addresses) LivePacketDevice::LivePacketDevice(String^ name, String^ description, DeviceAttributes^ attributes, ReadOnlyCollection<DeviceAddress^>^ addresses)
{ {
_name = name; _name = name;
_description = description; _description = description;
_flags = flags; _attributes = attributes;
_addresses = addresses; _addresses = addresses;
} }
...@@ -22,9 +22,9 @@ namespace PcapDotNet { namespace Core ...@@ -22,9 +22,9 @@ namespace PcapDotNet { namespace Core
System::String^ get() override; System::String^ get() override;
} }
virtual property DeviceFlags^ Flags virtual property DeviceAttributes^ Attributes
{ {
DeviceFlags^ get() override; DeviceAttributes^ get() override;
} }
virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
...@@ -36,17 +36,17 @@ namespace PcapDotNet { namespace Core ...@@ -36,17 +36,17 @@ namespace PcapDotNet { namespace Core
/// Open a generic source in order to capture / send (WinPcap only) traffic. /// Open a generic source in order to capture / send (WinPcap only) traffic.
/// </summary> /// </summary>
/// <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="attributes">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="readTimeout">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 PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) override; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout) override;
private: private:
LivePacketDevice(System::String^ name, System::String^ description, DeviceFlags^ flags, System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ addresses); LivePacketDevice(System::String^ name, System::String^ description, DeviceAttributes^ attributes, System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ addresses);
private: private:
System::String^ _name; System::String^ _name;
System::String^ _description; System::String^ _description;
DeviceFlags^ _flags; DeviceAttributes^ _attributes;
System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ _addresses; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ _addresses;
}; };
}} }}
\ No newline at end of file
...@@ -8,8 +8,8 @@ PacketTotalStatistics^ OfflinePacketCommunicator::TotalStatistics::get() ...@@ -8,8 +8,8 @@ PacketTotalStatistics^ OfflinePacketCommunicator::TotalStatistics::get()
throw gcnew InvalidOperationException("Can't get TotalStatistics for offline devices"); throw gcnew InvalidOperationException("Can't get TotalStatistics for offline devices");
} }
OfflinePacketCommunicator::OfflinePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth* auth) OfflinePacketCommunicator::OfflinePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth)
: PacketCommunicator(source, snapshotLength, flags, readTimeout, auth, nullptr) : PacketCommunicator(source, snapshotLength, attributes, readTimeout, auth, nullptr)
{ {
} }
......
...@@ -16,6 +16,6 @@ namespace PcapDotNet { namespace Core ...@@ -16,6 +16,6 @@ namespace PcapDotNet { namespace Core
virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override; virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override;
internal: internal:
OfflinePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth* auth); OfflinePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth);
}; };
}} }}
...@@ -26,9 +26,9 @@ String^ OfflinePacketDevice::Description::get() ...@@ -26,9 +26,9 @@ String^ OfflinePacketDevice::Description::get()
return String::Empty; return String::Empty;
} }
DeviceFlags^ OfflinePacketDevice::Flags::get() DeviceAttributes^ OfflinePacketDevice::Attributes::get()
{ {
return DeviceFlags::None; return DeviceAttributes::None;
} }
ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get() ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get()
...@@ -36,7 +36,7 @@ ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get() ...@@ -36,7 +36,7 @@ ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get()
return gcnew ReadOnlyCollection<DeviceAddress^>(gcnew List<DeviceAddress^>()); return gcnew ReadOnlyCollection<DeviceAddress^>(gcnew List<DeviceAddress^>());
} }
PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout)
{ {
std::string unamangedFilename = MarshalingServices::ManagedToUnmanagedString(_fileName); std::string unamangedFilename = MarshalingServices::ManagedToUnmanagedString(_fileName);
...@@ -54,5 +54,5 @@ PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOp ...@@ -54,5 +54,5 @@ PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOp
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 OfflinePacketCommunicator(source, snapshotLength, flags, readTimeout, NULL); return gcnew OfflinePacketCommunicator(source, snapshotLength, attributes, readTimeout, NULL);
} }
...@@ -19,9 +19,9 @@ namespace PcapDotNet { namespace Core ...@@ -19,9 +19,9 @@ namespace PcapDotNet { namespace Core
System::String^ get() override; System::String^ get() override;
} }
virtual property DeviceFlags^ Flags virtual property DeviceAttributes^ Attributes
{ {
DeviceFlags^ get() override; DeviceAttributes^ get() override;
} }
virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
...@@ -29,7 +29,7 @@ namespace PcapDotNet { namespace Core ...@@ -29,7 +29,7 @@ namespace PcapDotNet { namespace Core
System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() override; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() override;
} }
virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) override; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout) override;
private: private:
System::String^ _fileName; System::String^ _fileName;
......
...@@ -14,14 +14,14 @@ using namespace System::Collections::Generic; ...@@ -14,14 +14,14 @@ using namespace System::Collections::Generic;
using namespace Packets; using namespace Packets;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth *auth, SocketAddress^ netmask) PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth *auth, SocketAddress^ netmask)
{ {
// Open the device // Open the device
char errbuf[PCAP_ERRBUF_SIZE]; char errbuf[PCAP_ERRBUF_SIZE];
pcap_t *pcapDescriptor = pcap_open(source, // name of the device pcap_t *pcapDescriptor = pcap_open(source, // name of the device
snapshotLength, // portion of the packet to capture snapshotLength, // portion of the packet to capture
// 65536 guarantees that the whole packet will be captured on all the link layers // 65536 guarantees that the whole packet will be captured on all the link layers
safe_cast<int>(flags), safe_cast<int>(attributes),
readTimeout, // read timeout readTimeout, // read timeout
auth, // authentication on the remote machine auth, // authentication on the remote machine
errbuf); // error buffer errbuf); // error buffer
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public delegate void HandlePacket(Packets::Packet^ packet);
public delegate void HandleStatistics(PacketSampleStatistics^ statistics);
/// <summary> /// <summary>
/// Used to receive and send packets accross the network or to read and write packets to a pcap file. /// Used to receive and send packets accross the network or to read and write packets to a pcap file.
/// </summary> /// </summary>
...@@ -74,12 +77,10 @@ namespace PcapDotNet { namespace Core ...@@ -74,12 +77,10 @@ namespace PcapDotNet { namespace Core
void SetSamplingMethod(SamplingMethod^ method); void SetSamplingMethod(SamplingMethod^ method);
delegate void HandlePacket(Packets::Packet^ packet);
PacketCommunicatorReceiveResult ReceivePacket([System::Runtime::InteropServices::Out] Packets::Packet^% packet); PacketCommunicatorReceiveResult ReceivePacket([System::Runtime::InteropServices::Out] Packets::Packet^% packet);
PacketCommunicatorReceiveResult ReceiveSomePackets([System::Runtime::InteropServices::Out] int% countGot, int maxPackets, HandlePacket^ callback); PacketCommunicatorReceiveResult ReceiveSomePackets([System::Runtime::InteropServices::Out] int% countGot, int maxPackets, HandlePacket^ callback);
PacketCommunicatorReceiveResult ReceivePackets(int count, HandlePacket^ callback); PacketCommunicatorReceiveResult ReceivePackets(int count, HandlePacket^ callback);
delegate void HandleStatistics(PacketSampleStatistics^ statistics);
PacketCommunicatorReceiveResult ReceiveStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics); PacketCommunicatorReceiveResult ReceiveStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics);
PacketCommunicatorReceiveResult ReceiveStatistics(int count, HandleStatistics^ callback); PacketCommunicatorReceiveResult ReceiveStatistics(int count, HandleStatistics^ callback);
...@@ -97,7 +98,7 @@ namespace PcapDotNet { namespace Core ...@@ -97,7 +98,7 @@ namespace PcapDotNet { namespace Core
~PacketCommunicator(); ~PacketCommunicator();
internal: internal:
PacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout, pcap_rmtauth* auth, PacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth,
SocketAddress^ netmask); SocketAddress^ netmask);
protected: protected:
......
...@@ -4,5 +4,5 @@ using namespace PcapDotNet::Core; ...@@ -4,5 +4,5 @@ using namespace PcapDotNet::Core;
PacketCommunicator^ PacketDevice::Open() PacketCommunicator^ PacketDevice::Open()
{ {
return Open(DefaultSnapshotLength, PacketDeviceOpenFlags::Promiscuous, 1000); return Open(DefaultSnapshotLength, PacketDeviceOpenAttributes::Promiscuous, 1000);
} }
...@@ -7,7 +7,7 @@ namespace PcapDotNet { namespace Core ...@@ -7,7 +7,7 @@ namespace PcapDotNet { namespace Core
public ref class PacketDevice abstract : IPacketDevice public ref class PacketDevice abstract : IPacketDevice
{ {
public: public:
static const int DefaultSnapshotLength = 65536; literal int DefaultSnapshotLength = 65536;
virtual property System::String^ Name virtual property System::String^ Name
{ {
...@@ -19,9 +19,9 @@ namespace PcapDotNet { namespace Core ...@@ -19,9 +19,9 @@ namespace PcapDotNet { namespace Core
System::String^ get() = 0; System::String^ get() = 0;
} }
virtual property DeviceFlags^ Flags virtual property DeviceAttributes^ Attributes
{ {
DeviceFlags^ get() = 0; DeviceAttributes^ get() = 0;
} }
virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses virtual property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
...@@ -29,7 +29,7 @@ namespace PcapDotNet { namespace Core ...@@ -29,7 +29,7 @@ namespace PcapDotNet { namespace Core
System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() = 0; System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get() = 0;
} }
virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) = 0; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout) = 0;
virtual PacketCommunicator^ Open(); virtual PacketCommunicator^ Open();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
[System::Flags] [System::Flags]
public enum class PacketDeviceOpenFlags : System::Int32 public enum class PacketDeviceOpenAttributes : 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.
......
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
using namespace System; using namespace System;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
SamplingMethodOneEveryN::SamplingMethodOneEveryN(int n) SamplingMethodOneEveryCount::SamplingMethodOneEveryCount(int count)
{ {
if (n <= 0) if (count <= 0)
throw gcnew ArgumentOutOfRangeException("n", n, "Must be positive"); throw gcnew ArgumentOutOfRangeException("count", count, "Must be positive");
_n = n; _count = count;
} }
int SamplingMethodOneEveryN::Method::get() int SamplingMethodOneEveryCount::Method::get()
{ {
return PCAP_SAMP_1_EVERY_N; return PCAP_SAMP_1_EVERY_N;
} }
int SamplingMethodOneEveryN::Value::get() int SamplingMethodOneEveryCount::Value::get()
{ {
return _n; return _count;
} }
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
public ref class SamplingMethodOneEveryN : SamplingMethod public ref class SamplingMethodOneEveryCount : SamplingMethod
{ {
public: public:
SamplingMethodOneEveryN(int n); SamplingMethodOneEveryCount(int count);
internal: internal:
virtual property int Method virtual property int Method
...@@ -21,6 +21,6 @@ namespace PcapDotNet { namespace Core ...@@ -21,6 +21,6 @@ namespace PcapDotNet { namespace Core
} }
private: private:
int _n; int _count;
}; };
}} }}
\ No newline at end of file
...@@ -4,40 +4,40 @@ namespace PcapDotNet { namespace Core ...@@ -4,40 +4,40 @@ namespace PcapDotNet { namespace Core
{ {
public enum class SocketAddressFamily : System::UInt16 public enum class SocketAddressFamily : System::UInt16
{ {
UNSPEC = 0, // unspecified Unspecified = 0, // unspecified
UNIX = 1, // local to host (pipes, portals) Unix = 1, // local to host (pipes, portals)
INET = 2, // internetwork: UDP, TCP, etc. Internet = 2, // internetwork: UDP, TCP, etc.
IMPLINK = 3, // arpanet imp addresses ImpLink = 3, // arpanet imp addresses
PUP = 4, // pup protocols: e.g. BSP Pup = 4, // pup protocols: e.g. BSP
CHAOS = 5, // mit CHAOS protocols Chaos = 5, // mit CHAOS protocols
NS = 6, // XEROX NS protocols NS = 6, // XEROX NS protocols
IPX = NS, // IPX protocols: IPX, SPX, etc. Ipx = NS, // IPX protocols: IPX, SPX, etc.
ISO = 7, // ISO protocols Iso = 7, // ISO protocols
OSI = ISO, // OSI is ISO Osi = Iso, // OSI is ISO
ECMA = 8, // european computer manufacturers EuropeanComputerManufactures = 8, // european computer manufacturers
DATAKIT = 9, // datakit protocols Datakit = 9, // datakit protocols
CCITT = 10, Ccitt = 10,
// CCITT protocols, X.25 etc // CCITT protocols, X.25 etc
SNA = 11, // IBM SNA Sna = 11, // IBM SNA
DECnet = 12, // DECnet DECnet = 12, // DECnet
DLI = 13, // Direct data link interface DirectDataLinkInterface = 13, // Direct data link interface
LAT = 14, // LAT Lat = 14, // LAT
HYLINK = 15, // NSC Hyperchannel HyperChannel = 15, // NSC Hyperchannel
APPLETALK = 16, // AppleTalk AppleTalk = 16, // AppleTalk
NETBIOS = 17, // NetBios-style addresses NetBios = 17, // NetBios-style addresses
VOICEVIEW = 18, // VoiceView VoiceView = 18, // VoiceView
FIREFOX = 19, // Protocols from Firefox Firefox = 19, // Protocols from Firefox
UNKNOWN1 = 20, // Somebody is using this! Unknown1 = 20, // Somebody is using this!
BAN = 21, // Banyan Ban = 21, // Banyan
ATM = 22, // Native ATM Services Atm = 22, // Native ATM Services
INET6 = 23, // Internetwork Version 6 Internet6 = 23, // Internetwork Version 6
CLUSTER = 24, // Microsoft Wolfpack Cluster = 24, // Microsoft Wolfpack
IEEE12844 = 25, // IEEE 1284.4 WG AF Ieee12844 = 25, // IEEE 1284.4 WG AF
IRDA = 26, // IrDA Irda = 26, // IrDA
NETDES = 28, // Network Designers OSI & gateway NetworkDesigners = 28, // Network Designers OSI & gateway
TCNPROCESS = 29, TcnProcess = 29,
TCNMESSAGE = 30, TcnMessage = 30,
ICLFXBM = 31, Iclfxbm = 31,
BTH = 32 // Bluetooth RFCOMM/L2CAP protocols Bluetooth = 32 // Bluetooth RFCOMM/L2CAP protocols
}; };
}} }}
\ No newline at end of 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