class MBufChain
Defined at line 22 of file ../../zircon/kernel/object/include/object/mbuf.h
MBufChain is a container for storing a stream of bytes or a sequence of datagrams.
It's designed to back sockets and channels. Don't simultaneously store stream data and datagrams
in a single instance.
Public Methods
void MBufChain ()
Defined at line 24 of file ../../zircon/kernel/object/include/object/mbuf.h
void ~MBufChain ()
Total amount of memory occupied by MBuf objects.
Defined at line 28 of file ../../zircon/kernel/object/mbuf.cc
zx_status_t WriteStream (user_in_ptr<const char> src, size_t len, size_t * written)
Writes |len| bytes of stream data from |src| and sets |written| to number of bytes written.
Returns an error on failure, although some data may still have been written, in which case
|written| is set with the amount.
Defined at line 159 of file ../../zircon/kernel/object/mbuf.cc
zx_status_t WriteDatagram (user_in_ptr<const char> src, size_t len, size_t * written)
Writes a datagram of |len| bytes from |src| and sets |written| to number of bytes written.
This operation is atomic in that either the entire datagram is written successfully or the
chain is unmodified.
Writing a zero-length datagram is an error.
Returns an error on failure, although some data may still have been written, in which case
|written| is set with the amount.
Defined at line 116 of file ../../zircon/kernel/object/mbuf.cc
zx_status_t Read (user_out_ptr<char> dst, size_t len, bool datagram, size_t * actual)
Reads up to |len| bytes from chain into |dst|.
When |datagram| is false, the data in the chain is treated as a stream (no boundaries).
When |datagram| is true, the data in the chain is treated as a sequence of datagrams and the
call will read at most one datagram. If |len| is too small to read a complete datagram, a
partial datagram is returned and its remaining bytes are discarded.
The actual number of bytes read is returned in |actual|, and this can be non-zero even if the
read itself is an error.
Returns an error on failure. If an error occurs while copying a datagram to |dst|, the
datagram is dropped.
Defined at line 30 of file ../../zircon/kernel/object/mbuf.cc
zx_status_t Peek (user_out_ptr<char> dst, size_t len, bool datagram, size_t * actual)
Same as Read() but leaves the bytes in the chain instead of consuming them, even if
an error occurs.
Returns an error on failure.
Defined at line 34 of file ../../zircon/kernel/object/mbuf.cc
bool is_full ()
Defined at line 65 of file ../../zircon/kernel/object/include/object/mbuf.h
bool is_empty ()
Defined at line 66 of file ../../zircon/kernel/object/include/object/mbuf.h
size_t size (bool datagram)
Returns number of bytes stored in the chain.
When |datagram| is true, return only the number of bytes in the first
datagram, or 0 if in ZX_SOCKET_STREAM mode.
Defined at line 71 of file ../../zircon/kernel/object/include/object/mbuf.h
size_t max_size ()
Returns the maximum number of bytes that can be stored in the chain.
Defined at line 79 of file ../../zircon/kernel/object/include/object/mbuf.h
size_t mbuf_payload_size ()
Returns the number of bytes that will be placed in a given MBuf in the chain. Exposed only for
testing reasons.
Defined at line 83 of file ../../zircon/kernel/object/include/object/mbuf.h