templates: C stub template for Rust parser

pull/3487/head
Jason Ish 7 years ago committed by Victor Julien
parent 789b1474ed
commit 96dc20abb1

@ -51,6 +51,7 @@ app-layer-ikev2.c app-layer-ikev2.h \
app-layer-krb5.c app-layer-krb5.h \
app-layer-dhcp.c app-layer-dhcp.h \
app-layer-template.c app-layer-template.h \
app-layer-template-rust.c app-layer-template-rust.h \
app-layer-ssh.c app-layer-ssh.h \
app-layer-ssl.c app-layer-ssl.h \
conf.c conf.h \

@ -731,6 +731,8 @@ static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingPar
printf(" alproto: ALPROTO_KRB5\n");
else if (pp_pe->alproto == ALPROTO_DHCP)
printf(" alproto: ALPROTO_DHCP\n");
else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST)
printf(" alproto: ALPROTO_TEMPLATE_RUST\n");
else if (pp_pe->alproto == ALPROTO_TEMPLATE)
printf(" alproto: ALPROTO_TEMPLATE\n");
else if (pp_pe->alproto == ALPROTO_DNP3)
@ -802,6 +804,8 @@ static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingPar
printf(" alproto: ALPROTO_KRB5\n");
else if (pp_pe->alproto == ALPROTO_DHCP)
printf(" alproto: ALPROTO_DHCP\n");
else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST)
printf(" alproto: ALPROTO_TEMPLATE_RUST\n");
else if (pp_pe->alproto == ALPROTO_TEMPLATE)
printf(" alproto: ALPROTO_TEMPLATE\n");
else if (pp_pe->alproto == ALPROTO_DNP3)

@ -68,6 +68,7 @@
#include "app-layer-krb5.h"
#include "app-layer-dhcp.h"
#include "app-layer-template.h"
#include "app-layer-template-rust.h"
#include "conf.h"
#include "util-spm.h"
@ -1466,6 +1467,7 @@ void AppLayerParserRegisterProtocolParsers(void)
RegisterIKEV2Parsers();
RegisterKRB5Parsers();
RegisterDHCPParsers();
RegisterTemplateRustParsers();
RegisterTemplateParsers();
/** IMAP */

@ -105,6 +105,9 @@ const char *AppProtoToString(AppProto alproto)
case ALPROTO_TEMPLATE:
proto_name = "template";
break;
case ALPROTO_TEMPLATE_RUST:
proto_name = "template-rust";
break;
case ALPROTO_FAILED:
proto_name = "failed";
break;
@ -145,6 +148,7 @@ AppProto StringToAppProto(const char *proto_name)
if (strcmp(proto_name,"krb5")==0) return ALPROTO_KRB5;
if (strcmp(proto_name,"dhcp")==0) return ALPROTO_DHCP;
if (strcmp(proto_name,"template")==0) return ALPROTO_TEMPLATE;
if (strcmp(proto_name,"template-rust")==0) return ALPROTO_TEMPLATE_RUST;
if (strcmp(proto_name,"failed")==0) return ALPROTO_FAILED;
return ALPROTO_UNKNOWN;

@ -52,6 +52,7 @@ enum AppProtoEnum {
ALPROTO_KRB5,
ALPROTO_DHCP,
ALPROTO_TEMPLATE,
ALPROTO_TEMPLATE_RUST,
/* used by the probing parser when alproto detection fails
* permanently for that particular stream */

@ -0,0 +1,74 @@
/* 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 pruposes.
*
* 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"
#ifdef HAVE_RUST
#include "rust-applayertemplate-template-gen.h"
#endif
void RegisterTemplateRustParsers(void)
{
#ifdef HAVE_RUST
/* Only register if enabled in config. */
if (ConfGetNode("app-layer.protocols.template-rust") == NULL) {
return;
}
SCLogNotice("Registring Rust template parser.");
rs_template_register_parser();
#endif
#ifdef UNITTESTS
AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_TEMPLATE_RUST,
TemplateRustParserRegisterTests);
#endif
}
#ifdef UNITTESTS
#endif
void TemplateRustParserRegisterTests(void)
{
#ifdef UNITTESTS
#endif
}

@ -0,0 +1,30 @@
/* 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__ */
Loading…
Cancel
Save