c - String search in a packet -
assume capture packets c api of libpcap. efficient parse payload strings string search strstr() in line speed (e.g. mbps/gbps)? example strstr(payload,"user-agent");
would more efficient regular expression pattern matching library, such libpcre?
if want http header arguments, there c api? not clear me if libcurl can that... thank in advance.
if searching single short string, nothing faster linear comparison used strstr()
. said, strstr()
's special treatment of nul
bytes not want examining network traffic, , better off writing own implementation treated bytes same , accepted length parameters.
if you're searching multiple strings, you're better off using fast string-matching algorithm aho–corasick or building state machine matches strings want in context want—i.e., parser. parsing mostly-regular grammar http's in c, ragel state machine compiler tool of choice.
Comments
Post a Comment