Commit 22797897 authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 6a6c0fc5
...@@ -79,3 +79,8 @@ PcapDumpFile^ PcapDeviceHandler::OpenDump(System::String^ filename) ...@@ -79,3 +79,8 @@ PcapDumpFile^ PcapDeviceHandler::OpenDump(System::String^ filename)
throw gcnew InvalidOperationException("Error opening output file " + filename + " Error: " + gcnew System::String(pcap_geterr(_handler))); throw gcnew InvalidOperationException("Error opening output file " + filename + " Error: " + gcnew System::String(pcap_geterr(_handler)));
return gcnew PcapDumpFile(dumpFile, filename); return gcnew PcapDumpFile(dumpFile, filename);
} }
pcap_t* PcapDeviceHandler::Handler::get()
{
return _handler;
}
\ No newline at end of file
...@@ -29,6 +29,12 @@ namespace PcapDotNet ...@@ -29,6 +29,12 @@ namespace PcapDotNet
PcapDumpFile^ OpenDump(System::String^ filename); PcapDumpFile^ OpenDump(System::String^ filename);
internal:
property pcap_t* Handler
{
pcap_t* get();
}
private: private:
pcap_t* _handler; pcap_t* _handler;
IpV4SocketAddress^ _ipV4Netmask; IpV4SocketAddress^ _ipV4Netmask;
......
#include "PcapSendQueue.h" #include "PcapSendQueue.h"
#include "PacketHeader.h"
#include "Pcap.h" #include "Pcap.h"
using namespace System;
using namespace PcapDotNet; using namespace PcapDotNet;
using namespace BPacket; using namespace BPacket;
PcapSendQueue::PcapSendQueue(unsigned int size) PcapSendQueue::PcapSendQueue(unsigned int capacity)
{ {
_pcapSendQueue = pcap_sendqueue_alloc(size); _pcapSendQueue = pcap_sendqueue_alloc(capacity);
} }
void PcapSendQueue::Enqueue(Packet^ packet) void PcapSendQueue::Enqueue(Packet^ packet)
{ {
pcap_pkthdr pcapHeader;
PacketHeader::GetPcapHeader(pcapHeader, packet);
pin_ptr<Byte> unamangedPacketBytes = &packet->Buffer[0];
if (pcap_sendqueue_queue(_pcapSendQueue, &pcapHeader, unamangedPacketBytes) == -1)
throw gcnew InvalidOperationException("Failed enqueue packet");
}
//pcap_sendqueue_queue(_pcapSendQueue, void PcapSendQueue::Transmit(PcapDeviceHandler^ deviceHandler, bool isSync)
{
unsigned int numBytesTransmitted = pcap_sendqueue_transmit(deviceHandler->Handler, _pcapSendQueue, isSync);
if (numBytesTransmitted < _pcapSendQueue->len)
{
throw gcnew InvalidOperationException(String::Format("An error occurred sending the packets: %s. Only %d bytes were sent", gcnew String(pcap_geterr(deviceHandler->Handler)), numBytesTransmitted));
}
} }
PcapSendQueue::~PcapSendQueue() PcapSendQueue::~PcapSendQueue()
......
#pragma once #pragma once
#include "PcapDeviceHandler.h"
#include "PcapDeclarations.h" #include "PcapDeclarations.h"
namespace PcapDotNet namespace PcapDotNet
...@@ -7,10 +8,12 @@ namespace PcapDotNet ...@@ -7,10 +8,12 @@ namespace PcapDotNet
public ref class PcapSendQueue : System::IDisposable public ref class PcapSendQueue : System::IDisposable
{ {
public: public:
PcapSendQueue(unsigned int size); PcapSendQueue(unsigned int capacity);
void Enqueue(BPacket::Packet^ packet); void Enqueue(BPacket::Packet^ packet);
void Transmit(PcapDeviceHandler^ deviceHandler, bool isSync);
~PcapSendQueue(); ~PcapSendQueue();
private: private:
......
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