classtype: increase id size

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.
pull/4288/head
Victor Julien 7 years ago
parent ccf6c5a6ef
commit 323a747f39

@ -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 */

@ -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;
}
}

@ -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;

@ -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)

@ -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;

Loading…
Cancel
Save