TSDuck v3.40-4161
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
Networking

Networking features. More...

Collaboration diagram for Networking:

Files

file  tsIP.h
 Include the multiple and messy system headers for IP networking.
 
file  tsIPProtocols.h
 Definitions of protocols for IP networking.
 
file  tsIPUtils.h
 Utilities for IP networking.
 

Classes

class  ts::AbstractNetworkAddress
 Abstract base class for all network address and socket address classes. More...
 
class  ts::tlv::Connection< SAFETY >
 TCP connection using TLV messages. More...
 
class  ts::IPAddress
 A generic representation of an IP address, IPv4 or IPv6. More...
 
class  ts::IPAddressMask
 A combination of IP address and network mask or prefix. More...
 
class  ts::IPPacket
 Representation of a raw IPv4 or IPv6 packet. More...
 
class  ts::IPSocketAddress
 Generic socket address class (IPv4 or IPv6 address & port). More...
 
class  ts::MACAddress
 A basic representation of a MAC address. More...
 
class  ts::NetworkInterface
 Description of a network interface. More...
 
class  ts::PcapFile
 Read a pcap or pcapng capture file format. More...
 
class  ts::PcapFilter
 Read a pcap or pcapng file with packet filtering. More...
 
class  ts::PcapStream
 Read a TCP/IP session from a pcap or pcapng file. More...
 
class  ts::Socket
 Base class for TCP and UDP sockets. More...
 
class  ts::SRTSocket
 Secure Reliable Transport (SRT) Socket. More...
 
class  ts::TCPConnection
 Base class for a TCP/IP session. More...
 
class  ts::TCPServer
 Implementation of a TCP/IP server. More...
 
class  ts::TCPSocket
 Base class for TCP/IP sockets. More...
 
class  ts::TelnetConnection
 Implementation of a half-duplex line oriented telnet connection. More...
 
class  ts::UDPReceiver
 UDP datagram receiver with common command line options. More...
 
class  ts::UDPReceiverArgs
 Command line arguments for the class UDPReceiver. More...
 
class  ts::UDPReceiverArgsList
 Command line arguments for the class UDPReceiver. More...
 
class  ts::UDPSocket
 UDP Socket. More...
 
class  ts::URL
 Representation of a Uniform Resource Locator (URL). More...
 
class  ts::VLANId
 A structure which describes a VLAN identification. More...
 
class  ts::VLANIdStack
 A stack of VLAN identifiers, from outer to inner VLAN. More...
 
class  ts::WebRequest
 Perform a simple Web request (HTTP, HTTPS, FTP). More...
 
class  ts::WebRequestArgs
 Command line arguments for the class WebRequest. More...
 

Typedefs

using ts::rtp_units = cn::duration< std::intmax_t, std::ratio< 1, RTP_RATE_MP2T > >
 Definition of a number of RTP clock units as a std::chrono::duration type.
 
using ts::SysRecvBufferPointer = platform_specific
 Pointer type for the address of the data buffer for a recv() system call.
 
using ts::SysSendBufferPointer = platform_specific
 Pointer type for the address of the data buffer for a send() system call.
 
using ts::SysSendSizeType = platform_specific
 Integer type for the size of the data buffer for a send() system call.
 
using ts::SysSocketLengthType = platform_specific
 Integer data type which receives the length of a struct sockaddr.
 
using ts::SysSocketLingerType = platform_specific
 Integer data type for the field l_linger in the struct linger socket option.
 
using ts::SysSocketMulticastLoopType = platform_specific
 Integer data type for the IPv4 multicast loop socket option.
 
using ts::SysSocketMulticastLoopType6 = platform_specific
 Integer data type for the IPv6 multicast loop socket option.
 
using ts::SysSocketMulticastTTLType = platform_specific
 Integer data type for the multicast Time To Live (TTL) socket option.
 
using ts::SysSocketPktInfoType = platform_specific
 Integer data type for the IP_PKTINFO socket option.
 
using ts::SysSocketSignedSizeType = platform_specific
 Integer data type for a "signed size" returned from send() or recv() system calls.
 
using ts::SysSocketTClassType = platform_specific
 Integer data type for the Traffic Class (TCLASS) IPv6 socket option.
 
using ts::SysSocketTOSType = platform_specific
 Integer data type for the Type Of Service (TOS) IPv4 socket option.
 
using ts::SysSocketTTLType = platform_specific
 Integer data type for the Time To Live (TTL) socket option.
 
using ts::SysSocketType = platform_specific
 Data type for socket descriptors as returned by the socket() system call.
 
using ts::SysSocketV6OnlyType = platform_specific
 Integer data type for the IPV6_V6ONLY socket option.
 
using ts::SysSockOptPointer = platform_specific
 Pointer type for the address of a socket option value.
 

Enumerations

enum class  ts::IP : uint8_t {
  ts::IP::Any = 0 ,
  ts::IP::v4 = 4 ,
  ts::IP::v6 = 6
}
 Generation of IP networks as an enum class. More...
 
enum  ts::PcapBsdProtocols : uint32_t {
  ts::PCAPNG_BSD_IPv4 = 2 ,
  ts::PCAPNG_BSD_IPv6_24 = 24 ,
  ts::PCAPNG_BSD_IPv6_28 = 28 ,
  ts::PCAPNG_BSD_IPv6_30 = 30 ,
  ts::PCAPNG_BSD_OSI = 7 ,
  ts::PCAPNG_BSD_IPX = 23 ,
  ts::PCAPNG_BSD_UNKNOWN = 0xFFFF
}
 Protocol types for LINKTYPE_NULL and LINKTYPE_LOOP (BSD loopback encapsulation). More...
 
enum  ts::PcapLinkType : uint16_t {
  ts::LINKTYPE_NULL = 0 ,
  ts::LINKTYPE_ETHERNET = 1 ,
  ts::LINKTYPE_AX25 = 3 ,
  ts::LINKTYPE_IEEE802_5 = 6 ,
  ts::LINKTYPE_ARCNET_BSD = 7 ,
  ts::LINKTYPE_SLIP = 8 ,
  ts::LINKTYPE_PPP = 9 ,
  ts::LINKTYPE_FDDI = 10 ,
  ts::LINKTYPE_PPP_HDLC = 50 ,
  ts::LINKTYPE_PPP_ETHER = 51 ,
  ts::LINKTYPE_ATM_RFC1483 = 100 ,
  ts::LINKTYPE_RAW = 101 ,
  ts::LINKTYPE_C_HDLC = 104 ,
  ts::LINKTYPE_IEEE802_11 = 105 ,
  ts::LINKTYPE_FRELAY = 107 ,
  ts::LINKTYPE_LOOP = 108 ,
  ts::LINKTYPE_LINUX_SLL = 113 ,
  ts::LINKTYPE_LTALK = 114 ,
  ts::LINKTYPE_PFLOG = 117 ,
  ts::LINKTYPE_IEEE802_11_PRISM = 119 ,
  ts::LINKTYPE_IP_OVER_FC = 122 ,
  ts::LINKTYPE_SUNATM = 123 ,
  ts::LINKTYPE_IEEE802_11_RADIOTAP = 127 ,
  ts::LINKTYPE_ARCNET_LINUX = 129 ,
  ts::LINKTYPE_APPLE_IP_OVER_IEEE1394 = 138 ,
  ts::LINKTYPE_MTP2_WITH_PHDR = 139 ,
  ts::LINKTYPE_MTP2 = 140 ,
  ts::LINKTYPE_MTP3 = 141 ,
  ts::LINKTYPE_SCCP = 142 ,
  ts::LINKTYPE_DOCSIS = 143 ,
  ts::LINKTYPE_LINUX_IRDA = 144 ,
  ts::LINKTYPE_USER0 = 147 ,
  ts::LINKTYPE_USER15 = 162 ,
  ts::LINKTYPE_IEEE802_11_AVS = 163 ,
  ts::LINKTYPE_BACNET_MS_TP = 165 ,
  ts::LINKTYPE_PPP_PPPD = 166 ,
  ts::LINKTYPE_GPRS_LLC = 169 ,
  ts::LINKTYPE_GPF_T = 170 ,
  ts::LINKTYPE_GPF_F = 171 ,
  ts::LINKTYPE_LINUX_LAPD = 177 ,
  ts::LINKTYPE_MFR = 182 ,
  ts::LINKTYPE_BLUETOOTH_HCI_H4 = 187 ,
  ts::LINKTYPE_USB_LINUX = 189 ,
  ts::LINKTYPE_PPI = 192 ,
  ts::LINKTYPE_IEEE802_15_4_WITHFCS = 195 ,
  ts::LINKTYPE_SITA = 196 ,
  ts::LINKTYPE_ERF = 197 ,
  ts::LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR = 201 ,
  ts::LINKTYPE_AX25_KISS = 202 ,
  ts::LINKTYPE_LAPD = 203 ,
  ts::LINKTYPE_PPP_WITH_DIR = 204 ,
  ts::LINKTYPE_C_HDLC_WITH_DIR = 205 ,
  ts::LINKTYPE_FRELAY_WITH_DIR = 206 ,
  ts::LINKTYPE_LAPB_WITH_DIR = 207 ,
  ts::LINKTYPE_IPMB_LINUX = 209 ,
  ts::LINKTYPE_FLEXRAY = 210 ,
  ts::LINKTYPE_IEEE802_15_4_NONASK_PHY = 215 ,
  ts::LINKTYPE_USB_LINUX_MMAPPED = 220 ,
  ts::LINKTYPE_FC_2 = 224 ,
  ts::LINKTYPE_FC_2_WITH_FRAME_DELIMS = 225 ,
  ts::LINKTYPE_IPNET = 226 ,
  ts::LINKTYPE_CAN_SOCKETCAN = 227 ,
  ts::LINKTYPE_IPV4 = 228 ,
  ts::LINKTYPE_IPV6 = 229 ,
  ts::LINKTYPE_IEEE802_15_4_NOFCS = 230 ,
  ts::LINKTYPE_DBUS = 231 ,
  ts::LINKTYPE_DVB_CI = 235 ,
  ts::LINKTYPE_MUX27010 = 236 ,
  ts::LINKTYPE_STANAG_5066_D_PDU = 237 ,
  ts::LINKTYPE_NFLOG = 239 ,
  ts::LINKTYPE_NETANALYZER = 240 ,
  ts::LINKTYPE_NETANALYZER_TRANSPARENT = 241 ,
  ts::LINKTYPE_IPOIB = 242 ,
  ts::LINKTYPE_MPEG_2_TS = 243 ,
  ts::LINKTYPE_NG40 = 244 ,
  ts::LINKTYPE_NFC_LLCP = 245 ,
  ts::LINKTYPE_INFINIBAND = 247 ,
  ts::LINKTYPE_SCTP = 248 ,
  ts::LINKTYPE_USBPCAP = 249 ,
  ts::LINKTYPE_RTAC_SERIAL = 250 ,
  ts::LINKTYPE_BLUETOOTH_LE_LL = 251 ,
  ts::LINKTYPE_NETLINK = 253 ,
  ts::LINKTYPE_BLUETOOTH_LINUX_MONITOR = 254 ,
  ts::LINKTYPE_BLUETOOTH_BREDR_BB = 255 ,
  ts::LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR = 256 ,
  ts::LINKTYPE_PROFIBUS_DL = 257 ,
  ts::LINKTYPE_PKTAP = 258 ,
  ts::LINKTYPE_EPON = 259 ,
  ts::LINKTYPE_IPMI_HPM_2 = 260 ,
  ts::LINKTYPE_ZWAVE_R1_R2 = 261 ,
  ts::LINKTYPE_ZWAVE_R3 = 262 ,
  ts::LINKTYPE_WATTSTOPPER_DLM = 263 ,
  ts::LINKTYPE_ISO_14443 = 264 ,
  ts::LINKTYPE_RDS = 265 ,
  ts::LINKTYPE_USB_DARWIN = 266 ,
  ts::LINKTYPE_SDLC = 268 ,
  ts::LINKTYPE_LORATAP = 270 ,
  ts::LINKTYPE_VSOCK = 271 ,
  ts::LINKTYPE_NORDIC_BLE = 272 ,
  ts::LINKTYPE_DOCSIS31_XRA31 = 273 ,
  ts::LINKTYPE_ETHERNET_MPACKET = 274 ,
  ts::LINKTYPE_DISPLAYPORT_AUX = 275 ,
  ts::LINKTYPE_LINUX_SLL2 = 276 ,
  ts::LINKTYPE_OPENVIZSLA = 278 ,
  ts::LINKTYPE_EBHSCR = 279 ,
  ts::LINKTYPE_VPP_DISPATCH = 280 ,
  ts::LINKTYPE_DSA_TAG_BRCM = 281 ,
  ts::LINKTYPE_DSA_TAG_BRCM_PREPEND = 282 ,
  ts::LINKTYPE_IEEE802_15_4_TAP = 283 ,
  ts::LINKTYPE_DSA_TAG_DSA = 284 ,
  ts::LINKTYPE_DSA_TAG_EDSA = 285 ,
  ts::LINKTYPE_ELEE = 286 ,
  ts::LINKTYPE_Z_WAVE_SERIAL = 287 ,
  ts::LINKTYPE_USB_2_0 = 288 ,
  ts::LINKTYPE_ATSC_ALP = 289 ,
  ts::LINKTYPE_ETW = 290 ,
  ts::LINKTYPE_UNKNOWN = 0xFFFF
}
 List of pcap LINKTYPE values. More...
 
enum  ts::PcapNgBlockType : uint32_t {
  ts::PCAPNG_SECTION_HEADER = PCAPNG_MAGIC ,
  ts::PCAPNG_INTERFACE_DESC = 0x00000001 ,
  ts::PCAPNG_OBSOLETE_PACKET = 0x00000002 ,
  ts::PCAPNG_SIMPLE_PACKET = 0x00000003 ,
  ts::PCAPNG_NAME_RES = 0x00000004 ,
  ts::PCAPNG_INTERFACE_STAT = 0x00000005 ,
  ts::PCAPNG_ENHANCED_PACKET = 0x00000006 ,
  ts::PCAPNG_SYSTEMD_JOURNAL = 0x00000009 ,
  ts::PCAPNG_DECRYPT_SECRETS = 0x0000000A ,
  ts::PCAPNG_CUSTOM = 0x00000BAD ,
  ts::PCAPNG_CUSTOM_NOCOPY = 0x40000BAD
}
 List of pcap-ng block types. More...
 
enum  ts::PcapNgOptionCode : uint32_t {
  ts::PCAPNG_OPT_ENDOFOPT = 0 ,
  ts::PCAPNG_OPT_COMMENT = 1 ,
  ts::PCAPNG_SHB_HARDWARE = 2 ,
  ts::PCAPNG_SHB_OS = 3 ,
  ts::PCAPNG_SHB_USERAPPL = 4 ,
  ts::PCAPNG_IF_NAME = 2 ,
  ts::PCAPNG_IF_DESCRIPTION = 3 ,
  ts::PCAPNG_IF_IPV4ADDR = 4 ,
  ts::PCAPNG_IF_IPV6ADDR = 5 ,
  ts::PCAPNG_IF_MACADDR = 6 ,
  ts::PCAPNG_IF_EUIADDR = 7 ,
  ts::PCAPNG_IF_SPEED = 8 ,
  ts::PCAPNG_IF_TSRESOL = 9 ,
  ts::PCAPNG_IF_TZONE = 10 ,
  ts::PCAPNG_IF_FILTER = 11 ,
  ts::PCAPNG_IF_OS = 12 ,
  ts::PCAPNG_IF_FCSLEN = 13 ,
  ts::PCAPNG_IF_TSOFFSET = 14 ,
  ts::PCAPNG_IF_HARDWARE = 15 ,
  ts::PCAPNG_IF_TXSPEED = 16 ,
  ts::PCAPNG_IF_RXSPEED = 17
}
 List of pcap-ng option codes. More...
 

Functions

const std::error_category & ts::getaddrinfo_category ()
 Get the std::error_category for getaddrinfo() error code (Unix only).
 
bool ts::IPInitialize (Report &=(ts::CerrReport::Instance()))
 Initialize the IP libraries in the current process.
 
UString ts::IPProtocolName (uint8_t protocol, bool long_format=false)
 Get the name of an IP protocol (UDP, TCP, etc).
 
int ts::SysCloseSocket (SysSocketType sock)
 The close() system call which applies to socket devices.
 
bool ts::TCPOrderedSequence (uint32_t seq1, uint32_t seq2)
 Check if two TCP sequence numbers are ordered, including wrapping back at 0xFFFFFFFF.
 
uint32_t ts::TCPSequenceDiff (uint32_t seq1, uint32_t seq2)
 Compute the difference between two TCP sequence numbers, including wrapping back at 0xFFFFFFFF.
 

Variables

constexpr int ts::SYS_SOCKET_ERR_NOTCONN = platform_specific
 System error code value meaning "peer socket not connected".
 
constexpr int ts::SYS_SOCKET_ERR_RESET = platform_specific
 System error code value meaning "connection reset by peer".
 
constexpr SysSocketType ts::SYS_SOCKET_INVALID = platform_specific
 Value of type SysSocketType which is returned by the socket() system call in case of failure.
 
constexpr int ts::SYS_SOCKET_SHUT_RD = platform_specific
 Name of the option for the shutdown() system call which means "close on receive side".
 
constexpr int ts::SYS_SOCKET_SHUT_RDWR = platform_specific
 Name of the option for the shutdown() system call which means "close on both directions".
 
constexpr int ts::SYS_SOCKET_SHUT_WR = platform_specific
 Name of the option for the shutdown() system call which means "close on send side".
 

Detailed Description

Networking features.

Typedef Documentation

◆ SysSocketLengthType

using ts::SysSocketLengthType = typedef platform_specific

Integer data type which receives the length of a struct sockaddr.

Example:

struct sockaddr sock_addr;
SysSocketLengthType len = sizeof(sock_addr);
if (getsockname(sock, &sock_addr, &len) != 0) {
... error processing ...
}
platform_specific SysSocketLengthType
Integer data type which receives the length of a struct sockaddr.
Definition tsIPUtils.h:112

◆ SysSocketSignedSizeType

using ts::SysSocketSignedSizeType = typedef platform_specific

Integer data type for a "signed size" returned from send() or recv() system calls.

Example:

SysSocketSignedSizeType got = recv(sock, SysRecvBufferPointer(&data), max_size, 0);
platform_specific SysSocketSignedSizeType
Integer data type for a "signed size" returned from send() or recv() system calls.
Definition tsIPUtils.h:128
platform_specific SysRecvBufferPointer
Pointer type for the address of the data buffer for a recv() system call.
Definition tsIPUtils.h:314

◆ SysSocketTTLType

using ts::SysSocketTTLType = typedef platform_specific

Integer data type for the Time To Live (TTL) socket option.

Example:

if (setsockopt(sock, IPPROTO_IP, IP_TTL, SysSockOptPointer(&ttl), sizeof(ttl)) != 0) {
... error processing ...
}
platform_specific SysSocketTTLType
Integer data type for the Time To Live (TTL) socket option.
Definition tsIPUtils.h:147
platform_specific SysSockOptPointer
Pointer type for the address of a socket option value.
Definition tsIPUtils.h:297

◆ SysSocketMulticastTTLType

using ts::SysSocketMulticastTTLType = typedef platform_specific

Integer data type for the multicast Time To Live (TTL) socket option.

Example:

if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, SysSockOptPointer(&mttl), sizeof(mttl)) != 0) {
... error processing ...
}
platform_specific SysSocketMulticastTTLType
Integer data type for the multicast Time To Live (TTL) socket option.
Definition tsIPUtils.h:166

◆ SysSocketMulticastLoopType

using ts::SysSocketMulticastLoopType = typedef platform_specific

Integer data type for the IPv4 multicast loop socket option.

Example:

if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_LOOP, SysSockOptPointer(&mloop), sizeof(mloop)) != 0) {
... error processing ...
}
platform_specific SysSocketMulticastLoopType
Integer data type for the IPv4 multicast loop socket option.
Definition tsIPUtils.h:221

◆ SysSocketMulticastLoopType6

using ts::SysSocketMulticastLoopType6 = typedef platform_specific

Integer data type for the IPv6 multicast loop socket option.

Example:

if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, SysSockOptPointer(&mloop), sizeof(mloop)) != 0) {
... error processing ...
}
platform_specific SysSocketMulticastLoopType6
Integer data type for the IPv6 multicast loop socket option.
Definition tsIPUtils.h:240

◆ SysSocketPktInfoType

using ts::SysSocketPktInfoType = typedef platform_specific

Integer data type for the IP_PKTINFO socket option.

Example:

if (setsockopt(sock, IPPROTO_IP, IP_PKTINFO, SysSockOptPointer(&state), sizeof(state)) != 0) {
... error processing ...
}
platform_specific SysSocketPktInfoType
Integer data type for the IP_PKTINFO socket option.
Definition tsIPUtils.h:259

◆ SysSocketLingerType

using ts::SysSocketLingerType = typedef platform_specific

Integer data type for the field l_linger in the struct linger socket option.

All systems do not use the same type size and this may generate some warnings. Example:

struct linger lin;
lin.l_linger = SysSocketLingerType(seconds);
platform_specific SysSocketLingerType
Integer data type for the field l_linger in the struct linger socket option.
Definition tsIPUtils.h:277

◆ SysSockOptPointer

using ts::SysSockOptPointer = typedef platform_specific

Pointer type for the address of a socket option value.

The "standard" parameter type is void* but some systems use other exotic values. Example:

if (setsockopt(sock, IPPROTO_IP, IP_TTL, SysSockOptPointer(&ttl), sizeof(ttl)) != 0) {
... error processing ...
}

◆ SysRecvBufferPointer

using ts::SysRecvBufferPointer = typedef platform_specific

Pointer type for the address of the data buffer for a recv() system call.

The "standard" parameter type is void* but some systems use other exotic values. Example:

SysSocketSignedSizeType got = recv(sock, SysRecvBufferPointer(&data), max_size, 0);

◆ SysSendBufferPointer

using ts::SysSendBufferPointer = typedef platform_specific

Pointer type for the address of the data buffer for a send() system call.

The "standard" parameter type is void* but some systems use other exotic values. Example:

SysSocketSignedSizeType gone = send(sock, SysSendBufferPointer(&data), SysSendSizeType(size), 0);
platform_specific SysSendSizeType
Integer type for the size of the data buffer for a send() system call.
Definition tsIPUtils.h:343
platform_specific SysSendBufferPointer
Pointer type for the address of the data buffer for a send() system call.
Definition tsIPUtils.h:331

Enumeration Type Documentation

◆ IP

enum class ts::IP : uint8_t
strong

Generation of IP networks as an enum class.

Converting to an integer returns the actual generation number (4 or 6).

Enumerator
Any 

Any generation of IP networks.

v4 

IPv4.

v6 

IPv6.

◆ PcapNgBlockType

enum ts::PcapNgBlockType : uint32_t

List of pcap-ng block types.

Enumerator
PCAPNG_SECTION_HEADER 

Section header block.

PCAPNG_INTERFACE_DESC 

Interface description block.

PCAPNG_OBSOLETE_PACKET 

Obsolete packet block.

PCAPNG_SIMPLE_PACKET 

Enhanced packet block.

PCAPNG_NAME_RES 

Name resolution block.

PCAPNG_INTERFACE_STAT 

Interface statistics block.

PCAPNG_ENHANCED_PACKET 

Simple packet block.

PCAPNG_SYSTEMD_JOURNAL 

Systemd journal block.

PCAPNG_DECRYPT_SECRETS 

Decryption secrets block.

PCAPNG_CUSTOM 

Custom block, can be copied.

PCAPNG_CUSTOM_NOCOPY 

Custom block, cannot be copied.

◆ PcapLinkType

enum ts::PcapLinkType : uint16_t

List of pcap LINKTYPE values.

See also
http://www.tcpdump.org/linktypes.html
Enumerator
LINKTYPE_NULL 

BSD loopback encapsulation.

LINKTYPE_ETHERNET 

IEEE 802.3 Ethernet (10Mb, 100Mb, 1000Mb, and up).

LINKTYPE_AX25 

AX.25 packet, with nothing preceding it.

LINKTYPE_IEEE802_5 

IEEE 802.5 Token Ring.

LINKTYPE_ARCNET_BSD 

ARCNET Data Packets, as described by 878.1-1999.

LINKTYPE_SLIP 

SLIP, encapsulated with a LINKTYPE_SLIP header.

LINKTYPE_PPP 

PPP, as per RFC 1661 and RFC 1662.

LINKTYPE_FDDI 

FDDI, as specified by ANSI INCITS 239-1994.

LINKTYPE_PPP_HDLC 

PPP in HDLC-like framing, as per RFC 1662, or Cisco PPP with HDLC framing.

LINKTYPE_PPP_ETHER 

PPPoE; the packet begins with a PPPoE header, as per RFC 2516.

LINKTYPE_ATM_RFC1483 

RFC 1483 LLC/SNAP-encapsulated ATM.

LINKTYPE_RAW 

Raw IP; the packet begins with an IPv4 or IPv6 header.

LINKTYPE_C_HDLC 

Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547.

LINKTYPE_IEEE802_11 

IEEE 802.11 wireless LAN.

LINKTYPE_FRELAY 

Frame Relay LAPF frames.

LINKTYPE_LOOP 

OpenBSD loopback encapsulation.

LINKTYPE_LINUX_SLL 

Linux "cooked" capture encapsulation.

LINKTYPE_LTALK 

Apple LocalTalk.

LINKTYPE_PFLOG 

OpenBSD pflog.

LINKTYPE_IEEE802_11_PRISM 

Prism monitor mode information followed by an 802.11 header.

LINKTYPE_IP_OVER_FC 

RFC 2625 IP-over-Fibre Channel.

LINKTYPE_SUNATM 

ATM traffic, encapsulated as per the scheme used by SunATM devices.

LINKTYPE_IEEE802_11_RADIOTAP 

Radiotap link-layer information followed by an 802.11 header.

LINKTYPE_ARCNET_LINUX 

ARCNET Data Packets.

LINKTYPE_APPLE_IP_OVER_IEEE1394 

Apple IP-over-IEEE 1394 cooked header.

LINKTYPE_MTP2_WITH_PHDR 

Signaling System 7 Message Transfer Part Level 2, ITU-T Q.703, preceded by a pseudo-header.

LINKTYPE_MTP2 

Signaling System 7 Message Transfer Part Level 2, ITU-T Q.703.

LINKTYPE_MTP3 

Signaling System 7 Message Transfer Part Level 3, ITU-T Q.704.

LINKTYPE_SCCP 

Signaling System 7 Signalling Connection Control Part, ITU-T Q.711.

LINKTYPE_DOCSIS 

DOCSIS MAC frames.

LINKTYPE_LINUX_IRDA 

Linux-IrDA packets.

LINKTYPE_USER0 

Reserved for private use.

LINKTYPE_USER15 

Reserved for private use.

LINKTYPE_IEEE802_11_AVS 

AVS monitor mode information followed by an 802.11 header.

LINKTYPE_BACNET_MS_TP 

BACnet MS/TP frames.

LINKTYPE_PPP_PPPD 

PPP in HDLC-like encapsulation.

LINKTYPE_GPRS_LLC 

General Packet Radio Service Logical Link Control.

LINKTYPE_GPF_T 

Transparent-mapped generic framing procedure, ITU-T G.7041/Y.1303.

LINKTYPE_GPF_F 

Frame-mapped generic framing procedure, ITU-T G.7041/Y.1303.

LINKTYPE_LINUX_LAPD 

Link Access Procedures on the D Channel (LAPD) frames.

LINKTYPE_MFR 

FRF.16.1 Multi-Link Frame Relay frames.

LINKTYPE_BLUETOOTH_HCI_H4 

Bluetooth HCI UART transport layer.

LINKTYPE_USB_LINUX 

USB packets, beginning with a Linux USB header.

LINKTYPE_PPI 

Per-Packet Information information.

LINKTYPE_IEEE802_15_4_WITHFCS 

IEEE 802.15.4 Low-Rate Wireless Networks.

LINKTYPE_SITA 

Various link-layer types, with a pseudo-header, for SITA.

LINKTYPE_ERF 

Various link-layer types, with a pseudo-header, for Endace DAG cards.

LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR 

Bluetooth HCI UART transport layer.

LINKTYPE_AX25_KISS 

AX.25 packet, with a 1-byte KISS header containing a type indicator.

LINKTYPE_LAPD 

Link Access Procedures on the D Channel (LAPD) frames, ITU-T Q.920 and Q.921.

LINKTYPE_PPP_WITH_DIR 

PPP, as per RFC 1661 and RFC 1662.

LINKTYPE_C_HDLC_WITH_DIR 

Cisco PPP with HDLC framing.

LINKTYPE_FRELAY_WITH_DIR 

Frame Relay LAPF frames.

LINKTYPE_LAPB_WITH_DIR 

Link Access Procedure, Balanced (LAPB).

LINKTYPE_IPMB_LINUX 

IPMB over an I2C circuit.

LINKTYPE_FLEXRAY 

FlexRay automotive bus frames.

LINKTYPE_IEEE802_15_4_NONASK_PHY 

IEEE 802.15.4 Low-Rate Wireless Networks.

LINKTYPE_USB_LINUX_MMAPPED 

USB packets, beginning with a Linux USB header.

LINKTYPE_FC_2 

Fibre Channel FC-2 frames, beginning with a Frame_Header.

LINKTYPE_FC_2_WITH_FRAME_DELIMS 

Fibre Channel FC-2 frames.

LINKTYPE_IPNET 

Solaris ipnet pseudo-header.

LINKTYPE_CAN_SOCKETCAN 

CAN (Controller Area Network) frames, with a pseudo-header followed by the frame payload.

LINKTYPE_IPV4 

Raw IPv4; the packet begins with an IPv4 header.

LINKTYPE_IPV6 

Raw IPv6; the packet begins with an IPv6 header.

LINKTYPE_IEEE802_15_4_NOFCS 

IEEE 802.15.4 Low-Rate Wireless Network.

LINKTYPE_DBUS 

Raw D-Bus messages.

LINKTYPE_DVB_CI 

DVB-CI.

LINKTYPE_MUX27010 

Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but not the same as, 27.010).

LINKTYPE_STANAG_5066_D_PDU 

D_PDUs as described by NATO standard STANAG 5066.

LINKTYPE_NFLOG 

Linux netlink NETLINK NFLOG socket log messages.

LINKTYPE_NETANALYZER 

Pseudo-header for Hilscher Gesellschaft für Systemautomation mbH netANALYZER devices.

LINKTYPE_NETANALYZER_TRANSPARENT 

Pseudo-header for Hilscher Gesellschaft für Systemautomation mbH netANALYZER devices.

LINKTYPE_IPOIB 

IP-over-InfiniBand.

LINKTYPE_MPEG_2_TS 

MPEG-2 Transport Stream transport packets, ISO 13818-1.

LINKTYPE_NG40 

Pseudo-header for ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format.

LINKTYPE_NFC_LLCP 

Pseudo-header for NFC LLCP packet captures.

LINKTYPE_INFINIBAND 

Raw InfiniBand frames.

LINKTYPE_SCTP 

SCTP packets, RFC 4960.

LINKTYPE_USBPCAP 

USB packets, beginning with a USBPcap header.

LINKTYPE_RTAC_SERIAL 

Serial-line packet header for the Schweitzer Engineering Laboratories "RTAC" product.

LINKTYPE_BLUETOOTH_LE_LL 

Bluetooth Low Energy air interface Link Layer packets.

LINKTYPE_NETLINK 

Linux Netlink capture encapsulation.

LINKTYPE_BLUETOOTH_LINUX_MONITOR 

Bluetooth Linux Monitor encapsulation of traffic for the BlueZ stack.

LINKTYPE_BLUETOOTH_BREDR_BB 

Bluetooth Basic Rate and Enhanced Data Rate baseband packets.

LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR 

Bluetooth Low Energy link-layer packets.

LINKTYPE_PROFIBUS_DL 

PROFIBUS data link layer packets.

LINKTYPE_PKTAP 

Apple PKTAP capture encapsulation.

LINKTYPE_EPON 

Ethernet-over-passive-optical-network packets.

LINKTYPE_IPMI_HPM_2 

IPMI trace packets.

LINKTYPE_ZWAVE_R1_R2 

Z-Wave RF profile R1 and R2 packets.

LINKTYPE_ZWAVE_R3 

Z-Wave RF profile R3 packets.

LINKTYPE_WATTSTOPPER_DLM 

Formats for WattStopper Digital Lighting Management (DLM).

LINKTYPE_ISO_14443 

Messages between ISO 14443 contactless smartcards.

LINKTYPE_RDS 

Radio data system (RDS) groups, IEC 62106.

LINKTYPE_USB_DARWIN 

USB packets, beginning with a Darwin (macOS, etc.) USB header.

LINKTYPE_SDLC 

SDLC packets.

LINKTYPE_LORATAP 

LoRaTap pseudo-header, followed by the payload.

LINKTYPE_VSOCK 

Protocol host/guest in VMware and KVM hypervisors.

LINKTYPE_NORDIC_BLE 

Messages to and from a Nordic Semiconductor nRF Sniffer for Bluetooth LE packets.

LINKTYPE_DOCSIS31_XRA31 

DOCSIS packets and bursts.

LINKTYPE_ETHERNET_MPACKET 

mPackets, as specified by IEEE 802.3br Figure 99-4.

LINKTYPE_DISPLAYPORT_AUX 

DisplayPort AUX channel monitoring.

LINKTYPE_LINUX_SLL2 

Linux "cooked" capture encapsulation v2.

LINKTYPE_OPENVIZSLA 

Openvizsla FPGA-based USB sniffer.

LINKTYPE_EBHSCR 

Elektrobit High Speed Capture and Replay (EBHSCR) format.

LINKTYPE_VPP_DISPATCH 

Records in traces from the http://!<fd.io VPP graph dispatch tracer.

LINKTYPE_DSA_TAG_BRCM 

Ethernet frames, with a switch tag.

LINKTYPE_DSA_TAG_BRCM_PREPEND 

Ethernet frames, with a switch tag.

LINKTYPE_IEEE802_15_4_TAP 

IEEE 802.15.4 Low-Rate Wireless Networks.

LINKTYPE_DSA_TAG_DSA 

Ethernet frames, with a switch tag.

LINKTYPE_DSA_TAG_EDSA 

Ethernet frames, with a programmable Ethernet type switch tag.

LINKTYPE_ELEE 

Payload of lawful intercept packets using the ELEE protocol.

LINKTYPE_Z_WAVE_SERIAL 

Serial between host and Z-Wave chip over an RS-232 or USB serial connection.

LINKTYPE_USB_2_0 

USB 2.0, 1.1, or 1.0 packet.

LINKTYPE_ATSC_ALP 

ATSC Link-Layer Protocol frames.

LINKTYPE_ETW 

Event Tracing for Windows messages.

LINKTYPE_UNKNOWN 

Placeholder for unknown link type.

◆ PcapBsdProtocols

enum ts::PcapBsdProtocols : uint32_t

Protocol types for LINKTYPE_NULL and LINKTYPE_LOOP (BSD loopback encapsulation).

See also
https://www.tcpdump.org/linktypes/LINKTYPE_NULL.html
https://www.tcpdump.org/linktypes/LINKTYPE_LOOP.html
Enumerator
PCAPNG_BSD_IPv4 

Payload is an IPv4 packet.

PCAPNG_BSD_IPv6_24 

Payload is an IPv6 packet.

PCAPNG_BSD_IPv6_28 

Payload is an IPv6 packet.

PCAPNG_BSD_IPv6_30 

Payload is an IPv6 packet.

PCAPNG_BSD_OSI 

Payload is an OSI packet.

PCAPNG_BSD_IPX 

Payload is an IPX packet.

PCAPNG_BSD_UNKNOWN 

Placeholder for unknown payload type.

◆ PcapNgOptionCode

enum ts::PcapNgOptionCode : uint32_t

List of pcap-ng option codes.

Enumerator
PCAPNG_OPT_ENDOFOPT 

End of option list.

PCAPNG_OPT_COMMENT 

Comment.

PCAPNG_SHB_HARDWARE 

System hardware.

PCAPNG_SHB_OS 

System operating system.

PCAPNG_SHB_USERAPPL 

User application.

PCAPNG_IF_NAME 

Interface name.

PCAPNG_IF_DESCRIPTION 

Interface description.

PCAPNG_IF_IPV4ADDR 

Interface IPv4 address.

PCAPNG_IF_IPV6ADDR 

Interface IPv6 address.

PCAPNG_IF_MACADDR 

Interface MAC address.

PCAPNG_IF_EUIADDR 

Interface EUI address.

PCAPNG_IF_SPEED 

Interface speed in b/s.

PCAPNG_IF_TSRESOL 

Time resolution.

PCAPNG_IF_TZONE 

Time zone.

PCAPNG_IF_FILTER 

Canpture filter.

PCAPNG_IF_OS 

Interface operating system.

PCAPNG_IF_FCSLEN 

Frame Check Sequence length.

PCAPNG_IF_TSOFFSET 

Timestamps offset.

PCAPNG_IF_HARDWARE 

Interface hardware.

PCAPNG_IF_TXSPEED 

Interface transmission speed.

PCAPNG_IF_RXSPEED 

Interface reception speed.

Function Documentation

◆ IPProtocolName()

UString ts::IPProtocolName ( uint8_t  protocol,
bool  long_format = false 
)

Get the name of an IP protocol (UDP, TCP, etc).

Parameters
[in]protocolProtocol identifier, as set in IP header.
[in]long_formatIf false (the default), return a simple acronym. When true, return a full description string.
Returns
The protocol name with optional description.

◆ TCPOrderedSequence()

bool ts::TCPOrderedSequence ( uint32_t  seq1,
uint32_t  seq2 
)

Check if two TCP sequence numbers are ordered, including wrapping back at 0xFFFFFFFF.

Parameters
[in]seq1First TCP sequence number.
[in]seq2Second TCP sequence number.
Returns
True if seq1 strictly logically preceeds seq2.

◆ TCPSequenceDiff()

uint32_t ts::TCPSequenceDiff ( uint32_t  seq1,
uint32_t  seq2 
)

Compute the difference between two TCP sequence numbers, including wrapping back at 0xFFFFFFFF.

Parameters
[in]seq1First TCP sequence number.
[in]seq2Second TCP sequence number which must logically follow seq1.
Returns
The difference between seq1 and seq2.

◆ IPInitialize()

bool ts::IPInitialize ( Report = (ts::CerrReport::Instance()))

Initialize the IP libraries in the current process.

On some systems (UNIX), there is no need to initialize IP. On other systems (Windows), using IP and socket without initialization fails. This method is a portable way to ensure that IP is properly initialized. It shall be called at least once before using IP in the application.

Returns
True on success, false on error.

◆ getaddrinfo_category()

const std::error_category & ts::getaddrinfo_category ( )

Get the std::error_category for getaddrinfo() error code (Unix only).

Returns
A constant reference to a std::error_category instance.

◆ SysCloseSocket()

int ts::SysCloseSocket ( SysSocketType  sock)
inline

The close() system call which applies to socket devices.

The "standard" name is close but some systems use other exotic names.

Parameters
[in]sockSystem socket descriptor.
Returns
Error code.

Variable Documentation

◆ SYS_SOCKET_INVALID

constexpr SysSocketType ts::SYS_SOCKET_INVALID = platform_specific
constexpr

Value of type SysSocketType which is returned by the socket() system call in case of failure.

Example:

SysSocketType sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock == SYS_SOCKET_INVALID) {
... error processing ...
}
constexpr SysSocketType SYS_SOCKET_INVALID
Value of type SysSocketType which is returned by the socket() system call in case of failure.
Definition tsIPUtils.h:68
platform_specific SysSocketType
Data type for socket descriptors as returned by the socket() system call.
Definition tsIPUtils.h:49

◆ SYS_SOCKET_SHUT_RDWR

constexpr int ts::SYS_SOCKET_SHUT_RDWR = platform_specific
constexpr

Name of the option for the shutdown() system call which means "close on both directions".

Example:

shutdown(sock, SYS_SOCKET_SHUT_RDWR);
constexpr int SYS_SOCKET_SHUT_RDWR
Name of the option for the shutdown() system call which means "close on both directions".
Definition tsIPUtils.h:359

◆ SYS_SOCKET_SHUT_RD

constexpr int ts::SYS_SOCKET_SHUT_RD = platform_specific
constexpr

Name of the option for the shutdown() system call which means "close on receive side".

Example:

shutdown(sock, SYS_SOCKET_SHUT_RD);
constexpr int SYS_SOCKET_SHUT_RD
Name of the option for the shutdown() system call which means "close on receive side".
Definition tsIPUtils.h:375

◆ SYS_SOCKET_SHUT_WR

constexpr int ts::SYS_SOCKET_SHUT_WR = platform_specific
constexpr

Name of the option for the shutdown() system call which means "close on send side".

Example:

shutdown(sock, SYS_SOCKET_SHUT_WR);
constexpr int SYS_SOCKET_SHUT_WR
Name of the option for the shutdown() system call which means "close on send side".
Definition tsIPUtils.h:391