44#define PROFILE_COUNT 16
65#define DATA(...) { __VA_ARGS__ }
68#define TCPIP_TEST( name, DATA ) \
69 static const uint8_t __attribute__ (( aligned ( 16 ) )) \
70 name ## _data[] = DATA; \
71 static struct tcpip_test name = { \
72 .data = name ## _data, \
73 .len = sizeof ( name ## _data ), \
77#define TCPIP_RANDOM_TEST( name, SEED, LEN, OFFSET ) \
78 static struct tcpip_random_test name = { \
105 DATA ( 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ) );
109 DATA ( 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 ) );
145 unsigned long sum = 0xffff;
157 sum = ( ( sum & 0xffff ) + ( sum >> 16 ) );
171 unsigned int line ) {
180 okx ( generic_sum == expected, file, line );
184 okx ( sum == expected, file, line );
186#define tcpip_ok( test ) tcpip_okx ( test, __FILE__, __LINE__ )
196 const char *file,
unsigned int line ) {
209 for ( i = 0 ; i <
test->len ; i++ )
216 okx ( generic_sum == expected, file, line );
220 okx ( sum == expected, file, line );
230 DBG (
"TCPIP checksummed %zd bytes (+%zd) in %ld +/- %ld ticks\n",
234#define tcpip_random_ok( test ) tcpip_random_okx ( test, __FILE__, __LINE__ )
#define DATA(...)
Define inline data.
#define assert(condition)
Assert a condition at run-time.
#define PROFILE_COUNT
Number of sample iterations for profiling.
uint8_t data[48]
Additional event data.
#define DBG(...)
Print a debugging message.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
static void profile_stop(struct profiler *profiler)
Stop profiling.
static void profile_start(struct profiler *profiler)
Start profiling.
Transport-network layer interface.
#define TCPIP_EMPTY_CSUM
Empty checksum value.
void * memset(void *dest, int character, size_t len) __nonnull
unsigned long profile_mean(struct profiler *profiler)
Get mean sample value.
unsigned long profile_stddev(struct profiler *profiler)
Get sample standard deviation.
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
void srandom(unsigned int seed)
Seed the pseudo-random number generator.
A data structure for storing profiling information.
A TCP/IP pseudorandom-data test.
size_t len
Length of data.
size_t offset
Alignment offset.
A TCP/IP fixed-data test.
size_t len
Length of data.
uint16_t generic_tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.
#define TCPIP_TEST(name, DATA)
Define a TCP/IP fixed-data test.
static void tcpip_test_exec(void)
Perform TCP/IP self-tests.
static uint16_t rfc_tcpip_chksum(const void *data, size_t len)
Calculate TCP/IP checksum.
static void tcpip_okx(struct tcpip_test *test, const char *file, unsigned int line)
Report TCP/IP fixed-data test result.
static uint8_t tcpip_data[4096+7]
Buffer for pseudorandom-data tests.
#define tcpip_random_ok(test)
static void tcpip_random_okx(struct tcpip_random_test *test, const char *file, unsigned int line)
Report TCP/IP pseudorandom-data test result.
#define TCPIP_RANDOM_TEST(name, SEED, LEN, OFFSET)
Define a TCP/IP pseudorandom-data test.
Self-test infrastructure.
#define okx(success, file, line)
Report test result.
#define __self_test
Declare a self-test.
uint16_t tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.