Thread: Use inherited baseCpu rather than cpu in SimpleThread
[gem5.git] / src / dev / ethertap.hh
index 3d28388171afefab5e800d88bc121f59c050c5b9..2f38d57b49ad2f13305ed3557e1b5e3c7c314ea7 100644 (file)
 #include <queue>
 #include <string>
 
+#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<EthPacketPtr> 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<const Params *>(_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 &section);
 };
 
+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__