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

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/ecos-2.0/packages/net/tcpip/v2_0/doc
    from Rev 27 to Rev 174
    Reverse comparison

Rev 27 → Rev 174

/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>
/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>
/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>
/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>
/socket.html
0,0 → 1,117
<html>
<body>
<pre>
NAME
socket - create an endpoint for communication
 
SYNOPSIS
#include &lt;network.h&gt;
 
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 &lt;network.h&gt;. 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 <sys/socket.h>.
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.
</pre>
</body>
</html>
/inet_addr.html
0,0 → 1,40
<html>
<body>
<pre>
NAME
inet_aton, inet_addr, inet_ntoa - Internet address
manipulation routines
 
SYNOPSIS
#include &lt;network.h&gt;
 
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
 
quent calls will overwrite.
 
</pre>
</body>
</html>
/write.html
0,0 → 1,42
<html>
<body>
<pre>
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
 
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.
</pre>
</body>
</html>
/sendto.html
0,0 → 1,106
<html>
<body>
<pre>
NAME
sendto - send a message from a socket
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
 
 
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.
 
 
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
 
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
 
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
 
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.
 
 
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.
</pre>
</body>
</html>
/getpeername.html
0,0 → 1,40
<html>
<body>
<pre>
NAME
getpeername - get name of connected peer
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
 
 
</pre>
</body>
</html>
/bridge.html
0,0 → 1,319
<html>
<body>
<pre>
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 <sys/sockio.h>.
 
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 <jason@thought.net> 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.
 
</pre>
</body>
</html>
/setsockopt.html
0,0 → 1,72
<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>
/inet_addr.man
0,0 → 1,34
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
 
quent calls will overwrite.
 
/getproto.html
0,0 → 1,48
<html>
<body>
<pre>
NAME
getprotobyname, getprotobynumber - get protocol entry
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
 
 
ture for the line that matches the protocol number number.
 
The protoent structure is defined in <netdb.h> 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.
 
 
</pre>
</body>
</html>
/tcpip_config.html
0,0 → 1,22
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; U; Linux 2.2.10 i686) [Netscape]">
</head>
<body>
 
<center>
<h1>
eCos TCP/IP Package Configuration</h1></center>
&nbsp;Follow these steps to enable networking:
<blockquote><tt>% ecosconfig add CYGPKG_NET</tt>
<br><tt>% ecosconfig add CYGPKG_NET_ETH_DRIVERS</tt></blockquote>
For the Motorola PowerPC (MBX/860) board:
<blockquote><tt>% ecosconfig add CYGPKG_NET_QUICC_ETH_DRIVERS</tt></blockquote>
For the Cirrus Logic EDB7xxx board:
<blockquote><tt>% ecosconfig add CYGPKG_NET_EDB7XXX_ETH_DRIVERS</tt></blockquote>
 
<br>&nbsp;
</body>
</html>
/listen.man
0,0 → 1,36
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.
/getsockname.man
0,0 → 1,31
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.
 
 
/sample_program.html
0,0 → 1,371
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; I; Linux 2.2.14 ppc) [Netscape]">
</head>
<body>
 
<center>
<h1>
Sample Networking Program</h1></center>
 
<p><br>This example is derived from the test program <tt>".../net/tcpip/v1_3_1/tests/ping_test.c"</tt>.
<br>&nbsp;
<blockquote><tt><font size=-1>//==========================================================================</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tests/ping_test.c</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Simple test of PING
(ICMP) and networking support</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//==========================================================================</font></tt>
<br><tt><font size=-1>//####BSDCOPYRIGHTBEGIN####</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>// -------------------------------------------</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>// Portions of this software may have been derived
from OpenBSD or other sources,</font></tt>
<br><tt><font size=-1>// and are covered by the appropriate copyright disclaimers
included herein.</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>// -------------------------------------------</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//####BSDCOPYRIGHTEND####</font></tt>
<br><tt><font size=-1>//==========================================================================</font></tt>
<br><tt><font size=-1>//#####DESCRIPTIONBEGIN####</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>// Author(s):&nbsp;&nbsp;&nbsp; gthomas</font></tt>
<br><tt><font size=-1>// Contributors: gthomas</font></tt>
<br><tt><font size=-1>// Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
2000-01-10</font></tt>
<br><tt><font size=-1>// Purpose:</font></tt>
<br><tt><font size=-1>// Description:</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//####DESCRIPTIONEND####</font></tt>
<br><tt><font size=-1>//</font></tt>
<br><tt><font size=-1>//==========================================================================</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>// PING test code</font></tt><b><tt><font size=-1></font></tt></b>
<p><b><tt><font size=-1>#include &lt;network.h></font></tt></b></blockquote>
This single include directive is all that is required to pick up the networking
support, including complete configuration information.
<blockquote><tt><font size=-1>#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL</font></tt>
<br><tt><font size=-1>static char stack[STACK_SIZE];</font></tt>
<br><tt><font size=-1>static cyg_thread thread_data;</font></tt>
<br><tt><font size=-1>static cyg_handle_t thread_handle;</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>#define NUM_PINGS 16</font></tt>
<br><tt><font size=-1>#define MAX_PACKET 4096</font></tt>
<br><tt><font size=-1>static unsigned char pkt1[MAX_PACKET], pkt2[MAX_PACKET];</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>#define UNIQUEID 0x1234</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>void</font></tt>
<br><tt><font size=-1>cyg_test_exit(void)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf("... Done\n");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; while (1) ;</font></tt>
<br><tt><font size=-1>}</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>void</font></tt>
<br><tt><font size=-1>pexit(char *s)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; perror(s);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_test_exit();</font></tt>
<br><tt><font size=-1>}</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>// Compute INET checksum</font></tt>
<br><tt><font size=-1>int</font></tt>
<br><tt><font size=-1>inet_cksum(u_short *addr, int len)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; register int nleft = len;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; register u_short *w = addr;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; register u_short answer;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; register u_int sum = 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; u_short odd_byte = 0;</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; /*</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp; Our algorithm is
simple, using a 32 bit accumulator (sum),</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp; we add sequential
16 bit words to it, and at the end, fold</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp; back all the carry
bits from the top 16 bits into the lower</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp; 16 bits.</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; */</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; while( nleft > 1 )&nbsp; {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum +=
*w++;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nleft
-= 2;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; /* mop up an odd byte, if necessary
*/</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; if( nleft == 1 ) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *(u_char
*)(&amp;odd_byte) = *(u_char *)w;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum +=
odd_byte;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; /*</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; * add back carry outs from
top 16 bits to low 16 bits</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp; */</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; sum = (sum >> 16) + (sum &amp;
0x0000ffff); /* add hi 16 to low 16 */</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; sum += (sum >> 16);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* add carry */</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; answer = ~sum;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* truncate to 16 bits */</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; return (answer);</font></tt>
<br><tt><font size=-1>}</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>static int</font></tt>
<br><tt><font size=-1>show_icmp(unsigned char *pkt, int len,</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
struct sockaddr_in *from, struct sockaddr_in *to)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_tick_count_t *tp, tv;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct ip *ip;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct icmp *icmp;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; tv = cyg_current_time();</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; ip = (struct ip *)pkt;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; if ((len &lt; sizeof(*ip)) ||
ip->ip_v != IPVERSION) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diag_printf("%s:
Short packet or not IP! - Len: %d, Version: %d\n",</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
inet_ntoa(from->sin_addr), len, ip->ip_v);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; icmp = (struct icmp *)(pkt + sizeof(*ip));</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; len -= (sizeof(*ip) + 8);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; tp = (cyg_tick_count_t *)&amp;icmp->icmp_data;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; if (icmp->icmp_type != ICMP_ECHOREPLY)
{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diag_printf("%s:
Invalid ICMP - type: %d\n",</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
inet_ntoa(from->sin_addr), icmp->icmp_type);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; if (icmp->icmp_id != UNIQUEID)
{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diag_printf("%s:
ICMP received for wrong id - sent: %x, recvd: %x\n",</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
inet_ntoa(from->sin_addr), UNIQUEID, icmp->icmp_id);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf("%d bytes from %s:
", len, inet_ntoa(from->sin_addr));</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf("icmp_seq=%d", icmp->icmp_seq);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf(", time=%dms\n", (int)(tv
- *tp)*10);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; return (from->sin_addr.s_addr
== to->sin_addr.s_addr);</font></tt>
<br><tt><font size=-1>}</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>static void</font></tt>
<br><tt><font size=-1>ping_host(int s, struct sockaddr_in *host)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct icmp *icmp = (struct icmp
*)pkt1;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; int icmp_len = 64;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; int seq, ok_recv, bogus_recv;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_tick_count_t *tp;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; long *dp;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct sockaddr_in from;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; int i, len, fromlen;</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; ok_recv = 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; bogus_recv = 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf("PING server %s\n",
<b>inet_ntoa(host->sin_addr)</b>);</font></tt></blockquote>
This function takes an IP address and returns a string representation.&nbsp;
Useful for printing the address.
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp; for (seq = 0;&nbsp; seq
&lt; NUM_PINGS;&nbsp; seq++) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Build
ICMP packet</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icmp->icmp_type
= ICMP_ECHO;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icmp->icmp_code
= 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icmp->icmp_cksum
= 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icmp->icmp_seq
= seq;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icmp->icmp_id
= 0x1234;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Set
up ping data</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tp = (cyg_tick_count_t
*)&amp;icmp->icmp_data;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *tp++
= cyg_current_time();</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dp = (long
*)tp;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i
= sizeof(*tp);&nbsp; i &lt; icmp_len;&nbsp; i += sizeof(*dp)) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
*dp++ = i;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add
checksum</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icmp->icmp_cksum
= inet_cksum( (u_short *)icmp, icmp_len+8);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Send
it off</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>if
(sendto(s, icmp, icmp_len+8, 0, (struct sockaddr *)host, sizeof(*host))
&lt; 0) {</b></font></tt></blockquote>
This function sends a single packet, in this case via the ICMP protocol.&nbsp;
The destination address is specified by the <tt>host</tt> argument.
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
perror("sendto");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
continue;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Wait
for a response</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fromlen
= sizeof(from);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>len
= recvfrom(s, pkt2, sizeof(pkt2), 0, (struct sockaddr *)&amp;from, &amp;fromlen);</b></font></tt></blockquote>
This function waits for a packet to be sent to this interface.&nbsp; Note:
this operation can fail if no packet is received with a given amount of
time (this timeout value is setup in the <tt>ping_test()</tt> routine below).
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (len &lt; 0) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
perror("recvfrom");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else
{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (show_icmp(pkt2, len, &amp;from, host)) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ok_recv++;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} else {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
bogus_recv++;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf("Sent %d packets,
received %d OK, %d bad\n", NUM_PINGS, ok_recv, bogus_recv);</font></tt>
<br><tt><font size=-1>}</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>static void</font></tt>
<br><tt><font size=-1>ping_test(struct bootp *bp)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct protoent *p;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct timeval tv;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; struct sockaddr_in host;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; int s;</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; <b>if ((p = getprotobyname("icmp"))
== (struct protoent *)0) {</b></font></tt></blockquote>
This function gets information about the ICMP protocol.&nbsp; This will
be used below to set up the "socket" (the handle to a network connection).
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
perror("getprotobyname");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; <b>s = socket(AF_INET, SOCK_RAW,
p->p_proto);</b></font></tt></blockquote>
Create the socket "s".&nbsp; A socket is an abstract object (sometimes
called a handle or endpoint).&nbsp; Sockets come in many flavors, RAW sockets
are used for communicating with non-structured protocols.&nbsp; DATAGRAM
sockets are used for packet oriented protocols, such as UDP.&nbsp; STREAM
sockets are used for reliable, sequenced byte streams, such as those provided
by TCP.
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp; if (s &lt; 0) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; perror("socket");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; tv.tv_sec = 1;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; tv.tv_usec = 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; <b>setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
&amp;tv, sizeof(tv));</b></font></tt></blockquote>
This function instructs the system that receive operations (see <tt>ping_host()</tt>
above) must complete within 1 second or issue a timed out error condition.
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp; // Set up host address</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; host.sin_family = AF_INET;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; host.sin_addr = bp->bp_siaddr;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; host.sin_port = 0;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; ping_host(s, &amp;host);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; // Now try a bogus host</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr)
+ 32);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; ping_host(s, &amp;host);</font></tt>
<br><tt><font size=-1>}</font></tt>
<br><tt><font size=-1></font></tt>&nbsp;</blockquote>
This function drives the test.
<blockquote><tt><font size=-1>void</font></tt>
<br><tt><font size=-1>net_test(cyg_addrword_t p)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; diag_printf("Start PING test\n");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; <b>init_all_network_interfaces();</b></font></tt></blockquote>
This is a call to the network initialization code.&nbsp; Note that it must
be executed from a thread context, thus we can't put it in the <tt>cyg_start()
</tt>function which follows.&nbsp; The <tt>init_all_network_interfaces()</tt>
routine will cause the networking system to be initialized and any hardware
interfaces will be set up.&nbsp; Using the system configuration information,
an interface can be started using either <b>BOOTP</b>,&nbsp; or a predefined
configuration with static IP information.&nbsp; It is also possible to
indicate that an interface will be configured by the user code, outside
of "<tt>init_all_network_interfaces()</tt>".
<br><tt><font size=-1>&nbsp;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; #ifdef CYGHWR_NET_DRIVER_ETH0</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (eth0_up)
{</font></tt>
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ping_test(&amp;eth0_bootp_data);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>#endif</font></tt></blockquote>
Notice that there is a BOOTP information structure kept about all hardware
interfaces.&nbsp; This is created and initialized by the call to <tt>init_all_network_interfaces()</tt>,
unless manual configuration is selected.&nbsp; This information can be
used by the application to learn things such as the local IP address, server
name, etc.
<blockquote><tt><font size=-1>#ifdef CYGHWR_NET_DRIVER_ETH1</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; if (eth1_up) {</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ping_test(&amp;eth1_bootp_data);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; }</font></tt>
<br><tt><font size=-1>#endif</font></tt></blockquote>
Multiple hardware interfaces can be supported, depending on the hardware
platform.&nbsp; If the platform provides a single ethernet device then&nbsp;
<b><tt>CYGHWR_NET_DRIVER_ETH0 </tt></b>will be defined.&nbsp; If there
is a second interface, then will <b><tt>CYGHWR_NET_DRIVER_ETH1 </tt></b>be
defined.
<blockquote><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_test_exit();</font></tt>
<br><tt><font size=-1>}</font></tt>
<br><tt><font size=-1></font></tt>&nbsp;</blockquote>
The following function creates an initial thread which runs the program.&nbsp;
This could just as easily be done by naming the <tt>net_test()</tt> function
<tt>main()</tt>.
<blockquote><tt><font size=-1>void</font></tt>
<br><tt><font size=-1>cyg_start(void)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; // Create a main thread, so we
can run the scheduler and have time 'pass'</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_thread_create(10,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Priority - just a number</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
net_test,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // entry</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// entry parameter</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"Network test",&nbsp;&nbsp;&nbsp; // Name</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;stack[0],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Stack</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
STACK_SIZE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Size</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;thread_handle,&nbsp;&nbsp;&nbsp; // Handle</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;thread_data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Thread data structure</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_thread_resume(thread_handle);&nbsp;
// Start it</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; cyg_scheduler_start();</font></tt>
<br><tt><font size=-1>}</font></tt></blockquote>
 
</body>
</html>
/getproto.man
0,0 → 1,42
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.
 
 
ture for the line that matches the protocol number number.
 
The protoent structure is defined in <netdb.h> 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.
 
 
/ioctl.html
0,0 → 1,46
<html>
<body>
<pre>
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.
</pre>
</body>
</html>
/shutdown.html
0,0 → 1,33
<html>
<body>
<pre>
NAME
shutdown - shut down part of a full-duplex connection
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
</pre>
</body>
</html>
/shutdown.man
0,0 → 1,27
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.
/recvfrom.html
0,0 → 1,159
<html>
<body>
<pre>
NAME
recvfrom - receive a message from a socket
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
 
 
 
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
 
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
 
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
 
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
 
dent on the protocol (for IP IP_RECVERR). The
 
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.
 
 
 
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.
 
 
nal before any data were available.
 
EINVAL Invalid argument passed.
</pre>
</body>
</html>
/bind.man
0,0 → 1,58
NAME
bind - bind a name to a socket
 
SYNOPSIS
#include <network.h>
 
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.
 
 
/ecos_tcpip.html
0,0 → 1,88
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; U; Linux 2.2.10 i686) [Netscape]">
</head>
<body>
 
<center>
<h1>
TCP/IP Networking for eCos</h1></center>
eCos now provides a complete TCP/IP networking stack.&nbsp; This package
was derived from the latest stable release of <a href="http://www.openbsd.org/">OpenBSD</a>.&nbsp;&nbsp;
At this time, the networking support is considered "beta" quality although
it is already fully featured and well tested within the eCos environment.
<p>Ethernet drivers are provided for these standard supported platforms:
<blockquote>
<li>
Motorola PowerPC MBX/860</li>
 
<li>
Cirrus Logic EDB72xx</li>
</blockquote>
Other drivers for supported platforms are planned or underway.
<h4>
Networking Stack Features</h4>
Since this networking package is based on the venerable BSD code, it is
very complete and robust.&nbsp; The eCos implementation includes support
for these protocols:
<blockquote>
<li>
IPv4</li>
 
<li>
UDP</li>
 
<li>
TCP</li>
 
<li>
ICMP</li>
 
<li>
raw packet interface</li>
</blockquote>
These additional features are also present in the package.&nbsp; However
they are not yet supported:
<blockquote>
<li>
Berkeley Packet Filter</li>
 
<li>
Multi-cast and uni-cast support, including multi-casting routing</li>
 
<li>
IPv6</li>
</blockquote>
 
<h4>
Provided Documentation</h4>
Since the networking package is "beta", documentation is still a bit thin.&nbsp;
However, you will find a complete set of pages documenting the supported
networking functions (user code API) <a href="tcpip_library.html">here</a>.
<h4>
Ethernet Driver Design</h4>
Note: Currently, the networking stack only supports ethernet based networking.
<p>The network drivers use a two-layer design.&nbsp; One layer is hardware
independent but contains all the stack specific code.&nbsp; The other layer
is platform dependent and communicates with the hardware independent layer
via a very simple API.&nbsp; In this way, hardware device drivers can actually
be used with other stacks, if the same API can be provided by that stack.&nbsp;
We designed the drivers this way to encourage the development of other
stacks in eCos while allowing reuse of the actual hardware specific code.
<p>Complete documentation of the ethernet device driver and the associated
API can be found in the file <tt>net/drivers/eth/common/<i>version</i>/doc/driver_doc</tt>.
<h4>
Sample Code</h4>
Many examples using the networking support are provided.&nbsp; These are
arranged as eCos test programs, primarily for us to verify the package,
but also can serve as useful frameworks for program design.&nbsp; We have
taken a <i>KISS </i>approach to building programs which use the network.&nbsp;
A single include file <tt>&lt;network.h></tt> is all that is required to
access the stack.&nbsp; A complete, annotated test program can be found
<a href="sample_program.html">here</a>.
<br>&nbsp;
<br>&nbsp;
</body>
</html>
/getsockopt.man
0,0 → 1,65
NAME
getsockopt, setsockopt - get and set options on sockets
 
SYNOPSIS
#include <network.h>
 
 
 
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 <sys/socket.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.
/connect.html
0,0 → 1,81
<html>
<body>
<pre>
NAME
connect - initiate a connection on a socket
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
</pre>
</body>
</html>
/recvfrom.man
0,0 → 1,152
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.
 
 
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
 
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
 
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
 
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
 
dent on the protocol (for IP IP_RECVERR). The
 
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.
 
 
 
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.
 
 
nal before any data were available.
 
EINVAL Invalid argument passed.
/listen.html
0,0 → 1,42
<html>
<body>
<pre>
NAME
listen - listen for connections on a socket
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
</pre>
</body>
</html>
/accept.html
0,0 → 1,81
<html>
<body>
<pre>
NAME
accept - accept a connection on a socket
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
 
 
</pre>
</body>
</html>
/socket.man
0,0 → 1,111
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 <sys/socket.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 <sys/socket.h>.
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.
/getsockname.html
0,0 → 1,37
<html>
<body>
<pre>
NAME
getsockname - get socket name
 
SYNOPSIS
#include &lt;network.h&gt;
 
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.
 
 
</pre>
</body>
</html>
/connect.man
0,0 → 1,75
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.
/tcpip_tests.html
0,0 → 1,98
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; I; Linux 2.2.14 ppc) [Netscape]">
</head>
<body>
 
<center>
<h1>
eCos TCP/IP Networking Tests and Examples</h1></center>
A number of test/example programs are currently provided with the TCP/IP
networking package.&nbsp; These are not "tests" in the traditional eCos
test suite sense, but rather simple programs which exercise various parts
of the networking stack.&nbsp; Also included are a set of performance tests,
used to measure throughput and latency in an embedded eCos system.
<p>The following paragraphs list the various tests and how they might be
used.&nbsp;&nbsp; They are enumerated in the order in which they should
be run to verify a system configuration.
<p>Note: none of these tests are built by default.&nbsp; The user must
enable the <b><tt>CYGPKG_NET_BUILD_TESTS </tt></b>option and then "<tt>make
tests</tt>" to create them for the target environment.&nbsp; Also, these
tests require that the hardware interfaces be configured to use either
BOOTP or static initialization methods.
<h3>
mbuf_test.c</h3>
This should be the first test run on a new system.&nbsp; It simply tests
that the networking system can be initialized and that the internal memory
management (used by the stack) is functioning.
<h3>
socket_test.c</h3>
This test exercises some of the basic library interfaces.
<h3>
server_test.c</h3>
This test creates a server process on the target hardware which listens
on port TCP/7734.&nbsp; To verify that it is working, try to connect to
this port from some other [host] system.&nbsp; E.g. on Linux, use the command
"<tt>telnet <i>eCos</i> 7734</tt>", where "<i><tt>eCos</tt></i>" is the
name associated with the target hardware.&nbsp; 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.
<h3>
ping_test.c</h3>
This tests attempts to issue an ICMP "echo" request to the "server" host
(provided as part of the BOOTP or static configuration information).&nbsp;
The output will be similar to the analogous Linux program, "<tt>ping</tt>".&nbsp;
The test program also attempts to ping an additional host whose IP address
is the server IP+32.&nbsp; This second test is present to verify that the
ICMP (actually <tt>receive</tt>) time-out mechanism is working (assuming
that the second host is non-existent).
<h3>
ftp_test.c</h3>
This test attempts to make a connection to an FTP server, assuming the
default server host.&nbsp; This is an additional test which verifies that
the basic TCP functionality is working.
<h3>
nc_test_master.c</h3>
 
<h3>
nc_test_slave.c</h3>
This pair of programs can be used to measure throughput and latencies in
the target system.&nbsp; 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 "<tt>nc_test_master</tt>" program on a Linux host
and the "<tt>nc_test_slave</tt>" on the target hardware.&nbsp; 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.&nbsp; Additionally,
measurements will be made on an eCos slave of the actual CPU utilization
by the networking stack.
<p>To build the Linux versions, simply execute (in the eCos source tree,
not the install tree):
<blockquote><tt>make -f make.linux</tt></blockquote>
 
<h3>
tcp_echo.c</h3>
 
<h3>
tcp_sink.c</h3>
 
<h3>
tcp_source.c</h3>
This set of programs is similar to the <i><tt>nc_test_XXX</tt></i> programs
described above.&nbsp; However, they are designed to measure overall throughput
of the eCos system.&nbsp; The setup allows for one Linux host to run "<tt>tcp_source
<i>eCos</i></tt>" and another Linux host to run "<tt>tcp_sink <i>eCos</i></tt>".&nbsp;
The "<tt>tcp_echo</tt>" program is run on the target hardware.&nbsp; 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.&nbsp; Note:
the two Linux host systems may be the same computer in which case this
becomes a single wire echo test.&nbsp; This test suite is unique in that
it attempts to load the target system down with additional background processing
at various levels.&nbsp; This is done to simulate a real world environment
where the networking is ancillary to the main processing on the target
system.
<br>&nbsp;
</body>
</html>
/write.man
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
 
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.
/bridge.man
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 <sys/sockio.h>.
 
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 <jason@thought.net> 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.
 
/getpeername.man
0,0 → 1,34
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.
 
 
/sendto.man
0,0 → 1,100
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.
 
 
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.
 
 
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
 
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
 
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
 
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.
 
 
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.
/tcpip_library.html
0,0 → 1,77
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; I; Linux 2.2.14 ppc) [Netscape]">
</head>
<body>
 
<center>
<h1>
TCP/IP Library Reference</h1></center>
 
<li>
<a href="accept.html">accept</a></li>
 
<li>
<a href="bind.html">bind</a></li>
 
<li>
<a href="close.html">close</a></li>
 
<li>
<a href="connect.html">connect</a></li>
 
<li>
<a href="gethost.html">gethostbyname, gethostbyaddr</a></li>
 
<li>
<a href="getpeername.html">getpeername</a></li>
 
<li>
<a href="getproto.html">getprotobyname, getprotobynumber</a></li>
 
<li>
<a href="getserv.html">getservbyname, getservbyport</a></li>
 
<li>
<a href="getsockname.html">getsockname</a></li>
 
<li>
<a href="getsockopt.html">getsockopt</a></li>
 
<li>
<a href="inet_addr.html">inet_aton, inet_addr, inet_addr</a></li>
 
<li>
<a href="ioctl.html">ioctl</a></li>
 
<li>
<a href="listen.html">listen</a></li>
 
<li>
<a href="read.html">read</a></li>
 
<li>
<a href="recvfrom.html">recvfrom</a></li>
 
<li>
<a href="select.html">select</a></li>
 
<li>
<a href="sendto.html">sendto</a></li>
 
<li>
<a href="setsockopt.html">setsockopt</a></li>
 
<li>
<a href="shutdown.html">shutdown</a></li>
 
<li>
<a href="socket.html">socket</a></li>
 
<li>
<a href="write.html">write</a></li>
 
</body>
</html>
/close.html
0,0 → 1,27
<html>
<body>
<pre>
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.
 
 
</pre>
</body>
</html>
/setsockopt.man
0,0 → 1,66
NAME
getsockopt, setsockopt - get and set options on sockets
 
SYNOPSIS
#include <network.h>
 
 
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 <sys/socket.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.
 
 
/accept.man
0,0 → 1,75
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.html
0,0 → 1,27
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; I; Linux 2.2.14 ppc) [Netscape]">
</head>
<body>
 
<center>
<h1>
eCos TCP/IP Networking Documentation (beta)</h1></center>
&nbsp;
<li>
<a href="ecos_tcpip.html">Introduction</a></li>
 
<li>
<a href="tcpip_library.html">Library Reference</a></li>
 
<li>
<a href="tcpip_config.html">Configuration</a></li>
 
<li>
<a href="tcpip_tests.html">Tests and Examples</a></li>
 
<br>&nbsp;
</body>
</html>
/read.html
0,0 → 1,61
<html>
<body>
<pre>
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.
</pre>
</body>
</html>

powered by: WebSVN 2.1.0

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