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"
15 byte *data, *stop, *ebuf;
19 static inline uns pkt_len(struct pkt *p)
21 return p->stop - p->data;
24 static inline void pkt_push(struct pkt *p, uns len)
27 ASSERT(p->data >= p->buf);
30 static inline void *pkt_pop(struct pkt *p, uns len)
33 if (d + len > p->stop)
39 static inline void *pkt_peek(struct pkt *p, uns len)
42 if (d + len > p->stop)
47 static inline byte *pkt_append(struct pkt *p, uns len)
51 ASSERT(p->stop <= p->ebuf);
55 static inline void pkt_unappend(struct pkt *p, uns len)
58 ASSERT(p->stop >= p->data);
61 struct pkt *pkt_new(uns preroom, uns postroom);
62 void pkt_free(struct pkt *pkt);
69 static inline void pkt_account(struct pkt_stats *stats, struct pkt *pkt)
72 stats->bytes += pkt_len(pkt);