Page MenuHomeFreeBSD
Authored By
dsl
Sun, Mar 29, 11:37 AM
Size
1 KB
Referenced Files
None
Subscribers
None

test01.c

/*
* test01.c
*
* TCP connection test which sends a pattern of 0xA...0xF numbers sequentially
* in 1024 byte blocks indefinitely. Server is supposed to verify received data
* read from the TCP connection and terminate it in case of missed bytes.
*
* This test helps to identify problems with the TX path of the DPAA2 driver in
* FreeBSD when generation of the checksums is offloaded to the DPAA2 hardware.
*
* See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292006#c31
*
* Based on G. Adam Stanislav work at
* https://docs.freebsd.org/en/books/developers-handbook/sockets/
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#define BLOCKSZ (128u)
int main() {
int s, bytes;
struct sockaddr_in sa;
uint8_t buffer[BLOCKSZ], sym;
if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket");
return 1;
}
memset(&sa, '\0', sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(5202);
sa.sin_addr.s_addr = htonl((((((10 << 8) | 100) << 8) | 0) << 8) | 2);
if (connect(s, (struct sockaddr *)&sa, sizeof sa) < 0) {
perror("connect");
close(s);
return 2;
}
sym = 0xAu;
memset(&buffer, sym, BLOCKSZ);
while (write(s, buffer, BLOCKSZ) == BLOCKSZ) {
sym++;
sym = (sym == 0x10u) ? 0xAu : sym;
memset(&buffer, sym, BLOCKSZ);
}
close(s);
return 0;
}

File Metadata

Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30585733
Default Alt Text
test01.c (1 KB)

Event Timeline