--- nono/host/hostnet.h 2026/04/29 17:05:39 1.1.1.6 +++ nono/host/hostnet.h 2026/04/29 17:06:02 1.1.1.9 @@ -15,13 +15,9 @@ #include "netdriver.h" #include "spscqueue.h" -// パケット -class NetPacket : public std::array +// パケット。 +class NetPacket { - // ジャンボフレームでないイーサネットフレームは最大 1518バイトだが - // このパケットバッファの長さは 1519 バイト以上必要。 - // vm/lance が 1518 バイトを越えたことを検出するのに使っている。 - public: NetPacket() { Clear(); @@ -30,32 +26,63 @@ class NetPacket : public std::array buf {}; }; // MAC アドレスフィルタ。 @@ -116,7 +143,7 @@ class HostNetDevice : public HostDevice }; public: - HostNetDevice(Device *parent_, uint n); + HostNetDevice(Device *parent_, uint n, const std::string& portname_); ~HostNetDevice() override; void SetLogLevel(int loglevel_) override; @@ -139,8 +166,8 @@ class HostNetDevice : public HostDevice // マルチキャストフィルタを設定する。 void SetMCastFilter(uint64 filter); - // ドライバ名を返す (ステータスパネルから呼ばれる) - const std::string GetDriverName() const; + // ドライバ名を返す。 + const std::string& GetDriverName(); // 統計情報を返す (ステータスパネルから呼ばれる) uint64 GetTXPkts() const { return stat.tx_pkts; } @@ -152,24 +179,27 @@ class HostNetDevice : public HostDevice // コンパイル済みのドライバ名一覧を返す static std::vector GetDrivers(); + // libslirp のバージョン文字列を返す + static const char *GetSlirpVersion(); + // デバッグ用。 static std::vector DumpHex(const void *, size_t); static std::vector DumpFrame(const void *, size_t); private: - bool SelectDriver(); - bool CreateNone(); - bool CreateSlirp(); - bool CreateTap(); - bool CreateBPF(); - bool CreateAFPacket(); + bool SelectDriver(bool startup) override; + void CreateNone(); + void CreateSlirp(bool startup); + void CreateTap(); + void CreateBPF(); + void CreateAFPacket(); int Read() override; // 外部への書き出し(パケットを送信) - void Write(uint32 data) override; + void Write() override; - DECLARE_MONITOR_CALLBACK(MonitorUpdate); + DECLARE_MONITOR_SCREEN(MonitorScreen); // デバッグ用 (下請け) static std::vector DumpARP(const void *, size_t); @@ -198,8 +228,6 @@ class HostNetDevice : public HostDevice // 統計情報 struct stat_t stat {}; - std::string errmsg {}; - Monitor *monitor {}; IHWAddrFilter *ihwaddrfilter {};