Commit 4a505ab8 authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent f3580f3a
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<SccLocalPath>SAK</SccLocalPath> <SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath> <SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider> <SccProvider>SAK</SccProvider>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Packets.snk</AssemblyOriginatorKeyFile>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
...@@ -62,6 +65,9 @@ ...@@ -62,6 +65,9 @@
<Compile Include="PacketBuilder.cs" /> <Compile Include="PacketBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Packets.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
...@@ -70,4 +76,7 @@ ...@@ -70,4 +76,7 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
<PropertyGroup>
<PreBuildEvent>if not exist "$(ProjectDir)$(ProjectName).snk" ("%25PROGRAMFILES%25\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -k "$(ProjectDir)$(ProjectName).snk")</PreBuildEvent>
</PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -10,14 +10,14 @@ using namespace System::Runtime::InteropServices; ...@@ -10,14 +10,14 @@ using namespace System::Runtime::InteropServices;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
using namespace Packets; using namespace Packets;
BerkeleyPacketFilter::BerkeleyPacketFilter(String^ filterString, int snapshotLength, DataLinkKind kind, IpV4SocketAddress^ netmask) BerkeleyPacketFilter::BerkeleyPacketFilter(String^ filterValue, int snapshotLength, DataLinkKind kind, IpV4SocketAddress^ netmask)
{ {
Initialize(filterString, snapshotLength, kind, netmask); Initialize(filterValue, snapshotLength, kind, netmask);
} }
BerkeleyPacketFilter::BerkeleyPacketFilter(String^ filterString, int snapshotLength, DataLinkKind kind) BerkeleyPacketFilter::BerkeleyPacketFilter(String^ filterValue, int snapshotLength, DataLinkKind kind)
{ {
Initialize(filterString, snapshotLength, kind, nullptr); Initialize(filterValue, snapshotLength, kind, nullptr);
} }
bool BerkeleyPacketFilter::Test([Out] int% snapshotLength, Packets::Packet^ packet) bool BerkeleyPacketFilter::Test([Out] int% snapshotLength, Packets::Packet^ packet)
......
...@@ -8,8 +8,8 @@ namespace PcapDotNet { namespace Core ...@@ -8,8 +8,8 @@ namespace PcapDotNet { namespace Core
public ref class BerkeleyPacketFilter : System::IDisposable public ref class BerkeleyPacketFilter : System::IDisposable
{ {
public: public:
BerkeleyPacketFilter(System::String^ filterString, int snapshotLength, Packets::DataLinkKind kind, IpV4SocketAddress^ netmask); BerkeleyPacketFilter(System::String^ filterValue, int snapshotLength, Packets::DataLinkKind kind, IpV4SocketAddress^ netmask);
BerkeleyPacketFilter(System::String^ filterString, int snapshotLength, Packets::DataLinkKind kind); BerkeleyPacketFilter(System::String^ filterValue, int snapshotLength, Packets::DataLinkKind kind);
bool Test([System::Runtime::InteropServices::Out] int% snapshotLength, Packets::Packet^ packet); bool Test([System::Runtime::InteropServices::Out] int% snapshotLength, Packets::Packet^ packet);
bool Test(Packets::Packet^ packet); bool Test(Packets::Packet^ packet);
......
<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
<Words>
<Recognized>
<Word>netmask</Word>
<Word>pcap</Word>
</Recognized>
</Words>
</Dictionary>
\ No newline at end of file
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
[System::Flags] [System::Flags]
public enum class DeviceFlags : System::UInt32 public enum class DeviceFlags : System::Int32
{ {
None = 0x00000000, None = 0x00000000,
LoopBack = 0x00000001 Loopback = 0x00000001
}; };
public interface class IPacketDevice public interface class IPacketDevice
......
...@@ -12,7 +12,7 @@ LivePacketCommunicator::LivePacketCommunicator(const char* source, int snapshotL ...@@ -12,7 +12,7 @@ LivePacketCommunicator::LivePacketCommunicator(const char* source, int snapshotL
PacketTotalStatistics^ LivePacketCommunicator::TotalStatistics::get() PacketTotalStatistics^ LivePacketCommunicator::TotalStatistics::get()
{ {
int statisticsSize; int statisticsSize;
pcap_stat* statistics = pcap_stats_ex(_pcapDescriptor, &statisticsSize); pcap_stat* statistics = pcap_stats_ex(PcapDescriptor, &statisticsSize);
if (statistics == NULL) if (statistics == NULL)
throw BuildInvalidOperation("Failed getting total statistics"); throw BuildInvalidOperation("Failed getting total statistics");
...@@ -27,5 +27,5 @@ PacketTotalStatistics^ LivePacketCommunicator::TotalStatistics::get() ...@@ -27,5 +27,5 @@ PacketTotalStatistics^ LivePacketCommunicator::TotalStatistics::get()
void LivePacketCommunicator::Transmit(PacketSendQueue^ sendQueue, bool isSync) void LivePacketCommunicator::Transmit(PacketSendQueue^ sendQueue, bool isSync)
{ {
sendQueue->Transmit(_pcapDescriptor, isSync); sendQueue->Transmit(PcapDescriptor, isSync);
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
using namespace System; using namespace System;
using namespace System::Collections::Generic; using namespace System::Collections::Generic;
using namespace System::Collections::ObjectModel; using namespace System::Collections::ObjectModel;
using namespace System::Globalization;
using namespace Packets; using namespace Packets;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
...@@ -22,7 +23,7 @@ ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get() ...@@ -22,7 +23,7 @@ ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get()
&alldevs, errbuf) == -1) &alldevs, errbuf) == -1)
{ {
String^ errorString = gcnew String(errbuf); String^ errorString = gcnew String(errbuf);
throw gcnew InvalidOperationException(String::Format("Failed getting devices. Error: %s", errorString)); throw gcnew InvalidOperationException(String::Format(CultureInfo::InvariantCulture, "Failed getting devices. Error: %s", errorString));
} }
try try
......
...@@ -10,5 +10,8 @@ namespace PcapDotNet { namespace Core ...@@ -10,5 +10,8 @@ namespace PcapDotNet { namespace Core
static std::string ManagedToUnmanagedString(System::String^ managedString); static std::string ManagedToUnmanagedString(System::String^ managedString);
static array<System::Byte>^ UnamangedToManagedByteArray(const unsigned char* unmanagedByteArray, int offset, int count); static array<System::Byte>^ UnamangedToManagedByteArray(const unsigned char* unmanagedByteArray, int offset, int count);
private:
MarshalingServices(){}
}; };
}} }}
\ No newline at end of file
...@@ -11,14 +11,14 @@ using namespace System::Collections::Generic; ...@@ -11,14 +11,14 @@ using namespace System::Collections::Generic;
using namespace System::Collections::ObjectModel; using namespace System::Collections::ObjectModel;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
OfflinePacketDevice::OfflinePacketDevice(System::String^ filename) OfflinePacketDevice::OfflinePacketDevice(System::String^ fileName)
{ {
_filename = filename; _fileName = fileName;
} }
String^ OfflinePacketDevice::Name::get() String^ OfflinePacketDevice::Name::get()
{ {
return _filename; return _fileName;
} }
String^ OfflinePacketDevice::Description::get() String^ OfflinePacketDevice::Description::get()
...@@ -38,7 +38,7 @@ ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get() ...@@ -38,7 +38,7 @@ ReadOnlyCollection<DeviceAddress^>^ OfflinePacketDevice::Addresses::get()
PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout)
{ {
std::string unamangedFilename = MarshalingServices::ManagedToUnmanagedString(_filename); std::string unamangedFilename = MarshalingServices::ManagedToUnmanagedString(_fileName);
// Create the source string according to the new WinPcap syntax // Create the source string according to the new WinPcap syntax
char source[PCAP_BUF_SIZE]; char source[PCAP_BUF_SIZE];
...@@ -51,7 +51,7 @@ PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOp ...@@ -51,7 +51,7 @@ PacketCommunicator^ OfflinePacketDevice::Open(int snapshotLength, PacketDeviceOp
errbuf // error buffer errbuf // error buffer
) != 0) ) != 0)
{ {
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, flags, readTimeout, NULL);
......
...@@ -7,9 +7,9 @@ namespace PcapDotNet { namespace Core ...@@ -7,9 +7,9 @@ namespace PcapDotNet { namespace Core
public ref class OfflinePacketDevice : PacketDevice public ref class OfflinePacketDevice : PacketDevice
{ {
public: public:
OfflinePacketDevice(System::String^ filename); OfflinePacketDevice(System::String^ fileName);
virtual property System::String^ Name virtual property System::String^ Name
{ {
System::String^ get() override; System::String^ get() override;
} }
...@@ -32,6 +32,6 @@ namespace PcapDotNet { namespace Core ...@@ -32,6 +32,6 @@ namespace PcapDotNet { namespace Core
virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) override; virtual PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenFlags flags, int readTimeout) override;
private: private:
System::String^ _filename; System::String^ _fileName;
}; };
}} }}
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "Pcap.h" #include "Pcap.h"
using namespace System; using namespace System;
using namespace System::Globalization;
using namespace System::Runtime::InteropServices; using namespace System::Runtime::InteropServices;
using namespace System::Collections::ObjectModel; using namespace System::Collections::ObjectModel;
using namespace System::Collections::Generic; using namespace System::Collections::Generic;
...@@ -27,7 +28,7 @@ PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, P ...@@ -27,7 +28,7 @@ PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, P
if (pcapDescriptor == NULL) if (pcapDescriptor == NULL)
{ {
throw gcnew InvalidOperationException(String::Format("Unable to open the adapter. %s is not supported by WinPcap", gcnew String(source))); throw gcnew InvalidOperationException(String::Format(CultureInfo::InvariantCulture, "Unable to open the adapter. %s is not supported by WinPcap", gcnew String(source)));
} }
_pcapDescriptor = pcapDescriptor; _pcapDescriptor = pcapDescriptor;
...@@ -186,15 +187,15 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceiveSomePackets([Out] int ...@@ -186,15 +187,15 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceiveSomePackets([Out] int
return PacketCommunicatorReceiveResult::Ok; return PacketCommunicatorReceiveResult::Ok;
} }
PacketCommunicatorReceiveResult PacketCommunicator::ReceivePackets(int numPackets, HandlePacket^ callBack) PacketCommunicatorReceiveResult PacketCommunicator::ReceivePackets(int count, HandlePacket^ callback)
{ {
AssertMode(PacketCommunicatorMode::Capture); AssertMode(PacketCommunicatorMode::Capture);
PacketHandler^ packetHandler = gcnew PacketHandler(callBack, DataLink); PacketHandler^ packetHandler = gcnew PacketHandler(callback, DataLink);
HandlerDelegate^ packetHandlerDelegate = gcnew HandlerDelegate(packetHandler, &PacketHandler::Handle); HandlerDelegate^ packetHandlerDelegate = gcnew HandlerDelegate(packetHandler, &PacketHandler::Handle);
pcap_handler functionPointer = (pcap_handler)Marshal::GetFunctionPointerForDelegate(packetHandlerDelegate).ToPointer(); pcap_handler functionPointer = (pcap_handler)Marshal::GetFunctionPointerForDelegate(packetHandlerDelegate).ToPointer();
int result = pcap_loop(_pcapDescriptor, numPackets, functionPointer, NULL); int result = pcap_loop(_pcapDescriptor, count, functionPointer, NULL);
switch (result) switch (result)
{ {
case -2: case -2:
...@@ -202,7 +203,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceivePackets(int numPacket ...@@ -202,7 +203,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceivePackets(int numPacket
case -1: case -1:
throw BuildInvalidOperation("Failed reading from device"); throw BuildInvalidOperation("Failed reading from device");
case 0: case 0:
if (packetHandler->PacketCounter != numPackets) if (packetHandler->PacketCounter != count)
return PacketCommunicatorReceiveResult::Eof; return PacketCommunicatorReceiveResult::Eof;
} }
...@@ -228,7 +229,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceiveStatistics([Out] Pack ...@@ -228,7 +229,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceiveStatistics([Out] Pack
return result; return result;
} }
PacketCommunicatorReceiveResult PacketCommunicator::ReceiveStatistics(int numStatistics, HandleStatistics^ callBack) PacketCommunicatorReceiveResult PacketCommunicator::ReceiveStatistics(int count, HandleStatistics^ callBack)
{ {
AssertMode(PacketCommunicatorMode::Statistics); AssertMode(PacketCommunicatorMode::Statistics);
...@@ -236,7 +237,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceiveStatistics(int numSta ...@@ -236,7 +237,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::ReceiveStatistics(int numSta
HandlerDelegate^ statisticsHandlerDelegate = gcnew HandlerDelegate(statisticsHandler, &StatisticsHandler::Handle); HandlerDelegate^ statisticsHandlerDelegate = gcnew HandlerDelegate(statisticsHandler, &StatisticsHandler::Handle);
pcap_handler functionPointer = (pcap_handler)Marshal::GetFunctionPointerForDelegate(statisticsHandlerDelegate).ToPointer(); pcap_handler functionPointer = (pcap_handler)Marshal::GetFunctionPointerForDelegate(statisticsHandlerDelegate).ToPointer();
int result = pcap_loop(_pcapDescriptor, numStatistics, functionPointer, NULL); int result = pcap_loop(_pcapDescriptor, count, functionPointer, NULL);
if (result == -1) if (result == -1)
throw BuildInvalidOperation("Failed reading from device"); throw BuildInvalidOperation("Failed reading from device");
if (result == -2) if (result == -2)
...@@ -259,9 +260,9 @@ void PacketCommunicator::SendPacket(Packet^ packet) ...@@ -259,9 +260,9 @@ void PacketCommunicator::SendPacket(Packet^ packet)
} }
BerkeleyPacketFilter^ PacketCommunicator::CreateFilter(String^ filterString) BerkeleyPacketFilter^ PacketCommunicator::CreateFilter(String^ filterValue)
{ {
return gcnew BerkeleyPacketFilter(_pcapDescriptor, filterString, _ipV4Netmask); return gcnew BerkeleyPacketFilter(_pcapDescriptor, filterValue, _ipV4Netmask);
} }
void PacketCommunicator::SetFilter(BerkeleyPacketFilter^ filter) void PacketCommunicator::SetFilter(BerkeleyPacketFilter^ filter)
...@@ -269,9 +270,9 @@ void PacketCommunicator::SetFilter(BerkeleyPacketFilter^ filter) ...@@ -269,9 +270,9 @@ void PacketCommunicator::SetFilter(BerkeleyPacketFilter^ filter)
filter->SetFilter(_pcapDescriptor); filter->SetFilter(_pcapDescriptor);
} }
void PacketCommunicator::SetFilter(String^ filterString) void PacketCommunicator::SetFilter(String^ filterValue)
{ {
BerkeleyPacketFilter^ filter = CreateFilter(filterString); BerkeleyPacketFilter^ filter = CreateFilter(filterValue);
try try
{ {
SetFilter(filter); SetFilter(filter);
...@@ -282,9 +283,9 @@ void PacketCommunicator::SetFilter(String^ filterString) ...@@ -282,9 +283,9 @@ void PacketCommunicator::SetFilter(String^ filterString)
} }
} }
PacketDumpFile^ PacketCommunicator::OpenDump(System::String^ filename) PacketDumpFile^ PacketCommunicator::OpenDump(System::String^ fileName)
{ {
return gcnew PacketDumpFile(_pcapDescriptor, filename); return gcnew PacketDumpFile(_pcapDescriptor, fileName);
} }
PacketCommunicator::~PacketCommunicator() PacketCommunicator::~PacketCommunicator()
...@@ -328,7 +329,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::RunPcapNextEx(pcap_pkthdr** ...@@ -328,7 +329,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::RunPcapNextEx(pcap_pkthdr**
case 1: case 1:
return PacketCommunicatorReceiveResult::Ok; return PacketCommunicatorReceiveResult::Ok;
default: default:
throw gcnew InvalidOperationException("Result value " + result.ToString() + " is undefined"); throw gcnew InvalidOperationException("Result value " + result.ToString(CultureInfo::InvariantCulture) + " is undefined");
} }
} }
...@@ -343,10 +344,15 @@ InvalidOperationException^ PacketCommunicator::BuildInvalidOperation(System::Str ...@@ -343,10 +344,15 @@ InvalidOperationException^ PacketCommunicator::BuildInvalidOperation(System::Str
return PcapError::BuildInvalidOperation(errorMessage, _pcapDescriptor); return PcapError::BuildInvalidOperation(errorMessage, _pcapDescriptor);
} }
pcap_t* PacketCommunicator::PcapDescriptor::get()
{
return _pcapDescriptor;
}
void PacketCommunicator::PacketHandler::Handle(unsigned char *user, const struct pcap_pkthdr *packetHeader, const unsigned char *packetData) void PacketCommunicator::PacketHandler::Handle(unsigned char *user, const struct pcap_pkthdr *packetHeader, const unsigned char *packetData)
{ {
++_packetCounter; ++_packetCounter;
_callBack->Invoke(CreatePacket(*packetHeader, packetData, _dataLink)); _callback->Invoke(CreatePacket(*packetHeader, packetData, _dataLink));
} }
int PacketCommunicator::PacketHandler::PacketCounter::get() int PacketCommunicator::PacketHandler::PacketCounter::get()
...@@ -356,5 +362,5 @@ int PacketCommunicator::PacketHandler::PacketCounter::get() ...@@ -356,5 +362,5 @@ int PacketCommunicator::PacketHandler::PacketCounter::get()
void PacketCommunicator::StatisticsHandler::Handle(unsigned char *user, const struct pcap_pkthdr *packetHeader, const unsigned char *packetData) void PacketCommunicator::StatisticsHandler::Handle(unsigned char *user, const struct pcap_pkthdr *packetHeader, const unsigned char *packetData)
{ {
_callBack->Invoke(CreateStatistics(*packetHeader, packetData)); _callback->Invoke(CreateStatistics(*packetHeader, packetData));
} }
\ No newline at end of file
...@@ -76,23 +76,23 @@ namespace PcapDotNet { namespace Core ...@@ -76,23 +76,23 @@ namespace PcapDotNet { namespace Core
delegate void HandlePacket(Packets::Packet^ packet); 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% numPacketsGot, int maxPackets, HandlePacket^ callBack); PacketCommunicatorReceiveResult ReceiveSomePackets([System::Runtime::InteropServices::Out] int% numPacketsGot, int maxPackets, HandlePacket^ callback);
PacketCommunicatorReceiveResult ReceivePackets(int numPackets, HandlePacket^ callBack); PacketCommunicatorReceiveResult ReceivePackets(int count, HandlePacket^ callback);
delegate void HandleStatistics(PacketSampleStatistics^ statistics); delegate void HandleStatistics(PacketSampleStatistics^ statistics);
PacketCommunicatorReceiveResult ReceiveStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics); PacketCommunicatorReceiveResult ReceiveStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics);
PacketCommunicatorReceiveResult ReceiveStatistics(int numStatistics, HandleStatistics^ callBack); PacketCommunicatorReceiveResult ReceiveStatistics(int count, HandleStatistics^ callback);
void Break(); void Break();
void SendPacket(Packets::Packet^ packet); void SendPacket(Packets::Packet^ packet);
virtual void Transmit(PacketSendQueue^ sendQueue, bool isSync) = 0; virtual void Transmit(PacketSendQueue^ sendQueue, bool isSync) = 0;
BerkeleyPacketFilter^ CreateFilter(System::String^ filterString); BerkeleyPacketFilter^ CreateFilter(System::String^ filterValue);
void SetFilter(BerkeleyPacketFilter^ filter); void SetFilter(BerkeleyPacketFilter^ filter);
void SetFilter(System::String^ filterString); void SetFilter(System::String^ filterValue);
PacketDumpFile^ OpenDump(System::String^ filename); PacketDumpFile^ OpenDump(System::String^ fileName);
~PacketCommunicator(); ~PacketCommunicator();
...@@ -101,6 +101,11 @@ namespace PcapDotNet { namespace Core ...@@ -101,6 +101,11 @@ namespace PcapDotNet { namespace Core
SocketAddress^ netmask); SocketAddress^ netmask);
protected: protected:
property pcap_t* PcapDescriptor
{
pcap_t* get();
}
System::InvalidOperationException^ BuildInvalidOperation(System::String^ errorMessage); System::InvalidOperationException^ BuildInvalidOperation(System::String^ errorMessage);
private: private:
...@@ -117,9 +122,9 @@ namespace PcapDotNet { namespace Core ...@@ -117,9 +122,9 @@ namespace PcapDotNet { namespace Core
ref class PacketHandler ref class PacketHandler
{ {
public: public:
PacketHandler(HandlePacket^ callBack, PcapDataLink dataLink) PacketHandler(HandlePacket^ callback, PcapDataLink dataLink)
{ {
_callBack = callBack; _callback = callback;
_dataLink = dataLink; _dataLink = dataLink;
} }
...@@ -131,7 +136,7 @@ namespace PcapDotNet { namespace Core ...@@ -131,7 +136,7 @@ namespace PcapDotNet { namespace Core
} }
private: private:
HandlePacket^ _callBack; HandlePacket^ _callback;
PcapDataLink _dataLink; PcapDataLink _dataLink;
int _packetCounter; int _packetCounter;
}; };
...@@ -139,21 +144,19 @@ namespace PcapDotNet { namespace Core ...@@ -139,21 +144,19 @@ namespace PcapDotNet { namespace Core
ref class StatisticsHandler ref class StatisticsHandler
{ {
public: public:
StatisticsHandler(HandleStatistics^ callBack) StatisticsHandler(HandleStatistics^ callback)
{ {
_callBack = callBack; _callback = callback;
} }
void Handle(unsigned char *user, const struct pcap_pkthdr *packetHeader, const unsigned char *packetData); void Handle(unsigned char *user, const struct pcap_pkthdr *packetHeader, const unsigned char *packetData);
private: private:
HandleStatistics^ _callBack; HandleStatistics^ _callback;
}; };
protected:
pcap_t* _pcapDescriptor;
private: private:
pcap_t* _pcapDescriptor;
IpV4SocketAddress^ _ipV4Netmask; IpV4SocketAddress^ _ipV4Netmask;
PacketCommunicatorMode _mode; PacketCommunicatorMode _mode;
}; };
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
Description="Create Public/Private Key Pair"
CommandLine="if not exist &quot;$(ProjectDir)$(ProjectName).snk&quot; (&quot;%PROGRAMFILES%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe&quot; -k &quot;$(ProjectDir)$(ProjectName).snk&quot;)"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
...@@ -47,12 +49,13 @@ ...@@ -47,12 +49,13 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="&quot;..\..\3rdParty\WpdPack\Include&quot;" AdditionalIncludeDirectories="&quot;..\..\3rdParty\WpdPack\Include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG" PreprocessorDefinitions="WIN32;_DEBUG;CODE_ANALYSIS"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
GenerateXMLDocumentationFiles="true" GenerateXMLDocumentationFiles="true"
WarningLevel="3" WarningLevel="3"
DebugInformationFormat="3" DebugInformationFormat="3"
EnablePREfast="false"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
...@@ -72,6 +75,7 @@ ...@@ -72,6 +75,7 @@
GenerateDebugInformation="true" GenerateDebugInformation="true"
AssemblyDebug="1" AssemblyDebug="1"
TargetMachine="1" TargetMachine="1"
KeyFile="&quot;$(ProjectDir)$(ProjectName).snk&quot;"
Profile="true" Profile="true"
/> />
<Tool <Tool
...@@ -88,6 +92,8 @@ ...@@ -88,6 +92,8 @@
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
EnableFxCop="true"
Dictionaries="CodeAnalysisDictionary.xml"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
...@@ -107,6 +113,8 @@ ...@@ -107,6 +113,8 @@
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
Description="Create Public/Private Key Pair"
CommandLine="if not exist &quot;$(ProjectDir)$(ProjectName).snk&quot; (&quot;%PROGRAMFILES%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe&quot; -k &quot;$(ProjectDir)$(ProjectName).snk&quot;)"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
...@@ -146,6 +154,7 @@ ...@@ -146,6 +154,7 @@
AddModuleNamesToAssembly="" AddModuleNamesToAssembly=""
GenerateDebugInformation="true" GenerateDebugInformation="true"
TargetMachine="1" TargetMachine="1"
KeyFile="&quot;$(ProjectDir)$(ProjectName).snk&quot;"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
...@@ -188,7 +197,7 @@ ...@@ -188,7 +197,7 @@
/> />
<ProjectReference <ProjectReference
ReferencedProjectIdentifier="{8A184AF5-E46C-482C-81A3-76D8CE290104}" ReferencedProjectIdentifier="{8A184AF5-E46C-482C-81A3-76D8CE290104}"
RelativePathToProject=".\BPacket\Packets.csproj" RelativePathToProject=".\Packets\Packets.csproj"
/> />
</References> </References>
<Files> <Files>
...@@ -380,6 +389,10 @@ ...@@ -380,6 +389,10 @@
RelativePath=".\BerkeleyPacketFilter.h" RelativePath=".\BerkeleyPacketFilter.h"
> >
</File> </File>
<File
RelativePath=".\CodeAnalysisDictionary.xml"
>
</File>
<File <File
RelativePath=".\PacketDumpFile.cpp" RelativePath=".\PacketDumpFile.cpp"
> >
......
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