Sponge
CS144's user-space TCP library
Public Member Functions | Private Attributes | List of all members
TCPSegment Class Reference

TCP segment More...

#include <tcp_segment.hh>

Public Member Functions

size_t length_in_sequence_space () const
 Segment's length in sequence space. More...
 
ParseResult parse (const Buffer buffer, const uint32_t datagram_layer_checksum=0)
 Parse the segment from a string. More...
 
BufferList serialize (const uint32_t datagram_layer_checksum=0) const
 Serialize the segment to a string. More...
 
Accessors
const TCPHeaderheader () const
 
TCPHeaderheader ()
 
const Bufferpayload () const
 
Bufferpayload ()
 

Private Attributes

TCPHeader _header {}
 
Buffer _payload {}
 

Detailed Description

TCP segment

Definition at line 10 of file tcp_segment.hh.

Member Function Documentation

◆ header() [1/2]

TCPHeader& TCPSegment::header ( )
inline

Definition at line 25 of file tcp_segment.hh.

◆ header() [2/2]

const TCPHeader& TCPSegment::header ( ) const
inline

Definition at line 24 of file tcp_segment.hh.

◆ length_in_sequence_space()

size_t TCPSegment::length_in_sequence_space ( ) const

Segment's length in sequence space.

Note
Equal to payload length plus one byte if SYN is set, plus one byte if FIN is set

Definition at line 25 of file tcp_segment.cc.

◆ parse()

ParseResult TCPSegment::parse ( const Buffer  buffer,
const uint32_t  datagram_layer_checksum = 0 
)

Parse the segment from a string.

Parameters
[in]bufferstring/Buffer to be parsed
[in]datagram_layer_checksumpseudo-checksum from the lower-layer protocol

Definition at line 12 of file tcp_segment.cc.

◆ payload() [1/2]

Buffer& TCPSegment::payload ( )
inline

Definition at line 28 of file tcp_segment.hh.

◆ payload() [2/2]

const Buffer& TCPSegment::payload ( ) const
inline

Definition at line 27 of file tcp_segment.hh.

◆ serialize()

BufferList TCPSegment::serialize ( const uint32_t  datagram_layer_checksum = 0) const

Serialize the segment to a string.

Parameters
[in]datagram_layer_checksumpseudo-checksum from the lower-layer protocol

Definition at line 30 of file tcp_segment.cc.

Member Data Documentation

◆ _header

TCPHeader TCPSegment::_header {}
private

Definition at line 12 of file tcp_segment.hh.

◆ _payload

Buffer TCPSegment::_payload {}
private

Definition at line 13 of file tcp_segment.hh.


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