--- nono/host/netdriver_slirp.h 2026/04/29 17:05:39 1.1 +++ nono/host/netdriver_slirp.h 2026/04/29 17:05:47 1.1.1.2 @@ -38,12 +38,16 @@ class NetDriverSlirp : public NetDriver ~NetDriverSlirp() override; void SetLogLevel(int) override; - bool InitDriver() override; + bool InitDriver(bool startup) override; + int Read(NetPacket *p) override; void Write(const void *buf, int buflen) override; void MonitorUpdateMD(TextScreen&, int y) override; + // Slirp ドライバが稼働中かどうか (高々1つなのでグローバル) + static bool IsOccupied() noexcept { return slirp_occupied; } + private: void Close(); @@ -88,11 +92,19 @@ class SlirpThread : public ThreadDevice void TimerModCB(SlirpTimer *, int64); void GuestErrorCB(const char *); + // エラーメッセージ。表スレッドへの連絡用。 + std::string errmsg {}; + private: void ThreadRun() override; - bool ParseAddr(std::string, const char *, struct sockaddr_in *, - std::string&) const; + bool ParseConfigNet(const ConfigItem&, + struct in_addr *addr, struct in_addr *mask); + bool ParseConfigNet6(const ConfigItem&, struct in6_addr *addr6, uint *len); + bool ParseConfigHostFwdEntry(const ConfigItem&, const std::string& entry, + const std::string& where); + int ParseAddrPort(const ConfigItem&, const std::string& hostport, + struct sockaddr_in *, const char *which, const std::string& where); void Write(); // 一部のパケットをこちらで処理する。 @@ -118,7 +130,6 @@ class SlirpThread : public ThreadDevice struct in6_addr gw6 {}; struct in6_addr dns6 {}; - struct in6_addr perfaddr6 {}; // 表スレッドとの送信側/受信側パイプ。 autofd txd_r {};