|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file. 1 #ifndef SPONGE_LIBSPONGE_PARSER_HH
2 #define SPONGE_LIBSPONGE_PARSER_HH
79 #endif // SPONGE_LIBSPONGE_PARSER_HH
uint16_t u16()
Parse a 16-bit integer in network byte order from the data stream.
static void u8(std::string &s, const uint8_t val)
Write an 8-bit integer into the data stream in network byte order.
void remove_prefix(const size_t n)
Remove n bytes from the buffer.
void _check_size(const size_t size)
Check that there is sufficient data to parse the next token.
bool error() const
Returns true if there has been an error.
@ BadChecksum
Bad checksum.
static void u16(std::string &s, const uint16_t val)
Write a 16-bit integer into the data stream in network byte order.
T _parse_int()
Generic integer parsing method (used by u32, u16, u8)
A reference-counted read-only string that can discard bytes from the front.
static void _unparse_int(std::string &s, T val)
@ Unsupported
Packet uses unsupported features.
ParseResult
The result of parsing or unparsing an IP datagram, TCP segment, Ethernet frame, or ARP message.
void set_error(ParseResult res)
Set BaseParser::_error.
@ TruncatedPacket
Packet length is shorter than header claims.
static void u32(std::string &s, const uint32_t val)
Write a 32-bit integer into the data stream in network byte order.
uint8_t u8()
Parse an 8-bit integer in network byte order from the data stream.
@ WrongIPVersion
Got a version of IP other than 4.
@ HeaderTooShort
Header length is shorter than minimum required.
std::string as_string(const ParseResult r)
Output a string representation of a ParseResult.
@ PacketTooShort
Not enough data to finish parsing.
ParseResult get_error() const
Get the current value stored in BaseParser::_error.
ParseResult _error
Result of parsing so far.
uint32_t u32()
Parse a 32-bit integer in network byte order from the data stream.