Sponge
CS144's user-space TCP library
ethernet_frame.cc
Go to the documentation of this file.
1 #include "ethernet_frame.hh"
2 
3 #include "parser.hh"
4 #include "util.hh"
5 
6 #include <stdexcept>
7 #include <string>
8 
9 using namespace std;
10 
12  NetParser p{buffer};
13  _header.parse(p);
14  _payload = p.buffer();
15 
16  return p.get_error();
17 }
18 
20  BufferList ret;
21  ret.append(_header.serialize());
22  ret.append(_payload);
23  return ret;
24 }
util.hh
BufferList::append
void append(const BufferList &other)
Append a BufferList.
Definition: buffer.cc:15
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
Buffer
A reference-counted read-only string that can discard bytes from the front.
Definition: buffer.hh:14
ParseResult
ParseResult
The result of parsing or unparsing an IP datagram, TCP segment, Ethernet frame, or ARP message.
Definition: parser.hh:12
EthernetFrame::parse
ParseResult parse(const Buffer buffer)
Parse the frame from a string.
Definition: ethernet_frame.cc:11
NetParser
Definition: parser.hh:25
std
ethernet_frame.hh
EthernetFrame::serialize
BufferList serialize() const
Serialize the frame to a string.
Definition: ethernet_frame.cc:19
parser.hh