]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: split new keyword id from registration
authorJason Ish <jason.ish@oisf.net>
Fri, 17 Jan 2025 20:46:07 +0000 (14:46 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 29 Mar 2025 21:14:00 +0000 (22:14 +0100)
Split DetectHelperKeywordRegister into 2 functions, one for acquiring
a new keyword ID, and another to perform the registration.

This makes it easier to do the traditional C keyword initialization
with a dynamic ID.

plugins/ndpi/ndpi.c

index c1879c212fc88c89cb5797ca182c5a2180740671..ec0342c78ae8e2f189f56122f5f40edbae7b8dc5 100644 (file)
@@ -466,8 +466,7 @@ static void NdpInitRiskKeyword(void)
      * support all the fields required to register the nDPI keywords,
      * so we'll just register with an empty keyword specifier to get
      * the ID, then fill in the ID. */
-    SCSigTableElmt keyword = {};
-    ndpi_protocol_keyword_id = DetectHelperKeywordRegister(&keyword);
+    ndpi_protocol_keyword_id = SCDetectHelperNewKeywordId();
     SCLogDebug("Registered new ndpi-protocol keyword with ID %" PRIu32, ndpi_protocol_keyword_id);
 
     sigmatch_table[ndpi_protocol_keyword_id].name = "ndpi-protocol";
@@ -479,7 +478,7 @@ static void NdpInitRiskKeyword(void)
     sigmatch_table[ndpi_protocol_keyword_id].flags =
             (SIGMATCH_QUOTES_OPTIONAL | SIGMATCH_HANDLE_NEGATION);
 
-    ndpi_risk_keyword_id = DetectHelperKeywordRegister(&keyword);
+    ndpi_risk_keyword_id = SCDetectHelperNewKeywordId();
     SCLogDebug("Registered new ndpi-risk keyword with ID %" PRIu32, ndpi_risk_keyword_id);
 
     sigmatch_table[ndpi_risk_keyword_id].name = "ndpi-risk";