const EthPacketPtr packet() const { return p; }
EthPacketPtr packet() { return p; }
bool operator!() const { return !p; }
- operator bool() const { return p; }
+ operator bool() const { return (p != nullptr); }
int off() const { return 0; }
int pstart() const { return off() + ((const EthHdr*)p->data)->size(); }
};
const EthPacketPtr packet() const { return p; }
EthPacketPtr packet() { return p; }
bool operator!() const { return !p; }
- operator bool() const { return p; }
+ operator bool() const { return (p != nullptr); }
int off() const { return (sizeof(eth_hdr) + ((eth_hdr_vlan) ? 4 : 0)); }
int pstart() const { return (off() + get()->size()); }
};
const EthPacketPtr packet() const { return p; }
EthPacketPtr packet() { return p; }
bool operator!() const { return !p; }
- operator bool() const { return p; }
+ operator bool() const { return (p != nullptr); }
int off() const { return sizeof(eth_hdr) + ((eth_hdr_vlan) ? 4 : 0); }
int pstart() const { return off() + get()->size(); }
};
const EthPacketPtr packet() const { return p; }
EthPacketPtr packet() { return p; }
bool operator!() const { return !p; }
- operator bool() const { return p; }
+ operator bool() const { return (p != nullptr); }
int off() const { return _off; }
int pstart() const { return off() + get()->size(); }
};
const EthPacketPtr packet() const { return p; }
EthPacketPtr packet() { return p; }
bool operator!() const { return !p; }
- operator bool() const { return p; }
+ operator bool() const { return (p != nullptr); }
int off() const { return _off; }
int pstart() const { return off() + get()->size(); }
};
void
EtherLink::Link::serialize(const string &base, ostream &os)
{
- bool packet_exists = packet;
+ bool packet_exists = packet != nullptr;
paramOut(os, base + ".packet_exists", packet_exists);
if (packet_exists)
packet->serialize(base + ".packet", os);
bool packet_exists;
paramIn(cp, section, base + ".packet_exists", packet_exists);
if (packet_exists) {
- packet = new EthPacketData(16384);
+ packet = make_shared<EthPacketData>(16384);
packet->unserialize(base + ".packet", cp, section);
}
link = parent->link[number];
- packet = new EthPacketData(16384);
+ packet = make_shared<EthPacketData>(16384);
packet->unserialize("packet", cp, section);
}
#include <iosfwd>
#include <memory>
-#include "base/refcnt.hh"
#include "base/types.hh"
/*
* Reference counted class containing ethernet packet data
*/
class Checkpoint;
-class EthPacketData : public RefCounted
+class EthPacketData
{
public:
/*
const std::string §ion);
};
-typedef RefCountingPtr<EthPacketData> EthPacketPtr;
+typedef std::shared_ptr<EthPacketData> EthPacketPtr;
#endif // __ETHERPKT_HH__
while (data_len != 0 && buffer_offset >= data_len + sizeof(uint32_t)) {
EthPacketPtr packet;
- packet = new EthPacketData(data_len);
+ packet = make_shared<EthPacketData>(data_len);
packet->length = data_len;
memcpy(packet->data, data, data_len);
*/
#include <algorithm>
+#include <memory>
#include "base/inet.hh"
#include "base/trace.hh"
}
if (!txPacket) {
- txPacket = new EthPacketData(16384);
+ txPacket = std::make_shared<EthPacketData>(16384);
}
if (!txDescCache.packetWaiting()) {
rxFifo.serialize("rxfifo", os);
txFifo.serialize("txfifo", os);
- bool txPktExists = txPacket;
+ bool txPktExists = txPacket != nullptr;
SERIALIZE_SCALAR(txPktExists);
if (txPktExists)
txPacket->serialize("txpacket", os);
bool txPktExists;
UNSERIALIZE_SCALAR(txPktExists);
if (txPktExists) {
- txPacket = new EthPacketData(16384);
+ txPacket = std::make_shared<EthPacketData>(16384);
txPacket->unserialize("txpacket", cp, section);
}
* DP83820 ethernet controller. Does not support priority queueing
*/
#include <deque>
+#include <memory>
#include <string>
#include "base/debug.hh"
// clang complains about std::set being overloaded with Packet::set if
// we open up the entire namespace std
+using std::make_shared;
using std::min;
using std::ostream;
using std::string;
case txFifoBlock:
if (!txPacket) {
DPRINTF(EthernetSM, "****starting the tx of a new packet****\n");
- txPacket = new EthPacketData(16384);
+ txPacket = make_shared<EthPacketData>(16384);
txPacketBufPtr = txPacket->data;
}
/*
* Serialize the various helper variables
*/
- bool txPacketExists = txPacket;
+ bool txPacketExists = txPacket != nullptr;
SERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
txPacket->length = txPacketBufPtr - txPacket->data;
SERIALIZE_SCALAR(txPktBufPtr);
}
- bool rxPacketExists = rxPacket;
+ bool rxPacketExists = rxPacket != nullptr;
SERIALIZE_SCALAR(rxPacketExists);
if (rxPacketExists) {
rxPacket->serialize("rxPacket", os);
bool txPacketExists;
UNSERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
- txPacket = new EthPacketData(16384);
+ txPacket = make_shared<EthPacketData>(16384);
txPacket->unserialize("txPacket", cp, section);
uint32_t txPktBufPtr;
UNSERIALIZE_SCALAR(txPktBufPtr);
UNSERIALIZE_SCALAR(rxPacketExists);
rxPacket = 0;
if (rxPacketExists) {
- rxPacket = new EthPacketData(16384);
+ rxPacket = make_shared<EthPacketData>(16384);
rxPacket->unserialize("rxPacket", cp, section);
uint32_t rxPktBufPtr;
UNSERIALIZE_SCALAR(rxPktBufPtr);
PacketFifoEntry::unserialize(const string &base, Checkpoint *cp,
const string §ion)
{
- packet = new EthPacketData(16384);
+ packet = make_shared<EthPacketData>(16384);
packet->unserialize(base + ".packet", cp, section);
paramIn(cp, section, base + ".slack", slack);
paramIn(cp, section, base + ".number", number);
assert(Regs::get_TxDone_Busy(vnic->TxDone));
if (!txPacket) {
// Grab a new packet from the fifo.
- txPacket = new EthPacketData(16384);
+ txPacket = make_shared<EthPacketData>(16384);
txPacketOffset = 0;
}
SERIALIZE_SCALAR(txState);
SERIALIZE_SCALAR(txFull);
txFifo.serialize("txFifo", os);
- bool txPacketExists = txPacket;
+ bool txPacketExists = txPacket != nullptr;
SERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
txPacket->serialize("txPacket", os);
UNSERIALIZE_SCALAR(txPacketExists);
txPacket = 0;
if (txPacketExists) {
- txPacket = new EthPacketData(16384);
+ txPacket = make_shared<EthPacketData>(16384);
txPacket->unserialize("txPacket", cp, section);
UNSERIALIZE_SCALAR(txPacketOffset);
UNSERIALIZE_SCALAR(txPacketBytes);