thansk for tellig me the decode event report,now I found the keyword "decode-event" codes.<br>but still has a problem,when decode-event geneted,the match codes like<br><br>DetectDecodeEventMatch->DECODER_ISSET_EVENT<br>
<br>#define DECODER_ISSET_EVENT(p, e) ({ \<br> int r = 0; \<br> uint8_t u; \<br> for (u = 0; u < (p)->events.cnt; u++) { \<br> if ((p)->events.events[u] == (e)) { \<br> r = 1; \<br> break; \<br>
} \<br> } \<br> r; \<br>})<br><br>so we have to compare multi times for a decode-event defined in signature. if we have N decode-event defined in rule files,whe have to compare up to N*p->events.cnt tmes,why we don't use hash to store decode-event as I mentioned ?<br>
<br>/** number of decoder events we support per packet. Power of 2 minus 1<br> * for memory layout */<br>#define PACKET_DECODER_EVENT_MAX 15<br><br>/** data structure to store decoder, defrag and stream events */<br>typedef struct PacketDecoderEvents_ {<br>
uint8_t cnt; /**< number of events */<br> uint8_t events[PACKET_DECODER_EVENT_MAX]; /**< array of events */<br>} PacketDecoderEvents;<br><br>the max number of decode-event defined as the MAX in decode-event enum type,as<br>
<br>typedef struct PacketDecoderEvents_ {<br>
uint8_t cnt; /**< number of events */ /*I think the cnt mybe not need anymore*/<br>
uint8_t events[<span style="background-color: rgb(255, 0, 0);">DECODE_EVENT_MAX</span>]; /**< array of events */<br>
} PacketDecoderEvents;<br><br>when decode event generated,we can use codes like:<br><br>/* OLD codes*/<br>#define DECODER_SET_EVENT(p, e) do { \<br> if ((p)->events.cnt < PACKET_DECODER_EVENT_MAX) { \<br> (p)->events.events[(p)->events.cnt] = e; \<br>
(p)->events.cnt++; \<br> } \<br>} while(0)<br><br>/*NEW codes*/<br>#define DECODER_SET_EVENT(p, e) do { \<br> if ((p)->events.cnt < <span style="background-color: rgb(255, 0, 0);">DECODE_EVENT_MAX</span>) { \/*usually not occur*/<br>
(p)->events.events[e] = 1; \<br> } else {\<br> BUG();\/*oop,you not use decode-event defined in enum type*/<br> }\<br>} while(0)<br><br>new match codes like<br>#define DECODER_ISSET_EVENT(p, e) ({ \<br>
if ((p)->events.events[u] == (e)) { \<br> r = 1; \<br> } else {\<br> r=0;\<br> } \<br> r; \<br>})<br><br>so the index of events arry is the definition of devode-event.we can match if the decode-event generated directly,not compare anymore in a for loop.<br>
<br><br>