From e6d71622143ff9b2421a1abbe8434b954b5b1099 Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Tue, 22 Sep 2015 12:53:15 -0700 Subject: bringing suricata to commit 4a738023d5ac945f0109ceb13fcc43e3f3095453 Change-Id: I7bbd8767089a43573cb38d23fe7bf1b656b29893 --- framework/src/suricata/scripts/setup-app-layer.sh | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100755 framework/src/suricata/scripts/setup-app-layer.sh (limited to 'framework/src/suricata/scripts/setup-app-layer.sh') diff --git a/framework/src/suricata/scripts/setup-app-layer.sh b/framework/src/suricata/scripts/setup-app-layer.sh new file mode 100755 index 00000000..b24b5e61 --- /dev/null +++ b/framework/src/suricata/scripts/setup-app-layer.sh @@ -0,0 +1,166 @@ +#! /bin/sh +# +# Script to provision a new application layer detector and parser. + +set -e +#set -x + +function usage() { + cat < + +This script will provision a new app-layer parser for the protocol +name specified on the command line. This is done by copying and +patching src/app-layer-template.[ch] then linking the new files into +the build system. + +Examples: + + $0 DNP3 + $0 Gopher + +EOF +} + +fail_if_exists() { + path="$1" + if test -e "${path}"; then + echo "error: ${path} already exists." + exit 1 + fi +} + +function copy_template_file() { + src="$1" + dst="$2" + + echo "Creating ${dst}." + + sed -e "s/TEMPLATE/${protoname_upper}/g" \ + -e "s/template/${protoname_lower}/g" \ + -e "s/Template/${protoname}/g" > ${dst} < ${src} +} + +function copy_app_layer_templates { + src_h="src/app-layer-template.h" + dst_h="src/app-layer-${protoname_lower}.h" + src_c="src/app-layer-template.c" + dst_c="src/app-layer-${protoname_lower}.c" + + fail_if_exists ${dst_h} + fail_if_exists ${dst_c} + + copy_template_file ${src_h} ${dst_h} + copy_template_file ${src_c} ${dst_c} +} + +function patch_makefile_am { + filename="src/Makefile.am" + echo "Patching ${filename}." + ed -s ${filename} > /dev/null < /dev/null < /dev/null < /dev/null < /dev/null < /dev/null <