--- nono/host/netdriver.h 2026/04/29 17:04:30 1.1.1.2 +++ nono/host/netdriver.h 2026/04/29 17:04:48 1.1.1.6 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once @@ -15,20 +16,21 @@ class NetDriver : public Object public: // コンストラクタ NetDriver(const char *name, EthernetDevice *parent, - std::mutex *m, std::condition_variable *c); + std::mutex *mtx, std::condition_variable *cv); // デストラクタ。 - virtual ~NetDriver(); + ~NetDriver() override; // 初期化 & オープン。 // EthernetDevice::Init() から呼ばれる。諸制約については device.h 参照。 + // まずどれが呼ばれたかを putmsg(1) でログ表示し、 // 必要なオープン処理や、必要なら受信スレッドの作成を行う。 // 成功すれば true、失敗すれば warn()/warnx() でメッセージを出力して // false を返すこと。 // また、クローズ相当の動作はなくデストラクタで行う。 virtual bool Init() = 0; - virtual bool MonitorUpdate(); + void MonitorUpdate(TextScreen&) override; // パケットを送信する。正常に送信できれば true を返す。 // EthernetDevice::SendPacket() が呼ばれると常に呼び出される。 @@ -51,21 +53,21 @@ class NetDriver : public Object // 受信スレッドを起動する (必要なら継承クラス側が呼ぶ) bool InitRecvThread(); - const char *drivername = NULL; // ドライバ名 - EthernetDevice *parent = NULL; // 親 + const char *drivername {}; // ドライバ名 + EthernetDevice *parent {}; // 親 - std::string devpath; // デバイスファイルパス - std::string ifname; // 作成したインタフェース名 + std::string devpath {}; // デバイスファイルパス + std::string ifname {}; // 作成したインタフェース名 // デバイスディスクリプタ。 // ディスクリプタを持つというのは共通なのでディスクリプタはここに置くが // これを Open(), Close() するのはあくまで継承側の仕事で、こちらでは // 初期化と IsOpen() だけ受け持つ。ちょっと責任分解点が気持ち悪いけど。 - int fd = 0; + int fd {}; // 親(Ethernet)デバイスの mutex と condvar - std::mutex *mtx; - std::condition_variable *cv; + std::mutex *mtx {}; + std::condition_variable *cv {}; // 統計情報 uint64 tx_pkts = 0;