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__ ) static void tcpip_random_okx(struct tcpip_random_test *test, const char *file, unsigned int line)
Report TCP/IP pseudorandom-data test result.
static void tcpip_okx(struct tcpip_test *test, const char *file, unsigned int line)
Report TCP/IP fixed-data test result.
unsigned long profile_mean(struct profiler *profiler)
Get mean sample value.
uint16_t generic_tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define TCPIP_EMPTY_CSUM
Empty checksum value.
A TCP/IP pseudorandom-data test.
static uint16_t rfc_tcpip_chksum(const void *data, size_t len)
Calculate TCP/IP checksum.
Self-test infrastructure.
const char * name
Test set name.
A data structure for storing profiling information.
static void profile_stop(struct profiler *profiler)
Stop profiling.
unsigned long profile_stddev(struct profiler *profiler)
Get sample standard deviation.
size_t offset
Alignment offset.
size_t len
Length of data.
void srandom(unsigned int seed)
Seed the pseudo-random number generator.
#define okx(success, file, line)
Report test result.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Transport-network layer interface.
static void profile_start(struct profiler *profiler)
Start profiling.
A TCP/IP fixed-data test.
#define tcpip_random_ok(test)
static uint8_t tcpip_data[4096+7]
Buffer for pseudorandom-data tests.
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
#define TCPIP_TEST(name, DATA)
Define a TCP/IP fixed-data test.
size_t len
Length of data.
static void tcpip_test_exec(void)
Perform TCP/IP self-tests.
#define TCPIP_RANDOM_TEST(name, SEED, LEN, OFFSET)
Define a TCP/IP pseudorandom-data test.
uint8_t data[48]
Additional event data.
#define DATA(...)
Define inline data.
#define DBG(...)
Print a debugging message.
#define PROFILE_COUNT
Number of sample iterations for profiling.
uint16_t tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.
struct self_test tcpip_test __self_test
TCP/IP self-test.
void * memset(void *dest, int character, size_t len) __nonnull