Add more utilities for ADML-HTTP image
authorEduardo Ramos Testillano (ert) <eduardo.ramos.testillano@gmail.com>
Tue, 6 Jul 2021 07:49:38 +0000 (09:49 +0200)
committerEduardo Ramos Testillano (ert) <eduardo.ramos.testillano@gmail.com>
Tue, 6 Jul 2021 07:49:38 +0000 (09:49 +0200)
jq and decode helper are added

docker-images/anna-adml-http/Dockerfile
example/diameter/launcher/resources/scripts/decode.sh [new file with mode: 0755]
tools/build-anna-adml-http

index 9a3a7a7..c155c3e 100644 (file)
@@ -7,6 +7,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y tshark
 RUN apt-get update && apt-get install -y \
    net-tools \
    procps \
+   jq \
    python3 \
    python3-pip
 
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
+
index 7a42e1c..a7e7e4d 100755 (executable)
@@ -33,6 +33,7 @@ echo ${AD} | ${REPO_DIR}/example/diameter/launcher/deploy-adml-http.sh ${VARIANT
 # Add interesting stuff:
 cp -r ${REPO_DIR}/example/diameter/launcher/resources/rest_api/helpers/diameterJsonHelper ${AD}
 cp ${REPO_DIR}/example/diameter/pcapDecoder/tsharkDecoder.sh ${AD}
+cp ${REPO_DIR}/example/diameter/launcher/resources/scripts/decode.sh ${AD}
 
 echo
 echo "Generate docker image ..."