]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
classtype: increase id size
authorVictor Julien <victor@inliniac.net>
Tue, 1 Oct 2019 10:50:13 +0000 (12:50 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 8 Oct 2019 18:31:09 +0000 (20:31 +0200)
Switch from u8 to u16 to allow for more classtypes.

Rename Signature::class to Signature::class_id to make it clear
it is an id.

src/alert-unified2-alert.c
src/detect-classtype.c
src/detect.h
src/util-classification-config.c
src/util-classification-config.h

index 6fe26efa452081e504a25ccd94757772f3a8b9be..fd23ed1bd0465d9d85218e7467c694f5349f493a 100644 (file)
@@ -948,7 +948,7 @@ static int Unified2IPv6TypeAlert(ThreadVars *t, const Packet *p, void *data)
         phdr->generator_id = htonl(pa->s->gid);
         phdr->signature_id = htonl(pa->s->id);
         phdr->signature_revision = htonl(pa->s->rev);
-        phdr->classification_id = htonl(pa->s->class);
+        phdr->classification_id = htonl(pa->s->class_id);
         phdr->priority_id = htonl(pa->s->prio);
 
         SCMutexLock(&file_ctx->fp_mutex);
@@ -1136,7 +1136,7 @@ static int Unified2IPv4TypeAlert (ThreadVars *tv, const Packet *p, void *data)
         phdr->generator_id = htonl(pa->s->gid);
         phdr->signature_id = htonl(pa->s->id);
         phdr->signature_revision = htonl(pa->s->rev);
-        phdr->classification_id = htonl(pa->s->class);
+        phdr->classification_id = htonl(pa->s->class_id);
         phdr->priority_id = htonl(pa->s->prio);
 
         /* check and enforce the filesize limit */
index 6122e523f9aba7988ade37445b3ab215d57943b2..04955bf5cf6187fb1cc0c41eab22d3b7a7541399 100644 (file)
@@ -101,7 +101,7 @@ static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, const cha
 {
     char parsed_ct_name[1024] = "";
 
-    if ((s->class > 0) || (s->class_msg != NULL)) {
+    if ((s->class_id > 0) || (s->class_msg != NULL)) {
         SCLogWarning(SC_ERR_CONFLICTING_RULE_KEYWORDS, "duplicated 'classtype' "
                 "keyword detected. Using instance with highest priority");
     }
@@ -121,16 +121,16 @@ static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, const cha
 
     if ((s->init_data->init_flags & SIG_FLAG_INIT_PRIO_EXPLICT) != 0) {
         /* don't touch Signature::prio */
-        s->class = ct->classtype_id;
+        s->class_id = ct->classtype_id;
         s->class_msg = ct->classtype_desc;
     } else if (s->prio == -1) {
         s->prio = ct->priority;
-        s->class = ct->classtype_id;
+        s->class_id = ct->classtype_id;
         s->class_msg = ct->classtype_desc;
     } else {
         if (ct->priority < s->prio) {
             s->prio = ct->priority;
-            s->class = ct->classtype_id;
+            s->class_id = ct->classtype_id;
             s->class_msg = ct->classtype_desc;
         }
     }
index d556dd1fd95b88dc829d26a3e3b2da61abf1c863..c4babf91ffc4da380cd76ef40e42cbab3a27c841 100644 (file)
@@ -535,7 +535,7 @@ typedef struct Signature_ {
     DetectProto proto;
 
     /** classification id **/
-    uint8_t class;
+    uint16_t class_id;
 
     /** ipv4 match arrays */
     uint16_t addr_dst_match4_cnt;
index a59624af6f37dec1930719a7d292a22cd624a93f..6cc75672c9dd6fd55d1cb917bc6b9030c7fec267 100644 (file)
@@ -56,7 +56,7 @@ char SCClassConfClasstypeHashCompareFunc(void *data1, uint16_t datalen1,
 void SCClassConfClasstypeHashFree(void *ch);
 static const char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx);
 
-static SCClassConfClasstype *SCClassConfAllocClasstype(uint8_t classtype_id,
+static SCClassConfClasstype *SCClassConfAllocClasstype(uint16_t classtype_id,
         const char *classtype, const char *classtype_desc, int priority);
 static void SCClassConfDeAllocClasstype(SCClassConfClasstype *ct);
 
@@ -248,13 +248,13 @@ static char *SCClassConfStringToLowercase(const char *str)
  * \retval  0 On success.
  * \retval -1 On failure.
  */
-static int SCClassConfAddClasstype(char *rawstr, uint8_t index, DetectEngineCtx *de_ctx)
+static int SCClassConfAddClasstype(char *rawstr, uint16_t index, DetectEngineCtx *de_ctx)
 {
     char ct_name[64];
     char ct_desc[512];
     char ct_priority_str[16];
     int ct_priority = 0;
-    uint8_t ct_id = index;
+    uint16_t ct_id = index;
 
     SCClassConfClasstype *ct_new = NULL;
     SCClassConfClasstype *ct_lookup = NULL;
@@ -359,7 +359,7 @@ static int SCClassConfIsLineBlankOrComment(char *line)
 static void SCClassConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
 {
     char line[1024];
-    uint8_t i = 1;
+    uint16_t i = 1;
 
     while (fgets(line, sizeof(line), fd) != NULL) {
         if (SCClassConfIsLineBlankOrComment(line))
@@ -389,7 +389,7 @@ static void SCClassConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
  * \retval ct Pointer to the new instance of SCClassConfClasstype on success;
  *            NULL on failure.
  */
-static SCClassConfClasstype *SCClassConfAllocClasstype(uint8_t classtype_id,
+static SCClassConfClasstype *SCClassConfAllocClasstype(uint16_t classtype_id,
                                                 const char *classtype,
                                                 const char *classtype_desc,
                                                 int priority)
index e35e992e18f8d518751d591b93b7a0b565c17094..97f58abb5b16ff913f794213f70cff241b8139d4 100644 (file)
@@ -29,7 +29,7 @@
  */
 typedef struct SCClassConfClasstype_ {
     /* The index of the classification within classification.confg */
-    uint8_t classtype_id;
+    uint16_t classtype_id;
 
     /* The priority this classification type carries */
     int priority;