#! /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 '/TEMPLATE_START_REMOVE/,/TEMPLATE_END_REMOVE/d' \ -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 <