fix indentation in ac code

remotes/origin/master-1.2.x
Anoop Saldanha 15 years ago committed by Victor Julien
parent 5c56053a33
commit 781e7c776f

@ -793,47 +793,47 @@ static inline void SCACCreateDeltaTable(MpmCtx *mpm_ctx)
} }
} }
} else { } else {
/* create space for the state table. We could have used the existing goto /* create space for the state table. We could have used the existing goto
* table, but since we have it set to hold 32 bit state values, we will create * table, but since we have it set to hold 32 bit state values, we will create
* a new state table here of type SC_AC_STATE_TYPE(current set to uint16_t) */ * a new state table here of type SC_AC_STATE_TYPE(current set to uint16_t) */
ctx->state_table_u32 = SCMalloc(ctx->state_count * ctx->state_table_u32 = SCMalloc(ctx->state_count *
sizeof(SC_AC_STATE_TYPE_U32) * 256); sizeof(SC_AC_STATE_TYPE_U32) * 256);
if (ctx->state_table_u32 == NULL) { if (ctx->state_table_u32 == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(ctx->state_table_u32, 0, memset(ctx->state_table_u32, 0,
ctx->state_count * sizeof(SC_AC_STATE_TYPE_U32) * 256); ctx->state_count * sizeof(SC_AC_STATE_TYPE_U32) * 256);
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += (ctx->state_count *
sizeof(SC_AC_STATE_TYPE_U32) * 256);
StateQueue q;
memset(&q, 0, sizeof(StateQueue));
for (ascii_code = 0; ascii_code < 256; ascii_code++) { mpm_ctx->memory_cnt++;
SC_AC_STATE_TYPE_U32 temp_state = ctx->goto_table[0][ascii_code]; mpm_ctx->memory_size += (ctx->state_count *
ctx->state_table_u32[0][ascii_code] = temp_state; sizeof(SC_AC_STATE_TYPE_U32) * 256);
if (temp_state != 0)
SCACEnqueue(&q, temp_state);
}
while (!SCACStateQueueIsEmpty(&q)) { StateQueue q;
r_state = SCACDequeue(&q); memset(&q, 0, sizeof(StateQueue));
for (ascii_code = 0; ascii_code < 256; ascii_code++) { for (ascii_code = 0; ascii_code < 256; ascii_code++) {
int32_t temp_state = ctx->goto_table[r_state][ascii_code]; SC_AC_STATE_TYPE_U32 temp_state = ctx->goto_table[0][ascii_code];
if (temp_state != SC_AC_FAIL) { ctx->state_table_u32[0][ascii_code] = temp_state;
if (temp_state != 0)
SCACEnqueue(&q, temp_state); SCACEnqueue(&q, temp_state);
ctx->state_table_u32[r_state][ascii_code] = temp_state; }
} else {
ctx->state_table_u32[r_state][ascii_code] = while (!SCACStateQueueIsEmpty(&q)) {
ctx->state_table_u32[ctx->failure_table[r_state]][ascii_code]; r_state = SCACDequeue(&q);
for (ascii_code = 0; ascii_code < 256; ascii_code++) {
int32_t temp_state = ctx->goto_table[r_state][ascii_code];
if (temp_state != SC_AC_FAIL) {
SCACEnqueue(&q, temp_state);
ctx->state_table_u32[r_state][ascii_code] = temp_state;
} else {
ctx->state_table_u32[r_state][ascii_code] =
ctx->state_table_u32[ctx->failure_table[r_state]][ascii_code];
}
} }
} }
} }
}
return; return;
} }
@ -854,14 +854,14 @@ static inline void SCACClubOutputStatePresenceWithDeltaTable(MpmCtx *mpm_ctx)
} }
} }
} else { } else {
for (state = 0; state < ctx->state_count; state++) { for (state = 0; state < ctx->state_count; state++) {
for (ascii_code = 0; ascii_code < 256; ascii_code++) { for (ascii_code = 0; ascii_code < 256; ascii_code++) {
temp_state = ctx->state_table_u32[state & 0x00FFFFFF][ascii_code]; temp_state = ctx->state_table_u32[state & 0x00FFFFFF][ascii_code];
if (ctx->output_table[temp_state & 0x00FFFFFF].no_of_entries != 0) if (ctx->output_table[temp_state & 0x00FFFFFF].no_of_entries != 0)
ctx->state_table_u32[state & 0x00FFFFFF][ascii_code] |= (1 << 24); ctx->state_table_u32[state & 0x00FFFFFF][ascii_code] |= (1 << 24);
}
} }
} }
}
return; return;
} }
@ -1245,45 +1245,45 @@ uint32_t SCACSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
} /* for (i = 0; i < buflen; i++) */ } /* for (i = 0; i < buflen; i++) */
} else { } else {
register SC_AC_STATE_TYPE_U32 state = 0; register SC_AC_STATE_TYPE_U32 state = 0;
SC_AC_STATE_TYPE_U32 (*state_table_u32)[256] = ctx->state_table_u32; SC_AC_STATE_TYPE_U32 (*state_table_u32)[256] = ctx->state_table_u32;
for (i = 0; i < buflen; i++) { for (i = 0; i < buflen; i++) {
state = state_table_u32[state & 0x00FFFFFF][u8_tolower(buf[i])]; state = state_table_u32[state & 0x00FFFFFF][u8_tolower(buf[i])];
if (state & 0xFF000000) { if (state & 0xFF000000) {
uint32_t no_of_entries = ctx->output_table[state & 0x00FFFFFF].no_of_entries; uint32_t no_of_entries = ctx->output_table[state & 0x00FFFFFF].no_of_entries;
uint32_t *pids = ctx->output_table[state & 0x00FFFFFF].pids; uint32_t *pids = ctx->output_table[state & 0x00FFFFFF].pids;
uint32_t k; uint32_t k;
for (k = 0; k < no_of_entries; k++) { for (k = 0; k < no_of_entries; k++) {
if (pids[k] & 0xFFFF0000) { if (pids[k] & 0xFFFF0000) {
if (SCMemcmp(pid_pat_list[pids[k] & 0x0000FFFF].cs, if (SCMemcmp(pid_pat_list[pids[k] & 0x0000FFFF].cs,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) { if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
}
} }
} if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { ;
; } else {
} else { pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] |= (1 << ((pids[k] & 0x0000FFFF) % 8));
pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] |= (1 << ((pids[k] & 0x0000FFFF) % 8)); pmq->pattern_id_array[pmq->pattern_id_array_cnt++] = pids[k] & 0x0000FFFF;
pmq->pattern_id_array[pmq->pattern_id_array_cnt++] = pids[k] & 0x0000FFFF; }
} matches++;
matches++;
} else {
if (pmq->pattern_id_bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
;
} else { } else {
pmq->pattern_id_bitarray[pids[k] / 8] |= (1 << (pids[k] % 8)); if (pmq->pattern_id_bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
pmq->pattern_id_array[pmq->pattern_id_array_cnt++] = pids[k]; ;
} else {
pmq->pattern_id_bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
pmq->pattern_id_array[pmq->pattern_id_array_cnt++] = pids[k];
}
matches++;
} }
matches++; //loop1:
//;
} }
//loop1:
//;
} }
} } /* for (i = 0; i < buflen; i++) */
} /* for (i = 0; i < buflen; i++) */
} }
return matches; return matches;

Loading…
Cancel
Save