Debian Codegraph @

tests/ts/lsfd/mkfds-tcp6

raw
1 #!/bin/bash
2 #
3 # Copyright (C) 2023 Masatake YAMATO <[email protected]>
4 #
5 # This file is part of util-linux.
6 #
7 # This file is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This file is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 TS_TOPDIR="${0%/*}/../.."
18 TS_DESC="TCP6 sockets"
19
20 . "$TS_TOPDIR"/functions.sh
21 ts_init "$*"
22
23 ts_check_test_command "$TS_CMD_LSFD"
24 ts_check_test_command "$TS_HELPER_MKFDS"
25 ts_check_native_byteorder
26 ts_check_ipv6
27 ts_skip_docker
28
29 ts_cd "$TS_OUTDIR"
30
31 PID=
32 FDS=3
33 FDC=4
34 FDA=5
35 EXPR='(TYPE == "TCPv6") and (FD >= 3) and (FD <= 5)'
36
37 {
38 coproc MKFDS { "$TS_HELPER_MKFDS" tcp6 $FDS $FDC $FDA \
39 server-port=56789 \
40 client-port=45678 ; }
41 if read -r -u "${MKFDS[0]}" PID; then
42 ${TS_CMD_LSFD} -n \
43 -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \
44 -p "${PID}" -Q "${EXPR}"
45 echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $?
46
47 echo DONE >&"${MKFDS[1]}"
48 fi
49 wait "${MKFDS_PID}"
50 } > "$TS_OUTPUT" 2>&1
51
52 ts_finalize