Encapsulates a TCP payload. More...
#include <DwmIpv4TcpPayload.hh>


Public Member Functions | |
| Ipv4TcpPayload () | |
| Constructor. | |
| Ipv4TcpPayload (const Ipv4PacketHeader &ipHeader, const Ipv4TcpHeader &tcpHeader) | |
| Construct based on an Ipv4PacketHeader and Ipv4TcpHeader that point into a TCP packet, which may have a payload following the TCP header. More... | |
| Ipv4TcpPayload (uint8_t *buf, uint16_t len) | |
| Construct based on a pointer that points to the first byte of the payload in a TCP packet. More... | |
| Ipv4TcpPayload (const std::string &s) | |
| Copy the given string into the payload. | |
| ~Ipv4TcpPayload () | |
| Destructor. | |
| std::pair< uint16_t, const uint8_t * > | Payload () const |
| Returns a shallow copy of the payload. | |
| std::string | ToString () const |
| Returns the payload as a string. | |
| uint32_t | Sum () const |
| Returns the IP sum of the payload, which can be used as part of TCP checksum computation. More... | |
| template<typename T > | |
| bool | GetPayload (T &payload) const |
Copies the payload into payload. More... | |
| template<typename T > | |
| bool | SetPayload (const T &payload) |
Sets the payload to payload. More... | |
| void | Clear () |
| Clears the payload. | |
| std::istream & | Read (std::istream &is, uint16_t len) |
Reads len bytes of the payload from the given istream is. | |
| std::ostream & | Write (std::ostream &os) const |
Writes the payload to the given ostream os. | |
| ssize_t | Read (int fd, uint16_t len) |
Reads len bytes of the payload from the given descriptor fd. More... | |
| ssize_t | Write (int fd) const |
Writes the payload to the given descriptor fd. More... | |
| size_t | Read (FILE *f, uint16_t len) |
Reads len bytes of the payload from the given FILE f. More... | |
| size_t | Write (FILE *f) const |
Writes the payload to the given FILE f. More... | |
| int | Read (gzFile gzf, uint16_t len) |
Reads len bytes of the payload from the given gzFile gzf. More... | |
| int | Write (gzFile gzf) const |
Writes the payload to the given gzFile gzf. More... | |
| int | BZRead (BZFILE *bzf, uint16_t len) |
Reads len bytes of the payload from the given BZFILE bzf. More... | |
| int | BZWrite (BZFILE *bzf) const |
Writes the payload to the given BZFILE bzf. More... | |
| uint32_t | StreamedLength () const |
| Returns the number of bytes that would be written if we called one of the Write() members. More... | |
Public Member Functions inherited from Dwm::Writable | |
| virtual | ~Writable () |
| Destructor. | |
Public Member Functions inherited from Dwm::GZWritable | |
| virtual | ~GZWritable () |
| destructor | |
Encapsulates a TCP payload.
| Dwm::Ipv4TcpPayload::Ipv4TcpPayload | ( | const Ipv4PacketHeader & | ipHeader, |
| const Ipv4TcpHeader & | tcpHeader | ||
| ) |
Construct based on an Ipv4PacketHeader and Ipv4TcpHeader that point into a TCP packet, which may have a payload following the TCP header.
The underlying memory will not be copied, we'll just point to it. Hence the caller should not free the underlying memory while the Ipv4TcpPayload is still in use.
| Dwm::Ipv4TcpPayload::Ipv4TcpPayload | ( | uint8_t * | buf, |
| uint16_t | len | ||
| ) |
Construct based on a pointer that points to the first byte of the payload in a TCP packet.
The underlying memory will not be copied, we'll just point to it. Hence the caller should not free the underlying memory while the Ipv4TcpPayload is still in use.
| int Dwm::Ipv4TcpPayload::BZRead | ( | BZFILE * | bzf, |
| uint16_t | len | ||
| ) |
Reads len bytes of the payload from the given BZFILE bzf.
Returns the number of bytes read on success, -1 on failure.
|
virtual |
Writes the payload to the given BZFILE bzf.
Returns the number of bytes written on success, -1 on failure.
Implements Dwm::BZ2Writable.
|
inline |
Copies the payload into payload.
Returns true on success, false on failure. Note that payload must be a type natively supported by Dwm::IO or a type derived from Dwm::Readable.

| ssize_t Dwm::Ipv4TcpPayload::Read | ( | int | fd, |
| uint16_t | len | ||
| ) |
Reads len bytes of the payload from the given descriptor fd.
Returns the number of bytes read on success, -1 on failure.
| size_t Dwm::Ipv4TcpPayload::Read | ( | FILE * | f, |
| uint16_t | len | ||
| ) |
Reads len bytes of the payload from the given FILE f.
Returns 1 on success, 0 on failure (fread() semantics).
| int Dwm::Ipv4TcpPayload::Read | ( | gzFile | gzf, |
| uint16_t | len | ||
| ) |
Reads len bytes of the payload from the given gzFile gzf.
Returns the number of bytes read on success, -1 on failure.
|
inline |
Sets the payload to payload.
Returns true on success, false on failure. Note that payload must be a type natively supported by Dwm::IO or a type derived from Dwm::Writable.

|
virtual |
Returns the number of bytes that would be written if we called one of the Write() members.
Implements Dwm::Writable.
| uint32_t Dwm::Ipv4TcpPayload::Sum | ( | ) | const |
Returns the IP sum of the payload, which can be used as part of TCP checksum computation.
|
virtual |
Writes the payload to the given descriptor fd.
Returns the number of bytes written on success, -1 on failure.
Implements Dwm::Writable.
|
virtual |
Writes the payload to the given FILE f.
Returns 1 on success, 0 on failure (fread() semantics).
Implements Dwm::Writable.
|
virtual |
Writes the payload to the given gzFile gzf.
Returns the number of bytes written on success, -1 on failure.
Implements Dwm::GZWritable.