Libraryize test.cc

This commit is contained in:
Ian Gulliver
2016-09-25 17:37:37 -07:00
parent c067cbd71e
commit f31ccaad16
10 changed files with 100 additions and 102 deletions

View File

@@ -1,21 +1,33 @@
#include <string>
#include <fcntl.h>
#include <linux/if_tun.h>
#include <sys/stat.h>
#include <sys/types.h>
class TapTunDevice {
namespace funstraw {
class TunTapDevice {
public:
static const auto kTunFormat = IFF_TUN;
static const auto kTapFormat = IFF_TAP;
static const auto kNoPacketInfo = IFF_NO_PI;
static const auto kIfFormatTun = IFF_TUN;
static const auto kIfFormatTap = IFF_TAP;
static const auto kIfNoPacketInfo = IFF_NO_PI;
TapTunDevice(const std::string& name, uint64_t flags);
TapTunDevice(uint64_t flags);
static const auto kFdReadOnly = O_RDONLY;
static const auto kFdWriteOnly = O_WRONLY;
static const auto kFdReadWrite = O_RDWR;
const std::string& Name() {
return name_;
}
TunTapDevice(const std::string& name, uint64_t if_flags, uint64_t fd_flags);
~TunTapDevice();
const std::string& Name() { return name_; }
// TODO: real buffer object
size_t Read(char* buf);
private:
int fd_;
std::string name_;
};
} // namespace funstraw