예제 #1
0
/** \brief Initialise SOM state. Used in both block and streaming mode. */
static really_inline
void initSomState(const struct RoseEngine *rose, u8 *state) {
    assert(rose && state);
    const u32 somCount = rose->somLocationCount;
    mmbit_clear(state + rose->stateOffsets.somValid, somCount);
    mmbit_clear(state + rose->stateOffsets.somWritable, somCount);
}
예제 #2
0
파일: eod.c 프로젝트: 0x4e38/hyperscan
static really_inline
void roseEodExec_i(const struct RoseEngine *t, u8 *state, u64a offset,
                   struct hs_scratch *scratch, const char is_streaming) {
    assert(t);
    assert(scratch->core_info.buf || scratch->core_info.hbuf);
    assert(!scratch->core_info.buf || !scratch->core_info.hbuf);
    assert(!can_stop_matching(scratch));

    // Fire the special EOD event literal.
    if (t->hasEodEventLiteral) {
        DEBUG_PRINTF("firing eod event id %u at offset %llu\n",
                     t->eodLiteralId, offset);
        const struct core_info *ci = &scratch->core_info;
        size_t len = ci->buf ? ci->len : ci->hlen;
        assert(len || !ci->buf); /* len may be 0 if no history is required
                                  * (bounds checks only can lead to this) */

        roseRunEvent(len, t->eodLiteralId, &scratch->tctxt);
        if (can_stop_matching(scratch)) {
            DEBUG_PRINTF("user told us to stop\n");
            return;
        }
    }

    roseCheckNfaEod(t, state, scratch, offset, is_streaming);

    if (!t->eodIterOffset && !t->ematcherOffset) {
        DEBUG_PRINTF("no eod accepts\n");
        return;
    }

    // Handle pending EOD reports.
    int itrv = roseEodRunIterator(t, state, offset, scratch);
    if (itrv == MO_HALT_MATCHING) {
        return;
    }

    // Run the EOD anchored matcher if there is one.
    if (t->ematcherOffset) {
        assert(t->ematcherRegionSize);
        // Unset the reports we just fired so we don't fire them again below.
        mmbit_clear(getRoleState(state), t->rolesWithStateCount);
        mmbit_clear(getActiveLeafArray(t, state), t->activeArrayCount);
        sidecar_enabled_populate(t, scratch, state);

        hwlmcb_rv_t rv = roseEodRunMatcher(t, offset, scratch, is_streaming);
        if (rv == HWLM_TERMINATE_MATCHING) {
            return;
        }

        cleanupAfterEodMatcher(t, state, offset, scratch);

        // Fire any new EOD reports.
        roseEodRunIterator(t, state, offset, scratch);

        roseCheckEodSuffixes(t, state, offset, scratch);
    }
}