Skip to content

Commit

Permalink
PacketGateBase: Fixed #1003 issue, fixed IPacketCollection interface …
Browse files Browse the repository at this point in the history
…implementation when the gate is closed.
  • Loading branch information
levy committed Nov 29, 2024
1 parent 9027e00 commit 503728a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/inet/queueing/base/PacketGateBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,39 @@ void PacketGateBase::close()
updateDisplayString();
}

int PacketGateBase::getNumPackets() const
{
return isOpen() ? PacketFlowBase::getNumPackets() : 0;
}

b PacketGateBase::getTotalLength() const
{
return isOpen() ? PacketFlowBase::getTotalLength() : b(0);
}

Packet *PacketGateBase::getPacket(int index) const
{
ASSERT(isOpen());
return PacketFlowBase::getPacket(index);
}

bool PacketGateBase::isEmpty() const
{
return isOpen() ? PacketFlowBase::isEmpty() : true;
}

void PacketGateBase::removePacket(Packet *packet)
{
ASSERT(isOpen());
PacketFlowBase::removePacket(packet);
}

void PacketGateBase::removeAllPackets()
{
if (isOpen())
PacketFlowBase::removeAllPackets();
}

void PacketGateBase::processPacket(Packet *packet)
{
if (!isOpen_)
Expand Down
7 changes: 7 additions & 0 deletions src/inet/queueing/base/PacketGateBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class INET_API PacketGateBase : public PacketFlowBase, public TransparentProtoco
virtual void open() override;
virtual void close() override;

virtual int getNumPackets() const override;
virtual b getTotalLength() const override;
virtual Packet* getPacket(int index) const override;
virtual bool isEmpty() const override;
virtual void removePacket(Packet *packet) override;
virtual void removeAllPackets() override;

virtual IPassivePacketSink *getConsumer(const cGate *gate) override { return this; }
virtual IPassivePacketSource *getProvider(const cGate *gate) override { return this; }

Expand Down

0 comments on commit 503728a

Please sign in to comment.