Sponge
CS144's user-space TCP library
|
#include <tcp_header.hh>
Public Member Functions | |
bool | operator== (const TCPHeader &other) const |
ParseResult | parse (NetParser &p) |
Parse the TCP fields from the provided NetParser. More... | |
std::string | serialize () const |
Serialize the TCP fields. More... | |
std::string | summary () const |
Return a string containing a human-readable summary of the header. More... | |
std::string | to_string () const |
Return a string containing a header in human-readable format. More... | |
Public Attributes | |
TCP Header fields | |
uint16_t | sport = 0 |
source port More... | |
uint16_t | dport = 0 |
destination port More... | |
WrappingInt32 | seqno {0} |
sequence number More... | |
WrappingInt32 | ackno {0} |
ack number More... | |
uint8_t | doff = LENGTH / 4 |
data offset More... | |
bool | urg = false |
urgent flag More... | |
bool | ack = false |
ack flag More... | |
bool | psh = false |
push flag More... | |
bool | rst = false |
rst flag More... | |
bool | syn = false |
syn flag More... | |
bool | fin = false |
fin flag More... | |
uint16_t | win = 0 |
window size More... | |
uint16_t | cksum = 0 |
checksum More... | |
uint16_t | uptr = 0 |
Static Public Attributes | |
static constexpr size_t | LENGTH = 20 |
TCP header length, not including options More... | |
TCP segment header
Definition at line 9 of file tcp_header.hh.
bool TCPHeader::operator== | ( | const TCPHeader & | other | ) | const |
Definition at line 103 of file tcp_header.cc.
ParseResult TCPHeader::parse | ( | NetParser & | p | ) |
Parse the TCP fields from the provided NetParser.
[in,out] | p | is a NetParser from which the TCP fields will be extracted |
It is important to check for (at least) the following potential errors (but note that NetParser inherently checks for certain errors; use that fact to your advantage!):
doff
field is shorter than the minimum alloweddoff
field claimsDefinition at line 17 of file tcp_header.cc.
string TCPHeader::serialize | ( | ) | const |
Serialize the TCP fields.
Serialize the TCPHeader to a string (does not recompute the checksum)
Definition at line 51 of file tcp_header.cc.
string TCPHeader::summary | ( | ) | const |
Return a string containing a human-readable summary of the header.
Definition at line 96 of file tcp_header.cc.
string TCPHeader::to_string | ( | ) | const |
Return a string containing a header in human-readable format.
Definition at line 81 of file tcp_header.cc.
bool TCPHeader::ack = false |
ack flag
Definition at line 43 of file tcp_header.hh.
WrappingInt32 TCPHeader::ackno {0} |
ack number
Definition at line 40 of file tcp_header.hh.
uint16_t TCPHeader::cksum = 0 |
checksum
Definition at line 49 of file tcp_header.hh.
uint8_t TCPHeader::doff = LENGTH / 4 |
data offset
Definition at line 41 of file tcp_header.hh.
uint16_t TCPHeader::dport = 0 |
destination port
Definition at line 38 of file tcp_header.hh.
bool TCPHeader::fin = false |
fin flag
Definition at line 47 of file tcp_header.hh.
|
staticconstexpr |
TCP header length, not including options
Definition at line 10 of file tcp_header.hh.
bool TCPHeader::psh = false |
push flag
Definition at line 44 of file tcp_header.hh.
bool TCPHeader::rst = false |
rst flag
Definition at line 45 of file tcp_header.hh.
WrappingInt32 TCPHeader::seqno {0} |
sequence number
Definition at line 39 of file tcp_header.hh.
uint16_t TCPHeader::sport = 0 |
source port
Definition at line 37 of file tcp_header.hh.
bool TCPHeader::syn = false |
syn flag
Definition at line 46 of file tcp_header.hh.
uint16_t TCPHeader::uptr = 0 |
urgent pointer
Definition at line 50 of file tcp_header.hh.
bool TCPHeader::urg = false |
urgent flag
Definition at line 42 of file tcp_header.hh.
uint16_t TCPHeader::win = 0 |
window size
Definition at line 48 of file tcp_header.hh.