Sponge
CS144's user-space TCP library
Public Member Functions | List of all members
TapFD Class Reference

A FileDescriptor to a Linux TAP device. More...

#include <tun.hh>

Inheritance diagram for TapFD:
Inheritance graph
[legend]

Public Member Functions

 TapFD (const std::string &devname)
 Open an existing persistent TAP device. More...
 
- Public Member Functions inherited from TunTapFD
 TunTapFD (const std::string &devname, const bool is_tun)
 Open an existing persistent TUN or TAP device. More...
 
- Public Member Functions inherited from FileDescriptor
 FileDescriptor (const int fd)
 Construct from a file descriptor number returned by the kernel. More...
 
 ~FileDescriptor ()=default
 Free the std::shared_ptr; the FDWrapper destructor calls close() when the refcount goes to zero. More...
 
void close ()
 Close the underlying file descriptor. More...
 
FileDescriptor duplicate () const
 Copy a FileDescriptor explicitly, increasing the FDWrapper refcount. More...
 
std::string read (const size_t limit=std::numeric_limits< size_t >::max())
 Read up to limit bytes. More...
 
void read (std::string &str, const size_t limit=std::numeric_limits< size_t >::max())
 Read up to limit bytes into str (caller can allocate storage) More...
 
void set_blocking (const bool blocking_state)
 Set blocking(true) or non-blocking(false) More...
 
size_t write (BufferViewList buffer, const bool write_all=true)
 Write a buffer (or list of buffers), possibly blocking until all is written. More...
 
size_t write (const char *str, const bool write_all=true)
 Write a string, possibly blocking until all is written. More...
 
size_t write (const std::string &str, const bool write_all=true)
 Write a string, possibly blocking until all is written. More...
 
int fd_num () const
 underlying descriptor number More...
 
bool eof () const
 EOF flag state. More...
 
bool closed () const
 closed flag state More...
 
unsigned int read_count () const
 number of reads More...
 
unsigned int write_count () const
 number of writes More...
 
 FileDescriptor (const FileDescriptor &other)=delete
 copy construction is forbidden More...
 
FileDescriptoroperator= (const FileDescriptor &other)=delete
 copy assignment is forbidden More...
 
 FileDescriptor (FileDescriptor &&other)=default
 move construction is allowed More...
 
FileDescriptoroperator= (FileDescriptor &&other)=default
 move assignment is allowed More...
 

Detailed Description

A FileDescriptor to a Linux TAP device.

Definition at line 23 of file tun.hh.

Constructor & Destructor Documentation

◆ TapFD()

TapFD::TapFD ( const std::string devname)
inlineexplicit

Open an existing persistent TAP device.

Definition at line 26 of file tun.hh.


The documentation for this class was generated from the following file: