2019-10-30 21:44:29 +05:30
|
|
|
#!/bin/sh
|
2021-11-24 13:31:16 +05:30
|
|
|
# Verify that the sending to a remote IP:PORT works, note not receiving,
|
|
|
|
# there's a test fwd.sh that verifies that.
|
2022-03-06 05:36:38 +05:30
|
|
|
# shellcheck disable=SC1090
|
2021-11-22 19:46:05 +05:30
|
|
|
set -x
|
|
|
|
|
2021-11-22 15:52:04 +05:30
|
|
|
if [ x"${srcdir}" = x ]; then
|
|
|
|
srcdir=.
|
|
|
|
fi
|
2021-11-22 19:46:05 +05:30
|
|
|
. ${srcdir}/lib.sh
|
|
|
|
setup
|
2019-10-30 21:44:29 +05:30
|
|
|
|
2021-11-24 13:31:16 +05:30
|
|
|
export MSG="kilroy"
|
|
|
|
|
|
|
|
# Only needed for verifying correct RFC3164 parsing
|
2022-03-06 05:36:38 +05:30
|
|
|
cat <<-EOF >"${CONFD2}/50-default.conf"
|
2021-11-24 13:31:16 +05:30
|
|
|
*.* ${LOG2}
|
|
|
|
EOF
|
2022-03-06 05:26:03 +05:30
|
|
|
|
|
|
|
setup2 -m0 -a 127.0.0.2:* -b ":${PORT2}"
|
2019-10-30 21:44:29 +05:30
|
|
|
|
2022-03-06 05:32:03 +05:30
|
|
|
print "TEST: Starting"
|
|
|
|
|
2019-10-31 16:37:52 +05:30
|
|
|
# Start collector in background, note: might need sudo!
|
2019-11-12 17:57:07 +05:30
|
|
|
#tshark -Qni lo -w ${CAP} port ${PORT} &
|
2022-03-06 05:36:38 +05:30
|
|
|
tshark -Qni lo -w "${CAP}" port 514 2>/dev/null &
|
2021-07-01 02:30:09 +05:30
|
|
|
TPID="$!"
|
2021-11-22 19:46:05 +05:30
|
|
|
echo "$TPID" >> "$DIR/PIDs"
|
2019-10-31 16:37:52 +05:30
|
|
|
|
|
|
|
# Wait for tshark to start up properly
|
2019-11-14 06:10:33 +05:30
|
|
|
sleep 3
|
2019-10-30 21:44:29 +05:30
|
|
|
|
2022-05-21 19:13:12 +05:30
|
|
|
logger ${MSG}
|
2019-10-30 21:44:29 +05:30
|
|
|
|
2019-10-31 16:37:52 +05:30
|
|
|
# Wait for any OS delays, in particular on Travis
|
2019-11-14 06:10:33 +05:30
|
|
|
sleep 1
|
2019-10-31 16:37:52 +05:30
|
|
|
|
|
|
|
# Stop tshark collector
|
2021-07-01 02:30:09 +05:30
|
|
|
kill -TERM ${TPID}
|
|
|
|
wait ${TPID}
|
2019-10-30 21:44:29 +05:30
|
|
|
|
2019-10-31 16:37:52 +05:30
|
|
|
# Analyze content, should have $MSG now ...
|
2019-11-12 17:57:07 +05:30
|
|
|
#tshark -d udp.port==${PORT},syslog -r ${CAP} | grep ${MSG}
|
2022-05-21 19:13:12 +05:30
|
|
|
tshark -r "${CAP}" 2>/dev/null | grep "${MSG}" || FAIL "Cannot find: ${MSG}"
|
2022-03-06 05:32:03 +05:30
|
|
|
|
|
|
|
OK
|