Commit a3b27233 authored by Brickner_cp's avatar Brickner_cp

PreEmptive Analysis - Receiving and Sending packets features.

PacketSendBuffer - number of packets (Length).
parent d3b9fd5b
......@@ -42,6 +42,9 @@
<PropertyGroup>
<DelaySign>true</DelaySign>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\PcapDotNet\src\PcapDotNet.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="PreEmptive.Attributes">
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 10.0\PreEmptive Solutions\Dotfuscator Community Edition\PreEmptive.Attributes.dll</HintPath>
......@@ -58,6 +61,11 @@
<Compile Include="PcapDotNetAnalysis.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\PcapDotNet\src\PcapDotNet.snk">
<Link>PcapDotNet.snk</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
......
......@@ -47,7 +47,6 @@ namespace PcapDotNet.Analysis
[PreEmptive.Attributes.Teardown]
private static void ProcessExit(object sender, EventArgs e)
{
Console.WriteLine("ProcessExit");
}
public static bool OptIn { get; set; }
......
......@@ -57,6 +57,10 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="PcapDotNet.Analysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\3rdParty\PcapDotNet\PcapDotNet.Analysis.dll</HintPath>
</Reference>
<Reference Include="PcapDotNet.Base, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58cf32d85728e684, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\3rdParty\PcapDotNet\PcapDotNet.Base.dll</HintPath>
......
using System;
using System.Collections.Generic;
using PcapDotNet.Core;
using PcapDotNet.Packets;
namespace ObtainingTheDeviceList
{
......@@ -8,6 +9,9 @@ namespace ObtainingTheDeviceList
{
static void Main(string[] args)
{
PcapDotNet.Analysis.PcapDotNetAnalysis.OptIn = true;
PcapDotNet.Analysis.PcapDotNetAnalysis.Initialize();
// Retrieve the device list from the local machine
IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;
......
......@@ -12,6 +12,9 @@ namespace UsingLinq
{
static void Main(string[] args)
{
PcapDotNet.Analysis.PcapDotNetAnalysis.OptIn = true;
PcapDotNet.Analysis.PcapDotNetAnalysis.Initialize();
// Retrieve the device list from the local machine
IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;
......
......@@ -57,6 +57,9 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="PcapDotNet.Analysis">
<HintPath>..\..\3rdParty\PcapDotNet\PcapDotNet.Analysis.dll</HintPath>
</Reference>
<Reference Include="PcapDotNet.Base, Version=0.2.0.18201, Culture=neutral, PublicKeyToken=58cf32d85728e684, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\3rdParty\PcapDotNet\PcapDotNet.Base.dll</HintPath>
......
......@@ -250,6 +250,7 @@ void PacketCommunicator::SendPacket(Packet^ packet)
pin_ptr<Byte> unamangedPacketBytes = &packet->Buffer[0];
if (pcap_sendpacket(_pcapDescriptor, unamangedPacketBytes, packet->Length) != 0)
throw BuildInvalidOperation("Failed writing to device");
PcapDotNet::Analysis::PcapDotNetAnalysis::PacketSent();
}
BerkeleyPacketFilter^ PacketCommunicator::CreateFilter(String^ filterValue)
......@@ -326,6 +327,7 @@ InvalidOperationException^ PacketCommunicator::BuildInvalidOperation(System::Str
// static
Packet^ PacketCommunicator::CreatePacket(const pcap_pkthdr& packetHeader, const unsigned char* packetData, IDataLink^ dataLink)
{
PcapDotNet::Analysis::PcapDotNetAnalysis::PacketReceived();
DateTime timestamp;
PacketTimestamp::PcapTimestampToDateTime(packetHeader.ts, timestamp);
......
......@@ -12,6 +12,11 @@ PacketSendBuffer::PacketSendBuffer(unsigned int capacity)
_pcapSendQueue = pcap_sendqueue_alloc(capacity);
}
int PacketSendBuffer::Length::get()
{
return _length;
}
void PacketSendBuffer::Enqueue(Packet^ packet)
{
if (packet == nullptr)
......@@ -22,6 +27,8 @@ void PacketSendBuffer::Enqueue(Packet^ packet)
pin_ptr<Byte> unmanagedPacketBytes = &packet->Buffer[0];
if (pcap_sendqueue_queue(_pcapSendQueue, &pcapHeader, unmanagedPacketBytes) != 0)
throw gcnew InvalidOperationException("Failed enqueueing to queue");
++_length;
}
PacketSendBuffer::~PacketSendBuffer()
......@@ -34,4 +41,6 @@ void PacketSendBuffer::Transmit(pcap_t* pcapDescriptor, bool isSync)
unsigned int numBytesTransmitted = pcap_sendqueue_transmit(pcapDescriptor, _pcapSendQueue, isSync);
if (numBytesTransmitted < _pcapSendQueue->len)
throw PcapError::BuildInvalidOperation("Failed transmiting packets from queue", pcapDescriptor);
PcapDotNet::Analysis::PcapDotNetAnalysis::PacketSent(Length);
}
......@@ -17,6 +17,11 @@ namespace PcapDotNet { namespace Core
/// <param name="capacity">The size, in bytes, of the buffer, therefore it determines the maximum amount of data that the buffer will contain.</param>
PacketSendBuffer(unsigned int capacity);
property int Length
{
int get();
}
/// <summary>
/// Adds a raw packet at the end of the send buffer.
/// 'Raw packet' means that the sending application will have to include the protocol headers, since every packet is sent to the network 'as is'. The CRC of the packets needs not to be calculated, because it will be transparently added by the network interface.
......@@ -35,5 +40,6 @@ namespace PcapDotNet { namespace Core
private:
pcap_send_queue *_pcapSendQueue;
int _length;
};
}}
\ No newline at end of file
......@@ -22,6 +22,9 @@
<CodeAnalysisDictionary Include="..\PcapDotNet.CodeAnalysisDictionary.xml" />
</ItemGroup>
<ItemGroup>
<Reference Include="PcapDotNet.Analysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4b6f3e583145a652">
<HintPath>..\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll</HintPath>
</Reference>
<Reference Include="System">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
......@@ -225,6 +228,9 @@
<PostBuildEvent>
<Command>sn -Ra "$(TargetPath)" "$(SolutionDir)$(SolutionName).snk"</Command>
</PostBuildEvent>
<PreLinkEvent>
<Command>sn -Ra "$(SolutionDir)\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll" "$(SolutionDir)$(SolutionName).snk"</Command>
</PreLinkEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PreBuildEvent>
......@@ -261,6 +267,9 @@
<PostBuildEvent>
<Command>sn -Ra "$(TargetPath)" "$(SolutionDir)$(SolutionName).snk"</Command>
</PostBuildEvent>
<PreLinkEvent>
<Command>sn -Ra "$(SolutionDir)\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll" "$(SolutionDir)$(SolutionName).snk"</Command>
</PreLinkEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
......@@ -292,6 +301,9 @@
<PostBuildEvent>
<Command>sn -Ra "$(TargetPath)" "$(SolutionDir)$(SolutionName).snk"</Command>
</PostBuildEvent>
<PreLinkEvent>
<Command>sn -Ra "$(SolutionDir)\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll" "$(SolutionDir)$(SolutionName).snk"</Command>
</PreLinkEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PreBuildEvent>
......@@ -326,6 +338,9 @@
<PostBuildEvent>
<Command>sn -Ra "$(TargetPath)" "$(SolutionDir)$(SolutionName).snk"</Command>
</PostBuildEvent>
<PreLinkEvent>
<Command>sn -Ra "$(SolutionDir)\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll" "$(SolutionDir)$(SolutionName).snk"</Command>
</PreLinkEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
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