Encapsulates an IPv4 UDP header. More...
#include <DwmIpv4UdpHeader.hh>


Public Member Functions | |
| Ipv4UdpHeader () | |
| Constructor. The new object will own the underlying memory. | |
| Ipv4UdpHeader (const Ipv4PacketHeader &ipHeader) | |
Construct from the given IPv4 packet header ipHeader. | |
| Ipv4UdpHeader (const Ipv4UdpHeader &udpHeader) | |
| Copy constructor. | |
| Ipv4UdpHeader (struct udphdr *udpHdr) | |
| Construct from a pointer to an existing udphdr. More... | |
| Ipv4UdpHeader (const struct udphdr &udpHdr) | |
Constructor. Copies the contents of udpHdr. The new object will. | |
| Ipv4UdpHeader & | operator= (const Ipv4UdpHeader &udpHeader) |
| operator = | |
| ~Ipv4UdpHeader () | |
| Destructor. More... | |
| uint16_t | SourcePort () const |
| Returns the UDP source port in host byte order. | |
| uint16_t | SourcePort (uint16_t port) |
Sets the UDP source port to port, which must be in host byte order. More... | |
| uint16_t | DestinationPort () const |
| Returns the UDP destination port in host byte order. | |
| uint16_t | DestinationPort (uint16_t port) |
Sets the UDP destination port to port, which must be in host byte order. More... | |
| uint16_t | UdpLength () const |
| Returns the UDP length in host byte order. More... | |
| uint16_t | UdpLength (uint16_t udpLength) |
| Sets and returns the UDP length in host byte order. More... | |
| uint16_t | UdpChecksum () const |
| Returns the UDP checksum field. | |
| void | SetUdpChecksum (const Ipv4PacketHeader &ipHeader, const std::string &data) |
Calculates and sets the UDP checksum field, which requires the UDP payload data and some fields from the IP header. More... | |
| void | SetUdpChecksum (const Ipv4PacketHeader &ipHeader, const Ipv4UdpPayload &data) |
Calculates and sets the UDP checksum field, which requires the UDP payload data and some fields from the IP header. More... | |
| uint8_t * | End () const |
| std::istream & | Read (std::istream &is) |
| Reads the UDP header from an istream. Returns the istream. | |
| std::ostream & | Write (std::ostream &os) const |
| Writes the UDP header to an ostream. Returns the ostream. | |
| ssize_t | Read (int fd) |
| Reads the UDP header from a file descriptor. More... | |
| ssize_t | Write (int fd) const |
| Writes the UDP header to a file descriptor. More... | |
| size_t | Read (FILE *f) |
| Reads the UDP header from a FILE. More... | |
| size_t | Write (FILE *f) const |
| Writes the UDP header to a FILE. More... | |
| uint32_t | StreamedLength () const |
| Returns the number of bytes that would be written if we called one of the Write() members. More... | |
| int | Read (gzFile gzf) |
| Reads the UDP header from a gzFile. More... | |
| int | Write (gzFile gzf) const |
| Writes the UDP header to a gzFile. More... | |
| int | BZRead (BZFILE *bzf) |
| Reads the UDP header from a BZFILE. More... | |
| int | BZWrite (BZFILE *bzf) const |
| Writes the UDP header to a BZFILE. More... | |
| bool | operator== (const Ipv4UdpHeader &udpHeader) const |
| operator == | |
| std::ostream & | PrintXML (std::ostream &os, const std::string &pre="") const |
Print the UDP header to an ostream in pseudo-XML, with each line prefixed by pre. 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 an IPv4 UDP header.
| Dwm::Ipv4UdpHeader::Ipv4UdpHeader | ( | struct udphdr * | udpHdr | ) |
Construct from a pointer to an existing udphdr.
We will not copy the contents of udpHdr, it will continue to be owned by the caller. This is useful when the caller wishes to use this class for manipulating an existing udphdr.
| Dwm::Ipv4UdpHeader::~Ipv4UdpHeader | ( | ) |
Destructor.
If the object owns the underlying memory, the underlying memory will be freed.
|
virtual |
Reads the UDP header from a BZFILE.
Returns the number of bytes read on success (should be equal to StreamedLength()), -1 on failure.
Implements Dwm::BZ2Readable.
|
virtual |
Writes the UDP header to a BZFILE.
Returns the number of bytes written on success (should be equal to StreamedLength()), -1 on failure.
Implements Dwm::BZ2Writable.
| uint16_t Dwm::Ipv4UdpHeader::DestinationPort | ( | uint16_t | port | ) |
Sets the UDP destination port to port, which must be in host byte order.
Returns the UDP destination port in host byte order.
| std::ostream& Dwm::Ipv4UdpHeader::PrintXML | ( | std::ostream & | os, |
| const std::string & | pre = "" |
||
| ) | const |
Print the UDP header to an ostream in pseudo-XML, with each line prefixed by pre.
Returns the ostream.
|
virtual |
Reads the UDP header from a file descriptor.
Returns the number of bytes read on success (should be equal to StreamedLength()), -1 on failure.
Implements Dwm::Readable.
|
virtual |
|
virtual |
Reads the UDP header from a gzFile.
Returns the number of bytes read on success (should be equal to StreamedLength()), -1 on failure.
Implements Dwm::GZReadable.
| void Dwm::Ipv4UdpHeader::SetUdpChecksum | ( | const Ipv4PacketHeader & | ipHeader, |
| const std::string & | data | ||
| ) |
Calculates and sets the UDP checksum field, which requires the UDP payload data and some fields from the IP header.
| void Dwm::Ipv4UdpHeader::SetUdpChecksum | ( | const Ipv4PacketHeader & | ipHeader, |
| const Ipv4UdpPayload & | data | ||
| ) |
Calculates and sets the UDP checksum field, which requires the UDP payload data and some fields from the IP header.
| uint16_t Dwm::Ipv4UdpHeader::SourcePort | ( | uint16_t | port | ) |
Sets the UDP source port to port, which must be in host byte order.
Returns the UDP source port in host byte order.
|
virtual |
Returns the number of bytes that would be written if we called one of the Write() members.
Implements Dwm::Writable.
| uint16_t Dwm::Ipv4UdpHeader::UdpLength | ( | ) | const |
Returns the UDP length in host byte order.
The UDP length field includes the bytes for both the UDP header and the UDP payload.
| uint16_t Dwm::Ipv4UdpHeader::UdpLength | ( | uint16_t | udpLength | ) |
Sets and returns the UDP length in host byte order.
The UDP length field includes the bytes for both the UDP header and the UDP payload.
|
virtual |
Writes the UDP header to a file descriptor.
Returns the number of bytes written on success (should be equal to StreamedLength()), -1 on failure.
Implements Dwm::Writable.
|
virtual |
|
virtual |
Writes the UDP header to a gzFile.
Returns the number of bytes written on success (should be equal to StreamedLength()), -1 on failure.
Implements Dwm::GZWritable.