TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Representation of a raw IPv4 packet. More...
#include <tsIPv4Packet.h>
Public Types | |
using | Port = AbstractNetworkAddress::Port |
The concept of port is used by TCP and UDP. | |
Public Member Functions | |
IPv4Packet ()=default | |
Default constructor. | |
IPv4Packet (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 IPv4 packet content. | |
IPv4Address | destinationAddress () const |
Get the destination IPv4 address. | |
Port | destinationPort () const |
Get the TCP or UDP destination port. | |
IPv4SocketAddress | destinationSocketAddress () const |
Get the destination IPv4 socket address. | |
bool | fragmented () const |
Check if the IPv4 packet is fragmented. | |
const uint8_t * | ipHeader () const |
Get the address of the IPv4 header. | |
size_t | ipHeaderSize () const |
Get the size in bytes of the IPv4 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 IPv4 packet with new content. | |
size_t | size () const |
Get the size in bytes of the IPv4 packet content. | |
IPv4Address | sourceAddress () const |
Get the source IPv4 address. | |
Port | sourcePort () const |
Get the TCP or UDP source port. | |
IPv4SocketAddress | sourceSocketAddress () const |
Get the source IPv4 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) |
Get the size in bytes of an IPv4 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 packet.
ts::IPv4Packet::IPv4Packet | ( | 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::IPv4Packet::reset | ( | const void * | data, |
size_t | size | ||
) |
Reinitialize the IPv4 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 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 IPv4 packet content.
|
inline |
Get the size in bytes of the IPv4 packet content.
|
inline |
Get the address of the IPv4 header.
|
inline |
Get the size in bytes of the IPv4 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::IPv4Packet::fragmented | ( | ) | const |
Check if the IPv4 packet is fragmented.
IPv4Address ts::IPv4Packet::sourceAddress | ( | ) | const |
Get the source IPv4 address.
IPv4Address ts::IPv4Packet::destinationAddress | ( | ) | const |
Get the destination IPv4 address.
|
inline |
Get the TCP or UDP source port.
|
inline |
Get the TCP or UDP destination port.
IPv4SocketAddress ts::IPv4Packet::sourceSocketAddress | ( | ) | const |
Get the source IPv4 socket address.
IPv4SocketAddress ts::IPv4Packet::destinationSocketAddress | ( | ) | const |
Get the destination IPv4 socket address.
uint32_t ts::IPv4Packet::tcpSequenceNumber | ( | ) | const |
Get the TCP sequence number in the packet.
bool ts::IPv4Packet::tcpSYN | ( | ) | const |
Get the TCP SYN flag in the packet.
bool ts::IPv4Packet::tcpACK | ( | ) | const |
Get the TCP ACK flag in the packet.
bool ts::IPv4Packet::tcpFIN | ( | ) | const |
Get the TCP FIN flag in the packet.
|
static |
Get the size in bytes 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 |
Compute 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 |
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). |