--- nono/host/hostnet.cpp 2026/04/29 17:05:47 1.1.1.9 +++ nono/host/hostnet.cpp 2026/04/29 17:05:55 1.1.1.11 @@ -77,6 +77,7 @@ #endif #if defined(HAVE_HOSTNET_SLIRP) #include "netdriver_slirp.h" +#include #endif #if defined(HAVE_HOSTNET_TAP) #include "netdriver_tap.h" @@ -109,6 +110,18 @@ HostNetDevice::GetDrivers() return list; } +// libslirp のバージョン文字列を返す。 +// libslirp が有効でなければ NULL を返す。 +/*static*/ const char * +HostNetDevice::GetSlirpVersion() +{ +#if defined(SLIRP_VERSION_STRING) + return SLIRP_VERSION_STRING; +#else + return NULL; +#endif +} + // コンストラクタ HostNetDevice::HostNetDevice(Device *parent_, uint n, @@ -145,7 +158,7 @@ HostNetDevice::SetLogLevel(int loglevel_ { inherited::SetLogLevel(loglevel_); - std::lock_guard guard(driverlock); + RWLockGuard_Read guard(driverlock); if ((bool)driver) { driver->SetLogLevel(loglevel_); } @@ -159,16 +172,6 @@ HostNetDevice::Create2() return false; } - // hostnet*-fallback は使わなくなったので、 - // 初期値から変更されていれば警告だけ出す。 - std::string key = GetConfigKey(); - const std::string fallback_key = key + "-fallback"; - const ConfigItem& fallback_item = gConfig->Find(fallback_key); - if (fallback_item.GetFrom() != ConfigItem::FromInitial) { - warnx("Warning: option '%s' has been obsoleted.", - fallback_key.c_str()); - } - if (SelectDriver(true) == false) { return false; } @@ -184,7 +187,7 @@ HostNetDevice::Create2() bool HostNetDevice::SelectDriver(bool startup) { - std::lock_guard guard(driverlock); + RWLockGuard_Write guard(driverlock); driver.reset(); errmsg.clear(); @@ -267,7 +270,7 @@ HostNetDevice::SelectDriver(bool startup } else { // UI に通知してフォールバック。 int n = GetId() - OBJ_HOSTNET0; - UIMessage::Post(UIMessage::HOSTNET_FAILED, n); + gMainApp.GetUIMessage()->Post(UIMessage::HOSTNET_FAILED, n); CreateNone(); } @@ -487,7 +490,7 @@ HostNetDevice::Read() int queued = 0; int left = 0; - std::lock_guard guard(driverlock); + RWLockGuard_Read guard(driverlock); assert((bool)driver); do { @@ -585,7 +588,7 @@ HostNetDevice::Write() { const NetPacket *p; - std::lock_guard guard(driverlock); + RWLockGuard_Read guard(driverlock); assert((bool)driver); // 送信キューから取り出す @@ -622,10 +625,10 @@ HostNetDevice::Write() } // ドライバ名を返す -const std::string +const std::string& HostNetDevice::GetDriverName() { - std::lock_guard guard(driverlock); + RWLockGuard_Read guard(driverlock); assert((bool)driver); return driver->GetDriverName(); } @@ -648,8 +651,9 @@ HostNetDevice::MonitorUpdate(Monitor *, screen.Print(0, 0, "Device(Port) : %s", GetPortName().c_str()); { - std::lock_guard guard(driverlock); - screen.Print(0, 1, "HostNet Driver: %s", driver->GetDriverName()); + RWLockGuard_Read guard(driverlock); + screen.Print(0, 1, "HostNet Driver: %s", + driver->GetDriverName().c_str()); // 次の2行はドライバ依存情報 driver->MonitorUpdateMD(screen, 2); }