diff options
Diffstat (limited to 'slirp2/sbuf.h')
-rw-r--r-- | slirp2/sbuf.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/slirp2/sbuf.h b/slirp2/sbuf.h new file mode 100644 index 0000000..05fa01a --- /dev/null +++ b/slirp2/sbuf.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 1995 Danny Gasparovski. + * + * Please read the file COPYRIGHT for the + * terms and conditions of the copyright. + */ + +#ifndef _SBUF_H_ +#define _SBUF_H_ + +#include "mbuf.h" +#include <stddef.h> + +/* a SBuf is a simple circular buffer used to hold RX and TX data in a struct socket + */ + +typedef struct sbuf { + unsigned sb_cc; /* actual chars in buffer */ + unsigned sb_datalen; /* Length of data */ + char* sb_wptr; /* write pointer. points to where the next + * bytes should be written in the sbuf */ + char* sb_rptr; /* read pointer. points to where the next + * byte should be read from the sbuf */ + char* sb_data; /* Actual data */ +} SBufRec, *SBuf; + +void sbuf_free (SBuf sb); +void sbuf_drop (SBuf sb, int num); +void sbuf_reserve (SBuf sb, int count); +void sbuf_append (struct socket *so, MBuf m); +void sbuf_appendsb(SBuf sb, MBuf m); +void sbuf_copy (SBuf sb, int offset, int length, char *to); + +#define sbuf_flush(sb) sbuf_drop((sb),(sb)->sb_cc) +#define sbuf_space(sb) ((sb)->sb_datalen - (sb)->sb_cc) + +#endif |