Add more utilities for ADML-HTTP image
[anna.git] / example / diameter / launcher / resources / scripts / decode.sh
1 #!/bin/bash
2 # Diameter decoder for ADML-HTTP
3
4 [ -z "$1" ] && echo "Usage: $0 <pcap file>" && exit 1
5 PCAP=$(readlink -f $1 2>/dev/null)
6 [ ! -f "${PCAP}" ] && echo "Invalid or missing file '$1'" && exit 1
7 PCAP_BN=$(basename ${PCAP} .pcap)
8 PCAP_DN=$(dirname ${PCAP})
9
10 cd $(dirname $0)
11
12 ./tsharkDecoder.sh ${PCAP}
13
14 # Decode hex data:
15 trap "rm -f .body.json" EXIT
16 for hex in $(ls ${PCAP_DN}/*.hex 2>/dev/null)
17 do
18   echo "{\"diameterHex\":\"$(cat ${hex})\"}" > .body.json
19   curl -s -XPOST --http2-prior-knowledge -d@./.body.json http://localhost:8074/decode | jq -r '.response' | base64 -d > ${hex}.xml
20 done
21