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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [tests/] [nc_test_framework.h] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      tests/nc_test_framework.h
4
//
5
//      Network characterization tests framework
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
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.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
#ifndef _TESTS_NC_TEST_FRAMEWORK_H_
33
#define _TESTS_NC_TEST_FRAMEWORK_H_
34
 
35
#ifdef __ECOS
36
#include <network.h>
37
#else
38
#undef _KERNEL
39
#include <sys/param.h>
40
#include <sys/socket.h>
41
#include <sys/ioctl.h>
42
#include <sys/errno.h>
43
#include <sys/time.h>
44
 
45
#include <net/if.h>
46
#include <netinet/in_systm.h>
47
#include <netinet/in.h>
48
#include <netinet/ip.h>
49
#include <netinet/ip_icmp.h>
50
#include <net/route.h>
51
 
52
#include <netdb.h>
53
#ifndef EAI_NONE
54
#define EAI_NONE 0
55
#endif
56
#endif
57
 
58
#ifdef __ECOS
59
#define test_printf diag_printf
60
typedef cyg_addrword_t test_param_t;
61
#else
62
#define test_printf printf
63
typedef void *test_param_t;
64
#endif
65
 
66
#ifndef true
67
#define false 0
68
#define true  1
69
#endif
70
 
71
#define NC_SLAVE_PORT  7777
72
#define NC_MASTER_PORT 7776
73
 
74
#define NC_TESTING_SLAVE_PORT  8770
75
#define NC_TESTING_MASTER_PORT 8771
76
 
77
#define __string(s) #s
78
#define _string(s) __string(s)
79
 
80
//
81
// The basic idea behind this test structure is that one end will run
82
// in "slave" mode and the other in "master" mode.  Typically, the slave
83
// will run on a target platform with the master running on a host.
84
//
85
// The slave starts up by listening for a connection on the "SLAVE_PORT".
86
// In order for the testing to require the minimum stack support, this
87
// connection (and the protocol) will use UDP.
88
//
89
// The master will connect to the slave and send it a request over this
90
// connection.  Once the slave accepts the request, then master and slave
91
// will execute the operation, typically a test.  The control connection
92
// will remain active until the master sends a 'disconnect' request.  The
93
// control connection will be broken after the reply to this request has
94
// been sent.
95
//
96
 
97
#define MAX_ERRORS          5   // Give up after this many errors
98
 
99
#define NC_REPLY_TIMEOUT    10  // The slave may be slow
100
#define NC_TEST_TIMEOUT     3   // More generous for tests
101
#define NC_RESULTS_TIMEOUT  (MAX_ERRORS+2)*NC_TEST_TIMEOUT
102
 
103
struct nc_request {
104
    int type;          // Description of request
105
    int seq;           // Sequence number, used to build response
106
    int nbufs;         // Number of "buffers" to send
107
    int buflen;        // Length of each buffer
108
    int slave_port;    // Network ports to use
109
    int master_port;
110
    int timeout;       // Max time to wait for any packet
111
};
112
 
113
#define NC_REQUEST_DISCONNECT 0x0001
114
#define NC_REQUEST_UDP_SEND   0x0010  // Slave to send UDP data
115
#define NC_REQUEST_UDP_RECV   0x0011  // Slave to receive UDP data
116
#define NC_REQUEST_UDP_ECHO   0x0012  // Master->slave->master
117
#define NC_REQUEST_TCP_SEND   0x0020  // Slave to send TCP data
118
#define NC_REQUEST_TCP_RECV   0x0021  // Slave to receive TCP data
119
#define NC_REQUEST_TCP_ECHO   0x0022  // Master->slave->master
120
#define NC_REQUEST_START_IDLE 0x0100  // Start some idle processing
121
#define NC_REQUEST_STOP_IDLE  0x0101  // Stop idle processing
122
#define NC_REQUEST_SET_LOAD   0x0200  // Set the background load level
123
 
124
struct nc_reply {
125
    int  response; // ACK or NAK
126
    int  seq;      // Must match request
127
    int  reason;   // If NAK, why request turned down
128
    union {        // Miscellaneous data, depending on request
129
        struct {
130
            long      elapsed_time;  // In 10ms "ticks"
131
            long      count[2];      // Result 
132
        } idle_results;
133
    } misc;
134
};
135
 
136
#define NC_REPLY_ACK  0x0001    // Request accepted
137
#define NC_REPLY_NAK  0x0000    // Request denied
138
 
139
#define NC_REPLY_NAK_UNKNOWN_REQUEST 0x0001
140
#define NC_REPLY_NAK_BAD_REQUEST     0x0002  // Slave can't handle
141
#define NC_REPLY_NAK_NO_BACKGROUND   0x0003  // Slave can't do background/idle
142
 
143
//
144
// Test data 'packets' look like this
145
 
146
struct nc_test_data {
147
    long  key1;
148
    int   seq;
149
    int   len;
150
    long  key2;
151
    char  data[0];  // Actual data
152
};
153
 
154
#define NC_TEST_DATA_KEY1 0xC0DEADC0
155
#define NC_TEST_DATA_KEY2 0xC0DEADC1
156
 
157
struct nc_test_results {
158
    long key1;         // Identify uniquely as a response record
159
    int  seq;          // Matches request
160
    int  nsent;
161
    int  nrecvd;
162
    long key2;         // Additional verification
163
};
164
 
165
#define NC_TEST_RESULT_KEY1 0xDEADC0DE
166
#define NC_TEST_RESULT_KEY2 0xDEADC1DE
167
 
168
#endif // _TESTS_NC_TEST_FRAMEWORK_H_
169
 
170
 
171
 

powered by: WebSVN 2.1.0

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