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.
32 .Nm md_append_record ,
47 .Nd "set of functions to dissect an mbuf chain to various data types"
56 .Fn md_initm "struct mdchain *mdp" "struct mbuf *m"
58 .Fn md_done "struct mdchain *mdp"
60 .Fn md_append_record "struct mdchain *mdp" "struct mbuf *top"
62 .Fn md_next_record "struct mdchain *mdp"
64 .Fn md_get_uint8 "struct mdchain *mdp" "uint8_t *x"
66 .Fn md_get_uint16 "struct mdchain *mdp" "uint16_t *x"
68 .Fn md_get_uint16be "struct mdchain *mdp" "uint16_t *x"
70 .Fn md_get_uint16le "struct mdchain *mdp" "uint16_t *x"
72 .Fn md_get_uint32 "struct mdchain *mdp" "uint32_t *x"
74 .Fn md_get_uint32be "struct mdchain *mdp" "uint32_t *x"
76 .Fn md_get_uint32le "struct mdchain *mdp" "uint32_t *x"
78 .Fn md_get_int64 "struct mdchain *mdp" "int64_t *x"
80 .Fn md_get_int64be "struct mdchain *mdp" "int64_t *x"
82 .Fn md_get_int64le "struct mdchain *mdp" "int64_t *x"
84 .Fn md_get_mem "struct mdchain *mdp" "caddr_t target" "int size" "int type"
86 .Fn md_get_mbuf "struct mdchain *mdp" "int size" "struct mbuf **m"
88 .Fn md_get_uio "struct mdchain *mdp" "struct uio *uiop" "int size"
90 These functions are used to decompose mbuf chains to various data types.
93 structure is used as a working context
94 and should be initialized through a call of the
97 It has the following fields:
98 .Bl -tag -width "md_top"
100 .Pq Vt "struct mbuf *"
101 A pointer to the top of the parsed mbuf chain.
103 .Pq Vt "struct mbuf *"
104 A pointer to the currently parsed mbuf.
107 Offset in the current mbuf.
112 function disposes of an mbuf chain pointed to by the
114 field and sets the field to
119 appends a new mbuf chain using
121 field to form a single linked list of mbuf chains.
126 then this function behaves exactly as the
132 function extracts the next mbuf chain and disposes the current one, if any.
133 For a new mbuf chain it calls the
136 If there is no data left the function returns
141 functions perform an actual copy of the data from an mbuf chain.
146 suffixes will perform conversion to the little\- or big\-endian data formats.
151 bytes of data specified by the
153 argument from an mbuf chain.
156 argument specifies the method used to perform a copy,
157 and can be one of the following:
158 .Bl -tag -width ".Dv MB_MINLINE"
170 loop which does not call any function.
177 an actual copy is not performed
178 and the function just skips the given number of bytes.
182 functions return zero if successful,
183 otherwise an error code is returned.
186 after failure of any function,
187 an mbuf chain is left in the broken state and only the
189 function can safely be called to destroy it.
199 if (md_get_uint8(mdp, &byte) != 0 ||
200 md_get_uint16le(mdp, &length) != 0)
208 This manual page was written by
209 .An Boris Popov Aq Mt bp@FreeBSD.org .