29 #ifndef __DEV_NET_PKTFIFO_HH__ 30 #define __DEV_NET_PKTFIFO_HH__ 55 : packet(s.packet), number(s.number), slack(s.slack), priv(s.priv)
60 : packet(p), number(n), slack(0), priv(-1)
93 : _counter(0), _maxsize(max), _size(0), _reserved(0) {}
96 unsigned packets()
const {
return fifo.size(); }
97 unsigned maxsize()
const {
return _maxsize; }
98 unsigned size()
const {
return _size; }
99 unsigned reserved()
const {
return _reserved; }
100 unsigned avail()
const {
return _maxsize - _size - _reserved; }
101 bool empty()
const {
return size() <= 0; }
102 bool full()
const {
return avail() <= 0; }
107 assert(avail() >=
len);
112 iterator
begin() {
return fifo.begin(); }
113 iterator
end() {
return fifo.end(); }
115 const_iterator
begin()
const {
return fifo.begin(); }
116 const_iterator
end()
const {
return fifo.end(); }
123 assert(_reserved <= ptr->
length);
124 if (avail() < ptr->length - _reserved)
127 _size += ptr->length;
131 entry.
number = _counter++;
132 fifo.push_back(entry);
142 iterator entry = fifo.begin();
143 _size -= entry->packet->length;
144 _size -= entry->slack;
145 entry->packet = NULL;
151 for (iterator
i = begin();
i != end(); ++
i)
158 void remove(iterator
i)
160 if (
i != fifo.begin()) {
163 assert(prev != fifo.end());
164 prev->slack +=
i->packet->length;
165 prev->slack +=
i->slack;
167 _size -=
i->packet->length;
175 bool copyout(
void *dest,
unsigned offset,
unsigned len);
181 return i->number - fifo.begin()->number;
186 auto end = fifo.end();
189 return (--end)->number - i->number;
195 for (
auto i = begin();
i != end(); ++
i)
196 total +=
i->packet->length +
i->slack;
199 panic(
"total (%d) is not == to size (%d)\n", total, _size);
210 #endif // __DEV_NET_PKTFIFO_HH__ #define panic(...)
This implements a cprintf based panic() function.
int countPacketsBefore(const_iterator i) const
void unserialize(const std::string &base, CheckpointIn &cp)
fifo_list::const_iterator const_iterator
std::list< PacketFifoEntry > fifo
std::list< PacketFifoEntry > fifo_list
std::shared_ptr< EthPacketData > EthPacketPtr
unsigned reserve(unsigned len=0)
PacketFifoEntry(const PacketFifoEntry &s)
PacketFifoEntry(EthPacketPtr p, uint64_t n)
const FlagsType total
Print the total.
std::ostream CheckpointOut
fifo_list::iterator iterator
int countPacketsAfter(const_iterator i) const
const_iterator end() const
void serialize(const std::string &base, CheckpointOut &cp) const
unsigned reserved() const
bool push(EthPacketPtr ptr)
const_iterator begin() const