TSDuck v3.40-4058
MPEG Transport Stream Toolkit
|
Representation of a raw IPv4 or IPv6 packet. More...
#include <tsIPPacket.h>
Public Types | |
using | Port = AbstractNetworkAddress::Port |
The concept of port is used by TCP and UDP. | |
Public Member Functions | |
IPPacket ()=default | |
Default constructor. | |
IPPacket (const void *data, size_t size) | |
Constructor from raw content. | |
void | clear () |
Clear the packet content. | |
const uint8_t * | data () const |
Get the address of the IP packet content. | |
const IPSocketAddress & | destination () const |
Get the destination IP socket address. | |
bool | fragmented () const |
Check if the IP packet is fragmented. | |
IP | generation () const |
Get the current generation of IP addresses. | |
const uint8_t * | ipHeader () const |
Get the address of the IP header. | |
size_t | ipHeaderSize () const |
Get the size in bytes of the IP header. | |
bool | isTCP () const |
Check if the packet is a valid TCP packet. | |
bool | isUDP () const |
Check if the packet is a valid UDP packet. | |
bool | isValid () const |
Check if the IPv4 packet is valid. | |
uint8_t | protocol () const |
Get the sub-protocol type (TCP, UDP, etc). | |
const uint8_t * | protocolData () const |
Get the address of the sub-protocol payload data (TCP data, UDP data, etc). | |
size_t | protocolDataSize () const |
Get the size in bytes of the sub-protocol payload data (TCP data, UDP data, etc). | |
const uint8_t * | protocolHeader () const |
Get the address of the sub-protocol header (TCP header, UDP header, etc). | |
size_t | protocolHeaderSize () const |
Get the size in bytes of the sub-protocol header (TCP header, UDP header, etc). | |
bool | reset (const void *data, size_t size) |
Reinitialize the IP4 packet with new content. | |
size_t | size () const |
Get the size in bytes of the IP packet content. | |
const IPSocketAddress & | source () const |
Get the source IP socket address. | |
bool | tcpACK () const |
Get the TCP ACK flag in the packet. | |
bool | tcpFIN () const |
Get the TCP FIN flag in the packet. | |
bool | tcpRST () const |
Get the TCP RST flag in the packet. | |
uint32_t | tcpSequenceNumber () const |
Get the TCP sequence number in the packet. | |
bool | tcpSYN () const |
Get the TCP SYN flag in the packet. | |
Static Public Member Functions | |
static uint16_t | IPHeaderChecksum (const void *data, size_t size) |
Compute the checksum of an IPv4 header from raw data. | |
static size_t | IPHeaderSize (const void *data, size_t size, uint8_t *protocol=nullptr) |
Get the size in bytes of an IP header from raw data. | |
static bool | UpdateIPHeaderChecksum (void *data, size_t size) |
Update the checksum of an IPv4 header as raw data. | |
static bool | VerifyIPHeaderChecksum (const void *data, size_t size) |
Verify the checksum of an IPv4 header from raw data. | |
Representation of a raw IPv4 or IPv6 packet.
ts::IPPacket::IPPacket | ( | const void * | data, |
size_t | size | ||
) |
Constructor from raw content.
[in] | data | Address of the IP packet data. |
[in] | size | Size of the IP packet data. |
bool ts::IPPacket::reset | ( | const void * | data, |
size_t | size | ||
) |
Reinitialize the IP4 packet with new content.
[in] | data | Address of the IP packet data. |
[in] | size | Size of the IP packet data. |
|
inline |
Check if the IPv4 packet is valid.
|
inline |
Get the current generation of IP addresses.
|
inline |
Get the sub-protocol type (TCP, UDP, etc).
|
inline |
Check if the packet is a valid TCP packet.
|
inline |
Check if the packet is a valid UDP packet.
|
inline |
Get the address of the IP packet content.
|
inline |
Get the size in bytes of the IP packet content.
|
inline |
Get the address of the IP header.
|
inline |
Get the size in bytes of the IP header.
|
inline |
Get the address of the sub-protocol header (TCP header, UDP header, etc).
|
inline |
Get the size in bytes of the sub-protocol header (TCP header, UDP header, etc).
|
inline |
Get the address of the sub-protocol payload data (TCP data, UDP data, etc).
|
inline |
Get the size in bytes of the sub-protocol payload data (TCP data, UDP data, etc).
bool ts::IPPacket::fragmented | ( | ) | const |
Check if the IP packet is fragmented.
|
inline |
Get the source IP socket address.
|
inline |
Get the destination IP socket address.
uint32_t ts::IPPacket::tcpSequenceNumber | ( | ) | const |
Get the TCP sequence number in the packet.
bool ts::IPPacket::tcpSYN | ( | ) | const |
Get the TCP SYN flag in the packet.
bool ts::IPPacket::tcpACK | ( | ) | const |
Get the TCP ACK flag in the packet.
bool ts::IPPacket::tcpFIN | ( | ) | const |
Get the TCP FIN flag in the packet.
|
static |
Get the size in bytes of an IP header from raw data.
[in] | data | Address of the IP packet. |
[in] | size | Size of the IP packet or header (must be larger than the header size). |
[out] | protocol | If not null, receives the type of the next protocol layer (TCP, UDP, etc). |
|
static |
Compute the checksum of an IPv4 header from raw data.
The concept of header checksum is specific to IPv4. IPv6 headers do not have checksums.
[in] | data | Address of the IP packet. |
[in] | size | Size of the IP packet or header (must be larger than the header size). |
|
static |
Verify the checksum of an IPv4 header from raw data.
[in] | data | Address of the IP packet. |
[in] | size | Size of the IP packet or header (must be larger than the header size). |
|
static |
Update the checksum of an IPv4 header as raw data.
[in,out] | data | Address of the IP packet. |
[in] | size | Size of the IP packet or header (must be larger than the header size). |