Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150111545
test01d.c
dsl (Dmitry Salychev)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
dsl
Sun, Mar 29, 11:36 AM
2026-03-29 11:36:53 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
test01d.c
View Options
/*
* test01d.c
*
* TCP connection test server which accepts a pattern of 0xA...0xF numbers
* sequentially in 1024 byte blocks. Server is supposed to verify received data
* read from the TCP connection and terminate it when the pattern is violated
* (e.g. missed bytes, incorrect block sizes, etc.)
*
* 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
<time.h>
#include
<unistd.h>
#include
<sys/types.h>
#include
<sys/socket.h>
#include
<netinet/in.h>
#define BACKLOG 4
#define BLOCKSZ (128u)
int
main
()
{
int
s
,
c
,
bytes
,
i
;
socklen_t
b
;
struct
sockaddr_in
sa
;
time_t
t
;
struct
tm
*
tm
;
uint8_t
buffer
,
sym
;
uint32_t
block
;
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
);
if
(
INADDR_ANY
)
sa
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
if
(
bind
(
s
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
sa
)
<
0
)
{
perror
(
"bind"
);
return
2
;
}
switch
(
fork
())
{
case
-1
:
perror
(
"fork"
);
return
3
;
default
:
close
(
s
);
return
0
;
case
0
:
break
;
}
listen
(
s
,
BACKLOG
);
b
=
sizeof
sa
;
if
((
c
=
accept
(
s
,
(
struct
sockaddr
*
)
&
sa
,
&
b
))
<
0
)
{
perror
(
"test01d accept"
);
return
4
;
}
sym
=
0xAu
;
i
=
0
;
bytes
=
0
;
block
=
0
;
memset
(
&
buffer
,
'\0'
,
sizeof
(
buffer
));
while
((
bytes
=
read
(
c
,
&
buffer
,
sizeof
(
buffer
)))
>
0
)
{
if
(
bytes
!=
sizeof
(
buffer
))
{
fprintf
(
stdout
,
"read bytes: %d != %lu
\n
"
,
bytes
,
sizeof
(
buffer
));
return
6
;
}
if
(
buffer
!=
sym
)
{
fprintf
(
stdout
,
"wrong symbol: '0x%X' (expected '0x%X') "
"at %d block %d
\n
"
,
buffer
,
sym
,
i
,
block
);
return
7
;
}
i
++
;
if
(
i
>
(
BLOCKSZ
-
1
))
{
i
=
0
;
sym
++
;
sym
=
(
sym
==
0x10u
)
?
0xAu
:
sym
;
block
++
;
}
}
close
(
c
);
return
0
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30585729
Default Alt Text
test01d.c (2 KB)
Attached To
Mode
D56144: dpaa2: Perform bus_dma pre-write sync before enqueue operation
Attached
Detach File
Event Timeline
Log In to Comment