libDwm-0.6.0
Dwm::Ipv4TcpHeader Class Reference

Encapsulates a TCP header. More...

#include <DwmIpv4TcpHeader.hh>

Inheritance diagram for Dwm::Ipv4TcpHeader:
Collaboration diagram for Dwm::Ipv4TcpHeader:

Public Member Functions

 Ipv4TcpHeader ()
 Constructor.
 
 Ipv4TcpHeader (const Ipv4PacketHeader &ipHeader)
 Construct from an Ipv4PacketHeader which points at the IP header in a TCP packet. More...
 
 Ipv4TcpHeader (const Ipv4TcpHeader &tcpHeader)
 Copy constructor.
 
 Ipv4TcpHeader (struct tcphdr *tcpHdr)
 Construct from a pointer to a struct tcphdr. More...
 
 Ipv4TcpHeader (const struct tcphdr &tcpHdr)
 Construct by copying from a struct tcphdr.
 
Ipv4TcpHeaderoperator= (const Ipv4TcpHeader &tcpHeader)
 operator =
 
 ~Ipv4TcpHeader ()
 Destructor.
 
uint16_t SourcePort () const
 Returns the source port.
 
uint16_t SourcePort (uint16_t port)
 Sets and returns the source port.
 
uint16_t DestinationPort () const
 Returns the destination port.
 
uint16_t DestinationPort (uint16_t port)
 Sets and returns the destination port.
 
uint32_t SequenceNumber () const
 Returns the sequence number.
 
uint32_t SequenceNumber (uint32_t seq)
 Sets and returns the sequence number.
 
uint32_t AckNumber () const
 Returns the ACK nuber.
 
uint32_t AckNumber (uint32_t ack)
 Sets and returns the ACK number.
 
uint8_t DataOffset () const
 The number of 32 bit words in the TCP header. More...
 
uint8_t DataOffset (uint8_t offset)
 Sets the number of 32 bit words in the TCP header. More...
 
uint8_t Flags () const
 Returns the flags.
 
uint8_t Flags (uint8_t flags)
 Sets and returns the flags.
 
uint16_t Window () const
 Returns the window.
 
uint16_t Window (uint16_t window)
 Sets and returns the window.
 
uint16_t Checksum () const
 Returns the checksum.
 
void SetChecksum (const Ipv4PacketHeader &ipHeader, const std::string &data)
 Sets the checksum, for which we need the IP header and the data.
 
uint16_t UrgentPointer () const
 Returns the urgent pointer.
 
uint16_t UrgentPointer (uint16_t urgent)
 Sets the urgent pointer.
 
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 the given file descriptor fd. More...
 
ssize_t Write (int fd) const
 Writes to the given file descriptor fd. More...
 
size_t Read (FILE *f)
 Reads from the given FILE pointer f. More...
 
size_t Write (FILE *f) const
 Writes to the given FILE pointer f. More...
 
int Read (gzFile gzf)
 Reads from the given gzFile gzf. More...
 
int Write (gzFile gzf) const
 Writes to the given gzFile gzf. More...
 
int BZRead (BZFILE *bzf)
 Reads from the given BZFILE pointer bzf. More...
 
int BZWrite (BZFILE *bzf) const
 Writes to the given BZFILE pointer bzf. More...
 
uint32_t StreamedLength () const
 Returns the number of bytes that would be written if one of the Write() members were called. More...
 
bool operator== (const Ipv4TcpHeader &tcpHeader) const
 operator ==
 
std::ostream & PrintXML (std::ostream &os, const std::string &pre="") const
 Prints the TCP header to an ostream as pseudo-XML. More...
 
uint8_t * End () const
 Returns the address of the end of the TCP header. 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
 

Detailed Description

Encapsulates a TCP header.

Constructor & Destructor Documentation

◆ Ipv4TcpHeader() [1/2]

Dwm::Ipv4TcpHeader::Ipv4TcpHeader ( const Ipv4PacketHeader ipHeader)

Construct from an Ipv4PacketHeader which points at the IP header in a TCP packet.

DO NOT FREE THE UNDERLYING MEMORY WHILE THE Ipv4TcpHeader IS STILL IN USE!

◆ Ipv4TcpHeader() [2/2]

Dwm::Ipv4TcpHeader::Ipv4TcpHeader ( struct tcphdr *  tcpHdr)

Construct from a pointer to a struct tcphdr.

We don't copy, so don't free the data into which tcpHdr points until after the Ipv4TcpHeader is no longer in use.

Member Function Documentation

◆ BZRead()

int Dwm::Ipv4TcpHeader::BZRead ( BZFILE *  bzf)
virtual

Reads from the given BZFILE pointer bzf.

Returns the number of bytes read on success, -1 on failure.

Implements Dwm::BZ2Readable.

◆ BZWrite()

int Dwm::Ipv4TcpHeader::BZWrite ( BZFILE *  bzf) const
virtual

Writes to the given BZFILE pointer bzf.

Returns the number of bytes written on success, -1 on failure.

Implements Dwm::BZ2Writable.

◆ DataOffset() [1/2]

uint8_t Dwm::Ipv4TcpHeader::DataOffset ( ) const

The number of 32 bit words in the TCP header.

This indicates where the data begins. The TCP header (even one including options) is an integral number of 32 bits long.

Note
since the offset field is only 4 bits, a TCP header can't be more than 60 bytes long (15 * 4).

◆ DataOffset() [2/2]

uint8_t Dwm::Ipv4TcpHeader::DataOffset ( uint8_t  offset)

Sets the number of 32 bit words in the TCP header.

This indicates where the data begins. The TCP header (even one including options) is an integral number of 32 bits long.

Note
since the offset field is only 4 bits, a TCP header can't be more than 60 bytes long (15 * 4).

◆ End()

uint8_t* Dwm::Ipv4TcpHeader::End ( ) const

Returns the address of the end of the TCP header.

If our TCP header points into an existing TCP packet, this will be the first byte of the user data.

◆ PrintXML()

std::ostream& Dwm::Ipv4TcpHeader::PrintXML ( std::ostream &  os,
const std::string &  pre = "" 
) const

Prints the TCP header to an ostream as pseudo-XML.

Each line will be prefixed with pre.

◆ Read() [1/3]

ssize_t Dwm::Ipv4TcpHeader::Read ( int  fd)
virtual

Reads from the given file descriptor fd.

Returns the number of bytes read on success, -1 on failure.

Implements Dwm::Readable.

◆ Read() [2/3]

size_t Dwm::Ipv4TcpHeader::Read ( FILE *  f)
virtual

Reads from the given FILE pointer f.

Returns 1 on success, 0 on failure (fread() semantics).

Implements Dwm::Readable.

◆ Read() [3/3]

int Dwm::Ipv4TcpHeader::Read ( gzFile  gzf)
virtual

Reads from the given gzFile gzf.

Returns the number of bytes read on success, -1 on failure.

Implements Dwm::GZReadable.

◆ StreamedLength()

uint32_t Dwm::Ipv4TcpHeader::StreamedLength ( ) const
virtual

Returns the number of bytes that would be written if one of the Write() members were called.

Implements Dwm::Writable.

◆ Write() [1/3]

ssize_t Dwm::Ipv4TcpHeader::Write ( int  fd) const
virtual

Writes to the given file descriptor fd.

Returns the number of bytes written on success, -1 on failure.

Implements Dwm::Writable.

◆ Write() [2/3]

size_t Dwm::Ipv4TcpHeader::Write ( FILE *  f) const
virtual

Writes to the given FILE pointer f.

Returns 1 on success, 0 on failure (fwrite() semantics).

Implements Dwm::Writable.

◆ Write() [3/3]

int Dwm::Ipv4TcpHeader::Write ( gzFile  gzf) const
virtual

Writes to the given gzFile gzf.

Returns the number of bytes written on success, -1 on failure.

Implements Dwm::GZWritable.


The documentation for this class was generated from the following file: