always initalize the size of a packet (forgotten on checkpoints
[gem5.git] / dev / etherpkt.hh
index c91322526022b3703960ab7c8c7b9fd9a3f9d2da..7a7809f0a1f12f5ad8a34f73d0df335938d05c94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2002-2004 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #ifndef __ETHERPKT_HH__
 #define __ETHERPKT_HH__
 
+#include <iosfwd>
 #include <memory>
-
-#include "sim/host.hh"
+#include <assert.h>
 
 #include "base/refcnt.hh"
-
-class Checkpoint;
+#include "sim/host.hh"
 
 /*
  * Reference counted class containing ethernet packet data
  */
-class EtherPacket : public RefCounted
+class Checkpoint;
+class PacketData : public RefCounted
 {
   public:
     uint8_t *data;
     int length;
 
   public:
-    EtherPacket() : data(NULL), length(0) {}
-    EtherPacket(std::auto_ptr<uint8_t> d, int l)
-        : data(d.release()), length(l) {}
-    ~EtherPacket() { if (data) delete [] data; }
+    PacketData() : data(NULL), length(0) { }
+    explicit PacketData(size_t size) : data(new uint8_t[size]), length(0) { }
+    PacketData(std::auto_ptr<uint8_t> d, int l)
+        : data(d.release()), length(l) { }
+    ~PacketData() { if (data) delete [] data; }
 
   public:
-    bool IsUnicast() { return data[0] == 0x00; }
-    bool IsMulticast() { return data[0] == 0x01; }
-    bool IsBroadcast() { return data[0] == 0xff; }
-
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(const std::string &base, std::ostream &os);
+    void unserialize(const std::string &base, Checkpoint *cp,
+                     const std::string &section);
 };
 
-typedef RefCountingPtr<EtherPacket> PacketPtr;
+typedef RefCountingPtr<PacketData> PacketPtr;
 
 #endif // __ETHERPKT_HH__