mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 15:32:35 +00:00
Filan: Fixed TCP/UDP displaying; fixed a few syntax error messages
This commit is contained in:
parent
486bb2c65c
commit
75922a9189
4 changed files with 105 additions and 8 deletions
9
CHANGES
9
CHANGES
|
@ -16,6 +16,15 @@ Corrections:
|
|||
The retry option with some address types (TCP) did not close() the
|
||||
sockets after failed attempts, resulting in an FD leak.
|
||||
|
||||
Filan: Corrected some syntax error messages
|
||||
|
||||
Filan: Fixed a bug introduces in 1.7.4.4 that broke displaying
|
||||
TCP/UDP on options -s, -S
|
||||
Test: FILAN_SHORT_TCP
|
||||
|
||||
Filan: If IP protocol type cannot be retrieved, display at least the
|
||||
socket type
|
||||
|
||||
Coding:
|
||||
New Environment variable SOCAT_TRANSFER_WAIT that Socat sleep before
|
||||
starting the data transfer loop. Useful, e.g., to accumulate multiple
|
||||
|
|
27
fdname.c
27
fdname.c
|
@ -232,7 +232,7 @@ int sockname(int fd, FILE *outfile, char style) {
|
|||
#define PROTONAMEMAX 1024
|
||||
char protoname[PROTONAMEMAX] = "";
|
||||
#if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
|
||||
int proto;
|
||||
int proto = 0;
|
||||
#endif
|
||||
int opttype;
|
||||
#ifdef SO_ACCEPTCONN
|
||||
|
@ -268,7 +268,6 @@ int sockname(int fd, FILE *outfile, char style) {
|
|||
#endif
|
||||
", &%p, {"F_socklen"}): errno=%d (%s)", fd, &proto, optlen, errno, strerror(errno));
|
||||
}
|
||||
proto = 0;
|
||||
#endif /* defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) */
|
||||
optlen = sizeof(opttype);
|
||||
Getsockopt(fd, SOL_SOCKET, SO_TYPE, &opttype, &optlen);
|
||||
|
@ -313,9 +312,29 @@ int sockname(int fd, FILE *outfile, char style) {
|
|||
#endif
|
||||
#else
|
||||
if (opttype == SOCK_STREAM) {
|
||||
strcpy(protoname, "tcp");
|
||||
strcpy(protoname, "(stream)");
|
||||
} else if (opttype == SOCK_DGRAM) {
|
||||
strcpy(protoname, "udp");
|
||||
strcpy(protoname, "(dgram)");
|
||||
#ifdef SOCK_RAW
|
||||
} else if (opttype == SOCK_RAW) {
|
||||
strcpy(protoname, "(raw)");
|
||||
#endif
|
||||
#ifdef SOCK_RDM
|
||||
} else if (opttype == SOCK_RDM) {
|
||||
strcpy(protoname, "(rdm)");
|
||||
#endif
|
||||
#ifdef SOCK_SEQPACKET
|
||||
} else if (opttype == SOCK_SEQPACKET) {
|
||||
strcpy(protoname, "(seqpacket)");
|
||||
#endif
|
||||
#ifdef SOCK_DCCP
|
||||
} else if (opttype == SOCK_DCCP) {
|
||||
strcpy(protoname, "(dccp)");
|
||||
#endif
|
||||
#ifdef SOCK_PACKET
|
||||
} else if (opttype == SOCK_PACKET) {
|
||||
strcpy(protoname, "(packet)");
|
||||
#endif
|
||||
} else {
|
||||
strcpy(protoname, "socket");
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ int main(int argc, const char *argv[]) {
|
|||
}
|
||||
m = strtoul(a, (char **)&a, 0);
|
||||
if (a == a0) {
|
||||
Error1("not a numerical arg in \"-b %s\"", a0);
|
||||
Error1("not a numerical arg in \"-i %s\"", a0);
|
||||
}
|
||||
if (*a != '\0') {
|
||||
Error1("trailing garbage in \"-b %s\"", a0);
|
||||
Error1("trailing garbage in \"-i %s\"", a0);
|
||||
}
|
||||
n = m;
|
||||
break;
|
||||
|
@ -79,10 +79,10 @@ int main(int argc, const char *argv[]) {
|
|||
}
|
||||
n = strtoul(a, (char **)&a, 0);
|
||||
if (a == a0) {
|
||||
Error1("not a numerical arg in \"-b %s\"", a0);
|
||||
Error1("not a numerical arg in \"-n %s\"", a0);
|
||||
}
|
||||
if (*a != '\0') {
|
||||
Error1("trailing garbage in \"-b %s\"", a0);
|
||||
Error1("trailing garbage in \"-n %s\"", a0);
|
||||
}
|
||||
break;
|
||||
case 'f': if (arg1[0][2]) {
|
||||
|
|
69
test.sh
69
test.sh
|
@ -15770,6 +15770,75 @@ fi # NUMCOND
|
|||
esac
|
||||
N=$((N+1))
|
||||
|
||||
|
||||
# Test if filan -s correctly displays TCP on appropriate FDs
|
||||
# This feature was broken in version 1.7.4.4
|
||||
NAME=FILAN_SHORT_TCP
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%filan%*|*%$NAME%*)
|
||||
TEST="$NAME: filan -s displays TCP etc"
|
||||
# Establish a TCP connection using Socat server and client; on the server
|
||||
# exec() filan -s using nofork option, so its output appears on the client.
|
||||
# When the second word in the first line is "tcp" the test succeeded.
|
||||
if ! eval $NUMCOND; then :
|
||||
elif ! a=$(testfeats STDIO IP4 TCP LISTEN EXEC); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $a not available in $SOCAT${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
elif ! a=$(testaddrs STDIO TCP4 TCP4-LISTEN EXEC); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Address $a not available in $SOCAT${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
elif ! o=$(testoptions so-reuseaddr nofork ) >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Option $o not available in $SOCAT${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
elif ! runsip4 >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}IPv4 not available${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
tdiff="$td/test$N.diff"
|
||||
da="test$N $(date) $RANDOM"
|
||||
CMD0="$TRACE $SOCAT $opts TCP4-LISTEN:$PORT,reuseaddr EXEC:'$FILAN -s',nofork"
|
||||
CMD1="$TRACE $SOCAT $opts - TCP4:localhost:$PORT"
|
||||
printf "test $F_n $TEST... " $N
|
||||
eval "$CMD0" >/dev/null 2>"${te}0" &
|
||||
pid0=$!
|
||||
waittcp4port $PORT 1
|
||||
$CMD1 >"${tf}1" 2>"${te}1" </dev/null
|
||||
rc1=$?
|
||||
kill $pid0 2>/dev/null; wait
|
||||
result="$(head -n 1 ${tf}1 |awk '{print($2);}')"
|
||||
if [ $rc1 -eq 0 -a "$result" = tcp ]; then
|
||||
$PRINTF "$OK\n"
|
||||
if [ "$VERBOSE" ]; then echo "$CMD0 &"; fi
|
||||
if [ "$DEBUG" ]; then cat "${te}0" >&2; fi
|
||||
if [ "$VERBOSE" ]; then echo "$CMD1"; fi
|
||||
if [ "$DEBUG" ]; then cat "${te}1" >&2; fi
|
||||
numOK=$((numOK+1))
|
||||
else
|
||||
$PRINTF "$FAILED\n"
|
||||
if [ $rc1 -ne 0 ]; then
|
||||
echo "rc=$rc1" >&2
|
||||
else
|
||||
echo "result is \"$result\" instead of \"tcp\"" >&2
|
||||
fi
|
||||
echo "$CMD0 &"
|
||||
cat "${te}0" >&2
|
||||
echo "$CMD1"
|
||||
cat "${te}1" >&2
|
||||
numFAIL=$((numFAIL+1))
|
||||
listFAIL="$listFAIL $N"
|
||||
fi
|
||||
fi # NUMCOND
|
||||
;;
|
||||
esac
|
||||
PORT=$((PORT+1))
|
||||
N=$((N+1))
|
||||
|
||||
# end of common tests
|
||||
|
||||
##################################################################################
|
||||
|
|
Loading…
Reference in a new issue