⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inet6_option_space.3

📁 Newlib 嵌入式 C库 标准实现代码
💻 3
字号:
.\" Copyright (c) 1983, 1987, 1991, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"     $Id: inet6_option_space.3,v 1.1 2003/05/28 22:04:39 jjohnstn Exp $.\" $FreeBSD: src/lib/libc/net/inet6_option_space.3,v 1.8 2001/10/01 16:08:55 ru Exp $.\".Dd December 10, 1999.Dt INET6_OPTION_SPACE 3.Os.\".Sh NAME.Nm inet6_option_space ,.Nm inet6_option_init ,.Nm inet6_option_append ,.Nm inet6_option_alloc ,.Nm inet6_option_next ,.Nm inet6_option_find.Nd IPv6 Hop-by-Hop and Destination Options manipulation.\".Sh LIBRARY.Lb libc.Sh SYNOPSIS.In sys/types.h.In netinet/in.h.Ft "int".Fn inet6_option_space "int nbytes".Ft "int".Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type".Ft "int".Fn inet6_option_append "struct cmsghdr *cmsg" "const u_int8_t *typep" "int multx" "int plusy".Ft "u_int8_t *".Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy".Ft "int".Fn inet6_option_next "const struct cmsghdr *cmsg" "u_int8_t **tptrp".Ft "int".Fn inet6_option_find "const struct cmsghdr *cmsg" "u_int8_t **tptrp" "int type".\".Sh DESCRIPTION.\"Building and parsing the Hop-by-Hop and Destination options iscomplicated due to alignment constranints, padding andancillary data manipulation.RFC2292 defines a set of functions to help the application.The function prototypes forthese functions are all in the.Aq Li netinet/in.hheader..\".Ss inet6_option_space.Fn inet6_option_spacereturns the number of bytes required to hold an option when it is stored asancillary data, including the.Li cmsghdrstructure at the beginning,and any padding at the end(to make its size a multiple of 8 bytes).The argument is the size of the structure defining the option,which must include any pad bytes at the beginning(the value.Li yin the alignment term.Dq Li "xn + y" ) ,the type byte, the length byte, and the option data..PpNote: If multiple options are stored in a single ancillary dataobject, which is the recommended technique, this functionoverestimates the amount of space required by the size of.Li N-1.Li cmsghdrstructures,where.Li Nis the number of options to be stored in the object.This is of little consequence, since it is assumed that mostHop-by-Hop option headers and Destination option headers carry onlyone option(appendix B of [RFC-2460])..\".Ss inet6_option_init.Fn inet6_option_initis called once per ancillary data object that willcontain either Hop-by-Hop or Destination options.It returns.Li 0on success or.Li -1on an error..Pp.Fa bpis a pointer to previously allocated space that will contain theancillary data object.It must be large enough to contain all theindividual options to be added by later calls to.Fn inet6_option_appendand.Fn inet6_option_alloc ..Pp.Fa cmsgpis a pointer to a pointer to a.Li cmsghdrstructure..Fa *cmsgpis initialized by this function to point to the.Li cmsghdrstructure constructed by this function in the buffer pointed to by.Fa bp ..Pp.Fa typeis either.Dv IPV6_HOPOPTSor.Dv IPV6_DSTOPTS .This.Fa typeis stored in the.Li cmsg_typemember of the.Li cmsghdrstructure pointed to by.Fa *cmsgp ..\".Ss inet6_option_appendThis function appends a Hop-by-Hop option or a Destination optioninto an ancillary data object that has been initialized by.Fn inet6_option_init .This function returns.Li 0if it succeeds or.Li -1on an error..Pp.Fa cmsgis a pointer to the.Li cmsghdrstructure that must have beeninitialized by.Fn inet6_option_init ..Pp.Fa typepis a pointer to the 8-bit option type.It is assumed that thisfield is immediately followed by the 8-bit option data length field,which is then followed immediately by the option data.The callerinitializes these three fields(the type-length-value, or TLV)before calling this function..PpThe option type must have a value from.Li 2to.Li 255 ,inclusive..Li ( 0and.Li 1are reserved for the.Li Pad1and.Li PadNoptions, respectively.).PpThe option data length must have a value between.Li 0and.Li 255 ,inclusive, and is the length of the option data that follows..Pp.Fa multxis the value.Li xin the alignment term.Dq Li xn + y .It must have a value of.Li 1 ,.Li 2 ,.Li 4 ,or.Li 8 ..Pp.Fa plusyis the value.Li yin the alignment term.Dq Li xn + y .It must have a value between.Li 0and.Li 7 ,inclusive..\".Ss inet6_option_allocThis function appends a Hop-by-Hop option or a Destination optioninto an ancillary data object that has been initialized by.Fn inet6_option_init .This function returns a pointer to the 8-bitoption type field that starts the option on success, or.Dv NULLon an error..PpThe difference between this function and.Fn inet6_option_appendis that the latter copies the contents of a previously built option intothe ancillary data object while the current function returns apointer to the space in the data object where the option's TLV mustthen be built by the caller..Pp.Fa cmsgis a pointer to the.Li cmsghdrstructure that must have beeninitialized by.Fn inet6_option_init ..Pp.Fa datalenis the value of the option data length byte for this option.This value is required as an argument to allow the function todetermine if padding must be appended at the end of the option.(The.Fn inet6_option_appendfunction does not need a data length argumentsince the option data length must already be stored by the caller.).Pp.Fa multxis the value.Li xin the alignment term.Dq Li xn + y .It must have a value of.Li 1 ,.Li 2 ,.Li 4 ,or.Li 8 ..Pp.Fa plusyis the value.Li yin the alignment term.Dq Li xn + y .It must have a value between.Li 0and.Li 7 ,inclusive..\".Ss inet6_option_nextThis function processes the next Hop-by-Hop option or Destinationoption in an ancillary data object.If another option remains to beprocessed, the return value of the function is.Li 0and.Fa *tptrppoints tothe 8-bit option type field(which is followed by the 8-bit optiondata length, followed by the option data).If no more options remainto be processed, the return value is.Li -1and.Fa *tptrpis.Dv NULL .If an error occurs, the return value is.Li -1and.Fa *tptrpis not.Dv NULL ..Pp.Fa cmsgis a pointer to.Li cmsghdrstructure of which.Li cmsg_levelequals.Dv IPPROTO_IPV6and.Li cmsg_typeequals either.Dv IPV6_HOPOPTSor.Dv IPV6_DSTOPTS ..Pp.Fa tptrpis a pointer to a pointer to an 8-bit byte and.Fa *tptrpis usedby the function to remember its place in the ancillary data objecteach time the function is called.The first time this function iscalled for a given ancillary data object,.Fa *tptrpmust be set to.Dv NULL ..PpEach time this function returns success,.Fa *tptrppoints to the 8-bitoption type field for the next option to be processed..\".Ss inet6_option_findThis function is similar to the previously described.Fn inet6_option_nextfunction, except this function lets the callerspecify the option type to be searched for, instead of alwaysreturning the next option in the ancillary data object..Fa cmsgis apointer to.Li cmsghdrstructure of which.Li cmsg_levelequals.Dv IPPROTO_IPV6and.Li cmsg_typeequals either.Dv IPV6_HOPOPTSor.Dv IPV6_DSTOPTS ..Pp.Fa tptrpis a pointer to a pointer to an 8-bit byte and.Fa *tptrpis usedby the function to remember its place in the ancillary data objecteach time the function is called.The first time this function iscalled for a given ancillary data object,.Fa *tptrpmust be set to.Dv NULL ..PaThis function starts searching for an option of the specified typebeginning after the value of.Fa *tptrp .If an option of the specifiedtype is located, this function returns.Li 0and.Fa *tptrppoints to the 8-bit option type field for the option of the specified type.If anoption of the specified type is not located, the return value is.Li -1and.Fa *tptrpis.Dv NULL .If an error occurs, the return value is.Li -1and.Fa *tptrpis not.Dv NULL ..\".Sh DIAGNOSTICS.Fn inet6_option_initand.Fn inet6_option_appendreturn.Li 0on success or.Li -1on an error..Pp.Fn inet6_option_allocreturns.Dv NULLon an error..PpOn errors,.Fn inet6_option_nextand.Fn inet6_option_findreturn.Li -1setting.Fa *tptrpto non.Dv NULLvalue..\".Sh EXAMPLESRFC2292 gives comprehensive examples in chapter 6..\".Sh SEE ALSO.Rs.%A W. Stevens.%A M. Thomas.%T "Advanced Sockets API for IPv6".%N RFC2292.%D February 1998.Re.Rs.%A S. Deering.%A R. Hinden.%T "Internet Protocol, Version 6 (IPv6) Specification".%N RFC2460.%D December 1998.Re.\".Sh HISTORYThe implementation first appeared in KAME advanced networking kit..\".Sh STANDARDSThe functionsare documented in.Dq Advanced Sockets API for IPv6(RFC2292)..\".Sh BUGSThe text was shamelessly copied from RFC2292.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -