X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=dev%2Fetherpkt.hh;h=7a7809f0a1f12f5ad8a34f73d0df335938d05c94;hb=86836124ed272945e9d360c068728cd03917398d;hp=9c5f004910d00cb441fbfd7a4a48619a5e6b9a9b;hpb=ac422ac949ac792da48bdd1417dc53d9850943ff;p=gem5.git diff --git a/dev/etherpkt.hh b/dev/etherpkt.hh index 9c5f00491..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" /* @@ -53,24 +52,15 @@ class PacketData : public RefCounted public: 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) { } ~PacketData() { if (data) delete [] data; } public: - const EthHdr *eth() const { return (const EthHdr *)data; } - const IpHdr *ip() const {const EthHdr *h = eth(); return h ? h->ip() : 0;} - const TcpHdr *tcp() const {const IpHdr *h = ip(); return h ? h->tcp() : 0;} - const UdpHdr *udp() const {const IpHdr *h = ip(); return h ? h->udp() : 0;} - - EthHdr *eth() { return (EthHdr *)data; } - IpHdr *ip() { EthHdr *h = eth(); return h ? h->ip() : 0; } - TcpHdr *tcp() { IpHdr *h = ip(); return h ? h->tcp() : 0; } - UdpHdr *udp() { IpHdr *h = ip(); return h ? h->udp() : 0; } - - 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;