int mpseSearch( void *pvoid, const unsigned char * T, int n, int ( *action )(void* id, void * tree, int index, void *data, void *neg_list), void * data, int* current_state ) { MPSE * p = (MPSE*)pvoid; int ret; PROFILE_VARS; PREPROC_PROFILE_START(mpsePerfStats); p->bcnt += n; if(p->inc_global_counter) s_bcnt += n; switch( p->method ) { case MPSE_AC_BNFA: case MPSE_AC_BNFA_Q: /* return is actually the state */ ret = bnfaSearch((bnfa_struct_t*) p->obj, (unsigned char *)T, n, action, data, 0 /* start-state */, current_state ); PREPROC_PROFILE_END(mpsePerfStats); return ret; case MPSE_AC: ret = acsmSearch( (ACSM_STRUCT*) p->obj, (unsigned char *)T, n, action, data, current_state ); PREPROC_PROFILE_END(mpsePerfStats); return ret; case MPSE_ACF: case MPSE_ACF_Q: case MPSE_ACS: case MPSE_ACB: case MPSE_ACSB: ret = acsmSearch2( (ACSM_STRUCT2*) p->obj, (unsigned char *)T, n, action, data, current_state ); PREPROC_PROFILE_END(mpsePerfStats); return ret; case MPSE_LOWMEM: case MPSE_LOWMEM_Q: ret = KTrieSearch( (KTRIE_STRUCT *)p->obj, (unsigned char *)T, n, action, data); *current_state = 0; PREPROC_PROFILE_END(mpsePerfStats); return ret; #ifdef INTEL_SOFT_CPM case MPSE_INTEL_CPM: ret = IntelPmSearch((IntelPm *)p->obj, (unsigned char *)T, n, action, data); *current_state = 0; PREPROC_PROFILE_END(mpsePerfStats); return ret; #endif default: PREPROC_PROFILE_END(mpsePerfStats); return 1; } }
static uint32_t nvmStringMatchCoproTestPatternGroup (uint16_t group_id, uint8_t *haystack, uint32_t haylen, uint32_t start_offset, nvmStringMatchCoproInternalData *smcdata) { ACSM_STRUCT2 *acsm; //nvmStringMatchCoproMatchResult *r = NULL, *next = NULL; /* Reset match results data */ smcdata -> matches_no = 0; smcdata -> next_match_id = 0; //printf("group_id: %d\n",group_id); //printf("haylen: %d\n",haylen); //printf("haystack: %s\n",haystack+start_offset); /* Do the actual search */ if (group_id < smcdata -> graphs_no) { smdebug ("Matching pattern group %u\n", group_id); acsm = smcdata -> acsm[group_id]; acsmSearch2 (acsm, haystack + start_offset, haylen, nvmStringMatchCoproMatchFoundCallback, smcdata); } else { printf ("String-matching coprocessor: tried to use inexistent graph\n"); } //printf("matches_no: %d\n",smcdata->matches_no); return (smcdata -> matches_no); }