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