3 .\" Copyright (c) 2001 Boris Popov
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
15 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 .Nd "set of functions to build an mbuf chain from various data types"
57 .Fn mb_init "struct mbchain *mbp"
59 .Fn mb_initm "struct mbchain *mbp" "struct mbuf *m"
61 .Fn mb_done "struct mbchain *mbp"
63 .Fn mb_detach "struct mbchain *mbp"
65 .Fn mb_fixhdr "struct mbchain *mbp"
67 .Fn mb_reserve "struct mbchain *mbp" "int size"
69 .Fn mb_put_uint8 "struct mbchain *mbp" "u_int8_t x"
71 .Fn mb_put_uint16be "struct mbchain *mbp" "u_int16_t x"
73 .Fn mb_put_uint16le "struct mbchain *mbp" "u_int16_t x"
75 .Fn mb_put_uint32be "struct mbchain *mbp" "u_int32_t x"
77 .Fn mb_put_uint32le "struct mbchain *mbp" "u_int32_t x"
79 .Fn mb_put_int64be "struct mbchain *mbp" "int64_t x"
81 .Fn mb_put_int64le "struct mbchain *mbp" "int64_t x"
83 .Fn mb_put_mem "struct mbchain *mbp" "c_caddr_t source" "int size" "int type"
85 .Fn mb_put_mbuf "struct mbchain *mbp" "struct mbuf *m"
87 .Fn mb_put_uio "struct mbchain *mbp" "struct uio *uiop" "int size"
89 These functions are used to compose mbuf chains from various data types.
92 structure is used as a working context and should be initialized with a call
97 It has the following fields:
98 .Bl -tag -width ".Va mb_count"
100 .Pq Vt "struct mbuf *"
101 A pointer to the top of constructed mbuf chain.
103 .Pq Vt "struct mbuf *"
104 A pointer to the currently filled mbuf.
107 Number of bytes left in the current mbuf.
110 Total number of bytes placed in the mbuf chain.
113 User-defined function to perform a copy into mbuf;
114 useful if any unusual
115 data conversion is necessary.
118 User-supplied data which can be used in the
124 function disposes an mbuf chain pointed to by
131 function returns the value of
133 field and sets its value to
137 recalculates the length of an mbuf chain and updates the
139 field of the first mbuf in the chain.
140 It returns the calculated length.
143 ensures that the object of the length specified by the
145 argument will fit in the current mbuf (mbuf allocation is performed if
146 necessary), and advances all pointers as if the real data was placed.
148 value will point to the beginning of the reserved space.
150 of the object should not exceed
156 functions perform an actual copy of the data into mbuf chain.
161 suffixes will perform conversion to the little\- or big\-endian data formats.
166 bytes of data specified by the
168 argument to an mbuf chain.
171 argument specifies the method used to perform a copy,
172 and can be one of the following:
173 .Bl -tag -width ".Dv MB_MINLINE"
185 loop which does not call any function.
187 Do not copy any data, but just fill the destination with zero bytes.
189 Call function specified by the
198 return zero if successful and an error code otherwise.
201 after failure of any function, an mbuf chain is left in the broken state,
204 function can safely be called to destroy it.
211 mb_put_uint8(mbp, 33);
212 mb_put_uint16le(mbp, length);
213 m = m_copym(mbp->mb_top, 0, M_COPYALL, M_WAIT);
221 This manual page was written by
222 .An Boris Popov Aq bp@FreeBSD.org .