--- nono/host/netdriver_tap.h 2026/04/29 17:04:28 1.1.1.1 +++ nono/host/netdriver_tap.h 2026/04/29 17:04:48 1.1.1.3 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once @@ -9,18 +10,32 @@ class NetDriverTap : public NetDriver { - typedef NetDriver inherited; + using inherited = NetDriver; public: // コンストラクタ - NetDriverTap(EthernetDevice *p, - std::mutex *m, std::condition_variable *c); + NetDriverTap(EthernetDevice *parent_, + std::mutex *mtx_, std::condition_variable *cv_, + const std::string& devpath_); // デストラクタ - virtual ~NetDriverTap(); + ~NetDriverTap() override; - virtual bool Init(); - virtual bool SendPacket(const std::vector& data); - virtual void ThreadRun(); + bool Init() override; + bool SendPacket(const std::vector& data) override; + void ThreadRun() override; private: - virtual void Close(); +#if defined(__linux__) + bool OpenLinux(); +#endif + bool OpenDirect(); + bool OpenNumbered(); + bool OpenCloning(); + + void CloseFd(); + void Close(); + + // Open*() のエラーメッセージ。 + // Open*() は複数呼ぶ場合もあったりするのでエラーは基本的にログレベル1 + // で表示しておき、最後に一つだけそれっぽいのを warn() で出力する。 + std::string errmsg {}; };