Commit b3ce6e3b authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent e5640be4
...@@ -6,6 +6,40 @@ using namespace System; ...@@ -6,6 +6,40 @@ using namespace System;
using namespace System::Text; using namespace System::Text;
using namespace PcapDotNet::Core; using namespace PcapDotNet::Core;
SocketAddress^ DeviceAddress::Address::get()
{
return _address;
}
SocketAddress^ DeviceAddress::Netmask::get()
{
return _netmask;
}
SocketAddress^ DeviceAddress::Broadcast::get()
{
return _broadcast;
}
SocketAddress^ DeviceAddress::Destination::get()
{
return _destination;
}
String^ DeviceAddress::ToString()
{
StringBuilder^ result = gcnew StringBuilder();
AppendSocketAddressString(result, Address, "Address");
AppendSocketAddressString(result, Netmask, "Netmask");
AppendSocketAddressString(result, Broadcast, "Broadcast");
AppendSocketAddressString(result, Destination, "Destination");
return result->ToString();
}
// Internal
DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress) DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress)
{ {
SocketAddressFamily family = safe_cast<SocketAddressFamily>(pcapAddress->addr->sa_family); SocketAddressFamily family = safe_cast<SocketAddressFamily>(pcapAddress->addr->sa_family);
...@@ -53,37 +87,8 @@ DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress) ...@@ -53,37 +87,8 @@ DeviceAddress::DeviceAddress(pcap_addr_t* pcapAddress)
} }
} }
SocketAddress^ DeviceAddress::Address::get()
{
return _address;
}
SocketAddress^ DeviceAddress::Netmask::get()
{
return _netmask;
}
SocketAddress^ DeviceAddress::Broadcast::get()
{
return _broadcast;
}
SocketAddress^ DeviceAddress::Destination::get() // Private
{
return _destination;
}
String^ DeviceAddress::ToString()
{
StringBuilder^ result = gcnew StringBuilder();
AppendSocketAddressString(result, Address, "Address");
AppendSocketAddressString(result, Netmask, "Netmask");
AppendSocketAddressString(result, Broadcast, "Broadcast");
AppendSocketAddressString(result, Destination, "Destination");
return result->ToString();
}
// static // static
void DeviceAddress::AppendSocketAddressString(StringBuilder^ stringBuilder, SocketAddress^ socketAddress, String^ title) void DeviceAddress::AppendSocketAddressString(StringBuilder^ stringBuilder, SocketAddress^ socketAddress, String^ title)
......
...@@ -5,26 +5,39 @@ ...@@ -5,26 +5,39 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// Representation of an interface address.
/// </summary>
public ref class DeviceAddress public ref class DeviceAddress
{ {
public: public:
DeviceAddress(pcap_addr_t *pcapAddress); /// <summary>
/// The Device Address.
/// </summary>
property SocketAddress^ Address property SocketAddress^ Address
{ {
SocketAddress^ get(); SocketAddress^ get();
} }
/// <summary>
/// if not null, the netmask corresponding to the address in Address.
/// </summary>
property SocketAddress^ Netmask property SocketAddress^ Netmask
{ {
SocketAddress^ get(); SocketAddress^ get();
} }
/// <summary>
/// if not null, the broadcast address corresponding to the address in Address; may be null if the interface doesn't support broadcasts.
/// </summary>
property SocketAddress^ Broadcast property SocketAddress^ Broadcast
{ {
SocketAddress^ get(); SocketAddress^ get();
} }
/// <summary>
/// if not null, the destination address corresponding to the address in Address; may be null if the interface isn't a point-to-point interface
/// </summary>
property SocketAddress^ Destination property SocketAddress^ Destination
{ {
SocketAddress^ get(); SocketAddress^ get();
...@@ -32,6 +45,9 @@ namespace PcapDotNet { namespace Core ...@@ -32,6 +45,9 @@ namespace PcapDotNet { namespace Core
virtual System::String^ ToString() override; virtual System::String^ ToString() override;
internal:
DeviceAddress(pcap_addr_t *pcapAddress);
private: private:
static void AppendSocketAddressString(System::Text::StringBuilder^ stringBuilder, SocketAddress^ socketAddress, System::String^ title); static void AppendSocketAddressString(System::Text::StringBuilder^ stringBuilder, SocketAddress^ socketAddress, System::String^ title);
......
#pragma once
namespace PcapDotNet { namespace Core
{
/// <summary>
/// Attributes of a device.
/// </summary>
[System::Flags]
public enum class DeviceAttributes : System::Int32
{
/// <summary>
/// No attributes apply.
/// </summary>
None = 0x00000000,
/// <summary>
/// Interface is loopback.
/// </summary>
Loopback = 0x00000001
};
}}
\ No newline at end of file
#pragma once #pragma once
#include "DeviceAddress.h" #include "DeviceAddress.h"
#include "DeviceAttributes.h"
#include "PacketCommunicator.h" #include "PacketCommunicator.h"
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
[System::Flags] /// <summary>
public enum class DeviceAttributes : System::Int32 /// Represents an a live or offline interface.
{ /// </summary>
None = 0x00000000,
Loopback = 0x00000001
};
public interface class IPacketDevice public interface class IPacketDevice
{ {
/// <summary>
/// A string giving a name for the device.
/// </summary>
property System::String^ Name { System::String^ get(); }; property System::String^ Name { System::String^ get(); };
/// <summary>
/// if not null, a string giving a human-readable description of the device.
/// </summary>
property System::String^ Description { System::String^ get(); }; property System::String^ Description { System::String^ get(); };
/// <summary>
/// interface flags. Currently the only possible flag is Loopback, that is set if the interface is a loopback interface.
/// </summary>
property DeviceAttributes^ Attributes { DeviceAttributes^ get(); }; property DeviceAttributes^ Attributes { DeviceAttributes^ get(); };
/// <summary>
/// List of addresses for the interface.
/// </summary>
property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses property System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ Addresses
{ {
System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get(); System::Collections::ObjectModel::ReadOnlyCollection<DeviceAddress^>^ get();
...@@ -28,6 +40,7 @@ namespace PcapDotNet { namespace Core ...@@ -28,6 +40,7 @@ namespace PcapDotNet { namespace Core
/// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param> /// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param>
/// <param name="attributes">keeps several flags that can be needed for capturing packets.</param> /// <param name="attributes">keeps several flags that can be needed for capturing packets.</param>
/// <param name="readTimeout">read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</param> /// <param name="readTimeout">read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</param>
/// <exception cref="System::InvalidOperationException">Thrown on failure.</exception>
PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout); PacketCommunicator^ Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout);
/// <summary> /// <summary>
......
...@@ -221,6 +221,10 @@ ...@@ -221,6 +221,10 @@
RelativePath=".\DeviceAddress.h" RelativePath=".\DeviceAddress.h"
> >
</File> </File>
<File
RelativePath=".\DeviceAttributes.h"
>
</File>
<File <File
RelativePath=".\IPacketDevice.h" RelativePath=".\IPacketDevice.h"
> >
......
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