|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file. 1 #ifndef SPONGE_LIBSPONGE_TUNFD_ADAPTER_HH
2 #define SPONGE_LIBSPONGE_TUNFD_ADAPTER_HH
8 #include <unordered_map>
21 std::optional<TCPSegment>
read() {
42 #endif // SPONGE_LIBSPONGE_TUNFD_ADAPTER_HH
size_t write(const char *str, const bool write_all=true)
Write a string, possibly blocking until all is written.
void write(TCPSegment &seg)
Creates an IPv4 datagram from a TCP segment and writes it to the TUN device.
std::string read(const size_t limit=std::numeric_limits< size_t >::max())
Read up to limit bytes.
InternetDatagram wrap_tcp_in_ip(TCPSegment &seg)
std::optional< TCPSegment > read()
Attempts to read and parse an IPv4 datagram containing a TCP segment related to the current connectio...
ParseResult parse(const Buffer buffer)
Parse the segment from a string.
An adapter class that adds random dropping behavior to an FD adapter.
A FD adapter for IPv4 datagrams read from and written to a TUN device.
TCPOverIPv4OverTunFdAdapter(TunFD &&tun)
Construct from a TunFD.
A converter from TCP segments to serialized IPv4 datagrams.
A FileDescriptor to a Linux TUN device.
std::optional< TCPSegment > unwrap_tcp_in_ip(const InternetDatagram &ip_dgram)