]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/applayertemplate: replace rs_ naming with SC
authorJason Ish <jason.ish@oisf.net>
Mon, 5 May 2025 15:41:34 +0000 (09:41 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 5 May 2025 19:41:03 +0000 (21:41 +0200)
rust/src/applayertemplate/logger.rs
rust/src/applayertemplate/template.rs
scripts/setup-app-layer.py
src/app-layer-parser.c
src/output.c

index a970e832776e879006efe878ebfd8c31a98aa8e1..e1c4326bd02995b1cfce4de7f807c2a3fa9c9310 100644 (file)
@@ -32,7 +32,7 @@ fn log_template(tx: &TemplateTransaction, js: &mut JsonBuilder) -> Result<(), Js
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_template_logger_log(
+pub unsafe extern "C" fn SCTemplateLoggerLog(
     tx: *const std::os::raw::c_void, js: *mut std::os::raw::c_void,
 ) -> bool {
     let tx = cast_pointer!(tx, TemplateTransaction);
index 6748fa0702968b32c9902bff2107971a65c45d02..94101e5c61124fa0308daecfec44d06b1641ae29 100644 (file)
@@ -254,7 +254,7 @@ fn probe(input: &[u8]) -> nom::IResult<&[u8], ()> {
 // C exports.
 
 /// C entry point for a probing parser.
-unsafe extern "C" fn rs_template_probing_parser(
+unsafe extern "C" fn template_probing_parser(
     _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8,
 ) -> AppProto {
     // Need at least 2 bytes.
@@ -267,7 +267,7 @@ unsafe extern "C" fn rs_template_probing_parser(
     return ALPROTO_UNKNOWN;
 }
 
-extern "C" fn rs_template_state_new(
+extern "C" fn template_state_new(
     _orig_state: *mut c_void, _orig_proto: AppProto,
 ) -> *mut c_void {
     let state = TemplateState::new();
@@ -275,16 +275,16 @@ extern "C" fn rs_template_state_new(
     return Box::into_raw(boxed) as *mut c_void;
 }
 
-unsafe extern "C" fn rs_template_state_free(state: *mut c_void) {
+unsafe extern "C" fn template_state_free(state: *mut c_void) {
     std::mem::drop(Box::from_raw(state as *mut TemplateState));
 }
 
-unsafe extern "C" fn rs_template_state_tx_free(state: *mut c_void, tx_id: u64) {
+unsafe extern "C" fn template_state_tx_free(state: *mut c_void, tx_id: u64) {
     let state = cast_pointer!(state, TemplateState);
     state.free_tx(tx_id);
 }
 
-unsafe extern "C" fn rs_template_parse_request(
+unsafe extern "C" fn template_parse_request(
     _flow: *const Flow, state: *mut c_void, pstate: *mut c_void, stream_slice: StreamSlice,
     _data: *const c_void,
 ) -> AppLayerResult {
@@ -308,7 +308,7 @@ unsafe extern "C" fn rs_template_parse_request(
     }
 }
 
-unsafe extern "C" fn rs_template_parse_response(
+unsafe extern "C" fn template_parse_response(
     _flow: *const Flow, state: *mut c_void, pstate: *mut c_void, stream_slice: StreamSlice,
     _data: *const c_void,
 ) -> AppLayerResult {
@@ -326,7 +326,7 @@ unsafe extern "C" fn rs_template_parse_response(
     }
 }
 
-unsafe extern "C" fn rs_template_state_get_tx(state: *mut c_void, tx_id: u64) -> *mut c_void {
+unsafe extern "C" fn template_state_get_tx(state: *mut c_void, tx_id: u64) -> *mut c_void {
     let state = cast_pointer!(state, TemplateState);
     match state.get_tx(tx_id) {
         Some(tx) => {
@@ -338,12 +338,12 @@ unsafe extern "C" fn rs_template_state_get_tx(state: *mut c_void, tx_id: u64) ->
     }
 }
 
-unsafe extern "C" fn rs_template_state_get_tx_count(state: *mut c_void) -> u64 {
+unsafe extern "C" fn template_state_get_tx_count(state: *mut c_void) -> u64 {
     let state = cast_pointer!(state, TemplateState);
     return state.tx_id;
 }
 
-unsafe extern "C" fn rs_template_tx_get_alstate_progress(tx: *mut c_void, _direction: u8) -> c_int {
+unsafe extern "C" fn template_tx_get_alstate_progress(tx: *mut c_void, _direction: u8) -> c_int {
     let tx = cast_pointer!(tx, TemplateTransaction);
 
     // Transaction is done if we have a response.
@@ -360,7 +360,7 @@ export_state_data_get!(template_get_state_data, TemplateState);
 const PARSER_NAME: &[u8] = b"template\0";
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_template_register_parser() {
+pub unsafe extern "C" fn SCRegisterTemplateParser() {
     /* TEMPLATE_START_REMOVE */
     if crate::conf::conf_get_node("app-layer.protocols.template").is_none() {
         return;
@@ -372,20 +372,20 @@ pub unsafe extern "C" fn rs_template_register_parser() {
         name: PARSER_NAME.as_ptr() as *const c_char,
         default_port: default_port.as_ptr(),
         ipproto: IPPROTO_TCP,
-        probe_ts: Some(rs_template_probing_parser),
-        probe_tc: Some(rs_template_probing_parser),
+        probe_ts: Some(template_probing_parser),
+        probe_tc: Some(template_probing_parser),
         min_depth: 0,
         max_depth: 16,
-        state_new: rs_template_state_new,
-        state_free: rs_template_state_free,
-        tx_free: rs_template_state_tx_free,
-        parse_ts: rs_template_parse_request,
-        parse_tc: rs_template_parse_response,
-        get_tx_count: rs_template_state_get_tx_count,
-        get_tx: rs_template_state_get_tx,
+        state_new: template_state_new,
+        state_free: template_state_free,
+        tx_free: template_state_tx_free,
+        parse_ts: template_parse_request,
+        parse_tc: template_parse_response,
+        get_tx_count: template_state_get_tx_count,
+        get_tx: template_state_get_tx,
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
-        tx_get_progress: rs_template_tx_get_alstate_progress,
+        tx_get_progress: template_tx_get_alstate_progress,
         get_eventinfo: Some(TemplateEvent::get_event_info),
         get_eventinfo_byid: Some(TemplateEvent::get_event_info_by_id),
         localstorage_new: None,
index d8190ab3a20be649cfc02e2c717ee363ef4e6657..089ae2904a1c1411c4cfefd959abb513671172bf 100755 (executable)
@@ -148,7 +148,7 @@ def patch_app_layer_parser_c(proto):
     output = io.StringIO()
     inlines = open(filename).readlines()
     for line in inlines:
-        if line.find("rs_template_register_parser") > -1:
+        if line.find("SCRegisterTemplateParser") > -1:
             output.write(line.replace("template", proto.lower()))
         output.write(line)
     open(filename, "w").write(output.getvalue())
@@ -207,7 +207,7 @@ def logger_patch_output_c(proto):
             output.write(inlines[i+2].replace("TEMPLATE", proto.upper()).replace(
                     "template", proto.lower()).replace("Template", proto))
             output.write(inlines[i+3])
-        if line.find("rs_template_logger_log") > -1:
+        if line.find("SCTemplateLoggerLog") > -1:
             output.write(inlines[i].replace("TEMPLATE", proto.upper()).replace(
                     "template", proto.lower()))
             # RegisterSimpleJsonApplayerLogger( on its own line for clang-format
index 4fbf4e2d99d7f270d695fd8fe4be4445a5e7c586..2e22371d1015cae068b0422568b0d62122cc2bd0 100644 (file)
@@ -1798,7 +1798,7 @@ void AppLayerParserRegisterProtocolParsers(void)
     rs_websocket_register_parser();
     SCRegisterLdapTcpParser();
     SCRegisterLdapUdpParser();
-    rs_template_register_parser();
+    SCRegisterTemplateParser();
     SCRfbRegisterParser();
     SCMqttRegisterParser();
     SCRegisterPgsqlParser();
index 6453bc1d3d70517f8359dd76dbff6e0ead654762..41f198a3c77970c0ca0a2d9e30232e245347fa4e 100644 (file)
@@ -928,7 +928,7 @@ void OutputRegisterRootLoggers(void)
             ALPROTO_LDAP, (EveJsonSimpleTxLogFunc)rs_ldap_logger_log, NULL);
     RegisterSimpleJsonApplayerLogger(ALPROTO_DOH2, (EveJsonSimpleTxLogFunc)AlertJsonDoh2, NULL);
     RegisterSimpleJsonApplayerLogger(
-            ALPROTO_TEMPLATE, (EveJsonSimpleTxLogFunc)rs_template_logger_log, NULL);
+            ALPROTO_TEMPLATE, (EveJsonSimpleTxLogFunc)SCTemplateLoggerLog, NULL);
     RegisterSimpleJsonApplayerLogger(ALPROTO_RDP, (EveJsonSimpleTxLogFunc)SCRdpToJson, NULL);
     // special case : http2 is logged in http object
     RegisterSimpleJsonApplayerLogger(ALPROTO_HTTP2, (EveJsonSimpleTxLogFunc)SCHttp2LogJson, "http");