2 * Netgrind -- Packet Buffers
4 * (c) 2003 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU General Public License.
10 #include "lib/lists.h"
16 byte *data, *stop, *ebuf;
20 static inline uns pkt_len(struct pkt *p)
22 return p->stop - p->data;
25 static inline void pkt_push(struct pkt *p, uns len)
28 ASSERT(p->data >= p->buf);
31 static inline void *pkt_pop(struct pkt *p, uns len)
34 if (d + len > p->stop)
40 static inline void *pkt_peek(struct pkt *p, uns len)
43 if (d + len > p->stop)
48 static inline byte *pkt_append(struct pkt *p, uns len)
52 ASSERT(p->stop <= p->ebuf);
56 static inline void pkt_unappend(struct pkt *p, uns len)
59 ASSERT(p->stop >= p->data);
62 struct pkt *pkt_new(uns preroom, uns postroom);
63 void pkt_free(struct pkt *pkt);
70 static inline void pkt_account(struct pkt_stats *stats, struct pkt *pkt)
73 stats->bytes += pkt_len(pkt);