OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k/trunk/ecos-2.0/packages/net/tcpip/v2_0/doc
    from Rev 1254 to Rev 1765
    Reverse comparison

Rev 1254 → Rev 1765

/bind.html
0,0 → 1,64
<html>
<body>
<pre>
NAME
bind - bind a name to a socket
 
SYNOPSIS
#include &lt;network.h&gt;
 
int bind(int sockfd, struct sockaddr *my_addr, int
addrlen);
 
DESCRIPTION
bind gives the socket sockfd the local address my_addr.
my_addr is addrlen bytes long. Traditionally, this is
called "assigning a name to a socket." (When a socket is
created with socket(2), it exists in a name space (address
family) but has no name assigned.)
 
Before a SOCK_STREAM socket is put into the LISTEN state
to receive connections, you usually need to first assign a
local address using bind to make the socket visible.
 
NOTES
Binding a name that is not in the abstract namespace in
the UNIX domain creates a socket in the file system that
must be deleted by the caller when it is no longer needed
(using unlink(2)).
 
The rules used in name binding vary between communication
domains. Consult the manual entries in section 4 for
detailed information. For IP see ip(4) and for PF_UNIX see
unix(4). If you want to listen to every local interface
for IPv4 set the sin_addr member of the IP-specific sock-
addr_in to INADDR_ANY. For IP only one socket may be
bound to a specific local address/port pair. For TCP a
bound local socket endpoint (address/port pair) is
unavailable for some time after closing the socket, unless
the SO_REUSEADDR flag is set. Note that carelessly setting
SO_REUSEADDR might make TCP more unreliable unless PAWS is
used (see tcp(4)); the delay is needed to handle old pack-
ets still in the network.
 
IP sockets may also bind to a broadcast or multicast
address.
 
RETURN VALUE
On success, zero is returned. On error, -1 is returned,
and errno is set appropriately.
 
ERRORS
EBADF sockfd is not a valid descriptor.
 
EINVAL The socket is already bound to an address. This
may change in the future: see linux/unix/sock.c
for details.
 
ENOTSOCK
Argument is a descriptor for a file, not a socket.
 
 
</pre>
</body>
</html>
/close.man
0,0 → 1,21
NAME
close - close a file descriptor
 
SYNOPSIS
 
int close(int fd);
 
DESCRIPTION
close closes a file descriptor, so that it no longer
refers to any file and may be reused.
 
If fd is the last copy of a particular file descriptor the
resources associated with it are freed.
 
RETURN VALUE
close returns zero on success, or -1 if an error occurred.
 
ERRORS
EBADF fd isn't a valid open file descriptor.
 
 
/gethost.html
0,0 → 1,110
<html>
<body>
<pre>
NAME
gethostbyname, gethostbyaddr, herror, hstrerror - get network host entry
 
SYNOPSIS
#include &lt;network.h&gt;
 
struct hostent *gethostbyname(const char *name);
 
struct hostent *gethostbyaddr(const char *addr, int len, int type);
 
void herror(const char *s);
 
const char * hstrerror(int err);
 
DESCRIPTION
The gethostbyname() function returns a structure of type
hostent for the given host name. Here name is either a
host name, or an IPv4 address in standard dot notation, or
an IPv6 address in colon (and possibly dot) notation. (See
RFC 1884 for the description of IPv6 addresses.) If name
is an IPv4 or IPv6 address, no lookup is performed and
gethostbyname() simply copies name into the h_name field
and its struct in_addr equivalent into the h_addr_list[0]
field of the returned hostent structure. If name doesn't
end in a dot and the environment variable HOSTALIASES is
set, the alias file pointed to by HOSTALIASES will first
 
mat.) The current domain and its parents are searched
unless name ends in a dot.
 
The gethostbyaddr() function returns a structure of type
hostent for the given host address addr of length len and
 
rently AF_INET.
 
The (obsolete) herror() function prints the error message
associated with the current value of h_errno on stderr.
 
The (obsolete) hstrerror() function takes an error number
(typically h_errno) and returns the corresponding message
string.
 
The domain name queries carried out by gethostbyname() and
gethostbyaddr() use a combination of any or all of the
name server named(8), a broken out line from /etc/hosts,
and the Network Information Service (NIS or YP), depending
upon the contents of the order line in /etc/host.conf.
(See resolv+(8)). The default action is to query
named(8), followed by /etc/hosts.
 
The hostent structure is defined in &lt;netdb.h&gt; as follows:
 
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses */
}
#define h_addr h_addr_list[0] /* for backward compatibility */
 
The members of the hostent structure are:
 
h_name The official name of the host.
 
h_aliases
A zero-terminated array of alternative names for
the host.
 
h_addrtype
The type of address; always AF_INET at present.
 
h_length
The length of the address in bytes.
 
h_addr_list
A zero-terminated array of network addresses for
the host in network byte order.
 
 
patibility.
 
RETURN VALUE
The gethostbyname() and gethostbyaddr() functions return
the hostent structure or a NULL pointer if an error
occurs. On error, the h_errno variable holds an error
number.
 
ERRORS
The variable h_errno can have the following values:
 
HOST_NOT_FOUND
The specified host is unknown.
 
NO_ADDRESS or NO_DATA
The requested name is valid but does not have an IP
address.
 
NO_RECOVERY
A non-recoverable name server error occurred.
 
TRY_AGAIN
A temporary error occurred on an authoritative name
server. Try again later.
</pre>
</body>
</html>
/select.html
0,0 → 1,108
<html>
<body>
<pre>
NAME
select, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous
I/O multiplexing
 
SYNOPSIS
#include &lt;network.h&gt;
 
int select(int n, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
 
FD_CLR(int fd, fd_set *set);
FD_ISSET(int fd, fd_set *set);
FD_SET(int fd, fd_set *set);
FD_ZERO(fd_set *set);
 
DESCRIPTION
select waits for a number of file descriptors to change
status.
 
Three independent sets of descriptors are watched. Those
listed in readfds will be watched to see if characters
become available for reading, those in writefds will be
watched to see if it is ok to immediately write on them,
and those in exceptfds will be watched for exceptions. On
exit, the sets are modified in place to indicate which
descriptors actually changed status.
 
Four macros are provided to manipulate the sets. FD_ZERO
will clear a set. FD_SET and FD_CLR add or remove a given
descriptor from a set. FD_ISSET tests to see if a
descriptor is part of the set; this is useful after select
returns.
 
n is the highest-numbered descriptor in any of the three
sets, plus 1.
 
timeout is an upper bound on the amount of time elapsed
before select returns. It may be zero, causing select to
return immediately. If timeout is NULL (no timeout),
select can block indefinitely.
 
RETURN VALUE
On success, select returns the number of descriptors con-
tained in the descriptor sets, which may be zero if the
timeout expires before anything interesting happens. On
error, -1 is returned, and errno is set appropriately; the
sets and timeout become undefined, so do not rely on their
contents after an error.
 
ERRORS
EBADF An invalid file descriptor was given in one of the
sets.
 
EINTR A non blocked signal was caught.
 
EINVAL n is negative.
 
ENOMEM select was unable to allocate memory for internal
tables.
 
NOTES
Some code calls select with all three sets empty, n zero,
and a non-null timeout as a fairly portable way to sleep
with subsecond precision.
 
EXAMPLE
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
 
int
main(void)
{
fd_set rfds;
struct timeval tv;
int retval;
 
/* Watch stdin (fd 0) to see when it has input. */
FD_ZERO(&rfds);
FD_SET(0, &rfds);
/* Wait up to five seconds. */
tv.tv_sec = 5;
tv.tv_usec = 0;
 
retval = select(1, &rfds, NULL, NULL, &tv);
/* Don't rely on the value of tv now! */
 
if (retval)
printf("Data is available now.\n");
/* FD_ISSET(0, &rfds) will be true. */
else
printf("No data within five seconds.\n");
 
exit(0);
}
 
Generally portable to/from non-BSD systems supporting
clones of the BSD socket layer (including System V vari-
ants). However, note that the System V variant typically
sets the timeout variable before exit, but the BSD variant
does not.
</pre>
</body>
</html>
/getserv.html
0,0 → 1,54
<html>
<body>
<pre>
NAME
getservent, getservbyname, getservbyport - get service entry
 
SYNOPSIS
#include &lt;network.h&gt;
 
struct servent *getservbyname(const char *name, const char *proto);
 
struct servent *getservbyport(int port, const char *proto);
 
DESCRIPTION
The getservbyname() function returns a servent structure
for the line from /etc/services that matches the service
name using protocol proto.
 
The getservbyport() function returns a servent structure
for the line that matches the port port given in network
byte order using protocol proto.
 
The servent structure is defined in &lt;netdb.h&gt; as follows:
 
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port number */
char *s_proto; /* protocol to use */
}
 
The members of the servent structure are:
 
s_name The official name of the service.
 
s_aliases
A zero terminated list of alternative names for the
service.
 
s_port The port number for the service given in network
byte order.
 
s_proto
The name of the protocol to use with this service.
 
RETURN VALUE
The getservbyname() and getservbyport()
functions return the servent structure, or a NULL pointer
if an error occurs.
 
 
</pre>
</body>
</html>
/ioctl.man
0,0 → 1,40
NAME
ioctl - control device
 
SYNOPSIS
#include <sys/ioctl.h>
 
int ioctl(int d, int request, ...)
 
[The "third" argument is traditionally char *argp, and
will be so named for this discussion.]
 
DESCRIPTION
The ioctl function manipulates the underlying device
parameters of special files. In particular, many operat-
ing characteristics of sockets and network devices
may be controlled with ioctl requests. The argu-
ment d must be an open file descriptor.
 
An ioctl request has encoded in it whether the argument is
an in parameter or out parameter, and the size of the
argument argp in bytes. Macros and defines used in speci-
fying an ioctl request are located in the file
<sys/ioctl.h>.
 
RETURN VALUE
On success, zero is returned. On error, -1 is returned,
and errno is set appropriately.
 
ERRORS
EBADF d is not a valid descriptor.
 
EFAULT argp references an inaccessible memory area.
 
ENOTTY d is not associated with a character special
device.
 
ENOTTY The specified request does not apply to the kind of
object that the descriptor d references.
 
EINVAL Request or argp is not valid.
/getsockopt.html
0,0 → 1,70
<html>
<body>
<pre>
NAME
getsockopt, setsockopt - get and set options on sockets
 
SYNOPSIS
#include &lt;network.h&gt;
 
 
val, socklen_t *optlen);
 
int setsockopt(int s, int level, int optname, const void
*optval, socklen_t optlen);
 
DESCRIPTION
 
 
col levels; they are always present at the uppermost
socket level.
 
When manipulating socket options the level at which the
 
fied. To manipulate options at the socket level, level is
specified as SOL_SOCKET. To manipulate options at any
 
col controlling the option is supplied. For example, to
indicate that an option is to be interpreted by the TCP
protocol, level should be set to the protocol number of
TCP; see getprotoent(3).
 
The parameters optval and optlen are used to access option
values for setsockopt. For getsockopt they identify a
buffer in which the value for the requested option(s) are
to be returned. For getsockopt, optlen is a value-result
parameter, initially containing the size of the buffer
pointed to by optval, and modified on return to indicate
the actual size of the value returned. If no option value
is to be supplied or returned, optval may be NULL.
 
Optname and any specified options are passed uninterpreted
to the appropriate protocol module for interpretation.
The include file &lt;network.h&gt; contains definitions for
socket level options, described below. Options at other
protocol levels vary in format and name; consult the
appropriate entries in section 4 of the manual.
 
Most socket-level options utilize an int parameter for
optval. For setsockopt, the parameter should be non-zero
to enable a boolean option, or zero if the option is to be
disabled.
 
For a description of the available socket options see
socket(7) and the appropriate protocol man pages.
 
RETURN VALUE
On success, zero is returned. On error, -1 is returned,
and errno is set appropriately.
 
ERRORS
EBADF The argument s is not a valid descriptor.
 
ENOTSOCK
The argument s is a file, not a socket.
 
ENOPROTOOPT
The option is unknown at the level indicated.
</pre>
</body>
</html>
/read.man
0,0 → 1,55
NAME
read - read from a file descriptor
 
SYNOPSIS
ssize_t read(int fd, void *buf, size_t count);
 
DESCRIPTION
read() attempts to read up to count bytes from file
descriptor fd into the buffer starting at buf.
 
If count is zero, read() returns zero and has no other
results.
 
 
RETURN VALUE
On success, the number of bytes read is returned (zero
indicates end of file), and the file position is advanced
by this number. It is not an error if this number is
smaller than the number of bytes requested; this may hap-
pen for example because fewer bytes are actually available
right now (maybe because we were close to end-of-file, or
because we are reading from a pipe, or from a terminal),
or because read() was interrupted by a signal. On error,
-1 is returned, and errno is set appropriately. In this
case it is left unspecified whether the file position (if
any) changes.
 
ERRORS
EINTR The call was interrupted by a signal before any
data was read.
 
EAGAIN Non-blocking I/O has been selected using O_NON-
BLOCK and no data was immediately available for
reading.
 
EIO I/O error. This will happen for example when the
process is in a background process group, tries to
read from its controlling tty, and either it is
ignoring or blocking SIGTTIN or its process group
is orphaned. It may also occur when there is a
low-level I/O error while reading from a disk or
tape.
 
EISDIR fd refers to a directory.
 
EBADF fd is not a valid file descriptor or is not open
for reading.
 
EINVAL fd is attached to an object which is unsuitable
for reading.
 
Other errors may occur, depending on the object connected
to fd. POSIX allows a read that is interrupted after
reading some data to return -1 (with errno set to EINTR)
or to return the number of bytes already read.
/gethost.man
0,0 → 1,104
NAME
gethostbyname, gethostbyaddr, herror, hstrerror - get network host entry
 
SYNOPSIS
#include <network.h>
 
struct hostent *gethostbyname(const char *name);
 
struct hostent *gethostbyaddr(const char *addr, int len, int type);
 
void herror(const char *s);
 
const char * hstrerror(int err);
 
DESCRIPTION
The gethostbyname() function returns a structure of type
hostent for the given host name. Here name is either a
host name, or an IPv4 address in standard dot notation, or
an IPv6 address in colon (and possibly dot) notation. (See
RFC 1884 for the description of IPv6 addresses.) If name
is an IPv4 or IPv6 address, no lookup is performed and
gethostbyname() simply copies name into the h_name field
and its struct in_addr equivalent into the h_addr_list[0]
field of the returned hostent structure. If name doesn't
end in a dot and the environment variable HOSTALIASES is
set, the alias file pointed to by HOSTALIASES will first
 
mat.) The current domain and its parents are searched
unless name ends in a dot.
 
The gethostbyaddr() function returns a structure of type
hostent for the given host address addr of length len and
 
rently AF_INET.
 
The (obsolete) herror() function prints the error message
associated with the current value of h_errno on stderr.
 
The (obsolete) hstrerror() function takes an error number
(typically h_errno) and returns the corresponding message
string.
 
The domain name queries carried out by gethostbyname() and
gethostbyaddr() use a combination of any or all of the
name server named(8), a broken out line from /etc/hosts,
and the Network Information Service (NIS or YP), depending
upon the contents of the order line in /etc/host.conf.
(See resolv+(8)). The default action is to query
named(8), followed by /etc/hosts.
 
The hostent structure is defined in <netdb.h> as follows:
 
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses */
}
#define h_addr h_addr_list[0] /* for backward compatibility */
 
The members of the hostent structure are:
 
h_name The official name of the host.
 
h_aliases
A zero-terminated array of alternative names for
the host.
 
h_addrtype
The type of address; always AF_INET at present.
 
h_length
The length of the address in bytes.
 
h_addr_list
A zero-terminated array of network addresses for
the host in network byte order.
 
 
patibility.
 
RETURN VALUE
The gethostbyname() and gethostbyaddr() functions return
the hostent structure or a NULL pointer if an error
occurs. On error, the h_errno variable holds an error
number.
 
ERRORS
The variable h_errno can have the following values:
 
HOST_NOT_FOUND
The specified host is unknown.
 
NO_ADDRESS or NO_DATA
The requested name is valid but does not have an IP
address.
 
NO_RECOVERY
A non-recoverable name server error occurred.
 
TRY_AGAIN
A temporary error occurred on an authoritative name
server. Try again later.
/getserv.man
0,0 → 1,48
NAME
getservent, getservbyname, getservbyport - get service entry
 
SYNOPSIS
#include <network.h>
 
struct servent *getservbyname(const char *name, const char *proto);
 
struct servent *getservbyport(int port, const char *proto);
 
DESCRIPTION
The getservbyname() function returns a servent structure
for the line from /etc/services that matches the service
name using protocol proto.
 
The getservbyport() function returns a servent structure
for the line that matches the port port given in network
byte order using protocol proto.
 
The servent structure is defined in <netdb.h> as follows:
 
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port number */
char *s_proto; /* protocol to use */
}
 
The members of the servent structure are:
 
s_name The official name of the service.
 
s_aliases
A zero terminated list of alternative names for the
service.
 
s_port The port number for the service given in network
byte order.
 
s_proto
The name of the protocol to use with this service.
 
RETURN VALUE
The getservbyname() and getservbyport()
functions return the servent structure, or a NULL pointer
if an error occurs.
 
 
/select.man
0,0 → 1,102
NAME
select, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous
I/O multiplexing
 
SYNOPSIS
#include <network.h>
 
int select(int n, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
 
FD_CLR(int fd, fd_set *set);
FD_ISSET(int fd, fd_set *set);
FD_SET(int fd, fd_set *set);
FD_ZERO(fd_set *set);
 
DESCRIPTION
select waits for a number of file descriptors to change
status.
 
Three independent sets of descriptors are watched. Those
listed in readfds will be watched to see if characters
become available for reading, those in writefds will be
watched to see if it is ok to immediately write on them,
and those in exceptfds will be watched for exceptions. On
exit, the sets are modified in place to indicate which
descriptors actually changed status.
 
Four macros are provided to manipulate the sets. FD_ZERO
will clear a set. FD_SET and FD_CLR add or remove a given
descriptor from a set. FD_ISSET tests to see if a
descriptor is part of the set; this is useful after select
returns.
 
n is the highest-numbered descriptor in any of the three
sets, plus 1.
 
timeout is an upper bound on the amount of time elapsed
before select returns. It may be zero, causing select to
return immediately. If timeout is NULL (no timeout),
select can block indefinitely.
 
RETURN VALUE
On success, select returns the number of descriptors con-
tained in the descriptor sets, which may be zero if the
timeout expires before anything interesting happens. On
error, -1 is returned, and errno is set appropriately; the
sets and timeout become undefined, so do not rely on their
contents after an error.
 
ERRORS
EBADF An invalid file descriptor was given in one of the
sets.
 
EINTR A non blocked signal was caught.
 
EINVAL n is negative.
 
ENOMEM select was unable to allocate memory for internal
tables.
 
NOTES
Some code calls select with all three sets empty, n zero,
and a non-null timeout as a fairly portable way to sleep
with subsecond precision.
 
EXAMPLE
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
 
int
main(void)
{
fd_set rfds;
struct timeval tv;
int retval;
 
/* Watch stdin (fd 0) to see when it has input. */
FD_ZERO(&rfds);
FD_SET(0, &rfds);
/* Wait up to five seconds. */
tv.tv_sec = 5;
tv.tv_usec = 0;
 
retval = select(1, &rfds, NULL, NULL, &tv);
/* Don't rely on the value of tv now! */
 
if (retval)
printf("Data is available now.\n");
/* FD_ISSET(0, &rfds) will be true. */
else
printf("No data within five seconds.\n");
 
exit(0);
}
 
Generally portable to/from non-BSD systems supporting
clones of the BSD socket layer (including System V vari-
ants). However, note that the System V variant typically
sets the timeout variable before exit, but the BSD variant
does not.
/openbsd.sgml
0,0 → 1,193
<!-- {{{ Banner -->
 
<!-- =============================================================== -->
<!-- -->
<!-- openbsd.sgml -->
<!-- -->
<!-- eCos TCP/IP Stacks -->
<!-- -->
<!-- =============================================================== -->
<!-- ####COPYRIGHTBEGIN#### -->
<!-- -->
<!-- =============================================================== -->
<!-- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -->
<!-- This material may be distributed only subject to the terms -->
<!-- and conditions set forth in the Open Publication License, v1.0 -->
<!-- or later (the latest version is presently available at -->
<!-- http://www.opencontent.org/openpub/) -->
<!-- Distribution of the work or derivative of the work in any -->
<!-- standard (paper) book form is prohibited unless prior -->
<!-- permission obtained from the copyright holder -->
<!-- =============================================================== -->
<!-- -->
<!-- ####COPYRIGHTEND#### -->
<!-- =============================================================== -->
<!-- #####DESCRIPTIONBEGIN#### -->
<!-- -->
<!-- ####DESCRIPTIONEND#### -->
<!-- =============================================================== -->
 
<!-- }}} -->
 
<PART id="tcpip-openbsd">
<TITLE>OpenBSD TCP/IP Stack port for eCos</TITLE>
<PARTINTRO>
<PARA> <productname>TCP/IP Networking for eCos</productname>
now provides a complete
TCP/IP networking stack, which is derived from a recent
stable release of OpenBSD. The networking support is
fully featured and well tested within the eCos environment.
</PARA>
</PARTINTRO>
 
<CHAPTER id="tcpip-openbsd-networking-stack-features">
<TITLE>Networking Stack Features</TITLE>
<PARA>Since this networking package is based on BSD code, it is
very complete and robust. The eCos implementation includes support
for the following protocols: </PARA>
<itemizedlist>
<LISTITEM><PARA>IPv4</para></listitem>
<LISTITEM><PARA>UDP</para></listitem>
<LISTITEM><PARA>TCP</para></listitem>
<LISTITEM><PARA>ICMP</para></listitem>
<LISTITEM><PARA>raw packet interface</para></listitem>
</itemizedlist>
<PARA>These additional features are also present in the package,
but are not supported:</PARA>
<itemizedlist>
<LISTITEM><PARA>Berkeley Packet Filter </PARA></LISTITEM>
<LISTITEM><PARA>Multi-cast and uni-cast support, including multi-casting
routing </PARA></LISTITEM>
<LISTITEM><PARA>IPv6 </PARA></LISTITEM>
</itemizedlist>
</CHAPTER>
<CHAPTER id="tcpip-openbsd-stack-port">
<TITLE>OpenBSD TCP/IP stack port</TITLE>
<PARA>This document describes how to get started with the OpenBSD
TCP/IP network stack. </PARA>
<SECT1 id="tcpip-openbsd-tcpip-targets">
<TITLE>Targets</TITLE>
<PARA>A number of ethernet devices may be supported. The default configuration
supports two instances of the interface by default,
and you will need to write your own driver instantiation code,
and supplemental startup and initialization code,
if you should add additional ones.</PARA>
<PARA>The target for your board will normally be supplied with an
ethernet driver, in which case including the network stack and
generic ethernet driver package to your build will automatically
enable usage of the ethernet device driver.
If your target is not supplied with an ethernet
driver, you will need to use loopback (see
<xref linkend="net-common-loopback-tests">).</PARA>
</SECT1>
<SECT1 id="tcpip-openbsd-building-the-network-stack">
<TITLE><!--<conditionaltext>-->Building the Network Stack</TITLE>
<PARA>Using the <EMPHASIS>Build-&gt;Packages</EMPHASIS> dialog,
add the packages &ldquo;Networking&rdquo;,
&ldquo;OpenBSD TCP/IP Stack&rdquo;
and &ldquo;Common Ethernet Support&rdquo;
to your configuration. Their package names
are CYGPKG_NET, CYGPKG_NET_OPENBSD_STACK and CYGPKG_NET_ETH_DRIVERS
respectively.</PARA>
<para>A short-cut way to do this is by
using the &ldquo;net&rdquo; <emphasis>template</emphasis>
if it is available for your platform.</para>
<PARA>The platform-specific ethernet device driver for your platform
will be added as part of the target selection (in the
<EMPHASIS>Build-&gt;Templates</EMPHASIS> &ldquo;Hardware&rdquo; item),
along with the
PCI I/O subsystem (if relevent) and the appropriate serial device driver.
</para><para>
For example, the PowerPC MBX target selection adds the package
PKG_NET_QUICC_ETH_DRIVERS,
and the Cirrus Logic EDB7xxx target selection adds the package
CYGPKG_NET_EDB7XXX_ETH_DRIVERS.
After this, eCos and its tests can be built exactly as usual.</PARA>
<NOTE>
<PARA>By default, most of the network tests are not built. This
is because some of them require manual intervention, i.e. they are
to be run &ldquo;by hand&rdquo;, and are not suitable for
automated testing. To build the full set of network tests, set
the configuration option CYGPKG_NET_BUILD_TESTS &ldquo;Build
networking tests (demo programs)&rdquo; within &ldquo;Networking
support build options&rdquo;.</PARA>
</NOTE>
</SECT1>
</CHAPTER>
<CHAPTER id="tcpip-openbsd-tcpip-apis">
<TITLE>APIs</TITLE>
<SECT1 id="tcpip-openbsd-standard-networking-api">
<TITLE>Standard networking</TITLE>
<PARA>The APIs for the standard networking calls such as
<FUNCTION>socket()</FUNCTION>, <FUNCTION>recv()</FUNCTION> and so on, are
in header files relative to the top-level
include directory, within the standard subdirectories as conventionally
found in <FILENAME>/usr/include</FILENAME>. For example:
<PROGRAMLISTING>
install/include/arpa/tftp.h
install/include/netinet/tcpip.h
install/include/sys/socket.h
install/include/sys/socketvar.h
install/include/sys/sockio.h
</PROGRAMLISTING>
</PARA><PARA>
<filename>network.h</filename> at the top level
defines various extensions, for example the API
<function>init_all_network_interfaces(void)</function>
described
above. We advise including <filename>network.h</filename> whether
you use these features or not.</PARA>
<PARA>In general, using the networking code may require definition
of two symbols: _KERNEL and __ECOS. _KERNEL
is not normally required; __ECOS is normally required.
So add this to your compile lines for files which use the network
stack:</PARA>
<PROGRAMLISTING> -D__ECOS</PROGRAMLISTING>
<PARA>To expand a little, it&rsquo;s like this because this is
a port of a standard distribution external to Red Hat. One goal
is to perturb the sources as little as possible, so that upgrading
and maintenance from the external distribution is simplified. The __ECOS
symbol marks out Red Hat&rsquo;s additions in making the port.
The _KERNEL symbol is traditional UNIX practice: it distinguishes
a compilation which is to be linked into the kernel from one which
is part of an application. eCos applications are fully linked,
so this distinction does not apply. _KERNEL can however
be used to control the visibility of the internals of the stack,
so depending on what features your application uses, it may or may
not be necessary.</PARA>
<PARA>The include file <filename>network.h</filename> undefines _KERNEL
unconditionally, to provide an application-like compilation environment.
If you were writing code which, for example,
enumerates the stack&rsquo;s internal
structures, that is a kernel-like compilation environment, so you
would need to define _KERNEL (in addition to __ECOS)
and avoid including <filename>network.h</filename>.</PARA>
</SECT1>
<SECT1 id="tcpip-openbsd-enhanced-select">
<TITLE>Enhanced Select()</TITLE>
<PARA>The network stack supports an extension to the standard select
semantics which allows all threads that are waiting to be restarted
even if the select conditions are not satisfied.</PARA>
<PARA>The standard select() API: </PARA>
<PROGRAMLISTING>int
<function>select</function>(int nfd,
fd_set &ast;in, fd_set &ast;out, fd_set &ast;ex,
struct timeval &ast;tv); </PROGRAMLISTING>
<PARA>does not support the restart.</PARA>
<PARA>The additional API: </PARA>
<PROGRAMLISTING>int
<function>cyg_select_with_abort</function>(int nfd,
fd_set &ast;in, fd_set &ast;out, fd_set &ast;ex,
struct timeval &ast;tv)
</PROGRAMLISTING>
<PARA>behaves exactly as select() with the additional feature that
a call to</PARA>
<PROGRAMLISTING>
void <function>cyg_select_abort</function>(void)
</PROGRAMLISTING>
<PARA>will cause all threads waiting in any
<function>cyg_select_with_abort()</function> call
to cease waiting and continue execution.</PARA>
</SECT1>
</CHAPTER>
</PART>
openbsd.sgml Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: socket.html =================================================================== --- socket.html (nonexistent) +++ socket.html (revision 1765) @@ -0,0 +1,117 @@ + + +








    +NAME








    +       socket - create an endpoint for communication








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int socket(int domain, int type, int protocol);








    +








    +DESCRIPTION








    +       Socket creates an endpoint for communication and returns a








    +       descriptor.








    +








    +       The domain parameter  specifies  a  communications  domain








    +       within  which  communication will take place; this selects








    +       the protocol family which should be used.  These  families








    +       are  defined  in <network.h>.  The currently understood








    +       formats include:








    +








    +       PF_INET








    +              IPv4 Internet protocols; see ip(4)








    +








    +       The socket has the indicated  type,  which  specifies  the








    +       semantics of communication.  Currently defined types are:








    +








    +       SOCK_STREAM








    +              Provides  sequenced,  reliable, two-way connection-








    +              based byte streams.  An out-of-band data  transmis-








    +              sion mechanism may be supported.








    +








    +       SOCK_DGRAM








    +              Supports datagrams (connectionless, unreliable mes-








    +              sages of a fixed maximum length).








    +








    +       SOCK_SEQPACKET








    +              Provides a sequenced, reliable, two-way connection-








    +              based data transmission path for datagrams of fixed








    +              maximum length; a consumer is required to  read  an








    +              entire packet with each read system call.








    +








    +       SOCK_RAW








    +              Provides raw network protocol access.








    +








    +       The  protocol  specifies  a particular protocol to be used








    +       with the socket.  Normally only a single  protocol  exists








    +       to  support a particular socket type within a given proto-








    +       col family.  However, it is possible that  many  protocols








    +       may  exist,  in  which  case a particular protocol must be








    +       specified in this manner.  The protocol number to  use  is








    +       particular to the "communication domain" in which communi-








    +       cation is to take place; see  protocols(5).   See  getpro-








    +       toent(3)  on  how to map protocol name strings to protocol








    +       numbers.








    +








    +       Sockets of type SOCK_STREAM are full-duplex byte  streams,








    +       similar  to pipes.  A stream socket must be in a connected








    +       state before any data may be sent or received  on  it.   A








    +       connection  to another socket is created with a connect(2)








    +       call.  Once  connected,  data  may  be  transferred  using








    +       read(2)  and write(2) calls or some variant of the send(2)








    +       and recv(2) calls.  When a session has  been  completed  a








    +       close(2)  may  be performed.  Out-of-band data may also be








    +       transmitted  as  described  in  send(2)  and  received  as








    +       described in recv(2).








    +








    +       The communications protocols which implement a SOCK_STREAM








    +       ensure that data is not lost or duplicated.  If a piece of








    +       data  for  which the peer protocol has buffer space cannot








    +       be successfully transmitted within a reasonable length  of








    +       time,  then the connection is considered When SO_KEEPALIVE








    +       is enabled on the socket the protocol checks in  a  proto-








    +       col-specific  manner  if  the other end is still alive.








    +








    +       SOCK_DGRAM and SOCK_RAW sockets allow sending of datagrams








    +       to correspondents named in send(2) calls.   Datagrams  are








    +       generally  received  with  recvfrom(2),  which returns the








    +       next datagram with its return address.








    +








    +       When  the network signals an error condition to the proto-








    +       col module (e.g.  using a ICMP message for IP) the pending








    +       error  flag  is set for the socket.  The next operation on








    +       this socket will return the  error  code  of  the  pending








    +       error.  For some protocols it is possible to enable a per-








    +       socket error queue to retrieve detailed information  about








    +       the error; see IP_RECVERR in ip(4).








    +








    +       The  operation  of  sockets  is controlled by socket level








    +       options.  These options  are  defined  in  .








    +       Setsockopt(2)  and  getsockopt(2)  are used to set and get








    +       options, respectively.








    +








    +RETURN VALUES








    +       -1 is returned if an error occurs;  otherwise  the  return








    +       value is a descriptor referencing the socket.








    +








    +ERRORS








    +       EPROTONOSUPPORT








    +               The protocol type or the specified protocol is not








    +               supported within this domain.








    +








    +       EMFILE  There are too many open files.








    +








    +       EACCES  Permission  to  create  a  socket of the specified








    +               type and/or protocol is denied.








    +








    +       ENOBUFS or ENOMEM








    +               Insufficient memory is available.  The socket can-








    +               not  be  created  until  sufficient  resources are








    +               freed.








    +








    +       EINVAL  Unknown protocol, or protocol  family  not  avail-








    +               able.








    +
+ + Index: inet_addr.html =================================================================== --- inet_addr.html (nonexistent) +++ inet_addr.html (revision 1765) @@ -0,0 +1,40 @@ + + +








    +NAME








    +       inet_aton, inet_addr, inet_ntoa -  Internet  address








    +       manipulation routines








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int inet_aton(const char *cp, struct in_addr *inp);








    +








    +       unsigned long int inet_addr(const char *cp);








    +








    +       char *inet_ntoa(struct in_addr in);








    +








    +DESCRIPTION








    +       inet_aton() converts the Internet host address cp from the








    +       standard numbers-and-dots notation into  binary  data  and








    +       stores  it  in the structure that inp points to. inet_aton








    +       returns nonzero if the address is valid, zero if not.








    +








    +       The  inet_addr()  function  converts  the  Internet   host








    +       address cp from numbers-and-dots notation into binary data








    +       in  network  byte  order.   If  the  input   is   invalid,








    +       INADDR_NONE (usually -1) is returned.  This is an obsolete








    +       interface to inet_aton, described immediately above; it is








    +       obsolete  because -1 is a valid address (255.255.255.255),








    +       and inet_aton provides a cleaner  way  to  indicate  error








    +       return.








    +








    +       The   inet_ntoa()  function  converts  the  Internet  host








    +       address in given in network byte  order  to  a  string  in








    +       standard   numbers-and-dots   notation.    The  string  is








    +       returned in a statically allocated  buffer,  which  subse­








    +       quent calls will overwrite.








    +








    +
+ + Index: write.html =================================================================== --- write.html (nonexistent) +++ write.html (revision 1765) @@ -0,0 +1,42 @@ + + +








    +NAME








    +       write - write to a file descriptor








    +








    +SYNOPSIS








    +       ssize_t write(int fd, const void *buf, size_t count);








    +








    +DESCRIPTION








    +       write  writes  up to count bytes to the file referenced by








    +       the file descriptor fd from the buffer  starting  at  buf.








    +








    +RETURN VALUE








    +       On success, the number of bytes written are returned (zero








    +       indicates nothing was written).  On error, -1 is returned,








    +       and  errno is set appropriately.








    +








    +ERRORS








    +       EBADF  fd is not a valid file descriptor or  is  not  open








    +              for writing.








    +








    +       EINVAL fd is attached to an object which is unsuitable for








    +              writing.








    +








    +       EPIPE  fd is connected to a socket  whose  reading








    +              end  is closed.








    +








    +       EAGAIN Non-blocking I/O has been selected using O_NONBLOCK








    +              and  there  was  no room in the pipe or socket con­








    +              nected to fd to write the data immediately.








    +








    +       EINTR  The call was interrupted before  any








    +              data was written.








    +








    +       ENOSPC The  device  containing  the file referred to by fd








    +              has no room for the data.








    +








    +       EIO    A low-level I/O error occurred.








    +
+ + Index: getpeername.html =================================================================== --- getpeername.html (nonexistent) +++ getpeername.html (revision 1765) @@ -0,0 +1,40 @@ + + +








    +NAME








    +       getpeername - get name of connected peer








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int  getpeername(int  s,  struct sockaddr *name, socklen_t








    +       *namelen);








    +








    +DESCRIPTION








    +       Getpeername returns the name  of  the  peer  connected  to








    +       socket  s.  The namelen parameter should be initialized to








    +       indicate the amount of  space  pointed  to  by  name.   On








    +       return  it  contains  the actual size of the name returned








    +       (in bytes).  The name is truncated if the buffer  provided








    +       is too small.








    +








    +RETURN VALUE








    +       On  success,  zero is returned.  On error, -1 is returned,








    +       and errno is set appropriately.








    +








    +ERRORS








    +       EBADF   The argument s is not a valid descriptor.








    +








    +       ENOTSOCK








    +               The argument s is a file, not a socket.








    +








    +       ENOTCONN








    +               The socket is not connected.








    +








    +       ENOBUFS Insufficient resources were available in the  sys-








    +               tem to perform the operation.








    +








    +








    +
+ + Index: bridge.html =================================================================== --- bridge.html (nonexistent) +++ bridge.html (revision 1765) @@ -0,0 +1,319 @@ + + +








    +NAME








    +     bridge - Ethernet bridge interface








    +








    +SYNOPSIS








    +     pseudo-device bridge 2








    +








    +DESCRIPTION








    +     The bridge device creates a logical link between two or more Ethernet in








    +     terfaces.  This link between the interfaces selectively forwards frames








    +     from each interface on the bridge to every other interface on the bridge.








    +     A bridge can serve several services, including, isolation of traffic be








    +     tween sets of machines so that traffic local to one set of machines is








    +     not available on the wire of another set of machines, and it can act as a








    +     transparent filter for ip(4) datagrams.








    +








    +     The bridges provided by this interface are learning bridges with IP fil








    +     tering, see ipf(4).  In general a bridge works like a hub, forwarding








    +     traffic from one interface to another.  It differs from a hub in that it








    +     will "learn" which machines are on each of its attached segments by ac








    +     tively listening to incoming traffic and examining the headers of each








    +     frame.  A table is built containing the MAC address and segment to which








    +     the MAC address is attached.  This allows a bridge to be more selective








    +     about what it forwards, which can be used to reduce traffic on a set of








    +     segments and also to provide an IP firewall without changing the topology








    +     of the network.








    +








    +     The algorithm works as follows by default, but can be modified via








    +     ioctl(2) or the utility brconfig(8).  When a frame comes in, the origin








    +     segment and the source address are recorded.  If the bridge has no knowl








    +     edge about where the destination is to be found, the bridge will forward








    +     the frame to all attached segments.  If the destination is known to be on








    +     a different segment from its origin, the bridge will forward the packet








    +     only to the destination segment.  If the destination is on the same seg








    +     ment as the origin segment, the bridge will drop the packet because the








    +     receiver has already had a chance to see the frame.  Before forwarding a








    +     frame, the bridge will check to see if the packet contains an ip(4) data








    +     gram; if so, the datagram is run through the ipf(4) interface so that it








    +     can be filtered.  Only the ipf(4) input rules for the source interface








    +     are checked with the datagram; output rules have no effect.








    +








    +IOCTLS








    +     A bridge interface responds to all of the ioctl(2) calls specific to oth








    +     er interfaces listed in netintro(4).  The following ioctl(2) calls are








    +     specific to bridge devices.  They are defined in .








    +








    +     SIOCBRDGIFS      (struct ifbifconf) Retrieve member interface list from a








    +                      bridge.  This request takes an ifbifconf structure (see








    +                      below) as a value-result parameter.  The ifbic_len field








    +                      should be initially set to the size of the buffer point








    +                      ed to by ifbic_buf. On return it will contain the








    +                      length, in bytes, of the configuration list.  Alterna








    +                      tively, if the ifbic_len passed in is set to 0,








    +                      SIOCBRDGIFS will set ifbic_len to the size that








    +                      ifbic_buf needs to be to fit the entire configuration








    +                      list, and will not fill in the other parameters.  This








    +                      is useful for determining the exact size that ifbic_buf








    +                      needs to be in advance.








    +








    +                      The argument structure is defined as follows:








    +








    +                            struct ifbreq {








    +                                    char ifbr_name[IFNAMSIZ];    /* brdg nam */








    +                                    char ifbr_ifsname[IFNAMSIZ]; /* if name */








    +                                    u_int32_t ifbr_ifsflags;     /* if flags */








    +                            };








    +








    +                            #define IFBIF_LEARNING  0x1 /* learns addrs */








    +                            #define IFBIF_DISCOVER  0x2 /* gets fwd'd pkts */








    +








    +                            struct ifbifconf {








    +                                    char ifbic_name[IFNAMSIZ]; /* brdg name */








    +                                    u_int32_t       ifbic_len; /* buf size */








    +                                    union {








    +                                            caddr_t ifbicu_buf; /* buffer */








    +                                            struct  ifbreq *ifbicu_req;








    +                                    } ifbic_ifbicu;








    +                            #define ifbic_buf       ifbic_ifbicu.ifbicu_buf








    +                            #define ifbic_req       ifbic_ifbicu.ifbicu_req








    +                            };








    +








    +     SIOCBRDGADD      (struct ifbreq) Add the interface named in ifbr_ifsname








    +                      to the bridge named in ifbr_name.








    +








    +     SIOCBRDGDEL      (struct ifbreq) Delete the interface named in








    +                      ifbr_ifsname from the bridge named in ifbr_name.








    +








    +     SIOCBRDGSIFFLGS  (struct ifbreq) Set the bridge member interface flags








    +                      for the interface named in ifbr_ifsname attached to the








    +                      bridge ifbr_name. If the flag IFBIF_LEARNING is set on








    +                      an interface, source addresses from frames received on








    +                      the interface are recorded in the address cache.  If the








    +                      flag IFBIF_DISCOVER is set, the interface will receive








    +                      packets destined for unknown destinations, otherwise a








    +                      frame that has a destination not found in the address








    +                      cache is not forwarded to this interface.  The default








    +                      for newly added interfaces has both flags set.  If the








    +                      flag IFBIF_BLOCKNONIP is set, packets that are one of








    +                      ip(4),  ip6(4),  arp(4),  or Reverse ARP, will not be








    +                      bridged from and to the interface.








    +








    +     SIOCBRDGGIFFLGS  Retrieve the bridge member interface flags for the in








    +                      terface named in ifbr_ifsname attached to the bridge








    +                      ifbr_name.








    +








    +     SIOCBRDGRTS      (struct ifbaconf) Retrieve the address cache of the








    +                      bridge named in ifbac_name. This request takes an








    +                      ifbaconf structure (see below) as a value result parame








    +                      ter.  The ifbac_len field should be initially set to the








    +                      size of the buffer pointed to by ifbac_buf. On return,








    +                      it will contain the length, in bytes, of the configura








    +                      tion list.  Alternatively, if the ifbac_len passed in is








    +                      set to 0, SIOCBRDGRTS will set it to the size that








    +                      ifbac_buf needs to be to fit the entire configuration








    +                      list and not fill in the other parameters.  As with








    +                      SIOCBRDGIFS, this is useful for determining the exact








    +                      size that ifbac_buf needs to be in advance.








    +








    +                      The argument structure is defined as follows:








    +








    +                            struct ifbareq {








    +                                    char ifba_name[IFNAMSIZ];   /* brdg nam */








    +                                    char ifba_ifsname[IFNAMSIZ];/* dest ifs */








    +                                    u_int8_t ifba_age;          /* addr age */








    +                                    u_int8_t ifba_flags;        /* addr flag */








    +                                    struct ether_addr ifba_dst; /* dst addr */








    +                            };








    +








    +                            #define IFBAF_TYPEMASK 0x03  /* addr type mask */








    +                            #define IFBAF_DYNAMIC  0x00  /* dynamic addr */








    +                            #define IFBAF_STATIC   0x01  /* static address */








    +








    +                            struct ifbaconf {








    +                                    char ifbac_name[IFNAMSIZ]; /* brdg name */








    +                                    u_int32_t ifbac_len;       /* buf size */








    +                                    union {








    +                                            caddr_t ifbacu_buf;     /* buf */








    +                                            struct ifbareq *ifbacu_req;








    +                                    } ifbac_ifbacu;








    +                            #define ifbac_buf       ifbac_ifbacu.ifbacu_buf








    +                            #define ifbac_req       ifbac_ifbacu.ifbacu_req








    +                            };








    +                      Address cache entries with the type set to IFBAF_DYNAMIC








    +                      in ifba_flags are entries learned by the bridge.  En








    +                      tries with the type set to IFBAF_STATIC are manually








    +                      added entries.








    +








    +     SIOCBRDGSADDR    (struct ifbareq) Add an entry, manually, to the address








    +                      cache for the bridge named in ifba_name. The address and








    +                      its associated interface and flags are set in the








    +                      ifba_dst, ifba_ifsname, ifba_flags fields, respectively.








    +








    +     SIOCBRDGDADDR    (struct ifbareq) Delete an entry from the address cache








    +                      of the bridge named in ifba_name. Entries are deleted








    +                      strictly based on the address field ifba_dst.








    +








    +     SIOCBRDGSCACHE   (struct ifbcachereq) Set the maximum address cache size








    +                      for the bridge named in ifbc_name to ifbc_size entries.








    +








    +                      The argument structure is as follows:








    +








    +                            struct ifbcachereq {








    +                                    char ifbc_name[IFNAMSIZ]; /* bridge */








    +                                    u_int32_t ifbc_size;      /* size */








    +                            };








    +








    +     SIOCBRDGGCACHE   (struct ifbcachereq) Retrieve the maximum size of the








    +                      address cache for the bridge ifbc_name.








    +








    +     SIOCBRDGSTO      (struct ifbcachetoreq) Set the time, in seconds, that








    +                      addresses which have not been seen on the network








    +                      (transmitted a packet) remain in the cache.  If the time








    +                      is set to zero, no aging is performed on the address








    +                      cache.  The argument structure is as follows:








    +








    +                            struct ifbcachetoreq {








    +                                    char ifbct_name[IFNAMSIZ]; /* bridge */








    +                                    u_int32_t ifbct_time;      /* time */








    +                            };








    +








    +     SIOCBRDGGTO      (struct ifbcachetoreq) Retrieve the address cache expi








    +                      ration time (see above).








    +








    +     SIOCBRDGFLUSH    (struct ifbreq) Flush addresses from the cache.








    +                      ifbr_name contains the name of the bridge device, and








    +                      ifbr_ifsflags should be set to IFBF_FLUSHALL to flush








    +                      all addresses from the cache or IFBF_FLUSHDYN to flush








    +                      only the dynamically learned addresses from the cache.








    +








    +     SIOCBRDGARL      (struct ifbrlreq) Add a filtering rule to the bridge








    +                      named in ifbr_name on the interface named in








    +                      ifbr_ifsname. The argument structure is as follows:








    +








    +                            struct ifbrlreq {








    +                                    char ifbr_name[IFNAMSIZ];    /* bridge */








    +                                    char ifbr_ifsname[IFNAMSIZ]; /* ifs */








    +                                    u_int8_t ifbr_action;        /* handling */








    +                                    u_int8_t ifbr_flags;         /* flags */








    +                                    struct ether_addr ifbr_src;  /* src mac */








    +                                    struct ether_addr ifbr_dst;  /* dst mac */








    +                            };








    +                            #define BRL_ACTION_BLOCK        0x01








    +                            #define BRL_ACTION_PASS         0x02








    +                            #define BRL_FLAG_IN             0x08








    +                            #define BRL_FLAG_OUT            0x04








    +                            #define BRL_FLAG_SRCVALID       0x02








    +                            #define BRL_FLAG_DSTVALID       0x01








    +








    +                      Rules are applied in the order in which they were added








    +                      to the bridge, and the first matching rule's action pa








    +                      rameter determines the fate of the packet.  The








    +                      ifbr_action parameter specifies whether a frame matching








    +                      the rule is to be blocked or passed.








    +








    +                      If the BRL_FLAG_IN bit is set in ifbr_flags, then the








    +                      rule applies to frames received by the interface.  If








    +                      the BRL_FLAG_OUT bit is set, then the rule applies to








    +                      frame transmitted by the interface.  At least one of








    +                      BRL_FLAG_IN or BRL_FLAG_OUT must be set.








    +








    +                      The source ethernet address in ifbr_src is checked if








    +                      the BRL_FLAG_SRCVALID bit is set in ifbr_flags. The des








    +                      tination address in ifbr_dst is check if the








    +                      BRL_FLAG_DSTVALID bit is set.  If neither bit is set,








    +                      the rule is matches all frames.








    +








    +     SIOCBRDGFRL      (struct ifbrlreq) Remove all filtering rules from a








    +                      bridge interface member.  ifbr_name contains the name of








    +                      the bridge device, and ifbr_ifsname contains the name of








    +                      the bridge member interface.








    +








    +     SIOCBRDGGRL      (struct ifbrlconf) Retrieve all of the rules from the








    +                      bridge, ifbrl_name, for the member interface,








    +                      ifbrl_ifsname.








    +








    +                      This request takes an ifbrlconf structure (see below) as








    +                      a value result parameter.  The ifbrl_len field should be








    +                      initially set to the size of the buffer pointed to by








    +                      ifbrl_buf. On return, it will contain the length, in








    +                      bytes, of the configuration list.  Alternatively, if the








    +                      ifbrl_len passed in is set to 0, SIOCBRDGGRL will set it








    +                      to the size that ifbrl_buf needs to be to fit the entire








    +                      configuration list and not fill in the other parameters.








    +                      As with SIOCBRDGIFS, this is useful for determining the








    +                      exact size that ifbrl_buf needs to be in advance.








    +








    +                      The argument structure is defined as follows:








    +








    +                            struct ifbrlconf {








    +                                    char ifbrl_name[IFNAMSIZ];   /* brdg nam */








    +                                    char ifbrl_ifsname[IFNAMSIZ];/* ifs name */








    +                                    u_int32_t ifbr_len;         /* buf len */








    +                                    union {








    +                                            caddr_t ifbrlu_buf;








    +                                            struct ifbrlreq *ifbrlu_req;








    +                                    } ifrl_ifbrlu;








    +                            #define ifbrl_buf ifbrl_ifbrlu.ifbrlu_buf








    +                            #define ifbrl_req ifbrl_ifbrlu.ifbrlu_req








    +                            };








    +








    +








    +ERRORS








    +     If the ioctl(2) call fails, errno(2) is set to one of the following val








    +     ues:








    +








    +     [ENOENT]      For an add request, this means that the named interface is








    +                   not configured into the system.  For delete operation, it








    +                   means that the named interface is not a member of the








    +                   bridge.  For a address cache deletion, the address was not








    +                   found in the table.








    +








    +     [ENOMEM]      Memory could not be allocated for an interface or cache en








    +                   try to be added to the bridge.








    +








    +     [EEXIST]      The named interface is already a member of the bridge.








    +








    +     [EBUSY]       The named interface is already a member of another bridge.








    +








    +     [EINVAL]      The named interface is not an Ethernet interface or an in








    +                   valid ioctl was performed on the bridge.








    +








    +     [ENETDOWN]    Address cache operation (flush, add, delete) on a bridge








    +                   that is in the down state.








    +








    +     [EPERM]       Super-user privilege is required to add and delete inter








    +                   faces to and from bridges and to set the bridge interface








    +                   flags.








    +








    +     [EFAULT]      The buffer used in a SIOCBRDGIFS or SIOCBRDGRTS request








    +








    +                   points outside of the process's allocated address space.








    +








    +     [ESRCH]       No such member interface in the bridge.








    +








    +SEE ALSO








    +     errno(2),  ioctl(2),  ip(4),  ipf(4),  netintro(4),  bridgename.if(5),








    +     brconfig(8)








    +








    +HISTORY








    +     The brconfig(8) command and the bridge(4) kernel interface first appeared








    +     in








    +








    +AUTHOR








    +     The brconfig(8) command and the bridge(4) kernel interface were written








    +     by Jason L. Wright  as part of an undergraduate inde








    +     pendent study at the University of North Carolina at Greensboro.








    +








    +BUGS








    +     There is currently no loop detection.  Care must be taken to make sure








    +     that loops are not created when a bridge is brought up.








    +








    +     Only ipf(4) input rules are checked with incoming packet; there is no








    +     easy way to handle output rules.








    +








    +
+ + Index: sendto.html =================================================================== --- sendto.html (nonexistent) +++ sendto.html (revision 1765) @@ -0,0 +1,106 @@ + + +








    +NAME








    +       sendto - send a message from a socket








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int sendto(int s, const void *msg, int len,  unsigned  int








    +       flags, const struct sockaddr *to, int tolen);








    +








    +DESCRIPTION








    +       Sendto is used to transmit  a  message








    +       to  another socket.








    +








    +       The address of the target is given by to with tolen speci­








    +       fying its size.  The length of the  message  is  given  by








    +       len.   If  the  message  is  too  long  to pass atomically








    +       through the underlying protocol,  the  error  EMSGSIZE  is








    +       returned, and the message is not transmitted.








    +








    +       No indication of failure to deliver is implicit in a send.








    +       Locally detected errors are indicated by a return value of








    +       -1.








    +








    +       When  the message does not fit into the send buffer of the








    +       socket, send normally blocks, unless the socket  has  been








    +       placed  in non-blocking I/O mode.  In non-blocking mode it








    +       would return EAGAIN in this case.  The select(2) call  may








    +       be  used  to  determine  when  it is possible to send more








    +       data.








    +








    +       The flags parameter may include one or more of the follow­








    +       ing:








    +








    +              #define MSG_OOB           0x1     /* process out-of-band data */








    +              #define MSG_DONTROUTE     0x4     /* bypass routing, use direct interface */








    +              #define MSG_DONTWAIT      0x40    /* don't block */








    +              #define MSG_NOSIGNAL      0x2000  /* don't raise SIGPIPE */








    +








    +       MSG_OOB








    +              Sends out-of-band data on sockets that support this








    +              notion (e.g.  SOCK_STREAM); the underlying protocol








    +              must also support out-of-band data.








    +








    +       MSG_DONTROUTE








    +              Bypasses  the  usual routing table lookup and sends








    +              the packet directly to the interface  described  by








    +              the  destination address. This is usually used only








    +              by diagnostic or routing programs.








    +








    +       MSG_DONTWAIT








    +              Enables non-blocking operation;  if  the  operation








    +              would block, EAGAIN is returned.








    +








    +       MSG_NOSIGNAL








    +              Requests  not  to  send SIGPIPE on errors on stream








    +              oriented sockets when the other end breaks the con­








    +              nection. The EPIPE error is still returned.








    +








    +       See recv(2) for a description of the msghdr structure. You








    +       may send control information  using  the  msg_control  and








    +       msg_controllen  members. The maximum control buffer length








    +       the kernel can process is  limited  by  the  net.core.opt­








    +       mem_max sysctl; see socket(4).








    +








    +RETURN VALUES








    +       The  calls  return the number of characters sent, or -1 if








    +       an error occurred.








    +








    +ERRORS








    +       These are some standard errors  generated  by  the  socket








    +       layer.  Additional  errors  may  be generated and returned








    +       from the underlying protocol modules; see their respective








    +       manual pages.








    +








    +       EBADF   An invalid descriptor was specified.








    +








    +       ENOTSOCK








    +               The argument s is not a socket.








    +








    +       EMSGSIZE








    +               The socket requires that message  be  sent  atomi­








    +               cally, and the size of the message to be sent made








    +               this impossible.








    +








    +       EAGAIN  The  socket  is  marked   non-blocking   and   the








    +               requested operation would block.








    +








    +       ENOBUFS The system was unable to allocate an internal mem­








    +               ory block.  The operation may succeed when buffers








    +               become available.








    +








    +       EINTR   A signal occurred.








    +








    +       ENOMEM  No memory available.








    +








    +       EINVAL  Invalid argument passed.








    +








    +       EPIPE   The  local  end has been shut down on a connection








    +               oriented socket.  In this case  the  process  will








    +               also receive a SIGPIPE unless MSG_NOSIGNAL is set.








    +
+ + Index: setsockopt.html =================================================================== --- setsockopt.html (nonexistent) +++ setsockopt.html (revision 1765) @@ -0,0 +1,72 @@ + + +








    +NAME








    +       getsockopt, setsockopt - get and set options on sockets








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int  getsockopt(int  s, int level, int optname, void *opt­








    +       val, socklen_t *optlen);








    +








    +       int setsockopt(int s, int level, int optname,  const  void








    +       *optval, socklen_t optlen);








    +








    +DESCRIPTION








    +       Getsockopt  and  setsockopt manipulate the options associ­








    +       ated with a socket.  Options may exist at multiple  proto­








    +       col  levels;  they  are  always  present  at the uppermost








    +       socket level.








    +








    +       When manipulating socket options the level  at  which  the








    +       option  resides  and the name of the option must be speci­








    +       fied.  To manipulate options at the socket level, level is








    +       specified  as  SOL_SOCKET.   To  manipulate options at any








    +       other level the protocol number of the appropriate  proto­








    +       col  controlling  the option is supplied.  For example, to








    +       indicate that an option is to be interpreted  by  the  TCP








    +       protocol,  level  should  be set to the protocol number of








    +       TCP; see getprotoent(3).








    +








    +       The parameters optval and optlen are used to access option








    +       values  for  setsockopt.   For  getsockopt they identify a








    +       buffer in which the value for the requested option(s)  are








    +       to  be returned.  For getsockopt, optlen is a value-result








    +       parameter, initially containing the  size  of  the  buffer








    +       pointed  to  by optval, and modified on return to indicate








    +       the actual size of the value returned.  If no option value








    +       is to be supplied or returned, optval may be NULL.








    +








    +       Optname and any specified options are passed uninterpreted








    +       to the appropriate  protocol  module  for  interpretation.








    +       The  include  file <network.h> contains definitions for








    +       socket level options, described below.  Options  at  other








    +       protocol  levels  vary  in  format  and  name; consult the








    +       appropriate entries in section 4 of the manual.








    +








    +       Most socket-level options utilize  an  int  parameter  for








    +       optval.   For setsockopt, the parameter should be non-zero








    +       to enable a boolean option, or zero if the option is to be








    +       disabled.








    +








    +       For  a  description  of  the  available socket options see








    +       socket(7) and the appropriate protocol man pages.








    +








    +RETURN VALUE








    +       On success, zero is returned.  On error, -1  is  returned,








    +       and errno is set appropriately.








    +








    +ERRORS








    +       EBADF   The argument s is not a valid descriptor.








    +








    +       ENOTSOCK








    +               The argument s is a file, not a socket.








    +








    +       ENOPROTOOPT








    +               The option is unknown at the level indicated.








    +








    +








    +
+ + Index: inet_addr.man =================================================================== --- inet_addr.man (nonexistent) +++ inet_addr.man (revision 1765) @@ -0,0 +1,34 @@ +NAME + inet_aton, inet_addr, inet_ntoa - Internet address + manipulation routines + +SYNOPSIS + #include + + int inet_aton(const char *cp, struct in_addr *inp); + + unsigned long int inet_addr(const char *cp); + + char *inet_ntoa(struct in_addr in); + +DESCRIPTION + inet_aton() converts the Internet host address cp from the + standard numbers-and-dots notation into binary data and + stores it in the structure that inp points to. inet_aton + returns nonzero if the address is valid, zero if not. + + The inet_addr() function converts the Internet host + address cp from numbers-and-dots notation into binary data + in network byte order. If the input is invalid, + INADDR_NONE (usually -1) is returned. This is an obsolete + interface to inet_aton, described immediately above; it is + obsolete because -1 is a valid address (255.255.255.255), + and inet_aton provides a cleaner way to indicate error + return. + + The inet_ntoa() function converts the Internet host + address in given in network byte order to a string in + standard numbers-and-dots notation. The string is + returned in a statically allocated buffer, which subse­ + quent calls will overwrite. + Index: getproto.html =================================================================== --- getproto.html (nonexistent) +++ getproto.html (revision 1765) @@ -0,0 +1,48 @@ + + +








    +NAME








    +       getprotobyname,  getprotobynumber - get protocol entry








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       struct protoent *getprotobyname(const char *name);








    +








    +       struct protoent *getprotobynumber(int proto);








    +








    +DESCRIPTION








    +       The getprotobyname() function returns a protoent structure








    +       for the line from /etc/protocols that matches the protocol








    +       name name.








    +








    +       The  getprotobynumber() function returns a protoent struc­








    +       ture for the line that matches the protocol number number.








    +








    +       The protoent structure is defined in  as follows:








    +








    +              struct protoent {








    +                      char    *p_name;        /* official protocol name */








    +                      char    **p_aliases;    /* alias list */








    +                      int     p_proto;        /* protocol number */








    +              }








    +








    +       The members of the protoent structure are:








    +








    +       p_name The official name of the protocol.








    +








    +       p_aliases








    +              A zero terminated list of alternative names for the








    +              protocol.








    +       p_proto








    +              The protocol number.








    +








    +RETURN VALUE








    +       The getprotobyname() and getprotobynumber()








    +       functions return the protoent structure, or a NULL pointer








    +       if an error occurs.








    +








    +








    +
+ + Index: tcpip_config.html =================================================================== --- tcpip_config.html (nonexistent) +++ tcpip_config.html (revision 1765) @@ -0,0 +1,22 @@ + + + + + + + + +
+

+eCos TCP/IP Package Configuration

+ Follow these steps to enable networking: +
% ecosconfig add CYGPKG_NET +
% ecosconfig add CYGPKG_NET_ETH_DRIVERS
+For the Motorola PowerPC (MBX/860) board: +
% ecosconfig add CYGPKG_NET_QUICC_ETH_DRIVERS
+For the Cirrus Logic EDB7xxx board: +
% ecosconfig add CYGPKG_NET_EDB7XXX_ETH_DRIVERS
+ +
  + + Index: listen.man =================================================================== --- listen.man (nonexistent) +++ listen.man (revision 1765) @@ -0,0 +1,36 @@ +NAME + listen - listen for connections on a socket + +SYNOPSIS + #include + + int listen(int s, int backlog); + +DESCRIPTION + To accept connections, a socket is first created with + socket(2), a willingness to accept incoming connections + and a queue limit for incoming connections are specified + with listen, and then the connections are accepted with + accept(2). The listen call applies only to sockets of + type SOCK_STREAM or SOCK_SEQPACKET. + + The backlog parameter defines the maximum length the queue + of pending connections may grow to. If a connection + request arrives with the queue full the client may receive + an error with an indication of ECONNREFUSED or, if the + underlying protocol supports retransmission, the request + may be ignored so that retries may succeed. + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF The argument s is not a valid descriptor. + + ENOTSOCK + The argument s is not a socket. + + EOPNOTSUPP + The socket is not of a type that supports the lis- + ten operation. Index: getsockname.man =================================================================== --- getsockname.man (nonexistent) +++ getsockname.man (revision 1765) @@ -0,0 +1,31 @@ +NAME + getsockname - get socket name + +SYNOPSIS + #include + + int getsockname(int s , struct sockaddr * name , + socklen_t * namelen ) + +DESCRIPTION + Getsockname returns the current name for the specified + socket. The namelen parameter should be initialized to + indicate the amount of space pointed to by name. On + return it contains the actual size of the name returned + (in bytes). + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. A 0 is returned if the + call succeeds, -1 if it fails. + +ERRORS + EBADF The argument s is not a valid descriptor. + + ENOTSOCK + The argument s is a file, not a socket. + + ENOBUFS Insufficient resources were available in the sys- + tem to perform the operation. + + Index: sample_program.html =================================================================== --- sample_program.html (nonexistent) +++ sample_program.html (revision 1765) @@ -0,0 +1,371 @@ + + + + + + + + +
+

+Sample Networking Program

+ +


This example is derived from the test program ".../net/tcpip/v1_3_1/tests/ping_test.c". +
  +

//========================================================================== +
// +
//      tests/ping_test.c +
// +
//      Simple test of PING +(ICMP) and networking support +
// +
//========================================================================== +
//####BSDCOPYRIGHTBEGIN#### +
// +
// ------------------------------------------- +
// +
// Portions of this software may have been derived +from OpenBSD or other sources, +
// and are covered by the appropriate copyright disclaimers +included herein. +
// +
// ------------------------------------------- +
// +
//####BSDCOPYRIGHTEND#### +
//========================================================================== +
//#####DESCRIPTIONBEGIN#### +
// +
// Author(s):    gthomas +
// Contributors: gthomas +
// Date:         +2000-01-10 +
// Purpose: +
// Description: +
// +
// +
//####DESCRIPTIONEND#### +
// +
//========================================================================== +

// PING test code +

#include <network.h>

+This single include directive is all that is required to pick up the networking +support, including complete configuration information. +
#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +
static char stack[STACK_SIZE]; +
static cyg_thread thread_data; +
static cyg_handle_t thread_handle; +

#define NUM_PINGS 16 +
#define MAX_PACKET 4096 +
static unsigned char pkt1[MAX_PACKET], pkt2[MAX_PACKET]; +

#define UNIQUEID 0x1234 +

void +
cyg_test_exit(void) +
{ +
    diag_printf("... Done\n"); +
    while (1) ; +
} +

void +
pexit(char *s) +
{ +
    perror(s); +
    cyg_test_exit(); +
} +

// Compute INET checksum +
int +
inet_cksum(u_short *addr, int len) +
{ +
    register int nleft = len; +
    register u_short *w = addr; +
    register u_short answer; +
    register u_int sum = 0; +
    u_short odd_byte = 0; +

    /* +
     *  Our algorithm is +simple, using a 32 bit accumulator (sum), +
     *  we add sequential +16 bit words to it, and at the end, fold +
     *  back all the carry +bits from the top 16 bits into the lower +
     *  16 bits. +
     */ +
    while( nleft > 1 )  { +
        sum += +*w++; +
        nleft +-= 2; +
    } +

    /* mop up an odd byte, if necessary +*/ +
    if( nleft == 1 ) { +
        *(u_char +*)(&odd_byte) = *(u_char *)w; +
        sum += +odd_byte; +
    } +

    /* +
     * add back carry outs from +top 16 bits to low 16 bits +
     */ +
    sum = (sum >> 16) + (sum & +0x0000ffff); /* add hi 16 to low 16 */ +
    sum += (sum >> 16);                     +/* add carry */ +
    answer = ~sum;                          +/* truncate to 16 bits */ +
    return (answer); +
} +

static int +
show_icmp(unsigned char *pkt, int len, +
          +struct sockaddr_in *from, struct sockaddr_in *to) +
{ +
    cyg_tick_count_t *tp, tv; +
    struct ip *ip; +
    struct icmp *icmp; +
    tv = cyg_current_time(); +
    ip = (struct ip *)pkt; +
    if ((len < sizeof(*ip)) || +ip->ip_v != IPVERSION) { +
        diag_printf("%s: +Short packet or not IP! - Len: %d, Version: %d\n", +
                    +inet_ntoa(from->sin_addr), len, ip->ip_v); +
        return +0; +
    } +
    icmp = (struct icmp *)(pkt + sizeof(*ip)); +
    len -= (sizeof(*ip) + 8); +
    tp = (cyg_tick_count_t *)&icmp->icmp_data; +
    if (icmp->icmp_type != ICMP_ECHOREPLY) +{ +
        diag_printf("%s: +Invalid ICMP - type: %d\n", +
                    +inet_ntoa(from->sin_addr), icmp->icmp_type); +
        return +0; +
    } +
    if (icmp->icmp_id != UNIQUEID) +{ +
        diag_printf("%s: +ICMP received for wrong id - sent: %x, recvd: %x\n", +
                    +inet_ntoa(from->sin_addr), UNIQUEID, icmp->icmp_id); +
    } +
    diag_printf("%d bytes from %s: +", len, inet_ntoa(from->sin_addr)); +
    diag_printf("icmp_seq=%d", icmp->icmp_seq); +
    diag_printf(", time=%dms\n", (int)(tv +- *tp)*10); +
    return (from->sin_addr.s_addr +== to->sin_addr.s_addr); +
} +

static void +
ping_host(int s, struct sockaddr_in *host) +
{ +
    struct icmp *icmp = (struct icmp +*)pkt1; +
    int icmp_len = 64; +
    int seq, ok_recv, bogus_recv; +
    cyg_tick_count_t *tp; +
    long *dp; +
    struct sockaddr_in from; +
    int i, len, fromlen; +

    ok_recv = 0; +
    bogus_recv = 0; +
    diag_printf("PING server %s\n", +inet_ntoa(host->sin_addr));

+This function takes an IP address and returns a string representation.  +Useful for printing the address. +
    for (seq = 0;  seq +< NUM_PINGS;  seq++) { +
        // Build +ICMP packet +
        icmp->icmp_type += ICMP_ECHO; +
        icmp->icmp_code += 0; +
        icmp->icmp_cksum += 0; +
        icmp->icmp_seq += seq; +
        icmp->icmp_id += 0x1234; +
        // Set +up ping data +
        tp = (cyg_tick_count_t +*)&icmp->icmp_data; +
        *tp++ += cyg_current_time(); +
        dp = (long +*)tp; +
        for (i += sizeof(*tp);  i < icmp_len;  i += sizeof(*dp)) { +
            +*dp++ = i; +
        } +
        // Add +checksum +
        icmp->icmp_cksum += inet_cksum( (u_short *)icmp, icmp_len+8); +
        // Send +it off +
        if +(sendto(s, icmp, icmp_len+8, 0, (struct sockaddr *)host, sizeof(*host)) +< 0) {
+This function sends a single packet, in this case via the ICMP protocol.  +The destination address is specified by the host argument. +
            +perror("sendto"); +
            +continue; +
        } +
        // Wait +for a response +
        fromlen += sizeof(from); +
        len += recvfrom(s, pkt2, sizeof(pkt2), 0, (struct sockaddr *)&from, &fromlen);
+This function waits for a packet to be sent to this interface.  Note: +this operation can fail if no packet is received with a given amount of +time (this timeout value is setup in the ping_test() routine below). +
        +if (len < 0) { +
            +perror("recvfrom"); +
        } else +{ +
            +if (show_icmp(pkt2, len, &from, host)) { +
                +ok_recv++; +
            +} else { +
                +bogus_recv++; +
            +} +
        } +
    } +
    diag_printf("Sent %d packets, +received %d OK, %d bad\n", NUM_PINGS, ok_recv, bogus_recv); +
} +

static void +
ping_test(struct bootp *bp) +
{ +
    struct protoent *p; +
    struct timeval tv; +
    struct sockaddr_in host; +
    int s; +

    if ((p = getprotobyname("icmp")) +== (struct protoent *)0) {

+This function gets information about the ICMP protocol.  This will +be used below to set up the "socket" (the handle to a network connection). +
        +perror("getprotobyname"); +
        return; +
    } +
    s = socket(AF_INET, SOCK_RAW, +p->p_proto);
+Create the socket "s".  A socket is an abstract object (sometimes +called a handle or endpoint).  Sockets come in many flavors, RAW sockets +are used for communicating with non-structured protocols.  DATAGRAM +sockets are used for packet oriented protocols, such as UDP.  STREAM +sockets are used for reliable, sequenced byte streams, such as those provided +by TCP. +
    if (s < 0) { +
        perror("socket"); +
        return; +
    } +
    tv.tv_sec = 1; +
    tv.tv_usec = 0; +
    setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, +&tv, sizeof(tv));
+This function instructs the system that receive operations (see ping_host() +above) must complete within 1 second or issue a timed out error condition. +
    // Set up host address +
    host.sin_family = AF_INET; +
    host.sin_addr = bp->bp_siaddr; +
    host.sin_port = 0; +
    ping_host(s, &host); +
    // Now try a bogus host +
    host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) ++ 32); +
    ping_host(s, &host); +
} +
 
+This function drives the test. +
void +
net_test(cyg_addrword_t p) +
{ +
    diag_printf("Start PING test\n"); +
    init_all_network_interfaces();
+This is a call to the network initialization code.  Note that it must +be executed from a thread context, thus we can't put it in the cyg_start() +function which follows.  The init_all_network_interfaces() +routine will cause the networking system to be initialized and any hardware +interfaces will be set up.  Using the system configuration information, +an interface can be started using either BOOTP,  or a predefined +configuration with static IP information.  It is also possible to +indicate that an interface will be configured by the user code, outside +of "init_all_network_interfaces()". +
  +
    #ifdef CYGHWR_NET_DRIVER_ETH0 +
       if (eth0_up) +{ +
        +ping_test(&eth0_bootp_data); +
    } +
#endif
+Notice that there is a BOOTP information structure kept about all hardware +interfaces.  This is created and initialized by the call to init_all_network_interfaces(), +unless manual configuration is selected.  This information can be +used by the application to learn things such as the local IP address, server +name, etc. +
#ifdef CYGHWR_NET_DRIVER_ETH1 +
    if (eth1_up) { +
        ping_test(&eth1_bootp_data); +
    } +
#endif
+Multiple hardware interfaces can be supported, depending on the hardware +platform.  If the platform provides a single ethernet device then  +CYGHWR_NET_DRIVER_ETH0 will be defined.  If there +is a second interface, then will CYGHWR_NET_DRIVER_ETH1 be +defined. +
    cyg_test_exit(); +
} +
 
+The following function creates an initial thread which runs the program.  +This could just as easily be done by naming the net_test() function +main(). +
void +
cyg_start(void) +
{ +
    // Create a main thread, so we +can run the scheduler and have time 'pass' +
    cyg_thread_create(10,                +// Priority - just a number +
                      +net_test,          // entry +
                      +0,                 +// entry parameter +
                      +"Network test",    // Name +
                      +&stack[0],         // Stack +
                      +STACK_SIZE,        // Size +
                      +&thread_handle,    // Handle +
                      +&thread_data       // Thread data structure +
            +); +
    cyg_thread_resume(thread_handle);  +// Start it +
    cyg_scheduler_start(); +
}
+ + + Index: getproto.man =================================================================== --- getproto.man (nonexistent) +++ getproto.man (revision 1765) @@ -0,0 +1,42 @@ +NAME + getprotobyname, getprotobynumber - get protocol entry + +SYNOPSIS + #include + + struct protoent *getprotobyname(const char *name); + + struct protoent *getprotobynumber(int proto); + +DESCRIPTION + The getprotobyname() function returns a protoent structure + for the line from /etc/protocols that matches the protocol + name name. + + The getprotobynumber() function returns a protoent struc­ + ture for the line that matches the protocol number number. + + The protoent structure is defined in as follows: + + struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol number */ + } + + The members of the protoent structure are: + + p_name The official name of the protocol. + + p_aliases + A zero terminated list of alternative names for the + protocol. + p_proto + The protocol number. + +RETURN VALUE + The getprotobyname() and getprotobynumber() + functions return the protoent structure, or a NULL pointer + if an error occurs. + + Index: ioctl.html =================================================================== --- ioctl.html (nonexistent) +++ ioctl.html (revision 1765) @@ -0,0 +1,46 @@ + + +








    +NAME








    +       ioctl - control device








    +








    +SYNOPSIS








    +       #include 








    +








    +       int ioctl(int d, int request, ...)








    +








    +       [The  "third"  argument  is  traditionally char *argp, and








    +       will be so named for this discussion.]








    +








    +DESCRIPTION








    +       The  ioctl  function  manipulates  the  underlying  device








    +       parameters  of special files.  In particular, many operat-








    +       ing characteristics of sockets and network devices








    +       may be controlled with ioctl requests.  The argu-








    +       ment d must be an open file descriptor.








    +








    +       An ioctl request has encoded in it whether the argument is








    +       an  in  parameter  or  out  parameter, and the size of the








    +       argument argp in bytes.  Macros and defines used in speci-








    +       fying   an   ioctl   request   are  located  in  the  file








    +       .








    +








    +RETURN VALUE








    +       On success, zero is returned.  On error, -1  is  returned,








    +       and errno is set appropriately.








    +








    +ERRORS








    +       EBADF  d is not a valid descriptor.








    +








    +       EFAULT argp references an inaccessible memory area.








    +








    +       ENOTTY d  is  not  associated  with  a  character  special








    +              device.








    +








    +       ENOTTY The specified request does not apply to the kind of








    +              object that the descriptor d references.








    +








    +       EINVAL Request or argp is not valid.








    +
+ + Index: shutdown.html =================================================================== --- shutdown.html (nonexistent) +++ shutdown.html (revision 1765) @@ -0,0 +1,33 @@ + + +








    +NAME








    +       shutdown - shut down part of a full-duplex connection








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int shutdown(int s, int how);








    +








    +DESCRIPTION








    +       The shutdown call causes all or part of a full-duplex con-








    +       nection on the socket associated with s to be  shut  down.








    +       If  how is 0, further receives will be disallowed.  If how








    +       is 1, further sends will be disallowed.  If how is 2, fur-








    +       ther sends and receives will be disallowed.








    +








    +RETURN VALUE








    +       On  success,  zero is returned.  On error, -1 is returned,








    +       and errno is set appropriately.








    +








    +ERRORS








    +       EBADF   s is not a valid descriptor.








    +








    +       ENOTSOCK








    +               s is a file, not a socket.








    +








    +       ENOTCONN








    +               The specified socket is not connected.








    +
+ + Index: shutdown.man =================================================================== --- shutdown.man (nonexistent) +++ shutdown.man (revision 1765) @@ -0,0 +1,27 @@ +NAME + shutdown - shut down part of a full-duplex connection + +SYNOPSIS + #include + + int shutdown(int s, int how); + +DESCRIPTION + The shutdown call causes all or part of a full-duplex con- + nection on the socket associated with s to be shut down. + If how is 0, further receives will be disallowed. If how + is 1, further sends will be disallowed. If how is 2, fur- + ther sends and receives will be disallowed. + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF s is not a valid descriptor. + + ENOTSOCK + s is a file, not a socket. + + ENOTCONN + The specified socket is not connected. Index: recvfrom.html =================================================================== --- recvfrom.html (nonexistent) +++ recvfrom.html (revision 1765) @@ -0,0 +1,159 @@ + + +








    +NAME








    +       recvfrom - receive a message from a socket








    +








    +SYNOPSIS








    +       #include <network.h>








    +








    +       int recvfrom(int s, void *buf, int len, unsigned int flags








    +       struct sockaddr *from, int *fromlen);








    +








    +DESCRIPTION








    +       The  recvfrom call is used to receive messages from a socket,








    +       and may be used to receive data on a socket whether or not it








    +       is connection-oriented.








    +








    +








    +       If from is not NULL, and the socket is not connection-ori­








    +       ented, the source address of the  message  is  filled  in.








    +       Fromlen  is  a  value-result parameter, initialized to the








    +       size of the buffer associated with from, and  modified  on








    +       return  to  indicate the actual size of the address stored








    +       there.








    +








    +       The routine  returns  the length of the message on








    +       successful completion.  If a message is too long to fit in








    +       the supplied buffer, excess bytes may be discarded depend­








    +       ing on the type of socket the  message  is  received  from








    +       (see socket(2)).








    +








    +       If  no  messages  are available at the socket, the receive








    +       calls wait for a message to arrive, unless the  socket  is








    +       nonblocking  (see  fcntl(2)) in which case the value -1 is








    +       returned and the external variable errno  set  to  EAGAIN.








    +       The  receive  calls normally return any data available, up








    +       to the requested amount, rather than waiting  for  receipt








    +       of the full amount requested.








    +








    +       The  select(2)  call may be used to determine








    +       when more data arrives.








    +








    +       The flags argument to a recvfrom call is formed by OR'ing  one








    +       or more of the following values:








    +








    +       MSG_OOB








    +              This flag requests receipt of out-of-band data that








    +              would not be received in the  normal  data  stream.








    +              Some  protocols place expedited data at the head of








    +              the normal data queue, and thus this flag cannot be








    +              used with such protocols.








    +








    +       MSG_PEEK








    +              This  flag  causes  the receive operation to return








    +              data from the beginning of the receive queue  with­








    +              out  removing  that  data  from the queue.  Thus, a








    +              subsequent receive call will return the same  data.








    +








    +       MSG_WAITALL








    +              This  flag  requests that the operation block until








    +              the full request is satisfied.  However,  the  call








    +              may still return less data than requested if a sig­








    +              nal is caught, an error or  disconnect  occurs,  or








    +              the next data to be received is of a different type








    +              than that returned.








    +








    +       MSG_ERRQUEUE








    +              Receive packet from the error queue








    +








    +       MSG_NOSIGNAL








    +              This flag turns off raising of  SIGPIPE  on  stream








    +              sockets when the other end disappears.








    +








    +       MSG_ERRQUEUE








    +              This  flag  specifies  that queued errors should be








    +              received from the socket error queue.  The error is








    +              passed  in  a ancilliary message with a type depen­








    +              dent on the  protocol  (for  IP  IP_RECVERR).   The








    +              error  is  supplied in a sock_extended_error struc­








    +              ture:








    +








    +              #define SO_EE_ORIGIN_NONE       0








    +              #define SO_EE_ORIGIN_LOCAL      1








    +              #define SO_EE_ORIGIN_ICMP       2








    +              #define SO_EE_ORIGIN_ICMP6      3








    +








    +              struct sock_extended_err








    +              {








    +                  __u32           ee_errno;   /* error number */








    +                  __u8            ee_origin;  /* where the error originated */








    +                  __u8            ee_type;    /* type */








    +                  __u8            ee_code;    /* code */








    +                  __u8            ee_pad;








    +                  __u32           ee_info;    /* additional information */








    +                  __u32           ee_data;    /* other data */








    +              };








    +








    +              struct sockaddr *SOCK_EE_OFFENDER(struct sock_extended_err *);








    +








    +              ee_errno contains the errno number  of  the  queued








    +              error.   ee_origin  is the origin code of where the








    +              error originated.  The other  fields  are  protocol








    +              specific.   SOCK_EE_OFFENDER  returns  a pointer to








    +              the address of the network object where  the  error








    +              originated  from. If this address is not known, the








    +              sa_family member of the sockaddr contains AF_UNSPEC








    +              and the other fields of the sockaddr are undefined.








    +              The payload of the packet that caused the error  is








    +              passed as normal data.








    +








    +              For local errors, no address is passed (this can be








    +              checked with the cmsg_len member of  the  cmsghdr).








    +              For  error receives, the MSG_ERRQUEUE is set in the








    +              msghdr.  After a error has been passed, the pending








    +              socket  error  is  regenerated  based  on  the next








    +              queued error and will be passed on the next  socket








    +              operation.








    +








    +








    +       The msg_flags field is set on return according to the mes­








    +       sage  received.  MSG_EOR indicates end-of-record; the data








    +       returned completed a record (generally used  with  sockets








    +       of  type  SOCK_SEQPACKET).   MSG_TRUNC  indicates that the








    +       trailing portion of a datagram was discarded  because  the








    +       datagram  was larger than the buffer supplied.  MSG_CTRUNC








    +       indicates that some control data  were  discarded  due  to








    +       lack  of  space in the buffer for ancillary data.  MSG_OOB








    +       is returned to indicate that expedited or out-of-band data








    +       were  received.   MSG_ERRQUEUE  indicates that no data was








    +       received but an  extended  error  from  the  socket  error








    +       queue.








    +








    +RETURN VALUES








    +       These  calls return the number of bytes received, or -1 if








    +       an error occurred.








    +








    +ERRORS








    +       These are some standard errors  generated  by  the  socket








    +       layer.  Additional  errors  may  be generated and returned








    +       from the underlying protocol  modules;  see  their  manual








    +       pages.








    +








    +       EBADF   The argument s is an invalid descriptor.








    +








    +       ENOTSOCK








    +               The argument s does not refer to a socket.








    +








    +       EAGAIN  The  socket is marked non-blocking and the receive








    +               operation would block, or a  receive  timeout  had








    +               been  set  and the timeout expired before data was








    +               received.








    +








    +       EINTR   The receive was interrupted by delivery of a  sig­








    +               nal before any data were available.








    +








    +       EINVAL  Invalid argument passed.








    +
+ + Index: bind.man =================================================================== --- bind.man (nonexistent) +++ bind.man (revision 1765) @@ -0,0 +1,58 @@ +NAME + bind - bind a name to a socket + +SYNOPSIS + #include + + int bind(int sockfd, struct sockaddr *my_addr, int + addrlen); + +DESCRIPTION + bind gives the socket sockfd the local address my_addr. + my_addr is addrlen bytes long. Traditionally, this is + called "assigning a name to a socket." (When a socket is + created with socket(2), it exists in a name space (address + family) but has no name assigned.) + + Before a SOCK_STREAM socket is put into the LISTEN state + to receive connections, you usually need to first assign a + local address using bind to make the socket visible. + +NOTES + Binding a name that is not in the abstract namespace in + the UNIX domain creates a socket in the file system that + must be deleted by the caller when it is no longer needed + (using unlink(2)). + + The rules used in name binding vary between communication + domains. Consult the manual entries in section 4 for + detailed information. For IP see ip(4) and for PF_UNIX see + unix(4). If you want to listen to every local interface + for IPv4 set the sin_addr member of the IP-specific sock- + addr_in to INADDR_ANY. For IP only one socket may be + bound to a specific local address/port pair. For TCP a + bound local socket endpoint (address/port pair) is + unavailable for some time after closing the socket, unless + the SO_REUSEADDR flag is set. Note that carelessly setting + SO_REUSEADDR might make TCP more unreliable unless PAWS is + used (see tcp(4)); the delay is needed to handle old pack- + ets still in the network. + + IP sockets may also bind to a broadcast or multicast + address. + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF sockfd is not a valid descriptor. + + EINVAL The socket is already bound to an address. This + may change in the future: see linux/unix/sock.c + for details. + + ENOTSOCK + Argument is a descriptor for a file, not a socket. + + Index: ecos_tcpip.html =================================================================== --- ecos_tcpip.html (nonexistent) +++ ecos_tcpip.html (revision 1765) @@ -0,0 +1,88 @@ + + + + + + + + +
+

+TCP/IP Networking for eCos

+eCos now provides a complete TCP/IP networking stack.  This package +was derived from the latest stable release of OpenBSD.   +At this time, the networking support is considered "beta" quality although +it is already fully featured and well tested within the eCos environment. +

Ethernet drivers are provided for these standard supported platforms: +

+
  • +Motorola PowerPC MBX/860
  • + +
  • +Cirrus Logic EDB72xx
  • +
    +Other drivers for supported platforms are planned or underway. +

    +Networking Stack Features

    +Since this networking package is based on the venerable BSD code, it is +very complete and robust.  The eCos implementation includes support +for these protocols: +
    +
  • +IPv4
  • + +
  • +UDP
  • + +
  • +TCP
  • + +
  • +ICMP
  • + +
  • +raw packet interface
  • +
    +These additional features are also present in the package.  However +they are not yet supported: +
    +
  • +Berkeley Packet Filter
  • + +
  • +Multi-cast and uni-cast support, including multi-casting routing
  • + +
  • +IPv6
  • +
    + +

    +Provided Documentation

    +Since the networking package is "beta", documentation is still a bit thin.  +However, you will find a complete set of pages documenting the supported +networking functions (user code API) here. +

    +Ethernet Driver Design

    +Note: Currently, the networking stack only supports ethernet based networking. +

    The network drivers use a two-layer design.  One layer is hardware +independent but contains all the stack specific code.  The other layer +is platform dependent and communicates with the hardware independent layer +via a very simple API.  In this way, hardware device drivers can actually +be used with other stacks, if the same API can be provided by that stack.  +We designed the drivers this way to encourage the development of other +stacks in eCos while allowing reuse of the actual hardware specific code. +

    Complete documentation of the ethernet device driver and the associated +API can be found in the file net/drivers/eth/common/version/doc/driver_doc. +

    +Sample Code

    +Many examples using the networking support are provided.  These are +arranged as eCos test programs, primarily for us to verify the package, +but also can serve as useful frameworks for program design.  We have +taken a KISS approach to building programs which use the network.  +A single include file <network.h> is all that is required to +access the stack.  A complete, annotated test program can be found +here. +
      +
      + + Index: getsockopt.man =================================================================== --- getsockopt.man (nonexistent) +++ getsockopt.man (revision 1765) @@ -0,0 +1,65 @@ +NAME + getsockopt, setsockopt - get and set options on sockets + +SYNOPSIS + #include + + + int getsockopt(int s, int level, int optname, void *opt­ + val, socklen_t *optlen); + + int setsockopt(int s, int level, int optname, const void + *optval, socklen_t optlen); + +DESCRIPTION + Getsockopt and setsockopt manipulate the options associ­ + ated with a socket. Options may exist at multiple proto­ + col levels; they are always present at the uppermost + socket level. + + When manipulating socket options the level at which the + option resides and the name of the option must be speci­ + fied. To manipulate options at the socket level, level is + specified as SOL_SOCKET. To manipulate options at any + other level the protocol number of the appropriate proto­ + col controlling the option is supplied. For example, to + indicate that an option is to be interpreted by the TCP + protocol, level should be set to the protocol number of + TCP; see getprotoent(3). + + The parameters optval and optlen are used to access option + values for setsockopt. For getsockopt they identify a + buffer in which the value for the requested option(s) are + to be returned. For getsockopt, optlen is a value-result + parameter, initially containing the size of the buffer + pointed to by optval, and modified on return to indicate + the actual size of the value returned. If no option value + is to be supplied or returned, optval may be NULL. + + Optname and any specified options are passed uninterpreted + to the appropriate protocol module for interpretation. + The include file contains definitions for + socket level options, described below. Options at other + protocol levels vary in format and name; consult the + appropriate entries in section 4 of the manual. + + Most socket-level options utilize an int parameter for + optval. For setsockopt, the parameter should be non-zero + to enable a boolean option, or zero if the option is to be + disabled. + + For a description of the available socket options see + socket(7) and the appropriate protocol man pages. + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF The argument s is not a valid descriptor. + + ENOTSOCK + The argument s is a file, not a socket. + + ENOPROTOOPT + The option is unknown at the level indicated. Index: connect.html =================================================================== --- connect.html (nonexistent) +++ connect.html (revision 1765) @@ -0,0 +1,81 @@ + + +
    
    
    
    
    
    
    
    
        +NAME
    
    
    
    
    
    
    
    
        +       connect - initiate a connection on a socket
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +SYNOPSIS
    
    
    
    
    
    
    
    
        +       #include <network.h>
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       int  connect(int  sockfd,  struct sockaddr *serv_addr, int
    
    
    
    
    
    
    
    
        +       addrlen);
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +DESCRIPTION
    
    
    
    
    
    
    
    
        +       The parameter sockfd is a socket.  If  the  socket  is  of
    
    
    
    
    
    
    
    
        +       type  SOCK_DGRAM,  this call specifies the peer with which
    
    
    
    
    
    
    
    
        +       the socket is to be associated; this address  is  that  to
    
    
    
    
    
    
    
    
        +       which  datagrams are to be sent, and the only address from
    
    
    
    
    
    
    
    
        +       which datagrams are to be received.  If the socket  is  of
    
    
    
    
    
    
    
    
        +       type  SOCK_STREAM, this call attempts to make a connection
    
    
    
    
    
    
    
    
        +       to another socket.   The  other  socket  is  specified  by
    
    
    
    
    
    
    
    
        +       serv_addr, which is an address in the communications space
    
    
    
    
    
    
    
    
        +       of the socket.  Each communications space  interprets  the
    
    
    
    
    
    
    
    
        +       serv_addr  parameter  in  its  own way.  Generally, stream
    
    
    
    
    
    
    
    
        +       sockets may successfully connect only once; datagram sock-
    
    
    
    
    
    
    
    
        +       ets may use connect multiple times to change their associ-
    
    
    
    
    
    
    
    
        +       ation.  Datagram sockets may dissolve the  association  by
    
    
    
    
    
    
    
    
        +       connecting  to an address with the sa_family sockaddr mem-
    
    
    
    
    
    
    
    
        +       ber set to AF_UNSPEC.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +RETURN VALUE
    
    
    
    
    
    
    
    
        +       If the connection or binding succeeds, zero  is  returned.
    
    
    
    
    
    
    
    
        +       On  error, -1 is returned, and errno is set appropriately.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +ERRORS
    
    
    
    
    
    
    
    
        +       The following are general socket errors only.   There  may
    
    
    
    
    
    
    
    
        +       be other domain-specific error codes.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EBADF   Bad descriptor.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENOTSOCK
    
    
    
    
    
    
    
    
        +               The descriptor is not associated with a socket.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EISCONN The socket is already connected.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ECONNREFUSED
    
    
    
    
    
    
    
    
        +               Connection refused at server.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ETIMEDOUT
    
    
    
    
    
    
    
    
        +               Timeout while attempting connection.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENETUNREACH
    
    
    
    
    
    
    
    
        +               Network is unreachable.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EADDRINUSE
    
    
    
    
    
    
    
    
        +               Address is already in use.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EINPROGRESS
    
    
    
    
    
    
    
    
        +               The socket is non-blocking and the connection can-
    
    
    
    
    
    
    
    
        +               not  be  completed immediately.  It is possible to
    
    
    
    
    
    
    
    
        +               select(2) or poll(2) for completion  by  selecting
    
    
    
    
    
    
    
    
        +               the  socket  for  writing.  After select indicates
    
    
    
    
    
    
    
    
        +               writability,  use  getsockopt(2)   to   read   the
    
    
    
    
    
    
    
    
        +               SO_ERROR  option  at level SOL_SOCKET to determine
    
    
    
    
    
    
    
    
        +               whether connect completed  successfully  (SO_ERROR
    
    
    
    
    
    
    
    
        +               is zero) or unsuccessfully (SO_ERROR is one of the
    
    
    
    
    
    
    
    
        +               usual error codes  listed  above,  explaining  the
    
    
    
    
    
    
    
    
        +               reason for the failure).
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EALREADY
    
    
    
    
    
    
    
    
        +               The  socket is non-blocking and a previous connec-
    
    
    
    
    
    
    
    
        +               tion attempt has not yet been completed.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EAFNOSUPPORT
    
    
    
    
    
    
    
    
        +               The passed address didn't have the correct address
    
    
    
    
    
    
    
    
        +               family in its sa_family field.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EACCES  The  user  tried to connect to a broadcast address
    
    
    
    
    
    
    
    
        +               without having the socket broadcast flag  enabled.
    
    
    
    
    
    
    
    
        +
    + + Index: recvfrom.man =================================================================== --- recvfrom.man (nonexistent) +++ recvfrom.man (revision 1765) @@ -0,0 +1,152 @@ +NAME + recvfrom - receive a message from a socket + +SYNOPSIS + #include + + int recvfrom(int s, void *buf, int len, unsigned int flags + struct sockaddr *from, int *fromlen); + +DESCRIPTION + The recvfrom call is used to receive messages from a socket, + and may be used to receive data on a socket whether or not it + is connection-oriented. + + If from is not NULL, and the socket is not connection-ori­ + ented, the source address of the message is filled in. + Fromlen is a value-result parameter, initialized to the + size of the buffer associated with from, and modified on + return to indicate the actual size of the address stored + there. + + The routine returns the length of the message on + successful completion. If a message is too long to fit in + the supplied buffer, excess bytes may be discarded depend­ + ing on the type of socket the message is received from + (see socket(2)). + + If no messages are available at the socket, the receive + calls wait for a message to arrive, unless the socket is + nonblocking (see fcntl(2)) in which case the value -1 is + returned and the external variable errno set to EAGAIN. + The receive calls normally return any data available, up + to the requested amount, rather than waiting for receipt + of the full amount requested. + + The select(2) call may be used to determine + when more data arrives. + + The flags argument to a recvfrom call is formed by OR'ing one + or more of the following values: + + MSG_OOB + This flag requests receipt of out-of-band data that + would not be received in the normal data stream. + Some protocols place expedited data at the head of + the normal data queue, and thus this flag cannot be + used with such protocols. + + MSG_PEEK + This flag causes the receive operation to return + data from the beginning of the receive queue with­ + out removing that data from the queue. Thus, a + subsequent receive call will return the same data. + + MSG_WAITALL + This flag requests that the operation block until + the full request is satisfied. However, the call + may still return less data than requested if a sig­ + nal is caught, an error or disconnect occurs, or + the next data to be received is of a different type + than that returned. + + MSG_ERRQUEUE + Receive packet from the error queue + + MSG_NOSIGNAL + This flag turns off raising of SIGPIPE on stream + sockets when the other end disappears. + + MSG_ERRQUEUE + This flag specifies that queued errors should be + received from the socket error queue. The error is + passed in a ancilliary message with a type depen­ + dent on the protocol (for IP IP_RECVERR). The + error is supplied in a sock_extended_error struc­ + ture: + + #define SO_EE_ORIGIN_NONE 0 + #define SO_EE_ORIGIN_LOCAL 1 + #define SO_EE_ORIGIN_ICMP 2 + #define SO_EE_ORIGIN_ICMP6 3 + + struct sock_extended_err + { + __u32 ee_errno; /* error number */ + __u8 ee_origin; /* where the error originated */ + __u8 ee_type; /* type */ + __u8 ee_code; /* code */ + __u8 ee_pad; + __u32 ee_info; /* additional information */ + __u32 ee_data; /* other data */ + }; + + struct sockaddr *SOCK_EE_OFFENDER(struct sock_extended_err *); + + ee_errno contains the errno number of the queued + error. ee_origin is the origin code of where the + error originated. The other fields are protocol + specific. SOCK_EE_OFFENDER returns a pointer to + the address of the network object where the error + originated from. If this address is not known, the + sa_family member of the sockaddr contains AF_UNSPEC + and the other fields of the sockaddr are undefined. + The payload of the packet that caused the error is + passed as normal data. + + For local errors, no address is passed (this can be + checked with the cmsg_len member of the cmsghdr). + For error receives, the MSG_ERRQUEUE is set in the + msghdr. After a error has been passed, the pending + socket error is regenerated based on the next + queued error and will be passed on the next socket + operation. + + + The msg_flags field is set on return according to the mes­ + sage received. MSG_EOR indicates end-of-record; the data + returned completed a record (generally used with sockets + of type SOCK_SEQPACKET). MSG_TRUNC indicates that the + trailing portion of a datagram was discarded because the + datagram was larger than the buffer supplied. MSG_CTRUNC + indicates that some control data were discarded due to + lack of space in the buffer for ancillary data. MSG_OOB + is returned to indicate that expedited or out-of-band data + were received. MSG_ERRQUEUE indicates that no data was + received but an extended error from the socket error + queue. + +RETURN VALUES + These calls return the number of bytes received, or -1 if + an error occurred. + +ERRORS + These are some standard errors generated by the socket + layer. Additional errors may be generated and returned + from the underlying protocol modules; see their manual + pages. + + EBADF The argument s is an invalid descriptor. + + ENOTSOCK + The argument s does not refer to a socket. + + EAGAIN The socket is marked non-blocking and the receive + operation would block, or a receive timeout had + been set and the timeout expired before data was + received. + + EINTR The receive was interrupted by delivery of a sig­ + nal before any data were available. + + EINVAL Invalid argument passed. Index: listen.html =================================================================== --- listen.html (nonexistent) +++ listen.html (revision 1765) @@ -0,0 +1,42 @@ + + +
    
    
    
    
    
    
    
    
        +NAME
    
    
    
    
    
    
    
    
        +       listen - listen for connections on a socket
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +SYNOPSIS
    
    
    
    
    
    
    
    
        +       #include <network.h>
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       int listen(int s, int backlog);
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +DESCRIPTION
    
    
    
    
    
    
    
    
        +       To  accept  connections,  a  socket  is first created with
    
    
    
    
    
    
    
    
        +       socket(2), a willingness to  accept  incoming  connections
    
    
    
    
    
    
    
    
        +       and  a  queue limit for incoming connections are specified
    
    
    
    
    
    
    
    
        +       with listen, and then the connections  are  accepted  with
    
    
    
    
    
    
    
    
        +       accept(2).   The  listen  call  applies only to sockets of
    
    
    
    
    
    
    
    
        +       type SOCK_STREAM or SOCK_SEQPACKET.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       The backlog parameter defines the maximum length the queue
    
    
    
    
    
    
    
    
        +       of  pending  connections  may  grow  to.   If a connection
    
    
    
    
    
    
    
    
        +       request arrives with the queue full the client may receive
    
    
    
    
    
    
    
    
        +       an  error  with  an  indication of ECONNREFUSED or, if the
    
    
    
    
    
    
    
    
        +       underlying protocol supports retransmission,  the  request
    
    
    
    
    
    
    
    
        +       may be ignored so that retries may succeed.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +RETURN VALUE
    
    
    
    
    
    
    
    
        +       On success, zero is returned.  On error, -1  is  returned,
    
    
    
    
    
    
    
    
        +       and errno is set appropriately.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +ERRORS
    
    
    
    
    
    
    
    
        +       EBADF   The argument s is not a valid descriptor.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENOTSOCK
    
    
    
    
    
    
    
    
        +               The argument s is not a socket.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EOPNOTSUPP
    
    
    
    
    
    
    
    
        +               The socket is not of a type that supports the lis-
    
    
    
    
    
    
    
    
        +               ten operation.
    
    
    
    
    
    
    
    
        +
    + + Index: socket.man =================================================================== --- socket.man (nonexistent) +++ socket.man (revision 1765) @@ -0,0 +1,111 @@ +NAME + socket - create an endpoint for communication + +SYNOPSIS + #include + + int socket(int domain, int type, int protocol); + +DESCRIPTION + Socket creates an endpoint for communication and returns a + descriptor. + + The domain parameter specifies a communications domain + within which communication will take place; this selects + the protocol family which should be used. These families + are defined in . The currently understood + formats include: + + PF_INET + IPv4 Internet protocols; see ip(4) + + The socket has the indicated type, which specifies the + semantics of communication. Currently defined types are: + + SOCK_STREAM + Provides sequenced, reliable, two-way connection- + based byte streams. An out-of-band data transmis- + sion mechanism may be supported. + + SOCK_DGRAM + Supports datagrams (connectionless, unreliable mes- + sages of a fixed maximum length). + + SOCK_SEQPACKET + Provides a sequenced, reliable, two-way connection- + based data transmission path for datagrams of fixed + maximum length; a consumer is required to read an + entire packet with each read system call. + + SOCK_RAW + Provides raw network protocol access. + + The protocol specifies a particular protocol to be used + with the socket. Normally only a single protocol exists + to support a particular socket type within a given proto- + col family. However, it is possible that many protocols + may exist, in which case a particular protocol must be + specified in this manner. The protocol number to use is + particular to the "communication domain" in which communi- + cation is to take place; see protocols(5). See getpro- + toent(3) on how to map protocol name strings to protocol + numbers. + + Sockets of type SOCK_STREAM are full-duplex byte streams, + similar to pipes. A stream socket must be in a connected + state before any data may be sent or received on it. A + connection to another socket is created with a connect(2) + call. Once connected, data may be transferred using + read(2) and write(2) calls or some variant of the send(2) + and recv(2) calls. When a session has been completed a + close(2) may be performed. Out-of-band data may also be + transmitted as described in send(2) and received as + described in recv(2). + + The communications protocols which implement a SOCK_STREAM + ensure that data is not lost or duplicated. If a piece of + data for which the peer protocol has buffer space cannot + be successfully transmitted within a reasonable length of + time, then the connection is considered When SO_KEEPALIVE + is enabled on the socket the protocol checks in a proto- + col-specific manner if the other end is still alive. + + SOCK_DGRAM and SOCK_RAW sockets allow sending of datagrams + to correspondents named in send(2) calls. Datagrams are + generally received with recvfrom(2), which returns the + next datagram with its return address. + + When the network signals an error condition to the proto- + col module (e.g. using a ICMP message for IP) the pending + error flag is set for the socket. The next operation on + this socket will return the error code of the pending + error. For some protocols it is possible to enable a per- + socket error queue to retrieve detailed information about + the error; see IP_RECVERR in ip(4). + + The operation of sockets is controlled by socket level + options. These options are defined in . + Setsockopt(2) and getsockopt(2) are used to set and get + options, respectively. + +RETURN VALUES + -1 is returned if an error occurs; otherwise the return + value is a descriptor referencing the socket. + +ERRORS + EPROTONOSUPPORT + The protocol type or the specified protocol is not + supported within this domain. + + EMFILE There are too many open files. + + EACCES Permission to create a socket of the specified + type and/or protocol is denied. + + ENOBUFS or ENOMEM + Insufficient memory is available. The socket can- + not be created until sufficient resources are + freed. + + EINVAL Unknown protocol, or protocol family not avail- + able. Index: accept.html =================================================================== --- accept.html (nonexistent) +++ accept.html (revision 1765) @@ -0,0 +1,81 @@ + + +
    
    
    
    
    
    
    
    
        +NAME
    
    
    
    
    
    
    
    
        +       accept - accept a connection on a socket
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +SYNOPSIS
    
    
    
    
    
    
    
    
        +       #include <network.h>
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       int accept(int s, struct sockaddr *addr, int *addrlen);
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +DESCRIPTION
    
    
    
    
    
    
    
    
        +       The  argument  s  is  a  socket that has been created with
    
    
    
    
    
    
    
    
        +       socket(2), bound to an address with bind(2), and  is  lis-
    
    
    
    
    
    
    
    
        +       tening  for  connections  after  a  listen(2).  The accept
    
    
    
    
    
    
    
    
        +       function extracts the  first  connection  request  on  the
    
    
    
    
    
    
    
    
        +       queue  of  pending  connections, creates a new socket with
    
    
    
    
    
    
    
    
        +       the same  properties  of  s,  and  allocates  a  new  file
    
    
    
    
    
    
    
    
        +       descriptor  for the socket.  If no pending connections are
    
    
    
    
    
    
    
    
        +       present on the queue, and the socket is not marked as non-
    
    
    
    
    
    
    
    
        +       blocking,  accept  blocks the caller until a connection is
    
    
    
    
    
    
    
    
        +       present.  If the socket  is  marked  non-blocking  and  no
    
    
    
    
    
    
    
    
        +       pending  connections  are  present  on  the  queue, accept
    
    
    
    
    
    
    
    
        +       returns an error as described below.  The socket  returned
    
    
    
    
    
    
    
    
        +       by accept may not be used to accept more connections.  The
    
    
    
    
    
    
    
    
        +       original socket s remains open.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       The argument addr is a result parameter that is filled  in
    
    
    
    
    
    
    
    
        +       with the address of the connecting entity, as known to the
    
    
    
    
    
    
    
    
        +       communications layer.  The exact format of the addr param-
    
    
    
    
    
    
    
    
        +       eter  is  determined by the domain in which the communica-
    
    
    
    
    
    
    
    
        +       tion is occurring.  addrlen is a  value-result  parameter:
    
    
    
    
    
    
    
    
        +       it should initially contain the amount of space pointed to
    
    
    
    
    
    
    
    
        +       by addr; on return it will contain the actual  length  (in
    
    
    
    
    
    
    
    
        +       bytes)  of  the  address returned.  This call is used with
    
    
    
    
    
    
    
    
        +       connection-based socket types, currently with SOCK_STREAM.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       It  is  possible to select(2) a socket for the purposes of
    
    
    
    
    
    
    
    
        +       doing an accept by selecting it for read.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       For certain protocols which require an explicit  confirma-
    
    
    
    
    
    
    
    
        +       tion,  such  as DECNet, accept can be thought of as merely
    
    
    
    
    
    
    
    
        +       dequeuing the next connection  request  and  not  implying
    
    
    
    
    
    
    
    
        +       confirmation.   Confirmation  can  be  implied by a normal
    
    
    
    
    
    
    
    
        +       read or write on the new file  descriptor,  and  rejection
    
    
    
    
    
    
    
    
        +       can  be  implied by closing the new socket. Currently only
    
    
    
    
    
    
    
    
        +       DECNet has these semantics on Linux.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +NOTES
    
    
    
    
    
    
    
    
        +       If you want accept to never  block  the  listening  socket
    
    
    
    
    
    
    
    
        +       needs  to  have  the  non blocking flag set. Assuming that
    
    
    
    
    
    
    
    
        +       there is always a connection waiting after select returned
    
    
    
    
    
    
    
    
        +       true  is  not  reliable,  because  the connection might be
    
    
    
    
    
    
    
    
        +       removed by  an  asynchronous  network  error  between  the
    
    
    
    
    
    
    
    
        +       select/poll returning and the accept call. The application
    
    
    
    
    
    
    
    
        +       would hang then if the listen socket is not non  blocking.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +RETURN VALUES
    
    
    
    
    
    
    
    
        +       The  call returns -1 on error.  If it succeeds, it returns
    
    
    
    
    
    
    
    
        +       a non-negative  integer  that  is  a  descriptor  for  the
    
    
    
    
    
    
    
    
        +       accepted socket.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +ERRORS
    
    
    
    
    
    
    
    
        +       EBADF   The descriptor is invalid.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENOTSOCK
    
    
    
    
    
    
    
    
        +               The descriptor references a file, not a socket.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EOPNOTSUPP
    
    
    
    
    
    
    
    
        +               The referenced socket is not of type  SOCK_STREAM.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EAGAIN  The socket is marked non-blocking and  no  connec-
    
    
    
    
    
    
    
    
        +               tions are present to be accepted.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENOBUFS, ENOMEM
    
    
    
    
    
    
    
    
        +               Not enough free memory.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    + + Index: getsockname.html =================================================================== --- getsockname.html (nonexistent) +++ getsockname.html (revision 1765) @@ -0,0 +1,37 @@ + + +
    
    
    
    
    
    
    
    
        +NAME
    
    
    
    
    
    
    
    
        +       getsockname - get socket name
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +SYNOPSIS
    
    
    
    
    
    
    
    
        +       #include <network.h>
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       int   getsockname(int   s  ,  struct  sockaddr  *  name  ,
    
    
    
    
    
    
    
    
        +       socklen_t * namelen )
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +DESCRIPTION
    
    
    
    
    
    
    
    
        +       Getsockname returns the current  name  for  the  specified
    
    
    
    
    
    
    
    
        +       socket.   The  namelen  parameter should be initialized to
    
    
    
    
    
    
    
    
        +       indicate the amount of  space  pointed  to  by  name.   On
    
    
    
    
    
    
    
    
        +       return  it  contains  the actual size of the name returned
    
    
    
    
    
    
    
    
        +       (in bytes).
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +RETURN VALUE
    
    
    
    
    
    
    
    
        +       On success, zero is returned.  On error, -1  is  returned,
    
    
    
    
    
    
    
    
        +       and  errno  is  set appropriately.  A 0 is returned if the
    
    
    
    
    
    
    
    
        +       call succeeds, -1 if it fails.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +ERRORS
    
    
    
    
    
    
    
    
        +       EBADF   The argument s is not a valid descriptor.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENOTSOCK
    
    
    
    
    
    
    
    
        +               The argument s is a file, not a socket.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       ENOBUFS Insufficient resources were available in the  sys-
    
    
    
    
    
    
    
    
        +               tem to perform the operation.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    + + Index: connect.man =================================================================== --- connect.man (nonexistent) +++ connect.man (revision 1765) @@ -0,0 +1,75 @@ +NAME + connect - initiate a connection on a socket + +SYNOPSIS + #include + + int connect(int sockfd, struct sockaddr *serv_addr, int + addrlen); + +DESCRIPTION + The parameter sockfd is a socket. If the socket is of + type SOCK_DGRAM, this call specifies the peer with which + the socket is to be associated; this address is that to + which datagrams are to be sent, and the only address from + which datagrams are to be received. If the socket is of + type SOCK_STREAM, this call attempts to make a connection + to another socket. The other socket is specified by + serv_addr, which is an address in the communications space + of the socket. Each communications space interprets the + serv_addr parameter in its own way. Generally, stream + sockets may successfully connect only once; datagram sock- + ets may use connect multiple times to change their associ- + ation. Datagram sockets may dissolve the association by + connecting to an address with the sa_family sockaddr mem- + ber set to AF_UNSPEC. + +RETURN VALUE + If the connection or binding succeeds, zero is returned. + On error, -1 is returned, and errno is set appropriately. + +ERRORS + The following are general socket errors only. There may + be other domain-specific error codes. + + EBADF Bad descriptor. + + ENOTSOCK + The descriptor is not associated with a socket. + + EISCONN The socket is already connected. + + ECONNREFUSED + Connection refused at server. + + ETIMEDOUT + Timeout while attempting connection. + + ENETUNREACH + Network is unreachable. + + EADDRINUSE + Address is already in use. + + EINPROGRESS + The socket is non-blocking and the connection can- + not be completed immediately. It is possible to + select(2) or poll(2) for completion by selecting + the socket for writing. After select indicates + writability, use getsockopt(2) to read the + SO_ERROR option at level SOL_SOCKET to determine + whether connect completed successfully (SO_ERROR + is zero) or unsuccessfully (SO_ERROR is one of the + usual error codes listed above, explaining the + reason for the failure). + + EALREADY + The socket is non-blocking and a previous connec- + tion attempt has not yet been completed. + + EAFNOSUPPORT + The passed address didn't have the correct address + family in its sa_family field. + + EACCES The user tried to connect to a broadcast address + without having the socket broadcast flag enabled. Index: write.man =================================================================== --- write.man (nonexistent) +++ write.man (revision 1765) @@ -0,0 +1,36 @@ +NAME + write - write to a file descriptor + +SYNOPSIS + ssize_t write(int fd, const void *buf, size_t count); + +DESCRIPTION + write writes up to count bytes to the file referenced by + the file descriptor fd from the buffer starting at buf. + +RETURN VALUE + On success, the number of bytes written are returned (zero + indicates nothing was written). On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF fd is not a valid file descriptor or is not open + for writing. + + EINVAL fd is attached to an object which is unsuitable for + writing. + + EPIPE fd is connected to a socket whose reading + end is closed. + + EAGAIN Non-blocking I/O has been selected using O_NONBLOCK + and there was no room in the pipe or socket con­ + nected to fd to write the data immediately. + + EINTR The call was interrupted before any + data was written. + + ENOSPC The device containing the file referred to by fd + has no room for the data. + + EIO A low-level I/O error occurred. Index: tcpip_tests.html =================================================================== --- tcpip_tests.html (nonexistent) +++ tcpip_tests.html (revision 1765) @@ -0,0 +1,98 @@ + + + + + + + + +
    +

    +eCos TCP/IP Networking Tests and Examples

    +A number of test/example programs are currently provided with the TCP/IP +networking package.  These are not "tests" in the traditional eCos +test suite sense, but rather simple programs which exercise various parts +of the networking stack.  Also included are a set of performance tests, +used to measure throughput and latency in an embedded eCos system. +

    The following paragraphs list the various tests and how they might be +used.   They are enumerated in the order in which they should +be run to verify a system configuration. +

    Note: none of these tests are built by default.  The user must +enable the CYGPKG_NET_BUILD_TESTS option and then "make +tests" to create them for the target environment.  Also, these +tests require that the hardware interfaces be configured to use either +BOOTP or static initialization methods. +

    +mbuf_test.c

    +This should be the first test run on a new system.  It simply tests +that the networking system can be initialized and that the internal memory +management (used by the stack) is functioning. +

    +socket_test.c

    +This test exercises some of the basic library interfaces. +

    +server_test.c

    +This test creates a server process on the target hardware which listens +on port TCP/7734.  To verify that it is working, try to connect to +this port from some other [host] system.  E.g. on Linux, use the command +"telnet eCos 7734", where "eCos" is the +name associated with the target hardware.  Once connected, the eCos +application will respond with a "Hello" message and wait for a single line +of input text, which will be displayed on the diagnostic channel of the +target system. +

    +ping_test.c

    +This tests attempts to issue an ICMP "echo" request to the "server" host +(provided as part of the BOOTP or static configuration information).  +The output will be similar to the analogous Linux program, "ping".  +The test program also attempts to ping an additional host whose IP address +is the server IP+32.  This second test is present to verify that the +ICMP (actually receive) time-out mechanism is working (assuming +that the second host is non-existent). +

    +ftp_test.c

    +This test attempts to make a connection to an FTP server, assuming the +default server host.  This is an additional test which verifies that +the basic TCP functionality is working. +

    +nc_test_master.c

    + +

    +nc_test_slave.c

    +This pair of programs can be used to measure throughput and latencies in +the target system.  While both programs have been written in such +a way that they can be built and used on either Linux or eCos, the primary +use will be to run the "nc_test_master" program on a Linux host +and the "nc_test_slave" on the target hardware.  If run in +this configuration, the master program will attempt to connect to the slave +and make various measurements using both UDP and TCP protocols.  Additionally, +measurements will be made on an eCos slave of the actual CPU utilization +by the networking stack. +

    To build the Linux versions, simply execute (in the eCos source tree, +not the install tree): +

    make -f make.linux
    + +

    +tcp_echo.c

    + +

    +tcp_sink.c

    + +

    +tcp_source.c

    +This set of programs is similar to the nc_test_XXX programs +described above.  However, they are designed to measure overall throughput +of the eCos system.  The setup allows for one Linux host to run "tcp_source +eCos" and another Linux host to run "tcp_sink eCos".  +The "tcp_echo" program is run on the target hardware.  The +tests then measure the throughput and latency of sending TCP data from +one host, though the eCos target system and on to another host.  Note: +the two Linux host systems may be the same computer in which case this +becomes a single wire echo test.  This test suite is unique in that +it attempts to load the target system down with additional background processing +at various levels.  This is done to simulate a real world environment +where the networking is ancillary to the main processing on the target +system. +
      + + Index: getpeername.man =================================================================== --- getpeername.man (nonexistent) +++ getpeername.man (revision 1765) @@ -0,0 +1,34 @@ +NAME + getpeername - get name of connected peer + +SYNOPSIS + #include + + int getpeername(int s, struct sockaddr *name, socklen_t + *namelen); + +DESCRIPTION + Getpeername returns the name of the peer connected to + socket s. The namelen parameter should be initialized to + indicate the amount of space pointed to by name. On + return it contains the actual size of the name returned + (in bytes). The name is truncated if the buffer provided + is too small. + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF The argument s is not a valid descriptor. + + ENOTSOCK + The argument s is a file, not a socket. + + ENOTCONN + The socket is not connected. + + ENOBUFS Insufficient resources were available in the sys- + tem to perform the operation. + + Index: tcpip_library.html =================================================================== --- tcpip_library.html (nonexistent) +++ tcpip_library.html (revision 1765) @@ -0,0 +1,77 @@ + + + + + + + + +
    +

    +TCP/IP Library Reference

    + +
  • +accept
  • + +
  • +bind
  • + +
  • +close
  • + +
  • +connect
  • + +
  • +gethostbyname, gethostbyaddr
  • + +
  • +getpeername
  • + +
  • +getprotobyname, getprotobynumber
  • + +
  • +getservbyname, getservbyport
  • + +
  • +getsockname
  • + +
  • +getsockopt
  • + +
  • +inet_aton, inet_addr, inet_addr
  • + +
  • +ioctl
  • + +
  • +listen
  • + +
  • +read
  • + +
  • +recvfrom
  • + +
  • +select
  • + +
  • +sendto
  • + +
  • +setsockopt
  • + +
  • +shutdown
  • + +
  • +socket
  • + +
  • +write
  • + + + Index: sendto.man =================================================================== --- sendto.man (nonexistent) +++ sendto.man (revision 1765) @@ -0,0 +1,100 @@ +NAME + sendto - send a message from a socket + +SYNOPSIS + #include + + int sendto(int s, const void *msg, int len, unsigned int + flags, const struct sockaddr *to, int tolen); + +DESCRIPTION + Sendto is used to transmit a message + to another socket. + + The address of the target is given by to with tolen speci­ + fying its size. The length of the message is given by + len. If the message is too long to pass atomically + through the underlying protocol, the error EMSGSIZE is + returned, and the message is not transmitted. + + No indication of failure to deliver is implicit in a send. + Locally detected errors are indicated by a return value of + -1. + + When the message does not fit into the send buffer of the + socket, send normally blocks, unless the socket has been + placed in non-blocking I/O mode. In non-blocking mode it + would return EAGAIN in this case. The select(2) call may + be used to determine when it is possible to send more + data. + + The flags parameter may include one or more of the follow­ + ing: + + #define MSG_OOB 0x1 /* process out-of-band data */ + #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ + #define MSG_DONTWAIT 0x40 /* don't block */ + #define MSG_NOSIGNAL 0x2000 /* don't raise SIGPIPE */ + + MSG_OOB + Sends out-of-band data on sockets that support this + notion (e.g. SOCK_STREAM); the underlying protocol + must also support out-of-band data. + + MSG_DONTROUTE + Bypasses the usual routing table lookup and sends + the packet directly to the interface described by + the destination address. This is usually used only + by diagnostic or routing programs. + + MSG_DONTWAIT + Enables non-blocking operation; if the operation + would block, EAGAIN is returned. + + MSG_NOSIGNAL + Requests not to send SIGPIPE on errors on stream + oriented sockets when the other end breaks the con­ + nection. The EPIPE error is still returned. + + See recv(2) for a description of the msghdr structure. You + may send control information using the msg_control and + msg_controllen members. The maximum control buffer length + the kernel can process is limited by the net.core.opt­ + mem_max sysctl; see socket(4). + +RETURN VALUES + The calls return the number of characters sent, or -1 if + an error occurred. + +ERRORS + These are some standard errors generated by the socket + layer. Additional errors may be generated and returned + from the underlying protocol modules; see their respective + manual pages. + + EBADF An invalid descriptor was specified. + + ENOTSOCK + The argument s is not a socket. + + EMSGSIZE + The socket requires that message be sent atomi­ + cally, and the size of the message to be sent made + this impossible. + + EAGAIN The socket is marked non-blocking and the + requested operation would block. + + ENOBUFS The system was unable to allocate an internal mem­ + ory block. The operation may succeed when buffers + become available. + + EINTR A signal occurred. + + ENOMEM No memory available. + + EINVAL Invalid argument passed. + + EPIPE The local end has been shut down on a connection + oriented socket. In this case the process will + also receive a SIGPIPE unless MSG_NOSIGNAL is set. Index: bridge.man =================================================================== --- bridge.man (nonexistent) +++ bridge.man (revision 1765) @@ -0,0 +1,314 @@ + +NAME + bridge - Ethernet bridge interface + +SYNOPSIS + pseudo-device bridge 2 + +DESCRIPTION + The bridge device creates a logical link between two or more Ethernet in + terfaces. This link between the interfaces selectively forwards frames + from each interface on the bridge to every other interface on the bridge. + A bridge can serve several services, including, isolation of traffic be + tween sets of machines so that traffic local to one set of machines is + not available on the wire of another set of machines, and it can act as a + transparent filter for ip(4) datagrams. + + The bridges provided by this interface are learning bridges with IP fil + tering, see ipf(4). In general a bridge works like a hub, forwarding + traffic from one interface to another. It differs from a hub in that it + will "learn" which machines are on each of its attached segments by ac + tively listening to incoming traffic and examining the headers of each + frame. A table is built containing the MAC address and segment to which + the MAC address is attached. This allows a bridge to be more selective + about what it forwards, which can be used to reduce traffic on a set of + segments and also to provide an IP firewall without changing the topology + of the network. + + The algorithm works as follows by default, but can be modified via + ioctl(2) or the utility brconfig(8). When a frame comes in, the origin + segment and the source address are recorded. If the bridge has no knowl + edge about where the destination is to be found, the bridge will forward + the frame to all attached segments. If the destination is known to be on + a different segment from its origin, the bridge will forward the packet + only to the destination segment. If the destination is on the same seg + ment as the origin segment, the bridge will drop the packet because the + receiver has already had a chance to see the frame. Before forwarding a + frame, the bridge will check to see if the packet contains an ip(4) data + gram; if so, the datagram is run through the ipf(4) interface so that it + can be filtered. Only the ipf(4) input rules for the source interface + are checked with the datagram; output rules have no effect. + +IOCTLS + A bridge interface responds to all of the ioctl(2) calls specific to oth + er interfaces listed in netintro(4). The following ioctl(2) calls are + specific to bridge devices. They are defined in . + + SIOCBRDGIFS (struct ifbifconf) Retrieve member interface list from a + bridge. This request takes an ifbifconf structure (see + below) as a value-result parameter. The ifbic_len field + should be initially set to the size of the buffer point + ed to by ifbic_buf. On return it will contain the + length, in bytes, of the configuration list. Alterna + tively, if the ifbic_len passed in is set to 0, + SIOCBRDGIFS will set ifbic_len to the size that + ifbic_buf needs to be to fit the entire configuration + list, and will not fill in the other parameters. This + is useful for determining the exact size that ifbic_buf + needs to be in advance. + + The argument structure is defined as follows: + + struct ifbreq { + char ifbr_name[IFNAMSIZ]; /* brdg nam */ + char ifbr_ifsname[IFNAMSIZ]; /* if name */ + u_int32_t ifbr_ifsflags; /* if flags */ + }; + + #define IFBIF_LEARNING 0x1 /* learns addrs */ + #define IFBIF_DISCOVER 0x2 /* gets fwd'd pkts */ + + struct ifbifconf { + char ifbic_name[IFNAMSIZ]; /* brdg name */ + u_int32_t ifbic_len; /* buf size */ + union { + caddr_t ifbicu_buf; /* buffer */ + struct ifbreq *ifbicu_req; + } ifbic_ifbicu; + #define ifbic_buf ifbic_ifbicu.ifbicu_buf + #define ifbic_req ifbic_ifbicu.ifbicu_req + }; + + SIOCBRDGADD (struct ifbreq) Add the interface named in ifbr_ifsname + to the bridge named in ifbr_name. + + SIOCBRDGDEL (struct ifbreq) Delete the interface named in + ifbr_ifsname from the bridge named in ifbr_name. + + SIOCBRDGSIFFLGS (struct ifbreq) Set the bridge member interface flags + for the interface named in ifbr_ifsname attached to the + bridge ifbr_name. If the flag IFBIF_LEARNING is set on + an interface, source addresses from frames received on + the interface are recorded in the address cache. If the + flag IFBIF_DISCOVER is set, the interface will receive + packets destined for unknown destinations, otherwise a + frame that has a destination not found in the address + cache is not forwarded to this interface. The default + for newly added interfaces has both flags set. If the + flag IFBIF_BLOCKNONIP is set, packets that are one of + ip(4), ip6(4), arp(4), or Reverse ARP, will not be + bridged from and to the interface. + + SIOCBRDGGIFFLGS Retrieve the bridge member interface flags for the in + terface named in ifbr_ifsname attached to the bridge + ifbr_name. + + SIOCBRDGRTS (struct ifbaconf) Retrieve the address cache of the + bridge named in ifbac_name. This request takes an + ifbaconf structure (see below) as a value result parame + ter. The ifbac_len field should be initially set to the + size of the buffer pointed to by ifbac_buf. On return, + it will contain the length, in bytes, of the configura + tion list. Alternatively, if the ifbac_len passed in is + set to 0, SIOCBRDGRTS will set it to the size that + ifbac_buf needs to be to fit the entire configuration + list and not fill in the other parameters. As with + SIOCBRDGIFS, this is useful for determining the exact + size that ifbac_buf needs to be in advance. + + The argument structure is defined as follows: + + struct ifbareq { + char ifba_name[IFNAMSIZ]; /* brdg nam */ + char ifba_ifsname[IFNAMSIZ];/* dest ifs */ + u_int8_t ifba_age; /* addr age */ + u_int8_t ifba_flags; /* addr flag */ + struct ether_addr ifba_dst; /* dst addr */ + }; + + #define IFBAF_TYPEMASK 0x03 /* addr type mask */ + #define IFBAF_DYNAMIC 0x00 /* dynamic addr */ + #define IFBAF_STATIC 0x01 /* static address */ + + struct ifbaconf { + char ifbac_name[IFNAMSIZ]; /* brdg name */ + u_int32_t ifbac_len; /* buf size */ + union { + caddr_t ifbacu_buf; /* buf */ + struct ifbareq *ifbacu_req; + } ifbac_ifbacu; + #define ifbac_buf ifbac_ifbacu.ifbacu_buf + #define ifbac_req ifbac_ifbacu.ifbacu_req + }; + Address cache entries with the type set to IFBAF_DYNAMIC + in ifba_flags are entries learned by the bridge. En + tries with the type set to IFBAF_STATIC are manually + added entries. + + SIOCBRDGSADDR (struct ifbareq) Add an entry, manually, to the address + cache for the bridge named in ifba_name. The address and + its associated interface and flags are set in the + ifba_dst, ifba_ifsname, ifba_flags fields, respectively. + + SIOCBRDGDADDR (struct ifbareq) Delete an entry from the address cache + of the bridge named in ifba_name. Entries are deleted + strictly based on the address field ifba_dst. + + SIOCBRDGSCACHE (struct ifbcachereq) Set the maximum address cache size + for the bridge named in ifbc_name to ifbc_size entries. + + The argument structure is as follows: + + struct ifbcachereq { + char ifbc_name[IFNAMSIZ]; /* bridge */ + u_int32_t ifbc_size; /* size */ + }; + + SIOCBRDGGCACHE (struct ifbcachereq) Retrieve the maximum size of the + address cache for the bridge ifbc_name. + + SIOCBRDGSTO (struct ifbcachetoreq) Set the time, in seconds, that + addresses which have not been seen on the network + (transmitted a packet) remain in the cache. If the time + is set to zero, no aging is performed on the address + cache. The argument structure is as follows: + + struct ifbcachetoreq { + char ifbct_name[IFNAMSIZ]; /* bridge */ + u_int32_t ifbct_time; /* time */ + }; + + SIOCBRDGGTO (struct ifbcachetoreq) Retrieve the address cache expi + ration time (see above). + + SIOCBRDGFLUSH (struct ifbreq) Flush addresses from the cache. + ifbr_name contains the name of the bridge device, and + ifbr_ifsflags should be set to IFBF_FLUSHALL to flush + all addresses from the cache or IFBF_FLUSHDYN to flush + only the dynamically learned addresses from the cache. + + SIOCBRDGARL (struct ifbrlreq) Add a filtering rule to the bridge + named in ifbr_name on the interface named in + ifbr_ifsname. The argument structure is as follows: + + struct ifbrlreq { + char ifbr_name[IFNAMSIZ]; /* bridge */ + char ifbr_ifsname[IFNAMSIZ]; /* ifs */ + u_int8_t ifbr_action; /* handling */ + u_int8_t ifbr_flags; /* flags */ + struct ether_addr ifbr_src; /* src mac */ + struct ether_addr ifbr_dst; /* dst mac */ + }; + #define BRL_ACTION_BLOCK 0x01 + #define BRL_ACTION_PASS 0x02 + #define BRL_FLAG_IN 0x08 + #define BRL_FLAG_OUT 0x04 + #define BRL_FLAG_SRCVALID 0x02 + #define BRL_FLAG_DSTVALID 0x01 + + Rules are applied in the order in which they were added + to the bridge, and the first matching rule's action pa + rameter determines the fate of the packet. The + ifbr_action parameter specifies whether a frame matching + the rule is to be blocked or passed. + + If the BRL_FLAG_IN bit is set in ifbr_flags, then the + rule applies to frames received by the interface. If + the BRL_FLAG_OUT bit is set, then the rule applies to + frame transmitted by the interface. At least one of + BRL_FLAG_IN or BRL_FLAG_OUT must be set. + + The source ethernet address in ifbr_src is checked if + the BRL_FLAG_SRCVALID bit is set in ifbr_flags. The des + tination address in ifbr_dst is check if the + BRL_FLAG_DSTVALID bit is set. If neither bit is set, + the rule is matches all frames. + + SIOCBRDGFRL (struct ifbrlreq) Remove all filtering rules from a + bridge interface member. ifbr_name contains the name of + the bridge device, and ifbr_ifsname contains the name of + the bridge member interface. + + SIOCBRDGGRL (struct ifbrlconf) Retrieve all of the rules from the + bridge, ifbrl_name, for the member interface, + ifbrl_ifsname. + + This request takes an ifbrlconf structure (see below) as + a value result parameter. The ifbrl_len field should be + initially set to the size of the buffer pointed to by + ifbrl_buf. On return, it will contain the length, in + bytes, of the configuration list. Alternatively, if the + ifbrl_len passed in is set to 0, SIOCBRDGGRL will set it + to the size that ifbrl_buf needs to be to fit the entire + configuration list and not fill in the other parameters. + As with SIOCBRDGIFS, this is useful for determining the + exact size that ifbrl_buf needs to be in advance. + + The argument structure is defined as follows: + + struct ifbrlconf { + char ifbrl_name[IFNAMSIZ]; /* brdg nam */ + char ifbrl_ifsname[IFNAMSIZ];/* ifs name */ + u_int32_t ifbr_len; /* buf len */ + union { + caddr_t ifbrlu_buf; + struct ifbrlreq *ifbrlu_req; + } ifrl_ifbrlu; + #define ifbrl_buf ifbrl_ifbrlu.ifbrlu_buf + #define ifbrl_req ifbrl_ifbrlu.ifbrlu_req + }; + + +ERRORS + If the ioctl(2) call fails, errno(2) is set to one of the following val + ues: + + [ENOENT] For an add request, this means that the named interface is + not configured into the system. For delete operation, it + means that the named interface is not a member of the + bridge. For a address cache deletion, the address was not + found in the table. + + [ENOMEM] Memory could not be allocated for an interface or cache en + try to be added to the bridge. + + [EEXIST] The named interface is already a member of the bridge. + + [EBUSY] The named interface is already a member of another bridge. + + [EINVAL] The named interface is not an Ethernet interface or an in + valid ioctl was performed on the bridge. + + [ENETDOWN] Address cache operation (flush, add, delete) on a bridge + that is in the down state. + + [EPERM] Super-user privilege is required to add and delete inter + faces to and from bridges and to set the bridge interface + flags. + + [EFAULT] The buffer used in a SIOCBRDGIFS or SIOCBRDGRTS request + + points outside of the process's allocated address space. + + [ESRCH] No such member interface in the bridge. + +SEE ALSO + errno(2), ioctl(2), ip(4), ipf(4), netintro(4), bridgename.if(5), + brconfig(8) + +HISTORY + The brconfig(8) command and the bridge(4) kernel interface first appeared + in + +AUTHOR + The brconfig(8) command and the bridge(4) kernel interface were written + by Jason L. Wright as part of an undergraduate inde + pendent study at the University of North Carolina at Greensboro. + +BUGS + There is currently no loop detection. Care must be taken to make sure + that loops are not created when a bridge is brought up. + + Only ipf(4) input rules are checked with incoming packet; there is no + easy way to handle output rules. + Index: close.html =================================================================== --- close.html (nonexistent) +++ close.html (revision 1765) @@ -0,0 +1,27 @@ + + +
    
    
    
    
    
    
    
    
        +NAME
    
    
    
    
    
    
    
    
        +       close - close a file descriptor
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +SYNOPSIS
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       int close(int fd);
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +DESCRIPTION
    
    
    
    
    
    
    
    
        +       close  closes  a  file  descriptor,  so  that it no longer
    
    
    
    
    
    
    
    
        +       refers to any file and may be reused.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       If fd is the last copy of a particular file descriptor the
    
    
    
    
    
    
    
    
        +       resources associated with it are freed.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +RETURN VALUE
    
    
    
    
    
    
    
    
        +       close returns zero on success, or -1 if an error occurred.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +ERRORS
    
    
    
    
    
    
    
    
        +       EBADF  fd isn't a valid open file descriptor.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    + + Index: setsockopt.man =================================================================== --- setsockopt.man (nonexistent) +++ setsockopt.man (revision 1765) @@ -0,0 +1,66 @@ +NAME + getsockopt, setsockopt - get and set options on sockets + +SYNOPSIS + #include + + int getsockopt(int s, int level, int optname, void *opt­ + val, socklen_t *optlen); + + int setsockopt(int s, int level, int optname, const void + *optval, socklen_t optlen); + +DESCRIPTION + Getsockopt and setsockopt manipulate the options associ­ + ated with a socket. Options may exist at multiple proto­ + col levels; they are always present at the uppermost + socket level. + + When manipulating socket options the level at which the + option resides and the name of the option must be speci­ + fied. To manipulate options at the socket level, level is + specified as SOL_SOCKET. To manipulate options at any + other level the protocol number of the appropriate proto­ + col controlling the option is supplied. For example, to + indicate that an option is to be interpreted by the TCP + protocol, level should be set to the protocol number of + TCP; see getprotoent(3). + + The parameters optval and optlen are used to access option + values for setsockopt. For getsockopt they identify a + buffer in which the value for the requested option(s) are + to be returned. For getsockopt, optlen is a value-result + parameter, initially containing the size of the buffer + pointed to by optval, and modified on return to indicate + the actual size of the value returned. If no option value + is to be supplied or returned, optval may be NULL. + + Optname and any specified options are passed uninterpreted + to the appropriate protocol module for interpretation. + The include file contains definitions for + socket level options, described below. Options at other + protocol levels vary in format and name; consult the + appropriate entries in section 4 of the manual. + + Most socket-level options utilize an int parameter for + optval. For setsockopt, the parameter should be non-zero + to enable a boolean option, or zero if the option is to be + disabled. + + For a description of the available socket options see + socket(7) and the appropriate protocol man pages. + +RETURN VALUE + On success, zero is returned. On error, -1 is returned, + and errno is set appropriately. + +ERRORS + EBADF The argument s is not a valid descriptor. + + ENOTSOCK + The argument s is a file, not a socket. + + ENOPROTOOPT + The option is unknown at the level indicated. + + Index: accept.man =================================================================== --- accept.man (nonexistent) +++ accept.man (revision 1765) @@ -0,0 +1,75 @@ +NAME + accept - accept a connection on a socket + +SYNOPSIS + #include + + int accept(int s, struct sockaddr *addr, int *addrlen); + +DESCRIPTION + The argument s is a socket that has been created with + socket(2), bound to an address with bind(2), and is lis- + tening for connections after a listen(2). The accept + function extracts the first connection request on the + queue of pending connections, creates a new socket with + the same properties of s, and allocates a new file + descriptor for the socket. If no pending connections are + present on the queue, and the socket is not marked as non- + blocking, accept blocks the caller until a connection is + present. If the socket is marked non-blocking and no + pending connections are present on the queue, accept + returns an error as described below. The socket returned + by accept may not be used to accept more connections. The + original socket s remains open. + + The argument addr is a result parameter that is filled in + with the address of the connecting entity, as known to the + communications layer. The exact format of the addr param- + eter is determined by the domain in which the communica- + tion is occurring. addrlen is a value-result parameter: + it should initially contain the amount of space pointed to + by addr; on return it will contain the actual length (in + bytes) of the address returned. This call is used with + connection-based socket types, currently with SOCK_STREAM. + + It is possible to select(2) a socket for the purposes of + doing an accept by selecting it for read. + + For certain protocols which require an explicit confirma- + tion, such as DECNet, accept can be thought of as merely + dequeuing the next connection request and not implying + confirmation. Confirmation can be implied by a normal + read or write on the new file descriptor, and rejection + can be implied by closing the new socket. Currently only + DECNet has these semantics on Linux. + +NOTES + If you want accept to never block the listening socket + needs to have the non blocking flag set. Assuming that + there is always a connection waiting after select returned + true is not reliable, because the connection might be + removed by an asynchronous network error between the + select/poll returning and the accept call. The application + would hang then if the listen socket is not non blocking. + +RETURN VALUES + The call returns -1 on error. If it succeeds, it returns + a non-negative integer that is a descriptor for the + accepted socket. + +ERRORS + EBADF The descriptor is invalid. + + ENOTSOCK + The descriptor references a file, not a socket. + + EOPNOTSUPP + The referenced socket is not of type SOCK_STREAM. + + EAGAIN The socket is marked non-blocking and no connec- + tions are present to be accepted. + + ENOBUFS, ENOMEM + Not enough free memory. + + Index: index.html =================================================================== --- index.html (nonexistent) +++ index.html (revision 1765) @@ -0,0 +1,27 @@ + + + + + + + + +
    +

    +eCos TCP/IP Networking Documentation (beta)

    +  +
  • +Introduction
  • + +
  • +Library Reference
  • + +
  • +Configuration
  • + +
  • +Tests and Examples
  • + +
      + + Index: read.html =================================================================== --- read.html (nonexistent) +++ read.html (revision 1765) @@ -0,0 +1,61 @@ + + +
    
    
    
    
    
    
    
    
        +NAME
    
    
    
    
    
    
    
    
        +       read - read from a file descriptor
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +SYNOPSIS
    
    
    
    
    
    
    
    
        +       ssize_t read(int fd, void *buf, size_t count);
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +DESCRIPTION
    
    
    
    
    
    
    
    
        +       read()  attempts  to  read  up  to  count  bytes from file
    
    
    
    
    
    
    
    
        +       descriptor fd into the buffer starting at buf.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       If count is zero, read() returns zero  and  has  no  other
    
    
    
    
    
    
    
    
        +       results.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +RETURN VALUE
    
    
    
    
    
    
    
    
        +       On success, the number of bytes  read  is  returned  (zero
    
    
    
    
    
    
    
    
        +       indicates  end of file), and the file position is advanced
    
    
    
    
    
    
    
    
        +       by this number.  It is not an  error  if  this  number  is
    
    
    
    
    
    
    
    
        +       smaller  than the number of bytes requested; this may hap-
    
    
    
    
    
    
    
    
        +       pen for example because fewer bytes are actually available
    
    
    
    
    
    
    
    
        +       right  now (maybe because we were close to end-of-file, or
    
    
    
    
    
    
    
    
        +       because we are reading from a pipe, or from  a  terminal),
    
    
    
    
    
    
    
    
        +       or  because read() was interrupted by a signal.  On error,
    
    
    
    
    
    
    
    
        +       -1 is returned, and errno is set  appropriately.  In  this
    
    
    
    
    
    
    
    
        +       case  it is left unspecified whether the file position (if
    
    
    
    
    
    
    
    
        +       any) changes.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +ERRORS
    
    
    
    
    
    
    
    
        +       EINTR   The call was interrupted by a  signal  before  any
    
    
    
    
    
    
    
    
        +               data was read.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EAGAIN  Non-blocking  I/O  has  been selected using O_NON-
    
    
    
    
    
    
    
    
        +               BLOCK and no data was  immediately  available  for
    
    
    
    
    
    
    
    
        +               reading.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EIO     I/O  error.  This will happen for example when the
    
    
    
    
    
    
    
    
        +               process is in a background process group, tries to
    
    
    
    
    
    
    
    
        +               read  from  its  controlling tty, and either it is
    
    
    
    
    
    
    
    
        +               ignoring or blocking SIGTTIN or its process  group
    
    
    
    
    
    
    
    
        +               is  orphaned.   It  may also occur when there is a
    
    
    
    
    
    
    
    
        +               low-level I/O error while reading from a  disk  or
    
    
    
    
    
    
    
    
        +               tape.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EISDIR  fd refers to a directory.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EBADF   fd  is  not a valid file descriptor or is not open
    
    
    
    
    
    
    
    
        +               for reading.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       EINVAL  fd is attached to an object  which  is  unsuitable
    
    
    
    
    
    
    
    
        +               for reading.
    
    
    
    
    
    
    
    
        +
    
    
    
    
    
    
    
    
        +       Other  errors may occur, depending on the object connected
    
    
    
    
    
    
    
    
        +       to fd.  POSIX allows a  read  that  is  interrupted  after
    
    
    
    
    
    
    
    
        +       reading  some  data to return -1 (with errno set to EINTR)
    
    
    
    
    
    
    
    
        +       or to return the number of bytes already read.
    
    
    
    
    
    
    
    
        +
    + +

    powered by: WebSVN 2.1.0

    © copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.