logo资料库

IPv6 Network Programming.pdf

第1页 / 共374页
第2页 / 共374页
第3页 / 共374页
第4页 / 共374页
第5页 / 共374页
第6页 / 共374页
第7页 / 共374页
第8页 / 共374页
资料共374页,剩余部分请下载后查看
TeamLiB
Cover
Contents
Preface
About This Book
Write Portable Application Programs
Be Security Conscious When Writing Programs
Terminology and Portability
1 Introduction
1.1 A History of IPv6 and Its Key Features
1.2 Transition from IPv4-Only Internet to IPv4/v6 Dual Stack Internet
1.3 UNIX Socket Programming
1.4 IPv6 Architecture from a Programmer's Point of View
2 IPv6 Socket Programming
2.1 AF_INET6: The Address Family for IPv6
2.2 Why Programs Need to Be Address-Family Independent?
2.3 Guidelines to Address-Family Independent Socket Programming
3 Porting Applications to Support IPv6
3.1 Making Existing Applications IPv6 Ready
3.2 Finding Where to Rewrite, Reorganizing Code
3.3 Rewriting Client Applications
3.4 Rewriting Server Applications
4 Tips in IPv6 Programming
4.1 Parsing a IPv6 Address out of String
4.2 Issues with
4.3 Issues with an IPv4 Mapped Address
4.4 bind(2) Ordering and Conflicts
4.5 How IPv4 Traffic Gets Routed to Sockets
4.6 Portability across Systems
4.7 RFCs 2292/3542, Advanced API
4.8 Platform Support Status
5 A Practical Example
5.1 Server Program Example—popa3d
5.2 Further Extensions
5.3 Client Program Example—nail
A: Coming updates to IPv6 APIs
B: RFC2553
C: RFC3493
D: RFC2292
E: RFC3542
F: IPv4-Mapped Address API Considered Harmful
G: IPv4-Mapped Addresses on the Wire Considered Harmful
H: Possible Abuse Against IPv6 Transition Technologies
I: An Extension of format for IPv6 Scoped Addresses
J: Protocol Independence Using the Sockets API
References
Index
A
B
C
D
F
G
I
L
M
N
O
P
R
S
T
U
V
W
IPv6 Network Programming
This page intentionally left blank
IPv6 Network Programming Jun-ichiro itojun Hagino Amsterdam • Boston Heidelberg London New York Oxford Paris San Diego San Francisco Singapore Sydney Tokyo
Elsevier Digital Press 30 Corporate Drive, Suite 400, Burlington, MA 01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright © 2004, Elsevier Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail: permissions@elsevier.com.uk. You may also complete your request on-line via the Elsevier homepage (http://elsevier.com), by selecting “Customer Support” and then “Obtaining Permissions.” Recognizing the importance of preserving what has been written, Elsevier prints its books on acid-free paper whenever possible. Library of Congress Cataloging-in-Publication Data British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library. ISBN: 1-55558-318-0 For information on all Elsevier Digital Press publications visit our Web site at www.books.elsevier.com 04 05 06 07 08 09 10 9 8 7 6 5 4 3 2 1 Printed in the United States of America
Contents Preface About This Book Write Portable Application Programs Be Security Conscious When Writing Programs Terminology and Portability 1 Introduction 1.1 1.2 1.3 1.4 A History of IPv6 and Its Key Features Transition from IPv4-Only Internet to IPv4/v6 Dual Stack Internet UNIX Socket Programming IPv6 Architecture from a Programmer’s Point of View 2 IPv6 Socket Programming AF_INET6: The Address Family for IPv6 2.1 2.2 Why Programs Need to Be Address-Family Independent? 2.3 Guidelines to Address-Family Independent Socket Programming 3 Porting Applications to Support IPv6 3.1 3.2 3.3 3.4 Making Existing Applications IPv6 Ready Finding Where to Rewrite, Reorganizing Code Rewriting Client Applications Rewriting Server Applications vii ix ix ix x 1 1 4 6 10 13 13 14 17 27 27 27 29 31 v
vi 4 Tips in IPv6 Programming 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 Parsing a IPv6 Address out of String Issues with “:” As a Separator Issues with an IPv4 Mapped Address bind(2) Ordering and Conflicts How IPv4 Traffic Gets Routed to Sockets Portability across Systems RFCs 2292/3542, Advanced API Platform Support Status 5 A Practical Example 5.1 5.2 5.3 Server Program Example—popa3d Further Extensions Client Program Example—nail Coming updates to IPv6 APIs RFC2553 “Basic Socket Interface Extensions for IPv6" RFC3493 “Basic Socket Interface Extensions for IPv6” RFC2292 “Advanced Sockets API for IPv6" Contents 49 49 49 50 51 52 52 54 54 59 59 62 62 81 83 125 165 A B C D E F G H I J RFC3542 “Advanced Sockets Application Program Interface (API) for IPv6" 233 IPv4-Mapped Address API Considered Harmful IPv4-Mapped Addresses on the Wire Considered Harmful Possible Abuse Against IPv6 Transition Technologies An Extension of format for IPv6 Scoped Addresses Protocol Independence Using the Sockets API References 311 317 323 333 345 355
Preface Here in Japan, it looks like the Internet is deployed everywhere. Not a day will go by without hearing the word Internet. However, many people do not know that we are very close to reaching the theoretical limit of IPv4. The theoretical limit for the number of IPv4 nodes is only 4 billion—much fewer than the world’s population. People in trains and cars send email on their cellphones using small numeric key- pads. Most of these devices are not connected to the real Internet—these cellphones do not speak the Internet Protocol. They use proprietary protocols to deliver emails to the gateway, and the gateway relays the emails to the Internet. Cellular operators are now trying to make cellphones a real VoIP device (instead of “email only” device) to avoid the costs of operating proprietary phone switches/devices/gateways and to use inexpen- sive IP routers. There are a lot of areas where the Internet and the Internet Protocol have to be deployed. For instance, we need to enable every vehicle to be connected to the IP network in order to exchange information about traffic congestion. There are plans to interconnect every consumer device to the Internet, so that vendors can collect infor- mation from the machines (such as statistics), as well as provide various value-added services. Also, we need to deploy IP to every country in the world, including highly popu- lated areas such as China, India, and Africa, so that everyone has equal opportunity to access the information on the Internet. To deploy the Internet Protocol to wider domains, the transition from IPv4 to IPv6 is critical. IPv4 cannot accommodate the needs discussed previously, due to the limitation in address space size. With IPv6 we will be able to accomodate 3.4 × 1038 nodes to the Internet—it should be enough for our lifetime (I hope). vii
分享到:
收藏