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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -