X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fdev%2Fethertap.hh;h=2f38d57b49ad2f13305ed3557e1b5e3c7c314ea7;hb=4fdecae443c4f11d24b7da537b6f7a2baadbd130;hp=3d28388171afefab5e800d88bc121f59c050c5b9;hpb=398f6a70a788f1459cec7509859450984e442690;p=gem5.git diff --git a/src/dev/ethertap.hh b/src/dev/ethertap.hh index 3d2838817..2f38d57b4 100644 --- a/src/dev/ethertap.hh +++ b/src/dev/ethertap.hh @@ -38,19 +38,22 @@ #include #include +#include "base/pollevent.hh" #include "dev/etherint.hh" +#include "dev/etherobject.hh" #include "dev/etherpkt.hh" +#include "params/EtherTap.hh" #include "sim/eventq.hh" -#include "base/pollevent.hh" #include "sim/sim_object.hh" class TapEvent; class TapListener; +class EtherTapInt; /* * Interface to connect a simulated ethernet device to the real world */ -class EtherTap : public EtherInt +class EtherTap : public EtherObject { protected: friend class TapEvent; @@ -62,8 +65,8 @@ class EtherTap : public EtherInt int socket; char *buffer; int buflen; - int32_t buffer_offset; - int32_t data_len; + uint32_t buffer_offset; + uint32_t data_len; EtherDump *dump; @@ -73,6 +76,7 @@ class EtherTap : public EtherInt protected: std::string device; std::queue packetBuffer; + EtherTapInt *interface; void process(int revent); void enqueue(EthPacketData *packet); @@ -86,19 +90,28 @@ class EtherTap : public EtherInt EtherTap *tap; public: - TxEvent(EtherTap *_tap) - : Event(&mainEventQueue), tap(_tap) {} + TxEvent(EtherTap *_tap) : tap(_tap) {} void process() { tap->retransmit(); } - virtual const char *description() { return "EtherTap retransmit"; } + virtual const char *description() const + { return "EtherTap retransmit"; } }; friend class TxEvent; TxEvent txEvent; public: - EtherTap(const std::string &name, EtherDump *dump, int port, int bufsz); + typedef EtherTapParams Params; + EtherTap(const Params *p); virtual ~EtherTap(); + const Params * + params() const + { + return dynamic_cast(_params); + } + + virtual EtherInt *getEthPort(const std::string &if_name, int idx); + virtual bool recvPacket(EthPacketPtr packet); virtual void sendDone(); @@ -106,4 +119,18 @@ class EtherTap : public EtherInt virtual void unserialize(Checkpoint *cp, const std::string §ion); }; +class EtherTapInt : public EtherInt +{ + private: + EtherTap *tap; + public: + EtherTapInt(const std::string &name, EtherTap *t) + : EtherInt(name), tap(t) + { } + + virtual bool recvPacket(EthPacketPtr pkt) { return tap->recvPacket(pkt); } + virtual void sendDone() { tap->sendDone(); } +}; + + #endif // __ETHERTAP_HH__