Encapsulates a TCP packet, including the IP header. More...
#include <DwmIpv4TcpPacket.hh>


Public Member Functions | |
| Ipv4TcpPacket () | |
| Constructor. | |
| Ipv4TcpPacket (uint8_t *ptr) | |
| Construct from a pointer to the start of IP header in a TCP packet. More... | |
| ~Ipv4TcpPacket () | |
| Destructor. If we own the underlying data, we free it. | |
| const Ipv4PacketHeader & | IpHeader () const |
| Returns a const reference to the IP header. | |
| Ipv4PacketHeader & | IpHeader () |
| Returns a mutable reference to the IP header. | |
| const Ipv4TcpHeader & | TcpHeader () const |
| Returns a const refernece to the TCP header. | |
| Ipv4TcpHeader & | TcpHeader () |
| Returns a mutable reference to the TCP header. | |
| std::string | Payload () const |
| Returns the payload as a string. | |
| template<typename T > | |
| bool | GetPayload (T &payload) const |
Copies the packet payload into payload. More... | |
| template<typename T > | |
| bool | SetPayload (const T &payload) |
Sets the packet payload to payload. More... | |
| std::istream & | Read (std::istream &is) |
| Reads from an istream. Returns the istream. | |
| std::ostream & | Write (std::ostream &os) const |
| Writes to an ostream. Returns the ostream. | |
| ssize_t | Read (int fd) |
| Reads from a file descriptor. More... | |
| ssize_t | Write (int fd) const |
| Writes to a file descriptor. More... | |
| size_t | Read (FILE *f) |
Reads the packet from the given FILE pointer f. More... | |
| size_t | Write (FILE *f) const |
Writes the packet to the given FILE pointer f. More... | |
| int | Read (gzFile gzf) |
Reads the packet from the given gzFile gzf. More... | |
| int | Write (gzFile gzf) const |
Writes the packet to the given gzFile gzf. More... | |
| int | BZRead (BZFILE *bzf) |
Reads the packet from the given BZFILE bzf. More... | |
| int | BZWrite (BZFILE *bzf) const |
Writes the packet to the given BZFILE bzf. More... | |
| uint32_t | StreamedLength () const |
| Returns the numbers of bytes that should be written if one of the Write() members is called. More... | |
| bool | SendTo (int fd) const |
Sends the packet via the given descriptor fd. More... | |
| bool | SendTo (Socket &s) const |
Sends the packet via the given Socket s. More... | |
Public Member Functions inherited from Dwm::Readable | |
| virtual | ~Readable () |
| destructor | |
Public Member Functions inherited from Dwm::Writable | |
| virtual | ~Writable () |
| Destructor. | |
Public Member Functions inherited from Dwm::GZReadable | |
| virtual | ~GZReadable () |
| destructor | |
Public Member Functions inherited from Dwm::GZWritable | |
| virtual | ~GZWritable () |
| destructor | |
Encapsulates a TCP packet, including the IP header.
| Dwm::Ipv4TcpPacket::Ipv4TcpPacket | ( | uint8_t * | ptr | ) |
Construct from a pointer to the start of IP header in a TCP packet.
We don't copy, so the caller still owns the memory at ptr.
|
virtual |
Reads the packet from the given BZFILE bzf.
Returns the number of bytes read on success, -1 on failure.
Implements Dwm::BZ2Readable.
|
virtual |
Writes the packet to the given BZFILE bzf.
Returns the number of bytes written on success, -1 on failure.
Implements Dwm::BZ2Writable.
|
inline |
Copies the packet payload into payload.
Note that payload must be natively supported by Dwm::IO or a type derived from DWm::Readable. Returns true on success, false on failure.

|
virtual |
Reads from a file descriptor.
Returns the number of bytes read on success, -1 on failure.
Implements Dwm::Readable.
|
virtual |
Reads the packet from the given FILE pointer f.
Returns 1 on success, 0 on failure (fread() semantics).
Implements Dwm::Readable.
|
virtual |
Reads the packet from the given gzFile gzf.
Returns the number of bytes read on success, -1 on failure.
Implements Dwm::GZReadable.
| bool Dwm::Ipv4TcpPacket::SendTo | ( | int | fd | ) | const |
Sends the packet via the given descriptor fd.
Returns true on success, false on failure.
| bool Dwm::Ipv4TcpPacket::SendTo | ( | Socket & | s | ) | const |
Sends the packet via the given Socket s.
Returns true on success, false on failure.
|
inline |
Sets the packet payload to payload.
Note that payload must be natively supported by Dwm::IO or a type derived from Dwm::Writable. Returns true on success, false on failure.

|
virtual |
Returns the numbers of bytes that should be written if one of the Write() members is called.
Implements Dwm::Writable.
|
virtual |
Writes to a file descriptor.
Returns the number of bytes written on success, -1 on failure.
Implements Dwm::Writable.
|
virtual |
Writes the packet to the given FILE pointer f.
Returns 1 on success, 0 on failure (fwrite() semantics).
Implements Dwm::Writable.
|
virtual |
Writes the packet to the given gzFile gzf.
Returns the number of bytes written on success, -1 on failure.
Implements Dwm::GZWritable.