From 64cc135e716c2ef018227375fc4f15ff0670fdf7 Mon Sep 17 00:00:00 2001 From: "Eduardo Ramos Testillano (ert)" Date: Tue, 6 Jul 2021 09:49:38 +0200 Subject: [PATCH] Add more utilities for ADML-HTTP image jq and decode helper are added --- docker-images/anna-adml-http/Dockerfile | 1 + .../launcher/resources/scripts/decode.sh | 21 +++++++++++++++++++ tools/build-anna-adml-http | 1 + 3 files changed, 23 insertions(+) create mode 100755 example/diameter/launcher/resources/scripts/decode.sh diff --git a/docker-images/anna-adml-http/Dockerfile b/docker-images/anna-adml-http/Dockerfile index 9a3a7a7..c155c3e 100644 --- a/docker-images/anna-adml-http/Dockerfile +++ b/docker-images/anna-adml-http/Dockerfile @@ -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 index 0000000..c2ca72e --- /dev/null +++ b/example/diameter/launcher/resources/scripts/decode.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Diameter decoder for ADML-HTTP + +[ -z "$1" ] && echo "Usage: $0 " && 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 + diff --git a/tools/build-anna-adml-http b/tools/build-anna-adml-http index 7a42e1c..a7e7e4d 100755 --- a/tools/build-anna-adml-http +++ b/tools/build-anna-adml-http @@ -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 ..." -- 2.20.1