Sponge
CS144's user-space TCP library
tcp_segment.hh
Go to the documentation of this file.
1 #ifndef SPONGE_LIBSPONGE_TCP_SEGMENT_HH
2 #define SPONGE_LIBSPONGE_TCP_SEGMENT_HH
3 
4 #include "buffer.hh"
5 #include "tcp_header.hh"
6 
7 #include <cstdint>
8 
10 class TCPSegment {
11  private:
14 
15  public:
17  ParseResult parse(const Buffer buffer, const uint32_t datagram_layer_checksum = 0);
18 
20  BufferList serialize(const uint32_t datagram_layer_checksum = 0) const;
21 
24  const TCPHeader &header() const { return _header; }
25  TCPHeader &header() { return _header; }
26 
27  const Buffer &payload() const { return _payload; }
28  Buffer &payload() { return _payload; }
30 
33  size_t length_in_sequence_space() const;
34 };
35 
36 #endif // SPONGE_LIBSPONGE_TCP_SEGMENT_HH
TCPSegment::header
TCPHeader & header()
Definition: tcp_segment.hh:25
TCPSegment::serialize
BufferList serialize(const uint32_t datagram_layer_checksum=0) const
Serialize the segment to a string.
Definition: tcp_segment.cc:30
tcp_header.hh
BufferList
A reference-counted discontiguous string that can discard bytes from the front.
Definition: buffer.hh:56
buffer
std::string buffer
Definition: parser_example.cc:7
TCPSegment::_payload
Buffer _payload
Definition: tcp_segment.hh:13
Buffer
A reference-counted read-only string that can discard bytes from the front.
Definition: buffer.hh:14
TCPSegment::_header
TCPHeader _header
Definition: tcp_segment.hh:12
TCPSegment::parse
ParseResult parse(const Buffer buffer, const uint32_t datagram_layer_checksum=0)
Parse the segment from a string.
Definition: tcp_segment.cc:12
ParseResult
ParseResult
The result of parsing or unparsing an IP datagram, TCP segment, Ethernet frame, or ARP message.
Definition: parser.hh:12
TCPSegment::payload
Buffer & payload()
Definition: tcp_segment.hh:28
buffer.hh
TCPSegment::payload
const Buffer & payload() const
Definition: tcp_segment.hh:27
TCPHeader
TCP segment header
Definition: tcp_header.hh:9
TCPSegment
TCP segment
Definition: tcp_segment.hh:10
TCPSegment::header
const TCPHeader & header() const
Definition: tcp_segment.hh:24
TCPSegment::length_in_sequence_space
size_t length_in_sequence_space() const
Segment's length in sequence space.
Definition: tcp_segment.cc:25