1
0

dtlscid.test 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. # dtlscid.test
  3. # Copyright wolfSSL 2022-2024
  4. # if we can, isolate the network namespace to eliminate port collisions.
  5. if [[ -n "$NETWORK_UNSHARE_HELPER" ]]; then
  6. if [[ -z "$NETWORK_UNSHARE_HELPER_CALLED" ]]; then
  7. export NETWORK_UNSHARE_HELPER_CALLED=yes
  8. exec "$NETWORK_UNSHARE_HELPER" "$0" "$@" || exit $?
  9. fi
  10. elif [ "${AM_BWRAPPED-}" != "yes" ]; then
  11. bwrap_path="$(command -v bwrap)"
  12. if [ -n "$bwrap_path" ]; then
  13. export AM_BWRAPPED=yes
  14. exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@"
  15. fi
  16. unset AM_BWRAPPED
  17. fi
  18. cleanup () {
  19. echo "Cleaning up..."
  20. if [ ! -z "$SERVER_PID" ];then
  21. echo "Killing server $SERVER_PID"
  22. kill $SERVER_PID
  23. fi
  24. }
  25. trap cleanup err exit
  26. CCID="AA"
  27. SCID="BB"
  28. HEXCID=$(printf $CCID | od -An -tx1 | tr -d ' \n')
  29. HEXSCID=$(printf $SCID | od -An -tx1 | tr -d ' \n')
  30. WOLFSSL_ROOT=$(pwd)
  31. test_cid () {
  32. echo "Running test_cid"
  33. SERVER_FILE=$(mktemp)
  34. CLIENT_FILE=$(mktemp)
  35. $WOLFSSL_ROOT/examples/server/server -v4 -u --cid $SCID 1> $SERVER_FILE &
  36. SERVER_PID=$!
  37. sleep 0.2
  38. $WOLFSSL_ROOT/examples/client/client -v4 -u --cid $CCID 1> $CLIENT_FILE
  39. wait $SERVER_PID
  40. SERVER_PID=
  41. grep "Sending CID is ${HEXSCID}" $CLIENT_FILE > /dev/null
  42. grep "Sending CID is ${HEXCID}" $SERVER_FILE > /dev/null
  43. echo "test_cid has passed"
  44. }
  45. test_cid