ROPE Language Reference - "expect_str"

"expect_str" checks that specified string(s) are found at the current offset ($offset) in the IP packet buffer being inspected and advances the offset if a match is found. If no match is found, it flags a mismatch as if the "no" action was invoked.

For example:

"/rope/index.html" $u put
expect_str( "GET " $u " HTTP/1.1" )

This script stores the name of a web page URL in the user register $u, and then verifies that the packet contains the string "GET " followed by the contents of $u followed by " HTTP/1.1". If all three strings are found in the specified order at the current offset ($offset) then the offset is advanced to the end of the found strings. If the packet does not match the strings then the script is terminated with a "no" status.

If the AnchorBrackets syntax is used (as in the example), then expect_str checks all the specified strings, in the order in which they are specified. Without AnchorBrackets, it just checks the one string on the top of the stack against the packet contents.

Note: expecti_str does the same thing, but ignores the case of any letters during the comparison.

See Also