--- nono/host/netdriver.cpp 2026/04/29 17:04:28 1.1 +++ nono/host/netdriver.cpp 2026/04/29 17:04:48 1.1.1.5 @@ -1,31 +1,31 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // -#include "header.h" #include "netdriver.h" -#include "configfile.h" -#include "mystring.h" +#include "mainapp.h" +#include "mythread.h" static void *netdriver_run(void *); -NetDriver *gNetDriver; +std::unique_ptr gNetDriver; // コンストラクタ -NetDriver::NetDriver(const char *name, EthernetDevice *p, - std::mutex *m, std::condition_variable *c) +NetDriver::NetDriver(const char *drivername_, EthernetDevice *parent_, + std::mutex *mtx_, std::condition_variable *cv_) { logname = "netdriver"; devname = "NetDriver"; - monitor.Init(30, 7); + monitor_size = nnSize(30, 7); fd = -1; - drivername = name; - parent = p; - mtx = m; - cv = c; + drivername = drivername_; + parent = parent_; + mtx = mtx_; + cv = cv_; } // デストラクタ @@ -34,8 +34,8 @@ NetDriver::~NetDriver() } // モニタ -bool -NetDriver::MonitorUpdate() +void +NetDriver::MonitorUpdate(TextScreen& monitor) { monitor.Clear(); @@ -46,7 +46,6 @@ NetDriver::MonitorUpdate() monitor.Print(5, 4, "%9s %9s", "Packets", "Bytes"); monitor.Print(0, 5, "Send %9" PRIu64 " %9" PRIu64, tx_pkts, tx_bytes); monitor.Print(0, 6, "Recv %9" PRIu64 " %9" PRIu64, rx_pkts, rx_bytes); - return true; } // スレッドが必要な継承クラスが呼ぶ @@ -64,7 +63,7 @@ NetDriver::InitRecvThread() void * netdriver_run(void *dummy) { - pthread_setname_np("netdriver"); + PTHREAD_SETNAME("netdriver"); pthread_detach(pthread_self()); gNetDriver->ThreadRun(); @@ -90,7 +89,7 @@ bool NetDriver::RunScript(const char *filename) { // ファイルが存在するか - std::string path = gConfig->SearchFile(filename); + std::string path = gMainApp.SearchFile(filename); if (path.empty()) { warnx("%s not found", filename); return false;