rust: example of how an app-layer may be initialized

Also shows basic usage of the configuration API from Rust.
pull/2746/head
Jason Ish 9 years ago
parent 949b358b80
commit f6f126d53d

@ -0,0 +1,34 @@
/* Copyright (C) 2017 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.
*/
use log::*;
use conf;
#[no_mangle]
pub extern "C" fn rs_dns_init() {
SCLogNotice!("Initializing DNS analyzer");
match conf::conf_get("app-layer.protocols.dns.tcp.enabled") {
Some(val) => SCLogNotice!("- TCP is enabled: {}", val),
None => SCLogNotice!("- TCP is not enabled."),
}
match conf::conf_get("app-layer.protocols.dns.udp.enabled") {
Some(val) => SCLogNotice!("- UDP is enabled: {}", val),
None => SCLogNotice!("- UDP is not enabled."),
}
}

@ -2,3 +2,4 @@
pub mod log;
pub mod conf;
pub mod dns;

@ -50,6 +50,10 @@
#include "app-layer-dns-udp.h"
#ifdef HAVE_RUST
#include "rust.h"
#endif
/** \internal
* \brief Parse DNS request packet
*/
@ -385,6 +389,12 @@ void RegisterDNSUDPParsers(void)
{
const char *proto_name = "dns";
#ifdef HAVE_RUST
/* If DNS was implemented in Rust, we could call into the rust
* init function here. */
rs_dns_init();
#endif
/** DNS */
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name);

@ -16,3 +16,4 @@
*/
void rs_log_init(int32_t level);
void rs_dns_init(void);

Loading…
Cancel
Save