/* TEMPLATE_START_REMOVE */
use crate::conf::conf_get_node;
/* TEMPLATE_END_REMOVE */
-use crate::direction::Direction;
use crate::detect::{
DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperGetData,
DetectHelperKeywordRegister, DetectSignatureSetAppProto, SCSigTableElmt,
SIGMATCH_INFO_STICKY_BUFFER, SIGMATCH_NOOPT,
};
+use crate::direction::Direction;
use std::os::raw::{c_int, c_void};
static mut G_TEMPLATE_BUFFER_BUFFER_ID: c_int = 0;
#[no_mangle]
pub unsafe extern "C" fn rs_template_logger_log(
- tx: *mut std::os::raw::c_void, js: &mut JsonBuilder,
+ tx: *const std::os::raw::c_void, js: *mut std::os::raw::c_void,
) -> bool {
let tx = cast_pointer!(tx, TemplateTransaction);
+ let js = cast_pointer!(js, JsonBuilder);
log_template(tx, js).is_ok()
}
mod parser;
pub mod template;
/* TEMPLATE_START_REMOVE */
-pub mod logger;
pub mod detect;
+pub mod logger;
/* TEMPLATE_END_REMOVE */
*/
use super::parser;
-use crate::applayer::{self, *};
+use crate::applayer::*;
use crate::conf::conf_get;
use crate::core::{ALPROTO_UNKNOWN, IPPROTO_TCP};
use crate::flow::Flow;
use nom7 as nom;
-use suricata_sys::sys::AppProto;
use std;
use std::collections::VecDeque;
use std::ffi::CString;
use std::os::raw::{c_char, c_int, c_void};
+use suricata_sys::sys::AppProto;
static mut TEMPLATE_MAX_TX: usize = 256;
}
fn find_request(&mut self) -> Option<&mut TemplateTransaction> {
- self.transactions.iter_mut().find(|tx| tx.response.is_none())
+ self.transactions
+ .iter_mut()
+ .find(|tx| tx.response.is_none())
}
fn parse_request(&mut self, input: &[u8]) -> AppLayerResult {
SCLogNotice!("Request: {}", request);
let mut tx = self.new_tx();
tx.request = Some(request);
- if self.transactions.len() >= unsafe {TEMPLATE_MAX_TX} {
- tx.tx_data.set_event(TemplateEvent::TooManyTransactions as u8);
+ if self.transactions.len() >= unsafe { TEMPLATE_MAX_TX } {
+ tx.tx_data
+ .set_event(TemplateEvent::TooManyTransactions as u8);
}
self.transactions.push_back(tx);
- if self.transactions.len() >= unsafe {TEMPLATE_MAX_TX} {
+ if self.transactions.len() >= unsafe { TEMPLATE_MAX_TX } {
return AppLayerResult::err();
}
}
Ok((rem, response)) => {
start = rem;
- if let Some(tx) = self.find_request() {
+ if let Some(tx) = self.find_request() {
tx.tx_data.updated_tc = true;
tx.response = Some(response);
SCLogNotice!("Found response for request:");
localstorage_new: None,
localstorage_free: None,
get_tx_files: None,
- get_tx_iterator: Some(
- applayer::state_get_tx_iterator::<TemplateState, TemplateTransaction>,
- ),
+ get_tx_iterator: Some(state_get_tx_iterator::<TemplateState, TemplateTransaction>),
get_tx_data: template_get_tx_data,
get_state_data: template_get_state_data,
apply_tx_config: None,
if line.find("rs_template_logger_log") > -1:
output.write(inlines[i].replace("TEMPLATE", proto.upper()).replace(
"template", proto.lower()))
+ # RegisterSimpleJsonApplayerLogger( on itw own line for clang-format
+ output.write(inlines[i-1])
if line.find("OutputTemplateLogInitSub(") > -1:
output.write(inlines[i].replace("Template", proto))
output.write(inlines[i+1])
RegisterSimpleJsonApplayerLogger(ALPROTO_WEBSOCKET, rs_websocket_logger_log, NULL);
RegisterSimpleJsonApplayerLogger(ALPROTO_LDAP, rs_ldap_logger_log, NULL);
RegisterSimpleJsonApplayerLogger(ALPROTO_DOH2, AlertJsonDoh2, NULL);
- RegisterSimpleJsonApplayerLogger(ALPROTO_TEMPLATE, rs_template_logger_log, NULL);
+ RegisterSimpleJsonApplayerLogger(
+ ALPROTO_TEMPLATE, (EveJsonSimpleTxLogFunc)rs_template_logger_log, NULL);
RegisterSimpleJsonApplayerLogger(ALPROTO_RDP, (EveJsonSimpleTxLogFunc)rs_rdp_to_json, NULL);
// special case : http2 is logged in http object
RegisterSimpleJsonApplayerLogger(ALPROTO_HTTP2, rs_http2_log_json, "http");