IPv6 Core Protocols Implementation

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

The authoritative reference text on KAME and IPv6! IPv6 was introduced in 1994 and has been in development at the IETF for over 10 years. It has now reached the deployment stage. KAME, the de-facto open-source reference implementation of the IPv6 standards, played a significant role in the acceptance and the adoption of the IPv6 technology. The adoption of KAME by key companies in a wide spectrum of commercial products is a testimonial to the success of the KAME project, which concluded not long ago. This book is the first and the only one of its kind, which reveals all of the details of the KAME IPv6 protocol stack, explaining exactly what every line of code does and why it was designed that way. Through the dissection of both the code and its design, the authors illustrate how IPv6 and its related protocols have been interpreted and implemented from the specifications. This reference will demystify those ambiguous areas in the standards, which are open to interpretation and problematic in deployment, and presents solutions offered by KAME in dealing with these implementation challenges. About the Authors Qing Li is a senior architect at Blue Coat Systems, Inc. leading the design and development efforts of the next-generation IPv6 enabled secure proxy appliances. Qing holds multiple US patents. Qing is a contributing author of the book titled Handbook of Networked and Embedded Control Systems published in June 2005. He is the author of the embedded systems development book titled Real-Time Concepts for Embedded Systems published in April 2003. Tatuya Jinmei Ph.D. is a research scientist at Corporate Research & Development Center, Toshiba Corporation. He had been a core developer of the KAME project since the launch of the project through its conclusion. In 2003, he received the Ph.D. degree from Keio University, Japan, based on his work at KAME. Keiichi Shima is a senior researcher at Internet Initiative Japan Inc. He was a core developer of the KAME project from 2001 to the end of the project and developed Mobile IPv6/NEMO Basic Support protocol stack. He is now working on the new mobility stack (the SHISA stack) for BSD operating systems. IPv6 Core Protocols Implementation addresses with technical depth and clarity an IPv6 implementation on University California Berkeley Source Code Distribution (BSD), from the KAME project that was based in Japan, which is both a commercial and academic success in the world wide networking implementation market. The book begins with an overview of the KAME project and source code distribution, and then provides a concise, but thorough overview of the BSD network implementation. Then the book provides the architecture and an implementation code base component for IPv6 added to the current BSD TCP/IP Internet Protocol layer code base, the implications of the changes to the Transport Layer, and then provides a review of the BSD Socket Application Interface changes for IPv6. The authors did a very good job of representing the source code implementation and it was easy to read and comprehend, with discussion for each programmatic presentation of the code base functions and data structures. This book will be valuable to both networking architects and programmers that have to absorb and understand the implementation of IPv6 within the TCP/IP network implementation and reference model. The book was a pleasure to read and reminded me of the TCP/IP technical books by the late Dr. Richard Stevens, and afforded me the same technical depth. CTO IPv6 Forum www.ipv6forum.com ~Jim Bound. *Covering a snapshot version of KAME dated April 2003 based on FreeBSD 4.8 *Extensive line-by-line code listings with meticulous explanation of their rationale and use for the KAME snapshot implementation, which is generally applicable to most recent versions of the KAME IPv6 stack including those in recent releases of BSD variants * Numerous diagrams and illustrations help in visualizing the implementation * In-depth discussion of the standards provides intrinsic understanding of the specifications * Two CD-ROMs filled with the complete KAME IPv6 protocol stack and FreeBSD software

Author(s): Qing Li, Tatuya Jinmei, Keiichi Shima
Series: The Morgan Kaufmann Series in Networking
Publisher: Morgan Kaufmann
Year: 2006

Language: English
Pages: 968

Contents......Page 8
Foreword......Page 20
Preface......Page 22
About the Authors......Page 30
1.2 A Brief History of IPv6 and KAME......Page 32
1.3 Overview of the KAME Distribution......Page 37
1.3.2 Build Procedure......Page 38
1.4 Overview of BSD Network Implementation......Page 42
1.5.1 Typographical Conventions......Page 45
1.5.2 Sample Source Code Description......Page 46
1.5.3 Preprocessor Variables......Page 47
1.6 Mbufs and IPv6......Page 48
1.6.2 Mbuf Tagging......Page 51
1.6.3 Mbuf Requirement for IPv6......Page 55
1.6.4 Diagnosing Mbuf Chain......Page 57
2.1 Introduction......Page 60
2.2 IPv6 Addresses......Page 61
2.3 Textual Representation of IPv6 Addresses......Page 62
2.4 Address Scopes......Page 64
2.4.1 Scope Zones......Page 65
2.4.2 Zone Indices......Page 67
2.4.3 Textual Representation of Scoped Addresses......Page 69
2.4.4 Deprecation of Unicast Site-local Addresses......Page 70
2.5 IPv6 Address Format......Page 71
2.5.1 Interface Identifier Generation......Page 73
2.5.2 Notes about Address Format......Page 74
2.5.3 Multicast Address Format......Page 75
2.6 Node Address Requirements......Page 77
2.8 Code Introduction......Page 78
2.8.1 IPv6 Address Structures—in6_addr{} and sockaddr_in6{}......Page 79
2.8.2 Macros and Variables......Page 80
2.9 Handling Scope Zones......Page 82
2.9.1 Initialization of Scope Zones......Page 83
2.9.2 Scope Zone IDs......Page 84
2.9.3 Zone IDs in Address Structures......Page 85
2.9.4 Scope-Related Utility Functions......Page 88
2.10.1 ifaddr{} and in6_ifaddr{} Structures......Page 95
2.10.2 in6_ifreq{} and in6_aliasreq{} Structures......Page 98
2.10.3 Multicast Address Structures......Page 99
2.11 IPv6 Prefix Structure......Page 101
2.12 Overview of Address Manipulation Routines......Page 104
2.13.1 in6_if_up() Function......Page 107
2.13.2 in6_ifattach() Function......Page 109
2.13.3 in6_ifattach_loopback() Function......Page 112
2.13.4 in6_ifattach_linklocal() Function......Page 113
2.13.5 get_ifid() Function......Page 118
2.13.6 get_hw_ifid() Function......Page 120
2.13.7 get_rand_ifid() Function......Page 124
2.13.8 in6if_do_dad() Function......Page 125
2.14.1 in6_control() Function......Page 126
2.14.2 in6_update_ifa() Function......Page 132
2.14.3 in6_joingroup() and in6_leavegroup() Functions......Page 146
2.14.4 in6_addmulti() and in6_delmulti() Functions......Page 147
2.14.5 in6_ifinit() Function......Page 149
2.14.6 in6_ifaddloop() and in6_ifloop_request() Functions......Page 151
2.15 Deleting an IPv6 Address......Page 153
2.15.1 in6_purgeaddr() Function......Page 154
2.15.2 in6_ifremloop() Function......Page 155
2.15.3 in6_unlink_ifa() Function......Page 156
2.16 Operation with Address Configuration Utility......Page 158
3.1 Introduction......Page 162
3.2 IPv6 Header Format......Page 163
3.2.1 Comparison to the IPv4 Header......Page 164
3.3 IPv6 Extension Headers......Page 165
3.3.1 Order of Extension Headers......Page 166
3.3.2 Hop-by-Hop Options Header......Page 167
3.3.4 Routing Header......Page 168
3.3.5 Fragment Header......Page 171
3.3.6 IPv6 Options......Page 173
3.4.1 Default Address Selection......Page 175
3.4.2 Source Address Selection......Page 177
3.4.3 Destination Address Selection......Page 179
3.5 Code Introduction......Page 180
3.5.2 Header Structures......Page 182
3.5.3 ip6protosw{} Structure......Page 188
3.6 IPv6 Packet Address Information in Mbuf......Page 191
3.6.2 ip6_getdstifaddr() Function......Page 193
3.6.3 ip6_setpktaddrs() Function......Page 194
3.7 Input Processing: ip6_input() Function......Page 195
3.8 Processing Hop-by-Hop Options Header: ip6_hopopts_input() Function......Page 210
3.8.1 Processing Each Option: ip6_process_hopopts() Function......Page 211
3.8.2 Processing Unknown Option: ip6_unknown_opt() Function......Page 215
3.9 Processing Destination Options Header: dest6_input() Function......Page 216
3.10.1 Structures for Packet Reassembly......Page 218
3.10.2 frag6_input() Function......Page 221
3.11 Processing Routing Header: route6_input() Function......Page 235
3.12 Forwarding: ip6_forward() Function......Page 240
3.13.1 Source Address Selection—in6_selectsrc() Function......Page 250
3.13.2 Route Selection: ip6_selectroute() Function......Page 265
3.13.3 ip6_output() Function......Page 273
3.13.4 Make Extension Headers: ip6_copyexthdr() Function......Page 307
3.13.5 Split Headers: ip6_splithdr() Function......Page 308
3.13.6 Insert Jumbo Payload Option: ip6_insert_jumboopt() Function......Page 309
3.13.7 Fragmentation: ip6_insertfraghdr() Function......Page 312
3.13.8 Path MTU Determination: ip6_getpmtu() Function......Page 313
3.13.9 Multicast Loopback: ip6_mloopback() Function......Page 316
4.1 Introduction......Page 318
4.2 ICMPv6 Message......Page 319
4.2.1 Destination Unreachable Message......Page 320
4.2.2 Packet Too Big Message......Page 322
4.2.3 Time Exceeded Message......Page 323
4.2.4 Parameter Problem Message......Page 324
4.2.6 Echo Reply Message......Page 325
4.2.7 ICMPv6 Message Processing Rules......Page 326
4.3 Path MTU Discovery Mechanism......Page 327
4.4 Node Information Query......Page 328
4.4.1 Node Information Message Format......Page 330
4.4.4 Node Name Query......Page 332
4.4.5 Node Addresses Query......Page 334
4.5.1 Statistics......Page 335
4.6 ICMPv6 Input Processing......Page 339
4.6.1 icmp6_input() Function......Page 341
4.6.2 Notifying Errors: icmp6_notify_error() Function......Page 351
4.7.1 icmp6_mtudisc_update() Function......Page 360
4.8 ICMPv6 Output Processing......Page 363
4.8.1 Sending Error: icmp6_error() Function......Page 364
4.8.2 Error Rate Limitation: icmp6_ratelimit() Function......Page 372
4.8.3 icmp6_reflect() Function......Page 373
4.9.1 Types and Variables......Page 379
4.9.2 ping6 Command: Send Queries......Page 381
4.9.3 ping6 Command: Receive Replies......Page 386
4.9.4 ping6 Command: Print Supported Qtypes......Page 393
4.9.5 ping6 Command: Print Node Addresses......Page 396
4.9.6 Query Processing: ni6_input() Function......Page 398
4.9.7 Node Name Manipulation......Page 407
4.9.8 Create Node Addresses Reply: ni6_store_addrs() Function......Page 414
4.10 Node Information Operation......Page 418
5.1 Introduction......Page 420
5.2 Neighbor Discovery Protocol Overview......Page 421
5.3 Stateless Address Autoconfiguration Overview......Page 422
5.4 ND Protocol Messages......Page 423
5.5 Example Exchanges of ND Protocol Messages......Page 424
5.6 ND Protocol Packet Types and Formats......Page 426
5.6.1 Router Solicitation Message......Page 427
5.6.2 Router Advertisement Message......Page 428
5.6.3 Neighbor Solicitation Message......Page 432
5.6.4 Neighbor Advertisement Message......Page 433
5.6.5 Redirect Message......Page 434
5.7.1 Link-Layer Address Options......Page 436
5.7.2 Prefix Information Option......Page 437
5.7.4 MTU Option......Page 438
5.7.5 Route Information Option......Page 439
5.8 Next-Hop Determination and Address Resolution......Page 441
5.9 Neighbor Unreachability Detection Algorithm......Page 442
5.10 Stateless Address Autoconfiguration......Page 443
5.10.1 Address Formation and Address States......Page 444
5.10.2 Duplicate Address Detection Algorithm......Page 446
5.10.3 Processing Router Advertisement......Page 447
5.10.4 Privacy Extensions......Page 448
5.11 Router Specific Operation......Page 450
5.11.2 Processing Router Solicitations......Page 453
5.12.1 Sending Router Solicitations......Page 454
5.12.2 Processing Router Advertisements......Page 456
5.13 Code Introduction......Page 457
5.13.1 ND Message Definitions......Page 458
5.13.2 Neighbor Cache—llinfo_nd6{} Structure......Page 460
5.13.3 Operational Variables—nd_ifinfo{} Structure......Page 463
5.13.4 Default Router—nd_defrouter{} Structure......Page 464
5.13.5 Prefix—nd_prefix{} Structure......Page 465
5.13.7 ND Message Options—nd_opts{} Structure......Page 467
5.13.8 DAD Queue Entry—dadq{} Structure......Page 468
5.13.11 Operation Constants......Page 469
5.14.1 nd6_init() Function......Page 470
5.14.2 nd6_ifattach() Function......Page 471
5.15.1 nd6_rtrequest() Function......Page 472
5.15.2 nd6_cache_lladdr() Function......Page 483
5.15.3 nd6_lookup() Function......Page 494
5.15.4 nd6_free() Function......Page 498
5.15.5 nd6_timer() Function......Page 501
5.16.1 nd6_ns_output() Function......Page 509
5.16.2 nd6_ns_input() Function......Page 515
5.16.3 nd6_na_input() Function......Page 524
5.16.4 nd6_na_output() Function......Page 535
5.16.5 nd6_rs_input() Function......Page 541
5.16.6 nd6_ra_input() Function......Page 544
5.16.7 icmp6_redirect_input() Function......Page 552
5.16.8 icmp6_redirect_output() Function......Page 559
5.17.2 nd6_option() Function......Page 567
5.17.3 nd6_options() Function......Page 569
5.18.1 defrouter_addreq() Function......Page 571
5.18.2 defrouter_delreq() Function......Page 572
5.18.3 defrouter_addifreq() Function......Page 573
5.18.4 defrouter_delifreq() Function......Page 575
5.18.5 defrouter_lookup() Function......Page 576
5.18.6 defrouter_select() Function......Page 577
5.18.7 defrtrlist_del() Function......Page 581
5.18.8 defrtrlist_update() Function......Page 584
5.19.1 nd6_prelist_add() Function......Page 586
5.19.2 prelist_remove() Function......Page 588
5.19.3 prelist_update() Function......Page 589
5.19.5 Prefix and Address State about On-link Condition......Page 599
5.19.6 pfxlist_onlink_check() Function......Page 602
5.19.7 nd6_prefix_onlink() Function......Page 606
5.19.8 nd6_prefix_offlink() Function......Page 609
5.20.1 in6_ifadd() Function......Page 611
5.20.2 in6_tmpifadd() Function......Page 615
5.20.3 regen_tmpaddr() Function......Page 619
5.21.3 nd6_dad_stoptimer() Function......Page 621
5.21.4 nd6_dad_start() Function......Page 622
5.21.6 nd6_dad_timer() Function......Page 625
5.21.7 nd6_dad_duplicated() Function......Page 629
5.21.8 nd6_dad_ns_output() Function......Page 630
5.21.9 nd6_dad_ns_input() Function......Page 631
5.21.10 nd6_dad_na_input() Function......Page 632
5.22.1 nd6_is_addr_neighbor() Function......Page 633
5.22.2 nd6_output() Function......Page 635
5.22.3 rt6_flush() Function......Page 642
5.22.4 nd6_rtmsg() Function......Page 643
6.1 Introduction......Page 646
6.3 Pseudo Header for IPv6......Page 647
6.4 Checksum Difference between IPv4 and IPv6......Page 648
6.6.1 Protocol Control Blocks for IPv6......Page 649
6.7.1 IPv6 PCB Allocation—in_pcballoc() Function......Page 658
6.7.2 Bind Local Address—in6_pcbbind() Function......Page 661
6.7.3 Fix Remote Address—in6_pcbconnect() Function......Page 670
6.7.4 Function in6_pcbladdr()......Page 673
6.7.5 Search for a PCB Entry—in6_pcblookup_local() Function......Page 675
6.7.6 Search for IPv4-mapped PCB—in_pcblookup_local() Function......Page 678
6.7.7 Search for a PCB Entry—in6_pcblookup_hash() Function......Page 681
6.7.8 Search for IPv4-mapped PCB—in_pcblookup_hash() Function......Page 682
6.7.9 Detach an IPv6 PCB—in6_pcbdetach() Function......Page 684
6.7.10 Control Message Signaling—in6_pcbnotify() Function......Page 686
6.7.11 Flush PCB Cached Route—in6_rtchange() Function......Page 690
6.7.12 Retrieve Peer Address—in6_setpeeraddr() Function......Page 691
6.7.13 Retrieve Local Address—in6_setsockaddr() Function......Page 693
6.8.2 TCP Output......Page 694
6.8.3 Initializing Headers—tcp_fillheaders() Function......Page 700
6.8.4 TCP Input—tcp6_input() and tcp_input() Functions......Page 701
6.8.5 TCP Control Input—tcp6_ctlinput() Function......Page 706
6.8.6 TCP User Requests......Page 709
6.9.2 UDP Output—udp6_output() Function......Page 716
6.9.3 UDP Input—udp6_input() Function......Page 723
6.9.4 UDP Control Input—udp6_ctlinput() Function......Page 730
6.9.5 UDP User Requests Handling......Page 733
6.10.1 Raw IPv6 Statistics......Page 740
6.10.2 Raw IPv6 Output—rip6_output() Function......Page 741
6.10.3 Raw IPv6 Input—rip6_input() Function......Page 746
6.10.4 ICMPv6 Input—icmp6_rip6_input() Function......Page 750
6.10.5 Raw IPv6 Control Input—rip6_ctlinput() Function......Page 755
6.10.6 Raw IPv6 Control Output—rip6_ctloutput() Function......Page 756
6.10.7 Raw IPv6 User Requests Handling......Page 761
6.11 Summary of Operation with IPv4-mapped IPv6 Addresses......Page 769
6.12 Viewing IPv6 Connections with netstat......Page 774
6.13 Configuring IPv4-mapped IPv6 Address Support......Page 776
7.1 Introduction......Page 778
7.2.1 Basic Definitions......Page 779
7.2.2 Interface Identification......Page 780
7.2.3 IPv4 Communication over AF_INET6 Socket......Page 781
7.2.4 Address and Name Conversion Functions......Page 783
7.2.5 Basic Socket Options......Page 791
7.3.1 Advanced Definitions......Page 795
7.3.2 IPv6 Raw Sockets......Page 797
7.3.3 Introduction to Ancillary Data......Page 799
7.3.4 IPv6 Packet Information......Page 801
7.3.5 Manipulation of IPv6 Extension Headers......Page 804
7.3.7 Socket Extensions for the “r” Commands......Page 809
7.3.8 Summary Tables of Socket Options......Page 811
7.4.1 Code Introduction......Page 814
7.4.2 ip6_pktopts{} Structure......Page 817
7.4.3 IPv6 Socket Option Processing—ip6_ctloutput() Function......Page 821
7.4.4 Getting Socket Options—ip6_getpcbopt() Function......Page 836
7.4.5 Setting Socket Options and Ancillary Data......Page 838
7.4.6 Cleaning Up—ip6_freepcbopts() Function......Page 854
7.4.7 IPv6 Multicast Socket Options......Page 855
7.4.8 IPv6 Raw Socket Options—ip6_raw_ctloutput() Function......Page 866
7.4.9 ICMPv6 Socket Options—icmp6_ctloutput() Function......Page 869
7.4.10 Delivering Incoming Information—ip6_savecontrol() Function......Page 871
7.5.1 Example of the Send Path......Page 879
7.5.2 Example of the Receive Path......Page 881
7.6.1 inet_pton() and inet_pton6() Functions......Page 884
7.6.2 inet_ntop() and inet_ntop6() Functions......Page 890
7.6.3 getaddrinfo() Function......Page 894
7.6.4 Address Ordering Examples......Page 919
7.6.5 freeaddrinfo() Function......Page 926
7.6.6 gai_strerror() Function......Page 928
7.6.7 getnameinfo() Function......Page 929
7.6.8 Other Library Functions......Page 937
References......Page 940
Index......Page 946