More documentation for 1.1 release.
[gem5.git] / dev / etherpkt.cc
index 292fe7faf26eb2d59a4449903594baeb446e631d..5dee7dc0df43463981f31e7d8b410dc97e8d4e79 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 The Regents of The University of Michigan
+ * Copyright (c) 2004-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 #include <iostream>
 
+#include "base/misc.hh"
 #include "dev/etherpkt.hh"
 #include "sim/serialize.hh"
 
 using namespace std;
 
 void
-PacketData::doext()
+PacketData::serialize(const string &base, ostream &os)
 {
-    _eth = 0;
-    _ip = 0;
-    _tcp = 0;
-    _udp = 0;
-
-    if (!data)
-        return;
-
-    _eth = data;
-    if (eth()->type() == ETH_TYPE_IP) {
-        _ip = eth()->payload();
-
-        if (ip()->proto() == IP_PROTO_TCP)
-            _tcp = ip()->payload();
-
-        if (ip()->proto() == IP_PROTO_UDP)
-            _udp = ip()->payload();
-    }
-}
-
-void
-PacketData::serialize(ostream &os)
-{
-    SERIALIZE_SCALAR(length);
-    SERIALIZE_ARRAY(data, length);
+    paramOut(os, base + ".length", length);
+    arrayParamOut(os, base + ".data", data, length);
 }
 
 void
-PacketData::unserialize(Checkpoint *cp, const string &section)
+PacketData::unserialize(const string &base, Checkpoint *cp,
+                        const string &section)
 {
-    UNSERIALIZE_SCALAR(length);
-    data = new uint8_t[length];
-    UNSERIALIZE_ARRAY(data, length);
+    paramIn(cp, section, base + ".length", length);
+    if (length)
+        arrayParamIn(cp, section, base + ".data", data, length);
 }