[hyperscan][pkg-config] hyperscan 从0到1路线图
接续前文,继续深入理解:
概述:
1. 自动机理论,是hyperscan的理论基础。
https://zh.wikipedia.org/wiki/%E8%87%AA%E5%8B%95%E6%A9%9F%E7%90%86%E8%AB%96
2. 主要工作流程,分编译期和运行期。
3。与传统正则匹配引擎不同,Hyperscan支持多规则的同步匹配。在用户为每条规则指定独有的编号后,Hypercan可以将所有规则编译成一个数据库并在匹配过程中输出所有当前匹配到的规则信息。
4. No memory allocations occur at runtime with the exception of two fixed-size allocations, these structures can be pre-allocated if required for performance reasons.
编译:
http://intel.github.io/hyperscan/dev-reference/compilation.html#compilation
摘要:
1. 三个编译函数
hs_compile()
hs_compile_multi()
hs_compile_ext_multi()
2. 编译时需要决定三种应用模式:
streaming / block / vectored
有参数mode决定:
One of HS_MODE_STREAM or HS_MODE_BLOCK or HS_MODE_VECTORED must be supplied, to select between the generation of a streaming, block or vectored database.
运行:
http://intel.github.io/hyperscan/dev-reference/runtime.html
摘要:
1. 回调函数可以通过返回一个非0值来终止尚没有完成的scaning
The match callback function has the capability to halt scanning by returning a non-zero value.
2. Hyperscan provides three different scanning modes
Streaming Mode
Block Mode
Vectored Mode
3. 内存预分配
API:
http://intel.github.io/hyperscan/dev-reference/api_files.html
摘要:
block模式下的常用函数:
hs_compile_multi() hs_compile_ext_multi() int(* match_event_handler)() hs_scan() hs_alloc_scratch() hs_free_scratch()