1 //==========================================================================
3 // tests/nc_test_framework.h
5 // Network characterization tests framework
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas
28 //####DESCRIPTIONEND####
30 //==========================================================================
32 #ifndef _TESTS_NC_TEST_FRAMEWORK_H_
33 #define _TESTS_NC_TEST_FRAMEWORK_H_
39 #include <sys/param.h>
40 #include <sys/socket.h>
41 #include <sys/ioctl.h>
42 #include <sys/errno.h>
46 #include <netinet/in_systm.h>
47 #include <netinet/in.h>
48 #include <netinet/ip.h>
49 #include <netinet/ip_icmp.h>
58 #define test_printf diag_printf
59 typedef cyg_addrword_t test_param_t;
61 #define test_printf printf
62 typedef void *test_param_t;
70 #define NC_SLAVE_PORT 7777
71 #define NC_MASTER_PORT 7776
73 #define NC_TESTING_SLAVE_PORT 8770
74 #define NC_TESTING_MASTER_PORT 8771
76 #define __string(s) #s
77 #define _string(s) __string(s)
80 // The basic idea behind this test structure is that one end will run
81 // in "slave" mode and the other in "master" mode. Typically, the slave
82 // will run on a target platform with the master running on a host.
84 // The slave starts up by listening for a connection on the "SLAVE_PORT".
85 // In order for the testing to require the minimum stack support, this
86 // connection (and the protocol) will use UDP.
88 // The master will connect to the slave and send it a request over this
89 // connection. Once the slave accepts the request, then master and slave
90 // will execute the operation, typically a test. The control connection
91 // will remain active until the master sends a 'disconnect' request. The
92 // control connection will be broken after the reply to this request has
96 #define MAX_ERRORS 5 // Give up after this many errors
98 #define NC_REPLY_TIMEOUT 10 // The slave may be slow
99 #define NC_TEST_TIMEOUT 3 // More generous for tests
100 #define NC_RESULTS_TIMEOUT (MAX_ERRORS+2)*NC_TEST_TIMEOUT
103 int type; // Description of request
104 int seq; // Sequence number, used to build response
105 int nbufs; // Number of "buffers" to send
106 int buflen; // Length of each buffer
107 int slave_port; // Network ports to use
109 int timeout; // Max time to wait for any packet
112 #define NC_REQUEST_DISCONNECT 0x0001
113 #define NC_REQUEST_UDP_SEND 0x0010 // Slave to send UDP data
114 #define NC_REQUEST_UDP_RECV 0x0011 // Slave to receive UDP data
115 #define NC_REQUEST_UDP_ECHO 0x0012 // Master->slave->master
116 #define NC_REQUEST_TCP_SEND 0x0020 // Slave to send TCP data
117 #define NC_REQUEST_TCP_RECV 0x0021 // Slave to receive TCP data
118 #define NC_REQUEST_TCP_ECHO 0x0022 // Master->slave->master
119 #define NC_REQUEST_START_IDLE 0x0100 // Start some idle processing
120 #define NC_REQUEST_STOP_IDLE 0x0101 // Stop idle processing
121 #define NC_REQUEST_SET_LOAD 0x0200 // Set the background load level
124 int response; // ACK or NAK
125 int seq; // Must match request
126 int reason; // If NAK, why request turned down
127 union { // Miscellaneous data, depending on request
129 long elapsed_time; // In 10ms "ticks"
130 long count[2]; // Result
135 #define NC_REPLY_ACK 0x0001 // Request accepted
136 #define NC_REPLY_NAK 0x0000 // Request denied
138 #define NC_REPLY_NAK_UNKNOWN_REQUEST 0x0001
139 #define NC_REPLY_NAK_BAD_REQUEST 0x0002 // Slave can't handle
140 #define NC_REPLY_NAK_NO_BACKGROUND 0x0003 // Slave can't do background/idle
143 // Test data 'packets' look like this
145 struct nc_test_data {
150 char data[0]; // Actual data
153 #define NC_TEST_DATA_KEY1 0xC0DEADC0
154 #define NC_TEST_DATA_KEY2 0xC0DEADC1
156 struct nc_test_results {
157 long key1; // Identify uniquely as a response record
158 int seq; // Matches request
161 long key2; // Additional verification
164 #define NC_TEST_RESULT_KEY1 0xDEADC0DE
165 #define NC_TEST_RESULT_KEY2 0xDEADC1DE
167 #endif // _TESTS_NC_TEST_FRAMEWORK_H_