Add serialization (which Nate now says we probably don't need)
authorSteve Raasch <sraasch@umich.edu>
Thu, 30 Oct 2003 20:16:00 +0000 (15:16 -0500)
committerSteve Raasch <sraasch@umich.edu>
Thu, 30 Oct 2003 20:16:00 +0000 (15:16 -0500)
--HG--
extra : convert_revision : e075fafdf6e72a424110a120e24ca71cb44cfb03

dev/ethertap.cc
dev/ethertap.hh

index b99d46ce5771d7d35998a11bcfe510810c1e4444..339e7ac78beb22d614b8c2f175dea83ba04eaaf4 100644 (file)
@@ -163,6 +163,7 @@ EtherTap::detach()
 {
     DPRINTF(Ethernet, "EtherTap detached\n");
     delete event;
+    event = 0;
     close(socket);
     socket = -1;
 }
@@ -262,6 +263,52 @@ EtherTap::retransmit()
         txEvent.schedule(curTick + 1000);
 }
 
+//=====================================================================
+
+void
+EtherTap::serialize(ostream &os)
+{
+    SERIALIZE_SCALAR(socket);
+    SERIALIZE_SCALAR(buflen);
+    SERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+    SERIALIZE_SCALAR(buffer_offset);
+    SERIALIZE_SCALAR(data_len);
+
+    bool tapevent_present = false;
+    if (event) {
+        tapevent_present = true;
+        SERIALIZE_SCALAR(tapevent_present);
+        event->serialize(os);
+    }
+    else {
+        SERIALIZE_SCALAR(tapevent_present);
+    }
+}
+
+void
+EtherTap::unserialize(Checkpoint *cp, const std::string &section)
+{
+    UNSERIALIZE_SCALAR(socket);
+    UNSERIALIZE_SCALAR(buflen);
+    UNSERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+    UNSERIALIZE_SCALAR(buffer_offset);
+    UNSERIALIZE_SCALAR(data_len);
+
+    bool tapevent_present;
+    UNSERIALIZE_SCALAR(tapevent_present);
+    if (tapevent_present) {
+        event = new TapEvent(this, socket, POLLIN|POLLERR);
+
+        event->unserialize(cp,section);
+
+        if (event->queued()) {
+            pollQueue.schedule(event);
+        }
+    }
+}
+
+//=====================================================================
+
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherTap)
 
     SimObjectParam<EtherInt *> peer;
index 6e99bd91d77112b3ae9a147e982215d7b7d95824..e2b1f640fb57b35b40f00fd0fe7ddf4e8b67580e 100644 (file)
@@ -96,6 +96,9 @@ class EtherTap : public EtherInt
 
     virtual bool recvPacket(PacketPtr packet);
     virtual void sendDone();
+
+    virtual void serialize(std::ostream &os);
+    virtual void unserialize(Checkpoint *cp, const std::string &section);
 };
 
 #endif // __ETHERTAP_HH__