Add more utilities for ADML-HTTP image
[anna.git] / example / diameter / launcher / resources / scripts / decode.sh
diff --git a/example/diameter/launcher/resources/scripts/decode.sh b/example/diameter/launcher/resources/scripts/decode.sh
new file mode 100755 (executable)
index 0000000..c2ca72e
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Diameter decoder for ADML-HTTP
+
+[ -z "$1" ] && echo "Usage: $0 <pcap file>" && exit 1
+PCAP=$(readlink -f $1 2>/dev/null)
+[ ! -f "${PCAP}" ] && echo "Invalid or missing file '$1'" && exit 1
+PCAP_BN=$(basename ${PCAP} .pcap)
+PCAP_DN=$(dirname ${PCAP})
+
+cd $(dirname $0)
+
+./tsharkDecoder.sh ${PCAP}
+
+# Decode hex data:
+trap "rm -f .body.json" EXIT
+for hex in $(ls ${PCAP_DN}/*.hex 2>/dev/null)
+do
+  echo "{\"diameterHex\":\"$(cat ${hex})\"}" > .body.json
+  curl -s -XPOST --http2-prior-knowledge -d@./.body.json http://localhost:8074/decode | jq -r '.response' | base64 -d > ${hex}.xml
+done
+