--- nono/host/hostnet.h 2026/04/29 17:05:21 1.1.1.2 +++ nono/host/hostnet.h 2026/04/29 17:05:56 1.1.1.8 @@ -12,7 +12,6 @@ #include "hostdevice.h" #include "macaddr.h" -#include "monitor.h" #include "netdriver.h" #include "spscqueue.h" @@ -37,12 +36,6 @@ class NetPacket : public std::array 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 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); + // デバッグ用 (下請け) + static std::vector DumpARP(const void *, size_t); + static std::vector DumpIPv4(const void *, size_t); + static std::vector DumpICMPv4(const char *, const char *, + const void *, size_t); + static std::vector DumpTCPv4(const char *, const char *, + const void *, size_t); + static std::vector DumpUDPv4(const char *, const char *, + const void *, size_t); + static std::vector DumpDHCP(const void *, size_t); + static std::vector DumpIPv6(const void *, size_t); + static std::vector DumpICMPv6(const char *, const char *, + const void *, size_t); + static std::string DumpDHCPAddrList(const uint8 *, size_t); + static std::string GetServByPort(uint16 port_be, const char *protoname); + std::unique_ptr driver {}; bool rx_enable {}; - macaddr_t myaddr {}; // 自身の MAC アドレス - bool promisc {}; // プロミスキャスモードなら true // キュー NetTxQueue txq {}; @@ -154,7 +201,7 @@ class HostNetDevice : public HostDevice // 統計情報 struct stat_t stat {}; - std::string errmsg {}; + Monitor *monitor {}; - Monitor monitor { this }; + IHWAddrFilter *ihwaddrfilter {}; };