|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2024 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // VirtIO ネットワークデバイス
9: //
10:
11: #pragma once
12:
13: #include "virtio_base.h"
14: #include "event.h"
15: #include "hostnet.h"
16: #include "message.h"
17:
1.1.1.4 ! root 18: class VirtIONetDevice : public VirtIODevice, public IHWAddrFilter
1.1 root 19: {
20: using inherited = VirtIODevice;
21: public:
1.1.1.2 root 22: explicit VirtIONetDevice(uint slot_);
1.1 root 23: ~VirtIONetDevice() override;
24:
25: bool Create() override;
26: bool Init() override;
27:
1.1.1.4 ! root 28: int HWAddrFilter(const MacAddr& dstaddr) const override;
! 29:
1.1 root 30: private:
31: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
32:
1.1.1.3 root 33: void QueueReadyChanged(VirtQueue *) override;
1.1.1.2 root 34: void ProcessDesc(VirtIOReq&) override;
1.1 root 35:
1.1.1.2 root 36: const char *GetFeatureName(uint feature) const override;
1.1 root 37:
38: // 受信
39: void HostRxCallback();
40: void RxMessage(MessageID, uint32);
41: void RxEvent(Event&);
42: void Rx(VirtQueue *);
43:
1.1.1.4 ! root 44: MacAddr macaddr {};
1.1 root 45: std::string macaddr_str {};
46:
47: NetPacket rx_packet {};
48:
49: std::unique_ptr<HostNetDevice> hostnet /*{}*/;
50:
51: Event event { this };
52: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.