]>
git.ipfire.org Git - people/ms/suricata.git/blob - scripts/setup-decoder.sh
e041226b6be1ca7d99dcee1ccfc62db2f7946a81
3 # Script to setup a new decoder.
4 # Written by Victor Julien <victor@inliniac.net>
12 echo "$(basename $0) -- script to provision a decoder. The script"
13 echo "makes a copy of the decode-template, sets the name and updates"
14 echo " the build system."
16 echo "Call from the 'src' directory, with one argument: the decoder name."
18 echo "E.g. inside 'src': ../scripts/$(basename $0) ipv7"
24 echo "Decoder $NR has been set up in $FILE_C and $FILE_H and the"
25 echo "build system has been updated."
27 echo "The decoder should now compile cleanly. Try running 'make'."
29 echo "Next steps are to edit the files to implement the actual"
30 echo "decoding of $NR."
34 # Make sure we are running from the correct directory.
36 if [ -e .
/suricata.c
]; then
39 elif [ -e .
/src
/suricata.c
]; then
42 echo "error: this does not appear to be a suricata source directory."
47 if [ $# -ne "1" ]; then
49 echo "ERROR: call with one argument"
64 FILE_C
="decode-${LC}.c"
65 FILE_H
="decode-${LC}.h"
71 if [ ! -e decode-template.c
] ||
[ ! -e decode-template.h
]; then
73 echo "ERROR: input files decode-template.c and/or decode-template.h are missing"
76 if [ -e $FILE_C ] ||
[ -e $FILE_H ]; then
78 echo "ERROR: file(s) $FILE_C and/or $FILE_H already exist, won't overwrite"
82 cp decode-template.c
$FILE_C
83 cp decode-template.h
$FILE_H
86 sed -i "s/TEMPLATE/${UC}/g" $FILE_C
87 sed -i "s/TEMPLATE/${UC}/g" $FILE_H
88 sed -i "s/Template/${NR}/g" $FILE_C
89 sed -i "s/Template/${NR}/g" $FILE_H
90 sed -i "s/template/${LC}/g" $FILE_C
91 sed -i "s/template/${LC}/g" $FILE_H
92 sed -i "s/decode-template.c decode-template.h \\\/decode-template.c decode-template.h \\\\\n${FILE_C} ${FILE_H} \\\/g" Makefile.am
94 ed
-s decode.h
> /dev
/null
<<EOF
97 s/DecodeTEMPLATE/Decode${UC}/g