📄 inet6_rthdr_space.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_rthdr_space.3,v 1.1 2003/05/28 22:04:39 jjohnstn Exp $.\" $FreeBSD: src/lib/libc/net/inet6_rthdr_space.3,v 1.8 2001/10/01 16:08:55 ru Exp $.\".Dd December 10, 1999.Dt INET6_RTHDR_SPACE 3.Os.\".Sh NAME.Nm inet6_rthdr_space ,.Nm inet6_rthdr_init ,.Nm inet6_rthdr_add ,.Nm inet6_rthdr_lasthop ,.Nm inet6_rthdr_reverse ,.Nm inet6_rthdr_segments ,.Nm inet6_rthdr_getaddr ,.Nm inet6_rthdr_getflags.Nd IPv6 Routing Header Options manipulation.\".Sh LIBRARY.Lb libc.Sh SYNOPSIS.In sys/types.h.In netinet/in.h.Ft size_t.Fn inet6_rthdr_space "int type" "int segments".Ft "struct cmsghdr *".Fn inet6_rthdr_init "void *bp" "int type".Ft int.Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags".Ft int.Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags".Ft int.Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out".Ft int.Fn inet6_rthdr_segments "const struct cmsghdr *cmsg".Ft "struct in6_addr *".Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index".Ft int.Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index".\".Sh DESCRIPTIONRFC2292 IPv6 advanced API defines eightfunctions that the application calls to build and examine a Routingheader. Four functions build a Routing header:.Bl -hang.It Fn inet6_rthdr_spacereturn #bytes required for ancillary data.It Fn inet6_rthdr_initinitialize ancillary data for Routing header.It Fn inet6_rthdr_addadd IPv6 address & flags to Routing header.It Fn inet6_rthdr_lasthopspecify the flags for the final hop.El.PpFour functions deal with a returned Routing header:.Bl -hang.It Fn inet6_rthdr_reversereverse a Routing header.It Fn inet6_rthdr_segmentsreturn #segments in a Routing header.It Fn inet6_rthdr_getaddrfetch one address from a Routing header.It Fn inet6_rthdr_getflagsfetch one flag from a Routing header.El.PpThe function prototypes for these functions are all in the.Aq Li netinet/in.hheader..\".Ss inet6_rthdr_spaceThis function returns the number of bytes required to hold a Routingheader of the specified.Fa typecontaining the specified number of.Fa segments(addresses).For an IPv6 Type 0 Routing header, the numberof segments must be between 1 and 23, inclusive. The return valueincludes the size of the cmsghdr structure that precedes the Routingheader, and any required padding..PpIf the return value is 0, then either the type of the Routing headeris not supported by this implementation or the number of segments isinvalid for this type of Routing header..PpNote: This function returns the size but does not allocate the spacerequired for the ancillary data.This allows an application toallocate a larger buffer, if other ancillary data objects aredesired, since all the ancillary data objects must be specified to.Xr sendmsg 2as a single.Li msg_controlbuffer..\".Ss inet6_rthdr_initThis function initializes the buffer pointed to by.Fa bpto contain a.Li cmsghdrstructure followed by a Routing header of the specified.Fa type .The.Li cmsg_lenmember of the.Li cmsghdrstructure is initialized to thesize of the structure plus the amount of space required by theRouting header.The.Li cmsg_leveland.Li cmsg_typemembers are also initialized as required..PpThe caller must allocate the buffer and its size can be determined bycalling.Fn inet6_rthdr_space ..PpUpon success the return value is the pointer to the.Li cmsghdrstructure, and this is then used as the first argument to the nexttwo functions.Upon an error the return value is.Dv NULL ..\".Ss inet6_rthdr_addThis function adds the address pointed to by.Fa addrto the end of theRouting header being constructed and sets the type of this hop to thevalue of.Fa flags .For an IPv6 Type 0 Routing header,.Fa flagsmust beeither.Dv IPV6_RTHDR_LOOSEor.Dv IPV6_RTHDR_STRICT ..PpIf successful, the.Li cmsg_lenmember of the.Li cmsghdrstructure isupdated to account for the new address in the Routing header and thereturn value of the function is 0.Upon an error the return value ofthe function is -1..\".Ss inet6_rthdr_lasthopThis function specifies the Strict/Loose flag for the final hop of aRouting header.For an IPv6 Type 0 Routing header,.Fa flagsmust be either.Dv IPV6_RTHDR_LOOSEor.Dv IPV6_RTHDR_STRICT ..PpThe return value of the function is 0 upon success, or -1 upon an error..PpNotice that a Routing header specifying.Li Nintermediate nodes requires.Li N+1Strict/Loose flags.This requires.Li Ncalls to.Fn inet6_rthdr_addfollowed by one call to.Fn inet6_rthdr_lasthop ..\".Ss inet6_rthdr_reverseThis function is not yet implemented.When implemented, this should behave as follows..PpThis function takes a Routing header that was received as ancillarydata(pointed to by the first argument,.Fa in )and writes a new Routingheader that sends datagrams along the reverse of that route.Botharguments are allowed to point to the same buffer(that is, the reversal can occur in place)..PpThe return value of the function is 0 on success, or -1 upon anerror..\".Ss inet6_rthdr_segmentsThis function returns the number of segments(addresses)contained inthe Routing header described by.Fa cmsg .On success the return value isbetween 1 and 23, inclusive.The return value of the function is -1 upon an error..\".Ss inet6_rthdr_getaddrThis function returns a pointer to the IPv6 address specified by.Fa index(which must have a value between 1 and the value returned by.Fn inet6_rthdr_segments )in the Routing header described by.Fa cmsg .Anapplication should first call.Fn inet6_rthdr_segmentsto obtain the number of segments in the Routing header..PpUpon an error the return value of the function is.Dv NULL ..\".Ss inet6_rthdr_getflagsThis function returns the flags value specified by.Fa index(which musthave a value between 0 and the value returned by.Fn inet6_rthdr_segments )in the Routing header described by.Fa cmsg .For an IPv6 Type 0 Routing header the return value will be either.Dv IPV6_RTHDR_LOOSEor.Dv IPV6_RTHDR_STRICT ..PpUpon an error the return value of the function is -1..PpNote: Addresses are indexed starting at 1, and flags starting at 0,to maintain consistency with the terminology and figures in RFC2460..\".Sh DIAGNOSTICS.Fn inet6_rthdr_spacereturns 0 on errors..Pp.Fn inet6_rthdr_add ,.Fn inet6_rthdr_lasthopand.Fn inet6_rthdr_reversereturn 0 on success, and returns -1 on error..Pp.Fn inet6_rthdr_initand.Fn inet6_rthdr_getaddrreturn.Dv NULLon error..Pp.Fn inet6_rthdr_segmentsand.Fn inet6_rthdr_getflagsreturn -1 on error..\".Sh EXAMPLESRFC2292 gives comprehensive examples in chapter 8..\".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..Pp.Fn inet6_rthdr_reverseis not implemented yet.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -