diff options
author | cvs2svn <admin@example.com> | 2025-04-14 17:32:06 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2025-04-14 17:32:06 +0000 |
commit | eb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch) | |
tree | edb6da6af7e865d488dc1a29309f1e1ec226e603 /src/lib/libc/net/inet6_opt_init.3 | |
parent | 247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff) | |
download | openbsd-tb_20250414.tar.gz openbsd-tb_20250414.tar.bz2 openbsd-tb_20250414.zip |
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/lib/libc/net/inet6_opt_init.3')
-rw-r--r-- | src/lib/libc/net/inet6_opt_init.3 | 328 |
1 files changed, 0 insertions, 328 deletions
diff --git a/src/lib/libc/net/inet6_opt_init.3 b/src/lib/libc/net/inet6_opt_init.3 deleted file mode 100644 index 41ba842166..0000000000 --- a/src/lib/libc/net/inet6_opt_init.3 +++ /dev/null | |||
@@ -1,328 +0,0 @@ | |||
1 | .\" $OpenBSD: inet6_opt_init.3,v 1.8 2022/03/31 17:27:16 naddy Exp $ | ||
2 | .\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (C) 2004 WIDE Project. | ||
5 | .\" All rights reserved. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the project nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .Dd $Mdocdate: March 31 2022 $ | ||
32 | .Dt INET6_OPT_INIT 3 | ||
33 | .Os | ||
34 | .\" | ||
35 | .Sh NAME | ||
36 | .Nm inet6_opt_init , | ||
37 | .Nm inet6_opt_append , | ||
38 | .Nm inet6_opt_finish , | ||
39 | .Nm inet6_opt_set_val , | ||
40 | .Nm inet6_opt_next , | ||
41 | .Nm inet6_opt_find , | ||
42 | .Nm inet6_opt_get_val | ||
43 | .Nd IPv6 Hop-by-Hop and Destination Options manipulation | ||
44 | .\" | ||
45 | .Sh SYNOPSIS | ||
46 | .In netinet/in.h | ||
47 | .Ft "int" | ||
48 | .Fn inet6_opt_init "void *extbuf" "socklen_t extlen" | ||
49 | .Ft "int" | ||
50 | .Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp" | ||
51 | .Ft "int" | ||
52 | .Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset" | ||
53 | .Ft "int" | ||
54 | .Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen" | ||
55 | .Ft "int" | ||
56 | .Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp" | ||
57 | .Ft "int" | ||
58 | .Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp" | ||
59 | .Ft "int" | ||
60 | .Fn inet6_opt_get_val "void *databuf" "socklen_t offset" "void *val" "socklen_t vallen" | ||
61 | .\" | ||
62 | .Sh DESCRIPTION | ||
63 | Building and parsing the Hop-by-Hop and Destination options is | ||
64 | complicated. | ||
65 | The advanced sockets API defines a set of functions to | ||
66 | help applications create and manipulate Hop-by-Hop and Destination | ||
67 | options. | ||
68 | These functions use the | ||
69 | formatting rules specified in Appendix B in RFC 2460, i.e. that the | ||
70 | largest field is placed last in the option. | ||
71 | The function prototypes | ||
72 | for these functions are all contained in the header file | ||
73 | .In netinet/in.h . | ||
74 | .\" | ||
75 | .Ss inet6_opt_init | ||
76 | The | ||
77 | .Fn inet6_opt_init | ||
78 | function | ||
79 | returns the number of bytes needed for an empty | ||
80 | extension header, one without any options. | ||
81 | If the | ||
82 | .Va extbuf | ||
83 | argument points to a valid section of memory | ||
84 | then the | ||
85 | .Fn inet6_opt_init | ||
86 | function also initializes the extension header's length field. | ||
87 | When attempting to initialize an extension buffer passed in the | ||
88 | .Va extbuf | ||
89 | argument, | ||
90 | .Fa extlen | ||
91 | must be a positive multiple of 8 or else the function fails and | ||
92 | returns \-1 to the caller. | ||
93 | .\" | ||
94 | .Ss inet6_opt_append | ||
95 | The | ||
96 | .Fn inet6_opt_append | ||
97 | function can perform different jobs. | ||
98 | When a valid | ||
99 | .Fa extbuf | ||
100 | argument is supplied, it appends an option to the extension buffer and | ||
101 | returns the updated total length as well as a pointer to the newly | ||
102 | created option in | ||
103 | .Fa databufp . | ||
104 | If the value | ||
105 | of | ||
106 | .Fa extbuf | ||
107 | is | ||
108 | .Dv NULL | ||
109 | then the | ||
110 | .Fn inet6_opt_append | ||
111 | function only reports what the total length would | ||
112 | be if the option were actually appended. | ||
113 | The | ||
114 | .Fa len | ||
115 | and | ||
116 | .Fa align | ||
117 | arguments specify the length of the option and the required data | ||
118 | alignment which must be used when appending the option. | ||
119 | The | ||
120 | .Fa offset | ||
121 | argument should be the length returned by the | ||
122 | .Fn inet6_opt_init | ||
123 | function or a previous call to | ||
124 | .Fn inet6_opt_append . | ||
125 | .Pp | ||
126 | The | ||
127 | .Fa type | ||
128 | argument is the 8-bit option type. | ||
129 | .Pp | ||
130 | After | ||
131 | .Fn inet6_opt_append | ||
132 | has been called, the application can use the buffer pointed to by | ||
133 | .Fa databufp | ||
134 | directly, or use | ||
135 | .Fn inet6_opt_set_val | ||
136 | to specify the data to be contained in the option. | ||
137 | .Pp | ||
138 | Option types of | ||
139 | .Li 0 | ||
140 | and | ||
141 | .Li 1 | ||
142 | are reserved for the | ||
143 | .Li Pad1 | ||
144 | and | ||
145 | .Li PadN | ||
146 | options. | ||
147 | All other values from 2 through 255 may be used by applications. | ||
148 | .Pp | ||
149 | The length of the option data is contained in an 8-bit value and so | ||
150 | may contain any value from 0 through 255. | ||
151 | .Pp | ||
152 | The | ||
153 | .Fa align | ||
154 | parameter must have a value of 1, 2, 4, or 8 and cannot exceed the | ||
155 | value of | ||
156 | .Fa len . | ||
157 | The alignment values represent no alignment, 16-bit, 32-bit and 64-bit | ||
158 | alignments respectively. | ||
159 | .\" | ||
160 | .Ss inet6_opt_finish | ||
161 | The | ||
162 | .Fn inet6_opt_finish | ||
163 | function calculates the final padding necessary to make the extension header a | ||
164 | multiple of 8 bytes, as required by the IPv6 extension header | ||
165 | specification, and returns the extension header's updated total | ||
166 | length. | ||
167 | The | ||
168 | .Fa offset | ||
169 | argument should be the length returned by | ||
170 | .Fn inet6_opt_init | ||
171 | or | ||
172 | .Fn inet6_opt_append . | ||
173 | When | ||
174 | .Fa extbuf | ||
175 | is not | ||
176 | .Dv NULL , | ||
177 | the function also sets up the appropriate padding bytes by inserting a | ||
178 | Pad1 or PadN option of the proper length. | ||
179 | .Pp | ||
180 | If the extension header is too small to contain the proper padding | ||
181 | then an error of \-1 is returned to the caller. | ||
182 | .\" | ||
183 | .Ss inet6_opt_set_val | ||
184 | The | ||
185 | .Fn inet6_opt_set_val | ||
186 | function inserts data items of various sizes into the data portion of | ||
187 | the option. | ||
188 | The | ||
189 | .Fa databuf | ||
190 | argument is a pointer to memory that was returned by the | ||
191 | .Fn inet6_opt_append | ||
192 | call and the | ||
193 | .Fa offset | ||
194 | argument specifies where the option should be placed in the | ||
195 | data buffer. | ||
196 | The | ||
197 | .Fa val | ||
198 | argument points to an area of memory containing the data to be | ||
199 | inserted into the extension header, and the | ||
200 | .Fa vallen | ||
201 | argument indicates how much data to copy. | ||
202 | .Pp | ||
203 | The caller should ensure that each field is aligned on its natural | ||
204 | boundaries as described in Appendix B of RFC 2460. | ||
205 | .Pp | ||
206 | The function returns the offset for the next field which is calculated as | ||
207 | .Fa offset | ||
208 | + | ||
209 | .Fa vallen | ||
210 | and is used when composing options with multiple fields. | ||
211 | .\" | ||
212 | .Ss inet6_opt_next | ||
213 | The | ||
214 | .Fn inet6_opt_next | ||
215 | function parses received extension headers. | ||
216 | The | ||
217 | .Fa extbuf | ||
218 | and | ||
219 | .Fa extlen | ||
220 | arguments specify the location and length of the extension header | ||
221 | being parsed. | ||
222 | The | ||
223 | .Fa offset | ||
224 | argument should either be zero, for the first option, or the length value | ||
225 | returned by a previous call to | ||
226 | .Fn inet6_opt_next | ||
227 | or | ||
228 | .Fn inet6_opt_find . | ||
229 | The return value specifies the position where to continue scanning the | ||
230 | extension buffer. | ||
231 | The option is returned in the arguments | ||
232 | .Fa typep , lenp , | ||
233 | and | ||
234 | .Fa databufp . | ||
235 | .Fa typep , lenp , | ||
236 | and | ||
237 | .Fa databufp | ||
238 | point to the 8-bit option type, the 8-bit option length and the option | ||
239 | data respectively. | ||
240 | This function does not return any PAD1 or PADN options. | ||
241 | When an error occurs or there are no more options, the return | ||
242 | value is \-1. | ||
243 | .\" | ||
244 | .Ss inet6_opt_find | ||
245 | The | ||
246 | .Fn inet6_opt_find | ||
247 | function searches the extension buffer for a particular option type, | ||
248 | passed in through the | ||
249 | .Fa type | ||
250 | argument. | ||
251 | If the option is found then the | ||
252 | .Fa lenp | ||
253 | and | ||
254 | .Fa databufp | ||
255 | arguments are updated to point to the option's length and data | ||
256 | respectively. | ||
257 | .Fa extbuf | ||
258 | and | ||
259 | .Fa extlen | ||
260 | must point to a valid extension buffer and give its length. | ||
261 | The | ||
262 | .Fa offset | ||
263 | argument can be used to search from a location anywhere in the | ||
264 | extension header. | ||
265 | .Ss inet6_opt_get_val | ||
266 | The | ||
267 | .Fn inet6_opt_get_val | ||
268 | function extracts data items of various sizes in the data portion of | ||
269 | the option. | ||
270 | The | ||
271 | .Fa databuf | ||
272 | is a pointer returned by the | ||
273 | .Fn inet6_opt_next | ||
274 | or | ||
275 | .Fn inet6_opt_find | ||
276 | functions. | ||
277 | The | ||
278 | .Fa val | ||
279 | argument points to where the data will be extracted. | ||
280 | The | ||
281 | .Fa offset | ||
282 | argument specifies from where in the data portion of the option the | ||
283 | value should be extracted; the first byte of option data is specified | ||
284 | by an offset of zero. | ||
285 | .Pp | ||
286 | It is expected that each field is aligned on its natural boundaries as | ||
287 | described in Appendix B of RFC 2460. | ||
288 | .Pp | ||
289 | The function returns the offset for the next field | ||
290 | by calculating | ||
291 | .Fa offset | ||
292 | + | ||
293 | .Fa vallen | ||
294 | which can be used when extracting option content with multiple fields. | ||
295 | Robust receivers must verify alignment before calling this function. | ||
296 | .\" | ||
297 | .Sh EXAMPLES | ||
298 | RFC 3542 gives comprehensive examples in Section 23. | ||
299 | KAME also provides examples in the | ||
300 | .Pa advapitest | ||
301 | directory of its kit. | ||
302 | .\" | ||
303 | .Sh DIAGNOSTICS | ||
304 | All the functions return | ||
305 | \-1 | ||
306 | on an error. | ||
307 | .\" | ||
308 | .Sh STANDARDS | ||
309 | .Rs | ||
310 | .%A S. Deering | ||
311 | .%A R. Hinden | ||
312 | .%D December 1998 | ||
313 | .%R RFC 2460 | ||
314 | .%T Internet Protocol, Version 6 (IPv6) Specification | ||
315 | .Re | ||
316 | .Pp | ||
317 | .Rs | ||
318 | .%A W. Stevens | ||
319 | .%A M. Thomas | ||
320 | .%A E. Nordmark | ||
321 | .%A T. Jinmei | ||
322 | .%D May 2003 | ||
323 | .%R RFC 3542 | ||
324 | .%T Advanced Sockets Application Program Interface (API) for IPv6 | ||
325 | .Re | ||
326 | .Sh HISTORY | ||
327 | The implementation first appeared in KAME advanced networking kit. | ||
328 | .\" | ||