Encapsulates a UDP packet, including the IP header. More...
#include <DwmIpv4UdpPacket.hh>


Public Member Functions | |
| Ipv4UdpPacket () | |
| Constructor. | |
| Ipv4UdpPacket (uint8_t *ptr) | |
| Construct from a pointer to the start of IP header in a UDP packet. More... | |
| ~Ipv4UdpPacket () | |
| 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 Ipv4UdpHeader & | UdpHeader () const |
| Returns a const refernece to the UDP header. | |
| Ipv4UdpHeader & | UdpHeader () |
| Returns a mutable reference to the UDP header. | |
| std::string | Payload () const |
| Returns the payload as a string. | |
| template<typename T > | |
| bool | GetPayload (T &payload) const |
Copies the contained payload into payload. More... | |
| template<typename T > | |
| bool | SetPayload (const T &payload) |
Sets the contained 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) |
| NOT IMPLEMENTED. | |
| ssize_t | Write (int fd) const |
| Writes to a file descriptor. More... | |
| size_t | Read (FILE *f) |
Reads the packet from the given FILE f. More... | |
| size_t | Write (FILE *f) const |
Writes the packet to the given FILE 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 UDP packet, including the IP header.
| Dwm::Ipv4UdpPacket::Ipv4UdpPacket | ( | uint8_t * | ptr | ) |
Construct from a pointer to the start of IP header in a UDP 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 contained payload into payload.
Returns true on success, false on failure. Note that payload must be of a type natively supported by Dwm::IO or derived from Dwm::Readable.

|
virtual |
Reads the packet from the given FILE 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::Ipv4UdpPacket::SendTo | ( | int | fd | ) | const |
Sends the packet via the given descriptor fd.
Returns true on success, false on failure.
| bool Dwm::Ipv4UdpPacket::SendTo | ( | Socket & | s | ) | const |
Sends the packet via the given Socket s.
Returns true on success, false on failure.
|
inline |
Sets the contained payload to payload.
Returns true on success, false on failure. Note that payload must be of a type natively supported by Dwm::IO or derived from Dwm::Writable.

|
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 f.
Returns 1 on success, 0 on failure.
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.