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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -