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.
34 .Nm md_append_record ,
49 .Nd "set of functions to dissect an mbuf chain to various data types"
58 .Fn md_initm "struct mdchain *mdp" "struct mbuf *m"
60 .Fn md_done "struct mdchain *mdp"
62 .Fn md_append_record "struct mdchain *mdp" "struct mbuf *top"
64 .Fn md_next_record "struct mdchain *mdp"
66 .Fn md_get_uint8 "struct mdchain *mdp" "u_int8_t *x"
68 .Fn md_get_uint16 "struct mdchain *mdp" "u_int16_t *x"
70 .Fn md_get_uint16be "struct mdchain *mdp" "u_int16_t *x"
72 .Fn md_get_uint16le "struct mdchain *mdp" "u_int16_t *x"
74 .Fn md_get_uint32 "struct mdchain *mdp" "u_int32_t *x"
76 .Fn md_get_uint32be "struct mdchain *mdp" "u_int32_t *x"
78 .Fn md_get_uint32le "struct mdchain *mdp" "u_int32_t *x"
80 .Fn md_get_int64 "struct mdchain *mdp" "int64_t *x"
82 .Fn md_get_int64be "struct mdchain *mdp" "int64_t *x"
84 .Fn md_get_int64le "struct mdchain *mdp" "int64_t *x"
86 .Fn md_get_mem "struct mdchain *mdp" "caddr_t target" "int size" "int type"
88 .Fn md_get_mbuf "struct mdchain *mdp" "int size" "struct mbuf **m"
90 .Fn md_get_uio "struct mdchain *mdp" "struct uio *uiop" "int size"
92 These functions are used to decompose mbuf chains to various data types.
95 structure is used as a working context
96 and should be initialized through a call of the
99 It has the following fields:
100 .Bl -tag -width "md_top"
102 .Pq Vt "struct mbuf *"
103 A pointer to the top of the parsed mbuf chain.
105 .Pq Vt "struct mbuf *"
106 A pointer to the currently parsed mbuf.
109 Offset in the current mbuf.
114 function disposes of an mbuf chain pointed to by the
116 field and sets the field to
121 appends a new mbuf chain using
123 field to form a single linked list of mbuf chains.
128 then this function behaves exactly as the
134 function extracts the next mbuf chain and disposes the current one, if any.
135 For a new mbuf chain it calls the
138 If there is no data left the function returns
143 functions perform an actual copy of the data from an mbuf chain.
148 suffixes will perform conversion to the little\- or big\-endian data formats.
153 bytes of data specified by the
155 argument from an mbuf chain.
158 argument specifies the method used to perform a copy,
159 and can be one of the following:
160 .Bl -tag -width ".Dv MB_MINLINE"
172 loop which does not call any function.
179 an actual copy is not performed
180 and the function just skips the given number of bytes.
184 functions return zero if successful,
185 otherwise an error code is returned.
188 after failure of any function,
189 an mbuf chain is left in the broken state and only the
191 function can safely be called to destroy it.
201 if (md_get_uint8(mdp, &byte) != 0 ||
202 md_get_uint16le(mdp, &length) != 0)
210 This manual page was written by
211 .An Boris Popov Aq bp@FreeBSD.org .