ddn.lib.pcap.types

Foundational types, constants, and utilities for the libpcap D binding.

This module defines basic types used throughout the library and provides cross-platform helpers and string conversion utilities.

Authors

Dejan Lekić

License

BSD-3-Clause

Types 19

aliasbpf_int32 = int

BPF 32-bit signed integer.

aliasbpf_u_int32 = uint

BPF 32-bit unsigned integer.

aliasu_int = uint

Equivalent to C unsigned int.

aliasu_short = ushort

Equivalent to C unsigned short.

aliasu_char = ubyte

Equivalent to C unsigned char.

structpcap_pkthdr

Generic per-packet information, as supplied by libpcap.

Fields
timeval ts
bpf_u_int32 caplen
bpf_u_int32 len
structpcap_stat

Statistics as returned by pcap_stats().

Fields
u_int ps_recv
u_int ps_drop
u_int ps_ifdrop
structpcap_if

Item in a list of interfaces.

Fields
pcap_if * next
char * name
char * description
pcap_addr * addresses
bpf_u_int32 flags
aliaspcap_if_t = pcap_if

ditto

structpcap_addr

Representation of an interface address.

Fields
pcap_addr * next
sockaddr * addr
sockaddr * netmask
sockaddr * broadaddr
sockaddr * dstaddr
aliaspcap_addr_t = pcap_addr

ditto

structpcap_file_header

Header of a pcap savefile.

Fields
bpf_u_int32 magic
u_short version_major
u_short version_minor
bpf_int32 thiszone
bpf_u_int32 sigfigs
bpf_u_int32 snaplen
bpf_u_int32 linktype
structbpf_insn

BPF instruction.

Fields
u_short code
u_char jt
u_char jf
bpf_u_int32 k
structbpf_program

BPF program.

Fields
u_int bf_len
bpf_insn * bf_insns
structpcap_etherent

Ethernet entry.

Fields
u_char[6] addr
char[122] name
structpcap_rmtauth

Remote authentication methods.

Fields
int type
char * username
char * password
structpcap_samp

Sampling methods.

Fields
int method
int value
structpcap_send_queue

Windows-specific: Send queue for pcap_sendqueue_transmit.

Fields
u_int maxlen
u_int len
char * buffer
enumPcapMode : int

Windows-specific: Capture modes for pcap_setmode.

CAPT = 0Capture mode.
STAT = 1Statistical mode.
MON = 2Monitor mode.

Functions 3

fnstring fromCString(const(char) * cstr) pure nothrowConverts a null-terminated C string to a D string (copying the data).
fnconst(char) * toCString(string s) pure nothrowConverts a D string to a null-terminated C string.
fnconst(char) * toOwnedCString(string s) nothrowConverts a D string to a null-terminated C string backed by owned GC memory.

Variables 6

enumvarPCAP_ERRBUF_SIZE = 256

Size of the buffer used by libpcap for error messages.

enumvarPCAP_BUF_SIZE = 1024

The maximum buffer size in which address, port, interface names are kept.

enumvarPCAP_NETMASK_UNKNOWN = 0xffffffff

Value used to indicate an unknown netmask.

enumvarIS_WINDOWS = { version (Windows) return true; else return false; }()

Platform identification constants.

enumvarIS_POSIX = { version (Posix) return true; else return false; }()

ditto

enumvarIS_LINUX = { version (linux) return true; else return false; }()

ditto