|
|
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: #include "monitor.h"
18:
19: class HostNetDevice;
20:
21: class VirtIONetDevice : public VirtIODevice
22: {
23: using inherited = VirtIODevice;
24: public:
25: VirtIONetDevice(int slot_);
26: ~VirtIONetDevice() override;
27:
28: bool Create() override;
29: bool Init() override;
30:
31: private:
32: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
33:
34: void QueueReady() override;
35: void ProcessDesc(VirtQueue *) override;
36:
37: const char *GetFeatureName(int feature) const override;
38:
39: // 受信
40: void HostRxCallback();
41: void RxMessage(MessageID, uint32);
42: void RxEvent(Event&);
43: void Rx(VirtQueue *);
44:
45: // MAC アドレス自体は動作中は不要なので表示用の文字列だけ持っておく。
46: std::string macaddr_str {};
47:
48: NetPacket rx_packet {};
49:
50: std::unique_ptr<HostNetDevice> hostnet /*{}*/;
51:
52: Event event { this };
53:
54: Monitor monitor { this };
55: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.