annotate packages/net/ppp/current/tests/nc_test_framework.h @ 1586:e0d88dc6a92f

Added PPP network support.
author nickg
date Wed, 14 Apr 2004 15:08:56 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
1 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
2 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
3 // tests/nc_test_framework.h
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
4 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
5 // Network characterization tests framework
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
6 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
7 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
8 //####ECOSGPLCOPYRIGHTBEGIN####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
9 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
11 // Portions created by Nick Garnett are
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
12 // Copyright (C) 2003 eCosCentric Ltd.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
13 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
14 // eCos is free software; you can redistribute it and/or modify it under
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
15 // the terms of the GNU General Public License as published by the Free
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
16 // Software Foundation; either version 2 or (at your option) any later version.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
17 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
21 // for more details.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
22 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
23 // You should have received a copy of the GNU General Public License along
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
26 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
27 // As a special exception, if other files instantiate templates or use macros
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
28 // or inline functions from this file, or you compile this file and link it
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
29 // with other works to produce a work based on this file, this file does not
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
30 // by itself cause the resulting work to be covered by the GNU General Public
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
31 // License. However the source code for this file must still be made available
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
32 // in accordance with section (3) of the GNU General Public License.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
33 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
34 // This exception does not invalidate any other reasons why a work based on
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
35 // this file might be covered by the GNU General Public License.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
36 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
37 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
38 //####ECOSGPLCOPYRIGHTEND####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
39 //####BSDCOPYRIGHTBEGIN####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
40 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
41 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
42 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
43 // Portions of this software may have been derived from OpenBSD,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
44 // FreeBSD or other sources, and are covered by the appropriate
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
45 // copyright disclaimers included herein.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
46 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
47 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
48 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
49 //####BSDCOPYRIGHTEND####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
50 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
51 //#####DESCRIPTIONBEGIN####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
52 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
53 // Author(s): gthomas
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
54 // Contributors: gthomas
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
55 // Date: 2000-01-10
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
56 // Purpose:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
57 // Description:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
58 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
59 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
60 //####DESCRIPTIONEND####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
61 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
62 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
63
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
64 #ifndef _TESTS_NC_TEST_FRAMEWORK_H_
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
65 #define _TESTS_NC_TEST_FRAMEWORK_H_
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
66
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
67 #ifdef __ECOS
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
68 #include <network.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
69 #else
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
70 #undef _KERNEL
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
71 #include <sys/param.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
72 #include <sys/socket.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
73 #include <sys/ioctl.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
74 #include <sys/errno.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
75 #include <sys/time.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
76
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
77 #include <net/if.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
78 #include <netinet/in_systm.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
79 #include <netinet/in.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
80 #include <netinet/ip.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
81 #include <netinet/ip_icmp.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
82
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
83 #include <netdb.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
84 #ifndef EAI_NONE
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
85 #define EAI_NONE 0
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
86 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
87 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
88
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
89 #ifdef __ECOS
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
90 #define test_printf diag_printf
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
91 typedef cyg_addrword_t test_param_t;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
92 #else
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
93 #define test_printf printf
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
94 typedef void *test_param_t;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
95 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
96
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
97 #ifndef true
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
98 #define false 0
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
99 #define true 1
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
100 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
101
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
102 #define NC_SLAVE_PORT 7777
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
103 #define NC_MASTER_PORT 7776
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
104
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
105 #define NC_TESTING_SLAVE_PORT 8770
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
106 #define NC_TESTING_MASTER_PORT 8771
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
107
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
108 #define __string(s) #s
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
109 #define _string(s) __string(s)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
110
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
111 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
112 // The basic idea behind this test structure is that one end will run
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
113 // in "slave" mode and the other in "master" mode. Typically, the slave
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
114 // will run on a target platform with the master running on a host.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
115 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
116 // The slave starts up by listening for a connection on the "SLAVE_PORT".
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
117 // In order for the testing to require the minimum stack support, this
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
118 // connection (and the protocol) will use UDP.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
119 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
120 // The master will connect to the slave and send it a request over this
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
121 // connection. Once the slave accepts the request, then master and slave
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
122 // will execute the operation, typically a test. The control connection
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
123 // will remain active until the master sends a 'disconnect' request. The
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
124 // control connection will be broken after the reply to this request has
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
125 // been sent.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
126 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
127
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
128 #define MAX_ERRORS 5 // Give up after this many errors
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
129
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
130 #define NC_REPLY_TIMEOUT 10 // The slave may be slow
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
131 #define NC_TEST_TIMEOUT 3 // More generous for tests
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
132 #define NC_RESULTS_TIMEOUT (MAX_ERRORS+2)*NC_TEST_TIMEOUT
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
133
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
134 struct nc_request {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
135 int type; // Description of request
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
136 int seq; // Sequence number, used to build response
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
137 int nbufs; // Number of "buffers" to send
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
138 int buflen; // Length of each buffer
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
139 int slave_port; // Network ports to use
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
140 int master_port;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
141 int timeout; // Max time to wait for any packet
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
142 };
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
143
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
144 #define NC_REQUEST_DISCONNECT 0x0001
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
145 #define NC_REQUEST_UDP_SEND 0x0010 // Slave to send UDP data
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
146 #define NC_REQUEST_UDP_RECV 0x0011 // Slave to receive UDP data
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
147 #define NC_REQUEST_UDP_ECHO 0x0012 // Master->slave->master
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
148 #define NC_REQUEST_TCP_SEND 0x0020 // Slave to send TCP data
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
149 #define NC_REQUEST_TCP_RECV 0x0021 // Slave to receive TCP data
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
150 #define NC_REQUEST_TCP_ECHO 0x0022 // Master->slave->master
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
151 #define NC_REQUEST_START_IDLE 0x0100 // Start some idle processing
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
152 #define NC_REQUEST_STOP_IDLE 0x0101 // Stop idle processing
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
153 #define NC_REQUEST_SET_LOAD 0x0200 // Set the background load level
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
154
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
155 struct nc_reply {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
156 int response; // ACK or NAK
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
157 int seq; // Must match request
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
158 int reason; // If NAK, why request turned down
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
159 union { // Miscellaneous data, depending on request
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
160 struct {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
161 long elapsed_time; // In 10ms "ticks"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
162 long count[2]; // Result
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
163 } idle_results;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
164 } misc;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
165 };
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
166
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
167 #define NC_REPLY_ACK 0x0001 // Request accepted
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
168 #define NC_REPLY_NAK 0x0000 // Request denied
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
169
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
170 #define NC_REPLY_NAK_UNKNOWN_REQUEST 0x0001
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
171 #define NC_REPLY_NAK_BAD_REQUEST 0x0002 // Slave can't handle
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
172 #define NC_REPLY_NAK_NO_BACKGROUND 0x0003 // Slave can't do background/idle
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
173
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
174 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
175 // Test data 'packets' look like this
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
176
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
177 struct nc_test_data {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
178 long key1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
179 int seq;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
180 int len;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
181 long key2;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
182 char data[0]; // Actual data
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
183 };
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
184
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
185 #define NC_TEST_DATA_KEY1 0xC0DEADC0
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
186 #define NC_TEST_DATA_KEY2 0xC0DEADC1
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
187
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
188 struct nc_test_results {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
189 long key1; // Identify uniquely as a response record
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
190 int seq; // Matches request
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
191 int nsent;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
192 int nrecvd;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
193 long key2; // Additional verification
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
194 };
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
195
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
196 #define NC_TEST_RESULT_KEY1 0xDEADC0DE
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
197 #define NC_TEST_RESULT_KEY2 0xDEADC1DE
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
198
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
199 #endif // _TESTS_NC_TEST_FRAMEWORK_H_
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
200
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
201
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
202