Path: blob/a-new-beginning/SharedDependencies/Sources/libslirp/include/sbuf.h
2 views
/* SPDX-License-Identifier: BSD-3-Clause */1/*2* Copyright (c) 1995 Danny Gasparovski.3*/45#ifndef SBUF_H6#define SBUF_H78/* How many bytes are free in the sbuf */9#define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)1011struct sbuf {12uint32_t sb_cc; /* actual chars in buffer */13uint32_t sb_datalen; /* Length of data */14char *sb_wptr; /* write pointer. points to where the next15* bytes should be written in the sbuf */16char *sb_rptr; /* read pointer. points to where the next17* byte should be read from the sbuf */18char *sb_data; /* Actual data */19};2021/* Release the sbuf */22void sbfree(struct sbuf *sb);2324/* Drop len bytes from the reading end of the sbuf */25bool sbdrop(struct sbuf *sb, size_t len);2627/* (re)Allocate sbuf buffer to store size bytes */28void sbreserve(struct sbuf *sb, size_t size);2930/*31* Try and write() to the socket, whatever doesn't get written32* append to the buffer... for a host with a fast net connection,33* this prevents an unnecessary copy of the data34* (the socket is non-blocking, so we won't hang)35*/36void sbappend(struct socket *sb, struct mbuf *mb);3738/*39* Copy data from sbuf to a normal, straight buffer40* Don't update the sbuf rptr, this will be41* done in sbdrop when the data is acked42*/43void sbcopy(struct sbuf *sb, size_t off, size_t len, char *p);4445#endif464748