Commit 3ea1b949 authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 16159dcc
...@@ -42,10 +42,26 @@ DeviceHandlerMode PcapDeviceHandler::Mode::get() ...@@ -42,10 +42,26 @@ DeviceHandlerMode PcapDeviceHandler::Mode::get()
void PcapDeviceHandler::Mode::set(DeviceHandlerMode value) void PcapDeviceHandler::Mode::set(DeviceHandlerMode value)
{ {
if (pcap_setmode(_pcapDescriptor, safe_cast<int>(value)) < 0) if (pcap_setmode(_pcapDescriptor, safe_cast<int>(value)) < 0)
throw gcnew InvalidOperationException("Error setting the mode."); throw BuildInvalidOperation("Error setting mode " + value.ToString());
_mode = value; _mode = value;
} }
bool PcapDeviceHandler::NonBlocking::get()
{
char errbuf[PCAP_ERRBUF_SIZE];
int nonBlockValue = pcap_getnonblock(_pcapDescriptor, errbuf);
if (nonBlockValue == -1)
throw gcnew InvalidOperationException("Error getting NonBlocking value");
return nonBlockValue != 0;
}
void PcapDeviceHandler::NonBlocking::set(bool value)
{
char errbuf[PCAP_ERRBUF_SIZE];
if (pcap_setnonblock(_pcapDescriptor, value, errbuf) != 0)
throw gcnew InvalidOperationException("Error setting NonBlocking to " + value.ToString());
}
DeviceHandlerResult PcapDeviceHandler::GetNextPacket([Out] Packet^% packet) DeviceHandlerResult PcapDeviceHandler::GetNextPacket([Out] Packet^% packet)
{ {
AssertMode(DeviceHandlerMode::Capture); AssertMode(DeviceHandlerMode::Capture);
......
...@@ -36,6 +36,12 @@ namespace PcapDotNet ...@@ -36,6 +36,12 @@ namespace PcapDotNet
void set(DeviceHandlerMode value); void set(DeviceHandlerMode value);
} }
property bool NonBlocking
{
bool get();
void set(bool value);
}
delegate void HandlePacket(BPacket::Packet^ packet); delegate void HandlePacket(BPacket::Packet^ packet);
DeviceHandlerResult GetNextPacket([System::Runtime::InteropServices::Out] BPacket::Packet^% packet); DeviceHandlerResult GetNextPacket([System::Runtime::InteropServices::Out] BPacket::Packet^% packet);
DeviceHandlerResult GetNextPackets(int maxPackets, HandlePacket^ callBack, [System::Runtime::InteropServices::Out] int% numPacketsGot); DeviceHandlerResult GetNextPackets(int maxPackets, HandlePacket^ callBack, [System::Runtime::InteropServices::Out] int% numPacketsGot);
......
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