summaryrefslogtreecommitdiff
path: root/ecos/packages/net/autotest/current
diff options
context:
space:
mode:
authorMichael Gielda <mgielda@antmicro.com>2014-04-03 14:53:04 +0200
committerMichael Gielda <mgielda@antmicro.com>2014-04-03 14:53:04 +0200
commitae1e4e08a1005a0c487f03ba189d7536e7fdcba6 (patch)
treef1c296f8a966a9a39876b0e98e16d9c5da1776dd /ecos/packages/net/autotest/current
parentf157da5337118d3c5cd464266796de4262ac9dbd (diff)
Added the OS files
Diffstat (limited to 'ecos/packages/net/autotest/current')
-rw-r--r--ecos/packages/net/autotest/current/ChangeLog297
-rw-r--r--ecos/packages/net/autotest/current/cdl/net_autotest.cdl123
-rw-r--r--ecos/packages/net/autotest/current/doc/host.txt414
-rw-r--r--ecos/packages/net/autotest/current/doc/strategy.txt237
-rw-r--r--ecos/packages/net/autotest/current/host/_suping.c14
-rw-r--r--ecos/packages/net/autotest/current/host/awaitorder.c151
-rwxr-xr-xecos/packages/net/autotest/current/host/floodping.sh86
-rw-r--r--ecos/packages/net/autotest/current/host/makefile19
-rwxr-xr-xecos/packages/net/autotest/current/host/obey.sh83
-rwxr-xr-xecos/packages/net/autotest/current/host/sendack.sh42
-rwxr-xr-xecos/packages/net/autotest/current/host/slowping.sh50
-rwxr-xr-xecos/packages/net/autotest/current/host/snmpwalk.sh51
-rwxr-xr-xecos/packages/net/autotest/current/host/tftpget.sh104
-rwxr-xr-xecos/packages/net/autotest/current/host/tftpput.sh80
-rw-r--r--ecos/packages/net/autotest/current/host/tmpfile.c142
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_bootp.ptest13
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_corrupt.ptest19
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_failrx.ptest19
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_failtx.ptest19
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_rt.ptest13
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_snmp.ptest11
-rw-r--r--ecos/packages/net/autotest/current/permtests/netauto_std.ptest10
-rw-r--r--ecos/packages/net/autotest/current/tests/autohost.inl365
-rw-r--r--ecos/packages/net/autotest/current/tests/floodping.c181
-rw-r--r--ecos/packages/net/autotest/current/tests/floodpingmux.c464
-rw-r--r--ecos/packages/net/autotest/current/tests/memcheck.inl130
-rw-r--r--ecos/packages/net/autotest/current/tests/route_3.c74
-rw-r--r--ecos/packages/net/autotest/current/tests/route_3_4.c74
-rw-r--r--ecos/packages/net/autotest/current/tests/route_4.c74
-rw-r--r--ecos/packages/net/autotest/current/tests/route_none.c74
-rw-r--r--ecos/packages/net/autotest/current/tests/routeping.inl638
-rw-r--r--ecos/packages/net/autotest/current/tests/slowping.c199
-rw-r--r--ecos/packages/net/autotest/current/tests/slowpingmux.c389
-rw-r--r--ecos/packages/net/autotest/current/tests/snmpmulti.c201
-rw-r--r--ecos/packages/net/autotest/current/tests/snmppings.c249
-rw-r--r--ecos/packages/net/autotest/current/tests/snmpwalk.c201
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv.inl227
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_g0.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_g1M.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_g512.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_get.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_p0.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_p1M.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_p512.c72
-rw-r--r--ecos/packages/net/autotest/current/tests/tftp_serv_put.c72
45 files changed, 6113 insertions, 0 deletions
diff --git a/ecos/packages/net/autotest/current/ChangeLog b/ecos/packages/net/autotest/current/ChangeLog
new file mode 100644
index 0000000..7b74130
--- /dev/null
+++ b/ecos/packages/net/autotest/current/ChangeLog
@@ -0,0 +1,297 @@
+2009-11-13 John Dallaway <john@dallaway.org.uk>
+
+ * cdl/net_autotest.cdl: Specify test executable names for
+ compatibility with the eCos Configuration Tool.
+
+2002-02-01 Gary Thomas <gthomas@redhat.com>
+
+ * tests/slowpingmux.c (ping_test):
+ * tests/routeping.inl: (ping_test):
+ * tests/floodpingmux.c: (net_test):
+ * tests/autohost.inl (autohost_tell):
+ * host/awaitorder.c (main): Need valid value for sin_len.
+
+2001-10-10 Hugo Tyson <hmt@redhat.com>
+
+ * tests/floodping.c:
+ * tests/floodpingmux.c:
+ * tests/snmpmulti.c:
+ * tests/snmppings.c:
+ * tests/snmpwalk.c:
+ More conditional compilation needed for use of eth0_up, eth1_up
+ and the like, since the config opt is now a boolean and so these
+ might not exist.
+
+2001-06-26 Hugo Tyson <hmt@redhat.com>
+
+ * tests/routeping.inl (route_add_s): Add a close to the socket.
+ Don't be upset if you can't ping www.cygnus.com by number!
+
+2000-12-08 Hugo Tyson <hmt@redhat.com>
+
+ * host/tftpget.sh (TARGET): Try a little harder to put a correct
+ test dataset into the target; we are testing GET not PUT here. We
+ are seeing get fails of 1Mb data on the zeroth try; it could be a
+ real get bug, or problems putting the original image. This change
+ should help diagnose which.
+
+ * tests/slowpingmux.c (ping_host): Make this much less verbose in
+ [good] output; the farm rejects too much chatter.
+
+2000-11-17 Hugo Tyson <hmt@redhat.com>
+
+ * tests/memcheck.inl (memcheck_final): Ignore clusters if
+ simulating network failures; I guess memory is used up with
+ partial packets awaiting reassembly, and they'll time out.
+
+ * tests/routeping.inl (net_test): Call TNR_ON/OFF() correctly.
+
+ * tests/slowpingmux.c (net_test): Call TNR_ON/OFF() correctly.
+
+ * tests/floodpingmux.c (net_test): Only call TNR_INIT() once.
+ Call TNR_OFF(); again after dumpstats() turned it on again.
+ Call TNR_ON/OFF() correctly.
+
+ * tests/autohost.inl (autohost_getresults): Add a missing
+ semicolon. Doh! Only a problem with realtime test harness
+ enabled.
+
+2000-11-15 Hugo Tyson <hmt@redhat.com>
+
+ * doc/host.txt: Updated.
+
+2000-11-15 Hugo Tyson <hmt@redhat.com>
+
+ * cdl/net_autotest.cdl: Build the new tests.
+
+ * tests/routeping.inl: New file: the meat of a testcase to check
+ that external networks are only accessible if we have added a
+ suitable route. This requires a further network called 10.0.3.x
+ attached to the machine that serves DHCP to eth0, and one called
+ 10.0.4.x on the server for eth1. These can both be aliases for
+ loopback on the linux host if needs be.
+
+ * tests/route_none.c:
+ * tests/route_3.c:
+ * tests/route_4.c:
+ * tests/route_3_4.c:
+ New files: Various invocations of the above. These just make a
+ few #defines then #include "routeping.inl"
+
+2000-11-10 Hugo Tyson <hmt@redhat.com>
+
+ * tests/autohost.inl (autohost_init): Call the memory checking
+ init and finalization functions in the appropriate places.
+
+ * tests/memcheck.inl (RATIO): New file; check for mbuf &c leaks
+ (if the API is defined in network.h, so it it'll work with the 144
+ tarball). We allow either as much again or 15% of memory to be
+ used at the end of the test, for each of the 3 memory regions the
+ stack uses.
+
+ * tests/floodpingmux.c (net_test): Don't print out mbuf &c usage,
+ leave it up to the memory checking subsystem.
+
+2000-11-10 Hugo Tyson <hmt@redhat.com>
+
+ * host/obey.sh: Handle the new case of doing snmpwalk and
+ snmpstatus to the target. (SNMP_WALK)
+
+ * cdl/net_autotest.cdl: Build the new tests.
+
+ * host/snmpwalk.sh: New file: snmpwalk the target's public MIB and
+ check target status for the timeout. Much like the other cases.
+
+ * tests/snmpwalk.c: New file: do one snmpwalk session on each
+ interface.
+
+ * tests/snmpmulti.c: New file: ditto, 3 sessions per i/f.
+
+ * tests/snmppings.c: New file: ditto, 2 x snmp, plus some pinging
+ and flood pinging simulataneously.
+
+2000-11-09 Hugo Tyson <hmt@redhat.com>
+
+ * host/obey.sh: Handle the new case of flood pinging the
+ target. (FLOOD_PING)
+
+ * host/floodping.sh: New file: flood ping the target, with a
+ variable active/sleep ratio so that we can use this to perturb
+ other tests also. An suid executable "./_suping" is needed to be
+ able to flood ping automatically.
+
+ * cdl/net_autotest.cdl: Build the two new tests.
+
+ * tests/floodping.c: New file: ask the host to flood ping me, for
+ 5 minutes in the usual manner.
+
+ * tests/floodpingmux.c: New file: as floodping.c and the target
+ floods the host in turn also.
+
+ * host/makefile: Build _suping: it must be set uid &c manually.
+
+ * host/_suping.c: New file: a tiny su root program to run ping
+ with real uid root (ping is suid root anyway) to allow us to flood
+ the target.
+
+2000-11-08 Hugo Tyson <hmt@redhat.com>
+
+ * tests/autohost.inl (XFAIL): Detect the configuration that means
+ simulated unreliable network is enabled. Send the XFAIL parameter
+ to the network testing server if so. Also do not check for the
+ count of pass messages required in the autohost_end() routine; we
+ expect them to go missing and/or there to be failures per se.
+
+ * host/obey.sh (XFAIL): Detect and pass through the XFAIL
+ parameter to indicate simulated unreliable network is enabled.
+
+ * host/tftpget.sh (XFAIL):
+ * host/tftpput.sh (XFAIL):
+ * host/slowping.sh (XFAIL): If XFAIL, do not report failures as
+ such; also echo the process ID ($$) in messages to help untangle
+ the interleaved status messages.
+
+ * host/sendack.sh (XFAIL): Try less zealously and moan less loudly
+ if failure is expected.
+
+ * doc/host.txt: Document XFAIL stuff.
+
+2000-10-26 Hugo Tyson <hmt@redhat.com>
+
+ * tests/slowping.c (net_test): New file:
+ * tests/slowpingmux.c (net_test): New file: simple test, the host
+ pings the target (a lot, 10x simultaneously), while the target
+ also pings the host in slowpingmux.
+
+ * host/slowping.sh (TARGET): New file: handle target side of ping
+ testing.
+
+ * cdl/net_autotest.cdl: Build the new tests.
+
+2000-10-26 Hugo Tyson <hmt@redhat.com>
+
+ * tests/tftp_serv.inl (do_tftp_tests): Fix typo in info printf;
+ nothing of substance.
+
+2000-10-25 Hugo Tyson <hmt@redhat.com>
+
+ * permtests/netauto_bootp.ptest: net with bootp only init.
+ * permtests/netauto_corrupt.ptest: net + 10% rx corruption.
+ * permtests/netauto_failrx.ptest: net + 10% rx discards.
+ * permtests/netauto_failtx.ptest: net + 10% tx discards.
+ * permtests/netauto_rt.ptest: net + snmp + realtime test.
+ * permtests/netauto_snmp.ptest: net + snmp.
+ * permtests/netauto_std.ptest: standard net config
+ New files; permtest configurations for farm testing.
+
+2000-10-24 Hugo Tyson <hmt@redhat.com>
+
+ * doc/host.txt: More info added; kept up to date.
+
+2000-10-24 Hugo Tyson <hmt@redhat.com>
+
+ * tests/tftp_serv.inl: New file, the guts of both tftp_serv_get.c
+ and tftp_serv_put.c removed to here, so that a number of tests can
+ be created to hit the server with different sizes of datafile.
+ This is the easiest way to test lots of different filesizes and
+ edge conditions; just replicate the testcase.
+
+ * tests/tftp_serv_put.c (FILESIZE):
+ * tests/tftp_serv_get.c (FILESIZE): Use "tftp_serv.inl" with a
+ coupla #defines for the op and the filesize to implement the test.
+
+ * tests/tftp_serv_g0.c: New: get zero and 1-byte datafiles.
+ * tests/tftp_serv_g1M.c: New: get 1Mb and 1Mb-1 datafiles.
+ * tests/tftp_serv_g512.c: New: get 512 and 513-byte datafiles.
+ * tests/tftp_serv_p0.c: New: put zero and 1-byte datafiles.
+ * tests/tftp_serv_p1M.c: New: put 1Mb and 1Mb-1 datafiles.
+ * tests/tftp_serv_p512.c: New: put 512 and 513-byte datafiles.
+
+ * cdl/net_autotest.cdl: Build all the new testcases to diddle
+ different file sizes.
+
+ * host/tftpput.sh (TARGET): Do not read back the file every time;
+ check the gotton file once at the end correctly; count up the
+ transfers for info.
+
+ * host/tftpget.sh (TARGET): Check the gotton file correctly; count
+ up the transfers for info.
+
+2000-10-23 Hugo Tyson <hmt@redhat.com>
+
+ * host/tftpdata.src: DELETED: we now make our own data files on
+ the fly.
+
+ * host/makefile (tmpfile): Build this. Also add a make clean.
+
+ * host/tmpfile.c (main): New file: builds to a simple executable
+ that makes a scratch file full of random data of the length
+ requested. A simple but order-sensitive checksum is appended,
+ though the testcase doesn't use this yet.
+
+ * tests/tftp_serv_put.c (do_tftp_tests):
+ * tests/tftp_serv_get.c (do_tftp_tests): Pass a filesize to the
+ test script; it will make a temp file accordingly.
+
+ * host/tftpput.sh:
+ * host/tftpget.sh: Parameterize these more so that they accept a
+ filesize; the data file is created with random data.
+
+2000-10-20 Hugo Tyson <hmt@redhat.com>
+
+ * doc/host.txt: New file. Details the host side code, scripts,
+ environment, tempfiles, conventions, output...
+
+ * doc/strategy.txt: New file. The original design notes.
+
+ * host/obey.sh: Correct typo and add . to the path; stupid
+ pedantic environment.
+
+2000-10-20 Hugo Tyson <hmt@redhat.com>
+
+ * tests/tftp_serv_get.c (net_test):
+ * tests/tftp_serv_put.c (net_test): Use the new API, and remember
+ how many host sessions we expected to invoke.
+
+ * tests/autohost.inl (autohost_end): New API to check counts of
+ PASS and FAIL statii from the hosts.
+
+2000-10-19 Hugo Tyson <hmt@redhat.com>
+
+ * Changelog: New file.
+ * cdl/net_autotest.cdl: New file.
+ * host/awaitorder.c: New file.
+ * host/makefile: New file.
+ * host/obey.sh: New file.
+ * host/sendack.sh: New file.
+ * host/tftpdata.src: New file.
+ * host/tftpget.sh: New file.
+ * host/tftpput.sh: New file.
+ * tests/autohost.inl: New file.
+ * tests/tftp_serv_get.c: New file.
+ * tests/tftp_serv_put.c: New file.
+ Indeed a new package, even. Documentation will be forthcoming.
+
+//===========================================================================
+// ####GPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 or (at your option) any
+// later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc., 51 Franklin Street,
+// Fifth Floor, Boston, MA 02110-1301, USA.
+// -------------------------------------------
+// ####GPLCOPYRIGHTEND####
+//===========================================================================
diff --git a/ecos/packages/net/autotest/current/cdl/net_autotest.cdl b/ecos/packages/net/autotest/current/cdl/net_autotest.cdl
new file mode 100644
index 0000000..3b89b73
--- /dev/null
+++ b/ecos/packages/net/autotest/current/cdl/net_autotest.cdl
@@ -0,0 +1,123 @@
+# ====================================================================
+#
+# net_autotest.cdl
+#
+# Networking autotest subsystem configuration data
+#
+# ====================================================================
+## ####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
+##
+## eCos is free software; you can redistribute it and/or modify it under
+## the terms of the GNU General Public License as published by the Free
+## Software Foundation; either version 2 or (at your option) any later
+## version.
+##
+## eCos is distributed in the hope that it will be useful, but WITHOUT
+## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with eCos; if not, write to the Free Software Foundation, Inc.,
+## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+##
+## As a special exception, if other files instantiate templates or use
+## macros or inline functions from this file, or you compile this file
+## and link it with other works to produce a work based on this file,
+## this file does not by itself cause the resulting work to be covered by
+## the GNU General Public License. However the source code for this file
+## must still be made available in accordance with section (3) of the GNU
+## General Public License v2.
+##
+## This exception does not invalidate any other reasons why a work based
+## on this file might be covered by the GNU General Public License.
+## -------------------------------------------
+## ####ECOSGPLCOPYRIGHTEND####
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s): hmt
+# Original data: hmt
+# Contributors:
+# Date: 2000-10-19
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+
+cdl_package CYGPKG_NET_AUTOTEST {
+ display "Networking autotest"
+ doc doc/index.html
+ include_dir net/autotest
+ requires CYGPKG_IO
+ requires CYGPKG_ISOINFRA
+ requires CYGPKG_LIBC_TIME
+ requires CYGPKG_ERROR
+ requires CYGPKG_MEMALLOC
+ requires CYGPKG_NET
+ description "Networking autotest facilities"
+
+# compile *NONE*
+
+ cdl_option CYGPKG_NET_AUTOTEST_TESTS {
+ display "Networking tests"
+ flavor data
+ no_define
+ calculated { "\
+ tests/floodping \
+ tests/floodpingmux \
+ tests/route_3 \
+ tests/route_3_4 \
+ tests/route_4 \
+ tests/route_none \
+ tests/slowping \
+ tests/slowpingmux \
+ tests/snmpwalk \
+ tests/snmpmulti \
+ tests/snmppings \
+ tests/tftp_serv_get \
+ tests/tftp_serv_put \
+ tests/tftp_serv_g0 \
+ tests/tftp_serv_p0 \
+ tests/tftp_serv_g512 \
+ tests/tftp_serv_p512 \
+ tests/tftp_serv_g1M \
+ tests/tftp_serv_p1M"
+ }
+ description "
+ This option specifies the set of tests
+ for the networking package."
+ }
+
+ cdl_component CYGPKG_NET_AUTOTEST_OPTIONS {
+ display "Networking support build options"
+ flavor none
+ no_define
+
+ cdl_option CYGPKG_NET_AUTOTEST_CFLAGS_ADD {
+ display "Additional compiler flags"
+ flavor data
+ no_define
+ default_value { "-D_KERNEL -D__ECOS" }
+ description "
+ This option modifies the set of compiler flags for
+ building the autotest package.
+ These flags are used in addition
+ to the set of global flags."
+ }
+
+ cdl_option CYGPKG_NET_AUTOTEST_CFLAGS_REMOVE {
+ display "Suppressed compiler flags"
+ flavor data
+ no_define
+ default_value { "" }
+ description "
+ This option modifies the set of compiler flags for
+ building the autotest package. These flags are removed from
+ the set of global flags if present."
+ }
+ }
+}
diff --git a/ecos/packages/net/autotest/current/doc/host.txt b/ecos/packages/net/autotest/current/doc/host.txt
new file mode 100644
index 0000000..c655c81
--- /dev/null
+++ b/ecos/packages/net/autotest/current/doc/host.txt
@@ -0,0 +1,414 @@
+
+Host Software for Automated Network Testing for eCos
+====================================================
+
+Hugo Tyson, Red Hat, Cambridge UK, 2000-10-20
+
+
+What Host Software?
+-------------------
+
+This note refers to the package CYGPKG_NET_AUTOTEST which lives in
+packages/net/autotest in the eCos repository.
+
+It contains, amongst other things, some software to run a "network testing
+server" which eCos network test cases (from the same package) use to test
+the network stack.
+
+The reason such a server is needed is simple: testing the eCos network
+stack involves an external, standard, computer _doing_things_to_ the target
+board as well as having the target board's test program do things itself.
+
+For example, one test case (in the main network package, net/tcpip) to test
+TFTP will get a file from a server using TFTP and put the data to another
+file on the server using TFTP. This tests the ability of the eCos TCPIP
+stack to act as a TFTP client. But it does not test the eCos TCPIP stack's
+TFTP server at all. To do that an external agent must act as client -
+using the standard tftp(1) app on linux, for example - to put and get data
+to and from an eCos testcase running on the target, offering a TFTP server.
+
+
+Quick Start Guide
+-----------------
+
+Set up your LINUX machine to serve DHCP to the target you want to test;
+ensure that any 10.0.0.x addresses used are given a class C (/24) netmask.
+Provide a genuine gateway to the internet via some route; the routing tests
+expect to ping www.cygnus.com! Also let it have the normal networking apps
+(tftp, ftp, ping) and servers (tftpd, ftpd) available, plus the SNMP
+package from UCD: snmpwalk and snmpstatus and standard MIBs.
+
+Make sure it is on on the same network(s) as the target you want to test.
+
+Set up aliases for loopback interface on the servers: on server for eth0 on
+the target, add an alias for 10.0.3.1/24. For eth1, 10.0.4.1/24.
+
+With a checked-out eCos source tree, change directory into either
+packages/net/autotest/current/host or a copy of it, and type make.
+
+Follow the printed instruction to change the simple executable "./_suping"
+to su root execution. You will need to become root temporarily to do this.
+
+Make sure . is on your path and type "awaitorder | obey.sh" to run the
+server; it prints info about messages it receives and sends.
+
+The test server is now running. You can now run test built from the
+CYGPKG_NET_AUTOTEST package (packages/net/autotest) on your target and they
+will talk to this host test server.
+
+
+Categories of Tests
+-------------------
+
+ o Host passive
+
+ The host is server, the eCos test case is the proactive client.
+
+ Such tests use the host to talk to, where the eCos testcase is the
+ client, and the host is the server. The network testing server is
+ not involved in these tests, but other servers which must be set up
+ there are used.
+
+ o Host proactive
+
+ The host is client to the eCos server.
+
+ The target board running eCos is the server, the host must run
+ scripts to do thing to it and report success or otherwise over the
+ net. The eCos test case typically starts a server, issues order
+ about how to test it, then sleeps for a time until the test is
+ deemed complete.
+
+
+Building the Network Testing Server
+-----------------------------------
+
+Cd into either packages/net/autotest/current/host or a copy of it, and type
+make. The standard makefile just compiles ./awaitorder.c into ./awaitorder
+the executable that waits for a request from a testcase and prints it to
+its stdout. It also builds some other utilities that are used by the test
+scripts, for example ./tmpfile from ./tmpfile.c - this just creates a file
+of random data for passing back and forth. It also builds _suping: make
+sure this is suid-root to be able to flood-ping the target.
+
+
+Running the Network Testing Server
+----------------------------------
+
+Make sure "." is on your path, early enough, then
+
+ awaitorder | obey.sh
+
+This is all you need to do to run the testing server.
+
+
+"./awaitorder" just waits for a connection on TCP port 9980 and prints what
+it receives. For example, to test it:
+
+ % telnet masala 9980
+ you type ---> Eggs, bacon, beans, mushrooms, toast and coffee
+ Acknowledged
+ Connection closed by foreign host.
+ %
+
+and awaitorder will print as follows:
+
+ % awaitorder
+ awaitorder: connection from 172.16.19.13:3739
+ ORDERS: Eggs, bacon, beans, mushrooms, toast and coffee
+
+and continue waiting for the next order.
+
+
+"./obey.sh" does rather more. It assumes that its stdin is connected to a
+source of orders, and it expects that lines of input will look like this:
+
+ ORDERS: TFTP_SERV_GET 10.16.19.171 300
+
+or more generally
+
+ "ORDERS:" [XFAIL] <order> <target IP> <extra params...>
+
+The set of valid orders (TFTP_SERV_GET, TFTP_SERV_PUT ...) will expand with
+time as we add more tests.
+
+Having checked that an order looks generally valid, and set up some
+environment, it then switches on the order to execute a test script to do
+what the testcase that sent the order wants. The extra params are given to
+the test script. The test script is invoked in background, so that several
+sessions can be running at once to hit the target board hard, or of course
+one network testing server can be servicing several target boards running
+different testcases all at once. After the test script is launched,
+obey.sh just loops back to reading an input line, to get the next order.
+
+"XFAIL" in parameter 1 means the target is configured to simulate network
+unreliability, or otherwise be uncooperative. It is passed both to the
+individual testing scripts and to the system for returning status messages
+to the test target.
+
+This structure is designed to allow separate development and testing of the
+individual parts of the network testing server and also of new testcases;
+the eCos testcase and its test script can be developed on your desk without
+running the network test server - you only need to knit them all together
+at the end by adding a simple clause to obey.sh to invoke the test script
+automatically.
+
+
+Test Script Environment
+-----------------------
+
+There is some IO redirection nastiness in obey.sh to separate errors from
+good status from status to return to the eCos testcase and so on.
+
+awaitorder takes care to issue complaints to stderr, whilst obviously its
+stdout is piped in to obey.sh
+
+obey.sh takes care to issue problem reports to stderr, and mere commentary
+to stdout; neither is paricularly verbose right now, so there's no need to
+so anything special.
+
+Individual test scripts are invoked as follows. Stdout is directed to a
+logfile named uniquely and for the test in question, according the the
+variable $LG. Stderr is piped to an acknowledgement agent, by default
+"./sendack.sh", which is invoked with the target address as its argument.
+This returns status messages from the host testing script to the eCos
+testcase via TCP port 9990.
+
+Let's look at the two example switch cases for the TFTP tests. There are
+two to mostly put versus mostly get files with the eCos TFTP server.
+
+ # Now the main swicth that runs the test script: this is where
+ # new testcases are added:
+ case $TEST in
+
+ TFTP_SERV_GET)
+ tftpget.sh $TARGET $WF/tftpget.$unique ${PARAMS[@]} \
+ 2>&1 >$LG/tftpget.$unique | $SENDACK $TARGET & ;;
+
+ TFTP_SERV_PUT)
+ tftpput.sh $TARGET $WF/tftpput.$unique ${PARAMS[@]} \
+ 2>&1 >$LG/tftpput.$unique | $SENDACK $TARGET & ;;
+
+OK, this is horrid. But breaking up one example:
+
+this first part is the invokation of the script:
+
+ tftpput.sh $TARGET $WF/tftpput.$unique ${PARAMS[@]}
+
+its arguments are
+
+ tftpput.sh <target IP> <temporary file> <timeout> <filesize>
+
+ o <target IP> is $TARGET, from the original order.
+
+ o obey.sh has invented <temporary file> with a unique id, in the workfiles
+ directory, $WF. It will typically be "/tmp/auto/wf/tftpput.1138". In
+ this example, the test script will make files called
+ "/tmp/auto/wf/tftpput.1138.src" and "/tmp/auto/wf/tftpput.1138.tmp" to
+ play with; one is created by the tmpfile program, the other read back
+ from the TFTP server.
+
+ o <timeout> is part of the extra params supplied by the eCos testcase,
+ which in this case will serve TFTP for about 5 minutes, so it tells the
+ test script to diddle it for about 5 minutes too.
+
+ o <filesize> is another param supplied by the eCos testcase, which tells
+ the script to create a testfile of a particular size to exercise edge
+ conditions wrt the blocksize.
+
+The second part of the example is the IO redirection and backgrounding:
+
+ 2>&1 >$LG/tftpput.$unique | $SENDACK $XFAIL $TARGET & ;;
+
+This sets the script's fd2 to a copy of its stdout, then sets its stdout to
+go to the logfile, typically "/tmp/auto/log/tftpput.1138", then pipes the
+original stdout which now occupies fd2 into $SENDACK, the acknowledgement
+agent, which is itself invoked with the target's IP address and optionally
+XFAIL to tell it not to be so upset if it fails to return the result. The
+whole thing is run in background by the "&" and the ";;" is the end of this
+case within the switch statement. Phew!
+
+More briefly, the test script's stdout goes into the logfile and the test
+script's stderr goes into $SENDACK (./sendack.sh) and thence to the
+testcase.
+
+
+Typical Output
+--------------
+
+This is the output from awaitorder | obey.sh from running just one eCos
+testcase, which requests 3 simultaneous TFTP sessions for 5 minutes:
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+awaitorder: connection from 10.16.19.171:34554
+test TFTP_SERV_PUT; target 10.16.19.171; params 300 512
+awaitorder: connection from 10.16.19.171:46052
+test TFTP_SERV_PUT; target 10.16.19.171; params 300 513
+awaitorder: connection from 172.16.19.171:25388
+test TFTP_SERV_PUT; target 172.16.19.171; params 300 512
+10.16.19.171: result INFO:<10.16.19.171 is up>
+172.16.19.171: result INFO:<172.16.19.171 is up>
+10.16.19.171: result INFO:<10.16.19.171 is up>
+10.16.19.171: result PASS:<tftp put OK, 300 seconds 513 bytes 20696 xfers>
+10.16.19.171: result PASS:<tftp put OK, 300 seconds 512 bytes 14982 xfers>
+172.16.19.171: result PASS:<tftp put OK, 300 seconds 512 bytes 12649 xfers>
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+and the eCos test case prints, amongst other things, on receipt of the
+results via sendack.sh
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INFO:<10.16.19.171 is up> (10.16.19.171) (from 10.16.19.13:4764)
+INFO:<172.16.19.171 is up> (172.16.19.171) (from 172.16.19.13:4765)
+INFO:<10.16.19.171 is up> (10.16.19.171) (from 10.16.19.13:4766)
+....
+PASS:<tftp put OK, 300 seconds 513 bytes 20696 xfers> (10.16.19.171) (from 10.16.19.13:4775)
+PASS:<tftp put OK, 300 seconds 512 bytes 14982 xfers> (10.16.19.171) (from 10.16.19.13:4776)
+PASS:<tftp put OK, 300 seconds 512 bytes 12649 xfers> (172.16.19.171) (from 172.16.19.13:4777)
+....
+PASS:<Results from host[s] OK>
+EXIT:<Done>
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+This output format will change over time as more features may be added, but
+this example should convey the general idea.
+
+
+Individual Host Testing Scripts
+-------------------------------
+
+The params and invocation of these is entirely a matter of agreement
+between the eCos testcase and the test script. A new case arm in the
+obey.sh switch statement must be written for any new testcase, so the
+script's invocation is not prescribed in any way.
+
+For the sake of easier separate development of testcases, it would be
+better to follow the pattern of the other testcases, also for consistency
+and comprehensibility. Here are some guidelines and requirements, but
+first some assumptions:
+
+ o One test script "does things to" one target board, and more specifically
+ one target IP address. If you want several things done to your target
+ board at once, invoke several scripts at once - all on the same IP
+ address if you want, that's fine.
+
+ o The test script may need to be told that the target network stack is
+ configured to simulate network unreliability, so the test script should
+ not expect perfect communications. Eg. weaker protocols will in fact
+ fail - the point of the test is verify that the target does not hang or
+ crash or assert-fail and so on; host side network failures within the
+ script are unimportant. Otherwise, the test script should expect
+ correct operation in the operations it performs.
+
+ o The network test server can serve testing to many eCos target boards at
+ once. Therefore any particular test script can be invoked several times
+ at once to deal with different target boards, if they happen at random
+ to run the same testcase at the same time as each other. Therefore a
+ test script should only use temporary files which are uniquely named per
+ invocation.
+
+These lead to requirements and guidelines:
+
+ o Take the flag XFAIL optionally as the first argument, if it is XFAIL
+ shift to get the other arguments.
+
+ o Take the target IP address as the next argument; it's an obvious place
+ for it and you'll certainly need it anyhow.
+
+ o For workfiles, have obey.sh supply a parameter to name such files
+ uniquely. Use a full pathname. Include the test type also, for example
+ "/tmp/auto/wf/tftpput.1138" identifies the file as belonging to the
+ tftpput testcase. Make required workfiles be second and subsequent
+ arguments.
+
+ o Further arguments which are arbitrary and passed from the testcase
+ should be last, and passed all together. It's not convenient in the
+ shell to split out words 2 through the end from an array if you already
+ quoted word one elsewhere, so instead put all the extras together as in
+ ${PARAMS[@]} in the tftpput.sh invocation discussed above.
+
+
+Other Environment
+-----------------
+
+ o DHCP
+
+Set up DHCP to support the target board - it's the easiest way.
+
+The tests know which server to talk to by looking in the server ID field of
+the bootp information record; if DHCP or BOOTP is used, this will be the
+server that served it. It is also possible to set up the stack with static
+initialization of that field - if you do this, make sure it points to a
+machine that is running the network test server.
+
+Setting up the server to serve DHCP to the target boards only is easy;
+keeping other DHCP servers, who offer dynamic addresses to any new net
+presence, from offering service to them requires a little trick. A dynamic
+server should be set up to supply a static address to the target board's
+MAC address, with the additional key: "deny booting;". This does nothing
+malicious, but it lets the server recognize the target board and ignore it.
+
+This ensures that the network test server machine "wins" the race to set up
+the target, and so ensures that the test talks to the network test server
+rather than trying to talk to a global DHCP server.
+
+
+ o /tmp clearance
+
+The ongoing testing fills /tmp with log files and work files. The logs
+will likely not be very large, but the work files could be a few Mb per
+test run.
+
+A cron job to remove everything older than an hour, or some such might be
+useful; or if the machine can stand it, just wipe /tmp/auto every night.
+
+
+ o Ping!
+
+The tests will expect to ping (and flood ping) the server; it should be
+allowed to do this back. An suid executable (CARE!) is needed to enable
+this. "./_suping" is built by the host makefile: make it be suid root.
+It is a trivial app that execs ping after setting the effective UID to
+root. This is necessary because ping is an suid-root executable anyway, to
+be able to get at raw sockets; it checks the effective UID to decide
+whether to permit flood pinging; we need this for the flood tests floodping
+and floodpingmux.
+
+
+ o Network aliases in the loopback interface
+
+The routing tests require a network setup like this:
+
+ 10.0.3.1 A.B.C.D A.B.C.E N.M.O.P N.M.O.Q 10.0.4.1
+ -------- Box1 ----------------- target ----------------- Box2 --------
+
+
+Optionally with 10.0.3 and 10.0.4 being real networks, with other stations
+on them; addresses 10.0.x.99 are also pinged. Alternatively, 10.0.3 and
+10.0.4 can be aliases for the loopback device in Box1 and Box2 (which may
+be the same box really). A typical setup might really look like:
+
+ HOST: eth0 172.16.19.13 ------ 172.16.19.171 eth0 on TARGET
+ HOST: eth1 10.16.19.13 -------- 10.16.19.171 eth1 on TARGET
+ HOST: lo:0 10.0.3.1
+ HOST: lo:1 10.0.4.1
+
+with all netmasks being /24 (255.255.255.0).
+
+This means that the target can only ping addresses 10.0.3.x and 10.0.4.x if
+a route has been set up via 172.16.19.13 or 10.16.19.13 (respectively, for
+the case of having two distinct hosts). The routing tests verify that
+behaviour.
+
+
+ o TFTP server and its files
+
+No test of the eCos TFTP client yet, so no details here.
+
+ o FTP server and its files
+
+No test for the eCos FTP client yet, so no details here.
+
+
+
+.fin
diff --git a/ecos/packages/net/autotest/current/doc/strategy.txt b/ecos/packages/net/autotest/current/doc/strategy.txt
new file mode 100644
index 0000000..aa7c40d
--- /dev/null
+++ b/ecos/packages/net/autotest/current/doc/strategy.txt
@@ -0,0 +1,237 @@
+
+Some Thoughts on Automated Network Testing for eCos
+***************************************************
+
+Hugo Tyson, Red Hat, Cambridge UK, 2000-07-28
+
+
+Requirements
+============
+
+This thinking is dominated by the need for automated continuous testing
+of the StrongARM EBSA-285 boards, which have two ethernet interfaces.
+We also have some needs for ongoing eCos network testing.
+
+ o TCP testing: move a large amount of data, checking its correctness.
+ (with several streams running in parallel at once)
+
+ o UDP testing: similar but using UDP.
+
+ o TFTP testing: an external server, from a choice of LINUX, NT, SunOS, and
+ another EBSA board, get from the target some files, of sizes 0, 1, 512,
+ 513, 1048576 bytes. (with several streams running in parallel at once)
+
+ o TFTP testing: put to the target some files, ....
+
+ o TFTP testing: the target tftp client code does the same, getting and
+ putting, to an external server.
+
+ [ All that TFTP test makes explicit testing of UDP unneccessary; UDP
+ testing would need sequence numbers and so on, so we may as well use
+ TFTP as the implementation of that]
+
+ o FTP test: we have a trivial "connect" test; continue to use it.
+
+ o Performance testing: TCP_ECHO, TCP_SOURCE, TCP_SINK programs work in
+ concert to measure throughput of a partially loaded target board.
+ Source and Sink apps run on an external host.
+
+ o Flood pings: the target floods the hosts on its two external interfaces
+ whilst they flood it. This is left going for a long time, and store
+ leaks or crashes are checked for.
+
+Orthogonally to these "feature tests" are requirements to run these tests
+with and without these features in combinations:
+
+ o The "realtime test harness" operating - it checks interrupt latencies
+ and so on. This is written and works.
+
+ o Booting statically, via bootp, via DHCP statically/leased on the two
+ interfaces in combination.
+
+ o Simulated failure of the network, of the kinds "drop 1 in N packets",
+ "drop all for 0 < random() < 30 Seconds" and the like. Corrupted
+ packets being sent out by the target, also!
+
+Needs
+---------------
+
+We have some other requirements:
+
+ o Support testing of other net-enabled targets!
+
+ o Run tests at a reasonable rate, so do NOT require a reboot of, say, a
+ LINUX host every test run to reconfigure the network environment.
+
+ o Feasible: do NOT require anything too complex in terms of controlling
+ the network environment.
+
+ o Do not use too many machines. The farm is full already.
+
+
+Other Goals
+-----------
+
+These are some ideas that are useful but not strictly necessary:
+
+ o Re-use/work-with the existing test infrastructure
+
+ o Provide the sort of results information that the existing test
+ infrastructure does.
+
+ o Work with standard testing *host* computers of various kinds.
+
+ o Support conveniently debugging these test examples at developers' desks
+ - not just in the farm.
+
+
+Details
+=======
+
+Because of the flood pinging and malformed packet requirements, the target
+boards need to be on an isolated network.
+
+The target board's two interfaces need to be on distinct networks for the
+stack to behave properly.
+
+
+
+Strategy
+========
+
+I believe we can implement everything we need for the host computers to do
+using a daemon or server, (cf. the serial test filter) which sits on the
+host computer waiting to be told what test we are about to run, and takes
+appropriate action.
+
+Note that this does work even for situations where the target is passive,
+eg. being a TFTP server. The target simply "does" TFTP serving for a set
+period of time - or perhaps until a cookie file exists in its test file
+system - and then performs a set of consistency checks (including on the
+state of the test FS), thus creating a PASS/FAIL test result. It can also
+periodically run those checks anyway, and choose FAIL at any time.
+
+But who tells the host daemon what to do? The target does, of course.
+That way, the host is stateless, it simply runs that daemon doing what it's
+bid, and does NOT ever have to report test results. This has enormous
+advantages, because it means we gather test results from what the target
+said, and no other source, thus minimizing changes to the farm software.
+It also means that to add a new test, we can asynchronously add the feature
+to the test daemons of that is required, then add a new testcase in the
+usual manner, with all the usual (compile-time) testing of its
+applicability as usual.
+
+Network Topology
+----------------
+
+The idea is that we can initially have a setup like this:
+
+ house network <---> [net-testfarm-machine] serial -------+
+ |
+ serial
+ house network <----> eth0 [LINUX BOX] eth1 <---> eth0 [ EBSA ]
+ [ dhcpd ] eth2 <---> eth1 [ ]
+ [ tftpd ]
+ [ ftpd ]
+ [ testd ]
+
+for developing the system. Testd is our new daemon that runs tcp_sink, or
+tcp_source, or a floodping, or does tftp to the target (rather than vice
+versa) as and when the target instructs it. The target can report test
+results to the net-testfarm-machine as usual, but with bigger timeouts &c
+configured in the test farm.
+
+This system can then be generalized to
+
+ test-server1 test-server2 test-serverN
+ eth0 eth0 eth0
+ | | |
+ | | |
+ eth0 | |
+ target1 target4 targetM
+ target2 target5 targetM+1
+ target3 target6 targetM+2
+ eth1
+ |
+ |
+ test-server11
+
+where target1,2,3 have 2 ethernet interfaces and the others have only one.
+
+And further, provided the testd protocol supports targets choosing one
+server from many which offer service, which would be a good thing:
+
+ test-server1 test-server2 test-serverN
+ eth0 eth0 eth0
+ [LINUX] [Solaris] [NT4.0]
+ | | |
+ +----------------------+------------------------+
+ | | |
+ eth0 | |
+ target1 target4 targetM
+ target2 target5 targetM+1
+ target3 target6 targetM+2
+ eth1
+ |
+ +-----------------------+
+ | |
+ [LINUX] [NT4.0]
+ test-server11 test-server12
+
+which would IMHO be a good thing IN ADDITION to a completely partitioned
+set of test network as above. The partitioned set of test networks is
+required also because we need to test all of:
+
+ Target asks for BOOTP vs. DHCP -X- Server does only BOOTP vs. DHCP
+
+in combinations on the different interfaces. Simply setting up servers
+that way statically is best, rather than trying to script controls for
+servers that have them offering bootp one minute and DHCP the next.
+
+
+Test Farm
+---------
+
+Orthogonal to the network topology, the network test farm is connected to
+all these targets in the usual manner by serial lines. That way the tests
+can run and busy/cripple that local network without affecting the house
+network *and* without affecting the debug connection, and with the
+advantage that tests net traffic can interfere with each other, providing a
+diverse network environment for testing, rather than a quiet net.
+
+For testing with GDB connection over the network, which is desirable, I
+suggest either keeping those machines separate, or having the farm's
+connection into the test-net be via second interfaces fitted to the server
+machines.
+
+Otherwise, it's a standard test farm, which knows to choose only from a
+special set of perms, and which has waaay longer timeouts.
+
+
+Test Cases
+----------
+
+In this way, tests of the form "make an external machine do tftp to the
+target board" are implemented by means of a standard eCos test case, which
+requests that action from a server, then waits for it to be told AOK or
+just for a certain time, and reports as such to the test farm as usual.
+
+These special tests are only compiled in certain perms.
+
+Those same special perms select between the various initialization options
+required also: DHCP or BOOTP or static initialization, and so on, in the
+usual manner.
+
+
+Implementation
+--------------
+
+Just a quick note on this: DHCP has a lot of the properties we want for the
+test protocol. We should take a copy of that and use different port
+numbers, re-use a lot of the code, since server code is also available.
+
+Or something simpler; none of this seems especially challenging.
+
+
+That's all for now.
+.ends
diff --git a/ecos/packages/net/autotest/current/host/_suping.c b/ecos/packages/net/autotest/current/host/_suping.c
new file mode 100644
index 0000000..6689f2e
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/_suping.c
@@ -0,0 +1,14 @@
+// _suping.c
+
+#include <unistd.h>
+
+// This a piece of lameness to convince ping to do a floodping.
+int main( int argc, char **argv )
+{
+ setuid( 0 );
+ execvp( "ping", argv );
+ perror( "What, no ping?" );
+ exit( 1 );
+}
+
+// EOF
diff --git a/ecos/packages/net/autotest/current/host/awaitorder.c b/ecos/packages/net/autotest/current/host/awaitorder.c
new file mode 100644
index 0000000..869b868
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/awaitorder.c
@@ -0,0 +1,151 @@
+//==========================================================================
+//
+// awaitorder.c
+//
+// Await an order from the target, and print it out...
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <stdio.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <net/route.h>
+
+void
+pexit(char *s)
+{
+ perror(s);
+ exit(1);
+}
+
+#define SOURCE_PORT 9980
+
+int main( int argc, char **argv )
+{
+ int s_source, e_source;
+ struct sockaddr_in e_source_addr, local;
+ int one = 1;
+ int len;
+ char orders[256];
+ char ack[] = "Acknowledged\n";
+ int loop = 1;
+
+ if ( 2 < argc ) {
+ usage:
+ fprintf( stderr, "usage: %s [once|many]\n", argv[0] );
+ exit(1);
+ }
+
+ if ( 2 == argc ) {
+ if ( !strcmp( "once", argv[1] ) )
+ loop = 0;
+ else if ( !strcmp( "many", argv[1] ) )
+ loop = 1;
+ else
+ goto usage;
+ }
+
+ s_source = socket(AF_INET, SOCK_STREAM, 6 /* TCP */ );
+ if (s_source < 0) {
+ pexit("stream socket");
+ }
+
+
+ memset(&local, 0, sizeof(local));
+ local.sin_family = AF_INET;
+ local.sin_len = sizeof(local);
+ local.sin_port = ntohs(SOURCE_PORT);
+ local.sin_addr.s_addr = INADDR_ANY;
+ if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) {
+ pexit("bind /source/ error");
+ }
+ if (setsockopt(s_source, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
+ pexit("setsockopt /source/ SO_REUSEADDR");
+ }
+#ifdef SO_REUSEPORT
+ if (setsockopt(s_source, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one))) {
+ pexit("setsockopt /source/ SO_REUSEPORT");
+ }
+#endif
+
+ listen(s_source, SOMAXCONN);
+
+ do {
+ len = sizeof(e_source_addr);
+ if ((e_source = accept(s_source,
+ (struct sockaddr *)&e_source_addr, &len)) < 0) {
+ pexit("accept /source/");
+ }
+ fprintf( stderr, "awaitorder: connection from %s:%d\n",
+ inet_ntoa(e_source_addr.sin_addr), ntohs(e_source_addr.sin_port));
+
+ // Wait for "source" to tell us the orders
+ if ( 0 >= (len = read(e_source, orders, sizeof(orders)))) {
+ pexit("Can't read orders");
+ }
+ if ( sizeof(ack) != write(e_source, ack, sizeof( ack ) ) ) {
+ pexit("Can't write ACK");
+ }
+
+ orders[len] = 0;
+
+ printf( "ORDERS: %s\n", orders );
+ fflush( stdout );
+
+ close( e_source );
+ } while ( loop );
+
+ close( s_source );
+}
+// EOF awaitorder.c
diff --git a/ecos/packages/net/autotest/current/host/floodping.sh b/ecos/packages/net/autotest/current/host/floodping.sh
new file mode 100755
index 0000000..dc5e181
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/floodping.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# timeout is the total time to run the test, or thereabouts.
+#
+# ping/rest times are to let us do stuff like flood for 3 seconds then do
+# nothing for 5 seconds, over the total test time.
+#
+# That way this script can be used to torment other test variants such as
+# the SNMP walk, ordinary pinging and so on, all making for a more diverse
+# test environment.
+
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 [XFAIL] target [timeout [size [ping rest]]" > /dev/stderr
+ exit 1
+fi
+
+[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
+TARGET=$1
+if [ "x" == "x$2" ]; then TIMEOUT=10; else TIMEOUT=$2; fi
+if [ "x" == "x$3" ]; then PINGSIZE=64; else PINGSIZE=$3; fi
+if [ "x" == "x$4" ]; then PINGTIME=19; else PINGTIME=$4; fi
+if [ "x" == "x$5" ]; then RESTTIME=1; else RESTTIME=$5; fi
+
+# By default, flood for 19 seconds then rest for one.
+# We take one second off occasionally to allow eg. DHCP to stay alive in
+# configurations/environments where it is so short lived.
+
+if [ "x$XFAIL" != "xXFAIL" ]; then
+ # first try normal size packets
+ if ping -n -c 5 $TARGET > /dev/null ; then
+ echo "INFO:<$$: $TARGET is up>" > /dev/stderr
+ else
+ echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
+ fi
+fi
+
+# allow other pingers &c to start up:
+sleep 5
+
+declare -i COUNT=0
+
+# then the size we were asked to do, for the time requested
+
+while [ $SECONDS -le $TIMEOUT ]; do
+
+# Use an explicit path in '.' because this must be an SUID script to be
+# able to use the flood option. Direct stderr to tmp also because we
+# cannot report results whilst flooding.
+./_suping -f -n -w $PINGTIME -q -s $PINGSIZE $TARGET > /tmp/ping$$ 2>&1
+
+# dump this out for the controller logfile
+cat /tmp/ping$$
+
+INFO1=$(grep "bytes of data" /tmp/ping$$)
+INFO2=$(grep "packet loss" /tmp/ping$$)
+INFO3=$(grep "round-trip" /tmp/ping$$)
+
+rm -f /tmp/ping$$
+
+# but do not print it all out to stderr (and so to sendack and over the
+# net); the two cannot coexist reliably.
+
+#[ "x" != "x$INFO1" ] && echo "INFO:<$$: $INFO1>" > /dev/stderr
+#[ "x" != "x$INFO2" ] && echo "INFO:<$$: $INFO2>" > /dev/stderr
+#[ "x" != "x$INFO3" ] && echo "INFO:<$$: $INFO3>" > /dev/stderr
+
+# then a delay for other traffic - else other tests fail
+sleep $RESTTIME
+
+((COUNT++));
+done
+
+# allow other flood pingers to finish:
+sleep 5
+
+if [ "x$XFAIL" == "xXFAIL" ]; then
+ echo "PASS:<$$: flood ping XFAIL, $PINGSIZE bytes $TIMEOUT seconds $COUNT sessions>" > /dev/stderr
+ exit 0
+fi
+
+# we cannot really look for pass/fail from a flood ping...
+
+echo "PASS:<$$: flood ping OK, $PINGSIZE bytes $TIMEOUT seconds $COUNT sessions>" > /dev/stderr
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/makefile b/ecos/packages/net/autotest/current/host/makefile
new file mode 100644
index 0000000..c684bac
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/makefile
@@ -0,0 +1,19 @@
+
+all: awaitorder tmpfile _suping
+
+awaitorder: awaitorder.c
+ gcc -g -o awaitorder awaitorder.c
+
+
+tmpfile: tmpfile.c
+ gcc -g -o tmpfile tmpfile.c
+
+_suping: _suping.c
+ gcc -g -o _suping _suping.c
+ @echo "*** Don't forget to chown root _suping; chmod u+sx _suping ***"
+
+clean:
+ rm -f tmpfile
+ rm -f awaitorder
+ rm -f _suping
+ rm -f *~
diff --git a/ecos/packages/net/autotest/current/host/obey.sh b/ecos/packages/net/autotest/current/host/obey.sh
new file mode 100755
index 0000000..d7c5dee
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/obey.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+if [ $# -gt 1 ]; then
+ echo "Usage: $0 [acknowledgement-agent]" > /dev/stderr
+ exit 1
+fi
+
+# add . to the path for testing.
+export PATH=$PATH:.
+
+# get a script for returning results to the testcase; its API is
+# echo .... | SENDACK [XFAIL] <target>
+if [ $# -gt 0 ]; then
+ SENDACK=$1; shift
+else
+ SENDACK=sendack.sh
+fi
+
+TMP=/tmp/auto ;# root of temporary filespace
+
+WF=${TMP}/wf ;# work files for tftp et al
+LG=${TMP}/log ;# log files for individual tests
+
+declare -i unique=0 ;# unique IDs for workfiles and logfiles
+
+while [ true ]; do
+
+ ((unique++))
+
+ read -a ORDERS || { echo "FAIL: EOF on read" > /dev/stderr; exit 1; }
+
+ set ${ORDERS[@]}
+
+ [ "xQUIT" == "x$1" ] && break
+
+ [ "xORDERS:" != "x$1" ] && \
+ { echo "No ORDERS tag" > /dev/stderr; continue; }
+
+ XFAIL=""; [ "xXFAIL" == "x$2" ] && { XFAIL="XFAIL"; shift; }
+
+ shift; TEST=$1
+ shift; TARGET=$1
+ shift; PARAMS=($@)
+
+ echo "test $TEST [$XFAIL]; target $TARGET; params ${PARAMS[@]}"
+
+ # Be robust against zealous GC of workfiles - as late as possible
+ # before we use them, it's in the read above that we sleep.
+ [ ! -d ${TMP} ] && mkdir ${TMP}
+ [ ! -d ${WF} ] && mkdir ${WF}
+ [ ! -d ${LG} ] && mkdir ${LG}
+
+ # Now the main switch that runs the test script: this is where
+ # new testcases are added:
+ case $TEST in
+
+ TFTP_SERV_GET)
+ tftpget.sh $XFAIL $TARGET $WF/tftpget.$unique ${PARAMS[@]} \
+ 2>&1 >$LG/tftpget.$unique | $SENDACK $XFAIL $TARGET & ;;
+
+ TFTP_SERV_PUT)
+ tftpput.sh $XFAIL $TARGET $WF/tftpput.$unique ${PARAMS[@]} \
+ 2>&1 >$LG/tftpput.$unique | $SENDACK $XFAIL $TARGET & ;;
+
+ SLOW_PING)
+ slowping.sh $XFAIL $TARGET ${PARAMS[@]} \
+ 2>&1 >$LG/slowping.$unique | $SENDACK $XFAIL $TARGET & ;;
+
+ FLOOD_PING)
+ floodping.sh $XFAIL $TARGET ${PARAMS[@]} \
+ 2>&1 >$LG/floodping.$unique | $SENDACK $XFAIL $TARGET & ;;
+
+ SNMP_WALK)
+ snmpwalk.sh $XFAIL $TARGET ${PARAMS[@]} \
+ 2>&1 >$LG/snmpwalk.$unique | $SENDACK $XFAIL $TARGET & ;;
+
+ *) echo "Unknown order $TEST" > /dev/stderr ;;
+
+ esac
+
+done
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/sendack.sh b/ecos/packages/net/autotest/current/host/sendack.sh
new file mode 100755
index 0000000..a808c18
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/sendack.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+if [ $# -gt 2 ] || [ $# -lt 1 ]; then
+ echo "Usage: $0 [XFAIL] target-IP [port]" > /dev/stderr
+ exit 1
+fi
+
+[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
+
+TARGET=$1; shift
+
+PORT=9990; [ "x" != "x$1" ] && { PORT=$1; shift; }
+
+while [ true ]; do
+
+ read -a RESULT || { exit 0; }
+
+ echo "$TARGET: result ${RESULT[@]}"
+
+ # I really want it to try quite hard to get the message through
+ # (but not too hard if XFAIL)
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ { sleep 1 && { \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ { sleep 3 && { \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ { [ "x$XFAIL" != "xXFAIL" ] && sleep 5 && { \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ { sleep 10 && { \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ echo "${RESULT[@]} ($TARGET)" > /dev/tcp/$TARGET/$PORT || \
+ echo "***FAILED TO SEND RESULT TO $TARGET: result ${RESULT[@]}" \
+ ;};};};};};};};}
+ # brute force seems as good as any means...
+
+done
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/slowping.sh b/ecos/packages/net/autotest/current/host/slowping.sh
new file mode 100755
index 0000000..2a2a9af
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/slowping.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 [XFAIL] target [timeout [size]]" > /dev/stderr
+ exit 1
+fi
+
+[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
+TARGET=$1
+if [ "x" == "x$2" ]; then TIMEOUT=10; else TIMEOUT=$2; fi
+if [ "x" == "x$3" ]; then PINGSIZE=64; else PINGSIZE=$3; fi
+
+if [ "x$XFAIL" != "xXFAIL" ]; then
+ # first try normal size packets
+ if ping -n -c 5 $TARGET > /dev/null ; then
+ echo "INFO:<$$: $TARGET is up>" > /dev/stderr
+ else
+ echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
+ fi
+fi
+
+# then the size we were asked to do, for the time requested
+ping -n -c $TIMEOUT -s $PINGSIZE $TARGET > /tmp/ping$$ && PINGRESULT=ok
+
+# dump this out for the controller logfile
+cat /tmp/ping$$
+
+INFO1=$(grep "bytes of data" /tmp/ping$$)
+INFO2=$(grep "packet loss" /tmp/ping$$)
+INFO3=$(grep "round-trip" /tmp/ping$$)
+
+rm -f /tmp/ping$$
+
+[ "x" != "x$INFO1" ] && echo "INFO:<$$: $INFO1>" > /dev/stderr
+[ "x" != "x$INFO2" ] && echo "INFO:<$$: $INFO2>" > /dev/stderr
+[ "x" != "x$INFO3" ] && echo "INFO:<$$: $INFO3>" > /dev/stderr
+
+if [ "x$XFAIL" == "xXFAIL" ]; then
+ echo "PASS:<$$: slow ping XFAIL, $PINGSIZE bytes $TIMEOUT packets/seconds>" > /dev/stderr
+ exit 0
+fi
+
+if [ "x" == "x$PINGRESULT" ]; then
+ echo "FAIL:<$$: slow ping failed, $PINGSIZE bytes $TIMEOUT packets/seconds>" > /dev/stderr
+ exit 1
+fi
+
+echo "PASS:<$$: slow ping OK, $PINGSIZE bytes $TIMEOUT packets/seconds>" > /dev/stderr
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/snmpwalk.sh b/ecos/packages/net/autotest/current/host/snmpwalk.sh
new file mode 100755
index 0000000..d6a4896
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/snmpwalk.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 [XFAIL] target [timeout]" > /dev/stderr
+ exit 1
+fi
+
+[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
+TARGET=$1
+if [ "x" == "x$2" ]; then TIMEOUT=10; else TIMEOUT=$2; fi
+
+if [ "x$XFAIL" != "xXFAIL" ]; then
+ # first try normal size packets
+ if ping -n -c 5 $TARGET > /dev/null ; then
+ echo "INFO:<$$: $TARGET is up>" > /dev/stderr
+ else
+ echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
+ fi
+fi
+
+export MIBS=all
+
+declare -i COUNT=0
+declare -i FAILS=0
+
+# then the size we were asked to do, for the time requested
+
+while [ $SECONDS -le $TIMEOUT ]; do
+
+snmpwalk -OS $TARGET public
+
+snmpstatus $TARGET public || { ((FAILS++)); [ "x$XFAIL" == "xXFAIL" ]; } || break
+
+((COUNT++));
+
+done
+
+
+if [ "x$XFAIL" == "xXFAIL" ]; then
+ echo "PASS:<$$: snmpwalk XFAIL, $TIMEOUT seconds $COUNT snmpwalks $FAILS failed>" > /dev/stderr
+ exit 0
+fi
+
+if [ $FAILS -ne 0 ]; then
+ echo "FAIL:<$$: snmpwalk $TIMEOUT seconds $COUNT snmpwalks - status failed>" > /dev/stderr
+ exit 1
+fi
+
+echo "PASS:<$$: snmpwalk $TIMEOUT seconds $COUNT snmpwalks>" > /dev/stderr
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/tftpget.sh b/ecos/packages/net/autotest/current/host/tftpget.sh
new file mode 100755
index 0000000..090d786
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/tftpget.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 target [tempfile [timeout [filesize]]]" > /dev/stderr
+ exit 1
+fi
+
+[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
+TARGET=$1
+if [ "x" == "x$2" ]; then TMP=tftpdata; else TMP=$2; fi
+if [ "x" == "x$3" ]; then TIMEOUT=10; else TIMEOUT=$3; fi
+if [ "x" == "x$4" ]; then SIZE=unknown; else SIZE=$4; fi
+
+if [ -f $TMP ]; then
+ SRC=${TMP}
+ TMP=${TMP}.tmp
+else
+ SRC=${TMP}.src
+ TMP=${TMP}.tmp
+fi
+
+if [ -f $SRC ]; then
+ [ $SIZE == unknown ] || \
+ { echo "FAIL: '$SRC' exists but size given" > /dev/stderr; exit 1; }
+else
+ [ $SIZE == unknown ] && SIZE=876543
+ tmpfile $SRC $SIZE $$ || \
+ { echo "FAIL: Sourcefile '$SRC' create" > /dev/stderr; exit 1; }
+fi
+
+if [ ! -f $SRC ]; then
+ echo "FAIL: Sourcefile '$SRC' not found" > /dev/stderr; exit 1
+fi
+
+if [ "x$XFAIL" != "xXFAIL" ]; then
+ if ping -n -c5 $TARGET > /dev/null ; then
+ echo "INFO:<$$: $TARGET is up>" > /dev/stderr
+ else
+ echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
+ fi
+fi
+
+tftp $TARGET <<-EOF
+ rexmt 1
+ binary
+ put $SRC $TMP
+EOF
+
+declare -i COUNT=0
+declare -i FAILS=0
+
+# This test is to test tftp GET not PUT so gloss over one failed put
+# (ie. if it reports corrupt the first time, put it again).
+rm -f $TMP
+tftp $TARGET <<-EOF
+ rexmt 1
+ binary
+ get $TMP $TMP
+EOF
+if ! cmp -s $SRC $TMP; then
+echo "INFO:<$$: putting $SIZE bytes to $TARGET a second time>"
+tftp $TARGET <<-EOF
+ rexmt 1
+ binary
+ put $SRC $TMP
+EOF
+else
+((COUNT++));
+fi
+
+while [ $SECONDS -le $TIMEOUT ]; do
+rm -f $TMP
+tftp $TARGET <<-EOF
+ rexmt 1
+ binary
+ get $TMP $TMP
+EOF
+[ -f $TMP ] || [ "x$XFAIL" == "xXFAIL" ] || break
+cmp -s $SRC $TMP || { ((FAILS++)); [ "x$XFAIL" == "xXFAIL" ]; } || break
+((COUNT++));
+done
+
+if [ "x$XFAIL" == "xXFAIL" ]; then
+ echo "PASS:<$$: tftp get XFAIL, $TIMEOUT seconds $SIZE bytes $FAILS/$COUNT fails>" > /dev/stderr
+ exit 0
+fi
+
+if [ 1 -lt $FAILS ]; then
+ echo "FAIL:<$$: wierd, multiple failures $FAILS in $COUNT xfers>" > /dev/stderr
+fi
+
+if [ ! -f $TMP ]; then
+ echo "FAIL:<$$: temp file $TMP nonexistent $COUNT xfers>" > /dev/stderr
+ exit 1
+fi
+
+if ! cmp -s $SRC $TMP; then
+ echo "FAIL:<$$: temp file $TMP corrupt $COUNT xfers>" > /dev/stderr
+ exit 1
+fi
+
+echo "PASS:<$$: tftp get OK, $TIMEOUT seconds $SIZE bytes $COUNT xfers>" > /dev/stderr
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/tftpput.sh b/ecos/packages/net/autotest/current/host/tftpput.sh
new file mode 100755
index 0000000..049dd8b
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/tftpput.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 target [tempfile [timeout [filesize]]]" > /dev/stderr
+ exit 1
+fi
+
+[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
+TARGET=$1
+if [ "x" == "x$2" ]; then TMP=tftpdata; else TMP=$2; fi
+if [ "x" == "x$3" ]; then TIMEOUT=10; else TIMEOUT=$3; fi
+if [ "x" == "x$4" ]; then SIZE=unknown; else SIZE=$4; fi
+
+if [ -f $TMP ]; then
+ SRC=${TMP}
+ TMP=${TMP}.tmp
+else
+ SRC=${TMP}.src
+ TMP=${TMP}.tmp
+fi
+
+if [ -f $SRC ]; then
+ [ $SIZE == unknown ] || \
+ { echo "FAIL: '$SRC' exists but size given" > /dev/stderr; exit 1; }
+else
+ [ $SIZE == unknown ] && SIZE=876543
+ tmpfile $SRC $SIZE $$ || \
+ { echo "FAIL: Sourcefile '$SRC' create" > /dev/stderr; exit 1; }
+fi
+
+if [ ! -f $SRC ]; then
+ echo "FAIL: Sourcefile '$SRC' not found" > /dev/stderr; exit 1
+fi
+
+if [ "x$XFAIL" != "xXFAIL" ]; then
+ if ping -n -c5 $TARGET > /dev/null ; then
+ echo "INFO:<$$: $TARGET is up>" > /dev/stderr
+ else
+ echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
+ fi
+fi
+
+declare -i COUNT=0
+
+# Just put the file without checking the data; the get test tests that.
+while [ $SECONDS -le $TIMEOUT ]; do
+tftp $TARGET <<-EOF
+ rexmt 1
+ binary
+ put $SRC $TMP
+EOF
+((COUNT++));
+done
+
+if [ "x$XFAIL" == "xXFAIL" ]; then
+ echo "PASS:<$$: tftp put XFAIL, $TIMEOUT seconds $SIZE bytes $COUNT tries>" > /dev/stderr
+ exit 0
+fi
+
+# Verify it once at the end.
+rm -f $TMP
+tftp $TARGET <<-EOF
+ rexmt 1
+ binary
+ get $TMP $TMP
+EOF
+
+if [ ! -f $TMP ]; then
+ echo "FAIL:<$$: temp file $TMP nonexistent $COUNT xfers>" > /dev/stderr
+ exit 1
+fi
+
+if ! cmp -s $SRC $TMP; then
+ echo "FAIL:<$$: temp file $TMP corrupt $COUNT xfers>" > /dev/stderr
+ exit 1
+fi
+
+echo "PASS:<$$: tftp put OK, $TIMEOUT seconds $SIZE bytes $COUNT xfers>" > /dev/stderr
+
+# EOF
diff --git a/ecos/packages/net/autotest/current/host/tmpfile.c b/ecos/packages/net/autotest/current/host/tmpfile.c
new file mode 100644
index 0000000..e816967
--- /dev/null
+++ b/ecos/packages/net/autotest/current/host/tmpfile.c
@@ -0,0 +1,142 @@
+//==========================================================================
+//
+// tmpfile.c
+//
+// Make a temporary data file for test purposes
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-10-23
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <stdio.h>
+#include <errno.h>
+
+int main( int argc, char **argv )
+{
+ FILE *f;
+ int i;
+ unsigned int size, iirandom, z, csum;
+ char sizec, scratchc;
+
+ if ( 3 > argc || 4 < argc) {
+ usage:
+ fprintf( stderr, "usage: %s filename length [seed]\n", argv[0] );
+ exit(1);
+ }
+
+ f = fopen( argv[1], "rb" );
+ if ( f ) {
+ fclose( f );
+ fprintf( stderr, "File %s already exists\n", argv[1] );
+ goto usage;
+ }
+
+ i = sscanf( argv[2], "%u%1c%1c", &size, &sizec, &scratchc );
+ if ( 0 >= i || 2 < i )
+ goto usage;
+
+ if ( 2 == i )
+ switch ( sizec ) {
+ case 'G': size *= 1024;
+ case 'M': size *= 1024;
+ case 'k': size *= 1024;
+ break;
+ case 'b': size *= 512;
+ break;
+ default:
+ goto usage;
+ }
+
+ iirandom = 0;
+ if ( 4 == argc ) {
+ i = sscanf( argv[3], "%u%1c", &iirandom, &scratchc );
+ if ( 0 >= i || 1 < i )
+ goto usage;
+ }
+
+ f = fopen( argv[1], "wb" );
+ if ( !f ) {
+ perror( "fopen [create]" );
+ goto usage;
+ }
+
+ csum = 0;
+ iirandom += 0x23164920; // What date said
+
+ if ( size > 4 ) i = size-4; else i = size;
+
+ for ( /* i */ ; i > 0; i-- ) {
+ iirandom = iirandom * 91 + 137;
+ iirandom ^= iirandom >> 14 | iirandom << 7;
+ z = (i ^ iirandom) & 0xff;
+ // Keep a simple checksum in case we make some trick to check it in
+ // the pretend filesystem.
+ csum += z;
+ csum = (csum >> (z & 31)) ^ (csum << (32 - (z & 31)));
+ if ( 0 > putc( z, f ) ) {
+ perror( "putc" );
+ fclose( f );
+ exit( 1 );
+ }
+ }
+ // And bung the checksum on the end.
+ for ( i = 4 ; i < size && i > 0; i-- ) {
+ z = csum & 0xff;
+ csum >>= 8;
+ if ( 0 > putc( z, f ) ) {
+ perror( "putc" );
+ fclose( f );
+ exit( 1 );
+ }
+ }
+ fclose( f );
+ exit( 0 );
+}
+
+// EOF awaitorder.c
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_bootp.ptest b/ecos/packages/net/autotest/current/permtests/netauto_bootp.ptest
new file mode 100644
index 0000000..6e4d3fe
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_bootp.ptest
@@ -0,0 +1,13 @@
+
+# add the net and the net drivers
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-autotest
+
+# asserts on
+header infra.h {
+ enable CYGPKG_INFRA_DEBUG
+}
+
+# no DHCP, just bootp
+header net.h {
+ disable CYGPKG_NET_DHCP
+}
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_corrupt.ptest b/ecos/packages/net/autotest/current/permtests/netauto_corrupt.ptest
new file mode 100644
index 0000000..717f75d
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_corrupt.ptest
@@ -0,0 +1,19 @@
+
+# add the net and the net drivers, and the SNMP parts
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-snmplib -enable-snmpagent -enable-autotest
+
+# larger heap for SNMP to run? Not needed any more.
+
+# asserts on
+header infra.h {
+ enable CYGPKG_INFRA_DEBUG
+}
+
+# Simulated failures on:
+header io_eth_drivers.h {
+ enable CYGPKG_IO_ETH_DRIVERS_SIMULATED_FAILURES
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_DROP_RX
+ value CYGPKG_IO_ETH_DRIVERS_SIMULATE_CORRUPT_RX 10
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_DROP_TX
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_LINE_CUT
+}
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_failrx.ptest b/ecos/packages/net/autotest/current/permtests/netauto_failrx.ptest
new file mode 100644
index 0000000..3f3bd65
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_failrx.ptest
@@ -0,0 +1,19 @@
+
+# add the net and the net drivers, and the SNMP parts
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-snmplib -enable-snmpagent -enable-autotest
+
+# larger heap for SNMP to run? Not needed any more.
+
+# asserts on
+header infra.h {
+ enable CYGPKG_INFRA_DEBUG
+}
+
+# Simulated failures on:
+header io_eth_drivers.h {
+ enable CYGPKG_IO_ETH_DRIVERS_SIMULATED_FAILURES
+ value CYGPKG_IO_ETH_DRIVERS_SIMULATE_DROP_RX 10
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_CORRUPT_RX
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_DROP_TX
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_LINE_CUT
+}
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_failtx.ptest b/ecos/packages/net/autotest/current/permtests/netauto_failtx.ptest
new file mode 100644
index 0000000..66953e5
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_failtx.ptest
@@ -0,0 +1,19 @@
+
+# add the net and the net drivers, and the SNMP parts
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-snmplib -enable-snmpagent -enable-autotest
+
+# larger heap for SNMP to run? Not needed any more.
+
+# asserts on
+header infra.h {
+ enable CYGPKG_INFRA_DEBUG
+}
+
+# Simulated failures on:
+header io_eth_drivers.h {
+ enable CYGPKG_IO_ETH_DRIVERS_SIMULATED_FAILURES
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_DROP_RX
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_CORRUPT_RX
+ value CYGPKG_IO_ETH_DRIVERS_SIMULATE_DROP_TX 10
+ disable CYGPKG_IO_ETH_DRIVERS_SIMULATE_LINE_CUT
+}
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_rt.ptest b/ecos/packages/net/autotest/current/permtests/netauto_rt.ptest
new file mode 100644
index 0000000..3307199
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_rt.ptest
@@ -0,0 +1,13 @@
+
+# add the net and the net drivers, and the SNMP parts
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-snmplib -enable-snmpagent -enable-autotest
+
+# larger heap for SNMP to run? Not needed any more.
+
+# use the RealTime test harness, and two loopback interfaces
+header net.h {
+ enable CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS
+ value CYGPKG_NET_NLOOP 2
+}
+
+
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_snmp.ptest b/ecos/packages/net/autotest/current/permtests/netauto_snmp.ptest
new file mode 100644
index 0000000..41183ec
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_snmp.ptest
@@ -0,0 +1,11 @@
+
+# add the net and the net drivers, and the SNMP parts
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-snmplib -enable-snmpagent -enable-autotest
+
+# larger heap for SNMP to run? Not needed any more.
+
+# asserts on
+header infra.h {
+ enable CYGPKG_INFRA_DEBUG
+}
+
diff --git a/ecos/packages/net/autotest/current/permtests/netauto_std.ptest b/ecos/packages/net/autotest/current/permtests/netauto_std.ptest
new file mode 100644
index 0000000..4c7dc44
--- /dev/null
+++ b/ecos/packages/net/autotest/current/permtests/netauto_std.ptest
@@ -0,0 +1,10 @@
+
+# add the net and the net drivers
+pkgconf -disable-uitron -enable-net -enable-net_drivers -enable-autotest
+
+
+# asserts on
+header infra.h {
+ enable CYGPKG_INFRA_DEBUG
+}
+
diff --git a/ecos/packages/net/autotest/current/tests/autohost.inl b/ecos/packages/net/autotest/current/tests/autohost.inl
new file mode 100644
index 0000000..acd2882
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/autohost.inl
@@ -0,0 +1,365 @@
+//==========================================================================
+//
+// tests/auto/autohost.inl
+//
+// Automated Testing by a Host Computer
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-18
+// Purpose: Automated testing of the eCos TCP/IP Network Stack
+// Description:
+
+// This .inl file defines routines which send /orders/ to the server
+// running on the host machine who served us DHCP, and receive
+// /results/ from the same machine or machines.
+//
+// autohost_tell() sends the order to an app "awaitorder" which feeds
+// the order into obey.sh which obeys the order, for example, running
+// some tftp sessions to exercise the tftp server.
+//
+// The /orders/ must come from a predefined list, to match the
+// selection which obey.sh is expecting, for example "TFTP_SERV_GET"
+// which has further parameters <target> <timeout>. Additional
+// parameters are added/manipulated by obey.sh which then invokes a
+// relevent script (tftpget.sh) to do the test.
+//
+// The test script's output is returned to us, and is collected by
+// autohost_getresults() which runs in a high-ist prio thread. It
+// prints the output, which is expected to match the traditional eCos
+// PASS:<happy> FAIL:<eek!> sort of format, so that the test farm can
+// collect these messages from the testcase output, without any direct
+// connection to the server.
+//
+// autohost_init() simply starts the autohost_getresults() thread.
+//
+// The predefined list of orders is *not* defined here or anywhere
+// else besides obey.sh which does a switch statement for them, to
+// make it easier to extent; similarly the params each order takes are
+// not centrally recorded either. It is however a convention that the
+// word following the /order/ is our own IP address.
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include "memcheck.inl" // check on memory usage
+
+externC int sprintf( char * /* str */, const char * /* format */, ... );
+
+// ------------------------------------------------------------------------
+
+#include <pkgconf/system.h>
+#ifdef CYGPKG_IO_ETH_DRIVERS
+#include <pkgconf/io_eth_drivers.h>
+#endif
+
+#if defined(XFAIL) || defined(XPASS)
+// So that the test can override this automation
+# if defined(XFAIL) && defined(XPASS)
+# error Both XFAIL and XPASS predefined
+# endif
+# undef XFAIL
+# ifndef XPASS
+# define XFAIL "XFAIL"
+# endif
+#else
+# ifdef CYGPKG_IO_ETH_DRIVERS_SIMULATED_FAILURES
+// Then we must tell the test server to expect failures.
+# define XFAIL "XFAIL"
+# endif
+#endif // XFAIL/XPASS not predefined
+
+// ------------------------------------------------------------------------
+
+void
+pexit(char *s)
+{
+ TNR_OFF();
+ CYG_TEST_FAIL_EXIT( s );
+}
+
+// ------------------------------------------------------------------------
+
+#define SOURCE_PORT 9980
+#define RESULT_PORT 9990
+
+static int
+autohost_tell( struct bootp *bp, char *orders )
+{
+ int s_host;
+ struct sockaddr_in slave, local;
+ int one = 1;
+ int len = strlen( orders );
+ char ack[32];
+ int ret;
+
+ char complete_order[256];
+
+ if ( len > 240 )
+ pexit( "Orders too long" );
+
+ memset(&slave, 0, sizeof(slave));
+ slave.sin_family = AF_INET;
+ slave.sin_len = sizeof(slave);
+ slave.sin_port = htons(SOURCE_PORT);
+ slave.sin_addr = bp->bp_siaddr; // Talk to our DHCP server
+
+ s_host = socket(AF_INET, SOCK_STREAM, 0);
+ if (s_host < 0) {
+ pexit("stream socket");
+ }
+
+ memset(&local, 0, sizeof(local));
+ local.sin_family = AF_INET;
+ local.sin_len = sizeof(local);
+ local.sin_port = INADDR_ANY;
+ local.sin_addr.s_addr = INADDR_ANY;
+ if(bind(s_host, (struct sockaddr *) &local, sizeof(local)) < 0) {
+ pexit("bind /source/ error");
+ }
+ if (setsockopt(s_host, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
+ pexit("setsockopt /source/ SO_REUSEADDR");
+ }
+
+ ret = connect(s_host, (struct sockaddr *)&slave, sizeof(slave));
+ if ( ret < 0) {
+ TNR_OFF();
+ diag_printf(
+ "Connect failed %d err %d, s_host %d, sin_port %x, sin_addr %08x\n",
+ ret, errno, s_host, slave.sin_port, slave.sin_addr.s_addr );
+ pexit("Can't connect to target");
+ }
+
+ sprintf( complete_order,
+#ifdef XFAIL
+ "%s %s", XFAIL,
+#else
+ "%s",
+#endif
+ orders );
+ len = 1 + strlen( complete_order ); // Send the null also
+
+ if ( len != write(s_host, (unsigned char *)complete_order, len ) ) {
+ pexit("Can't send orders");
+ }
+ ret = read(s_host, (unsigned char *)&ack, sizeof(ack));
+ if ( 0 >= ret ) {
+ pexit("Can't get ACK");
+ }
+ close(s_host);
+ return 1;
+}
+
+// ---------------------------------------------------------------------------
+
+#define nHALTAFTERFAIL
+#ifdef HALTAFTERFAIL
+static cyg_alarm ahr_fail_alarm;
+static cyg_handle_t ahr_fail_alarm_handle = 0;
+static cyg_alarm_t ahr_fail_alarm_function;
+
+void ahr_fail_alarm_function(cyg_handle_t alarm, cyg_addrword_t data)
+{
+ CYG_TEST_FAIL_EXIT( "Failure reported by autohost" );
+}
+#endif
+
+static int result_passes = 0;
+static int result_fails = 0;
+
+static void
+autohost_getresults( cyg_addrword_t loop )
+{
+ int s_source, e_source;
+ struct sockaddr_in e_source_addr, local;
+ int one = 1;
+ int len;
+ char result[256];
+
+ s_source = socket(AF_INET, SOCK_STREAM, 6 /* TCP */ );
+ if (s_source < 0) {
+ pexit("stream socket");
+ }
+
+ memset(&local, 0, sizeof(local));
+ local.sin_family = AF_INET;
+ local.sin_len = sizeof(local);
+ local.sin_port = ntohs(RESULT_PORT);
+ local.sin_addr.s_addr = INADDR_ANY;
+ if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) {
+ pexit("bind /source/ error");
+ }
+ if (setsockopt(s_source, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
+ pexit("setsockopt /source/ SO_REUSEADDR");
+ }
+#ifdef SO_REUSEPORT
+ if (setsockopt(s_source, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one))) {
+ pexit("setsockopt /source/ SO_REUSEPORT");
+ }
+#endif
+
+ listen(s_source, SOMAXCONN);
+
+ do {
+ len = sizeof(e_source_addr);
+ if ((e_source = accept(s_source,
+ (struct sockaddr *)&e_source_addr, &len)) < 0) {
+ pexit("accept /source/");
+ }
+
+ // Wait for "source" to tell us the result
+ if ( 0 >= (len = read(e_source, result, sizeof(result)))) {
+ pexit("Can't read result");
+ }
+
+ result[len] = 0;
+ len--;
+ while( len && ('\r' == result[len] || '\n' == result[len]) )
+ result[len--] = 0;
+
+ TNR_OFF();
+ diag_printf( "%s (from %s:%d)\n", result,
+ inet_ntoa(e_source_addr.sin_addr), ntohs(e_source_addr.sin_port));
+ TNR_ON();
+
+ // Check for a pass message right now:
+ if ( 'P' == result[0] &&
+ 'A' == result[1] &&
+ 'S' == result[2] &&
+ 'S' == result[3] ) {
+ result_passes++;
+ }
+ else
+ // Check for a failure right now:
+ if ( 'F' == result[0] &&
+ 'A' == result[1] &&
+ 'I' == result[2] &&
+ 'L' == result[3] ) {
+ result_fails++;
+#ifdef HALTAFTERFAIL
+ // Wait a bit for the others, if any, to come in before halting
+ // the test, since the host is typically running multiple
+ // threads to torment us. Set an alarm to go FAIL_EXIT in 20S.
+ if ( ! ahr_fail_alarm_handle ) {
+ cyg_handle_t h;
+ cyg_clock_to_counter(cyg_real_time_clock(), &h),
+ cyg_alarm_create(
+ h, /* Attached to this ctr */
+ ahr_fail_alarm_function, /* Call-back function */
+ 0, /* Call-back data */
+ &ahr_fail_alarm_handle, /* Returned alarm obj */
+ &ahr_fail_alarm /* put alarm here */
+ );
+ cyg_alarm_initialize(
+ ahr_fail_alarm_handle,
+ cyg_current_time() + (20 * 100),
+ 0 );
+ cyg_alarm_enable( ahr_fail_alarm_handle );
+ }
+#endif
+ }
+
+ close( e_source );
+ } while ( loop );
+
+ close( s_source );
+}
+
+// ---------------------------------------------------------------------------
+
+static void autohost_end( int expected_passes )
+{
+#ifdef HALTAFTERFAIL
+ if ( ahr_fail_alarm_handle )
+ cyg_alarm_disable( ahr_fail_alarm_handle );
+#endif
+#ifdef XFAIL
+ if ( ! (result_passes >= expected_passes) )
+ CYG_TEST_INFO( "XFAIL: Not enough PASS results posted" );
+ if ( ! (0 == result_fails) )
+ CYG_TEST_INFO( "XFAIL: FAIL results posted" );
+ if ( ! (result_passes >= expected_passes && 0 == result_fails) )
+ CYG_TEST_PASS( "XFAIL: Pass anyway" );
+#else
+ CYG_TEST_CHECK( result_passes >= expected_passes,
+ "Not enough PASS results posted" );
+ CYG_TEST_CHECK( 0 == result_fails,
+ "FAIL results posted" );
+#endif
+ if ( result_passes >= expected_passes && 0 == result_fails )
+ CYG_TEST_PASS( "Results from host[s] OK" );
+
+ // Record and check final state of net stack memory consumption
+ memcheck_final();
+}
+
+// ---------------------------------------------------------------------------
+
+static char ahr_stack[ CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x400 ];
+static cyg_thread ahr_thread_data;
+
+static void autohost_init( void )
+{
+ cyg_handle_t ahr_thread_handle;
+ cyg_thread_create( 5, // Priority - just a number
+ autohost_getresults, // entry
+ 1, // entry parameter
+ "Autohost result monitor", // Name
+ &ahr_stack[0], // Stack
+ sizeof(ahr_stack), // Size
+ &ahr_thread_handle, // Handle
+ &ahr_thread_data // Thread data structure
+ );
+ cyg_thread_resume(ahr_thread_handle); // Start it
+
+ // Record initial state of net stack memory consumption
+ memcheck_init();
+}
+
+// EOF autohost.inl
diff --git a/ecos/packages/net/autotest/current/tests/floodping.c b/ecos/packages/net/autotest/current/tests/floodping.c
new file mode 100644
index 0000000..e6b9b6c
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/floodping.c
@@ -0,0 +1,181 @@
+//==========================================================================
+//
+// autotest/current/tests/floodping.c
+//
+// Flood pinging test, the server floods me and little else.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_ping_tests(struct bootp *bp, int testtime, int filesize)
+{
+ char order[256];
+ diag_printf( "INFO: telling %s to run 1 flood ping for %d seconds, %d bytes\n",
+ inet_ntoa(bp->bp_siaddr), testtime, filesize );
+
+ sprintf( order, "%s %s %d %d", "FLOOD_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize );
+ autohost_tell( bp, order );
+}
+
+#define TESTTIME (5 * 60) // Seconds
+
+void
+net_test(cyg_addrword_t param)
+{
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start PING server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ TNR_INIT();
+
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ do_ping_tests(&eth0_bootp_data, TESTTIME, 56);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ do_ping_tests(&eth1_bootp_data, TESTTIME, 56);
+ }
+#endif
+
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( 0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ + eth0_up
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ + eth1_up
+#endif
+ ); // check for 2 pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+}
+
+// EOF floodping.c
diff --git a/ecos/packages/net/autotest/current/tests/floodpingmux.c b/ecos/packages/net/autotest/current/tests/floodpingmux.c
new file mode 100644
index 0000000..dbf5181
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/floodpingmux.c
@@ -0,0 +1,464 @@
+//==========================================================================
+//
+// autotest/current/tests/floodpingmux.c
+//
+// Flood pinging test, the server floods me and I flood hir.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#define MAX_PACKET 4096
+
+#define NUMTHREADS 3
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + MAX_PACKET + MAX_PACKET + 0x1000)
+static char thread_stack[NUMTHREADS][STACK_SIZE];
+static cyg_thread thread_data[NUMTHREADS];
+static cyg_handle_t thread_handle[NUMTHREADS];
+
+#define DO_DUMPSTATS( seq ) (0 == (0xffff & seq))
+
+#ifdef CYGHWR_NET_DRIVER_ETH0
+struct sockaddr_in host0;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+struct sockaddr_in host1;
+#endif
+static int sock;
+
+static int uniqueid[3] = { 0x1234, 0x4321, 0xdead };
+
+static int ok_recv[3] = { 0,0,0 };
+static int bogus_recv[3] = { 0,0,0 };
+static int pings_sent[3] = { 0,0,0 };
+
+// ------------------------------------------------------------------------
+static void dumpstats(void)
+{
+ TNR_OFF();
+ diag_printf( "------------------------\n" );
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ diag_printf("%16s: Sent %d packets, received %d OK, %d bad\n",
+ inet_ntoa(host0.sin_addr), pings_sent[0],
+ ok_recv[0], bogus_recv[0]);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ diag_printf("%16s: Sent %d packets, received %d OK, %d bad\n",
+ inet_ntoa(host1.sin_addr), pings_sent[1],
+ ok_recv[1], bogus_recv[1]);
+ }
+#endif
+ if ( pings_sent[2] )
+ diag_printf("Wierd! %d unknown sends!\n", pings_sent[2] );
+ if ( ok_recv[2] )
+ diag_printf("Wierd! %d unknown good recvs!\n", ok_recv[2] );
+ if ( bogus_recv[2] )
+ diag_printf("Wierd! %d unknown bogus recvs!\n", bogus_recv[2] );
+ diag_printf( "------------------------\n" );
+ TNR_ON();
+}
+
+
+// ------------------------------------------------------------------------
+// Compute INET checksum
+int
+inet_cksum(u_short *addr, int len)
+{
+ register int nleft = len;
+ register u_short *w = addr;
+ register u_short answer;
+ register u_int sum = 0;
+ u_short odd_byte = 0;
+
+ /*
+ * Our algorithm is simple, using a 32 bit accumulator (sum),
+ * we add sequential 16 bit words to it, and at the end, fold
+ * back all the carry bits from the top 16 bits into the lower
+ * 16 bits.
+ */
+ while( nleft > 1 ) {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ /* mop up an odd byte, if necessary */
+ if( nleft == 1 ) {
+ *(u_char *)(&odd_byte) = *(u_char *)w;
+ sum += odd_byte;
+ }
+
+ /*
+ * add back carry outs from top 16 bits to low 16 bits
+ */
+ sum = (sum >> 16) + (sum & 0x0000ffff); /* add hi 16 to low 16 */
+ sum += (sum >> 16); /* add carry */
+ answer = ~sum; /* truncate to 16 bits */
+ return (answer);
+}
+
+// ------------------------------------------------------------------------
+static void
+show_icmp(unsigned char *pkt, int len, struct sockaddr_in *from)
+{
+ cyg_tick_count_t *tp, tv;
+ struct ip *ip;
+ struct icmp *icmp;
+ int which = 2;
+ tv = cyg_current_time();
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up && (from->sin_addr.s_addr == host0.sin_addr.s_addr) )
+ which = 0;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up && (from->sin_addr.s_addr == host1.sin_addr.s_addr) )
+ which = 1;
+#endif
+
+ ip = (struct ip *)pkt;
+ if ((len < sizeof(*ip)) || ip->ip_v != IPVERSION) {
+ TNR_OFF();
+ diag_printf("%s: Short packet or not IP! - Len: %d, Version: %d\n",
+ inet_ntoa(from->sin_addr), len, ip->ip_v);
+ TNR_ON();
+ bogus_recv[which]++;
+ return;
+ }
+ icmp = (struct icmp *)(pkt + sizeof(*ip));
+ len -= (sizeof(*ip) + 8);
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ if (icmp->icmp_type != ICMP_ECHOREPLY) {
+ TNR_OFF();
+ diag_printf("%s: Invalid ICMP - type: %d\n",
+ inet_ntoa(from->sin_addr), icmp->icmp_type);
+ TNR_ON();
+ bogus_recv[which]++;
+ return;
+ }
+ ok_recv[which]++;
+ if (icmp->icmp_id != uniqueid[which]) {
+ TNR_OFF();
+ diag_printf("%s: ICMP received for wrong id - sent: %x, recvd: %x\n",
+ inet_ntoa(from->sin_addr), uniqueid[which], icmp->icmp_id);
+ TNR_ON();
+ }
+// diag_printf("%d bytes from %s: ", len, inet_ntoa(from->sin_addr));
+// diag_printf("icmp_seq=%d", icmp->icmp_seq);
+// diag_printf(", time=%dms\n", (int)(tv - *tp)*10);
+}
+
+// ------------------------------------------------------------------------
+static void
+floodrecv(cyg_addrword_t p)
+{
+ unsigned char pkt[MAX_PACKET];
+ struct sockaddr_in from;
+ int len, fromlen;
+
+ diag_printf("PING listener...\n" );
+ for (;;) {
+ // Wait for a response
+ fromlen = sizeof(from);
+ len = recvfrom(sock, pkt, sizeof(pkt), 0,
+ (struct sockaddr *)&from, &fromlen);
+ if (len < 0)
+ perror("recvfrom");
+ else
+ show_icmp(pkt, len, &from);
+ }
+}
+
+// ------------------------------------------------------------------------
+static void
+pingsend( int seq, struct sockaddr_in *host,
+ struct icmp *icmp, int icmp_len, int which )
+{
+ cyg_tick_count_t *tp;
+ long *dp;
+ int i;
+ // Build ICMP packet for interface
+ icmp->icmp_type = ICMP_ECHO;
+ icmp->icmp_code = 0;
+ icmp->icmp_cksum = 0;
+ icmp->icmp_seq = seq;
+ icmp->icmp_id = uniqueid[which];
+ // Set up ping data
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ *tp++ = cyg_current_time();
+ dp = (long *)tp;
+ for (i = sizeof(*tp); i < icmp_len; i += sizeof(*dp))
+ *dp++ = i;
+
+ // Add checksum
+ icmp->icmp_cksum = inet_cksum( (u_short *)icmp, icmp_len+8);
+ // Send it off
+ if (sendto(sock, icmp, icmp_len+8, MSG_DONTWAIT,
+ (struct sockaddr *)host, sizeof(*host)) < 0) {
+ perror("sendto");
+ }
+ pings_sent[which]++;
+}
+
+// ------------------------------------------------------------------------
+static void
+floodsend(cyg_addrword_t param)
+{
+ unsigned char pkt0[MAX_PACKET], pkt1[MAX_PACKET];
+
+ struct icmp *icmp0 = (struct icmp *)pkt0;
+ struct icmp *icmp1 = (struct icmp *)pkt1;
+
+ int icmp_len = 64;
+ int seq;
+
+ for (seq = 0; 1 ; seq++) {
+ if ( DO_DUMPSTATS( seq ) )
+ dumpstats();
+
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up)
+ pingsend( seq, &host0, icmp0, icmp_len, 0 );
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up)
+ pingsend( seq, &host1, icmp1, icmp_len, 1 );
+#endif
+ }
+}
+
+
+// ------------------------------------------------------------------------
+
+#include "autohost.inl"
+
+static void
+do_ping_tests(struct bootp *bp, int testtime, int filesize)
+{
+ char order[256];
+ diag_printf( "INFO: telling %s to run 1 flood ping for %d seconds, %d bytes\n",
+ inet_ntoa(bp->bp_siaddr), testtime, filesize );
+
+ sprintf( order, "%s %s %d %d", "FLOOD_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize );
+ autohost_tell( bp, order );
+}
+
+// ------------------------------------------------------------------------
+
+#define TESTTIME (5 * 60) // Seconds
+
+void
+net_test(cyg_addrword_t param)
+{
+ struct protoent *p;
+
+ diag_printf("Start Flood PING test\n");
+ init_all_network_interfaces();
+ diag_printf("Interfaces up:\n");
+
+ if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
+ perror("getprotobyname");
+ return;
+ }
+ sock = socket(AF_INET, SOCK_RAW, p->p_proto);
+ if (sock < 0) {
+ perror("tx socket");
+ return;
+ }
+
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ host0.sin_family = AF_INET;
+ host0.sin_len = sizeof(host0);
+ host0.sin_addr = eth0_bootp_data.bp_siaddr;
+ host0.sin_port = 0;
+ diag_printf("PING server %16s\n", inet_ntoa(host0.sin_addr));
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ host1.sin_family = AF_INET;
+ host1.sin_len = sizeof(host1);
+ host1.sin_addr = eth1_bootp_data.bp_siaddr;
+ host1.sin_port = 0;
+ diag_printf("PING server %16s\n", inet_ntoa(host1.sin_addr));
+ }
+#endif
+ autohost_init();
+
+ TNR_INIT();
+
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ do_ping_tests(&eth0_bootp_data, TESTTIME, 56);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ do_ping_tests(&eth1_bootp_data, TESTTIME, 56);
+ }
+#endif
+
+ // And start the threads that make us ping them, and count the results
+ cyg_thread_resume(thread_handle[1]);
+ cyg_thread_resume(thread_handle[2]);
+
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+
+ // Stop the threads that make us ping them. Thread [2] is the pinger,
+ // thread [1] the receiver so that might as well continue.
+ cyg_thread_suspend(thread_handle[2]);
+
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( 0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ + eth0_up
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ + eth1_up
+#endif
+ ); // check for 2 pass messages from hosts
+
+ diag_printf("After running:\n");
+ dumpstats();
+ TNR_OFF(); // dumpstats() turned it on again!
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &thread_stack[0][0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle[0], // Handle
+ &thread_data[0] // Thread data structure
+ );
+ cyg_thread_resume(thread_handle[0]); // Start it
+
+ // Create the secondary threads
+ cyg_thread_create(11, // Priority - just a number
+ floodrecv, // entry
+ 0, // entry parameter
+ "Flood Ping Recv", // Name
+ &thread_stack[1][0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle[1], // Handle
+ &thread_data[1] // Thread data structure
+ );
+ cyg_thread_create(12, // Priority - just a number
+ floodsend, // entry
+ 0, // entry parameter
+ "Flood Ping Send", // Name
+ &thread_stack[2][0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle[2], // Handle
+ &thread_data[2] // Thread data structure
+ );
+
+ cyg_scheduler_start();
+}
+
+// EOF floodpingmux.c
diff --git a/ecos/packages/net/autotest/current/tests/memcheck.inl b/ecos/packages/net/autotest/current/tests/memcheck.inl
new file mode 100644
index 0000000..aefa938
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/memcheck.inl
@@ -0,0 +1,130 @@
+//==========================================================================
+//
+// tests/auto/memcheck.inl
+//
+// Automated Testing by a Host Computer
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-11-10
+// Purpose: Check memory usage of the eCos TCP/IP Network Stack
+// Description:
+
+#ifndef CYG_NET_GET_MEM_STATS_MISC
+// API is not present, so dummies:
+void memcheck_init( void ) {}
+void memcheck_final( void ) {}
+#else
+
+#include <sys/mbuf.h>
+extern struct mbstat mbstat;
+
+extern void cyg_kmem_print_stats( void );
+
+cyg_mempool_info initial[3], final[3];
+
+#define RATIO 15
+
+static char *names[3] = { "Misc", "Mbufs", "Clusters" };
+
+void memcheck_init( void )
+{
+ int i;
+
+ cyg_kmem_print_stats();
+
+ for ( i = 0; i < 3; i++ )
+ if ( ! cyg_net_get_mem_stats( i, initial + i ) )
+ CYG_TEST_FAIL( "Getting initial mem stats" );
+}
+
+void memcheck_final( void )
+{
+ int i;
+ for ( i = 0; i < 3; i++ )
+ if ( ! cyg_net_get_mem_stats( i, final + i ) )
+ CYG_TEST_FAIL( "Getting final mem stats" );
+
+ cyg_kmem_print_stats();
+
+ // NB do NOT check clusters (index 2) because clusters are managed
+ // differently.
+ for ( i = 0; i < 3; i++ ) {
+ int size = final[i].totalmem;
+ int initial_used = size - initial[i].freemem;
+ int margin = size * RATIO / 100;
+ int final_used = size - final[i].freemem;
+ int extra_used = final_used - initial_used;
+
+ if ( 2 == i ) {
+#ifdef XFAIL
+ // ignore clusters if a faulty network is being simulated
+ // because memory gets eaten for partial packets awaiting
+ // reassembly.
+ continue;
+#else
+ // Then it's clusters - they're managed differently
+ final_used -= (mbstat.m_clfree * final[i].blocksize);
+ extra_used = final_used - initial_used;
+#endif
+ }
+
+ // Using up up to whatever was initially used -or- the percentage
+ // we test for; whichever is larger, is OK.
+ if ( (extra_used > initial_used) && (extra_used > margin) ) {
+ CYG_TEST_INFO( "Memory leak suspected" );
+ CYG_TEST_INFO( names[i] );
+ CYG_TEST_INFO( (final[i].blocksize > 0) ?
+ "Variable mempool" : "Fixed mempool" );
+ CYG_TEST_FAIL( "Too much memory used - storeleak suspected" );
+ }
+ }
+}
+
+#undef RATIO
+
+#endif
+
+// EOF memcheck.inl
diff --git a/ecos/packages/net/autotest/current/tests/route_3.c b/ecos/packages/net/autotest/current/tests/route_3.c
new file mode 100644
index 0000000..4f70503
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/route_3.c
@@ -0,0 +1,74 @@
+//==========================================================================
+//
+// autotest/current/tests/route_3.c
+//
+// Simple pinging test, the server pings me and I ping her.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// Check that we can be pinged by the host(s):
+#define DOHOSTPINGS
+
+// Add a route to net 10.0.3.x via eth0's server
+#define ADDROUTETONET_10_0_3_x
+
+// Add a route to net 10.0.4.x via eth1's server
+//#define ADDROUTETONET_10_0_4_x
+
+// Check the correct working of a global gateway:
+#define PING_WWW_CYGNUS_COM
+
+#include "routeping.inl"
+
+// EOF route_3.c
diff --git a/ecos/packages/net/autotest/current/tests/route_3_4.c b/ecos/packages/net/autotest/current/tests/route_3_4.c
new file mode 100644
index 0000000..a07e4fe
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/route_3_4.c
@@ -0,0 +1,74 @@
+//==========================================================================
+//
+// autotest/current/tests/route_3_4.c
+//
+// Simple pinging test, the server pings me and I ping her.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// Check that we can be pinged by the host(s):
+#define DOHOSTPINGS
+
+// Add a route to net 10.0.3.x via eth0's server
+#define ADDROUTETONET_10_0_3_x
+
+// Add a route to net 10.0.4.x via eth1's server
+#define ADDROUTETONET_10_0_4_x
+
+// Check the correct working of a global gateway:
+#define PING_WWW_CYGNUS_COM
+
+#include "routeping.inl"
+
+// EOF route_3_4.c
diff --git a/ecos/packages/net/autotest/current/tests/route_4.c b/ecos/packages/net/autotest/current/tests/route_4.c
new file mode 100644
index 0000000..5d87038
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/route_4.c
@@ -0,0 +1,74 @@
+//==========================================================================
+//
+// autotest/current/tests/route_4.c
+//
+// Simple pinging test, the server pings me and I ping her.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// Check that we can be pinged by the host(s):
+#define DOHOSTPINGS
+
+// Add a route to net 10.0.3.x via eth0's server
+//#define ADDROUTETONET_10_0_3_x
+
+// Add a route to net 10.0.4.x via eth1's server
+#define ADDROUTETONET_10_0_4_x
+
+// Check the correct working of a global gateway:
+#define PING_WWW_CYGNUS_COM
+
+#include "routeping.inl"
+
+// EOF route_4.c
diff --git a/ecos/packages/net/autotest/current/tests/route_none.c b/ecos/packages/net/autotest/current/tests/route_none.c
new file mode 100644
index 0000000..51e52bb
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/route_none.c
@@ -0,0 +1,74 @@
+//==========================================================================
+//
+// autotest/current/tests/route_none.c
+//
+// Simple pinging test, the server pings me and I ping her.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// Check that we can be pinged by the host(s):
+#define DOHOSTPINGS
+
+// Add a route to net 10.0.3.x via eth0's server
+//#define ADDROUTETONET_10_0_3_x
+
+// Add a route to net 10.0.4.x via eth1's server
+//#define ADDROUTETONET_10_0_4_x
+
+// Check the correct working of a global gateway:
+#define PING_WWW_CYGNUS_COM
+
+#include "routeping.inl"
+
+// EOF route_none.c
diff --git a/ecos/packages/net/autotest/current/tests/routeping.inl b/ecos/packages/net/autotest/current/tests/routeping.inl
new file mode 100644
index 0000000..3177804
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/routeping.inl
@@ -0,0 +1,638 @@
+//==========================================================================
+//
+// autotest/current/tests/routeping.inl
+//
+// Simple pinging test, the server pings me and I ping her.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+// ------------------------------------------------------------------------
+
+externC int sscanf( char * /* str */, const char * /* format */, ... );
+
+// ------------------------------------------------------------------------
+
+static int route_add_s( struct sockaddr_in *target,
+ struct sockaddr_in *gw,
+ int maskbits,
+ int metric )
+{
+ struct ecos_rtentry route;
+ struct sockaddr_in mask;
+
+ int s;
+
+ memcpy( &mask, gw, sizeof(*gw) );
+ maskbits--;
+ mask.sin_addr.s_addr = htonl( (0xfffffffful ^ ((0x80000000ul >> maskbits)-1)) );
+
+ memset( &route, 0, sizeof(route) );
+
+ memcpy( &route.rt_dst , target, sizeof(*target) );
+ memcpy( &route.rt_gateway, gw , sizeof(*gw) );
+ memcpy( &route.rt_genmask, &mask , sizeof(mask) );
+
+ route.rt_flags = RTF_UP|RTF_GATEWAY;
+ route.rt_metric = metric;
+
+ route.rt_dev = NULL;
+
+ diag_printf("INFO:<Route - dst: %s",
+ inet_ntoa(((struct sockaddr_in *)&route.rt_dst)->sin_addr));
+ diag_printf(", mask: %s",
+ inet_ntoa(((struct sockaddr_in *)&route.rt_genmask)->sin_addr));
+ diag_printf(", gateway: %s>\n",
+ inet_ntoa(((struct sockaddr_in *)&route.rt_gateway)->sin_addr));
+
+ s = socket( AF_INET, SOCK_DGRAM, 0 );
+ if (s < 0) {
+ perror( "socket" );
+ return false;
+ }
+ if (ioctl(s, SIOCADDRT, &route)) {
+ perror("SIOCADDRT");
+ close(s);
+ return false;
+ }
+ diag_printf( "PASS:<Route added OK>\n" );
+ close(s);
+ return true;
+}
+
+
+
+int route_add( char *target,
+ char *gw,
+ int maskbits,
+ int metric )
+{
+ struct sockaddr_in t_s, gw_s;
+ int ints[4];
+
+ memset( &t_s, 0, sizeof(t_s) );
+ memset( &gw_s, 0, sizeof(gw_s) );
+
+ t_s.sin_len = gw_s.sin_len = sizeof(t_s);
+ t_s.sin_family = gw_s.sin_family = AF_INET;
+
+ if ( 4 != sscanf( target, "%d.%d.%d.%d", ints, ints+1, ints+2, ints+3 ) )
+ CYG_TEST_FAIL( "sscanf of target IP addr" );
+ else
+ t_s.sin_addr.s_addr = htonl(
+ (ints[0] << 24) |
+ (ints[1] << 16) |
+ (ints[2] << 8) |
+ (ints[3] ) );
+
+ if ( 4 != sscanf( gw, "%d.%d.%d.%d", ints, ints+1, ints+2, ints+3 ) )
+ CYG_TEST_FAIL( "sscanf of target IP addr" );
+ else
+ gw_s.sin_addr.s_addr = htonl(
+ (ints[0] << 24) |
+ (ints[1] << 16) |
+ (ints[2] << 8) |
+ (ints[3] ) );
+
+ return route_add_s( &t_s, &gw_s, maskbits, metric );
+}
+
+// ------------------------------------------------------------------------
+
+#define NUM_PINGS 16
+#define MAX_PACKET 4096
+#define MIN_PACKET 64
+#define MAX_SEND 4000
+
+#define PACKET_ADD ((MAX_SEND - MIN_PACKET)/NUM_PINGS)
+#define nPACKET_ADD 1
+
+static unsigned char pkt1[MAX_PACKET], pkt2[MAX_PACKET];
+
+#define UNIQUEID 0x1234
+
+// Compute INET checksum
+int
+inet_cksum(u_short *addr, int len)
+{
+ register int nleft = len;
+ register u_short *w = addr;
+ register u_short answer;
+ register u_int sum = 0;
+ u_short odd_byte = 0;
+
+ /*
+ * Our algorithm is simple, using a 32 bit accumulator (sum),
+ * we add sequential 16 bit words to it, and at the end, fold
+ * back all the carry bits from the top 16 bits into the lower
+ * 16 bits.
+ */
+ while( nleft > 1 ) {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ /* mop up an odd byte, if necessary */
+ if( nleft == 1 ) {
+ *(u_char *)(&odd_byte) = *(u_char *)w;
+ sum += odd_byte;
+ }
+
+ /*
+ * add back carry outs from top 16 bits to low 16 bits
+ */
+ sum = (sum >> 16) + (sum & 0x0000ffff); /* add hi 16 to low 16 */
+ sum += (sum >> 16); /* add carry */
+ answer = ~sum; /* truncate to 16 bits */
+ return (answer);
+}
+
+static int
+errshorts, errinvalids, errbadids, errwronghosts, errsendtos, errrecvfroms;
+#define ERRRESET() \
+errshorts=errinvalids=errbadids=errwronghosts=errsendtos=errrecvfroms=0
+
+static int
+check_icmp(unsigned char *pkt, int len,
+ struct sockaddr_in *from, struct sockaddr_in *to)
+{
+ cyg_tick_count_t *tp, tv;
+ struct ip *ip;
+ struct icmp *icmp;
+ tv = cyg_current_time();
+ ip = (struct ip *)pkt;
+ if (len < sizeof(*ip))
+ if (ip->ip_v != IPVERSION) {
+ errshorts++;
+ return 0;
+ }
+ icmp = (struct icmp *)(pkt + sizeof(*ip));
+ len -= (sizeof(*ip) + 8);
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ if (icmp->icmp_type != ICMP_ECHOREPLY) {
+ errinvalids++;
+ return 0;
+ }
+ if (icmp->icmp_id != UNIQUEID) {
+ errbadids++;
+ return 0;
+ }
+ if (from->sin_addr.s_addr != to->sin_addr.s_addr) {
+ errwronghosts++;
+ return 0;
+ }
+ return 1;
+}
+
+// expect is
+// 0 - require failure
+// 1 - require success
+// 2 - don't care
+
+#define FAILURE_REQUIRED 0
+#define SUCCESS_REQUIRED 1
+#define NOTHING_REQUIRED 2
+
+static void
+ping_host(int s, struct sockaddr_in *host, int expect )
+{
+ struct icmp *icmp = (struct icmp *)pkt1;
+ int icmp_len = MIN_PACKET;
+ int seq, ok_recv, bogus_recv;
+ cyg_tick_count_t *tp;
+ long *dp;
+ struct sockaddr_in from;
+ int i, len, fromlen;
+
+ ERRRESET();
+ ok_recv = 0;
+ bogus_recv = 0;
+ TNR_OFF();
+ diag_printf("INFO:<PING server %s ....>\n", inet_ntoa(host->sin_addr));
+ for (seq = 0; seq < NUM_PINGS; seq++, icmp_len += PACKET_ADD ) {
+ TNR_ON();
+ cyg_thread_delay( 47 ); // Half a second...
+ // Build ICMP packet
+ icmp->icmp_type = ICMP_ECHO;
+ icmp->icmp_code = 0;
+ icmp->icmp_cksum = 0;
+ icmp->icmp_seq = seq;
+ icmp->icmp_id = 0x1234;
+ // Set up ping data
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ *tp++ = cyg_current_time();
+ dp = (long *)tp;
+ for (i = sizeof(*tp); i < icmp_len; i += sizeof(*dp)) {
+ *dp++ = i;
+ }
+ // Add checksum
+ icmp->icmp_cksum = inet_cksum( (u_short *)icmp, icmp_len+8);
+ // Send it off
+ if (sendto(s, icmp, icmp_len+8, 0, (struct sockaddr *)host, sizeof(*host)) < 0) {
+ errsendtos++;
+ continue;
+ }
+ // Wait for a response
+ fromlen = sizeof(from);
+ len = recvfrom(s, pkt2, sizeof(pkt2), 0, (struct sockaddr *)&from, &fromlen);
+ if (len < 0) {
+ errrecvfroms++;
+ icmp_len = MIN_PACKET - PACKET_ADD; // just in case - long routes
+ } else {
+ if ( check_icmp(pkt2, len, &from, host) )
+ ok_recv++;
+ else
+ bogus_recv++;
+ }
+ }
+ TNR_OFF();
+ diag_printf("INFO:<Sent %d packets, received %d OK, %d bad>\n", NUM_PINGS, ok_recv, bogus_recv);
+ if ( errsendtos + errrecvfroms )
+ diag_printf("INFO:<%d sendto errors, %d recvfrom errors>\n", errsendtos, errrecvfroms );
+
+ if ( SUCCESS_REQUIRED == expect ) {
+ CYG_TEST_CHECK( 0 < ok_recv, "No pings succeeded" );
+ CYG_TEST_CHECK( 0 == errsendtos, "Sendto failures" );
+#ifndef XFAIL
+ CYG_TEST_CHECK( NUM_PINGS/2 < ok_recv, "Not enough pings succeeded" );
+ CYG_TEST_CHECK( NUM_PINGS/2 > bogus_recv, "Too many pings failed" );
+#endif
+ }
+ if ( FAILURE_REQUIRED == expect ) {
+ CYG_TEST_CHECK( 0 == ok_recv, "Pings succeeded" );
+ CYG_TEST_CHECK( bogus_recv + errsendtos + errrecvfroms == NUM_PINGS, "Not enough failures" );
+#ifndef XFAIL
+ CYG_TEST_CHECK( 0 == bogus_recv, "Some pings got bogus recv" );
+#endif
+ }
+ CYG_TEST_PASS( SUCCESS_REQUIRED == expect ? "Expected successful ping behaviour" :
+ FAILURE_REQUIRED == expect ? "Expected failure ping behaviour" :
+ "Non-predicted ping behaviour" );
+
+ TNR_ON();
+ return;
+}
+
+static void
+ping_test(struct bootp *bp)
+{
+ struct protoent *p;
+ struct timeval tv;
+ struct sockaddr_in host;
+ int s;
+
+ if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
+ pexit("getprotobyname");
+ return;
+ }
+ s = socket(AF_INET, SOCK_RAW, p->p_proto);
+ if (s < 0) {
+ pexit("socket");
+ return;
+ }
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ // Set up host address
+ host.sin_family = AF_INET;
+ host.sin_len = sizeof(host);
+ host.sin_addr = bp->bp_siaddr;
+ host.sin_port = 0;
+ ping_host(s, &host, SUCCESS_REQUIRED );
+ // Now try a bogus host
+ host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) + 32);
+ ping_host(s, &host, NOTHING_REQUIRED ); // Success is optional
+ close(s);
+}
+
+static void
+station_ping(char *name, int expect)
+{
+ struct protoent *p;
+ struct timeval tv;
+ struct sockaddr_in host;
+ int s;
+
+ int ints[4];
+
+ if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
+ pexit("getprotobyname");
+ return;
+ }
+ s = socket(AF_INET, SOCK_RAW, p->p_proto);
+ if (s < 0) {
+ pexit("socket");
+ return;
+ }
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ // Set up host address
+ host.sin_family = AF_INET;
+ host.sin_len = sizeof(host);
+ host.sin_port = 0;
+
+ if ( 4 != sscanf( name, "%d.%d.%d.%d", ints, ints+1, ints+2, ints+3 ) )
+ CYG_TEST_FAIL( "sscanf of host IP addr" );
+ else {
+ host.sin_addr.s_addr = htonl(
+ (ints[0] << 24) |
+ (ints[1] << 16) |
+ (ints[2] << 8) |
+ (ints[3] ) );
+
+ ping_host(s, &host, expect );
+
+ }
+ close(s);
+}
+
+// ------------------------------------------------------------------------
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_ping_tests(struct bootp *bp, int N, int testtime, int filesize)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d pings for %d seconds, %d bytes and up\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime, filesize );
+
+ // For 2nd and subsequent orders, we vary the ping data size:
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d %d", "SLOW_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize + 100 * i );
+ autohost_tell( bp, order );
+ }
+}
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 10 // why not?
+
+// ------------------------------------------------------------------------
+//
+// The plan is as follows:
+//
+// The host(s) will be set up so as to have additional interfaces as follows:
+//
+// eth0-host -> 10.0.3.1 and maybe others
+// eth1-host -> 10.0.4.1 and maybe others
+// 10.0.5.x should not exist
+//
+// These additional addresses can exist as extra loopback addresses, lo0:0,
+// lo0:1 and so on in a linux box.
+//
+// We want to ping all of the following:
+//
+// eth0-host should always work
+// eth0-host+32 not expected to work
+// eth1-host should always work
+// eth1-host+32 not expected to work
+// www.cygnus.com should always work if default gw is correct
+// 10.0.3.1 should only work if route via eth0-host is added
+// 10.0.3.99 might work if route via eth0-host is added
+// 10.0.4.1 should only work if route via eth0-host is added
+// 10.0.4.99 might work if route via eth0-host is added
+// 10.0.5.1 should never work
+// 10.0.5.99 should never work
+//
+// So we test those places in the following contexts:
+//
+// 1) No special routing added
+// 2) route via eth0-host to 10.0.3.x is added
+// 3) route via eth1-host to 10.0.4.x is added
+// 4) Both routes are added
+//
+// and check for correct operation and correct failure in all cases.
+//
+// Because of the time taken, these are separate test cases which include
+// this INL file after making suitable #defines.
+//
+// All the while, the hosts shall ping us, and when all is going we loop for
+// the rest of the test time.
+//
+
+void
+net_test(cyg_addrword_t param)
+{
+#ifdef DOHOSTPINGS
+ int i;
+ int numtests;
+#endif
+ int net3expect = FAILURE_REQUIRED;
+ int net4expect = FAILURE_REQUIRED;
+
+ cyg_tick_count_t ticks;
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start PING routing test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ TNR_INIT();
+
+#ifdef ADDROUTETONET_10_0_3_x
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ route_add( "10.0.3.0", inet_ntoa(eth0_bootp_data.bp_siaddr), 24, 1 );
+ net3expect = SUCCESS_REQUIRED;
+ }
+#endif
+#endif // ADDROUTETONET_10_0_3_x
+
+#ifdef ADDROUTETONET_10_0_4_x
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ route_add( "10.0.4.0", inet_ntoa(eth1_bootp_data.bp_siaddr), 24, 1 );
+ net4expect = SUCCESS_REQUIRED;
+ }
+#endif
+#endif // ADDROUTETONET_10_0_4_x
+
+ numtests = NUM_SESSIONS; // The number of pingers started OK
+ i = numtests;
+#ifdef DOHOSTPINGS
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 64);
+ do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 2000);
+ i -= 2;
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up && i > 0) {
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 100);
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 1800);
+ i -= 2;
+ }
+#endif
+#endif // DOHOSTPINGS
+ numtests -= i; // Adjust to how many we *actually* requested
+
+ ticks = cyg_current_time() + TESTTIME * 100; // FIXME - assume cS clock.
+
+ // Let the server run for 5 minutes
+ TNR_ON();
+
+ while (1) {
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up)
+ ping_test(&eth0_bootp_data);
+ if ( ticks < cyg_current_time() ) break;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up)
+ ping_test(&eth1_bootp_data);
+ if ( ticks < cyg_current_time() ) break;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ station_ping( "10.0.3.1", net3expect );
+ if ( ticks < cyg_current_time() ) break;
+ station_ping( "10.0.3.99", net3expect );
+ }
+ if ( ticks < cyg_current_time() ) break;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ station_ping( "10.0.4.1", net4expect );
+ if ( ticks < cyg_current_time() ) break;
+ station_ping( "10.0.4.99", net4expect );
+ }
+ if ( ticks < cyg_current_time() ) break;
+#endif
+ station_ping( "10.0.5.1", FAILURE_REQUIRED ); // Not valid
+ if ( ticks < cyg_current_time() ) break;
+ station_ping( "10.0.5.99", FAILURE_REQUIRED ); // Not valid
+ if ( ticks < cyg_current_time() ) break;
+#ifdef PING_WWW_CYGNUS_COM
+ station_ping( "205.180.83.41", NOTHING_REQUIRED ); // www.cygnus.com
+ if ( ticks < cyg_current_time() ) break;
+#endif
+ };
+
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( 0 ); // check for N pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+}
+
+// EOF routeping.inl
diff --git a/ecos/packages/net/autotest/current/tests/slowping.c b/ecos/packages/net/autotest/current/tests/slowping.c
new file mode 100644
index 0000000..5d0bf6a
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/slowping.c
@@ -0,0 +1,199 @@
+//==========================================================================
+//
+// autotest/current/tests/slowping.c
+//
+// Simple pinging test, the server pings me and little else.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_ping_tests(struct bootp *bp, int N, int testtime, int filesize)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d pings for %d seconds, %d bytes and up\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime, filesize );
+
+ // For 2nd and subsequent orders, we vary the ping data size:
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d %d", "SLOW_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize + 50 * i );
+ autohost_tell( bp, order );
+ }
+}
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 10 // why not?
+
+void
+net_test(cyg_addrword_t param)
+{
+ int i;
+ int numtests;
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start PING server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ TNR_INIT();
+
+ numtests = NUM_SESSIONS; // The number of pingers started OK
+ i = numtests;
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ // 2 small tests by default and a couple of larger ones
+ do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 64);
+ do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 1000);
+ do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 10000);
+ i -= 6;
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up && i > 0) {
+ // rest of the tests depending...
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 64);
+ i--;
+ if ( i > 0 ) {
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 4000);
+ i--;
+ }
+ if ( i > 0 ) {
+ do_ping_tests(&eth1_bootp_data, i, TESTTIME, 1200);
+ i = 0;
+ }
+ }
+#endif
+ numtests -= i; // Adjust to how many we *actually* requested
+
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( numtests ); // check for N pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+}
+
+// EOF slowping.c
diff --git a/ecos/packages/net/autotest/current/tests/slowpingmux.c b/ecos/packages/net/autotest/current/tests/slowpingmux.c
new file mode 100644
index 0000000..a94fe37
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/slowpingmux.c
@@ -0,0 +1,389 @@
+//==========================================================================
+//
+// autotest/current/tests/slowpingmux.c
+//
+// Simple pinging test, the server pings me and I ping her.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+
+#define NUM_PINGS 16
+#define MAX_PACKET 4096
+#define MIN_PACKET 64
+#define MAX_SEND 4000
+
+#define PACKET_ADD ((MAX_SEND - MIN_PACKET)/NUM_PINGS)
+#define nPACKET_ADD 1
+
+static unsigned char pkt1[MAX_PACKET], pkt2[MAX_PACKET];
+
+#define UNIQUEID 0x1234
+
+// Compute INET checksum
+int
+inet_cksum(u_short *addr, int len)
+{
+ register int nleft = len;
+ register u_short *w = addr;
+ register u_short answer;
+ register u_int sum = 0;
+ u_short odd_byte = 0;
+
+ /*
+ * Our algorithm is simple, using a 32 bit accumulator (sum),
+ * we add sequential 16 bit words to it, and at the end, fold
+ * back all the carry bits from the top 16 bits into the lower
+ * 16 bits.
+ */
+ while( nleft > 1 ) {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ /* mop up an odd byte, if necessary */
+ if( nleft == 1 ) {
+ *(u_char *)(&odd_byte) = *(u_char *)w;
+ sum += odd_byte;
+ }
+
+ /*
+ * add back carry outs from top 16 bits to low 16 bits
+ */
+ sum = (sum >> 16) + (sum & 0x0000ffff); /* add hi 16 to low 16 */
+ sum += (sum >> 16); /* add carry */
+ answer = ~sum; /* truncate to 16 bits */
+ return (answer);
+}
+
+static int
+show_icmp(unsigned char *pkt, int len,
+ struct sockaddr_in *from, struct sockaddr_in *to)
+{
+ cyg_tick_count_t *tp, tv;
+ struct ip *ip;
+ struct icmp *icmp;
+ tv = cyg_current_time();
+ ip = (struct ip *)pkt;
+ if ((len < sizeof(*ip)) || ip->ip_v != IPVERSION) {
+ diag_printf("%s: Short packet or not IP! - Len: %d, Version: %d\n",
+ inet_ntoa(from->sin_addr), len, ip->ip_v);
+ return 0;
+ }
+ icmp = (struct icmp *)(pkt + sizeof(*ip));
+ len -= (sizeof(*ip) + 8);
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ if (icmp->icmp_type != ICMP_ECHOREPLY) {
+ diag_printf("%s: Invalid ICMP - type: %d\n",
+ inet_ntoa(from->sin_addr), icmp->icmp_type);
+ return 0;
+ }
+ if (icmp->icmp_id != UNIQUEID) {
+ diag_printf("%s: ICMP received for wrong id - sent: %x, recvd: %x\n",
+ inet_ntoa(from->sin_addr), UNIQUEID, icmp->icmp_id);
+ }
+// diag_printf("%d bytes from %s: ", len, inet_ntoa(from->sin_addr));
+// diag_printf("icmp_seq=%d", icmp->icmp_seq);
+// diag_printf(", time=%dms\n", (int)(tv - *tp)*10);
+ return (from->sin_addr.s_addr == to->sin_addr.s_addr);
+}
+
+static void
+ping_host(int s, struct sockaddr_in *host)
+{
+ struct icmp *icmp = (struct icmp *)pkt1;
+ int icmp_len = MIN_PACKET;
+ int seq, ok_recv, bogus_recv;
+ cyg_tick_count_t *tp;
+ long *dp;
+ struct sockaddr_in from;
+ int i, len, fromlen;
+ int maxlen = 0;
+
+ ok_recv = 0;
+ bogus_recv = 0;
+ TNR_OFF();
+ diag_printf("PING server %s\n", inet_ntoa(host->sin_addr));
+ for (seq = 0; seq < NUM_PINGS; seq++, icmp_len += PACKET_ADD ) {
+ TNR_ON();
+ cyg_thread_delay( 47 ); // Half a second...
+ // Build ICMP packet
+ icmp->icmp_type = ICMP_ECHO;
+ icmp->icmp_code = 0;
+ icmp->icmp_cksum = 0;
+ icmp->icmp_seq = seq;
+ icmp->icmp_id = 0x1234;
+ // Set up ping data
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ *tp++ = cyg_current_time();
+ dp = (long *)tp;
+ for (i = sizeof(*tp); i < icmp_len; i += sizeof(*dp)) {
+ *dp++ = i;
+ }
+ // Add checksum
+ icmp->icmp_cksum = inet_cksum( (u_short *)icmp, icmp_len+8);
+ // Send it off
+ if (sendto(s, icmp, icmp_len+8, 0, (struct sockaddr *)host, sizeof(*host)) < 0) {
+ TNR_OFF();
+ perror("sendto");
+ continue;
+ }
+ // Wait for a response
+ fromlen = sizeof(from);
+ len = recvfrom(s, pkt2, sizeof(pkt2), 0, (struct sockaddr *)&from, &fromlen);
+ TNR_OFF();
+ if (len < 0) {
+// perror("recvfrom");
+ icmp_len = MIN_PACKET - PACKET_ADD; // just in case - long routes
+ } else {
+ if (show_icmp(pkt2, len, &from, host)) {
+ ok_recv++;
+ if ( len > maxlen )
+ maxlen = len;
+ } else {
+ bogus_recv++;
+ }
+ }
+ }
+ TNR_OFF();
+ diag_printf("Sent %d packets, received %d OK, %d bad max len %d\n",
+ NUM_PINGS, ok_recv, bogus_recv, maxlen);
+}
+
+static void
+ping_test(struct bootp *bp)
+{
+ struct protoent *p;
+ struct timeval tv;
+ struct sockaddr_in host;
+ int s;
+
+ if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
+ pexit("getprotobyname");
+ return;
+ }
+ s = socket(AF_INET, SOCK_RAW, p->p_proto);
+ if (s < 0) {
+ pexit("socket");
+ return;
+ }
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ // Set up host address
+ host.sin_family = AF_INET;
+ host.sin_len = sizeof(host);
+ host.sin_addr = bp->bp_siaddr;
+ host.sin_port = 0;
+ ping_host(s, &host);
+ // Now try a bogus host
+ host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) + 32);
+ ping_host(s, &host);
+ close(s);
+}
+
+// ------------------------------------------------------------------------
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_ping_tests(struct bootp *bp, int N, int testtime, int filesize)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d pings for %d seconds, %d bytes and up\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime, filesize );
+
+ // For 2nd and subsequent orders, we vary the ping data size:
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d %d", "SLOW_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize + 100 * i );
+ autohost_tell( bp, order );
+ }
+}
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 10 // why not?
+
+void
+net_test(cyg_addrword_t param)
+{
+ int i;
+ int numtests;
+ cyg_tick_count_t ticks;
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start PING server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ TNR_INIT();
+
+ numtests = NUM_SESSIONS; // The number of pingers started OK
+ i = numtests;
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ // 2 small tests by default and a couple of larger ones
+ do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 64);
+ do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 1000);
+ do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 10000);
+ i -= 5;
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up && i > 0) {
+ // rest of the tests depending...
+ do_ping_tests(&eth1_bootp_data, 2, TESTTIME, 64);
+ i -= 2;
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 4000);
+ i -= 1;
+ do_ping_tests(&eth1_bootp_data, i, TESTTIME, 1200);
+ i = 0; // Since we just used up the rest
+ }
+#endif
+ numtests -= i; // Adjust to how many we *actually* requested
+
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+
+ ticks = cyg_current_time() + TESTTIME * 100; // FIXME - assume cS clock.
+ while (1) {
+ if ( ticks < cyg_current_time() ) break;
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ ping_test(&eth0_bootp_data);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if ( ticks < cyg_current_time() ) break;
+ if (eth1_up) {
+ ping_test(&eth1_bootp_data);
+ }
+#endif
+ };
+
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( numtests ); // check for N pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+}
+
+// EOF slowpingmux.c
diff --git a/ecos/packages/net/autotest/current/tests/snmpmulti.c b/ecos/packages/net/autotest/current/tests/snmpmulti.c
new file mode 100644
index 0000000..5064692
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/snmpmulti.c
@@ -0,0 +1,201 @@
+//==========================================================================
+//
+// autotest/current/tests/snmpmulti.c
+//
+// Simple pinging test, the server pings me and little else.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_snmp_tests(struct bootp *bp, int N, int testtime)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d snmpwalks for %d seconds\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime );
+
+#ifdef XFAIL
+ // reduce the time to run so that we get a result
+ testtime *= 3;
+ testtime /= 4;
+#endif
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d", "SNMP_WALK",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime );
+ autohost_tell( bp, order );
+ }
+}
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 10 // why not?
+
+void
+net_test(cyg_addrword_t param)
+{
+ extern void cyg_net_snmp_init(void);
+
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start multiple SNMP server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ cyg_net_snmp_init();
+
+ TNR_INIT();
+
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ do_snmp_tests(&eth0_bootp_data, 3, TESTTIME);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ do_snmp_tests(&eth1_bootp_data, 3, TESTTIME);
+ }
+#endif
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( 3 * (0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ + eth0_up
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ + eth1_up
+#endif
+ ) ); // check for N pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
+
+void
+cyg_start(void)
+{
+#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+#else
+ CYG_TEST_NA( "No SNMP agent in this configuration" );
+#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
+}
+
+// EOF snmpmulti.c
diff --git a/ecos/packages/net/autotest/current/tests/snmppings.c b/ecos/packages/net/autotest/current/tests/snmppings.c
new file mode 100644
index 0000000..4e6c212
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/snmppings.c
@@ -0,0 +1,249 @@
+//==========================================================================
+//
+// autotest/current/tests/snmppings.c
+//
+// Simple pinging test, the server pings me and little else.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_ping_tests(struct bootp *bp, int N, int testtime, int filesize)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d pings for %d seconds, %d bytes and up\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime, filesize );
+
+ // For 2nd and subsequent orders, we vary the ping data size:
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d %d", "SLOW_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize + 50 * i );
+ autohost_tell( bp, order );
+ }
+}
+
+static void
+do_snmp_tests(struct bootp *bp, int N, int testtime)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d snmpwalks for %d seconds\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime );
+
+#ifdef XFAIL
+ // reduce the time to run so that we get a result
+ testtime *= 3;
+ testtime /= 4;
+#endif
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d", "SNMP_WALK",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime );
+ autohost_tell( bp, order );
+ }
+}
+
+static void
+do_flood_tests(struct bootp *bp, int testtime, int on, int off)
+{
+ char order[256];
+ diag_printf( "INFO: telling %s to run 1 flood ping for %d seconds, %d/%d flood/sleep\n",
+ inet_ntoa(bp->bp_siaddr), testtime, on, off );
+
+ sprintf( order, "%s %s %d %d %d %d", "FLOOD_PING",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ 56, // constant size
+ on, off );
+ autohost_tell( bp, order );
+}
+
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 10 // why not?
+
+void
+net_test(cyg_addrword_t param)
+{
+ extern void cyg_net_snmp_init(void);
+
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start multiple SNMP server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ cyg_net_snmp_init();
+
+ TNR_INIT();
+
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ // Two SNMP walk tests
+ do_snmp_tests(&eth0_bootp_data, 2, TESTTIME);
+ // ...and flood ping for one second in 10
+ do_flood_tests(&eth0_bootp_data, TESTTIME, 1, 9 );
+ // ...and ping a couple of times too, 56 bytes and 2000 bytes.
+ do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 56 );
+ do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 2000 );
+ // which makes 5 tests in all.
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ // Two SNMP walk tests
+ do_snmp_tests(&eth1_bootp_data, 2, TESTTIME);
+ // ...and flood ping for two seconds in 13
+ do_flood_tests(&eth1_bootp_data, TESTTIME, 2, 11 );
+ // ...and ping a couple of times too, 500 bytes and 1600 bytes.
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 500 );
+ do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 1600 );
+ // which makes 5 tests in all.
+ }
+#endif
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( 5 * (0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ + eth0_up
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ + eth1_up
+#endif
+ ) ); // check for N pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
+
+void
+cyg_start(void)
+{
+#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+#else
+ CYG_TEST_NA( "No SNMP agent in this configuration" );
+#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
+}
+
+// EOF snmppings.c
diff --git a/ecos/packages/net/autotest/current/tests/snmpwalk.c b/ecos/packages/net/autotest/current/tests/snmpwalk.c
new file mode 100644
index 0000000..eeb6683
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/snmpwalk.c
@@ -0,0 +1,201 @@
+//==========================================================================
+//
+// autotest/current/tests/snmpwalk.c
+//
+// Simple pinging test, the server pings me and little else.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-23
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+
+#include "autohost.inl"
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_snmp_tests(struct bootp *bp, int N, int testtime)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d snmpwalks for %d seconds\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime );
+
+#ifdef XFAIL
+ // reduce the time to run so that we get a result
+ testtime *= 3;
+ testtime /= 4;
+#endif
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d", "SNMP_WALK",
+ inet_ntoa(bp->bp_yiaddr),
+ testtime );
+ autohost_tell( bp, order );
+ }
+}
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 10 // why not?
+
+void
+net_test(cyg_addrword_t param)
+{
+ extern void cyg_net_snmp_init(void);
+
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start simple SNMP server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ cyg_net_snmp_init();
+
+ TNR_INIT();
+
+ // Now command the host to do ping to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ do_snmp_tests(&eth0_bootp_data, 1, TESTTIME);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ do_snmp_tests(&eth1_bootp_data, 1, TESTTIME);
+ }
+#endif
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the stuff start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ autohost_end( 0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ + eth0_up
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ + eth1_up
+#endif
+ ); // check for 2 pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
+
+void
+cyg_start(void)
+{
+#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+#else
+ CYG_TEST_NA( "No SNMP agent in this configuration" );
+#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
+}
+
+// EOF snmpwalk.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv.inl b/ecos/packages/net/autotest/current/tests/tftp_serv.inl
new file mode 100644
index 0000000..189e04f
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv.inl
@@ -0,0 +1,227 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv.inl
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+// ------------------------------------------------------------------------
+
+#include <errno.h>
+#include <network.h>
+#include <tftp_support.h>
+
+#include "autohost.inl"
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+static void
+do_tftp_tests(struct bootp *bp, int N, int testtime, int filesize)
+{
+ int i;
+ char order[256];
+ diag_printf( "INFO: telling %s to run %d tests for %d seconds, %d+/-%d bytes\n",
+ inet_ntoa(bp->bp_siaddr), N, testtime, filesize, N-1 );
+
+ // For 2nd and subsequent orders, we vary the filesize, thus testing
+ // together: 0 and 1 bytes; 512 and 513 bytes; 1Mb and 1Mb-1; in the
+ // standard invocations of this test. Don't go over 1Mb.
+ for ( i = 0; i < N; i++ ) {
+ sprintf( order, "%s %s %d %d", OPERATION,
+ inet_ntoa(bp->bp_yiaddr),
+ testtime,
+ filesize + ((filesize < (1024*1024)) ? i : -i ) );
+ autohost_tell( bp, order );
+ }
+}
+
+#define NUM_SERVERS 4
+static int servers[NUM_SERVERS] = { 0 };
+
+#define TESTTIME (5 * 60) // Seconds
+
+#define NUM_SESSIONS 3 // the dummy fileops system can only accept 3 new files
+
+void
+net_test(cyg_addrword_t param)
+{
+ int i;
+ int numtests;
+ CYG_TEST_INIT();
+ CYG_TEST_INFO("Start TFTP server test");
+ init_all_network_interfaces();
+
+ autohost_init();
+
+ TNR_INIT();
+
+ // Create TFTP servers
+ for ( i = 0; i < NUM_SERVERS; i++ ) {
+ extern struct tftpd_fileops dummy_fileops;
+ int server_id = tftpd_start(0, &dummy_fileops);
+ if (server_id > 0) {
+ diag_printf("INFO: TFTP server %d created - id: %x\n", i, server_id);
+ servers[i] = server_id;
+ }
+ else {
+ diag_printf("INFO: TFTP server %d NOT created [%x]\n", i, server_id);
+ i--;
+ break;
+ }
+ }
+
+ numtests = i; // The number of servers started OK
+ if ( numtests > NUM_SESSIONS )
+ numtests = NUM_SESSIONS;
+ i = numtests;
+
+ if ( i < 1 ) {
+ CYG_TEST_FAIL_EXIT( "Not enough TFTP servers created" );
+ }
+
+ // Now command the host to do tftp to us...
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ // 2 tests by default - if we have enough servers
+ if ( i > 1 ) {
+ do_tftp_tests(&eth0_bootp_data, 2, TESTTIME, FILESIZE);
+ i -= 2;
+ }
+ else {
+ do_tftp_tests(&eth0_bootp_data, 1, TESTTIME, FILESIZE);
+ i -= 1;
+ }
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up && i > 0) {
+ // rest of the tests depending...
+ do_tftp_tests(&eth1_bootp_data, i, TESTTIME, FILESIZE);
+ i = 0;
+ }
+#endif
+ numtests -= i; // Adjust to how many we *actually* requested
+
+ // Let the server run for 5 minutes
+ cyg_thread_delay(2*100); // let the tftpds start up first
+ TNR_ON();
+ cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
+ // Additional delay 'cos host may be slower than us - and it has to
+ // complete a transfer anyway:
+ cyg_thread_delay( 30 *100); // FIXME - assume cS clock.
+ TNR_OFF();
+
+ for ( i = 0; i < NUM_SERVERS; i++ ) {
+ int server_id = servers[i];
+ if ( server_id ) {
+ int res = tftpd_stop(servers[i]);
+ diag_printf("INFO: TFTP server %d stopped - res: %d\n", i, res);
+ CYG_TEST_CHECK( res > 0, "TFTP server did not die" );
+ }
+ }
+
+ autohost_end( numtests ); // check for 3 pass messages from hosts
+
+ TNR_PRINT_ACTIVITY();
+ CYG_TEST_EXIT("Done");
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+}
+
+// EOF tftp_serv.inl
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_g0.c b/ecos/packages/net/autotest/current/tests/tftp_serv_g0.c
new file mode 100644
index 0000000..739ce88
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_g0.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_g0.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_GET"
+#define FILESIZE 0
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_g0.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_g1M.c b/ecos/packages/net/autotest/current/tests/tftp_serv_g1M.c
new file mode 100644
index 0000000..ae7cf2c
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_g1M.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_g1M.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_GET"
+#define FILESIZE (1024 * 1024)
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_g1M.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_g512.c b/ecos/packages/net/autotest/current/tests/tftp_serv_g512.c
new file mode 100644
index 0000000..88b00ff
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_g512.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_g512.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_GET"
+#define FILESIZE 512
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_g512.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_get.c b/ecos/packages/net/autotest/current/tests/tftp_serv_get.c
new file mode 100644
index 0000000..e32659c
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_get.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_get.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_GET"
+#define FILESIZE (512 * 512 - 128)
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_get.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_p0.c b/ecos/packages/net/autotest/current/tests/tftp_serv_p0.c
new file mode 100644
index 0000000..8a5e9bf
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_p0.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_p0.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_PUT"
+#define FILESIZE 0
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_p0.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_p1M.c b/ecos/packages/net/autotest/current/tests/tftp_serv_p1M.c
new file mode 100644
index 0000000..fa17285
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_p1M.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_p1M.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_PUT"
+#define FILESIZE (1024 * 1024)
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_p1M.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_p512.c b/ecos/packages/net/autotest/current/tests/tftp_serv_p512.c
new file mode 100644
index 0000000..3bf37f0
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_p512.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_p512.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_PUT"
+#define FILESIZE 512
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_p512.c
diff --git a/ecos/packages/net/autotest/current/tests/tftp_serv_put.c b/ecos/packages/net/autotest/current/tests/tftp_serv_put.c
new file mode 100644
index 0000000..9e06ff4
--- /dev/null
+++ b/ecos/packages/net/autotest/current/tests/tftp_serv_put.c
@@ -0,0 +1,72 @@
+//==========================================================================
+//
+// tests/auto/tftp_serv_put.c
+//
+// Automated Multiple TFTP server GET test
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt,gthomas
+// Contributors: hmt,gthomas
+// Date: 2000-10-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+// TFTP test code
+
+#include <pkgconf/system.h>
+
+#include <cyg/infra/testcase.h> // testing infrastructure
+
+#include <pkgconf/net.h>
+
+#define OPERATION "TFTP_SERV_PUT"
+#define FILESIZE (512 * 512 + 128)
+
+#include "tftp_serv.inl"
+
+// EOF tftp_serv_put.c