Vxworks Network Programming Guide
Vxworks Network Programming Guide
Programmer’s Guide
5.4
Edition 1
ALL RIGHTS RESERVED. No part of this publication may be copied in any form, by photocopy,
microfilm, retrieval system, or by any other means now known or hereafter invented without the
prior written permission of Wind River Systems, Inc.
VxWorks, IxWorks, Wind River Systems, the Wind River Systems logo, wind, and Embedded Internet
are registered trademarks of Wind River Systems, Inc. Tornado, CrossWind, Personal JWorks, VxMP,
VxSim, VxVMI, WindC++, WindConfig,Wind Foundation Classes, WindNet, WindPower, WindSh,and
WindView are trademarks of Wind River Systems, Inc.
All other trademarks used in this document are the property of their respective owners.
CUSTOMER SUPPORT
If you purchased your Wind River Systems product from a distributor, please contact your
distributor to determine how to reach your technical support organization.
1 Overview ........................................................................................................................... 1
iii
VxWorks Network 5.4
Programmer’s Guide
iv
Contents
v
VxWorks Network 5.4
Programmer’s Guide
vi
Contents
vii
VxWorks Network 5.4
Programmer’s Guide
viii
Contents
ix
VxWorks Network 5.4
Programmer’s Guide
13.2.5 Boot Parameters Needed to Set Up Remote File Access and Get the
VxWorks Image .................................................................................. 192
13.2.6 Optional Boot Parameters ................................................................ 193
x
1
Overview
1.1 Introduction
This guide describes the standard VxWorks network stack, which is based on the
4.4 BSD TCP/IP release.
Chapter Overview
The first several chapters in this guide describe the network protocols supported
by the standard VxWorks network stack and explain how to configure VxWorks to
include a particular protocol or utility and how to configure the protocol or utility
itself.
Chapter 13. Booting over the Network explains how to boot VxWorks from the
network. Included are instructions for booting over the Ethernet, the serial line
(using PPP or SLIP), or the memory backplane.
Chapter 14. Upgrading 4.3 BSD Network Drivers describes the issues associated with
porting a 4.3 BSD network driver to work within the VxWorks network stack. You
can choose between two upgrade paths: you can do a simple upgrade of the driver
to the standard 4.4 BSD network driver interface; or, if your driver needs to
support features such as multiple protocols, it should be rewritten to use the MUX
interface.
The standard VxWorks network stack includes support for the following protocols
and utilities:
1
VxWorks Network 5.4
Programmer’s Guide
1.1.1 Network
One key to VxWorks’s effective relationship with host development machines is its
extensive networking facilities. By providing a fast, easy-to-use connection
between the target and host systems, the network allows full use of the host
machine as a development system, as a debugging host, and as a provider of non-
real-time services in a final system.
VxWorks currently supports loosely coupled network connections over serial lines
(using SLIP, CSLIP, or PPP) or Ethernet networks (IEEE 802.3). It also supports
tightly coupled connections over a backplane bus using shared memory. The
2
1
Overview
standard VxWorks network stack uses the Internet protocols, based on the 4.4 BSD 1
TCP/IP release, for all network communications.
In addition to the remote access provided by Tornado, VxWorks supports remote
command execution, remote login, and remote source-level debugging. VxWorks
also supports standard BSD socket calls, remote procedure calls, SNMP, remote file
access, boot parameter access from a host, and proxy ARP networks.
MUX Interface
A standard BSD 4.3 network driver can be ported to VxWorks with little effort.
However, VxWorks also supports an improved network driver interface. This
interface, called the MUX1, adds support for advanced features such as
multicasting, polled-mode Ethernet, and zero-copy transmission. This interface
also decouples the network driver and network protocol layers, allowing you add
new network drivers without the need to alter the network protocol, or to add a
new network protocol without the need to modify the existing MUX-based
network interface drivers.
Porting a driver to the MUX interface involves more work than a simple port to
BSD 4.4, but it is worth it if your driver must support multicasting, polled-mode
Ethernet, and other advanced features. More information about the process of
adding new drivers and protocols to the VxWorks network stack can be found in
the Network Protocol Toolkit User’s Guide.
Sockets
VxWorks provides standard BSD socket calls, which allow real-time VxWorks
tasks and other processes to communicate in any combination with each other over
the network. There are two sets of VxWorks socket calls: you can use sockets that
are source-compatible with BSD 4.4 UNIX, or you can use the zbuf socket interface
to streamline throughput.2
Any task can open one or more sockets, to which other sockets can be connected.
Data written to one socket of a connected pair is read, transparently, from the other
socket. Because of this transparency, the two tasks do not necessarily know
whether they are communicating with another process or VxWorks task on the
same CPU or on another CPU, or with a process running under some other host
operating system. Similarly, tasks using the zbuf socket interface are not aware of
whether their communications partners are using standard sockets, or are also
using the zbuf interface.
1. MUX: short for multiplexer, because it multiplexes access to physical network devices.
2. The TCP subset of the zbuf interface is sometimes called “zero-copy TCP.”
3
VxWorks Network 5.4
Programmer’s Guide
For information on sockets, see 2.6 Networking APIs, p.116, and the reference
entries for sockLib and zbufSockLib.
Originally designed by Sun Microsystems using the Sun ONC standard and now
available in the public domain, Remote Procedure Call (RPC) is a protocol that
allows a process on one machine to call a procedure that is executed by another
process on another machine. Thus with RPC, a VxWorks task or host machine
process can invoke routines that are executed on other VxWorks or host machines,
in any combination. For more information, see the RPC documentation (publicly
and commercially available) and the reference entry for rpcLib.
Remote file access across the network is also available. A program running on
VxWorks can use the host machine as a virtual file system. Files on any host
machine can be accessed through the network as if they were local to the VxWorks
system. A program running under VxWorks does not need to know where that file
is, or how to access it. For example, /dk/file might be a file local to the VxWorks
system, while host:file might be a file located on another machine entirely.
Conversely, VxWorks can allow host machines to use files maintained on VxWorks
just as transparently – programs running on the host need not know that the files
they use are maintained on the VxWorks system.
VxWorks includes the Sun Microsystems standard Network File System (NFS).
VxWorks systems can run NFS clients, using files from other systems that export
files over NFS, or run NFS servers, exporting files to other systems. Alternatively,
VxWorks can use the following protocols to provide transparent remote file access:
■ The Remote Shell protocol (RSH) can be used as a client, accessing files on
UNIX host systems running an RSH server.
4
1
Overview
■ The File Transfer Protocol (FTP) provides remote access to VxWorks files from 1
other systems using FTP.
■ The Trivial File Transfer Protocol (TFTP) provides read/write capability to and
from a remote server.
See the reference entries for nfsLib, remLib, ftpLib, ftpdLib, tftpLib, and
tftpdLib, and the following sections: 3.7.4 Network File System (NFS) Devices, p.124,
2.10 File Access Applications, p.153, and 3.7.5 Non-NFS Network Devices, p.126.
5
VxWorks Network 5.4
Programmer’s Guide
6
2
Configuring the VxWorks
Network Stack
2.1 Introduction
This chapter introduces the configuration and use of the standard VxWorks
network stack, the details of which are given in subsequent chapters.
Chapter 3. Data Link Layer Network Components is a discussion of the data link layer,
its general configuration needs, and network drivers. These drivers handle the
specifics of communicating over networking hardware, such as an Ethernet board,
a serial line, or even the shared-memory backplane. These drivers are the
foundation of the network stack. For information on booting VxWorks using these
drivers, see chapter 13. Booting over the Network.
After the chapter on the data link layer, chapter 4. TCP/IP Under VxWorks
introduces the MUX and the TCP/IP protocol suite. Under VxWorks, TCP/IP uses
the MUX interface to communicate with the data link layer. The purpose of the
MUX is to decouple the data link and network layers. This makes it easier to add
new network drivers under an existing protocol. It also makes it easier for an
alternative protocol to run over the standard VxWorks data link layer. For more
information on the MUX, see the Network Protocol Toolkit User’s Guide.
The discussion of IP, TCP, and UDP is primarily an overview that prepares you for
a discussion of their configuration needs under VxWorks. However, this chapter
7
VxWorks Network 5.4
Programmer’s Guide
does describe ARP and Proxy ARP in some detail. ARP provides dynamic
mapping from an IP address to the corresponding media address. Using ARP,
VxWorks implements a proxy ARP scheme that can make distinct networks
appear as one logical network. This proxy ARP scheme is an alternative to the use
of explicit subnets for accessing the shared-memory network.
8
2
Configuring the VxWorks Network Stack
VxWorks RIP server supports three modes of operation: Version 1 RIP, Version
2 RIP with multicasting, and Version 2 RIP with broadcasting.
2
■ OSPF, Open Shortest Path First
Like RIP, OSPF updates the information in the routing tables. However, OSPF
is more complex than RIP. This complexity enhances functionality. Thus, an
OSPF router can handle inter-networks that are too large for RIP.
Unfortunately, this complexity also makes OSPF much harder to configure.
DNS is a distributed database that most TCP/IP applications can use to translate
host names to IP addresses and back. DNS uses a client/server architecture. The
client side is known as the resolver. The server side is called the name server.
VxWorks provides the resolver functionality in resolvLib. DNS is discussed briefly
in chapter 8. DNS: Domain Name System. For detailed information on DNS, see
RFC-1034 and RFC-1035.
9
VxWorks Network 5.4
Programmer’s Guide
Using an SNTP client, a target can maintain the accuracy of its internal clock based
on time values reported by one or more remote sources. Using an SNTP server, the
target can provide time information to other systems. SNTP is discussed briefly in
chapter 9. SNTP: A Time Protocol.
Chapters 10. RPC: Remote Procedure Calls, 11. File Access Applications, and 12. rlogin
and telnet: Host Access Applications discuss the applications that provide remote
access over the network. VxWorks supports the following:
■ RPC (Remote Procedure Call, for distributed processing)
■ RSH (Remote Shell, for remote file access)
■ FTP (File Transfer Protocol, for remote file access)
■ NFS (Network File System, for remote file access)
■ TFTP (Trivial File Transfer Protocol, for remote file access)
■ rlogin (for remote login)
■ telnet (for remote login)
Within the configAll.h file, there are #ifdef blocks that depend on the value of a
symbolic constant whose value you might want to modify. You should insert any
change to config.h that modifies such constants before the inclusion of configAll.h.
10
2
Configuring the VxWorks Network Stack
11
VxWorks Network 5.4
Programmer’s Guide
12
3
Data Link Layer Network
Components
3.1 Introduction
The data link layer consists of drivers that directly handle communication with the
physical medium. It is their job to transmit and receive frames on the physical
network medium. VxWorks includes three different classes of data link layer
drivers: the Ethernet drivers; the Serial Line Interface Protocol (SLIP) driver; and
the shared-memory network driver, which provides communication over a
backplane. VxWorks also supports the creation of custom interface drivers.
13
VxWorks Network 5.4
Programmer’s Guide
network driver interfaces under VxWorks; eventually, all network drivers must be
ported to the MUX.
! CAUTION: The VxWorks implementation of PPP supports only IP. For more
information on PPP, see 3.4 PPP, the Point-to-Point Protocol for Serial Line IP, p.15.
Configuring your system for SLIP requires configuring both target and host
systems. See your host system’s manual for information on configuring your host.
! CAUTION: If you choose to use CSLIP, remember to make sure your host is also
using CSLIP. If your host is configured for SLIP, the VxWorks target receives
packets from the host, but the host cannot correctly decode the CSLIP packets from
the target. Eventually TCP resends the packets as SLIP packets, at which time the
host receives and acknowledge them. However, the whole process is slow. To
avoid this, configure the host and target to use the same serial protocol.
14
3
Data Link Layer Network Components
To use SLIP with your VxWorks target, make the following configuration changes
(for more information on configuring VxWorks, see the Tornado User’s Guide:
Projects):
1. Reconfigure VxWorks to include SLIP support. The relevant configuration 3
macro is INCLUDE_SLIP.
2. Specify the device to be used for the SLIP connection, the SLIP Channel
Identifier. The relevant configuration macro is SLIP_TTY. By default this is set
to 1, which sets the serial device to /tyCo/1.
3. Specify the baud rate or SLIP Channel Speed (optional). The relevant
configuration macro is SLIP_BAUDRATE. If this is not defined, SLIP uses the
baud rate defined by your serial driver.
4. Specify the SLIP Channel Capacity (optional). The relevant configuration
macro is SLIP_MTU. If you do not set this, the default value (576) will be used.
5. You can force the use of CSLIP when communicating with the host by setting
the Transmit Header Compression Flag. The relevant configuration macro is
CSLIP_ENABLE.
6. Otherwise, you can allow the use of plain SLIP unless the VxWorks target
receives a CSLIP packet (in which case the target also uses CSLIP) by setting
the Receive Header Compression Flag. The relevant configuration macro is
CSLIP_ALLOW.
! CAUTION: If you want to use VxSim for Solaris with PPP as the backend, you must
reconfigure VxWorks to remove BSD 4.3 compatability. (The relevant configuration
macro is BSD43_COMPATIBLE). Otherwise, you get an exception in the WDB task
when the target server tries to connect to the WDB agent.
15
VxWorks Network 5.4
Programmer’s Guide
■ A Link Control Protocol (LCP) for establishing, configuring, and testing the
data-link connection.
■ A family of Network Control Protocols (NCPs) for establishing and
configuring different network-layer protocols.
PPP is one method by which VxWorks can communicate with other operating
systems over a serial line connection. PPP supports Internet Protocol (IP) layer
networking software over point-to-point configurations, such as long-distance
telephone lines or RS-232 serial connections between machines. If either end of a
PPP connection has other network interfaces (such as Ethernet) and is able to
forward packets to other machines, a PPP connection can serve as a gateway
between networks.
The basic functionality provided by PPP is similar to that of the Serial Line Internet
Protocol (SLIP), with the advantage that PPP is extensible and offers various
configurable options.
PPP provides a standard method for transporting multi-protocol datagrams over
point-to-point links. It is designed for simple links which transport packets
between two peers. These links provide full-duplex, simultaneous operation and
are assumed to deliver packets in the order in which they are sent. It is intended
that PPP provide a common solution for easy connectivity among a variety of
hosts, bridges, and routers.
The following is a list of relevant Requests for Comments (RFCs) associated with
the VxWorks PPP implementation:
RFC 1332: The PPP Internet Protocol Control Protocol (IPCP)
RFC 1334: PPP Authentication Protocols
RFC 1548: The Point-to-Point Protocol (PPP)
The USENET news group, comp.protocols.ppp, is dedicated to the discussion of
PPP-related issues. Information presented in this forum is often of a general nature
(such as equipment, setup, or troubleshooting), but technical details concerning
specific PPP implementations are discussed as well.
16
3
Data Link Layer Network Components
■ PPP client and server connection support (either active or passive mode). In
active mode (default), the PPP software attempts to initiate a PPP link with the
peer. In passive mode, the PPP software waits for a peer to try to open a link.
■ Multiple unit support. Up to 16 PPP interfaces can be active at any one time. 3
■ Asynchronous character mapping. Users can specify control characters that
should be escaped by the peer upon transmission to avoid misinterpretation
by the serial driver library or by lower-level modem software.
■ Van Jacobsen (VJ) compression. This feature reduces the regular 40-byte
TCP/IP header to 3 or 8 bytes, thereby saving valuable link bandwidth.
■ Address, control, and protocol field compression. These types of compression
allow the PPP network interface driver to reduce the transmission of
extraneous PPP header information, thereby saving valuable link bandwidth.
■ Link state and link statistics querying. Internal PPP counters and protocol state
information may be obtained through query routines. This enables
applications to monitor and manage the PPP link.
■ IP address negotiation. Using IP address negotiation, one peer may assign the
other peer an IP address once the PPP link is established.
■ Echo request and reply. One peer may request that the other peer respond to
link-layer echoes. This allows for an automatic monitoring of the link’s
physical status.
■ Connect and disconnect hooks. Use of connect and disconnect hooks allows
applications to implement routines supporting modem control, dialing
software, connection scripting, etc.
■ Challenge-Handshake Authentication Protocol (CHAP) and Password
Authentication Protocol (PAP). These authentication protocols ensure that the
remote peer is authorized to establish a PPP link and that the correct IP address
is used.
■ Proxy ARP routing. Use of this feature allows hosts on the proxy-server peer’s
connected network to access the proxy-client peer without manually adding
routing entries.
For many years, transferring Internet Protocol (IP) packets over serial lines was
handled almost exclusively by the Serial Line Internet Protocol (SLIP). SLIP is a
simple link-layer driver that is installed between IP stack code and a serial driver.
17
VxWorks Network 5.4
Programmer’s Guide
While SLIP uses less object code than PPP and processes packets more efficiently
(using compressed headers in CSLIP), it can carry only IP packets and it is not
extensible. Furthermore, SLIP has several different protocol implementations that
do not always communicate smoothly with each other. Nevertheless, its general
ease of use and large installed base has made it the de facto standard for using IP
over point-to-point serial lines.
The Point-to-Point Protocol (PPP) was developed to address the shortcomings of
SLIP. Unlike SLIP, PPP is being defined and tracked by the Internet Engineering
Task Force (IETF), and the protocol specifications have been published in multiple
Request For Comments (RFC) documents. Although SLIP is still an attractive
choice for systems that only require basic IP-packet transfers, the advantages of
PPP are prompting the rapid growth of its installed base.
PPP supports several features that make it more suitable than SLIP for certain
applications:
■ Multi-Protocol Support. PPP packet framing includes a protocol field in the
header. This allows for the transfer of packets among different network-layer
protocols over a link. At present, the only protocols supported by this PPP
implementation are IP and the basic PPP protocols (LCP, IPCP, PAP, and
CHAP).
■ Extensibility. The protocol field in the frame header makes PPP able to
accommodate new protocols (both public and proprietary). The Internet
Assigned Numbers Authority (IANA) tracks the allocation of protocol field
values.
■ Error Detection. PPP framing also includes a Frame Check Sequence (FCS).
This field automatically ensures the data integrity of every packet received by
the PPP network interface driver. If an error is detected, the received packet is
dropped and an input error is recorded.
■ Link Management. The entire structure of PPP is based around the concept of a
point-to-point link which is established between peers (the local and remote
systems on either end of the serial connection). The link has several phases and
states associated with its life and is managed by its own separate protocol, the
Link Control Protocol (LCP). This concept of a link creates an environment that
can support features like option negotiation, link-layer user authentication,
link quality management, and loopback detection.
■ Option Negotiation. PPP allows for the dynamic negotiation of options between
peers. To some extent, this allows one end of the link to configure the peer. This
is especially useful in heterogeneous environments where a PPP server may
18
3
Data Link Layer Network Components
need to assign certain properties to the peer, such as the Maximum Receive
Unit (MRU).
■ Authentication. PPP supports link-layer authentication through two widely
used authentication protocols: PAP and CHAP. Both of these protocols check 3
that the peer is authorized to establish a link with the local host by sending
and/or receiving password information.
■ IP Address Negotiation. Built into the PPP control protocol for IP is the ability
to assign an IP address to a peer. This feature allows one peer to act as a PPP
server and assign addresses as clients dial in. The IP address can be re-used
when the PPP link is terminated.
While many applications do not require any of the features above, they may need
to interact with other systems that are using PPP and not SLIP. These two protocols
can not communicate with each other; this is perhaps the most compelling reason
for using PPP.
PPP provides for the encapsulation of data in frames. It also supports the following
protocols:
■ Link Control Protocol (LCP)
■ Internet Protocol Control Protocol (IPCP)
■ Password Authentication Protocol (PAP)
■ Challenge-Handshake Authentication Protocol (CHAP)
Encapsulation
19
VxWorks Network 5.4
Programmer’s Guide
The IP Control Protocol (IPCP) is the Network Control Protocol (NCP) for IP. IPCP
is responsible for configuring, enabling, and disabling the IP protocol modules on
both ends of the point-to-point link. It uses the same packet exchange mechanism
as LCP. IPCP packets are not exchanged until PPP has established a link. IPCP is
also responsible for IP address negotiation between peers. For more information,
see RFC 1332.
20
3
Data Link Layer Network Components
Configuring your environment for PPP requires both host and target software
installation and configuration. See your host’s operating system manual for
information on installing and configuring PPP on your host.1
To include the default PPP configuration, configure VxWorks with PPP support.
The relevant configuration macro is INCLUDE_PPP.
1. If your host operating system does not provide PPP facilities, you can use a publicly avail-
able implementation. One popular implementation for SunOS 4.1.x (and several other
hosts) is the PPP version 2.1.2 implementation provided in the unsupported/ppp-2.1.2
directory. This code is publicly available and is included only as a convenience. This code is
not supported by Wind River Systems.
21
VxWorks Network 5.4
Programmer’s Guide
! CAUTION: A VxWorks image that includes PPP sometimes fails to load. This
failure is due to the static maximum size of the VxWorks image allowed by the
loader. This problem can be fixed by either reducing the size of the VxWorks image
(by removing unneeded options), or by burning new boot ROMs. If you receive a
warning from vxsize when building VxWorks, or if the size of your image becomes
greater than that supported by the current setting of RAM_HIGH_ADRS, see
Creating Bootable Applications in the Tornado User’s Guide: Cross-Development for
information on how to resolve the problem.
You can include the optional DES cryptographic package for use with the
Password Authentication Protocol (PAP). The relevant configuration macro is
INCLUDE_PPP_CRYPT. It is not included in the standard Tornado Release; contact
your WRS Sales Representative to inquire about the availability of this optional
package. The DES package allows user passwords to be stored in encrypted form
on the VxWorks target. If the package is installed, then it is useful only when the
VxWorks target is acting as a PAP server, that is, when VxWorks is authenticating
the PPP peer. Its absence does not preclude the use of PAP. For detailed
information about using the DES package with PAP, see Using PAP, p.33).
This PPP implementation includes many optional features (approximately 50 in
all) that can be configured in to enable the PPP capabilities listed in 3.4.2 PPP
Features, p.16. There are three methods of configuration:
■ At compile-time, by reconfiguring VxWorks as described in the Tornado User’s
Guide: Projects. Use this method with usrPPPInit( ). (See Initializing a PPP Link,
p.26.)
■ At run-time, by filling in a PPP options structure. Use this method with
pppInit( ). (See Initializing a PPP Link, p.26.)
■ At run-time, by setting options in a PPP options file. This method is used with
either usrPPPInit( ) or pppInit( ), and can be used to change the selection of
PPP options previously configured by one of the other two configuration
methods, provided that the PPP options file can be read without using the PPP
link (for example, an options file located on a target’s local disk).
Each of these methods is described in a section that follows. For brief descriptions
of the various PPP options, see Table 3-3.
22
3
Data Link Layer Network Components
NOTE: See the Tornado User’s Guide: Projects for information on how to set some
configuration options through a graphical user interface, without directly editing
config.h.
3
First, make sure the PPP_OPTIONS_STRUCT constant is defined in config.h (it is
defined by default). Unless PPP_OPTIONS_STRUCT is defined, configuration
options in config.h cannot be enabled.
Then, specify the default serial interface that will be used by usrPPPInit( ) by
defining the PPP_TTY constant. Configuration options can be selected using
configuration constants only when usrPPPInit( ) is invoked to initialize PPP.
Specify the number of seconds usrPPPInit( ) will wait for a PPP link to be
established between a target and peer by defining the PPP_CONNECT_DELAY
constant. Table 3-1 lists the principal configuration constants used with PPP.
Constant Purpose
Table 3-2 shows the two basic formats used for configuration options in config.h.
The full list of options available with PPP appears in column 1 of Table 3-3. By
default, all of these options are disabled. To enable any PPP_OPT_option setting,
define its value to be 1 (these option constants are boolean values). To set any
PPP_STR_optionstring entry, define it by representing the desired value as a string.
For example, to set PPP_STR_MTU to 1000, enter:
#define PPP_STR_MTU "1000"
23
VxWorks Network 5.4
Programmer’s Guide
configuration file. These changes do not actually take effect until after you have
recompiled VxWorks and initialized PPP. To initialize PPP, call usrPPPInit( ). You
can make this call manually from a target shell (see Initializing a PPP Link, p.26) or
can include it in the boot code (see Booting over the Network, p.185).
PPP options may be set at run-time by filling in a PPP options structure and
passing the structure location to the pppInit( ) routine. This routine is the standard
entry point for initializing a PPP link (see Initializing a PPP Link, p.26).
The PPP options structure is typedefed to PPP_OPTIONS, and its definition is
located in h/netinet/ppp/options.h, which is included through h/pppLib.h.
The first field of the structure is an integer, flags, which is a bit field that holds the
ORed value of the OPT_option macros displayed in column 2 of Table 3-3.
Definitions for OPT_option are located in h/netinet/ppp/options.h. The remaining
structure fields in column 2 are character pointers to the various PPP options
specified by a string.
The following code fragment is one way to set configuration options using the PPP
options structure. It initializes a PPP interface that uses the target’s second serial
port (/tyCo/1). The local IP address is 90.0.0.1; the IP address of the remote peer is
90.0.0.10. The baud rate is the default rate for the tty device. The VJ compression
and authentication options have been disabled, and LCP (Link Control Protocol)
echo requests have been enabled.
PPP_OPTIONS pppOpt; /* PPP configuration options */
void routine ()
{
pppOpt.flags = OPT_PASSIVE_MODE | OPT_NO_PAP | OPT_NO_CHAP |
OPT_NO_VJ;
pppOpt.lcp_echo_interval = "30";
pppOpt.lcp_echo_failure = "10";
24
3
Data Link Layer Network Components
PPP options are most conveniently set using an options file. There is one
restriction: the options file must be readable by the target without there being an 3
active PPP link. Therefore the target must either have a local disk or RAM disk or
an additional network connection. For more information about using file systems,
see VxWorks Programmer’s Guide: Local File Systems.
This configuration method can be used with either usrPPPInit( ) or pppInit( ). It
also can be used to modify the selection of PPP options previously configured
using configuration constants in config.h or the option structure PPP_OPTION.
When using usrPPPInit( ) to initialize PPP, define the configuration constant
PPP_OPTIONS_FILE to be the absolute path name of the options file (NULL by
default). When using pppInit( ), pass in a character string that specifies the
absolute path name of the options file.
The options file format is one option per line; comment lines begin with #. For a
description of option syntax, see the manual entry for pppInit( ).
The following code fragment generates the same results as the code example in
Selecting PPP Options Using an Options Structure, p.24. The difference is that the
configuration options are obtained from a file rather than a structure.
pppFile = "mars:/tmp/ppp_options"; /* PPP config. options file */
void routine ()
{
pppInit (0, "/tyCo/1", "90.0.0.1", "90.0.0.10", 0, NULL, pppFile);
}
After it is configured and initialized, PPP attaches itself into the VxWorks TCP/IP
stack at the driver (link) layer. After a PPP link has been established with the
remote peer, all normal VxWorks IP networking facilities are available; the PPP
connection is transparent to the user.
25
VxWorks Network 5.4
Programmer’s Guide
You can use host names in usrPPPInit( ) provided the hosts have been previously
added to the host database. For example, you can call usrPPPInit( ) in the
following way:
usrPPPInit ("ppp=/tyCo/1,38400", 1, "147.11.90.1", "147.11.90.199")
The usrPPPInit( ) routine calls pppInit( ), which initializes PPP with the
configuration options that were specified at compile-time (see Selecting PPP
Options By Configuring VxWorks, p.22). The pppInit( ) routine can be called
multiple times to initialize multiple channels.2 The connection timeout is specified
by PPP_CONNECT_DELAY. The return value of this routine indicates whether the
link has been successfully established—if the return value is OK, the network
connection should be fully operational.
The pppInit( ) routine is the standard entry point for initializing a PPP link. All
available PPP options can be set using parameters specified for this routine (see
Selecting PPP Options Using an Options Structure, p.24). Unlike usrPPPInit( ), the
return value of pppInit( ) does not indicate the status of the PPP link; it merely
reports whether the link could be initialized. To check whether the link is actually
2. The usrPPPInit( ) routine can specify the unit number as a parameter. If this number is
omitted, PPP defaults to 0.
26
3
Data Link Layer Network Components
established, call pppInfoGet( ) and make sure that the state of IPCP is OPENED.
The following code fragment demonstrates use of this mechanism for PPP unit 2:
PPP_INFO pppInfo;
3
if ((pppInfoGet (2, &pppInfo) == OK) &&
(pppInfo.ipcp_fsm.state == OPENED))
return (OK); /* link established */
else
return (ERROR); /* link down */
PPP Options
Table 3-3 lists all the configuration options supported by PPP. Each option is
shown in its three forms, corresponding to the configuration methods explained in
the following sections:
Column 1: Selecting PPP Options By Configuring VxWorks, p.22
Column 2: Selecting PPP Options Using an Options Structure, p.24
Column 3: Setting PPP Options Using an Options File, p.25.
27
VxWorks Network 5.4
Programmer’s Guide
A brief description of each option follows the three formats. Configuration options
specified in the options file PPP_OPTIONS_FILE take precedence over any
previously set in config.h or set by passing the structure PPP_OPTIONS to
pppInit( ). For example:
■ If VxWorks is configured with the use of PAP negated, a subsequent setting of
require_pap in PPP_OPTIONS_FILE overrides the earlier setting enabling PAP
authentication. The relevant configuration macro is PPP_OPT_NO_PAP.
■ If char * netmask has been passed in the options structure PPP_OPTIONS to
pppInit( ) with a value of FFFF0000, and netmask FFFFFF00 is passed in
PPP_OPTIONS_FILE to usrPPPInit( ), the network mask value is set to
FFFFFF00.
Options Description
Set in config.h Set using options structure Set using options file
28
3
Data Link Layer Network Components
Options Description
Set in config.h Set using options structure Set using options file
3
PPP_OPT_NO_IP OPT_NO_IP no_ip Disable IP address negotiation in
IPCP.
PPP_STR_ASYNCMAP char * asyncmap asyncmap value Set the desired async map to the
specified value.
PPP_STR_CHAP_FILE char * chap_file chap_file file Get CHAP secrets from the
specified file. This option is
necessary if either peer requires
CHAP authentication.
29
VxWorks Network 5.4
Programmer’s Guide
Options Description
Set in config.h Set using options structure Set using options file
PPP_STR_CHAP_INTERVAL char * chap_interval chap_interval value Set the interval in seconds for
CHAP rechallenge to the specified
value.
PPP_STR_CHAP_RESTART char * chap_restart chap_restart value Set the timeout in seconds for the
CHAP negotiation to the specified
value.
PPP_STR_IPCP_MAX_FAILURE char * ipcp_max_failure ipcp_max_failure value Set the maximum number of IPCP
configuration NAKs to the
specified value.
PPP_STR_IPCP_RESTART char * ipcp_restart ipcp_restart value Set the timeout in seconds for the
IPCP negotiation to the specified
value.
PPP_STR_LCP_ECHO_FAILURE char * lcp_echo_failure lcp_echo_failure value Set the maximum consecutive LCP
echo failures to the specified value.
PPP_STR_LCP_ECHO_INTERVAL char * lcp_echo_interval lcp_echo_interval value Set the interval in seconds for the
LCP negotiation to the specified
value.
PPP_STR_LCP_MAX_FAILURE char * lcp_max_failure lcp_max_failure value Set the maximum number of LCP
configuration NAKs to the
specified value.
PPP_STR_LCP_RESTART char * lcp_restart lcp_restart value Set the timeout in seconds for the
LCP negotiation to the specified
value.
30
3
Data Link Layer Network Components
Options Description
Set in config.h Set using options structure Set using options file
3
PPP_STR_LOCAL_AUTH_NAME char * local_auth_name local_auth_name name Set the local name for
authentication to the specified
name.
PPP_STR_MRU char * mru mru value Set MRU (Maximum Receive Unit)
for negotiation to the specified
value.
PPP_STR_NETMASK char * netmask netmask value Set the network mask value for
negotiation to the specified value.
PPP_STR_PAP_FILE char * pap_file pap_file file Get PAP secrets from the specified
file. This option is necessary if
either peer requires PAP
authentication.
PPP_STR_PAP_PASSWD char * pap_passwd pap_passwd passwd Set the password for PAP
authentication with the peer to the
specified password.
PPP_STR_PAP_RESTART char * pap_restart pap_restart value Set the timeout in seconds for the
PAP negotiation to the specified
value.
PPP_STR_PAP_USER_NAME char * pap_user_name pap_user_name name Set the user name for PAP
authentication with the peer to the
specified name.
PPP_STR_REMOTE_AUTH_NAME char * remote_auth_name remote_auth_name name Set the remote name for
authentication to the specified
name.
31
VxWorks Network 5.4
Programmer’s Guide
PPP Authentication
PPP provides security through two authentication protocols: PAP (see Password
Authentication Protocol (PAP), p.20) and CHAP (see Challenge-Handshake
Authentication Protocol (CHAP), p.21). This section introduces the use of PPP link-
layer authentication (introduced in Link Control Protocol (LCP), p.20), and describes
the format of the secrets files.
In VxWorks, the default behavior of PPP is to provide authentication when
requested by a peer but not to require authentication from a peer. If additional
security is required, choose PAP or CHAP by enabling the corresponding option.
PPP in VxWorks can act as a client (the peer authenticating itself) or a server (the
authenticator).
Authentication for both PAP and CHAP is based on secrets, selected from a secrets
file or from the secrets database built by the user (which can hold both PAP and
CHAP secrets). A secret is represented by a record, which itself is composed of
fields. The secrets file and the secrets database contain secrets that authenticate
other clients, as well as secrets used to authenticate the VxWorks client to its peer.
In the case that a VxWorks target cannot access the secrets file through the file
system, use pppSecretAdd( ) to build a secrets database.
Secrets files for PAP and CHAP use identical formats. A secrets record is specified
in a file by a line containing at least three words that specify the contents of the
fields client, server, and secret, in that order. For PAP, secret is a password which
must match the password entered by the client seeking PAP authentication. For
CHAP, both client and server must have identical secrets records in their secrets
files; the secret consists of a string of one or more words (for example, “an
unguessable secret”).
Table 3-4 is an example of a secrets file. It could be either a PAP or CHAP secrets
file, since their formats are identical.
32
3
Data Link Layer Network Components
At the time of authentication, for a given record, PPP interprets any words
following client, server, and secret as acceptable IP addresses for the client and secret
specified. If there are only three words on the line, it is assumed that any IP address
is acceptable; to disallow all IP addresses, use a dash (-). If the secret starts with an 3
@, what follows is assumed to be the name of a file from which to read a secret. An
asterisk (*) as the client or server name matches any name. When authentication is
initiated, a best-match algorithm is used to find a match to the secret, meaning that,
given a client and server name, the secret returned is for the closest match found.
On receiving an authentication request, PPP checks for the existence of secrets
either in an internal secrets database or in a secrets file. If PPP does not find the
secrets information, the connection is terminated.
The secrets file contains secrets records used to authenticate the peer, and those
used to authenticate the VxWorks client to the peer. Selection of a record is based
on the local and remote names. By default, the local name is the host name of the
VxWorks target, unless otherwise set to a different name by the option
local_auth_name in the options file. The remote name is set to a NULL string by
default, unless otherwise set to a name specified by the option remote_auth_name
in the options file. (Both local_auth_name and remote_auth_name can be
specified in two other forms, as can other configuration options listed in Table 3-3.)
If the VxWorks target is unable to access the secrets file, call pppSecretAdd( ) to
build a secrets database.
33
VxWorks Network 5.4
Programmer’s Guide
If PPP requires the peer to authenticate itself using PAP, the necessary
configuration option can be set in one of the following ways:
1. By reconfiguring VxWorks with PAP required. The relevant configuration
macro is PPP_OPT_REQUIRE_PAP.
2. By setting the flag OPT_REQUIRE_PAP in the flags bit field of the
PPP_OPTIONS structure passed to pppInit( );
Secrets records are first searched in the secrets database; if none are found there,
then the PAP secrets file is searched. The search proceeds as follows:
■ VxWorks as an authenticator: PPP looks for a secrets record with a client field
that matches the user name specified in the PAP authentication request packet
and a server field matching the local name. If the password does not match the
secrets record supplied by the secrets file or the secrets database, it is
encrypted, provided the optional DES cryptographic package is installed.
Then it is checked against the secrets record again. Secrets records for
authenticating the peer can be stored in encrypted form if the optional DES
package is used. If the login option was specified, the user name and the
password specified in the PAP packet sent by the peer are checked against the
system password database. This enables restricted access to certain users.
■ VxWorks as a client: When authenticating the VxWorks target to the peer, PPP
looks for the secrets record with a client field that matches the user name (the
local name unless otherwise set by the PAP user name option in the options
file) and a server field matching the remote name.
34
3
Data Link Layer Network Components
If PPP requires the peer to authenticate itself using CHAP, the necessary
configuration option can be set in one of the following ways:
■ By reconfiguring VxWorks with CHAP required. The relevant configuration
macro is PPP_OPT_REQUIRE_CHAP.
■ By setting the flag OPT_REQUIRE_CHAP in the flags bit field of the
PPP_OPTIONS structure passed to pppInit( ).
■ By adding the following line entry in the options file:
require_chap
Secrets are first searched in the secrets database; if none are found there, then the
CHAP secrets file is searched. The search proceeds as follows:
■ VxWorks as an authenticator: When authenticating the peer, PPP looks for a
secrets record with a client field that matches the name specified in the CHAP
response packet and a server field matching the local name.
■ VxWorks as a client: When authenticating the VxWorks target to the peer, PPP
looks for the secrets record with a client field that matches the local name and
a server field that matches the remote name.
PPP provides connect and disconnect hooks for use with user-specific software.
Use the pppHookAdd( ) routine to add a connect hook that executes software
before initializing and establishing the PPP connection or a disconnect hook that
executes software after the PPP connection has been terminated. The
pppHookDelete( ) routine deletes connect and disconnect hooks.
The routine pppHookAdd( ) takes three arguments: the unit number, a pointer to
the hook routine, and the hook type (PPP_HOOK_CONNECT or
PPP_HOOK_DISCONNECT). The routine pppHookDelete( ) takes two arguments:
35
VxWorks Network 5.4
Programmer’s Guide
the unit number and the hook type. The hook type distinguishes between the
connect hook and disconnect hook routines.
Two arguments are used to call the connect and disconnect hooks: unit, which is
the unit number of the PPP connection, and fd, the file descriptor associated with
the PPP channel. If the user hook routines return ERROR, then the link is gracefully
terminated and an error message is logged.
The code in Example 3-1 demonstrates how to hook the example routines,
connectRoutine( ) and disconnectRoutine( ), into the PPP connection
establishment mechanism and termination mechanism, respectively.
#include <vxWorks.h>
#include <pppLib.h>
/* type declarations */
{
BOOL connectOk = FALSE;
36
3
Data Link Layer Network Components
PPP can be used in two ways in the Tornado environment. The PPP link can serve
as an additional network interface apart from the existing default network
interface, or it can be the default network interface on the target, causing PPP to
serve as a network back end for the target server on the host.
1. To use this option, rebuild the VxWorks image with PPP included. For more
information on how to include PPP, see 3.4.5 PPP Configuration, p.21.
2. Boot the image from the regular Tornado boot ROM.
3. Start the Tornado target server and launch Tornado.
4. Start the Tornado shell, and invoke usrPPPInit( ) from the shell. You can also
use pppInit( ) from an application to configure the PPP link. For more
information on these routines, see Initializing a PPP Link, p.26.
37
VxWorks Network 5.4
Programmer’s Guide
3. Configure and start the pppd daemon on the host. For example, on a Sun host
using SunOS, the following command can be run to start the daemon:
% pppd passive /dev/ttyb 38400
4. Change the boot configuration parameters to use the PPP link. For example:
[VxWorks Boot}: c
boot device : ppp,38400
processor number : 0
host name : host
file name : /usr/wind/target/config/mv177/vxWorks
inet on ethernet (e) : 90.0.0.165:ffffff00
host inet (h) : 90.0.0.5
gateway inet (g) : 90.0.0.5
user (u) : thardy
flags (f) : 0x4
target name (tn) : luna
VxWorks
Copyright 1984-1995 Wind River Systems, Inc.
CPU: Motorola MVME177
VxWorks: 5.3
BSP version: 1.1/0
Creation date: Jan 26 1996
WDB: Ready.
You are now ready to start the target server and run Tornado. For more information
on starting Tornado refer to the Tornado User’s Guide.
38
3
Data Link Layer Network Components
The PPP connection is a network back end established on a serial link. When using
the PPP link to communicate with the target, all the Tornado tools work in the same
way as any other network back end. (See the Tornado User’s Guide.)
3
! CAUTION: System-level debugging is not available when using the PPP link. To
perform system-level debugging, use the regular serial back end described in the
Tornado User’s Guide.
Because of the complex nature of PPP, you may encounter problems using it in
conjunction with VxWorks. Give yourself the opportunity to get familiar with
running VxWorks configured with PPP by starting out using a default
configuration. Additional options for the local peer should be disabled. (These can
always be added later.)
Problems with PPP generally occur in either of two areas: when establishing links
and when using authentication. The following sections offer checklists for
troubleshooting errors that have occurred during these processes. If, however,
difficulties using PPP with VxWorks persist, contact the Wind River Systems
technical support organization.
Link Establishment
The link is the basic operating element of PPP; a proper connection ensures the
smooth functioning of PPP, as well as VxWorks. The following steps should help
resolve simple problems encountered when establishing a link.
1. Make sure that the serial port is connected properly to the peer. A null modem
may be required.
2. Make sure that the serial driver is correctly configured for the default baud rate
of 9600, no parity, 8 DATA bits, and 1 STOP bit.
3. Make sure that there are no problems with the serial driver. PPP may not work
if there is a hang up in the serial driver.
4. Start the PPP daemon on the peer in the passive mode.
5. Boot the VxWorks target and start the PPP daemon by typing:
% usrPPPInit
39
VxWorks Network 5.4
Programmer’s Guide
Authentication
Authentication is one of the more robust features of PPP for VxWorks. The
following steps may help you troubleshoot basic authentication problems.
1. Turn on the debug option for PPP. The relevant configuration macro is
PPP_OPT_DEBUG. You can also use the alternative options in Table 3-3. By
turning on the debug option, you can witness various stages of authentication.
2. If the VxWorks target has no access to a file system, use pppSecretAdd( ) to
build the secrets database.
3. Make sure the secrets file is accessible and readable.
4. Make sure the format of the secrets file is correct.
5. PPP uses the MD5 algorithm for CHAP authentication of secrets. If the peer
tries to use a different algorithm for CHAP, then the CHAP option should be
turned off.
6. Turn off the VJ compression. It can be turned on after you get authentication
working.
40
3
Data Link Layer Network Components
In the example shown in Figure 3-2, two CPUs are on a backplane. The shared-
memory network’s Internet address is 161.27.0.0. Each CPU on the shared-
memory network has a unique Internet address, 161.27.0.1 for vx1 and 161.27.0.2
for vx2.
vx1 vx2
161.27.0.1 161.27.0.2
161.27.0.0
Backplane
41
VxWorks Network 5.4
Programmer’s Guide
■ Processors can poll the shared-memory data structures for input packets
receive notification of packet arrival through interrupts.
The shared-memory network is configured by various configuration constants and
by parameters specified to the VxWorks boot ROMs. The following sections give
the details of the backplane network operation and configuration.
The basis of the VxWorks shared-memory network is the shared-memory pool. This
is a contiguous block of memory that must be accessible to all processors on the
backplane. Typically this memory is either part of one of the processors’ on-board,
dual-ported memory, or a separate memory board.
The processors on the backplane are each assigned a unique backplane processor
number starting with 0. The assignment of numbers is arbitrary, except for
processor 0, which by convention is the shared-memory network master, described
in the next section.
The processor numbers are established by the parameters supplied to the boot
ROMs when the system is booted. These parameters can be burned into ROM, set
in the processor’s NVRAM (if available), or entered manually.
One of the processors on the backplane is the shared-memory network master. The
shared-memory network master has the following responsibilities:
■ Initializing the shared-memory pool and the shared-memory anchor.
■ Maintaining the shared-memory heartbeat.
■ Functioning (usually) as the gateway to the external (Ethernet) network.
■ Allocating the shared-memory pool from its dual-ported memory (in some
configurations).
No processor can use the shared-memory network until the master has initialized
it. However, the master processor is not involved in the actual transmission of
42
3
Data Link Layer Network Components
43
VxWorks Network 5.4
Programmer’s Guide
boot device. To do this, enter the address (separated by an equal sign, “=”) after
the shared-memory network boot device specifier sm. For example, the following
line sets the anchor address to 0x800000:
boot device: sm=0x800000
In this case, this is the address of the anchor as seen by the processor being booted.
44
3
Data Link Layer Network Components
The offset to the shared-memory pool is 0x170. To view the start of the shared-
memory pool, display 0x800170:
[VxWorks Boot]: d 0x800170
800170: 0000 0050 0000 0000 0000 0bfc 0000 0350 *...P...........P* 3
In this example, the value of the shared-memory heartbeat is 0x50. Examine this
location again to determine whether the network is alive. If the value has changed,
the network is alive.
Shared-Memory Location
The size of the shared-memory pool is set during configuration. The relevant
configuration macro is SM_MEM_SIZE.
The size required for the shared-memory pool depends on the number of
processors and the expected traffic. There is less than 2KB of overhead for data
structures. After that, the shared-memory pool is divided into 2KB packets. Thus,
the maximum number of packets available on the backplane network is (poolsize –
2KB) / 2KB. A reasonable minimum is 64KB. A configuration with a large number
of processors on one backplane and many simultaneous connections can require as
much as 512KB. Having too small a pool slows down communications.
45
VxWorks Network 5.4
Programmer’s Guide
NOTE: These configurations are provided as examples. Change them to suit your
needs.
46
3
Data Link Layer Network Components
if the memory is dual-ported, as the memory must then also lock out one port
during a RMW cycle on the other.
Some processors do not support RMW indivisibly in hardware, but do have
software hooks to provide the capability. For example, some processor boards 3
have a flag that can be set to prevent the board from releasing the backplane bus,
after it is acquired, until that flag is cleared. You can implement these techniques
for a processor in the sysBusTas( ) routine of the system-dependent library
sysLib.c. The shared-memory network driver calls this routine to set up mutual
exclusion on shared-memory data structures.
Each processor on the backplane has a single input queue for packets received from
other processors. There are three methods processors use to determine when to
examine their input queues: polling, bus interrupts, and mailbox interrupts.
When using polling, the processor examines its input queue at fixed intervals.
When using interrupts, the sending processor notifies the receiving processor that
its input queue contains packets. Interrupt-driven communication is much more
efficient than polling.
However, most backplane buses have a limited number of interrupt lines available
on the backplane (for example, VMEbus has seven). Although a processor can use
one of these interrupt lines as its input interrupt, each processor must have its own
interrupt line. In addition, not all processor boards are capable of generating bus
interrupts. Nor can you always use bus interrupts.
As an alternative interrupt mechanism, you can use mailbox interrupts, also called
location monitors because they monitor the access to specific memory locations. A
mailbox interrupt specifies a bus address that, when written to or read from, causes
a specific interrupt on the processor board. Each board can be set, with hardware
jumpers or software registers, to use a different address for its mailbox interrupt.
To generate a mailbox interrupt, a processor writes to that location. There is
effectively no limit to the number of processors that can use mailbox interrupts,
47
VxWorks Network 5.4
Programmer’s Guide
because each interrupt requires only a single address on the bus. Most modern
processor boards include some kind of mailbox interrupt.
Each processor must tell the other processors which notification method it uses.
Each processor enters its interrupt type and up to three related parameters in the
shared-memory data structures. This information is used by the shared-memory
network drivers of the other processors when sending packets.
The interrupt type and parameters for each processor are specified during
configuration. The relevant configuration macro is SM_INT_TYPE (also
SM_INT_ARGn). The possible values are defined in the header file smNetLib.h.
Table 3-5 summarizes the available interrupt types and parameters.
SM_INT_NONE - - - Polling
48
3
Data Link Layer Network Components
sm0
(Shared-Memory Network)
and the Internet addresses of all other targets on the shared-memory network,
hardware-to-IP translation (ARP) is unnecessary over the VxWorks shared-
memory network, and is therefore eliminated.
When setting up a shared-memory network with sequential addressing, choose a
block of IP addresses and assign the lowest address in this block to the master.
When the shared-memory network driver is initialized by the master with
smNetInit( ), the starting IP address is passed as a parameter and stored in the
shared-memory pool.
Each target sets its interface address with ifAddrSet( ). This routine checks that the
assigned address matches the expected address for its location on the backplane,
based on the processor number from the boot parameters. If any other address is
specified, the operation fails. To determine the starting address for an active
shared-memory network, use smNetShow( ).
In the following example, the master’s IP address is 150.12.17.1.
-> smNetShow
value = 0 = 0x0
49
VxWorks Network 5.4
Programmer’s Guide
With sequential addressing, when booting a slave, the backplane IP address and
gateway IP boot parameters are no longer necessary. The default gateway address
is the address of the master. Another address can be specified if this is not the
desired configuration.
[VxWorks Boot]: p
boot device : sm=0x800000
processor number : 1
file name : /folk/fred/wind/target/config/bspname/vxWorks
host inet (h) : 150.12.1.159
user (u) : darger
flags (f) : 0x0
[VxWorks Boot] : @
boot device : sm=0x800000
processor number : 1
file name : /folk/fred/wind/target/config/bspname/vxWorks
host inet (h) : 150.12.1.159
user (u) : darger
flags (f) : 0x0
For UNIX, configuring the host to support a shared-memory network uses the
same procedures outlined earlier in this chapter for other types of networks. In
particular, a shared-memory network requires that:
■ All shared-memory network host names and addresses are present in
/etc/hosts.
■ All shared-memory network host names are present in .rhosts in your home
directory or in /etc/hosts.equiv if you are using RSH.
■ A gateway entry specifies the master’s Internet address on the Ethernet as the
gateway to the shared-memory network. The gateway entry is not needed if
you are using proxy ARP. For more information, see 4.7 ARP and Proxy ARP for
Transparent Subnets, p.84.
50
3
Data Link Layer Network Components
For Windows hosts, the steps required to configure the host are determined by
your version of Windows and the networking software you are using. See that
documentation for details.
3
Example Configuration
h1
host
150.12.0.1
Ethernet 150.12.0.0
150.12.0.2
vx2 vx1
sm master
& gateway
161.27.0.2 161.27.0.1
Shared-Memory
Network 161.27.0.0
51
VxWorks Network 5.4
Programmer’s Guide
The master is vx1, and functions as the gateway between the Ethernet and shared-
memory networks. It therefore has two Internet addresses: 150.12.0.2 on the
Ethernet network and 161.27.0.1 on the shared-memory network.
The other backplane processor is vx2; it is assigned the shared-memory network
address 161.27.0.2. It has no address on the Ethernet because it is not, directly
connected to that network. However, it can communicate with h1 over the shared-
memory network, using vx1 as a gateway. Of course, all gateway use is handled
by the IP layer and is completely transparent to the user. Table 3-6 shows the
example address assignments.
h1 150.12.0.1 -
vx2 - 161.27.0.2
To configure the UNIX system for our example, the /etc/hosts file must contain the
Internet address and name of each system. Note that the backplane master has two
entries. The second entry, vx1.sm, is not actually necessary, because the host
system never accesses that system with that address—but it is useful to include it
in the file to ensure that the address is not used for some other purpose.
The entries in /etc/hosts are as follows:
150.12.0.1 h1
150.12.0.2 vx1
161.27.0.1 vx1.sm
161.27.0.2 vx2
To allow remote access from the target systems to the UNIX host, the .rhosts file in
your home directory, or the file /etc/hosts.equiv, must contain the target systems’
names:
vx1
vx2
52
3
Data Link Layer Network Components
Alternatively, you can add the route manually (effective until the next reboot) with
the following UNIX command:
% route add net 161.27.0.0 150.12.0.2 1
3
The target system’s configurations include the parameters shown in Table 3-7. The
backplane master, vx1, uses the following boot parameters:
boot device : gn
processor number : 0
host name : h1
file name : /usr/wind/target/config/bspname/vxWorks
inet on ethernet (e) : 150.12.0.2
inet on backplane (b) : 161.27.0.1
host inet (h) : 150.12.0.1
gateway inet (g) :
user (u) : darger
ftp password (pw) (blank=use rsh) :
flags (f) : 0
NOTE: For more information on boot devices, see the Tornado User’s Guide: Getting
Started. To determine which boot device to use, see the BSP’s documentation.
Troubleshooting
Getting a shared-memory network configured for the first time can be tricky. If
you have trouble, here are a few troubleshooting procedures you can use. Take one
step at a time.
3. The parameters inet on backplane (b) and gateway inet (g) are optional with sequential
addressing.
53
VxWorks Network 5.4
Programmer’s Guide
54
3
Data Link Layer Network Components
3. Reboot the system, filling in the inet on backplane parameter. This initializes
the shared-memory network. The following message appears during the
reboot:
Backplane anchor at anchor-addrs...Attaching network interface 3
sm0...done.
4. After VxWorks is booted, you can display the state of the shared-memory
network with the smNetShow( ) routine, as follows:
-> smNetShow ["interface"] [, 1]
value = 0 = 0x0
Enter the other boot parameters and try booting the second processor.
10. If the second processor does not boot, you can use smNetShow( ) on the first
processor to see if the second processor is correctly attaching to the shared-
55
VxWorks Network 5.4
Programmer’s Guide
memory network. If not, then you have probably specified the anchor address
incorrectly on the second processor. If the second processor is attached, then
the problem is more likely to be with the gateway or with the host system
configuration.
11. You can use host system utilities, such as arp, netstat, etherfind, and ping, to
study the state of the network from the host side; see the Tornado User’s Guide:
Getting Started.
12. If all else fails, call your technical support organization.
56
4
TCP/IP Under VxWorks
4.1 Introduction
Typically, most VxWorks systems use the TCP/IP protocol suite. Although you can
port other networking protocols to VxWorks, this document generally assumes
you are using TCP/IP and the numerous networking components, utilities, and
services built on TCP/IP. Included in the Internet Protocol suite are the transport
layer protocols TCP and UDP. These protocols, along with OSPF (a separately
purchasable option), are layered on top of the IP (network) layer. In turn, the IP
layer rests on top of the MUX.
Also included in this section is a detailed description of ARP and proxy ARP.
4.1.1 MUX, an Interface between the Data Link and Network Layers
57
VxWorks Network 5.4
Programmer’s Guide
To attach the TCP/IP stack to the MUX for a particular interface, use the
ipAttach( ) routine. When an interface is shut down, ipDetach( ) will release the
TCP/IP stack components for that interface.
Each Internet host has a unique Internet address and an associated address mask.
An Internet address is four bytes long and contains information that identifies a
network as well as a specific host on that network. The number of bits used for
network identification versus host identification can differ according to the class of
the address.
Depending on the address class, the networking software uses different masks to
separate the bits that carry the network address from those that carry the host
58
4
TCP/IP Under VxWorks
address. The address mask is set to a default value according to class if subnets are
not used. For more information, see 4.3.3 Subnet Configuration, p.72 and 4.7.8 Proxy
ARP and Its Consequences for Subnet Configuration, p.93.
The following list describes the Internet addresses used to accommodate different
network configurations. 4
Class A: These addresses support a small number of networks, each with a
large number of hosts.
Class B: These addresses support a moderate number of networks, each with a
moderate number of hosts.
Class C: These addresses support a large number of networks, each with a
small number of hosts.
Class D: These addresses support IP multicasting.
These classes are distinguished by the high-order bits of an Internet address as
shown in Figure 4-1.
1. Other declarations are possible, but struct in_addr is more forward compatible and less
subject to a change in the size of the address.
59
VxWorks Network 5.4
Programmer’s Guide
(used for separating the bits used for the network portion of the address) as shown
in Table 4-1.
VxWorks includes utilities for manipulating Internet addresses. For example,
there are routines for converting between dot notation and integer notation,
routines for extracting network and host portions of an address, and routines for
creating a new address from a network and host number.
See the reference entry for inetLib.
The IP protocol handles packet routing. Each route entry in the routing table is a
mapping between a destination address and the network interface through which
the packet is transmitted.
The route entries in a routing table are of two types: host-specific and network-
specific. Host-specific route entries contain the host destination address and the
address of the gateway to use for packets destined for this host. Network-specific
route entries contain a network destination address and the Internet address of the
gateway to use for packets destined for this network.
The VxWorks networking software establishes a route before transmitting each
packet. Given a destination address, VxWorks searches the routing table to find a
matching route entry and thus the network interface through which it transmits
the packet. A route entry is considered a match if the logical AND of the network
mask and the given search key (destination address) equals the destination
address stored in the route entry. For example, if a route entry has 147.11.44.00 as
a destination and 0xFFFFFF00 as a network mask, a search key of 147.11.44.155
matches. However, a search key of 147.11.43.155 does not match.
60
4
TCP/IP Under VxWorks
150.12.0.1
150.12.0.0
150.12.0.2
host gateway
161.27.0.51 161.27.0.50
161.27.0.0
For a host route, a mask of 0xFFFFFFFF is assumed. If a default route is added with
the destination address as “0.0.0.0”, an implicit netmask of 0x00000000 is assumed.
The destination address for a default route entry is always “0.0.0.0”. An implicit
network mask of 0x00000000 is assumed for this route entry.
When searching2 the routing table for a destination address, the search algorithm
first tries to match the complete host address. If the host address match is not
found, the search tries to match the network address of the provided destination
address. If a network address match is not found, the search returns the route entry
of the default address (if any).
If the search of the routing table finds a matching entry which has a clone flag set,
a new route entry is created (cloned) from the found entry. For example:
If: The routing table on a VxWorks target contains a route to an Ethernet
network interface whose IP address is 147.11.44.155.
And: The subnet mask is 0xFFFFFF00.
2. For more information about the routing table structure and the algorithms used to search
the routing table, see TCP/IP Illustrated, Volume 2, by Gary R. Wright and W. Richard Stevens.
61
VxWorks Network 5.4
Programmer’s Guide
A single network can contain CPUs using different internal architectures. The
numeric representation schemes of these architectures can differ: some use big-
endian numbers, and some use little-endian numbers. To permit exchanging
numeric data over a network, some overall convention is necessary. Network byte
order is the convention that governs exchange of numeric data related to the
network itself, such as socket addresses or shared-semaphore IDs. Numbers in
network byte order are big-endian.
The routines in Table 4-2 convert longs and shorts between host and network byte
order. To minimize overhead, macro implementations (which have no effect on
architectures where no conversion is needed) are also available, in h/netinet/in.h.
Macro Description
62
4
TCP/IP Under VxWorks
It is safer to increment separately from the macro call. The following increments
pBuf only once, whether the architecture is big- or little-endian:
pBufHostLong = ntohl (*pBuf);
pBuf++;
On a VxWorks target, you can use the functions of the ifLib library to associate
Internet addresses with network interfaces, host names, and broadcasting. For a
listing of these configuration functions, see the reference entry for ifLib.
This is usually done in the UNIX startup file /etc/rc.boot. For more information,
see the UNIX reference entry for ifconfig.
In VxWorks, the Internet address of a network interface is specified, and a new
route to that interface is constructed, by calling ifAddrSet( ). For example, to
associate the Internet address 150.12.0.1 with the interface ln0, enter:
63
VxWorks Network 5.4
Programmer’s Guide
NOTE: The subnet mask used in determining the network portion of the address
used in ifAddrSet( ) will be that set by ifMaskSet( ), or the default class mask if
ifMaskSet( ) has not been called. It is standard to call ifMaskSet( ) prior to any
calls to ifAddrSet( ).
For more information, see the Tornado reference entries for ifLib and ifAddrSet( ).
The VxWorks network startup routine, usrNetInit( ) in usrNetwork.c,
automatically sets the address of the interface used to boot VxWorks to the Internet
address specified in the VxWorks boot parameters.
The underlying Internet protocol uses the 32-bit Internet addresses of systems on
the network. People, however, prefer to use system names that are more
meaningful to them. Thus VxWorks and most host development systems maintain
their own maps between system names and Internet addresses.
On UNIX systems, /etc/hosts contains the mapping between system names and
Internet addresses. Each line consists of an Internet address and the assigned
name(s) for that address:
150.12.0.1 vx1
There must be an entry in this file for each UNIX system and for each VxWorks
system on the network. For more information on /etc/hosts, see your UNIX system
reference entry hosts(5).
In VxWorks, call hostAdd( ) to associate system names with Internet addresses.
Make one call to hostAdd( ) for each system the VxWorks target communicates
with, as follows:
hostAdd ("vx1", "150.12.0.1");
NOTE: In addition to hostAdd( ), VxWorks also includes DNS. You can use DNS
to create and automatically maintain host-name/address associations for your
VxWorks target. For more information, see DNS: Domain Name System, p.161.
To associate more than one name with an Internet address, hostAdd( ) can be called
several times with different host names and the same Internet address. The routine
hostShow( ) displays the current system name and Internet address associations.In
the following example, 150.12.0.1 can be accessed with the names host, myHost,
and widget:
64
4
TCP/IP Under VxWorks
-> hostShow
value = 0 = 0x0
Many physical networks support the notion of broadcasting a packet to all hosts on
the network. A special Internet broadcast address is interpreted by the network
subsystem to mean “all systems” when specified as the destination address of a
datagram message (UDP). This is shown in the demo program
target/src/demo/dg/dgTest.c.
Unfortunately, there is some ambiguity about which address is to be interpreted as
the broadcast address. The Internet specification now states that the broadcast
address is an Internet address with a host part of all ones (1). However, some older
systems use an Internet address with a host part of all zeros as the broadcast
address.
Most newer systems, including VxWorks, accept either address on incoming
packets as being a broadcast packet. But when an application sends a broadcast
packet, it must use the correct broadcast address for its system.
3. Internally, hostShow( ) uses the resolver library to access DNS to get the information it
needs to respond to a query.
65
VxWorks Network 5.4
Programmer’s Guide
VxWorks normally uses a host part of all ones as the broadcast address. Thus a
datagram sent to Internet address 150.255.255.255 (0x5AFFFFFF) is broadcast to all
systems on network 150. However, to allow compatibility with other systems,
VxWorks allows the broadcast address to be reassigned for each network interface
by calling the routine ifBroadcastSet( ). For more information, see the reference
entry for ifBroadcastSet( ).
In addition, VxWorks supports multicasting—transmission to a subset of hosts on
the network. For more information on multicasting, see Using a Datagram (UDP)
Socket to Access IP Multicasting, p.137.
One of the primary functions of IP is to transport packets from one host to another.
Communication between two hosts on the same physical network requires little
effort on the part of IP. In this case, IP can deliver the packet directly to the
destination. However, if the destination of a packet is not local, IP cannot deliver
the packet directly. In this case, IP hands the packet off to a gateway.
A gateway is a machine that is able to forward packets from one network to
another. Thus, a gateway has a physical connection to two or more networks. If the
destination of a packet is local to the network on the other side of the gateway, the
gateway can deliver the packet directly. Otherwise, the gateway passes the packet
to still another gateway. This process, called routing, continues until the packet is
delivered or expires.
To support routing, most systems contain a table that identifies a default gateway
as well as gateways associated with specific IP addresses. To maintain this table
and determine network connectivity, a VxWorks system uses the Routing
Information Protocol (RIP) either version 1 or 2. The RIP implementation provided
with VxWorks is based on the BSD 4.4 routed program.
To setup the initial routing information available on a VxWorks target, use the
functions of the routeLib library. Using the routeLib routines, you can establish
the default gateway you want the target to use. These routines also let you
associate a destination IP address with a specific gateway. For a listing of the
routing configuration functions, see the reference entry for routeLib.
66
4
TCP/IP Under VxWorks
The procedures vary according to your version of Windows and your networking
software package. For the details, see the documentation for your system.
where n is the hop count from the host system to the destination network (the
number of gateways between the host and the destination network) and “passive”
indicates the entry is to remain in the routing tables.
For example, consider a system on network 150. The following line in
/etc/gateways describes a gateway between networks 150 and 161, with an Internet
address 150.12.0.1 on network 150. A hop count (metric) of 1 specifies that the
gateway is a direct connection between the two networks:
net 161.27.0.0 gateway 150.12.0.1 metric 1 passive
After editing /etc/gateways, you must kill the route daemon and restart it, because
it only reads /etc/gateways when it starts. After the route daemon is running, it is
not aware of subsequent changes to the file.
Alternatively, you can use the route command to add routing information
explicitly:
# route add destination-network gatewayAddr [metric]
For example, the following command configures the gateway in the same way as
the previous example, which used the /etc/gateways file:
# route add net 161.27.0.0 150.12.0.1 1
Note, however, that routes added with this manual method are lost the next time
the system boots.
You can confirm that a route is in the routing table by using the UNIX command
netstat -r.
67
VxWorks Network 5.4
Programmer’s Guide
VxWorks provides a set of functions that you can use to edit the routing table.
However, before you edit the table, it is generally a good idea to look at what is
already there.
To inspect the contents of the routing table, use routeShow( ). If a VxWorks target
boots through an Ethernet network interface, a typical routeShow( ) call would
display the following:4
-> routeShow()
In the output shown above, the route entry for 147.11.44.0 shows that the flags
RTF_CLONING (0x100) and RTF_UP (0x001, signifying that the route is available
for use) are set. This route entry is set when the Ethernet network device “ei0” is
initialized. This is a network route and the network mask associated with this
route is 0xFFFFFF00.
VxWorks includes a number of functions that you can use to edit the routing table.
These functions are as follows:5
routeAdd( )
Adds a route to the routing table.
4. This assumes that the VxWorks image is configured with network show routines. The rele-
vant configuration macro is INCLUDE_NET_SHOW.
5. These routines manage static routing entries. These entries are not updated, modified, or
deleted by the dynamic routing protocols (RIP or OSPF). They remain active until you
explicitly delete them.
68
4
TCP/IP Under VxWorks
routeNetAdd( )
This function is the same as routeAdd( ) except that the destination
address is assumed to be a network. This is useful for adding a route to a
sub-network that is not on the same physical network as the local network.
routeDelete( ) 4
Deletes a route from the routing table.
mRouteAdd( )
Adds routes differentiated by masks and service quality.
mRouteDelete( )
Deletes routes differentiated by masks and service quality.
NOTE: The functions routeAdd( ) and routeDelete( ) implicitly derive the netmask
from the given destination and gateway address. Please refer to the manual pages
for the function calls mentioned above.
Both addresses can be specified either by dotted decimal notation or by the host
names defined by the routine hostAdd( ). If the destination address is a subnet,
you can use routeNetAdd( ) instead.
For example, consider two VxWorks machines vx2 and vx3 (shown in Figure 4-3),
both interfaced to network 161. Suppose that vx3 is a gateway between networks
150 and 161 and that its Internet address on network 161 is 161.27.0.3.
The following calls can then be made on vx2 to establish vx3 as a gateway to
network 150:
-> routeAdd ("150.12.0.0", "vx3");
or:
-> routeAdd ("150.12.0.0", "161.27.0.3");
To confirm that a route is in the routing table, use the routeShow( ) routine.6 Other
routing routines are available in the library routeLib.
6. This function is not built into the Tornado shell. The relevant configuration macro is
INCLUDE_NET_SHOW.
69
VxWorks Network 5.4
Programmer’s Guide
Network 161
161.27.0.2 161.27.0.3
vx2 vx3
150.12.0.1
Network 150
150.12.0.2
h1
If a default route is added to the routing table, any packet for which a host route or
a network route cannot be established, is forwarded to the address provided in the
default route entry.
To delete an entry from the routing table, use routeDelete( ).
/* Delete route to node 161.27.0.51 using gateway 150.12.0.2 */
routeDelete ("161.27.0.51", "150.12.0.2");
■ Using mRouteAdd( )
To use mRouteAdd( ) you need to specify a little more information than for a
simple routeAdd( ) call. However, this extra information does provide support for
additional routing services that take into account the type of service or mask
associated with a particular route. The general format of a mRouteAdd( ) call is as
follows:
70
4
TCP/IP Under VxWorks
Thus, to specify that the route to the 90.0.0.0 network use the 91.0.0.3 router:
mRouteAdd ("90.0.0.0", "91.0.0.3", 0xffffff00, 0, 0);
To delete a route that was added using mRouteAdd( ), call mRouteDelete( ). The 4
general format of a call to mRouteDelete( ) is as follows:
mRouteDelete ("destination", netmask, tos)
The netmask and type of service must match those of the route you want to delete.
Otherwise the route is not deleted.
Using mRouteAdd( ), you can specify multiple routes to a single destination. These
routes differ only in factors such as the netmask or the type of service. For example:
mRouteAdd ("90.0.0.0", "91.0.0.3", 0xFFFFFF00, 0, 0);
mRouteAdd ("90.0.0.0", "91.0.0.254", 0xFFFF0000, 0, 0);
Now packets destined for “90.0.0.0” can get there using either of the two different
gateways. The distinguishing factor is the netmask, although you could have used
the type-of-service or flags values to distinguish the routes. For more information,
see the mRouteAdd( ) reference entry.
The routing engine uses these values to pick among multiple routes when a user
application requests a certain type of service for their socket. Applications choose
their type of service as input to a setsockopt( ) call. See the setsockopt( ) reference
entry for more information.
71
VxWorks Network 5.4
Programmer’s Guide
Within VxWorks it is now possible to have routes chosen on a priority scheme. All
routes that are installed in the system have a routing protocol type associated with
them. These types are as follows:
M2_ipRouteProto_other8
M2_ipRouteProto_local
M2_ipRouteProto_netmgmt
M2_ipRouteProto_icmp
M2_ipRouteProto_egp
M2_ipRouteProto_ggp
M2_ipRouteProto_hello
M2_ipRouteProto_rip
M2_ipRouteProto_is_is
M2_ipRouteProto_es_is
M2_ipRouteProto_ciscoIgrp
M2_ipRouteProto_bbnSpfIgp
M2_ipRouteProto_ospf
M2_ipRouteProto_bgp
Using this routine, you can give a certain class of routes precedence over routes of
other classes. For example, you could use routeProtoPrioritySet( ) to give OSPF-
installed routes precedence over routes installed by RIP or mRouteAdd( ). See the
routeProtoPrioritySet( ) reference entry for more information.
72
4
TCP/IP Under VxWorks
131.1.7.81
When specifying the boot parameters in a boot string, the same Internet address
specification looks as follows:
e=131.1.7.81:ffffff00 b=131.1.81.1:ffffff00
73
VxWorks Network 5.4
Programmer’s Guide
74
4
TCP/IP Under VxWorks
stack uses for the network memory pool, modify the clDescTbl table defined in
target/src/config/usrNetwork.c.
4.6.2 Setting #defines for the IP, TCP, UDP, and ICMP Protocols
This section describes the configuration for the network layer protocols. Table 4-3
describes all configuration options. For some options, the default value is specified
using symbolic constants. These symbolic constants are defined in netLib.h. To
override any default values assigned to these constants, reconfigure VxWorks with
the appropriate values set.
75
VxWorks Network 5.4
Programmer’s Guide
76
4
TCP/IP Under VxWorks
77
VxWorks Network 5.4
Programmer’s Guide
IP Time-to-live Value for Default Value: 60 (30 seconds for received fragments)
packet fragments Sets the default time to live value for an IP fragment. To
(IP_FRAG_TTL_DFLT) transmit a packet bigger than the MTU size, the IP layer
breaks the packet into fragments. On the receiving side, IP
re-assembles these fragments to form the original packet.
Upon receiving a fragment, IP adds it to the IP fragment
queue. Each fragment waiting to be re-assembled has its
own time to live, which, by default, is 30 seconds. This
means that a fragment is deleted from the queue if it cannot
be assembled in 30 seconds.
If the network is extremely busy, the IP fragment queue can
accumulate a lot of fragments that are waiting to be
reassembled. This clutter can cause the queue to grow very
large and thus take up a lot of system memory. To alleviate
this problem, you can reduce the value of this configuration
constant.
VxWorks allocates and initializes memory for the network stack only once, at
network initialization time. Out of this pre-allocated memory, the network stack
uses netBufLib routines to set up a memory pool. From this memory pool, the
network stack uses netBufLib routines to get the memory needed for data transfer.
The netBufLib routines deal with data in terms of mBlk structures, clBlk
structures, and clusters. The mBlk and clBlk structures provide information
necessary to manage the data stored in clusters. The clusters, which come in
different sizes, contain the data described by the mBlk and clBlk structures. When
VxWorks sets up the network stack memory pool, it needs to know the number of
mBlks, clBlks, as well as the number of clusters per cluster size. The default counts
are specified by symbolic constants defined in h/netBufLib.h. These constants are
described in Table 4-4.
! CAUTION: Change these constants only after you fully understand what they do.
Setting inappropriate values can make the TCP/IP stack inoperable.
78
4
TCP/IP Under VxWorks
Constant Description
By default, the VxWorks network stack creates six pools (all within the main
network memory pool) for clusters ranging in size from 64 bytes to 2048 bytes.
However, valid cluster sizes can range from 64 bytes increasing by powers of two
to 64K (65535). If your network stack needs clusters of a valid but non-default size,
you can edit the clDescTbl table defined in target/src/config/usrNetwork.c. The
following is an example and clDescTbl[ ] table:
79
VxWorks Network 5.4
Programmer’s Guide
To add a cluster pool for clusters of 4096 bytes each, edit clDescTbl[ ] as follows: 9
CL_DESC clDescTbl [] = /* network cluster pool configuration table */
{
/*
clusterSize num memArea memSize
----------- ---- ------- -------
*/
{64, NUM_64, NULL, 0},
{128, NUM_128, NULL, 0},
{256, NUM_256, NULL, 0},
{512, NUM_512, NULL, 0},
{1024, NUM_1024, NULL, 0},
{2048, NUM_2048, NULL, 0},
{4096, NUM_4096, NULL, 0}
};
! CAUTION: Adjust the counts for mBlks, clBlks, clusters, and cluster pools only
after collecting data on system behavior and deciding whether or how you would
like to change that behavior. Carefully planned changes can significantly improve
performance, but reckless changes can significantly reduce performance.
The values shown above are reasonable defaults, but the network requirements for
your system could be radically different. For example, your use of the network
stack could require more clusters of a particular size. Making such a determination
is a matter of experimentation and analysis. However, as background information,
you need to understand how data divides up into mBlks, clBlks, and clusters.
9. For this particular clDescTbl[ ] table only, you can specify memArea values as NULL and
memSize values as 0. When the network initialization code actually allocates the necessary
memory, it resets these values appropriately. For all other clDescTbl[ ] tables, you must
provide these values explicitly before calling netPoolInit( ). For more information, see the
reference entry for netPoolInit( ).
80
4
TCP/IP Under VxWorks
The mBlk structure is the primary vehicle through which you access data in a
memory pool established by netPoolInit( ). Because the mBlk structure merely
references the data, this lets network layers communicate data without actually
having to copy the data. In addition, data can be chained using mBlks. Thus, you
can pass an arbitrarily large amount of data by passing the mBlk at the head of an
mBlk chain. Consider Figure 4-5. 10 4
clBlk clBlk
Packet 2
Cluster Cluster
64 bytes 2028
bytes
As shown in Figure 4-5, an mBlk references data only indirectly – through a clBlk
structure. This indirection makes it easier for multiple mBlks to share the same
cluster. See Figure 4-6.
10. To support chaining across multiple packets, the mBlk structure contains two members that
support of chaining. One member points to the next mBlk in the current packet. The other
member points to the head mBlk in the next packet (if any).
81
VxWorks Network 5.4
Programmer’s Guide
mBlk a mBlkbb
mBlk void
clBlk clBlk
Cluster Cluster
64 bytes 2028
bytes
Please note that using a clBlk structure instead of a pointer to provide a level of
indirection is not an extravagance. The clBlk structure tracks how many mBlks
share its underlying cluster. This is critical when it comes time to free an
mBlk/clBlk/cluster construct. If you use netMblkClFree( ) to free the construct,
the mBlk is freed back to the pool and the reference count in the clBlk is
decremented. If the reference count drops to zero, the clBlk and cluster are also
freed back to the memory pool.
The clDescTbl[ ] shown in the previous section did not make use of the memArea
and memSize members. For the default network buffer pool, the memory
allocation calls are handled internally and the values of memArea and memSize
are set for you. However, if necessary, you can supply these values and thus
explicitly determine the size and location of the memory pools. For more
information on how to use the memArea and memSize members, see the reference
entry for netPoolInit( ).
You can use the ping( ) utility from VxWorks to test whether a particular system is
accessible over the network. Like the UNIX command of the same name, ping( )
sends one or more packets to another system and waits for a response. You can
identify the other system either by name or by its numeric Internet address. This
is useful for testing routing tables and host tables, or determining whether another
machine is responding to network requests.
82
4
TCP/IP Under VxWorks
If the first argument uses a host name, ping( ) uses the host table to look it up, as in 4
the following example:
-> ping "caspian",1
caspian is alive
value = 0 = 0x0
The numeric argument specifies how many packets to expect back (typically, when
an address is reachable, that is also how many packets are sent). If you specify
more than one packet, ping( ) displays more elaborate output, including summary
statistics. For example, the following test sends packets to a remote network
address until it receives ten acknowledgments, and reports on the time it takes to
get replies:
-> ping "198.41.0.5",10
PING 198.41.0.5: 56 data bytes
64 bytes from 198.41.0.5: icmp_seq=0. time=176. ms
64 bytes from 198.41.0.5: icmp_seq=1. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=2. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=3. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=4. time=80. ms
64 bytes from 198.41.0.5: icmp_seq=5. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=6. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=7. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=8. time=64. ms
64 bytes from 198.41.0.5: icmp_seq=9. time=64. ms
The report format matches the format used by the UNIX ping utility. Timings are
based on the system clock; its resolution could be too coarse to show any elapsed
time when communicating with targets on a local network.
Applications can use ping( ) periodically to test whether another network node is
available. To support this use, the ping( ) routine returns a STATUS value and
accepts a PING_OPT_SILENT flag as a bit in its third argument to suppress printed
output, as in the following code fragment:
/* Check whether other system still there */
83
VxWorks Network 5.4
Programmer’s Guide
You can set one other flag in the third ping( ) argument: PING_OPT_DONTROUTE
restricts ping( ) to hosts that are directly connected, without going through a
gateway.
11. Proxy ARP is described in Request For Comments (RFC) 925 “Multi LAN Address Resolu-
tion,” and an implementation is discussed in RFC 1027 “Using ARP to Implement Trans-
parent Subnet Gateways.” The ARP protocol is described in RFC 826 “Ethernet Address
Resolution Protocol: Or converting network protocol addresses to 48-bit Ethernet address
for transmission on Ethernet hardware.” The implementation of Proxy ARP for VxWorks is
based on RFC 925. However, it is a limited subset of that proposal.
84
4
TCP/IP Under VxWorks
ARP is used to resolve a host’s IP address into a hardware address. This is done
by broadcasting an ARP request on the physical medium (typically Ethernet). The
destination host sees the request and recognizes the destination IP address as its
own. It then sends a reply with its hardware address. 4
In the example in Figure 4-7, host h1 wants to communicate with host h4. It needs
h4’s hardware address, so it broadcasts an ARP request. Host h4 sees the ARP
request and replies with its hardware address. h1 records h4’s IP-to-hardware
mapping and proceeds to communicate with it.
h1 h2 h3 h4
h1 h2 h3 h4
For a host to communicate with another host on a different subnet or network (as
indicated by the IP addresses and the subnet mask), it must use a gateway. In
Figure 4-8, vx3 acts as a gateway between Network A and Network B. Each host
must have a routing entry for the gateway in its routing table. The routing table for
vx1 to communicate with Network B includes entries like the following:
node destination gateway
vx1 150.12.2.0 150.12.1.1 (network)
85
VxWorks Network 5.4
Programmer’s Guide
The routing table for h1 to communicate with Network A includes entries like the
following:
node destination gateway
h1 150.12.1.0 150.12.2.1 (network)
A sender cannot send an ARP request for a host on another subnet or network.
Instead, if it doesn’t know the hardware address for the gateway listed in its
routing table, it sends an ARP request for the gateway’s hardware address.
Network A
150.12.1.20 150.12.1.1
gateway
vx1 vx3
150.12.2.1
Network B
150.12.2.34
h1
With proxy ARP, nodes on different physical networks are assigned addresses with
the same subnet number. Because they appear to reside on the same network, they
can communicate directly and use ARP to resolve hardware addresses. The
gateway node provides this network transparency by watching for and answering
ARP requests that cross network boundaries. The node providing this
transparency is the proxy server.
The example configuration shown in Figure 4-8 changes slightly when proxy ARP
is used. As shown in Figure 4-9, the nodes vx1 and h1 now look as if they are on
the same subnet. Nodes h1 and vx1 are fooled by vx3 into thinking they can send
86
4
TCP/IP Under VxWorks
directly to each other, when they are actually sending to vx3. The gateway node,
vx3, ensures that the packets get to the correct destination.
Network A 4
150.12.1.20 150.12.1.1
proxy
vx1 vx3
server
150.12.1.2
Network B
150.12.1.34
h1
In the example in Figure 4-10, vx1 and h1 have the same network address,
150.12.1.0. The proxy server, vx3, has a routing table like the following example:
87
VxWorks Network 5.4
Programmer’s Guide
Destination Gateway
150.12.1.6 (network route with netmask 0xffffffff).......) 150.12.1.8
150.12.1.7 (network route with netmask 0xffffffff........) 150.12.1.8
150.12.1.0 (network) 150.12.1.60
Shared-Memory
150.12.1.6 150.12.1.7 150.12.1.8 Network
150.12.1.60
Ethernet
150.12.1.62 150.12.1.61
h2 h1
The network on which the proxy server performs network-specific routing (or for
which it is acting as a proxy) with the mask 0xFFFFFFFF is referred to as the proxy
network. The proxy server has a network-specific route with mask 0xFFFFFFFF to
each node on the proxy network. The network interface on which the proxy server
performs network routing is called the main network. In the example in Figure 4-10,
the shared-memory network is the proxy network and the Ethernet is the main
network. The routing table of vx3 has network-specific routes with mask
0xFFFFFFFF for both vx1 and vx2. To send to nodes h1 and h2, it uses the network
route (150.12.1.0). There can be multiple proxy networks per main network.
However, there can only be one main network per network/subnet number.
Although network-specific routes with netmask 0xFFFFFFFF can be used on all
interfaces for complete generality, a VxWorks shared-memory network usually is
configured so that one side of the proxy server contains the majority of nodes (the
Ethernet side). Therefore, in this case it is reasonable to use this network as the
main network.
88
4
TCP/IP Under VxWorks
The following subsections describe how the proxy ARP protocol responds to ARP
requests for proxy clients, non-proxy clients, and how it responds to replies from
the main network.
4
ARP Requests for Proxy Clients
If the proxy server receives an ARP request from the main network for a node on
a proxy network (proxy client), the proxy server generates an ARP reply with its
own hardware address as the source hardware address. If the node that generated
the request is also on the proxy network, the destination proxy client answers for
itself. In the example in Figure 4-10, if vx1 broadcasts an ARP request for 150.12.1.7,
vx2 replies to the request, not the proxy server vx3. However, if h1 broadcasts an
ARP request for 150.12.1.7, the proxy server (vx3) replies with its own hardware
address.
If an ARP request comes from a proxy network and the destination address is not
a proxy client, the proxy server tries to resolve the request. If the hardware address
of the destination is known, the server generates and sends an ARP reply to the
source proxy client. If the hardware address is unknown, the server forwards the
ARP request to the proxy network’s corresponding main network, replacing the
source hardware address in the ARP message with its own outgoing interface
hardware address. For example, in Figure 4-10, vx1 sends an ARP request for
150.12.1.62. If vx3 knows the hardware address, it sends an ARP reply to vx1.
Otherwise it forwards the request to the Ethernet.
If the proxy server gets an ARP reply, the server checks to see if the destination is
a proxy client. If it is, and the server previously forwarded this request, then the
server forwards the ARP reply back to the proxy client (replacing the source
hardware address in the ARP reply message with its own). In the previous
example, if h2 replies to the request for the Ethernet address of 150.12.1.62, the
proxy server (vx3) records the address for itself and then forwards the reply to vx1
(with vx3’s own hardware address substituted for h2’s).
89
VxWorks Network 5.4
Programmer’s Guide
All nodes on a logical network are expected to receive an IP broadcast for that
network (for example, 150.12.1.255). Thus, broadcasts must be passed through the
proxy server so that nodes on both the proxy network and the main network
receive them. Because most broadcast traffic is extraneous, it is desirable to
minimize the number of forwarded shared-memory network broadcasts, thus
keeping shared-memory network traffic to a minimum.
To minimize and control shared-memory network broadcast traffic, the proxy
server can be configured to forward broadcasts only to a specified set of
destination UDP ports. Ports are enabled using the routine proxyPortFwdOn( ),
and are disabled with proxyPortFwdOff( ). Only the BOOTP/DHCP server port
(67) is enabled by default.
If a broadcast datagram originates from a proxy network (and the port is enabled),
the server forwards the broadcast to the main network, and to all other proxy
networks that have the same main network. For example, in Figure 4-11, if a
datagram comes from sm1, it gets forwarded to ln0 and sm0.
vx1
If the datagram originates from a main network (and the port is enabled), the
server forwards the broadcasts to all the main network’s proxy networks. For
example, in Figure 4-11, a datagram from ln0 is forwarded to both sm0 and sm1.
To prevent forwarding loops, broadcasts forwarded onto proxy networks are given
a time-to-live value of 1.
90
4
TCP/IP Under VxWorks
Using multi-homed proxy clients requires that you make changes to the routing
and broadcast configuration of your VxWorks system. These changes are described
in the following subsections.
If a proxy client also has an interface to the main network, some additional
configuration is required for optimal communications. The proxy client’s routing
tables must have network-specific routes with netmask 0xFFFFFFFF for nodes on
the proxy network, and a network-specific route for the main network. Otherwise
traffic travels an extra unnecessary hop through the proxy server.
In the example shown in Figure 4-12, vx1 is the proxy server and vx2 is a proxy
client with an interface on the main network. vx2 must be configured to have
network-specific routes with mask 0xFFFFFFFF to each of the other proxy clients
(vx4 and vx5), and a network-specific route to the main network. Otherwise any
traffic from vx2 to vx4 (or vx5) unnecessarily travels over the main network
through the proxy server (vx1).
The following is an example of vx2’s routing table. The routing table is
manipulated using routeAdd( ) and routeDelete( ). For more information, see the
reference entry for routeLib.
Destination Gateway
150.12.0.4 (network with netmask 0xffffffff) 150.12.0.6
150.12.0.5 (network with netmask 0xffffffff) 150.12.0.6
150.12.0.0 (network) 150.12.0.7
A proxy client that also has an interface connected to the main network must
disable broadcast packets from the proxy interface. Otherwise, it receives
duplicate copies of broadcast datagrams (one from Ethernet and one from the
shared-memory network). Broadcasts can be disabled on an interface using
ifFlagChange( ). (See the reference entry.)
91
VxWorks Network 5.4
Programmer’s Guide
h1
150.12.0.1
Main
Network
150.12.0.2 150.12.0.7
Proxy Proxy
vx1 Server Client vx2
150.12.0.3 150.12.0.6
Proxy
Network
150.12.0.4 150.12.0.5
vx4 vx5
Proxy ARP works only for a single tier of shared-memory networks. That is, only
interfaces directly attached to the proxy server are supported. Example
configurations that work are shown in Figure 4-13 and Figure 4-15.However, the
configuration shown in Figure 4-14 does not work because ARP requests are not
forwarded over proxy networks, and there can be only one proxy server per
shared-memory network. This single-tier restriction means that problems such as
network circles, broadcast storms, and continually forwarded ARP requests are
avoided.
To work, the configuration in Figure 4-14 requires a combination of proxy ARP and
IP (or standard subnet) routing. The modified configuration is shown in
Figure 4-16, where Proxy Network 1 has become an IP routing network with a
92
4
TCP/IP Under VxWorks
Figure 4-13 Single-Tier Example Using Proxy ARP with Two Branches
h1 h2
4
150.12.0.1 150.12.0.2
Main
Network
150.12.0.3
vx1
For h2 to send to vx6, it requires the following entry in its routing table:
Destination Gateway
161.27.0.0 (network) 150.12.0.6
If the main network on which the proxy server is connected is subnetted, then all
the interfaces (both proxy and main) must reside on the same subnet as the main
93
VxWorks Network 5.4
Programmer’s Guide
Figure 4-14 Multi-Tier Configuration that CANNOT Be Used with Proxy ARP
h1 h2
150.12.0.1 150.12.0.2
Main Network
150.12.0.3
Proxy
vx1 Server
150.12.0.4
Proxy Network 0
Proxy
vx2 vx3 Server vx4
150.12.0.9 150.12.0.10
vx5 vx6
network. That is, the main network interface and the proxy network interface on
the proxy server and all the proxy clients must have the same subnet mask.
To enable proxy ARP for the shared-memory network, reconfigure VxWorks and
rebuild it with the proxy server. The relevant configuration macro is
94
4
TCP/IP Under VxWorks
h1 h2
4
150.12.7.1 150.12.7.2
Main
Network
150.12.7.3
vx1
150.12.7.4
Proxy
Network
150.12.7.5 150.12.7.6 150.12.7.7
95
VxWorks Network 5.4
Programmer’s Guide
The proxy server for the shared-memory network must be the master board. As
previously mentioned, the server must be configured for proxy servers. The
relevant configuration macro is INCLUDE_PROXY_SERVER. If sequential
addressing is not used, then the master backplane inet address must be specified
as well as the slaves’ backplane and gateway inet addresses. This configuration
gives you greater control over the addresses that are assigned to the target boards.
If such control is not required, it is possible to have the proxy server assign the inet
addresses to the proxy clients. When VxWorks is configured for sequential
addressing, the proxy server assigns incremental inet addresses to the slave boards
based on the proxy server’s backplane inet address. The relevant configuration
macro is INCLUDE_SM_SEQ_ADDR. For example, if the proxy server has a
backplane inet address of 150.12.0.4, the inet address assigned to the first slave is
150.12.0.5, to the second slave 150.12.0.6, and so on. (See Figure 4-16.)
Using sequential addressing frees you from having to specify a backplane or a
gateway inet address for each proxy client. All the addresses are assigned by the
proxy server at boot time.
It is also possible to have the proxy server’s backplane address configured by
default. This allows for greater flexibility in the assignment of backplane inet
addresses. You are only required to assign the inet address for the proxy server’s
interface to the main network. The backplane address is assigned automatically by
adding 1 (one) to the network interface address.
To assign the proxy server’s backplane address by default, you must use a
configuration with default addressing as well as sequential addressing. The
relevant configuration macro is INCLUDE_PROXY_DEFAULT_ADDR. This frees
you from having to specify the backplane inet address of the proxy server and the
proxy clients, and the gateway address of the proxy clients.
For example, with VxWorks so configured: if the proxy server is given the inet
network address of 150.12.0.3, its backplane address is 150.12.0.4. The first proxy
client is assigned the inet address 150.12.0.5, the second 150.12.0.6, and so on.
Note that with proxy ARP it is no longer necessary to specify the gateway. Each
target on the shared-memory network (except the proxy server) can register itself
as a proxy client by specifying the proxy ARP flag, 0x100, in the boot flags instead
96
4
TCP/IP Under VxWorks
h1 h2
4
Main Network
150.12.0.1 150.12.0.2
(Ethernet)
150.12.0.3
Proxy
vx1 Server
(master)
Proxy Network
(Shared Memory Network) 150.12.0.4
Proxy
vx2 vx3 vx4 Clients
(slaves)
Network 161
(IP Routing Network) 161.27.0.1
161.27.0.2 161.27.0.3
vx5 vx6
of specifying the gateway. For additional information on booting with proxy ARP,
see 13.5 Booting from the Shared-Memory Network, p.201.
VxWorks Images for Proxy ARP with Shared Memory and IP Routing
Even if you are using the same board for the master and the slaves, the master and
slaves need separate BSP directories because they have different configurations.
97
VxWorks Network 5.4
Programmer’s Guide
For more information on configuring VxWorks, see the Tornado User’s Guide:
Projects.
■ Proxy ARP and Shared Memory Definition in the VxWorks Configuration:
#define PROXY_ARP_MASTER
#define SM_OFF_BOARD=FALSE
#define PROXY_ARP_SLAVE
#define SM_OFF_BOARD=TRUE
See 3.5 Shared-Memory Network on the Backplane, p.40 for information on booting
shared memory networks. After booting vx1 (the master), use smNetShow( ) to
find the shared memory anchor, which will be used with the slave boot device (for
vx2, vx3, and vx4). You will need to run sysLocalToBusAddr( ) on the master and
sysBusToLocalAddr( ) on each type of target to get the correct bus address for the
anchor. For general information on boot parameters, see the Tornado User’s Guide:
Getting Started.
From vx1 (the master): Use routeAdd( ) to tell the master (the proxy server) about
the IP routing network by running the following:
-> routeAdd ("161.27.0.0", "150.12.0.6")
value = 0 = 0x0
From vx3: Since vx3 boots from the shared memory network, it needs to have its
connection to the IP routing network brought up explicitly. The following example
shows how to do this for vx3 in Figure 4-16:
98
4
TCP/IP Under VxWorks
NOTE: Substitute the appropriate network boot device for “ln”. The correct boot 4
device is the first one given by ifShow( ).
The following routines can be useful in locating the source of routing problems:
ping( )
Starting from vx1, ping other processors in turn to see if you get the expected
result. The function returns OK if it reaches the other machine, or ERROR if the
connection fails.
smNetShow( )
This routine displays cumulative activity statistics for all attached processors.
arpShow( )
This routine displays the current Internet-to-Ethernet address mappings in the
system ARP table.
arptabShow( )
This routine displays the known Internet-to-Ethernet address mappings in the
ARP table
routeShow( )
This routine displays the current routing information contained in the routing
table.
ifShow( )
This routine displays the attached network interfaces for debugging and
diagnostic purposes.
proxyNetShow( )
This routine displays the proxy networks and their associated clients.
proxyPortShow( )
This routine displays the ports currently enabled.
99
VxWorks Network 5.4
Programmer’s Guide
100
5
Network Configuration
Protocols
5.1 Introduction
This section describes the protocols used for retrieving network configuration
information. These protocols are:
■ DHCP (Dynamic Host Configuration Protocol)
■ BOOTP (Boot Strap Protocol)
■ SNMP (Simple Network Management Protocol)
Both a DHCP server and a BOOTP server can supply an Internet host with an IP
address and related configuration information. When a BOOTP server assigns an
IP address to an Internet host, the address is permanently assigned.
A DHCP server is more flexible. It assigns an IP address on either a permanent or
leased basis. Leased IP addresses are an advantage in environments where large
numbers of Internet hosts join the network for sessions of limited duration.
Unfortunately, predicting the duration of such sessions is not usually possible at
the time the leases are assigned.
Fortunately, a DHCP client has the ability to recontact its server and renegotiate the
lease on an IP address (or request a replacement address). Unlike a BOOTP client,
a DHCP client must remain active for as long as the target needs a current lease on
an IP address.
Also included at the end of this section is a brief description of SNMP, a separately
purchasable optional networking product that is compatible with VxWorks. For
detailed usage information on SNMP, see the WindNet SNMP VxWorks Optional
Product Supplement.
101
VxWorks Network 5.4
Programmer’s Guide
Both the DHCP and BOOTP clients use broadcasts to discover an appropriate
server. As a result, both protocols require network devices capable of link-layer
broadcasts. In addition, the current VxWorks implementations of DHCP and
BOOTP assume Ethernet. Thus, under VxWorks, DHCP and BOOTP support only
Ethernet devices and the shared-memory network driver.
VxWorks includes a DHCP client, server, and relay agent. The DHCP client can
retrieve one or more sets of configuration parameters from either a DHCP or
BOOTP server. The DHCP client also maintains any leases it has retrieved.
Likewise, the DHCP server can process both BOOTP and DHCP messages. Both
the client and server implementations support all options described in RFC 1533.
The DHCP relay agent provides forwarding of DHCP and BOOTP messages across
subnet boundaries. 1
1. In addition to the supported target-resident server, VxWorks also includes source for an
unsupported UNIX-compatible DHCP server. See target/unsupported/dhcp-1.3beta.
102
5
Network Configuration Protocols
! WARNING: The Tornado tools do not currently have any way to discover or
5
respond to a change in the target’s IP address. Such a change breaks the network
connection. In response, you must manually reconnect the Tornado tools to the
target’s new IP address. During development, this is rarely a serious problem, and
you can avoid it by having the DHCP server issue an infinite lease on the target’s
IP address.
The following configuration macros are defined by default for the DHCP client:
DHCP Client Target Port
Port monitored by DHCP servers. Default: 67. (Configuration constant:
DHCPC_SPORT)
103
VxWorks Network 5.4
Programmer’s Guide
NOTE: In addition to setting values for the defines mentioned above, most real-
world uses of DHCP require that you provide an event hook routine to handle
lease events. For more information, see the dhcpcEventHookAdd( ) reference entry.
Configuring the DHCP server requires that you create a pool of configuration
parameter sets. Each parameter set must include an IP address. When a DHCP
104
5
Network Configuration Protocols
client makes a request of the server, the server can then assign a parameter set to
the client (either permanently or on a leased basis). To store and maintain this pool
of configuration parameter sets, some DHCP servers use one or more files. This
approach is analogous to the use of the bootptab file associated with SunOS
BOOTP servers. The unsupported DHCP server distributed with VxWorks takes
this approach.
However, some VxWorks targets do not include a file system. The supported 5
target-resident DHCP server does not use a file-based mechanism for parameter
storage. Instead, the target-resident server maintains configuration parameters in
memory-resident structures. To control the contents of these memory-resident
structures, you must modify the source code that defines these structures.
The following sections describe how to configure the supported DHCP server.
Also included are pointers to reference information on configuring the
unsupported DHCP server. If you decide to use a third-party DHCP server, consult
the configuration information in the vendor-supplied documentation.
105
VxWorks Network 5.4
Programmer’s Guide
DHCPS_MAX_LEASE
Default: 3600. This constant specifies the maximum lease length in
seconds. This value applies if no explicit value is set in the address pool.
DHCP Server/Relay Agent Network Radius
Default: 4. This value limits the number of subnets that a DHCP message
can cross (prevents network flooding). The maximum valid value is 16.
(Configuration constant: DHCP_MAX_HOPS)
DHCP Server/Relay Agent Host Port
Default: 67. This value specifies the port monitored by DHCP servers.
(Configuration constant: DHCP_SPORT)
DHCP Server/Relay Agent Target Port
Default: 68. This value specifies the port monitored by DHCP clients.
(Configuration constant: DHCPS_CPORT)
To determine its initial configuration data, the supported DHCP server uses the
dhcpsLeaseTbl structure defined in usrNetwork.c. This structure describes the
server’s pool of network configuration parameter sets. It has the following format:
DHCPS_LEASE_DESC dhcpsLeaseTbl [] =
{
/* {"Name", "Start IP", "End IP", "parameters"} */
};
Each entry in this lease table must include an unique entry name of up to eight
characters and an IP address range for assignment to requesting clients. The
parameters field contains a colon-separated list of optional parameters for
inclusion in the DHCP server’s response. If subnetting is in effect, a critical entry
in the parameters field is the subnet mask (snmk). The server does not issue
106
5
Network Configuration Protocols
addresses to clients which would change their current subnet. The address pool
must specify a correct subnet mask if the default class-based mask is not valid.
A complete description of the parameters field is found in the manual pages for the
DHCP server. Any parameters not specified take default values according to the
Host Requirements Documents (RFC 1122 and 1123). The server can also read
additional entries from an optional storage hook (discussed below).
5
The sample entries shown above demonstrate the possible server-issued lease
types:
clid Indicates that this is a manual lease. Such a lease is issued only to the client
with the matching type:id pair. The address range for these entries must
specify a single IP address. The sample shown for “ent1” uses the
hardware address which the supported DHCP client uses for an identifier.
maxl Indicates that this lease is dynamic. This parameter specifies the maximum
lease duration granted to any requesting client. The automatic lease
illustrated in the third sample entry is implied by the assignment of an
infinite value for maxl.
albp Indicates a special type of automatic lease. Setting the albp parameter to
true in the fourth entry marks this lease as suitable for BOOTP clients that
contact this DHCP server.
The lease type is used by the server to select one of the three supported
mechanisms for IP address allocation. With manual allocation, DHCP simply
conveys the related manual lease to the client. If dynamic allocation is used, the
protocol assigns one of the dynamic leases to the client for a finite period.
Automatic allocation assigns a permanent IP address from the corresponding
automatic leases.
Dynamic allocation is the only method that allows reuse of addresses. The
allocation type defines the priority for assigning an IP address to a DHCP client.
Manual allocations have the highest priority, and automatic allocations the lowest.
Among automatic leases, configurations which are available only to DHCP clients
are preferred.
After the server has started, use the following routine to add new entries to the
lease database:
107
VxWorks Network 5.4
Programmer’s Guide
STATUS dhcpsLeaseEntryAdd
(
char * pName, /* Name of lease entry. */
char * pStartIp, /* First IP address to assign. */
char * pEndIp, /* Last IP address in assignment range. */
char * pParams /* Formatted string of lease parameters. */
)
! CAUTION: Not providing the storage routine could cause DHCP to fail.
Your lease storage routine must store and retrieve active network configurations.
To install the routine you created, configure VxWorks with the DHCP Server Lease
Storage Routine set to a string containing the routine name. The relevant
configuration macro is DHCPS_LEASE_HOOK.
The address storage routine uses the following prototype:
STATUS dhcpsAddressStorageHook
(
int op, /* requested storage operation */
char * pName, /* name of address pool entry */
char * pStartIp, /* first IP address in range */
char * pEndIp, /* last IP address in range */
char * pParams /* lease parameters for each address */
)
108
5
Network Configuration Protocols
Your address storage routine (optional) stores and retrieves additional address-
pool entries using dhcpsLeaseEntryAdd( ). To preserve these entries, configure
VxWorks with the DHCP Server Address Storage Routine set to the name of the
storage routine. The relevant configuration macro is DHCPS_ADDRESS_HOOK. If
this configuration is not done, active leases using alternate entries are not renewed
when the server is restarted.
The cmd parameters of both storage routines expect one of the following values:2 5
DHCPS_STORAGE_START
Tells your storage routine to perform any necessary initialization. Your
storage routine should “reset” and thus return or replace any previously
stored data.
DHCPS_STORAGE_STOP
Tells your storage routine to perform any necessary cleanup. After a stop,
the storage routine should not perform any reads or writes until after the
next start.
DHCPS_STORAGE_WRITE
Tells the routine to store network configurations. Each write must store the
data to some form of permanent storage.
The write functionality of your lease storage routine is critical. It is
required to preserve the integrity of the protocol and prevent assignment
of IP addresses to multiple clients. If the server is unable to store and
retrieve the active network configurations, the results are unpredictable.
The write functionality of the lease storage routine must accept a sequence
of bytes of the indicated length.
The write functionality of the address storage routine must accept NULL-
terminated strings containing the entry name, starting and ending
addresses, and additional parameters.
If a write completes successfully, the routine must return OK.
DHCPS_STORAGE_READ
Tells your storage routine to retrieve network configurations. Each read
must copy the data (stored by earlier writes) into the buffers provided. The
returned information must be of the same format provided to the write
operation.
If a read completes successfully, your routine must return OK. If earlier
reads have retrieved all available data, or no data is available, your routine
109
VxWorks Network 5.4
Programmer’s Guide
must return ERROR. The server calls your routine with read requests until
ERROR is returned.
DHCPS_STORAGE_CLEAR
Used only in calls to your lease storage routine. This value tells your
routine that any data currently stored is no longer needed. Following this
operation, reads should return error until after the next write.
The unsupported DHCP server is a port of a public domain server available from
the WIDE project. This port modifies the original code so that it supports Solaris as
well as SunOS. As a convenience, WRS provides the code for the unsupported
sever in target/unsupported/dhcp-1.3beta. Unlike the supported VxWorks DHCP
server, the unsupported server uses files to store the databases that track the IP
addresses and the other configuration parameters that it distributes.
You can specify the names of these files in the dhcps command that you use to start
the DHCP server. If you do not specify the configuration files by name, the server
uses the following defaults: /etc/dhcpdb.pool, and /etc/dhcpdb.bind (or
/var/db/dhcpdb.bind for BSD/OS). If the server supports a relay agent, it also
maintains an extra database with the default name of /etc/dhcpdb.relay. The server
also creates other files as needed in the /etc directory, but you do not need to edit
these files to configure the server.
For the specifics of how you should edit these files, see the DHCPS(5),
DHCPDB.POOL(5), and DHCPDB.RELAY(5) man pages included with the source
code for the unsupported DHCP server.
The relay agent uses some of the same configuration constants as the DHCP server:
DHCP Server/Relay Agent Network Radius
Default: 4. Hops before discard, up to 16. (Configuration constant:
DHCP_MAX_HOPS)
110
5
Network Configuration Protocols
Each entry in the table must specify a valid IP address for a DHCP server on a
different subnet than the relay agent. The relay agent transmits a copy of all DHCP
messages sent by clients to each of the specified addresses. The agent does not set
the IP routing tables so that the specified target addresses are reachable.
The relay agent forwards DHCP client messages through only a limited number of
targets: the DHCP Server/Relay Agent Network Radius. When the value specified
in the VxWorks configuration is exceeded, the message is silently discarded. This
value is only increased when the message is forwarded by a DHCP agent. It is
completely independent of the similar value used by IP routers. RFC 1542 specifies
the maximum value of 16 for this constant. The default hops value is four.
Beyond providing the list of target addresses, and optionally changing the
maximum number of hops permitted, no further action is necessary. The DHCP
relay agent executes automatically whenever it is included in the VxWorks image.
111
VxWorks Network 5.4
Programmer’s Guide
In the code above, the dhcpcInit( ) call used a value of TRUE for the autoconfig
parameter. This automatically includes a request for a subnet mask and broadcast
address in the cookie (pLeaseCookie). To request additional options for this lease
(such as a lease duration of 30 minutes) the code makes a call to dhcpcOptionSet( ).
Because the DHCP protocol requires that all requested parameters be specified
before a lease is established, the dhcpcOptionSet( ) call must precede the
asynchronous dhcpcBind( ) call that establishes the lease.
Although it is omitted from the example, you can use a dhcpcLeaseHookAdd( ) call
to associate a lease event hook routine with this lease. That way, you can note the
DHCPC_LEASE_NEW event that occurs when the asynchronous dhcpcBind( )
completes its negotiations with the DHCP server.
To query the local DHCP client for a parameter value from the lease information it
has retrieved, call dhcpcOptionGet( ). This routine checks whether the lease
associated with a particular lease cookie is valid and whether the requested
parameter was provided by the server. If so, dhcpcOptionGet( ) copies the
parameter value into a buffer. Otherwise, it returns ERROR. A call to
dhcpcOptionGet( ) generates no network traffic; it queries the local DHCP client
for the information it needs. The following sample demonstrates the use of this
routine:
inet_addr webServer;
STATUS result;
...
result = dhcpcOptionGet (pLeaseCookie, _DHCP_DFLT_WWW_SERVER_TAG, 4,
&webServer);
3. The limit on the number of concurrent leases is the “DHCP Client Maximum Leases” value
set during configuration (configuration constant: DHCPC_MAX_LEASES). When setting
this value, remember to count the lease (if any) that the client retrieved at boot time.
112
5
Network Configuration Protocols
if (result == OK)
printf("Primary web server: %s", inet_ntoa (webServer));
...
NOTE: For many applications, the DHCP protocol can function as an alternative
to BOOTP.
4. For the complete BOOTP protocol specification, see RFC 951 “Bootstrap Protocol (BOOTP),”
RFC 1542 “Clarifications and Extensions for BOOTP,” and RFC 1048 “BOOTP Vendor Infor-
mation Extensions.”
113
VxWorks Network 5.4
Programmer’s Guide
Using the BOOTP server to supply boot parameters requires that you edit the
server’s BOOTP database file, bootptab. However, the specifics of how to do this
can vary from server to server. Refer to the manuals for your host’s BOOTP server.
If the host does not provide a BOOTP server as part of the operating system, a copy
of the publicly available CMU BOOTP server is provided in
target/unsupported/bootp2.1.
The following discussion of how to modify bootptab applies to the CMU BOOTP
server.
To register a VxWorks target with the BOOTP server, you must enter the target
parameters in the host’s BOOTP database (/etc/bootptab). The following is an
example bootptab for the CMU version of the BOOTP server:
# /etc/bootptab: database for bootp server (/etc/bootpd)
# Last update Mon 11/7/88 18:03
# Blank lines and lines beginning with '#' are ignored.
#
# Legend:
#
# first field -- hostname
# (may be full domain name and probably should be)
#
# hd -- home directory
# bf -- boot file
# cs -- cookie servers
# ds -- domain name servers
# gw -- gateways
# ha -- hardware address
114
5
Network Configuration Protocols
# ht -- hardware type
# im -- impress servers
# ip -- host IP address
# lg -- log servers
# lp -- LPR servers
# ns -- IEN-116 name servers
# rl -- resource location protocol servers
# sm -- subnet mask
# tc -- template host (points to similar host entry)
# to -- time offset (seconds) 5
# ts -- time servers
#
# Be careful to include backslashes where they are needed. Weird (bad)
# things can happen when a backslash is omitted where one is intended.
#
# First, we define a global entry which specifies what every host uses.
global.dummy:\
:sm=255.255.255.0:\
:hd=/usr/wind/target/vxBoot:\
:bf=vxWorks:
vx240:ht=ethernet:ha=00DD00CB1E05:ip=150.12.1.240:tc=global.dummy
vx241:ht=ethernet:ha=00DD00FE2D01:ip=150.12.1.241:tc=global.dummy
vx242:ht=ethernet:ha=00DD00CB1E02:ip=150.12.1.242:tc=global.dummy
vx243:ht=ethernet:ha=00DD00CB1E03:ip=150.12.1.243:tc=global.dummy
vx244:ht=ethernet:ha=0000530e0018:ip=150.12.1.244:tc=global.dummy
Note that common data is described in the entry global.dummy. Any target
entries that want to use the common data use tc=global.dummy. Any target-
specific information is listed separately on the target line. For example, in the
previous file, the entry for the target vx244 specifies only its Ethernet address
(0000530e0018) and IP address (150.12.1.244). The subnet mask (255.255.255.0),
home directory (/usr/wind/target/vxBoot), and boot file (vxWorks) are taken from
the common entry global.dummy.
To register a VxWorks target with the BOOTP server, log onto the host machine,
edit the BOOTP database file to include an entry that specifies the target address
(ha=), IP address (ip=), and boot file (bf=). For example, to add a target called
vx245, with Ethernet address 00:00:4B:0B:B3:A8, IP address 150.12.1.245, and boot
file /usr/wind/target/vxBoot/vxWorks, you would add the following line to the
file:
vx245:ht=ethernet:ha=00004B0BB3A8:ip=150.12.1.245:tc=global.dummy
115
VxWorks Network 5.4
Programmer’s Guide
Note that you do not need to specify the boot file name explicitly. The home
directory (hd) and the boot file (bf) are taken from global.dummy.
When performing the boot file name translation, the BOOTP server uses the value
specified in the boot file field of the client request message as well as the bf (boot
file) and the hd (home directory) field in the database. If the form of the file name
calls for it (for example, if it is relative), the server prefixes the home directory to
the file name. The server checks for the existence of the file; if the file is not found,
it sends no reply. For more information, see bootpd in the manual for your host.
When the server checks for the existence of the file, it also checks whether its read-
access bit is set to public, because this is required by tftpd(8) to permit the file
transfer. All file names are first tried as filename.hostname and then as filename, thus
providing for individual per-host boot files.
In the previous example, the server first searches for the file
/usr/wind/target/vxBoot/vxWorks.vx245. If the file does not exist, the server looks
for /usr/wind/target/vxBoot/vxWorks.
116
6
Dynamic Routing Protocols
6.1 Introduction
VxWorks retrieves routing information by searching for it in a routing table. To set
up and manage this table manually, use the routines routeAdd( ) or mRouteAdd( ).
However, because the network environment is constantly in flux, the information
in the routing table grows obsolete as machines join or leave the network. To
update the routing table dynamically, VxWorks supports two protocols:
■ RIP (Routing Information Protocol)
■ OSPF (Open Shortest Path First)
RIP, the older and simpler protocol, comes bundled with VxWorks, and is intended
for small to medium-sized networks. OSPF is a separately purchasable option for
use with VxWorks. OSPF is superior to RIP in many ways. For example, OSPF is a
link-state protocol, not a distance-vector protocol, like RIP. The messages from a
distance-vector protocol contain a vector of distances (a hop count). Each router uses
these distance-vectors to update its routing tables.
A router running a link-state protocol, such as OSPF, is more active about getting the
information it needs. An OSPF router actively tests the status of its links to its
neighbors, and then shares this information with other OSPF routers. One result of
this more active approach is faster network stabilization after a change, such as the
loss of a router or a link. Unfortunately, this enhanced stabilization comes at the
price of increased complexity. As a result, it requires considerably more thought to
configure OSPF correctly.
117
VxWorks Network 5.4
Programmer’s Guide
1. A packet takes a hop every time it crosses a subnet. If a packet leaves machine Q and must
pass through two subnet routers before it reaches its destination on machine N, the number
of hops is two.
118
6
Dynamic Routing Protocols
Provided with the RIP server are several routines that make debugging easier. The
most often used is ripLogLevelBump( ), which enables tracing of packets and
routing changes. Keep in mind that bumping the log level several times prints a lot
of data to the console. Another routine is ripRouteShow( ), which prints the
router’s internal tables to the console. The printed message provides the following
information:
6
■ the route being advertised
■ the router that routes the packets
■ a subnet mask
■ the timeout on the route (in seconds)2
■ the flags value (see Table 6-1)
Constant Meaning
2. The timeout is the length of time for which the route remains current. If a route is not
updated after 3 minutes, it is flushed from the routing table.
119
VxWorks Network 5.4
Programmer’s Guide
To include the RIP server, reconfigure the VxWorks image. The relevant
configuration macro is INCLUDE_RIP. The RIP server starts up when
usrNetwork.c calls ripLibInit( ). This routine takes four parameters. You set the
value of these parameters by editing the configuration and adjusting the following
configuration items:
RIP Supplier Flag
Set to 1 tells the RIP server to send out routing information and updates
no matter how many physical interfaces are attached to it. Setting this
constant to 0 turns off this feature. (Configuration macro: RIP_SUPPLIER)
RIP Gateway Flag
Set to 1 tells the server that it is a router to the greater Internet. If this is
not the case, set this constant to 0 (the default). (Configuration macro:
RIP_GATEWAY)
! WARNING: Do not set RIP_GATEWAY to 1 unless this really is the general gateway.
Setting this to 1 makes the RIP server send a default route (0.0.0.0) out with every
routing update. This tells all the other listening servers that this server is the
default route for its subnet. This causes all packets to go to this router if they do not
have a route that matches an existing entry in their routing table.
120
6
Dynamic Routing Protocols
! CAUTION: The RIP server does not support separate routing domains. Only
routing domain 0, the default, is supported.
In addition to setting the defines shown above, there are two alternate methods
you can use to configure RIP:
6
■ Use the m2Rip routines to configure RIP. These routines are documented in the
reference entries. The parameters to these routines are also described in RFC-
1389.
■ Use an SNMP agent to configure RIP.
121
VxWorks Network 5.4
Programmer’s Guide
To start OSPF, call ospfInit( ) after VxWorks has completed booting. This routine is
defined as follows:
STATUS ospfInit
(
int priority, /* Priority of tasks. */
int options,
int stackSize, /* Task stack size. */
int routerId /* The ID for this router. */
)
After OSPF is up and running, you must configure the OSPF MIB. To do this, use
the various m2Ospf routines. The parameters to these routines are specified in
the OSPF MIB as defined in RFC1253. The RFC provides explanations for all of
these routines and parameters. In addition, the VxWorks implementation of OSPF
supports additional configuration functions:
ospfAddExtRoute( )
Imports an external route into the OSPF domain.
ospfDelExtRoute( )
Deletes a route imported using ospfAddExtRoute( ).
ospfAddNbmaDest( )
Adds a destination on a NBMA (Non Broadcast Multi Access) link.
These routines are not MIB routines. They are convenience interfaces provided for
adding and removing external routes. For more information, see reference entries
for these routines.
This section provides an example router setup as well as the code necessary to
make the example work. In the example system, a router is attached to 2 subnets
160.10.10.00 and 160.10.11.00 with 0xffffff00 as the subnetmask. The interface
addresses are 160.10.10.5 and 160.10.11.5. The diagram in Figure 6-1 shows this
setup.
To set this up programatically, execute the following code:
void ospfSetup ()
{
/* This is a generic setup for all interfaces in the system. */
M2_OSPF_AREA_ENTRY area;
122
6
Dynamic Routing Protocols
160.10.11.00
160.10.11.5
Interface B
Router
Interface A 6
160.10.10.5
160.10.10.00
M2_OSPF_IF_ENTRY intf;
area.ospfAreaId = 0x2; /* using area id 2
area.ospfAuthType = 0; /* no authentication
if (m2OspfAreaEntrySet (M2_OSPF_AREA_ID |
M2_OSPF_AUTH_TYPE, area) != OK)
{
return (ERROR);
};
/* interface type */
intf.ospfIfType = 1;
/* router priority */
intf.ospfIfRtrPriority = 5;
123
VxWorks Network 5.4
Programmer’s Guide
M2_OSPF_IF_TYPE |
M2_OSPF_IF_RTR_PRIORITY |
M2_OSPF_IF_RETRANS_INTERVAL |
M2_OSPF_IF_HELLO_INTERVAL |
M2_OSPF_IF_RTR_DEAD_INTERVAL |
M2_OSPF_IF_POLL_INTERVAL |
M2_OSPF_IF_ADMIN_STAT,
& intf) != OK)
{
return (ERROR);
}
if (m2OspfIfEntrySet ( M2_OSPF_ADDRESS_LESS_IF |
M2_OSPF_IF_AREA_ID |
M2_OSPF_IF_TYPE |
M2_OSPF_IF_RTR_PRIORITY |
M2_OSPF_IF_RETRANS_INTERVAL |
M2_OSPF_IF_HELLO_INTERVAL |
M2_OSPF_IF_RTR_DEAD_INTERVAL |
M2_OSPF_IF_POLL_INTERVAL |
M2_OSPF_IF_ADMIN_STAT, & intf) != OK)
{
return (ERROR);
}
}
After this code has executed, the system uses OSPF to route between the two
interfaces, A and B. The system continues to use OSPF until either the system is
shut off or further calls are made into the system using the m2Ospf interfaces.
124
7
Networking APIs
7.1 Introduction
This section describes how to use the standard BSD socket interface for stream
sockets and datagram sockets on a VxWorks target. It also describes how to use
zbuf sockets, an alternative set of socket calls based on a data abstraction called the
zbuf. These zbuf calls let you share data buffers (or portions of data buffers)
between separate software modules.
Using sockets, processes can communicate within a single CPU, across a
backplane, across an Ethernet, or across any connected combination of networks.
Socket communications can occur between VxWorks tasks and host system
processes in any combination. In all cases, the communications appear identical to
the application—except, of course, for the speed of the communications.
One of the biggest advantages of socket communication is that it is a
“homogeneous” mechanism: socket communications among processes are exactly
the same, regardless of the location of the processes in the network or the operating
system where they run. This is true even if you use zbuf sockets, which are fully
interoperable with standard BSD sockets.
125
VxWorks Network 5.4
Programmer’s Guide
126
7
Networking APIs
Task 1 Task 2
Function Analogy
Waits Calls
7
socket( ) socket( ) Create sockets. Hook up telephones.
/* defines */
#define SERVER_PORT_NUM 5001 /* server's port number for bind() */
#define SERVER_WORK_PRIORITY 100 /* priority of server's work task */
#define SERVER_STACK_SIZE 10000 /* stack size of server's work task */
#define SERVER_MAX_CONNECTIONS 4 /* max clients connected at a time */
#define REQUEST_MSG_SIZE 1024 /* max size of request message */
#define REPLY_MSG_SIZE 500 /* max size of reply message */
127
VxWorks Network 5.4
Programmer’s Guide
/*
DESCRIPTION
This file contains the client-side of the VxWorks TCP example code.
The example code demonstrates the usage of several BSD 4.4-style
socket routine calls.
*/
/* includes */
#include "vxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "hostLib.h"
#include "ioLib.h"
#include "tcpExample.h"
/****************************************************************************
*
* tcpClient - send requests to server over a TCP socket
*
* This routine connects over a TCP socket to a server, and sends a
* user-provided message to the server. Optionally, this routine
* waits for the server's reply message.
*
* This routine may be invoked as follows:
* -> tcpClient "remoteSystem"
* Message to send:
* Hello out there
* Would you like a reply (Y or N):
* y
* value = 0 = 0x0
* -> MESSAGE FROM SERVER:
* Server received your message
*
* RETURNS: OK, or ERROR if the message could not be sent to the server.
*/
STATUS tcpClient
(
char * serverName /* name or IP address of server */
128
7
Networking APIs
)
{
struct request myRequest; /* request to send to server */
struct sockaddr_in serverAddr; /* server's socket address */
char replyBuf[REPLY_MSG_SIZE]; /* buffer for reply */
char reply; /* if TRUE, expect reply back */
int sockAddrSize; /* size of socket address structure */
int sFd; /* socket file descriptor */
int mlen; /* length of message */
/* connect to server */
if (connect (sFd, (struct sockaddr *) &serverAddr, sockAddrSize) == ERROR)
{
perror ("connect");
close (sFd);
return (ERROR);
}
129
VxWorks Network 5.4
Programmer’s Guide
close (sFd);
return (OK);
}
/*
DESCRIPTION
This file contains the server-side of the VxWorks TCP example code.
The example code demonstrates the useage of several BSD 4.4-style
socket routine calls.
*/
/* includes */
#include "vxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "taskLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "ioLib.h"
#include "fioLib.h"
#include "tcpExample.h"
/* function declarations */
/****************************************************************************
*
* tcpServer - accept and process requests over a TCP socket
130
7
Networking APIs
*
* This routine creates a TCP socket, and accepts connections over the socket
* from clients. Each client connection is handled by spawning a separate
* task to handle client requests.
*
* This routine may be invoked as follows:
* -> sp tcpServer
* task spawned: id = 0x3a6f1c, name = t1
* value = 3829532 = 0x3a6f1c
* -> MESSAGE FROM CLIENT (Internet Address 150.12.0.10, port 1027):
* Hello out there
*
* RETURNS: Never, or ERROR if a resources could not be allocated.
*/ 7
131
VxWorks Network 5.4
Programmer’s Guide
close (sFd);
return (ERROR);
}
FOREVER
{
if ((newFd = accept (sFd, (struct sockaddr *) &clientAddr,
&sockAddrSize)) == ERROR)
{
perror ("accept");
close (sFd);
return (ERROR);
}
perror ("taskSpawn");
close (newFd);
}
}
}
/****************************************************************************
*
* tcpServerWorkTask - process client requests
*
* This routine reads from the server's socket, and processes client
* requests. If the client requests a reply message, this routine
* will send a reply to the client.
*
* RETURNS: N/A.
*/
VOID tcpServerWorkTask
(
int sFd, /* server's socket fd */
char * address, /* client's socket address */
u_short port /* client's socket port */
)
{
struct request clientRequest; /* request/message from client */
int nRead; /* number of bytes read */
static char replyMsg[] = "Server received your message";
132
7
Networking APIs
{
printf ("MESSAGE FROM CLIENT (Internet Address %s, port %d):\n%s\n",
address, port, clientRequest.message);
if (clientRequest.reply)
if (write (sFd, replyMsg, sizeof (replyMsg)) == ERROR)
perror ("write");
}
struct request
{
int display; /* TRUE = display message */
char message[REQUEST_MSG_SIZE]; /* message buffer */
};
133
VxWorks Network 5.4
Programmer’s Guide
/*
DESCRIPTION
This file contains the client-side of the VxWorks UDP example code.
The example code demonstrates the useage of several BSD 4.4-style
socket routine calls.
*/
/* includes */
#include "vxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "hostLib.h"
#include "ioLib.h"
#include "udpExample.h"
/****************************************************************************
*
* udpClient - send a message to a server over a UDP socket
*
* This routine sends a user-provided message to a server over a UDP socket.
* Optionally, this routine can request that the server display the message.
* This routine may be invoked as follows:
* -> udpClient "remoteSystem"
* Message to send:
* Greetings from UDP client
* Would you like server to display your message (Y or N):
* y
* value = 0 = 0x0
*
* RETURNS: OK, or ERROR if the message could not be sent to the server.
*/
STATUS udpClient
(
char * serverName /* name or IP address of server */
)
{
struct request myRequest; /* request to send to server */
struct sockaddr_in serverAddr; /* server's socket address */
char display; /* if TRUE, server prints message */
int sockAddrSize; /* size of socket address structure */
int sFd; /* socket file descriptor */
int mlen; /* length of message */
134
7
Networking APIs
{
perror ("socket");
return (ERROR);
}
printf ("Would you like the server to display your message (Y or N): \n");
read (STD_IN, &display, 1);
switch (display)
{
case 'y':
case 'Y': myRequest.display = TRUE;
break;
default: myRey = FALSE;
break;
}
close (sFd);
return (OK);
}
135
VxWorks Network 5.4
Programmer’s Guide
/*
DESCRIPTION
This file contains the server-side of the VxWorks UDP example code.
The example code demonstrates the useage of several BSD 4.4-style
socket routine calls.
*/
/* includes */
#include "vxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "ioLib.h"
#include "fioLib.h"
#include "udpExample.h"
/*********************************************************************
*
* udpServer - read from UDP socket and display client's message if requested
*
* Example of VxWorks UDP server:
* -> sp udpServer
* task spawned: id = 0x3a1f6c, name = t2
* value = 3809132 = 0x3a1f6c
* -> MESSAGE FROM CLIENT (Internet Address 150.12.0.11, port 1028):
* Greetings from UDP client
*
* RETURNS: Never, or ERROR if a resources could not be allocated.
*/
136
7
Networking APIs
FOREVER
{
if (recvfrom (sFd, (char *) &clientRequest, sizeof (clientRequest), 0,
(struct sockaddr *) &clientAddr, &sockAddrSize) == ERROR)
{
perror ("recvfrom");
close (sFd);
return (ERROR);
}
if (clientRequest.display)
{
/* convert inet address to dot notation */
137
VxWorks Network 5.4
Programmer’s Guide
138
7
Networking APIs
224.0.0.3 Unassigned.
mcastRcv( ) receives any packet sent to a specified multicast address. As input, this
routine expects the interface address from which the packet is coming, a multicast
address, a port number, and the number of bytes to read from the packet. The
returned value of the function is a pointer a buffer containing the read bytes. For
example:
buf = mcastRcv (ifAddress, "224.1.0.1", 7777, 100) ;
139
VxWorks Network 5.4
Programmer’s Guide
/* includes */
#include "vxWorks.h"
#include "taskLib.h"
#include "socket.h"
#include "netinet/in.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sockLib.h"
#include "inetLib.h"
#include "ioLib.h"
#include "routeLib.h"
/* defines */
/* globals */
/* forward declarations */
/************************************************************************
* mcastSend - send a message to the multicast address
* This function sends a message to the multicast address
* The multicast group address to send, the port number, the pointer to the
* send buffer and the send buffer length are given as input parameters.
* RETURNS: OK if sucessful or ERROR
*/
STATUS mcastSend
(
char * mcastAddr, /* multicast address */
USHORT mcastPort, /* udp port number */
char * sendBuf, /* send Buffer */
int sendLen /* length of send buffer */
)
{
struct sockaddr_in sin;
struct sockaddr_in toAddr;
int toAddrLen;
int sockDesc;
char * bufPtr;
int len;
140
7
Networking APIs
return (ERROR);
}
sendLen -= len;
bufPtr += len;
if (sockDesc != ERROR)
close (sockDesc);
return (OK);
}
/************************************************************************
141
VxWorks Network 5.4
Programmer’s Guide
char * mcastRcv
(
char * ifAddr, /* interface address to recv mcast packets */
char * mcastAddr, /* multicast address */
USHORT mcastPort, /* udp port number to recv */
int numRead /* number of bytes to read */
)
{
struct sockaddr_in fromAddr;
struct sockaddr_in sin;
int fromLen;
struct ip_mreq ipMreq;
int recvLen;
int sockDesc;
char * bufPtr;
int status = OK;
char * recvBuf = NULL;
142
7
Networking APIs
cleanUp:
{
if (sockDesc != ERROR)
close (sockDesc);
if ((status != OK) && (recvBuf != NULL))
{
free (recvBuf);
recvBuf = NULL;
}
}
143
VxWorks Network 5.4
Programmer’s Guide
return (recvBuf);
}
! WARNING: The send socket buffer size (set during configuration, using the macros
TCP_SND_SIZE_DFLT or UDP_SND_SIZE_DFLT) must exceed that of any zbufs
sent over the socket
To link (and initialize) the zbuf socket interface, reconfigure VxWorks. The
relevant configuration macro is INCLUDE_ZBUF_SOCK.
The simplest way to use zbuf sockets is to call either zbufSockBufSend( ) (in place
of send( ) for a TCP connection) or zbufSockBufSendto( ) (in place of sendto( ) for
a UDP datagram). In either case, you supply a pointer to your application’s data
buffer containing the data or message to send, and the network protocol uses that
same buffer rather than copying the data out of it.
144
7
Networking APIs
! WARNING: Using zbufs allows different modules to share the same buffers. This
lets your application avoid the performance hit associated with copying the buffer.
To make this work, your application must not modify (let alone free!) the data
buffer while network software is still using it. Instead of freeing your buffer
explicitly, you can supply a free-routine callback: a pointer to a routine that knows
how to free the buffer. The zbuf library keeps track of how many zbufs point to a
data buffer, and calls the free routine when the data buffer is no longer in use.
To receive socket data using zbufs, see the following sections. 7.3.2 Manipulating
the Zbuf Data Structure, p.145 describes the routines to create and manage zbufs, 7
and 7.3.3 Zbuf Socket Calls, p.154 introduces the remaining zbuf-specific socket
routines. See also the reference entries for zbufLib and zbufSockLib.
You can address the contents of a zbuf by byte locations. A zbuf byte location has
two parts, an offset and a segment ID.
An offset is a signed integer (type int): the distance in bytes to a portion of data in
the zbuf, relative to the beginning of a particular segment. Zero refers to the first
byte in a segment; negative integers refer to bytes in previous segments; and
positive integers refer to bytes after the start of the current segment.
A segment ID is an arbitrary integer (type ZBUF_SEG) that identifies a particular
segment of a zbuf. You can always use NULL to refer to the first segment of a zbuf.
145
VxWorks Network 5.4
Programmer’s Guide
Figure 7-1 shows a simple zbuf with data organized into two segments, with
offsets relative to the first segment. This is the most efficient addressing scheme to
refer to bytes a, b, or c in the figure.
a b c
0 1 2
d e f g
3 4 5 6
Figure 7-2 shows the same zbuf, but labelled with offsets relative to the second
segment. This is the most efficient addressing scheme to refer to bytes d, e, f, or g
in the figure.
–3 –2 –1
a b c
0 1 2 3
d e f g
Two special shortcuts give the fastest access to either the beginning or the end of a
zbuf. The constant ZBUF_END refers to the position after all existing bytes in the
zbuf. Similarly, ZBUF_BEGIN refers to the position before all existing bytes. These
constants are the only offsets with meanings not relative to a particular segment.
When you insert data in a zbuf, the new data is always inserted before the byte
location you specify in the call to an insertion routine. That is, the byte location you
specify becomes the address of the newly inserted data.
146
7
Networking APIs
To create a new zbuf, call zbufCreate( ). The routine takes no arguments, and
returns a zbuf identifier (type ZBUF_ID) for a zbuf containing no segments. After
you have the zbuf ID, you can attach segments or otherwise insert data. While the
zbuf is empty, NULL is the only valid segment ID, and 0 the only valid offset.
When you no longer need a particular zbuf, call zbufDelete( ). Its single argument
is the ID for the zbuf to delete. The zbufDelete( ) routine calls the free routine
associated with each segment in the zbuf, for segments that are not shared by other
zbufs. After you delete a zbuf, its zbuf ID is meaningless; any reference to a deleted 7
zbuf ID is an error.
Call Description
The usual way to place data in a zbuf is to call zbufInsertBuf( ). This routine builds
a zbuf segment pointing to an existing data buffer, and inserts the new segment at
whatever byte location you specify in a zbuf. You can also supply a callback
pointer to a free routine, which the zbuf library calls when no zbuf segments point
to that data buffer.
Because the purpose of the zbuf socket interface is to avoid data copying, the need
to actually copy data into a zbuf (rather than designating its location as a shareable
buffer) occurs much less frequently. When that need does arise, however, the
routine zbufInsertCopy( ) is available. This routine does not require a callback
pointer to a free routine, because the original source of the data is not shared.
Similarly, the most efficient way to examine data in zbufs is to read it in place,
rather than to copy it to another location. However, if you must copy a portion of
data out of a zbuf (for example, to guarantee the data is contiguous, or to place it
in a data structure required by another interface), call zbufExtractCopy( )
specifying what to copy (zbuf ID, byte location, and the number of bytes) and
where to put it (an application buffer).
147
VxWorks Network 5.4
Programmer’s Guide
Call Description
zbufInsertBuf( ) Create a zbuf segment from a buffer and insert into a zbuf.
Operations on Zbufs
The routines listed in Table 7-6 perform several fundamental operations on zbufs.
Call Description
148
7
Networking APIs
to view the entire original range of data, another zbuf contains a leading fragment,
and the third zbuf holds the trailing fragment.
Similarly, if you call zbufCut( ) to remove some range of bytes from within a zbuf,
the effects are visible only to callers who view the data through the same zbuf ID
you used for the deletion; other zbuf segments can still address the original data
through a shared buffer.
For the most part, these routines do not free data buffers or delete zbufs, but there
are two exceptions:
■ zbufInsert( ) deletes the zbuf ID it inserts. No segments are freed, because they 7
now form part of the larger zbuf.
■ If the bytes you remove with zbufCut( ) span one or more complete segments,
the free routines for those segments can be called (if no other zbuf segment
refers to the same data).
The data-buffer free routine runs only when none of the data in a segment is part
of any zbuf; to avoid data copying, zbuf manipulation routines such as zbufCut( )
record which parts of a segment are currently in a zbuf, postponing the deletion of
a segment until no part of its data is in use.
Segments of Zbufs
The routines in Table 7-7 give your applications access to the underlying segments
in a zbuf.
Call Description
By specifying a NULL segment ID, you can address the entire contents of a zbuf as
offsets from its very first data byte. However, it is always more efficient to address
149
VxWorks Network 5.4
Programmer’s Guide
data in a zbuf relative to the closest segment. Use zbufSegFind( ) to translate any
zbuf byte location into the most local form.
The pair zbufSegNext( ) and zbufSegPrev( ) are useful for going through the
segments of a zbuf in order, perhaps in conjunction with zbufSegLength( ).
Finally, zbufSegData( ) allows the most direct access to the data in zbufs: it gives
your application the address where a segment’s data begins. If you manage
segment data directly using this pointer, bear the following restrictions in mind:
■ Do not change data if any other zbuf segment is sharing it.
■ As with any other direct memory access, it is up to your own code to restrict
itself to meaningful data: remember that the next segment in a zbuf is usually
not contiguous. Use zbufSegLength( ) as a limit, and zbufSegNext( ) when you
exceed that limit.
The following interaction illustrates the use of some of the previously described
zbufLib routines, and their effect on zbuf segments and data sharing. To keep the
example manageable, the zbuf data used is artificially small, and the execution
environment is the Tornado shell (for details on this shell, see the Tornado User’s
Guide: Shell).
To begin with, we create a zbuf, and use its ID zId to verify that a newly created
zbuf contains no data; zbufLength( ) returns a result of 0.
-> zId = zbufCreate()
new symbol "zId" added to symbol table.
zId = 0x3b58e8: value = 3886816 = 0x3b4ee0
-> zbufLength (zId)
value = 0 = 0x0
Next, we create a data buffer buf1, insert it into zbuf zId, and verify that
zbufLength( ) now reports a positive length. To keep the example simple, buf1 is
a literal string, and therefore we do not supply a free-routine callback argument to
zbufInsertBuf( ).
-> buf1 = "I cannot repeat enough!"
new symbol "buf1" added to symbol table.
buf1 = 0x3b5898: value = 3889320 = 0x3b58a8 = buf1 + 0x10
-> zbufInsertBuf (zId, 0, 0, buf1, strlen(buf1), 0, 0)
value = 3850240 = 0x3ac000
-> zbufLength (zId)
value = 23 = 0x17
150
7
Networking APIs
When we copy the zbuf, the copy has its own IDs, but still uses the same data
address:
-> zId2 = zbufDup (zId,0,0,23)
new symbol "zId2" added to symbol table.
zId2 = 0x3b5ff0: value = 3886824 = 0x3b4ee8
-> zbufDisplay zId2
segID 0x3abf80 at 0x3b58a8 + 0x0 (23 bytes): I cannot repeat enough!
value = 0 = 0x0
If we insert a second buffer into the middle of the existing data in zId, there is still
no data copying. Inserting the new buffer gives us a zbuf made up of three
segments—but notice that the address of the first segment is still the start of buf1,
and the third segment points into the middle of buf1:
-> buf2 = " this"
new symbol "buf2" added to symbol table.
buf2 = 0x3b5fb0: value = 3891136 = 0x3b5fc0 = buf2 + 0x10
-> zbufInsertBuf (zId, 0, 15, buf2, strlen(buf2), 0, 0)
value = 3849984 = 0x3abf00
-> zbufDisplay zId
segID 0x3ac000 at 0x3b58a8 + 0x0 (15 bytes): I cannot repeat
segID 0x3abf00 at 0x3b5fc0 + 0x0 ( 5 bytes): this
segID 0x3abe80 at 0x3b58b7 + 0x0 ( 8 bytes): enough!
value = 0 = 0x0
Because the underlying buffer is not modified, both buf1 and the duplicate zbuf
zId2 still contain the original string, rather than the modified one now in zId:
-> printf ("%s\n", buf1)
I cannot repeat enough!
value = 24 = 0x18
151
VxWorks Network 5.4
Programmer’s Guide
The zbufDup( ) routine can also select part of a zbuf without copying, for instance
to incorporate some of the same data into another zbuf—or even into the same
zbuf, as in the following example:
-> zTmp = zbufDup (zId, 0, 15, 5)
new symbol "zTmp" added to symbol table.
zTmp = 0x3b5f70: value = 3886832 = 0x3b4ef0
After zbufInsert( ) combines two zbufs, the second zbuf ID (zTmp in this example)
is automatically deleted. Thus, zTmp is no longer a valid zbuf ID—for example,
zbufLength( ) returns ERROR:
-> zbufLength (zTmp)
value = -1 = 0xffffffff = zId2 + 0xffc4a00f
However, you must still delete the remaining two zbuf IDs explicitly when they are
no longer needed. This releases all associated zbuf-structure storage. In a real
application, with free-routine callbacks filled in, it also calls the specified free
routine on the data buffers, as follows:
-> zbufDelete (zId)
value = 0 = 0x0
-> zbufDelete (zId2)
value = 0 = 0x0
The following is the complete source code for the zbufDisplay( ) utility used in the
preceding example:
/* zbufDisplay.c - zbuf example display routine */
/* includes */
#include "vxWorks.h"
#include "zbufLib.h"
#include "ioLib.h"
#include "stdio.h"
152
7
Networking APIs
/********************************************************************
*
* zbufDisplay - display contents of a zbuf
*
* RETURNS: OK, or ERROR if the specified data could not be displayed.
*/
STATUS zbufDisplay
(
ZBUF_ID zbufId, /* zbuf to display */
ZBUF_SEG zbufSeg, /* zbuf segment base for <offset> */
int offset, /* relative byte offset */
int len, /* number of bytes to display */
BOOL silent /* do not print out debug info */ 7
)
{
int lenData;
char * pData;
if (len <= 0)
len = ZBUF_END;
if (!silent)
printf ("segID 0x%x at 0x%x + 0x%x (%2d bytes): ",
(int) zbufSeg, (int) pData, offset, lenData);
write (STD_OUT, pData, lenData); /* display data */
if (!silent)
printf ("\n");
return (OK);
}
153
VxWorks Network 5.4
Programmer’s Guide
The following zbuf limitations are due to the current implementation; they are not
inherent to the data abstraction. They are described because they can have an
impact on application performance.
■ With the current implementation, references to data in zbuf segments before a
particular location (whether with zbufSegPrev( ), or with a negative offset in a
byte location) are significantly slower than references to data after a particular
location.
■ The data in small zbuf segments (less than 512 bytes) is sometimes copied,
rather than having references propagated to it.
The zbuf socket calls listed in Table 7-8 are named to emphasize parallels with the
standard BSD socket calls: thus, zbufSockSend( ) is the zbuf version of send( ), and
zbufSockRecvfrom( ) is the zbuf version of recvfrom( ). The arguments also
correspond directly to those of the standard socket calls.
Call Description
For a detailed description of each routine, see the corresponding reference entry.
154
7
Networking APIs
The zbuf socket calls are particularly useful when large data transfer is a significant
part of your socket application. For example, many socket applications contain
sections of code like the following fragment:
pBuffer = malloc (BUFLEN);
while ((readLen = read (fdDevice, pBuffer, BUFLEN)) > 0)
write (fdSock, pBuffer, readLen);
You can eliminate the overhead of copying from the application buffer pBuffer
into the internal socket buffers by changing the code to use zbuf socket calls. For 7
example, the following fragment is a zbuf version of the preceding loop:
pBuffer = malloc (BUFLEN * BUFNUM); /* allocate memory */
for (ix = 0; ix < (BUFNUM - 1); ix++, pBuffer += BUFLEN)
appBufRetn (pBuffer); /* fill list of free bufs */
For a small but complete example that illustrates the mechanics of using the zbuf
socket library, consider the conversion of the client-server example in Example 7-1
to use zbuf socket calls.
No conversion is needed for the client side of the example; the client operates the
same regardless of whether or not the server uses zbufs. The next example
illustrates the following changes to convert the server side to use zbufs:
– Instead of including the header file sockLib.h, include zbufSockLib.h.
– The data processing component must be capable of dealing with potentially
non-contiguous data in successive zbuf segments. In the TCP example, this
component displays a message using printf( ); we can use the zbufDisplay( )
routine from Example 7-4 instead.
155
VxWorks Network 5.4
Programmer’s Guide
– The original TCP example exploits fioRead( ) to collect the complete message,
rather than calling recv( ) directly. To achieve the same end while avoiding
data copying by using zbufs, the following example defines a
zbufFioSockRecv( ) subroutine to call zbufSockRecv( ) repeatedly until the
complete message is received.
– A new version of the worker routine tcpServerWorkTask( ) must tie together
these separate modifications, and must explicitly extract the reply and
msgLen fields from the client’s transmission to do so. When using zbufs, these
fields cannot be extracted by reference to the C structure in tcpExample.h
because of the possibility that the data is not contiguous.
The following example shows the auxiliary zbufFioSockRecv( ) routine and the
zbuf version of tcpServerWorkTask( ). To run this code:
1. Start with tcpServer.c as defined in Example 7-1.
2. Include the header file zbufSockLib.h.
3. Insert the zbufDisplay( ) routine from Example 7-4.
4. Replace the tcpServerWorkTask( ) definition with the following two routines:
/************************************************************************
*
* zbufFioSockRecv - receive <len> bytes from a socket into a zbuf
*
* This routine receives a specified amount of data from a socket into a
* zbuf, by repeatedly calling zbufSockRecv() until <len> bytes
* are read.
*
* RETURNS:
* The ID of the zbuf containing <len> bytes of data,
* or NULL if there is an error during the zbufSockRecv() operation.
*
* SEE ALSO: zbufSockRecv()
*/
ZBUF_ID zbufFioSockRecv
(
int fd, /* file descriptor of file to read */
int len /* maximum number of bytes to read */
)
{
BOOL first = TRUE; /* first time thru ? */
ZBUF_ID zRecvTotal = NULL; /* zbuf to return */
ZBUF_ID zRecv; /* zbuf read from sock */
int nbytes; /* number of recv bytes */
156
7
Networking APIs
if (first)
zRecvTotal = zRecv; /* cannot append to empty zbuf */ 7
else if (zbufInsert (zRecvTotal, NULL, ZBUF_END, zRecv) == NULL)
{
zbufDelete (zRecv);
zbufDelete (zRecvTotal);
return (NULL);
}
return (zRecvTotal);
}
/************************************************************************
*
* tcpServerWorkTask - process client requests
*
* This routine reads from the server's socket, and processes client
* requests. If the client requests a reply message, this routine
* sends a reply to the client.
*
* RETURNS: N/A.
*/
VOID tcpServerWorkTask
(
int sFd, /* server's socket fd */
char * address, /* client's socket address */
u_short port /* client's socket port */
)
{
static char replyMsg[] = "Server received your message";
ZBUF_ID zReplyOrig; /* original reply msg */
ZBUF_ID zReplyDup; /* duplicate reply msg */
ZBUF_ID zRequest; /* request msg from client */
int msgLen; /* request msg length */
int reply; /* reply requested ? */
157
VxWorks Network 5.4
Programmer’s Guide
158
7
Networking APIs
zbufDelete (zRequest);
}
! CAUTION: In the interests of brevity, the STATUS return values for several zbuf
socket calls are discarded with casts to void. In a real application, check these 7
return values for possible errors.
159
VxWorks Network 5.4
Programmer’s Guide
160
8
DNS: Domain Name System
8.1 Introduction
Most TCP/IP applications use Internet host names instead of IP addresses when
they must refer to locations in the network. One reason for this is that host names
are a friendlier human interface than IP addresses. In addition, when a host-
name/IP-address pair changes, the services associated with that site typically
follow the host name and not the IP address. Most applications should probably
refer to network locations using host names instead of IP addresses. To make this
possible, the applications need a way to translate between host names and IP
addresses.
On a small isolated network, a hand-edited table is a viable solution to the look-up
problem. Such a table contains entries that pair up host names with their
corresponding IP addresses. If you copy this table to each host on the network, you
give the applications running on those hosts the ability to translate host names to
IP addresses. However, as hosts are added to the network, you must update this
table and then redistribute it to all the hosts in the network. This can quickly
become an overwhelming task if you must manage it manually.
As networks grow, they develop a hierarchy whose structure changes with the
growth. Such restructuring can change the network addresses of almost every
machine on the network. In addition, these changes are not necessarily made from
a single central location. Network users at different locations can add or remove
machines at will. As a result, the network has a dynamic decentralized structure.
Trying to track such a structure using a static centralized table is impractical. One
response to this need is the Domain Name System (DNS).
DNS is a distributed database that most TCP/IP applications can use to translate
host names to IP addresses and back. DNS uses a client/server architecture. The
161
VxWorks Network 5.4
Programmer’s Guide
client side is known as the resolver. The server side is called the name server.
VxWorks provides the resolver functionality in resolvLib. For detailed
information on DNS, see RFC-1034, and RFC-1035.
162
8
DNS: Domain Name System
initialization or at run time.1 The resolver can also query multiple servers if you
need to add redundancy to name resolution in your system. Additionally, you can
configure the resolver library’s response to a failed name server query. Either the
resolver looks in the static host configuration table immediately after the failed
query, or the resolver ignores the static table.2 The default behavior of the resolver
is to query only the name server and ignore the static table.
The resolver has been fully integrated into VxWorks. Existing applications can
benefit from the resolver without needing to make any code changes. This is 8
because the code internal to hostGetByName( ) and hostGetByAddr( ) have been
updated to use the resolver.3 Thus, the only thing you need do to take advantage
of the resolver is to include it in your VxWorks image.
The resolver library is not included by default in the VxWorks image. Thus, to
include the resolver in your VxWorks image, you must modify config.h as follows:
1. Reconfigure VxWorks with the DNS resolver on. The relevant configuration
macro is INCLUDE_DNS_RESOLVER.
2. Establish the IP address of the Domain Name Server. Change the default value
for the constant:
#define RESOLVER_DOMAIN_SERVER "ip_address"
1. For initialization, call resolvParamsGet( ) and resolvParamsSet( ). See the reference entries
for these routines.
2. The boot configuration table is maintained by hostLib.
3. Both hostGetByName( ) and hostGetByAddr( ) are hostLib functions.
163
VxWorks Network 5.4
Programmer’s Guide
4. Define the domain to which the resolver belongs by changing the default
Resolver Domain in the VxWorks configuration (defined by the configuration
constant RESOLVER_DOMAIN).
You must change this domain name to the domain name to which your
organization belongs. The resolver uses this domain name when it tries to
query the domain server for the name of the host machine for its organization.
The resolver library supports a debug option, the DNS Debug Messages
parameter: DNS_DEBUG.
Using this parameter causes a log of the resolver queries to be printed to the
console. The use of this feature is limited to a single task. If you have multiple tasks
running, the output to the console will be garbled.
164
9
SNTP: A Time Protocol
9.1 Introduction
VxWorks supports a client and server for the Simple Network Time Protocol
(SNTP). You can use the client to maintain the accuracy of your system’s internal
clock based on time values reported by one or more remote sources. You can use
the server to provide time information to other systems.
165
VxWorks Network 5.4
Programmer’s Guide
Until this routine is hooked into SNTP, the server cannot provide timestamp
information. There are two ways to hook this routine into the SNTP server. The
first is to configure VxWorks with the SNTPS Time Hook (configuration constant
SNTPS_TIME_HOOK) set to the appropriate routine name. You can also call
sntpsClockSet( ). See the reference entry fro sntpsClockSet( ) for more
information.
166
10
RPC: Remote Procedure Calls
10.1 Introduction
Remote Procedure Call (RPC) implements a client-server model of task interaction.
In this model, client tasks request services of server tasks, and then wait for their
reply. RPC formalizes this model and provides a standard protocol for passing
requests and returning replies. Thus, a VxWorks or host system client task can
request services from VxWorks or the host servers in any combination.
Internally, RPC uses sockets as the underlying communication mechanism. RPC,
in turn, is used in the implementation of several higher-level facilities, including
the Network File System (NFS) and remote source-level debugging. Also, RPC
includes utilities to help generate the client interface routines and the server
skeleton.
The VxWorks implementation of RPC is task-specific. Each task must call
rpcTaskInit( ) before making any RPC-related calls.
The VxWorks implementation of RPC was originally designed by Sun
Microsystems and is in the public domain. For more information, see the public
domain RPC documentation (supplied in source form in the directories
target/unsupported/rpc4.0/doc and target/unsupported/rpc4.0/man), and the
reference entry for rpcLib.
167
VxWorks Network 5.4
Programmer’s Guide
168
11
File Access Applications
11.1 Introduction
Using RSH, FTP, or NFS, applications running under VxWorks can access files on
any host development system (over the network) exactly as if they were local to the
VxWorks system. For example, /dk0/file might be a file local to the VxWorks
system, while /host/file might be a file located on another machine entirely. To
VxWorks applications, the files operate in exactly the same way; only the name is
different. Transparent file access is available through any of three different
protocols:1
■ Remote Shell (RSH) is serviced by the remote shell daemon rshd on the host
system. See the reference entry for remLib.
■ Internet File Transfer Protocol (FTP) client and server functions are provided
with a library of routines in ftpLib to transfer files between FTP servers on the
network and invoke other FTP functions. See the reference entries for ftpLib
and ftpdLib.
■ Network File System (NFS) client protocol is implemented in the I/O driver
nfsDrv to access files on any NFS server on the network. This I/O driver was
tested with many different implementations of NFS file servers on various
operating systems. The NFS server protocol is implemented (for dosFs file
systems) in two libraries, mountLib and nfsdLib.
1. If you are developing on a Windows host, check your Windows and networking software
documentation for information on which of these protocols is available and how to use
them.
169
VxWorks Network 5.4
Programmer’s Guide
An alternative remote file transfer protocol is the Trivial File Transfer Protocol
(TFTP). The VxWorks implementation provides both client and server functions,
and is used only to retrieve a VxWorks image at boot time. See the reference entries
for tftpLib and tftpdLib.
170
11
File Access Applications
In the following example (also see Figure 11-1), a slave on the shared-memory
network boots from the master CPU’s local SCSI disk. (For more information on
shared-memory networks, see 3.5 Shared-Memory Network on the Backplane, p.40.)
Note that VxWorks requires a non-empty ftp password field. This is true even if
VxWorks is configured with FTP server security turned off (the default). The
relevant configuration macro is INCLUDE_FTPD_SECURITY. However, if FTP
security checks are turned on, the ftp password field must contain a valid
password for the specified user.
The following boot parameters are for the slave processor (vxSlave):
boot device : sm=0x800000
processor number : 1
host name : vxServer
file name : /sd0/vx2
inet on backplane (b) : 161.27.0.2
host inet (h) : 161.27.0.1
user (u) : caraboo
ftp password (pw) (blank=use rsh) : ignored 11
The FTP server daemon is initialized on the VxWorks server based on the
configuration. The relevant configuration macro is INCLUDE_FTP_SERVER. See
also the reference entry for ftpdLib.
vxServer vxSlave
SCSI Disk
161.27.0.1 161.27.0.2
Shared-Memory Network
An RSH request includes the name of the requesting user. The request is treated
like a remote login by that user.
171
VxWorks Network 5.4
Programmer’s Guide
For Windows hosts, the availability and functionality of this facility is determined
by your version of Windows and the networking software you are using. See that
documentation for details.
For UNIX hosts, such remote logins are restricted by means of the host file .rhosts
in the user’s home directory, and more globally with the host file /etc/hosts.equiv.
The .rhosts file contains a list of system names (as defined in /etc/hosts) that have
access to that user’s login. Therefore, make sure that the user’s home directory has
a .rhosts file listing the VxWorks systems, each on a separate line, that are allowed
to access files remotely using the user’s name.
The /etc/hosts.equiv file provides a less selective mechanism. Systems listed in
this file are allowed login access to any user defined on the local system (except the
super-user root). Thus, adding VxWorks system names to /etc/hosts.equiv allows
those VxWorks systems to access files using any user name on the UNIX system.
The FTP protocol, unlike RSH, specifies both the user name and password on every
request. Therefore, when using FTP, the UNIX system does not use the .rhosts or
/etc/hosts.equiv files to authorize remote access.
The routine netDevCreate( ) is used to create a VxWorks I/O device for a particular
remote host system:
netDevCreate ("devName", "host", protocol)
172
11
File Access Applications
After a network device is created, files on that host can be accessed by appending
the host path name to the device name. For example, the file name
mars:/usr/darger/myfile refers to the file /usr/darger/myfile on the mars system.
This file can be read and/or written exactly like a local file. For example, the
following Tornado shell command opens that file for I/O access:
-> fd = open ("mars:/usr/darger/myfile", 2)
11.2.3 Setting the User ID for Remote File Access with RSH or FTP
11
All FTP and RSH requests to a remote system include the user name. All FTP
requests include a password as well as a user name. From VxWorks you can
specify the user name and password for remote requests by calling iam( ):
iam ("username", "password")
The first argument to iam( ) is the user name that identifies you when you access
remote systems. The second argument is the FTP password. This is ignored if RSH
is being used, and can be specified as NULL or 0 (zero).
For example, the following command tells VxWorks that all accesses to remote
systems with RSH or FTP are through user darger, and if FTP is used, the password
is unreal:
-> iam "darger", "unreal"
173
VxWorks Network 5.4
Programmer’s Guide
The easiest way to check this is to log in to the host with the user name VxWorks
uses, and try to read or write the file in question. If you cannot do this, neither can
the VxWorks system.
11.3 NFS
The I/O driver nfsDrv, which provides NFS client support, uses the client routines
in the library nfsLib to access files on an NFS file server.
VxWorks also allows you to run an NFS server to export files to other systems. The
server task mountd allows other systems on the network to mount VxWorks file
systems (dosFs only); then the server task nfsd allows them to read and write to
those files. The VxWorks NFS server facilities are implemented in the following
libraries:
mountLib
Mount Protocol library. Provides functions to manage exporting file
systems.
nfsdLib
NFS Server library. Provides functions to manage requests from remote
NFS clients.
The routines in the VxWorks NFS libraries are implemented using RPC. For more
information, see the reference entries for these libraries and RPC: Remote Procedure
Calls, p.167.
To access files on UNIX, NFS clients mount file systems from NFS servers. On a
UNIX NFS server, the file /etc/exports specifies which of the server’s file systems
can be mounted by NFS clients. For example, if /etc/exports contains the following
line:
/usr
then the file system /usr can be mounted by NFS clients such as VxWorks. If a file
system is not listed in this file, it cannot be mounted by other machines. Other
174
11
File Access Applications
! CAUTION: On Windows, most networking packages that support NFS also supply
a mechanism for exporting files so that they are visible on the network. See your
Windows and networking software documentation for information on this facility.
Access to a remote NFS file system is established by mounting that file system
locally and creating an I/O device for it using the routine nfsMount( ):
nfsMount ("host", "hostFileSys", "localName")
The host name mars must already be in VxWorks’s list of hosts (added with the
routine hostAdd( )). VxWorks then creates a local I/O device /vwusr that refers to
the mounted file system. A reference on VxWorks to a file with the name
/vwusr/darger/myfile refers to the file /usr/darger/myfile on the host mars as if it
were local to the VxWorks system.
If VxWorks is configured with “NFS mount all” on, VxWorks mounts all host-
exported NFS file systems. The relevant configuration macro is
INCLUDE_NFS_MOUNT_ALL. Otherwise, the network startup routine,
usrNetInit( ) in usrNetwork.c, tries to mount the file system from which VxWorks
was booted—as long as NFS is included in the VxWorks configuration and the
VxWorks boot file begins with a slash (/). For example, if NFS is included and you
boot /usr/wind/target/config/bspname/vxWorks, then VxWorks attempts to mount
/usr from the boot host with NFS.
175
VxWorks Network 5.4
Programmer’s Guide
When making an NFS request to a host system, the NFS server expects more
information than the user’s name. NFS is built on top of Remote Procedure Call
(RPC) and uses a type of RPC authentication known as AUTH_UNIX. This
mechanism requires the user ID and a list of group IDs to which the user belongs.
These parameters can be set on VxWorks using nfsAuthUnixSet( ). For example,
to set the user ID to 1000 and the group ID to 200 for the machine mars, use:
-> nfsAuthUnixSet "mars", 1000, 200, 0
To export a dosFs file system with NFS, carry out the following steps:
■ Initialize a dosFs file system, with the option that makes it NFS-exportable.
■ Register the file system for export, with a call to nfsExport( ).
To use the file system from another machine after you export it, you must also:
■ Mount the remote VxWorks file system using local host facilities.
To include NFS Server support, reconfigure VxWorks. The relevant configuration
macro is INCLUDE_NFS_SERVER. If you wish, you can run a VxWorks system
with only NFS Server support (no client support).
To export a dosFs file system with NFS, you must initialize that file system with the
DOS_OPT_EXPORT option (see VxWorks Programmer’ Guide: Volume Configuration).
176
11
File Access Applications
With this option, the dosFs initialization code creates some small additional in-
memory data structures; these structures make the file system exportable.
The following steps initialize a DOS file system called /export on a SCSI drive. You
can use any block device instead of SCSI. Your BSP can also support other suitable
device drivers; see your BSP’s documentation.
1. Initialize the block device containing your file system.
For example, you can use a SCSI drive as follows:
scsiAutoConfig (NULL);
pPhysDev = scsiPhysDevIdGet (NULL, 1, 0);
pBlkDev = scsiBlkDevCreate (pPhysDev, 0, 0);
! CAUTION: For NFS-exportable file systems, the device name must not end in a
slash.
After you have an exportable file system, call nfsExport( ) to make it available to
NFS clients on your network. Then mount the file system from the remote NFS
client, using the facilities of that system. The following example shows how to
177
VxWorks Network 5.4
Programmer’s Guide
export the new dosFs file system from a VxWorks platform called vxTarget, and
how to mount it from a typical UNIX system.
1. After the file system (/export in this example) is initialized, the following
function call specifies it as a file system to be exported with NFS:
nfsExport ("/export", 0, FALSE, 0);
The first three arguments specify the name of the file system to export; the
VxWorks NFS export ID (0 means to assign one automatically); and whether
to export the file system as read-only. The last argument is a place-holder for
future extensions.
2. To mount the file system from another machine, see the system documentation
for that machine. Specify the name of the VxWorks system that exports the file
system, and the name of the desired file system. You can also specify a
different name for the file system as seen on the NFS client.
! CAUTION: On UNIX systems, you normally need root access to mount file
systems.
Several global variables allow you to specify dosFs facilities related to NFS
support. Because these facilities use global variables, you can export previously
existing dosFs file systems without altering the existing configuration stored with
the file system data on disk.
However, because these are global variables, you must take care to avoid race
conditions if more than one task initializes dosFs file systems. If your application
initializes file systems for NFS on the fly, you may need mutual exclusion
surrounding these global variable settings and the corresponding file system
initialization.
You can specify a single user ID, group ID, and mode (permissions) for all files
within a dosFs file system. To specify these values, define the following global
variables before initializing a dosFs file system with either dosFsDevInit( ) or
dosFsMkfs( ):
178
11
File Access Applications
dosFsUserId
Numeric user ID. Default: 65534.
dosFsGroupId
Numeric group ID. Default: 65534.
dosFsFileMode
Numeric file access mode (that is, permissions with UNIX encoding).
Default: 511 (octal, 777).
These settings remain in effect for the file system until you reboot.
! WARNING: dosFsFileMode controls only how the file access mode is reported to
NFS clients; it does not override local access restrictions on the DOS file system. In
particular, if any file in an exported file system has DOS_ATTR_RDONLY set in its
file-attribute byte, no modifications to that file are permitted regardless of what
dosFsFileMode says.
11
You can also set the current date and time for the DOS file system using
dosFsDateSet( ) and dosFsTimeSet( ). For a discussion of these routines and other
standard dosFs facilities, see VxWorks Programmer’s Guide: MS-DOS-Compatible File
System: dosFs.
The VxWorks NFS Server can export only dosFs file systems, which leads to the
following DOS limitations:
– File names in dosFs normally share the DOS limit of 8 characters with a three-
character extension. An optional dosFs feature allows (at the expense of DOS
compatibility) file names up to forty characters long. To enable this extension,
create the file system with the DOS_OPT_LONGNAMES option (defined in
dosFsLib.h).
– DOS file systems do not provide for permissions, user IDs, and group IDs on
individual files. You can provide a single user ID, a single group ID, and a
single set of permissions for all files on an entire DOS file system by defining
the global variables dosFsUserId, dosFsGroupId, and dosFsFileMode,
described in the reference entry for dosFsLib.
– Because the DOS file system does not provide file permissions, VxWorks does
not normally provide authentication services for NFS requests. To
authenticate incoming requests, write your own authentication functions and
179
VxWorks Network 5.4
Programmer’s Guide
arrange to call them when needed. See the reference entries for nfsdInit( ) and
mountdInit( ) for information on authorization hooks.
11.4 TFTP
The Trivial File Transfer Protocol (TFTP) is implemented on top of the Internet
User Datagram Protocol (UDP). VxWorks provides both a TFTP client and a TFTP
server. The TFTP client is useful at boot time, when you can use it to download a
VxWorks image from the boot host. The TFTP server is useful if you want to boot
an X-Terminal from VxWorks. It is also useful if you want to boot another VxWorks
system from a local disk.
Unlike FTP and RSH, TFTP requires no authentication; that is, the remote system
does not require an account or password. The TFTP server allows only publicly
readable files to be accessed. Files can be written only if they already exist and are
publicly writable.
Typically, the host-resident Internet daemon starts the TFTP server. For added
security, some hosts (for example, Sun hosts) default to starting the TFTP server
with the secure (-s) option enabled. If -s is specified, the server restricts host access
by rooting all TFTP requests into the directory specified (for example, /tftpboot).
For example, if the secure option was set with -s /tftpboot, a TFTP request for the
file /vxBoot/vxWorks is satisfied by the file /tftpboot/vxBoot/vxWorks rather than
the expected file /vxBoot/vxWorks.
To disable the secure option on the TFTP server, edit /etc/inetd.conf and remove
the -s option from the tftpd entry.
180
11
File Access Applications
Include the VxWorks TFTP client side by reconfiguring VxWorks. The relevant
configuration macro is INCLUDE_TFTP_CLIENT. To boot using TFTP, specify 0x80
in the boot flags parameters. To transfer files from the TFTP host and the VxWorks
client, two high-level interfaces are provided, tftpXfer( ) and tftpCopy( ). See the
reference entry for tftpLib.
11
181
VxWorks Network 5.4
Programmer’s Guide
182
12
rlogin and telnet: Host Access
Applications
12.1 Introduction
VxWorks supports the host access applications telnet and rlogin. VxWorks also
includes remLib, a library for the execution of commands on a remote shell.
12.2 rlogin
You can log in to a host system from a VxWorks terminal using rlogin( ). For more
information on the VxWorks side of this communication, see the reference entry for
rLogLib.
When connecting with a Windows host system, VxWorks’s ability to remotely
login depends on your version of Windows and the networking software you are
using. See that documentation for details.
When connecting with a UNIX host system, access permission must be granted to
the VxWorks system by entering its system name either in the .rhosts file (in your
home directory) or in the /etc/hosts.equiv file. For more information, see
11.2.1 Allowing Remote File Access with RSH, p.171.
183
VxWorks Network 5.4
Programmer’s Guide
12.3 telnet
Like rlogin, telnet is another remote login utility. However, telnet does not require
any previous setup of the “rhosts” file. For more information on how to use telnet
with a VxWorks target, see the reference entry for telnetLib.
12.4 remLib
The VxWorks remote command execution facilities allow applications running
under VxWorks to invoke commands on a remote system and have the results
returned on standard output and standard error over socket connections. This is
accomplished using the remote shell protocol, which on UNIX systems is serviced
by the remote shell daemon rshd. See the reference entry for remLib.
184
13
Booting over the Network
13.1 Introduction
To boot VxWorks over the network, a VxWorks target needs to know certain
configuration parameters that describe itself, the network, and its relationship to
the network. The goals of the boot program are as follows:
1. Gather configuration information (such as networking parameters).
2. Format the configuration information as an ASCII string, a boot line.
3. Store the boot line in a known memory location.
4. Retrieve and load a run-time VxWorks image.
5. Pass control to the run-time VxWorks image.
When the run-time VxWorks image needs the configuration information gathered
by the boot program, it reads the boot line that the boot program stored at the
known memory location.
The following sections describe the boot parameters and how to set them. This
section also discusses the protocols, network utilities, and network devices
available to the boot program. These various media, protocols, and utilities
combine to produce a great variety of different boot systems (Ethernet with DHCP
with TFTP, serial line with BOOTP with RSH, shared memory backplane with
BOOTP with FTP, and so on.) This section describes booting using three
representative systems, one example for each physical medium.
185
VxWorks Network 5.4
Programmer’s Guide
The default VxWorks boot program has a built-in default boot line.2 However, that
line might be incomplete, and certain values might not be valid. Before the boot
program tries to use its default boot line, the boot program looks in NVRAM, if
available. The boot program also accepts a boot line from user input.
From these sources, a non-networked boot program must be able to find
appropriate values for all necessary boot parameters. However, if the boot
program has network access, the initial boot line needs to define only those
parameters required to initialize and use its networking utilities. The boot program
can then use these networking utilities to retrieve the missing boot parameters and
the run-time VxWorks image from a remote source.
186
13
Booting over the Network
Start
Warm
reboot with
non-empty boot No Boot line
line in RAM at available in No Get the default
BOOT_LINE_ADRS NVRAM boot line.
? ?
13
No
auto-boot or Yes
user stops
countdown
?
No
User adjusts boot No
parameters.
Do boot Can
parameters specify No boot program
dynamic configuration load VxWorks
using DHCP or image
BOOTP ?
?
Yes Yes
187
VxWorks Network 5.4
Programmer’s Guide
When a VxWorks target boots, it uses the boot line to fill in a BOOT_PARAMS
structure. The boot program and the VxWorks run-time image use this structure to
track boot parameters. The BOOT_PARAMS structure is defined as follows:
typedef struct /* BOOT_PARAMS */
{
char bootDev [BOOT_DEV_LEN]; /* boot device code */
char hostName [BOOT_HOST_LEN]; /* name of host */
char targetName [BOOT_HOST_LEN]; /* name of target */
char ead [BOOT_ADDR_LEN]; /* ethernet internet addr */
char bad [BOOT_ADDR_LEN]; /* backplane internet addr */
char had [BOOT_ADDR_LEN]; /* host internet addr */
char gad [BOOT_ADDR_LEN]; /* gateway internet addr */
char bootFile [BOOT_FILE_LEN]; /* name of boot file */
char startupScript [BOOT_FILE_LEN]; /* name of startup script file */
char usr [BOOT_USR_LEN]; /* user name */
char passwd [BOOT_PASSWORD_LEN]; /* password */
char other [BOOT_OTHER_LEN]; /* available for applications */
int procNum; /* processor number */
int unitNum; /* network device unit number */
int flags; /* configuration flags */
} BOOT_PARAMS;
This structure is shown here because its member names provide a convenient set
of labels for discussing boot parameters. For example, using the member names
shown above, this document can represent the general format of a boot line is as
follows:
bootDev(unitNum, procNum) hostName:bootFile e=ead b=bad h=had g=gad u=userName
pw=passWord f=flags tn=targetName s=startupScript o=other
The labeled parameters e, b, h, and so on, are not order sensitive. You can leave
them blank. For example, “pw= “ specifies an empty password parameter. If the
labeled parameter is optional or supplied later by DHCP or BOOTP, you can omit
it from the boot line entirely.
As an example of a typical boot line, consider the following:
ln(0, 0) bear:/usr/wpwr/target/config/mz7122/vxworks e=90.0.0.2
b=91.0.0.2 h=100.0.0.4 g=90.0.0.3 u=papa pw=biggrump f=0x80 tn=goldilox
s=bear:/usr/papa/startup o=
To get a listing of the boot parameters, type p at the boot prompt (if a parameter
currently has no setting, the p command does not list it). The labels used in the p
listing differ somewhat from the names of the structure members.
188
13
Booting over the Network
13.2.3 Boot Parameters Needed for DHCP, BOOTP, and Network Device Initialization
Before the boot program can use a DHCP or BOOTP client to retrieve additional
boot parameters from a remote server, the boot program needs appropriate values
for bootDev, unitNum, procNum, and flags. See Table 13-1. Because the boot
program does not yet have network access, the target must be able to find these
parameter values in the default boot line, a user-provided boot line, or NVRAM
boot line.3
Table 13-1 Boot Parameters Needed for DHCP, BOOTP, and Network Device Initialization
3. If the target has NVRAM, and the user specified these parameters in a previous boot session,
the boot program knows to save these parameters to an NVRAM boot line for the use of the
next boot session.
189
VxWorks Network 5.4
Programmer’s Guide
Table 13-1 Boot Parameters Needed for DHCP, BOOTP, and Network Device Initialization
0x02 Loads the local symbols as well as the global symbols into the
target-based symbol table. This has consequences for tools
such as the target shell. If the target-based symbol contains
local variables, the target shell has access to both locally and
globally declared symbols. Setting this bit means you must
also reconfigure VxWorks with a downloaded symbol table.
The relevant configuration macro is
INCLUDE_NET_SYM_TBL. The VxWorks startup code
assumes that the file containing the symbol table is resident
on the same host as the boot image. The VxWorks startup
code also assumes that the name of the symbol table file is the
boot file name with an appended .sym suffix. When reading
the .sym file, the VxWorks image has the option of loading
local symbols as well as global symbols into its target-resident
symbol table.
0x80 Tells the target to use TFTP to get VxWorks image. Otherwise,
the target uses either RSH or FTP. The target uses FTP if you
enter a non-empty value for the passwd parameter.
Otherwise, the target uses RSH.
190
13
Booting over the Network
If the 0x40 bit in the flags parameter is set, the boot program uses either DHCP or
BOOTP client to retrieve the following parameters: ead (from which the boot
program also derives a value for bad), had, gad, and bootFile.4 See Table 13-2.
4. If you accidentally include both a DHCP and BOOTP client in a boot program, the program
uses the DHCP client.
191
VxWorks Network 5.4
Programmer’s Guide
13.2.5 Boot Parameters Needed to Set Up Remote File Access and Get the VxWorks
Image
To get a file containing the VxWorks run-time image, the boot program needs to
know the name of the file containing the run-time image. The boot program also
needs to know the identity of the machine that hosts the file. These are provided in
the boot parameters: had and fileName. Typically, the boot program gets these
parameters from a DHCP or BOOTP message.5
To retrieve the image, the boot program uses any of three protocols: TFTP, FTP, or
RSH. If the 0x80 bit in the flags parameter is set, the boot program uses TFTP.
Otherwise, the boot program uses FTP or RSH to retrieve the image. However, in
order to use RSH, the boot program needs a user ID, usr. If the boot program must
use FTP, it needs both a user ID and a password, passwd. In addition, if the
VxWorks run-time image is resident on a SCSI drive, you can use the other
parameter to specify the network interface to which the VxWorks image attaches
after it boots.
To support remote file access for startup code in the VxWorks image, you also need
to supply a host name, hostName. This parameter is not critical to the boot
program. You can leave it empty, if you want. However, entering a meaningful
hostName can make messages from the boot program a little easier to read. For
detailed descriptions of boot parameters for remote file access, see Table 13-3.
5. If the target reaches the host through a gateway, the target also needs the gad value, which
is included in the same DHCP or BOOTP message that provided the had value.
192
13
Booting over the Network
Table 13-4 lists the optional boot parameters. Omitting these parameters from the
boot line does not prevent the target from booting.
193
VxWorks Network 5.4
Programmer’s Guide
The default boot line is specified during configuration. The relevant configuration
macro is DEFAULT_BOOT_LINE. A valid setting looks like:
"ei(0,0)host:/vw/config/mv166/vxWorks h=90.0.0.3 e=90.0.0.50 u=target"
When control passes to the run-time VxWorks image, VxWorks parses the boot line
at the known memory location and loads the values into a BOOT_PARAMS
structure and checks for missing boot parameters. At this point, if you booted
using TFTP, the only parameters that could be missing are: hostName,
targetName, usr, passwd, startupScript, and other. Otherwise, the boot would
have failed.6
However, these parameters can be useful to the run-time image even if they were
not essential to the boot program. Therefore, it is possible to include values for
these parameters in the run-time VxWorks image. To do this, reconfigure VxWorks.
For more information on configuring VxWorks, see the Tornado User’s Guide:
Projects. The relevant configuration macros are the following:
HOST_NAME_DEFAULT
Supplies a hostName value, the name of the system that supplied the boot file,
bootFile. This name is added to the target’s host table to provide a convenient
label for the host machine at the IP address, had. The hostName is added to
the host and route tables. At startup, the run-time VxWorks image creates a
netDrv device named “hostName:”.
TARGET_NAME_DEFAULT
Supplies a targetName value, the name of the target. This name is added to the
target’s host table to provide a convenient label for the target’s IP address, had.
6. If you booted using RSH, you had to have provided the boot program with a value for usr.
If you booted using FTP, you had to have provided values for usr and passwd.
194
13
Booting over the Network
HOST_USER_DEFAULT
Supplies a usr value, the login name that this target’s netDrv device should
use.
HOST_PASSWORD_DEFAULT
Supplies a passwd value, the password (if any), to use. If there is a non-empty
passwd, this has configuration consequences for netDrv as well as for remote
login from the VxWorks target to a remote system. A password here tells
netDrv device, “hostName:”,7 to use FTP for remote file access. Otherwise, it
uses RSH.
SCRIPT_DEFAULT
Supplies a value for startupScript, the startup script for the VxWorks target-
based shell (if any). You can use this script to do things such as redirect output.
OTHER_DEFAULT
Supplies an other value. If the booted VxWorks image must access a local SCSI
disk, you can use the other parameter to specify which network interface to
attach.
13
13.3.2 Supplying Boot Parameters Manually
If you supply a boot line manually, its values take precedence over parameters
specified by any other source (except those few parameters retrieved by DHCP or
BOOTP). To check the values of all currently set boot parameters, type p at the
VxWorks prompt. This command lists all currently set boot parameters and their
values. For example:
[VxWorks Boot]: p
boot device : ln
processor number : 0
flags (f) : 0xc0
unit number : 0
Before you can boot the target from the network, you must enter appropriate
values for bootDev (boot device), procNum (processor number), flags, and
unitNum (unit number). The target can store these values in NVRAM (if available)
and use them in subsequent boot sessions.
To change the boot device, processor number, flags value, or unit number, enter a
c at the boot prompt. This runs a script that prompts you for individual boot
7. The presence or lack of a passwd affects only the “hostName:” device. Other instances of
netDrv are individually configurable.
195
VxWorks Network 5.4
Programmer’s Guide
parameters. To bypass the script and enter the whole boot line all at once, enter a
$ followed by the boot line.
If you intend to use a DHCP or BOOTP message to supply additional parameters,
make sure that you specify a flags value that sets the 0x40 bit (the dynamic
configuration bit). Although this setting is the same for both DHCP and BOOTP,
the VxWorks startup code automatically uses DHCP if available. If DHCP is
unavailable, the startup code uses BOOTP. Typically, the boot image contains
either a DHCP or BOOTP client and not both. However, if, for some reason, you
have included both clients in the boot image, the BOOTP client is ignored and the
boot image is larger than it need be.
To make a DHCP or BOOTP client available at boot time, you must construct boot
ROMs that contain the client code.
If the boot program includes a DHCP or BOOTP client, and you have set the 0x40
bit in the flags boot parameter, the boot program uses the DHCP or BOOTP client
to retrieve values for ead (from which the boot program derives bad), had, gad,
and bootFile.
NOTE: This section provides a general discussion of the issues that arise when
using a DHCP or BOOTP server to provide boot parameters. For more on
configuring the DHCP or BOOTP servers, see Configuring VxWorks to Include the
DHCP Components, p.96, or BOOTP Configuration, p.106.
IP Lease Length
When booting with DHCP, the value of the minimum lease length is critical.
Because the network address assigned by DHCP is only valid for a finite period of
time, the DHCP client must spawn a monitor task to renew the lease as necessary.
However, this cannot occur until after the VxWorks boot file has been downloaded.
Thus, the minimum lease setting must be large enough to allow this download to
complete. Otherwise, the server which supplied the IP address may reassign it
after the lease expires, and the VxWorks image will inadvertently use an invalid IP
address. The default value is acceptable for an Ethernet link, but might need to be
increased for slower connections, such as serial links.
196
13
Booting over the Network
When you configure the BOOTP server, you need the target’s hardware address to
use as a key into the BOOTP database. You get this address from the target device.
If the device is running VxWorks, you can use the ifShow( ) command. In the
following example, the target’s Ethernet address is 00:00:4b:0b:b3:a8.8
-> ifShow "ln0"
value = 0 = 0x0
The output is sent to the standard output device, and looks like the following:
ln (unit number 0):
Flags: (0x63) UP BROADCAST ARP RUNNING
Internet address: 150.12.1.240
Broadcast address: 150.12.1.255
Netmask 0xffff0000 Subnetmask 0xffffff00
Ethernet address is 00:00:4b:0b:b3:a8
Metric is 0
8. The ifShow( ) function is not built in to the Tornado shell but must be activated by turning
on network debugging. The relevant configuration macro is INCLUDE_TCP_SHOW.
197
VxWorks Network 5.4
Programmer’s Guide
If the device has not yet booted, you can use the n command to retrieve the
information from the boot ROMs. For example:
[VxWorks Boot]: n ln
Attaching network interface enp0... done
Address for device "ln" == 02:cf:1f:e0:20:24
2. Make sure that the permissions on the boot file make it accessible to all:
% chmod 644 vxWorks.vx245
% ls -l
total 609
-rw-r--r-- 1 target 519880 Jul 6 19:36 vxWorks.vx245
3. On the target, set the flag value to 0xc0. This enables automatic configuration
(using DHCP or BOOTP, 0x40) and file retrieval using TFTP (0x80).
To check the current value, enter p at the boot prompt:
[VxWorks Boot]: p
9. The file suffix, .vx245, is of no special significance. It just distinguishes this image from other
VxWorks images that might reside in the directory.
198
13
Booting over the Network
DHCP Server:147.11.46.24
Boot file: /usr/wind/target/vxBoot/vxWorks.vx245
Boot host: 147.11.46.24
Boot device Addr (ln0): 147.11.46.174
Subnet mask: 0xffffff00
Subnet gateway: 147.11.46.24
Attaching network interface lo0... done.
Loading... 374624 + 57008 + 20036 13
Starting at 0x1000...
199
VxWorks Network 5.4
Programmer’s Guide
VxWorks can be configured to omit the symbol table, by turning off the
“downloadable symbol table” during configuration. The relevant configuration
macro is INCLUDE_NET_SYM_TBL.10 Instead, the run-time VxWorks image (not
the boot program) downloads the symbol table file from the same remote directory
that contained the VxWorks image. To retrieve this file, VxWorks uses the netDrv
I/O driver.
When you copy the VxWorks image to the host boot directory:
% cp vxWorks /usr/wind/target/vxBoot/vxWorks.vx245
You must also copy the symbol file to the same directory:
% cp vxWorks.sym /usr/wind/target/vxBoot/vxWorks.vx245.sym
Note that the name of the symbol file is the bootfile name with a .sym suffix.
NOTE: Because netDrv uses either RSH or FTP to access the remote files, the boot
parameters must specify a value for the usr boot parameter. If you want to use FTP,
you must also specify a passwd. Otherwise, the target uses RSH. For more
information on netDrv, see 2.10.1 RSH and FTP, p.154.
13.4.1 Troubleshooting
10. You need this symbol table to be resident on the target only if you want to use target-resi-
dent (pre-Tornado) tools. Host-based tools do not require a target-resident symbol table.
200
13
Booting over the Network
BOOTP reply, the target sends a TFTP request to get the file
/tftpboot/vxBoot/vxWorks.vx245.
However, if the TFTP server was started with the -s /tftpboot option, the request
fails because the server looks for the file in /tftpboot/tftpboot/vxBoot rather than
in /tftpboot/vxBoot. If this is a problem, link /tftpboot/tftpboot to /tftpboot. To
do this, use the following commands:
% cd /tftpboot
% ln -s . tftpboot
If there are multiple BOOTP servers on the network, the target uses the parameters
specified in the first reply message it receives. In the previous example, the server
from which the reply message came is specified in an output line like the
following:
Bootp Server:150.12.1.159
201
VxWorks Network 5.4
Programmer’s Guide
[VxWorks Boot]: @
boot device : ln
processor number : 0
flags (f) : 0xc0
The parameters from the preceding output came from the following sources:
[1] These lines all display information retrieved from the BOOTP database.
[2] These lines display information you set during configuration (defaults).
[3] These lines appear because you have configured VxWorks with “proxy arp
server,” “auto address setup,” and “default address for bp” (the configuration
macros INCLUDE_PROXY_SERVER, INCLUDE_SM_SEQ_ADDR, and
INCLUDE_PROXY_DEFAULT_ADDR). (Note that the address is one more than
that of parameter inet on ethernet, in this case 150.12.1.230.)
The following example shows booting a slave processor using a combination of
BOOTP, TFTP, and sequential addressing:
[VxWorks Boot]: @
boot device : sm=0x800000
processor number : 1
flags (f) : 0x1c0
11. The use of sequential addressing can make it difficult to use DHCP.
202
13
Booting over the Network
The parameters from the preceding output came from the following sources:
[1] These lines appear because you have configured VxWorks with “proxy arp
client” and “auto address setup” (the configuration constants
INCLUDE_PROXY_CLIENT and INCLUDE_SM_SEQ_ADDR)12. (Note that the
address is equal to the master CPU’s backplane address plus the client’s
processor number.) 13
[2] These lines all display information retrieved from the BOOTP database.
If you have configured VxWorks to use SLIP, you can use the Serial Line Internet
Protocol to boot VxWorks. The relevant configuration macro is INCLUDE_SLIP.
SLIP supports IP layer software with point-to-point configurations such as RS-232
12. The use of sequential IP addressing makes this procedure incompatible with DHCP.
203
VxWorks Network 5.4
Programmer’s Guide
NOTE: Both target and host must agree on the MTU size. On a VxWorks system,
the default MTU size is 576.
Optionally, you can use compressed TCP/IP headers over SLIP. This variant of the
protocol is known as CSLIP (compressed SLIP). Only the TCP/IP headers are
compressed, not the data itself; this implies that CSLIP improves the
responsiveness of interactive communications (such as remote shells), where the
ratio of header size to data is large, but makes little difference for large data
transfers (such as downloading object code). Because compression applies only to
TCP/IP headers, not to other forms of IP, CSLIP has no impact on applications that
use UDP rather than TCP (for example, CSLIP has no effect on NFS).13
When booting using SLIP (or its CSLIP variant), specify the boot device as follows:
boot device: sl or sl=device
Using the form sl=device allows you to specify the SLIP tty, overriding the
configuration constant SLIP_TTY.
The following is a boot example for the configuration shown in Figure 13-2:
boot device : sl=/tyCo/1
processor number : 0
host name : phobos
file name : /usr/wind/target/config/ads302/vxWorks
inet on ethernet (e) : 150.12.1.2
host inet (h) : 150.12.1.1
user (u) : jane
target name (tn) : vxJane
When the boot device is SLIP, the SLIP interface is configured by usrSlipInit( ) in
target/src/config/usrNetwork.c. This sets up the SLIP tty, and configures the point-
to-point connection using the target and host IP addresses specified in the boot
parameters. If a gateway address is specified, the SLIP driver adds a routing entry
from the gateway address to the host address. If a gateway address is not
13. If your host operating system does not include SLIP or CSLIP facilities, consider using a
publicly available implementation. One popular implementation for SunOS 4.1.x, the Van
Jacobson CSLIP 2.7 release, is provided in target/unsupported/cslip-2.7. This code is
publicly available, and is not supported by Wind River Systems. It is included only as a
convenience.
204
13
Booting over the Network
target host
tty
/tyCo/1 150.12.1.2 150.12.1.1
Serial Line
specified, the SLIP driver assumes that the point-to-point peer address on the other
end of the serial line is the gateway and enters the appropriate routing entry.
If you do not have a second serial port, then you must use the console port as the
SLIP port. To do this:
1. Set the console serial port (configuration constant CONSOLE_TTY) to NONE
and define the SLIP channel identifier (configuration constant SLIP_TTY):
13
#define CONSOLE_TTY NONE
#define SLIP_TTY 0 /* use port number 0 for slip */
To boot VxWorks using PPP, first configure PPP into the system (see PPP
Configuration, p.18) and remake the VxWorks and boot ROM images. After a new
boot ROM image has been built, burned into ROM, and installed in the target
board, bootstrap the target board to the VxWorks boot ROM prompt.
When booting using PPP, specify the boot device with one of the following options:
boot device: ppp
If using boot device: ppp, the serial channel is set to PPP_TTY in the VxWorks
configuration and the baud rate is set to the default baud rate of the channel.
When the boot device is ppp, the PPP interface is initialized by usrPPPInit( ).
This configures the point-to-point connection using the serial device, target,
205
VxWorks Network 5.4
Programmer’s Guide
and host IP addresses specified in the boot parameters. And it configures in the
options defined at compile-time in the configuration (see the Tornado User’s
Guide: Projects for more information on configuring VxWorks). If a gateway
address is specified, the PPP driver adds a routing entry from the gateway
address to the host address. If a gateway address is not specified, the PPP
software assumes that the point-to-point peer address is on the other end of
the serial line and enters the appropriate routing entry.
ppp=device
Specifying ppp=device allows you to choose the PPP tty (serial channel),
overriding the PPP_TTY constant.
ppp=device,baudrate
Specifying ppp=device,baudrate allows you to choose the PPP tty (serial
channel) and the baud rate of the channel.
ppp,baudrate
The default baud rate used by the PPP tty (serial channel) can be configured
into the system by defining the constant PPP_BAUDRATE (in config.h) as the
required baud rate, and remaking VxWorks and the boot ROM images.
However, the baud rate supplied as a part of the boot device overrides any default
settings. The following is a boot example for the configuration shown in
Figure 13-3:
boot device : ppp=/tyCo/2,38400
processor number : 0
host name : mars
file name : /usr/vw/config/mv167/vxWorks
inet on ethernet (e) : 90.0.0.10
host inet (h) : 90.0.0.1
user (u) : jane
target name (tn) : vxJane
If you want to boot VxWorks over a PPP link but do not have a console device, the
following additional modifications must be made:
1. Set the console serial port (configuration constant CONSOLE_TTY) to NONE
and define the tty port number using the constant PPP_TTY in config.h:
#define PPP_TTY 0 /* use port number 0 for PPP */
206
13
Booting over the Network
target host
tty
90.0.0.10 /tyCo/2 90.0.0.1
Serial Line
3. If your system has nonvolatile RAM (NVRAM), edit sysLib.c and change
sysNvRamGet( ) to return ERROR. This forces the use of the default boot line,
instead of the value stored in NVRAM.
4. Initialize PPP on the remote peer. 13
5. Boot VxWorks with the new boot ROMs.
207
VxWorks Network 5.4
Programmer’s Guide
208
14
Upgrading 4.3 BSD Network
Drivers
14.1 Introduction
This chapter describes two upgrade paths for 4.3 BSD network drivers. One path
simply ports the 4.3 BSD network driver to the BSD 4.4 model. The other path
upgrades the 4.3 BSD network driver to an NPT driver (described in the Network
Protocol Toolkit User’s Guide).
Porting a network driver to the 4.4 BSD model should require only minimal
changes to the code. In fact, porting some drivers has taken less than a day’s work.
However, an older driver that does not already use a transmission startup routine
can take longer to port.
Porting a network driver to an NPT driver requires more extensive changes.
However, it is worth the effort if the driver must handle the following:
■ multicasting
■ polled-mode Ethernet (necessary for WDB system-mode debugging over a
network, a mode that is several orders of magnitude faster than the serial link)
■ zero-copy transmission
■ support for network protocols other than IP
209
VxWorks Network 5.4
Programmer’s Guide
Packet reception begins when the driver’s interrupt routine is invoked. The
interrupt routine does the least work necessary to get the packet off the local
hardware, schedules an input handler to run by calling netJobAdd( ), and then
returns. The tNetTask calls the function that was added to its work queue. In the
case of packet reception, this the driver’s xxReceive( ) function.
The xxReceive( ) function eventually sends the packet up to a protocol by calling
do_protocol_with_type( ). This routine is a switch statement that figures out
which protocol to hand the packet off to. This calling sequence is shown in
Figure 14-1.
Figure 14-2 shows the call graph for packet transmission. After a protocol has
picked an interface on which to send a packet, it calls the xxOutput( ) routine for
that interface. The output routine calls the generic ether_output( ) function,
passing it a pointer to addressing information (usually an arpcom structure) as
well as the data to be sent. After the data is properly packed, it is placed on the
output queue (using the IF_ENQUEUE macro), and the driver’s start routine is
called. The xxTxStartup( ) routine dequeues as many packets as it can and
transmits them on the physical medium.
210
14
Upgrading 4.3 BSD Network Drivers
etherInputHook( ) do_protocol_with_type( )
[1]
[2]
xxReceive( )
xxHandleRecvInt( )
xxInt( )
xxOutput( ) 14
ether_output( )
xxTxStartup( )
[1] [2]
etherOutputHook( ) transmit on medium
You can use the etherInputHook( ) and etherOutputHook( ) routines to bypass the
TCP/IP stack and thus get access to raw packets. On packet reception, if an
etherInputHook( ) function is installed, it receives the packet just after the driver
has completed reception but before the packet goes to the protocol. If
211
VxWorks Network 5.4
Programmer’s Guide
As arguments, this routine expects an Interface Data Record (idr), a unit number,
and a quoted string that is the name of the device, in this case, “xx”. The next four
arguments are the function pointers to relevant driver routines.
212
14
Upgrading 4.3 BSD Network Drivers
The first function pointer references this driver’s init( ) routine, which this driver
does not need or have. The second function pointer references the driver’s ioctl( )
interface, which allows the upper layer to manipulate the device state. The third
function pointer references the routine that outputs packets on the physical
medium. The last function pointer references a routine that can reset the device if
the TCP/IP stack decides that this needs to be done.
In 4.4 BSD, there is a generic output routine called ether_output( ) that all Ethernet
device drivers can use. Thus, to convert the above ether_attach( ) call to a 4.4-style
call, you would call ether_attach( ) as follows:
ether_attach(
(IFNET *) & pDrvCtrl->idr,
unit,
"xx",
(FUNCPTR) NULL,
(FUNCPTR) xxIoctl,
(FUNCPTR) ether_output, /* generic ether_output */
(FUNCPTR) xxReset
);
pDrvCtrl->idr.ac_if.if_start = (FUNCPTR)xxTxStartup;
This time, there is an extra line following the call to ether_attach( ). This line of
code adds a transmit startup routine to the Interface Data Record. The transmit 14
startup routine is called by the TCP/IP stack after the generic ether_output( )
routine is called. This extra line of code assumes that the driver already has a
transmit startup routine. If a driver lacks a separate transmit startup routine, you
must write one. See the template in 14.3.4 Creating a Transmit Startup Routine, p.214.
If a 4.3 BSD driver has an xxOutput( ) routine, it probably looks something like the
following:
static int xxOutput
(
IDR * pIDR,
MBUF * pMbuf,
SOCK * pDestAddr
)
{
return (ether_output ((IFNET *)pIDR, pMbuf, pDestAddr,
(FUNCPTR) xxTxStartup, pIDR));
}
Internally, this routine calls the ether_output( ) routine, which expects a pointer to
the startup routine as one of its arguments. However, in the 4.4 BSD model, all that
213
VxWorks Network 5.4
Programmer’s Guide
work that is now handled in the TCP/IP stack. Thus, in a 4.4 BSD driver, this code
is unnecessary and should be removed.
Under 4.3 BSD, the function prototype for a transmit startup routine is as follows:
static void xxTxStartup (int unit);
The 4.4 BSD version expects a pointer to a driver control structure. This change
eases the burden on the startup routine. Instead of having to find its own driver
control structure, it receives a pointer to a driver control structure as input.
If the driver uses netJobAdd( ) to schedule the transmit startup routine for task-
level execution, edit the netJobAdd( ) call to pass in a DRV_CTRL structure pointer
instead of a unit number.
This call expects an etherType (which the driver had to discover previously), a
pointer to an mbuf containing the packet data, the Interface Data Record, and the
length of the data.
Under 4.4 BSD, replace the call above with a call to do_protocol( ). For example:
do_protocol (pEh, pMbuf, &pDrvCtrl->idr, len);
The first parameter is a pointer to the very beginning of the packet (including the
link level header). All the other parameters remain the same. The driver no longer
needs to figure out the etherType for the protocol.
Some 4.3 BSD drivers did not have a transmit startup routine. For such a driver,
you must create one. The template is as follows:
214
14
Upgrading 4.3 BSD Network Drivers
void templateStartup
(
DRV_CTRL *pDrvCtrl
)
{
MBUF * pMbuf;
int length;
TFD * pTfd;
if (Insufficient Resources)
{
m_freem (pMbuf);/* Make sure to free the packet. */
return;
}
/*
* Update the counter that determines the number of
* packets that have been output.
*/
pDrvCtrl->idr.ac_if.if_opackets++;
215
VxWorks Network 5.4
Programmer’s Guide
216
Index
Symbols B
#define statements backplanes
see also individual #define parameters see also shared-memory networks
boot parameters, setting 194 anchor address, setting 43
network layer protocols, configuring 75–78 interprocessor interrupts 47
interrupt types 48
processor 0 42
processor numbers 42
A shared-memory pool 41–47
bad (inet on backplane (b)) 191
Address Resolution Protocol, see ARP
big-endian numbers 62
addresses, see broadcast addresses; Internet
boot line
addresses; port addresses
default, creating 194
anchor, see shared-memory anchor
format 188
ARP (Address Resolution Protocol) 84–86
boot parameters 186–207
main network, replies from the 89
see also boot program; booting
non-proxy clients, requests for 89
bad (inet on backplane (b)) 191
proxy clients, requests for 89
bootDev (boot device) 189
arpShow( ) 99
bootFile (file name) 191
arptabShow( ) 99
ead (inet on ethernet (e)) 191
AUTH_UNIX (RPC) 176
flags (flags (f)) 190
authentication 20
gad (gateway inet (g)) 191
CHAP 34
getting 186
PAP 33–34
had (host inet (h)) 191
RPC 176
hostName (host name) 193
listing 188
network devices, initializing 189–190
other (other (o)) 193
217
VxWorks Network 5.4
Programmer’s Guide
218
Index
219
VxWorks Network 5.4
Programmer’s Guide
220
Index
221
VxWorks Network 5.4
Programmer’s Guide
222
Index
223
VxWorks Network 5.4
Programmer’s Guide
224
Index
225
VxWorks Network 5.4
Programmer’s Guide
226
Index
SM_MEM_SIZE 45
SM_OFF_BOARD 45
T
SM_TAS_HARD 47 TARGET_NAME_DEFAULT 194
SM_TAS_SOFT 47 targetName (target name (tn)) 193
SM_TAS_TYPE 47 tasks
smNetInit( ) 49 network (tNetTask) 210
smNetShow( ) 98, 99 TCP (Transmission Control Protocol) 74
configuring a shared-memory network 54 configuring 75
sequential addressing 49 stream sockets 126–133
SNMP, see WindNet SNMP zbufs, using 144
SNTP (Simple Network Time Protocol) 165–166 zero-copy 144
SNTP_ACTIVE 166 TCP/IP protocol suite 57–99
SNTP_PASSIV 166 #define statements, setting 75–78
SNTP_PORT 166 TCP_CON_TIMEO_DFLT 76
sntpcTimeGet( ) 165 TCP_FLAGS_DFLT 75
SNTPS_CLOCK_HOOK 166 TCP_IDLE_TIMEO_DFLT 76
SNTPS_DSTADDR 166 TCP_MAX_PROBE_DFLT 76
SNTPS_INTERVAL 166 TCP_MSS_DFLT 76
SNTPS_MODE 166 TCP_RCV_SIZE_DFLT 75
sntpsClockSet( ) 166 TCP_REXMT_THLD_DFLT 76
sntpsConfigSet( ) 166 TCP_RND_TRIP_DFLT 76
sntpsInit( ) 166 TCP_SND_SIZE_DFLT 75
sockets 3, 125–159 telnet 184
see also zbufs; sockLib(1); zbufSockLib(1) see also telnetLib(1) IX
datagram 133–144 test-and-set instruction 46
signals, using 126 TFTP (Trivial File Transfer Protocol) 180–181
stream 126–133 see also tftpdLib(1); tftpLib(1)
zbufs 144–159 run-time image, getting the VxWorks 192
startupScript (startup script (s)) 193 security (-s option) 180
STOR command 170 VxWorks client 181
stream sockets 126–133 VxWorks server 180
client-server communication 127–133 tftpCopy( ) 181
code example 127–133 tftpXfer( ) 181
subnet addressing 73 tNetTask task 210
subnets Transmission Control Protocol, see TCP
configuring 72 Trivial File Transfer Protocol, see TFTP
proxy ARP, using 86–89, 93–99 troubleshooting
sysBusTas( ) 46 BOOTP 200
sysBusToLocalAddr( ) 98 DHCP 201
sysLocalToBusAddr( ) 98 PPP 39–40
sysPhysMemDesc[ ] 46 routing 99
non-cacheable shared-memory 46 shared-memory networks 53–55
227
VxWorks Network 5.4
Programmer’s Guide
U Z
UDP (User Datagram Protocol) 74 ZBUF_BEGIN 146
broadcasting 65 ZBUF_END 146
configuring 75 zbufCreate( ) 147
datagram sockets 133–144 zbufCut( ) 149
multicasting 66 zbufDelete( ) 147
zbufs, using 144 zbufDup( ) 148
UDP_FLAGS_DFLT 76 zbufExtractCopy( ) 147
UDP_RCV_SIZE_DFLT 76 zbufInsert( ) 148, 149
UDP_SND_SIZE_DFLT 76 zbufInsertBuf( ) 147
unitNum (unit number) 189 zbufInsertCopy( ) 147
User Datagram Protocol, see UDP zbufLength( ) 148
usr (user (u)) 192 zbufs 3, 144–159
usrNetInit( ) 64, 65, 70 see also zbufLib(1); zbufSockLib(1)
network device, creating a 173 byte locations 145–146
user name, setting 173 code examples
usrNetwork.c display routine, creating a 152–153
PPP links, initializing 26 TCP server, converting a 155–159
usrPPPInit( ) configuring into VxWorks image 144
calling 26 creating 147
links, initializing 26 data structures, manipulating 145–154
PPP options, selecting data, handling
configuration constants, using 23 copying into 147
options files, using 25 copying out of 147
target-peer link delay, setting 23 placing in 147
usrSlipInit( ) 204 deleting 147
dividing in two 148
inserting 148
length, determining 148
V limitations on use 154
offsets 145
Van Jacobsen (VJ) compression 17, 40
removing bytes 149
VMEbus access 46
segment IDs 145
VxSim, using (for Solaris) 23
segments 148, 149–150
byte locations, determining 150
data location, determining 150
W length, determining 150
reading 150
WindNet SNMP (option) 4, 116 sharing 148
socket calls 154–159
zbufSegData( ) 150
zbufSegFind( ) 150
zbufSegLength( ) 150
zbufSegNext( ) 150
228
Index
zbufSegPrev( ) 150
zbufSockBufSend( ) 144, 154
zbufSockBufSendto( ) 144, 154
zbufSockLibInit( ) 154
zbufSockRecv( ) 154
zbufSockRecvfrom( ) 154
zbufSockSend( ) 154
zbufSockSendto( ) 154
zbufSplit( ) 148
zero-copy TCP 144, 209
IX
229