亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bnfa_search.c

?? 著名的入侵檢測系統snort的最新版本的源碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
/*** bnfa_search.c   **** Basic multi-pattern search engine using Aho-Corasick NFA construction.**** Version 3.0  (based on acsmx.c and acsmx2.c)**** author: marc norton** date:   started 12/21/05**** Copyright(C) 2005-2007 Sourcefire, Inc.** ** General Design**   Aho-Corasick based NFA state machine. **   Compacted sparse storage mode for better performance.**   Up to 16 Million states + transitions (combined) in compacted sparse mode.****   ** Compacted sparse array storage **  ****   The primary data is held in one array.**   The patterns themselves are stored separately.**   The matching lists of patterns for each state are stored separately as well.**   The compacted sparse format improves caching/performance.****     word 1 : state  ( only low 24 bits are used )**     word 2 : control word = cb << 24 | fs**		cb: control byte **			cb = mb | fb | nt**          mb : 8th bit - if set state has matching patterns bit**		    fb : 7th bit - if set full storage array bit (256 entries used), else sparse**		    nt : 0-63= number of transitions (more than 63 requires full storage)**		fs: 24 bits for failure state transition index.**	   word 3+ : transition word =  input<<24 |  next-state-index**		input				: 8 bit character, input to state machine from search text**		next-state-index	: 24 bits for index of next state**		(if we reallly need  16M states, we can add a state->index lookup array)**	  ...repeat for each state ...****    * if a state is empty it has words 1 and 2, but no transition words.**    **   Construction:****   Patterns are added to a list based trie.**   The list based trie is compiled into a list based NFA with failure states.**   The list based NFA is converted to full or sparse format NFA. **   The Zero'th state sparse transitions may be stored in full format for performance.**   Sparse transition arrays are searched using linear and binary search strategies**   depending on the number of entries to search through in each state.**   The state machine in sparse mode is compacted into a single vector for *    better performance.**   ** Notes:**   **   The NFA can require twice the state transitions that a DFA uses. However,** the construction of a DFA generates many additional transitions in each** state which consumes significant additional memory. This particular ** implementation is best suited to environments where the very large memory ** requirements of a full state table implementation is not possible and/or ** the speed trade off is warranted to maintain a small memory footprint.**** Each state of an NFA usually has very few transitions but can have up to 256.** It is important to not degenerate into a linear search so we utilize a binary** search if there are more than 5 elements in the state to test for a match.** This allows us to use a simple sparse memory design with an acceptable worst case** search scenario.  The binary search over 256 elements is limtied to a max of** 8 tests.  The zero'th state may use a full 256 state array, so a quick index lookup** provides the next state transition.  The zero'th state is generally visited much** more than other states.**** Compiling : gcc, Intel C/C++, Microsoft C/C++, each optimize differently. My studies** have shown Intel C/C++ 9,8,7 to be the fastest, Microsoft 8,7,6 is next fastest,** and gcc 4.x,3.x,2.x is the slowest of the three.  My testing has been mainly on x86.** In general gcc does a poor job with optimizing this state machine for performance, ** compared to other less cache and prefetch sensitive algorithms.  I've documented** this behavior in a paper 'Optimizing Pattern Matching for IDS' (www.sourcefire.com,** www.idsresearch.org).**** The code is sensitive to cache optimization and prefetching, as well as instruction ** pipelining.  Aren't we all.  To this end, the number of patterns, length of search text,** and cpu cache L1,L2,L3 all affect performance. The relative performance of the sparse** and full format NFA and DFA varies as you vary the pattern charactersitics,and search** text length, but strong performance trends are present and stable.******  BNFA API SUMMARY****  bnfa=bnfaNew();				create a state machine**  bnfaAddPattern(bnfa,..);	add a pattern to the state machine**  bnfaCompile (bnfa,..)		compile the state machine**  bnfaPrintInfo(bnfa);		print memory usage and state info**  bnfaPrint(bnfa);			print the state machine in total **  state=bnfaSearch(bnfa, ...,state);	search a data buffer for a pattern match**  bnfaFree (bnfa);			free the bnfa****** Reference - Efficient String matching: An Aid to Bibliographic Search**             Alfred V Aho and Margaret J Corasick**             Bell Labratories **             Copyright(C) 1975 Association for Computing Machinery,Inc**** 12/4/06 - man - modified summary** 6/26/07 - man - Added last_match tracking, and accounted for nocase/case by**                 preseting the last match state, and reverting if we fail the **                 case memcmp test for any rule in the states matching rule list.**                 The states in the defaul matcher represent either case or nocase**                 states, so they are dual mode, that makes this a bit tricky.**                 When we sue the pure exact match, or pure don't care matching **                 routines, we just track the last state, and never need to revert.**                 This only tracks the single repeated states and repeated data. ****** LICENSE (GPL)**** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License Version 2 as** published by the Free Software Foundation.  You may not use, modify or** distribute this program under any other version of the GNU General** Public License.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.***/  #include <signal.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>  #include "bnfa_search.h"#include "util.h"/* * Used to initialize last state, states are limited to 0-16M * so this will not conflict. */#define LAST_STATE_INIT  0xffffffff#define printf LogMessage/** Case Translation Table - his guarantees we use * indexed lookups for case conversion*/ static unsigned char xlatcase[BNFA_MAX_ALPHABET_SIZE];staticvoid init_xlatcase(void) {  int i;  static int first=1;  if( !first ) 	  return;  for(i=0; i<BNFA_MAX_ALPHABET_SIZE; i++)  {      xlatcase[i] = (unsigned char)toupper(i);  }  first=0;}/** Custom memory allocator*/ staticvoid * bnfa_alloc( int n, int * m ){   void * p = calloc(1,n);   if( p )   {     if(m)	 {		 m[0] += n;	 }   }   return p;}staticvoid bnfa_free( void *p, int n, int * m ){   if( p )   {	   free(p);	   if(m)	   {	      m[0] -= n;	   }   }}#define BNFA_MALLOC(n,memory) bnfa_alloc(n,&(memory))#define BNFA_FREE(p,n,memory) bnfa_free(p,n,&(memory))/* queue memory traker */static int queue_memory=0;/**    simple queue node*/ typedef struct _qnode{   unsigned state;   struct _qnode *next; }QNODE;/**    simple fifo queue structure*/ typedef struct _queue{  QNODE * head, *tail;  int count;  int maxcnt;}QUEUE;/**   Initialize the fifo queue*/ staticvoid queue_init (QUEUE * s) {  s->head = s->tail = 0;  s->count= 0;  s->maxcnt=0;}/**  Add items to tail of queue (fifo)*/ staticint queue_add (QUEUE * s, int state) {  QNODE * q;  if (!s->head)  {      q = s->tail = s->head = (QNODE *) BNFA_MALLOC (sizeof(QNODE),queue_memory);      if(!q) return -1;      q->state = state;      q->next = 0;  }  else  {      q = (QNODE *) BNFA_MALLOC (sizeof(QNODE),queue_memory);      q->state = state;      q->next = 0;      s->tail->next = q;      s->tail = q;  }  s->count++;    if( s->count > s->maxcnt )	  s->maxcnt = s->count;  return 0;}/**  Remove items from head of queue (fifo)*/ static int queue_remove (QUEUE * s) {  int state = 0;  QNODE * q;  if (s->head)  {      q       = s->head;      state   = q->state;      s->head = s->head->next;      s->count--;      if( !s->head )      {	    s->tail = 0;	    s->count = 0;      }      BNFA_FREE (q,sizeof(QNODE),queue_memory);  }  return state;}/**   Return count of items in the queue*/ static int queue_count (QUEUE * s) {  return s->count;}/**  Free the queue*/ staticvoid queue_free (QUEUE * s) {  while (queue_count (s))    {      queue_remove (s);    }}/**  Get next state from transition list*/static int _bnfa_list_get_next_state( bnfa_struct_t * bnfa, int state, int input ){  if ( state == 0 ) /* Full set of states  always */  {       bnfa_state_t * p = (bnfa_state_t*)bnfa->bnfaTransTable[0];       if(!p) 	   {		   return 0;	   }       return p[input];  }  else  {    bnfa_trans_node_t * t = bnfa->bnfaTransTable[state];    while( t )    {      if( t->key == (unsigned)input )      {        return t->next_state;      }      t=t->next;    }    return BNFA_FAIL_STATE; /* Fail state */  }}/**  Put next state - head insertion, and transition updates*/static int _bnfa_list_put_next_state( bnfa_struct_t * bnfa, int state, int input, int next_state ){  if( state >= bnfa->bnfaMaxStates )  {	  return -1;  }  if( input >= bnfa->bnfaAlphabetSize )  {	  return -1;  }  if( state == 0 )  {    bnfa_state_t * p;     p = (bnfa_state_t*)bnfa->bnfaTransTable[0];    if( !p )    {       p = (bnfa_state_t*)BNFA_MALLOC(sizeof(bnfa_state_t)*bnfa->bnfaAlphabetSize,bnfa->list_memory);       if( !p ) 	   {		   return -1; 	   }       bnfa->bnfaTransTable[0] = (bnfa_trans_node_t*)p;    }    if( p[input] )    {        p[input] =  next_state;        return 0;    }    p[input] =  next_state;  }  else  {    bnfa_trans_node_t * p;    bnfa_trans_node_t * tnew;    /* Check if the transition already exists, if so just update the next_state */    p = bnfa->bnfaTransTable[state];    while( p )    {      if( p->key == (unsigned)input )  /* transition already exists- reset the next state */      {          p->next_state = next_state;          return 0;       }      p=p->next;    }    /* Definitely not an existing transition - add it */    tnew = (bnfa_trans_node_t*)BNFA_MALLOC(sizeof(bnfa_trans_node_t),bnfa->list_memory);    if( !tnew )	{	  return -1; 	}    tnew->key        = input;    tnew->next_state = next_state;    tnew->next       = bnfa->bnfaTransTable[state];    bnfa->bnfaTransTable[state] = tnew;   }  bnfa->bnfaNumTrans++;  return 0; }/**   Free the entire transition list table */static int _bnfa_list_free_table( bnfa_struct_t * bnfa ){  int i;  bnfa_trans_node_t * t, *p;  if( !bnfa->bnfaTransTable ) return 0;  if( bnfa->bnfaTransTable[0] )  {      BNFA_FREE(bnfa->bnfaTransTable[0],sizeof(bnfa_state_t)*bnfa->bnfaAlphabetSize,bnfa->list_memory);  }  for(i=1; i<bnfa->bnfaMaxStates; i++)  {       t = bnfa->bnfaTransTable[i];     while( t )     {       p = t;       t = t->next;       BNFA_FREE(p,sizeof(bnfa_trans_node_t),bnfa->list_memory);           }   }   if( bnfa->bnfaTransTable )   {      BNFA_FREE(bnfa->bnfaTransTable,sizeof(bnfa_trans_node_t*)*bnfa->bnfaMaxStates,bnfa->list_memory);      bnfa->bnfaTransTable = 0;   }   return 0;}#ifdef ALLOW_LIST_PRINT/** Print the transition list table to stdout*/static int _bnfa_list_print_table( bnfa_struct_t * bnfa ){  int i;  bnfa_trans_node_t * t;  bnfa_match_node_t * mn;  bnfa_pattern_t * patrn;  if( !bnfa->bnfaTransTable )  {      return 0;  }  printf("Print Transition Table- %d active states\n",bnfa->bnfaNumStates);  for(i=0;i< bnfa->bnfaNumStates;i++)  {       printf("state %3d: ",i);     if( i == 0 )     {		int k;        bnfa_state_t * p = (bnfa_state_t*)bnfa->bnfaTransTable[0];        if(!p) continue;        for(k=0;k<bnfa->bnfaAlphabetSize;k++)        {          if( p[k] == 0 ) continue;          if( isprint(p[k]) )             printf("%3c->%-5d\t",k,p[k]);          else             printf("%3d->%-5d\t",k,p[k]);        }     }     else     {       t = bnfa->bnfaTransTable[i];       while( t )       {          if( isprint(t->key) )           printf("%3c->%-5d\t",t->key,t->next_state);         else           printf("%3d->%-5d\t",t->key,t->next_state);         t = t->next;       }     }     mn =bnfa->bnfaMatchList[i];     while( mn )     {	   patrn =(bnfa_pattern_t *)mn->data;       printf("%.*s ",patrn->n,patrn->casepatrn);       mn = mn->next;     }     printf("\n");   }   return 0;}#endif/** Converts a single row of states from list format to a full format*/ static int _bnfa_list_conv_row_to_full(bnfa_struct_t * bnfa, bnfa_state_t state, bnfa_state_t * full ){    if( (int)state >= bnfa->bnfaMaxStates ) /* protects 'full' against overflow */    {	return -1;    }    if( state == 0 )    {       if( bnfa->bnfaTransTable[0] )          memcpy(full,bnfa->bnfaTransTable[0],sizeof(bnfa_state_t)*bnfa->bnfaAlphabetSize);       else          memset(full,0,sizeof(bnfa_state_t)*bnfa->bnfaAlphabetSize);       return bnfa->bnfaAlphabetSize;    }    else    {       int tcnt = 0;        bnfa_trans_node_t * t = bnfa->bnfaTransTable[ state ];       memset(full,0,sizeof(bnfa_state_t)*bnfa->bnfaAlphabetSize);   

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀久久久久久久| 精品久久久久久久久久久久久久久久久 | 欧美xfplay| 91精品国产综合久久久久久久久久 | 久久久久综合网| 久久美女高清视频| 国产午夜亚洲精品羞羞网站| 在线国产亚洲欧美| 精品视频免费看| 91精品婷婷国产综合久久性色| 7777精品伊人久久久大香线蕉最新版| 欧美伊人久久久久久久久影院 | 制服丝袜一区二区三区| 69堂国产成人免费视频| 欧美狂野另类xxxxoooo| 欧美一区二区日韩| 欧美电视剧免费观看| 久久免费看少妇高潮| 亚洲国产精品二十页| 亚洲色图在线看| 亚洲成人中文在线| 成人ar影院免费观看视频| 成人一区二区三区视频| 一本色道久久综合亚洲91| 欧美日韩高清在线播放| 日韩久久免费av| 欧美激情一区二区三区全黄| 国产精品欧美一区二区三区| 亚洲女人的天堂| 日韩一区精品字幕| 国产精品亚洲视频| 91亚洲精品久久久蜜桃| 欧美挠脚心视频网站| 精品国产91亚洲一区二区三区婷婷| 国产日韩欧美高清| 一区二区日韩av| 久久精品国产色蜜蜜麻豆| 大胆亚洲人体视频| 欧美视频中文一区二区三区在线观看| 911精品产国品一二三产区| 国产日韩欧美高清| 亚洲国产精品一区二区久久| 国内国产精品久久| 色94色欧美sute亚洲线路一ni| 在线综合+亚洲+欧美中文字幕| 26uuu精品一区二区| 亚洲欧美日韩国产综合| 理论电影国产精品| 99久久精品一区| 欧美一区二区三区四区在线观看| 久久久久99精品一区| 亚洲一区二区在线免费看| 精品一区二区免费| 日本韩国精品在线| 日本一区二区三区免费乱视频| 亚洲综合另类小说| 国产成人精品免费视频网站| 欧美三级电影一区| 欧美国产日韩a欧美在线观看| 午夜精品久久久久影视| 丰满白嫩尤物一区二区| 欧美精品国产精品| 中文字幕一区二区在线播放| 久久精品久久99精品久久| 色视频欧美一区二区三区| 精品va天堂亚洲国产| 亚洲国产另类精品专区| av中文字幕不卡| 精品不卡在线视频| 日韩在线一二三区| 91麻豆自制传媒国产之光| 久久美女高清视频| 男女激情视频一区| 欧美午夜影院一区| 国产精品久久久久久久午夜片| 天堂久久一区二区三区| 91麻豆国产在线观看| 国产视频一区二区在线观看| 天堂成人国产精品一区| 色哟哟欧美精品| 中文字幕精品—区二区四季| 国产毛片精品一区| 91精品国产综合久久久蜜臀图片| 夜夜揉揉日日人人青青一国产精品| 国产v综合v亚洲欧| 久久综合资源网| 久久成人久久鬼色| 欧美一区二区三区四区久久| 亚洲永久免费av| 色噜噜狠狠色综合欧洲selulu| 国产精品久久久久久久久图文区| 国产精品一级片在线观看| 精品国产乱码久久久久久牛牛| 图片区日韩欧美亚洲| 欧美日韩久久不卡| 亚洲午夜电影在线| 日韩一区二区高清| 亚洲一区二区三区免费视频| 在线视频综合导航| 一级精品视频在线观看宜春院| 色综合一个色综合| 亚洲你懂的在线视频| 色综合久久久久综合| 一区av在线播放| 欧美午夜电影网| 亚洲国产精品人人做人人爽| 欧美亚洲综合在线| 午夜精品久久久久久不卡8050| 欧美日韩一区不卡| 日韩国产在线一| 欧美一级午夜免费电影| 精品一区二区免费在线观看| 久久久三级国产网站| 丰满少妇在线播放bd日韩电影| 国产精品久久久久久亚洲毛片 | 91麻豆精东视频| 亚洲永久精品国产| 欧美一区二区成人| 韩国精品主播一区二区在线观看| 久久精品在线观看| 成人av网站免费| 一区二区三区欧美久久| 欧美人xxxx| 精品无人码麻豆乱码1区2区 | 中文字幕亚洲一区二区va在线| 97se亚洲国产综合自在线不卡| 亚洲美女免费在线| 欧美日韩国产综合一区二区三区| 免费高清视频精品| 国产日韩欧美激情| 日本韩国欧美在线| 青青草国产成人av片免费| 久久久久久久性| 91网站最新网址| 日韩av中文字幕一区二区| 久久综合九色综合欧美就去吻| 成人精品国产福利| 亚洲国产综合色| 欧美精品一区二区精品网| 99综合电影在线视频| 亚洲chinese男男1069| 精品国产污污免费网站入口| 成人高清视频在线| 日日摸夜夜添夜夜添国产精品 | 亚洲免费观看高清完整版在线观看熊| 欧美三级视频在线| 国产黄色精品网站| 一级中文字幕一区二区| 精品盗摄一区二区三区| 99在线精品观看| 日韩电影一二三区| 国产精品美女久久久久久久| 欧美年轻男男videosbes| 国产伦精品一区二区三区在线观看| 综合分类小说区另类春色亚洲小说欧美| 欧美精品国产精品| 不卡av电影在线播放| 天天影视色香欲综合网老头| 国产日产欧美一区二区三区| 精品视频资源站| 成人性生交大片免费看视频在线| 天天色天天爱天天射综合| 日本一区二区不卡视频| 日韩一级片网站| 在线视频你懂得一区二区三区| 精东粉嫩av免费一区二区三区| 亚洲五月六月丁香激情| 国产精品麻豆久久久| 日韩欧美www| 欧美性淫爽ww久久久久无| 国产99久久精品| 久久国产尿小便嘘嘘尿| 亚洲综合自拍偷拍| 国产精品久久久久久久久快鸭 | 亚洲欧美电影院| 国产精品麻豆一区二区| 精品美女一区二区三区| 欧美精品亚洲一区二区在线播放| 波多野结衣在线一区| 久久97超碰色| 视频一区二区国产| 亚洲自拍偷拍麻豆| 亚洲视频一区二区在线观看| 久久久久久久网| 精品99久久久久久| 欧美一区二区三区男人的天堂| 91福利视频网站| av在线播放成人| 国产不卡视频在线播放| 狠狠色丁香婷综合久久| 日韩av电影免费观看高清完整版| 亚洲精品videosex极品| 综合色中文字幕| 国产精品盗摄一区二区三区| 中文字幕巨乱亚洲| 国产亚洲欧洲997久久综合 | 久久综合网色—综合色88| 欧美精品第1页| 欧美日韩一区二区三区免费看| 色激情天天射综合网|