logo资料库

VxWorks Network Programmer's Guide 5.5[2003,364P].pdf

第1页 / 共364页
第2页 / 共364页
第3页 / 共364页
第4页 / 共364页
第5页 / 共364页
第6页 / 共364页
第7页 / 共364页
第8页 / 共364页
资料共364页,剩余部分请下载后查看
VxWorks Network Programmer's Guide
Contents
1 Overview
1.1 Introduction
1.2 Chapter Overviews
1.3 UML Notation
1.4 Recommended Reading
2 The VxWorks Network Stack
2.1 Introduction
2.2 Supported Protocols and Utilities
2.3 Setting Task Priorities Relative to the Networking Task
3 Data Link Layer Components
3.1 Introduction
3.2 Ethernet Driver Support
3.2.1 BPF, the BSD Packet Filter
3.2.2 Additional Filter Syntax
3.3 The Shared-Memory Backplane Network Driver
3.3.1 The Backplane Shared-Memory Region
Backplane Processor Numbers
The Shared-Memory Network Master
The Shared-Memory Anchor
The Shared-Memory Backplane Network Heartbeat
Shared-Memory Location
Shared Memory Size
Test-and-Set to Shared Memory
3.3.2 Interprocessor Interrupts
3.3.3 Sequential Addressing
3.3.4 Shared-Memory Backplane Network Configuration
Example Configuration
Troubleshooting
3.4 Custom Interfaces
4 Configuring the Network Stack
4.1 Introduction
4.2 Summary of Configuration Settings
4.3 Configuring the Network Stack at Build Time
4.3.1 Network Protocol Scalability
4.3.2 Configuring the ARP, IP, TCP, UDP, IGMP, and ICMP Protocols
TCP Window Sizes
4.3.3 Network Memory Pool Configuration
Setting the Number of Clusters
4.3.4 Testing Network Connections
4.3.5 Supporting Multiple Network Interface Drivers
Configuring the Network Stack for Multiple Drivers
4.4 Overview of TCP/IP
4.5 Configuring the IP-to-Link Layer Interface
4.5.1 Binding IP to the MUX (Link Layer)
4.5.2 Assigning an IP Address and Network Mask to an Interface
Interfaces Configured from the Boot Line
Assigning the Net Mask to a Network Interface
Assigning the Internet Address for a Network Interface
Manually Starting Additional Network Interfaces at Run-Time
4.5.3 Configuring IP Broadcast Addresses
4.6 IGMP under VxWorks
4.6.1 Including IGMPv2
4.6.2 IGMPv2 APIs
IGMPv2 Host Initialization
IGMPv2 Router Initialization and Termination
IGMPv2 Router Control
Working with VIFs (Ports) and ifnet Structure Pointers
4.7 Manually Editing the Routing Table
4.7.1 Adding Gateways (Routers) to a Network
4.8 Proxy ARP for Transparent Subnets
4.8.1 Proxy ARP Protocol Overview
4.8.2 Routing and the Proxy ARP Server
4.8.3 Proxy ARP and Broadcast Datagrams
4.8.4 Proxy ARP Configuration
Proxy ARP not Limited To a Shared Memory Network
Proxy ARP with Shared Memory and IP Routing
Setting Up Boot Parameters and Booting
Creating Network Connections
Routing Configuration for Multi-Homed Proxy Clients
Broadcasts Configuration for Multi-Homed Proxy Clients
4.9 Using Unnumbered Interfaces
4.10 Network Byte Order
4.11 Assigning Host Names to IP Addresses
5 Network Configuration Protocols
5.1 Introduction
5.2 BOOTP, Bootstrap Protocol
5.2.1 BOOTP Configuration
The BOOTP Database
Editing the BOOTP Database to Register a Target
5.3 DHCP, Dynamic Host Configuration Protocol
5.3.1 Including DHCP Components in an Image
5.3.2 Configuring the DHCP Client
5.3.3 Configuring DHCP Servers
Configuring the Supported DHCP Server
Adding Entries to the Database of a Running DHCP Server
Storing and Retrieving Active Network Configurations
Configuring the Unsupported DHCP Server
5.3.4 Configuring the Supported DHCP Relay Agent
5.3.5 DHCP within an Application
5.4 Boot Parameters for DHCP, BOOTP, and Network Initialization
5.4.1 Boot Parameters Returned from DHCP or BOOTP
5.5 SNMP, Simple Network Management Protocol
SNMP is a Separately Purchasable Option
6 Dynamic Routing Protocols
6.1 Introduction
6.2 RIP, Routing Information Protocol
6.2.1 VxWorks Debugging Routines for RIP
6.2.2 Configuring RIP
6.2.3 Creating an Interface Exclusion List for RIP
7 Sockets under VxWorks
7.1 Introduction
7.2 BSD Sockets under VxWorks
7.2.1 Initial Setup for a Socket under VxWorks
Creating a Socket Descriptor
Setting Socket Options
Binding a Name to a Socket
7.2.2 Creating the Connection for Stream Sockets
7.2.3 Sending and Receiving Data Using Sockets
7.2.4 Closing or Shutting Down a Socket Connection
7.2.5 Support Functions for Working with Internet Addresses
7.2.6 Datagram Sockets (UDP)
Using a Datagram Socket to Implement a Client-Server Communication System
Using a Datagram (UDP) Socket to Access IP Multicasting
7.2.7 Stream Sockets (TCP)
7.3 Zbuf Sockets
7.3.1 Zbuf Sockets and Protection Domains
7.3.2 Zbuf Calls to Send Existing Data Buffers
7.3.3 Manipulating the Zbuf Data Structure
Zbuf Byte Locations
Creating and Destroying Zbufs
Getting Data In and Out of Zbufs
Operations on Zbufs
Segments of Zbufs
Example: Manipulating Zbuf Structure
Limitations of the Zbuf Implementation
7.3.4 Zbuf Socket Calls
Standard Socket Calls and Zbuf Socket Calls
8 Remote Access Applications
8.1 Introduction
8.2 RSH, FTP, and netDrv
8.2.1 RSH
Configuring the Remote Host to Allow Access to an RSH User
8.2.2 FTP
8.2.3 Using netDrv
Using netDrv to Download Run-Time Images
8.3 NFS and nfsDrv
8.3.1 VxWorks NFS Clients
8.3.2 NFS Servers
Initializing a File System for NFS Export
Exporting a File System through NFS
Limitations of the VxWorks NFS Server
About leofs
8.4 TFTP
8.4.1 Host TFTP Server
8.4.2 VxWorks TFTP Server
8.4.3 VxWorks TFTP Client
8.5 RPC Remote Procedure Calls
8.6 rlogin
8.7 telnet
9 DNS and SNTP
9.1 Introduction
9.2 DNS: Domain Name System
9.2.1 Domain Names
9.2.2 The Resolver
Resolver Integration
Resolver Configuration
9.3 SNTP: A Time Protocol
9.3.1 Using the SNTP Client
9.3.2 Using the SNTP Server
10 Integrating a New Network Interface Driver
10.1 Introduction
10.1.1 The MUX and the OSI Network Model
10.1.2 The Protocol-to-MUX Interface
10.1.3 The Datalink-to-MUX Interface
10.1.4 How ENDs and NPT Drivers Differ
10.1.5 Managing Memory for Network Drivers and Services
10.1.6 Supporting Scatter-Gather in Your Driver
10.1.7 Early Link-Level Header Allocation in an NPT Driver
10.1.8 Buffer Alignment
10.2 END Implementation
10.2.1 END Operation
Adding an END to VxWorks
Launching the Driver
Binding to a Service
Receiving Frames in Interrupt Mode
10.2.2 The END Interface to the MUX
Data Structures Shared by the END and the MUX
END Entry Points Exported to the MUX
10.3 NPT Driver Implementation
10.3.1 NPT Driver Operation
Adding an NPT Driver to VxWorks
Launching the Driver
Responding to Network Service Bind Calls
Receiving Frames in Interrupt Mode
10.3.2 NPT Driver Interface to the MUX
Data Structures Used by the Driver
NPT Driver Entry Points Exported to the MUX
10.4 Porting a BSD Driver to the MUX
10.4.1 Remove Unit Number References
10.4.2 Create an END Object to Represent the Device
10.4.3 Implementing the Standard END or NPT Entry Points
Rewrite xxattach() to Use an npt/endLoad() Interface
The xxReceive() Routine Still Handles Task-Level Packets
Rewrite xxOutput() to Use an npt/endSend() Interface
The xxIoctl() Routine is the Basis of npt/endIoctl()
Implement All Remaining Required END or NPT Entry Points
10.5 Supporting Multiple Network Interface Drivers
10.5.1 Configuring VxWorks for Multiple Drivers
10.5.2 Starting Additional Drivers at Run-Time
10.6 Avoiding Memory Leaks
11 Integrating a New Network Service
11.1 Introduction
11.2 Writing a Network Service Sublayer
11.2.1 Interface Initialization
11.2.2 Data Structures and Resources
11.2.3 Sublayer Routines
Sending Packets
Receiving Packets
Shutting Down an Interface
Error Reporting
Flow Control
Device Control
11.3 Interfacing with the MUX
11.3.1 Service Functions Registered Using muxTkBind()
11.3.2 Service Functions Registered Using muxBind()
11.4 Adding a Socket Interface to Your Service
Process Overview
11.4.1 Implementing a Socket Back End
The Socket Functional Interface
The sockLibAdd() Function
11.4.2 Enabling Zbuf Support Within a Socket Back End
11.4.3 Implementing Socket Functions
Implementation Recommendations for the Elements of a SOCK_FUNC Table
Socket Functions Passed to iosDrvInstall()
A Using netBufLib
A.1 Introduction
A.2 How a netBufLib Pool Organizes Memory
A.3 Setting Up a Memory Pool
A.4 Storing and Using Data in Clusters
A.5 Freeing mBlks, clBlks, and Clusters
A.6 Macros for Buffer Manipulation
A.7 The netBufLib Library
B MUX/NPT Routines and Data Structures
B.1 Introduction
B.2 MUX Routines
B.2.1 muxAddrResFuncAdd()
B.2.2 muxAddrResFuncDel()
B.2.3 muxAddrResFuncGet()
B.2.4 muxAddressForm()
B.2.5 muxBind()
B.2.6 muxDevExists()
B.2.7 muxDevLoad()
B.2.8 muxDevStart()
B.2.9 muxDevStop()
B.2.10 muxDevUnload()
B.2.11 muxError()
B.2.12 muxIoctl()
B.2.13 muxMCastAddrAdd()
B.2.14 muxMCastAddrDel()
B.2.15 muxMCastAddrGet()
B.2.16 muxTkBind()
B.2.17 muxTkDrvCheck()
B.2.18 muxTkPollReceive()
B.2.19 muxTkPollSend()
B.2.20 muxTkReceive()
B.2.21 muxTkSend()
B.2.22 muxTxRestart()
B.2.23 muxUnbind()
B.3 Data Structures
B.3.1 DEV_OBJ
B.3.2 END_ERR
B.3.3 END_OBJ
B.3.4 END_QUERY
B.3.5 LL_HDR_INFO
B.3.6 M2_INTERFACETBL and M2-ID
B.3.7 mBlk
B.3.8 MULTI_TABLE
B.3.9 NET_FUNCS
C PPP, SLIP, and CSLIP
C.1 Introduction
C.2 Serial Driver Support
C.2.1 SLIP and CSLIP Configuration
C.3 PPP, the Point-to-Point Protocol for Serial Line IP
C.3.1 PPP Configuration
Setting PPP Options when Configuring VxWorks
Setting PPP Options Using an Options Structure
Setting PPP Options Using an Options File
C.3.2 Using PPP
Initializing a PPP Link
Deleting a PPP Link
PPP Authentication
Connect and Disconnect Hooks
C.3.3 Troubleshooting PPP
Link Establishment
Authentication
C.3.4 PPP Option Descriptions
Index
5.5 VxWorks ® Network Programmer’s Guide EDITION 2
Copyright  2003 Wind River Systems, Inc. All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means without the prior written permission of Wind River Systems, Inc. Wind River, the Wind River logo, Tornado, and VxWorks are registered trademarks of Wind River Systems, Inc. Any third-party trademarks referenced are the property of their respective owners. For further information regarding Wind River trademarks, please see: http://www.windriver.com/company/terms/trademark.html Corporate Headquarters Wind River Systems, Inc. 500 Wind River Way Alameda, CA 94501-1153 U.S.A. toll free (U.S.): (800) 545-WIND telephone: (510) 748-4100 facsimile: (510) 749-2010 For additional contact information, please visit the Wind River URL: http://www.windriver.com For information on how to contact Customer Support, please visit the following URL: http://www.windriver.com/support VxWorks Network Programmer’s Guide, 5.5 Edition 2 23 Apr 03 Part #: DOC-14618-ND-01
Contents 1 Overview ................................................................................................................... 1.1 1.2 1.3 1.4 Introduction ...................................................................................................... Chapter Overviews .......................................................................................... UML Notation ................................................................................................... Recommended Reading .................................................................................. 2 The VxWorks Network Stack ................................................................................... 2.1 2.2 2.3 Introduction ...................................................................................................... Supported Protocols and Utilities .................................................................. Setting Task Priorities Relative to the Networking Task ............................ 1 1 2 8 11 13 13 13 16 3 Data Link Layer Components .................................................................................. 19 3.1 3.2 Introduction ...................................................................................................... Ethernet Driver Support .................................................................................. BPF, the BSD Packet Filter ................................................................ 3.2.1 3.2.2 Additional Filter Syntax .................................................................... 19 19 20 21 iii
VxWorks Network Programmer’s Guide, 5.5 3.3 The Shared-Memory Backplane Network Driver ....................................... 3.3.1 The Backplane Shared-Memory Region ......................................... Backplane Processor Numbers ........................................................ The Shared-Memory Network Master ........................................... The Shared-Memory Anchor ........................................................... The Shared-Memory Backplane Network Heartbeat ................... Shared-Memory Location ................................................................. Shared Memory Size ......................................................................... Test-and-Set to Shared Memory ...................................................... Interprocessor Interrupts .................................................................. Sequential Addressing ...................................................................... Shared-Memory Backplane Network Configuration ................... Example Configuration ..................................................................... Troubleshooting ................................................................................. 3.3.2 3.3.3 3.3.4 3.4 Custom Interfaces ............................................................................................ 21 22 22 23 23 25 25 26 27 27 28 32 33 38 40 4 Configuring the Network Stack ............................................................................... 41 4.1 4.2 4.3 Introduction ...................................................................................................... Summary of Configuration Settings .............................................................. Configuring the Network Stack at Build Time ............................................ 4.3.1 Network Protocol Scalability ........................................................... Configuring the ARP, IP, TCP, UDP, IGMP, and ICMP Protocols 4.3.2 TCP Window Sizes ............................................................................ 4.3.3 Network Memory Pool Configuration ........................................... Setting the Number of Clusters ....................................................... Testing Network Connections ......................................................... Supporting Multiple Network Interface Drivers .......................... Configuring the Network Stack for Multiple Drivers .................. 4.3.4 4.3.5 4.4 Overview of TCP/IP ....................................................................................... 41 41 44 45 46 49 50 53 56 58 58 58 iv
Contents 4.5 4.6 4.7 4.8 Configuring the IP-to-Link Layer Interface .................................................. 4.5.1 Binding IP to the MUX (Link Layer) ............................................... Assigning an IP Address and Network Mask to an Interface ..... 4.5.2 Interfaces Configured from the Boot Line ...................................... Assigning the Net Mask to a Network Interface ........................... Assigning the Internet Address for a Network Interface ............. Manually Starting Additional Network Interfaces at Run-Time Configuring IP Broadcast Addresses .............................................. 4.5.3 IGMP under VxWorks ..................................................................................... Including IGMPv2 ............................................................................. 4.6.1 4.6.2 IGMPv2 APIs ...................................................................................... IGMPv2 Host Initialization .............................................................. IGMPv2 Router Initialization and Termination ............................ IGMPv2 Router Control .................................................................... Working with VIFs (Ports) and ifnet Structure Pointers .............. Manually Editing the Routing Table ............................................................. 4.7.1 Adding Gateways (Routers) to a Network .................................... Proxy ARP for Transparent Subnets .............................................................. Proxy ARP Protocol Overview ........................................................ 4.8.1 4.8.2 Routing and the Proxy ARP Server ................................................. Proxy ARP and Broadcast Datagrams ............................................ 4.8.3 4.8.4 Proxy ARP Configuration ................................................................. Proxy ARP not Limited To a Shared Memory Network .............. Proxy ARP with Shared Memory and IP Routing ........................ Setting Up Boot Parameters and Booting ....................................... Creating Network Connections ....................................................... Routing Configuration for Multi-Homed Proxy Clients .............. Broadcasts Configuration for Multi-Homed Proxy Clients ......... 4.9 Using Unnumbered Interfaces ....................................................................... 4.10 Network Byte Order ........................................................................................ 60 61 61 62 62 65 67 70 71 72 72 73 73 73 74 74 75 81 82 82 84 85 85 86 86 87 89 89 90 92 v
VxWorks Network Programmer’s Guide, 5.5 4.11 Assigning Host Names to IP Addresses ....................................................... 5 Network Configuration Protocols ........................................................................... Introduction ...................................................................................................... BOOTP, Bootstrap Protocol ............................................................................. BOOTP Configuration ...................................................................... 5.2.1 The BOOTP Database ........................................................................ Editing the BOOTP Database to Register a Target ........................ 93 95 95 96 97 97 98 5.1 5.2 5.3 5.4 5.5 DHCP, Dynamic Host Configuration Protocol ............................................ 5.3.1 5.3.2 5.3.3 99 Including DHCP Components in an Image ................................... 100 Configuring the DHCP Client ......................................................... 101 Configuring DHCP Servers .............................................................. 102 Configuring the Supported DHCP Server ..................................... 102 Adding Entries to the Database of a Running DHCP Server ...... 105 Storing and Retrieving Active Network Configurations ............. 106 Configuring the Unsupported DHCP Server ................................ 108 Configuring the Supported DHCP Relay Agent .......................... 109 DHCP within an Application .......................................................... 110 5.3.4 5.3.5 Boot Parameters for DHCP, BOOTP, and Network Initialization ............. 111 Boot Parameters Returned from DHCP or BOOTP ...................... 113 5.4.1 SNMP, Simple Network Management Protocol .......................................... 115 SNMP is a Separately Purchasable Option .................................... 116 6 Dynamic Routing Protocols .................................................................................... 117 6.1 6.2 Introduction ...................................................................................................... 117 RIP, Routing Information Protocol ................................................................ 117 6.2.1 VxWorks Debugging Routines for RIP ........................................... 118 Configuring RIP ................................................................................. 119 6.2.2 vi
Contents 6.2.3 Creating an Interface Exclusion List for RIP .................................. 122 7 Sockets under VxWorks .......................................................................................... 123 7.1 7.2 7.3 Introduction ...................................................................................................... 123 BSD Sockets under VxWorks .......................................................................... 124 Initial Setup for a Socket under VxWorks ...................................... 126 7.2.1 Creating a Socket Descriptor ............................................................ 126 Setting Socket Options ...................................................................... 127 Binding a Name to a Socket .............................................................. 130 Creating the Connection for Stream Sockets .................................. 132 Sending and Receiving Data Using Sockets ................................... 133 Closing or Shutting Down a Socket Connection ........................... 135 Support Functions for Working with Internet Addresses ............ 136 Datagram Sockets (UDP) .................................................................. 136 Using a Datagram Socket to Implement a Client-Server 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 Communication System ..................................................... 137 Using a Datagram (UDP) Socket to Access IP Multicasting ........ 141 Stream Sockets (TCP) ........................................................................ 146 7.2.7 Zbuf Sockets ...................................................................................................... 153 7.3.1 Zbuf Sockets and Protection Domains ............................................ 154 7.3.2 Zbuf Calls to Send Existing Data Buffers ....................................... 154 7.3.3 Manipulating the Zbuf Data Structure ........................................... 154 Zbuf Byte Locations ........................................................................... 155 Creating and Destroying Zbufs ....................................................... 156 Getting Data In and Out of Zbufs .................................................... 156 Operations on Zbufs .......................................................................... 157 Segments of Zbufs .............................................................................. 158 Example: Manipulating Zbuf Structure .......................................... 159 Limitations of the Zbuf Implementation ........................................ 163 Zbuf Socket Calls ............................................................................... 163 Standard Socket Calls and Zbuf Socket Calls ................................ 164 7.3.4 vii
VxWorks Network Programmer’s Guide, 5.5 8 Remote Access Applications .................................................................................. 169 8.1 8.2 8.3 8.4 8.5 8.6 8.7 Introduction ...................................................................................................... 169 RSH, FTP, and netDrv ..................................................................................... 170 8.2.1 RSH ...................................................................................................... 171 Configuring the Remote Host to Allow Access to an RSH User 172 FTP ....................................................................................................... 172 Using netDrv ...................................................................................... 173 Using netDrv to Download Run-Time Images ............................. 173 8.2.2 8.2.3 NFS and nfsDrv ................................................................................................ 175 8.3.1 VxWorks NFS Clients ........................................................................ 176 8.3.2 NFS Servers ........................................................................................ 178 Initializing a File System for NFS Export ....................................... 179 Exporting a File System through NFS ............................................ 179 Limitations of the VxWorks NFS Server ........................................ 180 About leofs .......................................................................................... 180 TFTP ................................................................................................................... 181 8.4.1 Host TFTP Server ............................................................................... 181 8.4.2 VxWorks TFTP Server ....................................................................... 181 VxWorks TFTP Client ....................................................................... 182 8.4.3 RPC Remote Procedure Calls ......................................................................... 182 rlogin .................................................................................................................. 182 telnet .................................................................................................................. 183 9 DNS and SNTP .......................................................................................................... 185 9.1 9.2 Introduction ...................................................................................................... 185 DNS: Domain Name System .......................................................................... 185 Domain Names .................................................................................. 186 9.2.1 viii
分享到:
收藏