ddn.lib.pcap.device

Device discovery and enumeration for libpcap.

This module provides the PcapIfList RAII wrapper for device enumeration and associated flags and structures.

Authors

Dejan Lekić

License

BSD-3-Clause

Types 4

enumDeviceFlags : uint

Flags for libpcap interfaces.

LOOPBACK = 0x00000001
UP = 0x00000002
RUNNING = 0x00000004
WIRELESS = 0x00000008
CONNECTION_STATUS = 0x00000030
CONNECTION_STATUS_UNKNOWN = 0x00000000
CONNECTION_STATUS_CONNECTED = 0x00000010
CONNECTION_STATUS_DISCONNECTED = 0x00000020
CONNECTION_STATUS_NOT_APPLICABLE = 0x00000030

D representation of an interface address.

This structure wraps the raw pcap_addr_t and provides a more idiomatic way to access address information.

Fields
private pcap_addr_t * _ptr
Methods
const(sockaddr) * addr() const @safe pure nothrow @nogcReturns the raw address.
const(sockaddr) * netmask() const @safe pure nothrow @nogcReturns the netmask.
const(sockaddr) * broadaddr() const @safe pure nothrow @nogcReturns the broadcast address.
const(sockaddr) * dstaddr() const @safe pure nothrow @nogcReturns the destination address.
Constructors
this(pcap_addr_t * ptr)Constructor.

D representation of a network device/interface.

This structure wraps the raw pcap_if_t and provides a more idiomatic way to access device metadata.

Fields
private pcap_if_t * _ptr
Methods
string name() const pure nothrowReturns the device name.
string description() const pure nothrowReturns the device description.
uint flags() const @safe pure nothrow @nogcReturns interface flags.
int opApply(int delegate(ref PcapAddress) dg)Support for iteration over interface addresses.
Constructors
this(pcap_if_t * ptr)Constructor.

RAII wrapper for the list of interfaces returned by pcap_findalldevs.

Fields
private pcap_if_t * _handle
Methods
void free()Frees the interface list. It is safe to call this method multiple times.
pcap_if_t * handle() @safe pure nothrow @nogcReturns the raw head of the interface list.
bool isNull() const @safe pure nothrow @nogcChecks if the list is empty.
int opApply(int delegate(ref PcapInterface) dg)Support for `foreach` iteration over the interface list.
Constructors
this(pcap_if_t * h)Constructor.
Destructors
~thisDestructor frees the interface list.

Functions 2

fnPcapIfList findAllDevs(out string errBuf)Finds all available network devices.
fnstring lookupDev(out string errBuf)Returns the name of a default device to capture on. (Obsolete, use `findAllDevs` instead)