#[no_mangle]
pub unsafe extern "C" fn rs_template_register_parser() {
+ /* TEMPLATE_START_REMOVE */
+ if crate::conf::conf_get_node("app-layer.protocols.template-rust").is_none() {
+ return;
+ }
+ /* TEMPLATE_END_REMOVE */
+
let default_port = CString::new("[7000]").unwrap();
let parser = RustParser {
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
if rust:
pairs = (
- ("src/app-layer-template-rust.c",
- "src/app-layer-%s.c" % (lower)),
- ("src/app-layer-template-rust.h",
- "src/app-layer-%s.h" % (lower)),
("rust/src/applayertemplate/mod.rs",
"rust/src/applayer%s/mod.rs" % (lower)),
("rust/src/applayertemplate/template.rs",
output.write(line)
open(filename, "w").write(output.getvalue())
-def patch_app_layer_parser_c(proto):
+def patch_app_layer_parser_c(proto, rust):
filename = "src/app-layer-parser.c"
print("Patching %s." % (filename))
output = io.StringIO()
inlines = open(filename).readlines()
for line in inlines:
- if line.find("app-layer-template.h") > -1:
- output.write(line.replace("template", proto.lower()))
- if line.find("RegisterTemplateParsers()") > -1:
- output.write(line.replace("Template", proto))
+ if rust:
+ if line.find("rs_template_register_parser") > -1:
+ output.write(line.replace("template", proto.lower()))
+ else:
+ if line.find("app-layer-template.h") > -1:
+ output.write(line.replace("template", proto.lower()))
+ if line.find("RegisterTemplateParsers()") > -1:
+ output.write(line.replace("Template", proto))
output.write(line)
open(filename, "w").write(output.getvalue())
copy_app_layer_templates(proto, args.rust)
if args.rust:
patch_rust_lib_rs(proto)
- patch_makefile_am(proto)
+ if not args.rust:
+ patch_makefile_am(proto)
patch_app_layer_protos_h(proto)
patch_app_layer_protos_c(proto)
patch_app_layer_detect_proto_c(proto)
- patch_app_layer_parser_c(proto)
+ patch_app_layer_parser_c(proto, args.rust)
patch_suricata_yaml_in(proto)
if logger:
app-layer-ssh.h \
app-layer-ssl.h \
app-layer-template.h \
- app-layer-template-rust.h \
app-layer-tftp.h \
autoconf.h \
build-info.h \
app-layer-ssh.c \
app-layer-ssl.c \
app-layer-template.c \
- app-layer-template-rust.c \
app-layer-tftp.c \
conf.c \
conf-yaml-loader.c \
#include "app-layer-snmp.h"
#include "app-layer-quic.h"
#include "app-layer-template.h"
-#include "app-layer-template-rust.h"
#include "app-layer-rdp.h"
#include "app-layer-http2.h"
RegisterSNMPParsers();
RegisterSIPParsers();
RegisterQuicParsers();
- RegisterTemplateRustParsers();
+ rs_template_register_parser();
RegisterRFBParsers();
RegisterMQTTParsers();
rs_pgsql_register_parser();
+++ /dev/null
-/* Copyright (C) 2018 Open Information Security Foundation
- *
- * You can copy, redistribute or modify this Program under the terms of
- * the GNU General Public License version 2 as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-/*
- * TODO: Update \author in this file and app-layer-templaterust.h.
- * TODO: Implement your app-layer logic with unit tests.
- * TODO: Remove SCLogNotice statements or convert to debug.
- */
-
-/**
- * \file
- *
- * \author FirstName LastName <yourname@domain>
- *
- * TemplateRust application layer detector and parser for learning and
- * templaterust purposes.
- *
- * This templaterust implements a simple application layer for something
- * like the echo protocol running on port 7.
- */
-
-#include "suricata-common.h"
-#include "stream.h"
-#include "conf.h"
-
-#include "util-unittest.h"
-
-#include "app-layer-detect-proto.h"
-#include "app-layer-parser.h"
-
-#include "app-layer-template-rust.h"
-#include "rust.h"
-
-void RegisterTemplateRustParsers(void)
-{
- /* TEMPLATE_START_REMOVE */
- /* Only register if enabled in config. */
- if (ConfGetNode("app-layer.protocols.template-rust") == NULL) {
- return;
- }
- /* TEMPLATE_END_REMOVE */
- SCLogNotice("Registering Rust template parser.");
- rs_template_register_parser();
-#ifdef UNITTESTS
- AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_TEMPLATE_RUST,
- TemplateRustParserRegisterTests);
-#endif
-}
-
-#ifdef UNITTESTS
-#endif
-
-void TemplateRustParserRegisterTests(void)
-{
-#ifdef UNITTESTS
-#endif
-}
+++ /dev/null
-/* Copyright (C) 2018 Open Information Security Foundation
- *
- * You can copy, redistribute or modify this Program under the terms of
- * the GNU General Public License version 2 as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-/**
- * \file
- *
- * \author FirstName LastName <yourname@domain>
- */
-
-#ifndef __APP_LAYER_TEMPLATE_RUST_H__
-#define __APP_LAYER_TEMPLATE_RUST_H__
-
-void RegisterTemplateRustParsers(void);
-void TemplateRustParserRegisterTests(void);
-
-#endif /* __APP_LAYER_TEMPLATE_RUST_H__ */
#include "app-layer.h"
#include "app-layer-parser.h"
-#include "app-layer-template-rust.h"
#include "output-json-template-rust.h"
#include "rust.h"