Commit 4239204c authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 6a6df7e5
...@@ -2,6 +2,11 @@ namespace Packets ...@@ -2,6 +2,11 @@ namespace Packets
{ {
public class Datagram public class Datagram
{ {
public Datagram(byte[] buffer)
: this(buffer, 0, buffer.Length)
{
}
public Datagram(byte[] buffer, int offset, int length) public Datagram(byte[] buffer, int offset, int length)
{ {
_buffer = buffer; _buffer = buffer;
......
...@@ -18,7 +18,7 @@ namespace Packets ...@@ -18,7 +18,7 @@ namespace Packets
public const int EtherTypeLength = 12; public const int EtherTypeLength = 12;
} }
internal const int HeaderLength = 14; public const int HeaderLength = 14;
public EthernetDatagram(byte[] buffer, int offset, int length) public EthernetDatagram(byte[] buffer, int offset, int length)
: base(buffer, offset, length) : base(buffer, offset, length)
......
...@@ -154,7 +154,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::GetPacket([Out] Packet^% pac ...@@ -154,7 +154,7 @@ PacketCommunicatorReceiveResult PacketCommunicator::GetPacket([Out] Packet^% pac
return result; return result;
} }
PacketCommunicatorReceiveResult PacketCommunicator::GetSomePackets(int maxPackets, HandlePacket^ callBack, [Out] int% numPacketsGot) PacketCommunicatorReceiveResult PacketCommunicator::GetSomePackets([Out] int% numPacketsGot, int maxPackets, HandlePacket^ callBack)
{ {
AssertMode(PacketCommunicatorMode::Capture); AssertMode(PacketCommunicatorMode::Capture);
...@@ -209,6 +209,22 @@ PacketCommunicatorReceiveResult PacketCommunicator::GetNextStatistics([Out] Pack ...@@ -209,6 +209,22 @@ PacketCommunicatorReceiveResult PacketCommunicator::GetNextStatistics([Out] Pack
return result; return result;
} }
PacketCommunicatorReceiveResult PacketCommunicator::GetStatistics(int numStatistics, HandleStatistics^ callBack)
{
AssertMode(PacketCommunicatorMode::Statistics);
StatisticsHandler^ statisticsHandler = gcnew StatisticsHandler(callBack);
HandlerDelegate^ statisticsHandlerDelegate = gcnew HandlerDelegate(statisticsHandler, &StatisticsHandler::Handle);
pcap_handler functionPointer = (pcap_handler)Marshal::GetFunctionPointerForDelegate(statisticsHandlerDelegate).ToPointer();
int result = pcap_loop(_pcapDescriptor, numStatistics, functionPointer, NULL);
if (result == -1)
throw BuildInvalidOperation("Failed reading from device");
if (result == -2)
return PacketCommunicatorReceiveResult::BreakLoop;
return PacketCommunicatorReceiveResult::Ok;
}
void PacketCommunicator::SendPacket(Packet^ packet) void PacketCommunicator::SendPacket(Packet^ packet)
{ {
pin_ptr<Byte> unamangedPacketBytes; pin_ptr<Byte> unamangedPacketBytes;
......
...@@ -84,11 +84,12 @@ namespace PcapDotNet { namespace Core ...@@ -84,11 +84,12 @@ namespace PcapDotNet { namespace Core
delegate void HandlePacket(Packets::Packet^ packet); delegate void HandlePacket(Packets::Packet^ packet);
PacketCommunicatorReceiveResult GetPacket([System::Runtime::InteropServices::Out] Packets::Packet^% packet); PacketCommunicatorReceiveResult GetPacket([System::Runtime::InteropServices::Out] Packets::Packet^% packet);
PacketCommunicatorReceiveResult GetSomePackets(int maxPackets, HandlePacket^ callBack, [System::Runtime::InteropServices::Out] int% numPacketsGot); PacketCommunicatorReceiveResult GetSomePackets([System::Runtime::InteropServices::Out] int% numPacketsGot, int maxPackets, HandlePacket^ callBack);
PacketCommunicatorReceiveResult GetPackets(int numPackets, HandlePacket^ callBack); PacketCommunicatorReceiveResult GetPackets(int numPackets, HandlePacket^ callBack);
delegate void HandleStatistics(PacketSampleStatistics^ statistics); delegate void HandleStatistics(PacketSampleStatistics^ statistics);
PacketCommunicatorReceiveResult GetNextStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics); PacketCommunicatorReceiveResult GetNextStatistics([System::Runtime::InteropServices::Out] PacketSampleStatistics^% statistics);
PacketCommunicatorReceiveResult GetStatistics(int numStatistics, HandleStatistics^ callBack);
void SendPacket(Packets::Packet^ packet); void SendPacket(Packets::Packet^ packet);
void Transmit(PacketSendQueue^ sendQueue, bool isSync); void Transmit(PacketSendQueue^ sendQueue, bool isSync);
......
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