-/* Copyright (C) 2013 Open Information Security Foundation
+/* Copyright (C) 2013-2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
*/
static void SCACTileGetConfig()
{
- return;
}
/**
* \param p Pointer to the SCACTilePattern instance to be freed.
* \param free Free the above pointer or not.
*/
-static inline void SCACTileFreePattern(MpmCtx *mpm_ctx, SCACTilePattern *p)
+static void SCACTileFreePattern(MpmCtx *mpm_ctx, SCACTilePattern *p)
{
if (p != NULL && p->cs != NULL && p->cs != p->ci) {
SCFree(p->cs);
mpm_ctx->memory_cnt--;
mpm_ctx->memory_size -= sizeof(SCACTilePattern);
}
- return;
}
/**
uint16_t i;
for (i = 0; i < len; i++)
d[i] = u8_tolower(s[i]);
-
- return;
}
static inline uint32_t SCACTileInitHash(SCACTilePattern *p)
/* Use Alpahbet Histogram to create compressed alphabet.
*/
-static inline void SCACTileInitTranslateTable(SCACTileCtx *ctx)
+static void SCACTileInitTranslateTable(SCACTileCtx *ctx)
{
/* Count the number of ASCII values actually appearing in any
* pattern. Create compressed mapping table with unused
SCACTileOutputTable *output_state = &ctx->output_table[state];
uint32_t i = 0;
+ /* Don't add the pattern more than once to the same state. */
for (i = 0; i < output_state->no_of_entries; i++) {
if (output_state->pids[i] == pid)
return;
}
+ /* Increase the size of the array of pids for this state and add
+ * the new pid. */
output_state->no_of_entries++;
ptmp = SCRealloc(output_state->pids,
output_state->no_of_entries * sizeof(uint32_t));
output_state->pids = ptmp;
output_state->pids[output_state->no_of_entries - 1] = pid;
-
- return;
}
/**
* need it to updated the output table for this pattern.
* \param mpm_ctx Pointer to the mpm context.
*/
-static inline void SCACTileEnter(uint8_t *pattern, uint16_t pattern_len,
- uint32_t pid, MpmCtx *mpm_ctx)
+static void SCACTileEnter(uint8_t *pattern, uint16_t pattern_len,
+ uint32_t pid, MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
SCACTileCtx *ctx = search_ctx->init_ctx;
int p = 0;
int tc;
- /* walk down the trie till we have a match for the pattern prefix */
+ /* Walk down the trie till we have a match for the pattern prefix */
state = 0;
for (i = 0; i < pattern_len; i++) {
tc = ctx->translate_table[pattern[i]];
- if (ctx->goto_table[state][tc] != SC_AC_TILE_FAIL) {
- state = ctx->goto_table[state][tc];
- } else {
+ if (ctx->goto_table[state][tc] == SC_AC_TILE_FAIL)
break;
- }
+ state = ctx->goto_table[state][tc];
}
- /* add the non-matching pattern suffix to the trie, from the last state
+ /* Add the non-matching pattern suffix to the trie, from the last state
* we left off */
for (p = i; p < pattern_len; p++) {
newstate = SCACTileInitNewState(mpm_ctx);
state = newstate;
}
- /* add this pattern id, to the output table of the last state, where the
+ /* Add this pattern id, to the output table of the last state, where the
* pattern ends in the trie */
SCACTileSetOutputState(state, pid, mpm_ctx);
-
- return;
}
/**
*
* \param mpm_ctx Pointer to the mpm context.
*/
-static inline void SCACTileCreateGotoTable(MpmCtx *mpm_ctx)
+static void SCACTileCreateGotoTable(MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
SCACTileCtx *ctx = search_ctx->init_ctx;
ctx->goto_table[0][aa] = 0;
}
}
-
- return;
}
static inline int SCACTileStateQueueIsEmpty(StateQueue *q)
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
-
- return;
}
static inline int32_t SCACTileDequeue(StateQueue *q)
* \param src_state Second state for the union operation.
* \param mpm_ctx Pointer to the mpm context.
*/
-static inline void SCACTileClubOutputStates(int32_t dst_state,
- int32_t src_state,
- MpmCtx *mpm_ctx)
+static void SCACTileClubOutputStates(int32_t dst_state,
+ int32_t src_state,
+ MpmCtx *mpm_ctx)
{
void *ptmp;
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
output_src_state->pids[i];
}
}
-
- return;
}
/**
*
* \param mpm_ctx Pointer to the mpm context.
*/
-static inline void SCACTileCreateFailureTable(MpmCtx *mpm_ctx)
+static void SCACTileCreateFailureTable(MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
SCACTileCtx *ctx = search_ctx->init_ctx;
mpm_ctx);
}
}
-
- return;
}
/*
}
}
-static inline void SCACTileClubOutputStatePresenceWithDeltaTable(MpmCtx *mpm_ctx)
+static void SCACTileClubOutputStatePresenceWithDeltaTable(MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
SCACTileCtx *ctx = search_ctx->init_ctx;
memset(mpm_thread_ctx->ctx, 0, sizeof(SCACTileThreadCtx));
mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(SCACTileThreadCtx);
-
- return;
}
/**
void SCACTilePrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
{
-
#ifdef SC_AC_TILE_COUNTERS
SCACTileThreadCtx *ctx = (SCACTileThreadCtx *)mpm_thread_ctx->ctx;
printf("AC Thread Search stats (ctx %p)\n", ctx);
printf("Total calls: %" PRIu32 "\n", ctx->total_calls);
printf("Total matches: %" PRIu64 "\n", ctx->total_matches);
#endif /* SC_AC_TILE_COUNTERS */
-
- return;
}
void SCACTilePrintInfo(MpmCtx *mpm_ctx)
printf("Largest: %" PRIu32 "\n", mpm_ctx->maxlen);
printf("Total states in the state table: %d\n", ctx->state_count);
printf("\n");
-
- return;
}
/************************** Mpm Registration ***************************/
mpm_table[MPM_AC_TILE].PrintCtx = SCACTilePrintInfo;
mpm_table[MPM_AC_TILE].PrintThreadCtx = SCACTilePrintSearchStats;
mpm_table[MPM_AC_TILE].RegisterUnittests = SCACTileRegisterTests;
-
- return;
}
UtRegisterTest("SCACTileTest28", SCACTileTest28, 1);
UtRegisterTest("SCACTileTest29", SCACTileTest29, 1);
#endif
-
- return;
}
#endif /* __tile__ */