X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=dev%2Fetherpkt.hh;h=7a7809f0a1f12f5ad8a34f73d0df335938d05c94;hb=244ce7fb29cbd7107a5dc0fb640a6154a091ec6e;hp=53612b830e745c811bf7e5ff63cdfd6c3f0f3b09;hpb=a58b834c8e333385f9be37eb4d343d70f8177613;p=gem5.git diff --git a/dev/etherpkt.hh b/dev/etherpkt.hh index 53612b830..7a7809f0a 100644 --- a/dev/etherpkt.hh +++ b/dev/etherpkt.hh @@ -38,7 +38,6 @@ #include #include "base/refcnt.hh" -#include "base/inet.hh" #include "sim/host.hh" /* @@ -51,34 +50,17 @@ class PacketData : public RefCounted uint8_t *data; int length; - protected: - uint8_t *_eth; - uint8_t *_ip; - uint8_t *_tcp; - uint8_t *_udp; - - void doext(); - void ext() - { - if (_eth != data) - doext(); - } - public: - PacketData() : data(NULL), length(0) { doext(); } + PacketData() : data(NULL), length(0) { } + explicit PacketData(size_t size) : data(new uint8_t[size]), length(0) { } PacketData(std::auto_ptr d, int l) - : data(d.release()), length(l) { doext(); } + : data(d.release()), length(l) { } ~PacketData() { if (data) delete [] data; } public: - EthHdr *eth() { ext(); return (EthHdr *)_eth; } - IpHdr *ip() { ext(); return (IpHdr *)_ip; } - TcpHdr *tcp() { ext(); return (TcpHdr *)_tcp; } - UdpHdr *udp() { ext(); return (UdpHdr *)_udp; } - - public: - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(const std::string &base, std::ostream &os); + void unserialize(const std::string &base, Checkpoint *cp, + const std::string §ion); }; typedef RefCountingPtr PacketPtr;