--- nono/host/netdriver_bpf.h 2026/04/29 17:04:28 1.1.1.1 +++ nono/host/netdriver_bpf.h 2026/04/29 17:06:02 1.1.1.9 @@ -1,30 +1,41 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt +// + +// +// ホストネットワークの BPF ドライバ // #pragma once #include "netdriver.h" +#include "hostnet.h" class NetDriverBPF : public NetDriver { - typedef NetDriver inherited; + using inherited = NetDriver; public: - // コンストラクタ - NetDriverBPF(EthernetDevice *p, std::mutex *m, std::condition_variable *c); - // デストラクタ - virtual ~NetDriverBPF(); - - virtual bool Init(); - virtual bool SendPacket(const std::vector& data); - virtual void ThreadRun(); + NetDriverBPF(HostDevice *hostdev_, const std::string& ifname_); + ~NetDriverBPF() override; + + bool InitDriver(bool startup) override; + + int Read(NetPacket *p) override; + void Write(const void *buf, int buflen) override; + + void MonitorScreenMD(TextScreen&, int y) override; private: - virtual void Close(); + void Close(); + + std::string FindInterface() const; - std::string FindInterface(); + // デバイスファイルパス + std::string devpath {}; - char *bpfbuf = NULL; - int bpfbuflen = 0; + std::vector bpfbuf {}; + uint8 *bpfptr {}; + ssize_t bpflen {}; };