--- nono/host/netdriver_bpf.cpp 2026/04/29 17:05:11 1.1.1.6 +++ nono/host/netdriver_bpf.cpp 2026/04/29 17:06:02 1.1.1.9 @@ -22,7 +22,7 @@ // コンストラクタ NetDriverBPF::NetDriverBPF(HostDevice *hostdev_, const std::string& ifname_) - : inherited(hostdev_, "BPF") + : inherited(hostdev_, "bpf") { ifname = ifname_; if (ifname.empty()) { @@ -38,7 +38,7 @@ NetDriverBPF::~NetDriverBPF() // ドライバ初期化 bool -NetDriverBPF::InitDriver() +NetDriverBPF::InitDriver(bool startup) { struct ifreq ifr; struct bpf_program prog; @@ -168,10 +168,10 @@ NetDriverBPF::Close() // モニタ (ドライバ依存情報のみ) void -NetDriverBPF::MonitorUpdateMD(TextScreen& screen) +NetDriverBPF::MonitorScreenMD(TextScreen& screen, int y) { - screen.Print(0, 1, "Device : %s", devpath.c_str()); - screen.Print(0, 2, "Interface: %s", ifname.c_str()); + screen.Print(0, y++, "Device : %s", devpath.c_str()); + screen.Print(0, y++, "Interface: %s", ifname.c_str()); } // パケットを送信する @@ -182,11 +182,11 @@ NetDriverBPF::Write(const void *buf, int n = write(fd, buf, buflen); if (n < 0) { - putmsg(0, "write: %s", strerror(errno)); + putmsg(0, "write(%d): %s", buflen, strerror(errno)); return; } if (n < buflen) { - putmsg(0, "write: short"); + putmsg(0, "write(%d): short(%zd)", buflen, n); return; } } @@ -209,10 +209,7 @@ NetDriverBPF::Read(NetPacket *p) // BPF ヘッダを除いた部分が 1 パケット struct bpf_hdr *bh = (struct bpf_hdr *)bpfptr; - - NetPacket& packet = *p; - memcpy(packet.data(), bpfptr + bh->bh_hdrlen, bh->bh_caplen); - packet.length = bh->bh_caplen; + p->Assign(bpfptr + bh->bh_hdrlen, bh->bh_caplen); // 次のフレームの先頭を指す int framelen = BPF_WORDALIGN(bh->bh_hdrlen + bh->bh_caplen);