没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Network Working Group W. Stevens
Request for Comments: 3542 M. Thomas
Obsoletes: 2292 Consultant
Category: Informational E. Nordmark
Sun
T. Jinmei
Toshiba
May 2003
Advanced Sockets Application Program Interface (API) for IPv6
Status of this Memo
This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2003). All Rights Reserved.
Abstract
This document provides sockets Application Program Interface (API) to
support "advanced" IPv6 applications, as a supplement to a separate
specification, RFC 3493. The expected applications include Ping,
Traceroute, routing daemons and the like, which typically use raw
sockets to access IPv6 or ICMPv6 header fields. This document
proposes some portable interfaces for applications that use raw
sockets under IPv6. There are other features of IPv6 that some
applications will need to access: interface identification
(specifying the outgoing interface and determining the incoming
interface), IPv6 extension headers, and path Maximum Transmission
Unit (MTU) information. This document provides API access to these
features too. Additionally, some extended interfaces to libraries
for the "r" commands are defined. The extension will provide better
backward compatibility to existing implementations that are not
IPv6-capable.
Stevens, et al. Informational [Page 1]
RFC 3542 Advanced Sockets API for IPv6 May 2003
Table of Contents
1. Introduction .............................................. 3
2. Common Structures and Definitions ......................... 5
2.1 The ip6_hdr Structure ................................ 6
2.1.1 IPv6 Next Header Values ....................... 6
2.1.2 IPv6 Extension Headers ........................ 7
2.1.3 IPv6 Options .................................. 8
2.2 The icmp6_hdr Structure .............................. 10
2.2.1 ICMPv6 Type and Code Values ................... 10
2.2.2 ICMPv6 Neighbor Discovery Definitions ......... 11
2.2.3 Multicast Listener Discovery Definitions ...... 14
2.2.4 ICMPv6 Router Renumbering Definitions ......... 14
2.3 Address Testing Macros ............................... 16
2.4 Protocols File ....................................... 16
3. IPv6 Raw Sockets .......................................... 17
3.1 Checksums ............................................ 18
3.2 ICMPv6 Type Filtering ................................ 19
3.3 ICMPv6 Verification of Received Packets .............. 22
4. Access to IPv6 and Extension Headers ...................... 22
4.1 TCP Implications ..................................... 24
4.2 UDP and Raw Socket Implications ...................... 25
5. Extensions to Socket Ancillary Data ....................... 26
5.1 CMSG_NXTHDR .......................................... 26
5.2 CMSG_SPACE ........................................... 26
5.3 CMSG_LEN ............................................. 27
6. Packet Information ........................................ 27
6.1 Specifying/Receiving the Interface ................... 28
6.2 Specifying/Receiving Source/Destination Address ...... 29
6.3 Specifying/Receiving the Hop Limit ................... 29
6.4 Specifying the Next Hop Address ...................... 30
6.5 Specifying/Receiving the Traffic Class value ......... 31
6.6 Additional Errors with sendmsg() and setsockopt() .... 32
6.7 Summary of Outgoing Interface Selection .............. 32
7. Routing Header Option ..................................... 33
7.1 inet6_rth_space ...................................... 35
7.2 inet6_rth_init ....................................... 35
7.3 inet6_rth_add ........................................ 36
7.4 inet6_rth_reverse .................................... 36
7.5 inet6_rth_segments ................................... 36
7.6 inet6_rth_getaddr .................................... 36
8. Hop-By-Hop Options ........................................ 37
8.1 Receiving Hop-by-Hop Options ......................... 38
8.2 Sending Hop-by-Hop Options ........................... 38
9. Destination Options ....................................... 39
9.1 Receiving Destination Options ........................ 39
9.2 Sending Destination Options .......................... 39
10. Hop-by-Hop and Destination Options Processing ............. 40
Stevens, et al. Informational [Page 2]
RFC 3542 Advanced Sockets API for IPv6 May 2003
10.1 inet6_opt_init ...................................... 41
10.2 inet6_opt_append .................................... 41
10.3 inet6_opt_finish .................................... 42
10.4 inet6_opt_set_val ................................... 42
10.5 inet6_opt_next ...................................... 42
10.6 inet6_opt_find ...................................... 43
10.7 inet6_opt_get_val ................................... 43
11. Additional Advanced API Functions ......................... 44
11.1 Sending with the Minimum MTU ........................ 44
11.2 Sending without Fragmentation ....................... 45
11.3 Path MTU Discovery and UDP .......................... 46
11.4 Determining the Current Path MTU .................... 47
12. Ordering of Ancillary Data and IPv6 Extension Headers ..... 48
13. IPv6-Specific Options with IPv4-Mapped IPv6 Addresses ..... 50
14. Extended interfaces for rresvport, rcmd and rexec ......... 51
14.1 rresvport_af ........................................ 51
14.2 rcmd_af ............................................. 51
14.3 rexec_af ............................................ 52
15. Summary of New Definitions ................................ 52
16. Security Considerations ................................... 56
17. Changes from RFC 2292 ..................................... 57
18. References ................................................ 59
19. Acknowledgments ........................................... 59
20. Appendix A: Ancillary Data Overview ....................... 60
20.1 The msghdr Structure ................................ 60
20.2 The cmsghdr Structure ............................... 61
20.3 Ancillary Data Object Macros ........................ 62
20.3.1 CMSG_FIRSTHDR ............................... 63
20.3.2 CMSG_NXTHDR ................................. 64
20.3.3 CMSG_DATA ................................... 65
20.3.4 CMSG_SPACE .................................. 65
20.3.5 CMSG_LEN .................................... 65
21. Appendix B: Examples Using the inet6_rth_XXX() Functions .. 65
21.1 Sending a Routing Header ............................ 65
21.2 Receiving Routing Headers ........................... 70
22. Appendix C: Examples Using the inet6_opt_XXX() Functions .. 72
22.1 Building Options .................................... 72
22.2 Parsing Received Options ............................ 74
23. Authors’ Addresses ........................................ 76
24. Full Copyright Statement .................................. 77
1. Introduction
A separate specification [RFC-3493] contains changes to the sockets
API to support IP version 6. Those changes are for TCP and UDP-based
applications. This document defines some of the "advanced" features
of the sockets API that are required for applications to take
advantage of additional features of IPv6.
Stevens, et al. Informational [Page 3]
RFC 3542 Advanced Sockets API for IPv6 May 2003
Today, the portability of applications using IPv4 raw sockets is
quite high, but this is mainly because most IPv4 implementations
started from a common base (the Berkeley source code) or at least
started with the Berkeley header files. This allows programs such as
Ping and Traceroute, for example, to compile with minimal effort on
many hosts that support the sockets API. With IPv6, however, there
is no common source code base that implementors are starting from,
and the possibility for divergence at this level between different
implementations is high. To avoid a complete lack of portability
amongst applications that use raw IPv6 sockets, some standardization
is necessary.
There are also features from the basic IPv6 specification that are
not addressed in [RFC-3493]: sending and receiving Routing headers,
Hop-by-Hop options, and Destination options, specifying the outgoing
interface, being told of the receiving interface, and control of path
MTU information.
This document updates and replaces RFC 2292. This revision is based
on implementation experience of RFC 2292, as well as some additional
extensions that have been found to be useful through the IPv6
deployment. Note, however, that further work on this document may
still be needed. Once the API specification becomes mature and is
deployed among implementations, it may be formally standardized by a
more appropriate body, such as has been done with the Basic API
[RFC-3493].
This document can be divided into the following main sections.
1. Definitions of the basic constants and structures required for
applications to use raw IPv6 sockets. This includes structure
definitions for the IPv6 and ICMPv6 headers and all associated
constants (e.g., values for the Next Header field).
2. Some basic semantic definitions for IPv6 raw sockets. For
example, a raw ICMPv4 socket requires the application to calculate
and store the ICMPv4 header checksum. But with IPv6 this would
require the application to choose the source IPv6 address because
the source address is part of the pseudo header that ICMPv6 now
uses for its checksum computation. It should be defined that with
a raw ICMPv6 socket the kernel always calculates and stores the
ICMPv6 header checksum.
3. Packet information: how applications can obtain the received
interface, destination address, and received hop limit, along with
specifying these values on a per-packet basis. There are a class
of applications that need this capability and the technique should
be portable.
Stevens, et al. Informational [Page 4]
RFC 3542 Advanced Sockets API for IPv6 May 2003
4. Access to the optional Routing header, Hop-by-Hop options, and
Destination options extension headers.
5. Additional features required for improved IPv6 application
portability.
The packet information along with access to the extension headers
(Routing header, Hop-by-Hop options, and Destination options) are
specified using the "ancillary data" fields that were added to the
4.3BSD Reno sockets API in 1990. The reason is that these ancillary
data fields are part of the Posix standard [POSIX] and should
therefore be adopted by most vendors.
This document does not address application access to either the
authentication header or the encapsulating security payload header.
Many examples in this document omit error checking in favor of
brevity and clarity.
We note that some of the functions and socket options defined in this
document may have error returns that are not defined in this
document. Some of these possible error returns will be recognized
only as implementations proceed.
Datatypes in this document follow the Posix format: intN_t means a
signed integer of exactly N bits (e.g., int16_t) and uintN_t means an
unsigned integer of exactly N bits (e.g., uint32_t).
Note that we use the (unofficial) terminology ICMPv4, IGMPv4, and
ARPv4 to avoid any confusion with the newer ICMPv6 protocol.
2. Common Structures and Definitions
Many advanced applications examine fields in the IPv6 header and set
and examine fields in the various ICMPv6 headers. Common structure
definitions for these protocol headers are required, along with
common constant definitions for the structure members.
This API assumes that the fields in the protocol headers are left in
the network byte order, which is big-endian for the Internet
protocols. If not, then either these constants or the fields being
tested must be converted at run-time, using something like htons() or
htonl().
Two new header files are defined: <netinet/ip6.h> and
<netinet/icmp6.h>.
Stevens, et al. Informational [Page 5]
剩余76页未读,继续阅读
资源评论
- wyx20100012013-05-09挺好的,不错
- luowanfu0072014-01-20很好,正好我现在在弄IPv6开发方面的。
baiyunbian
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功