Forum Discussion

teknet7_237497's avatar
teknet7_237497
Icon for Nimbostratus rankNimbostratus
Dec 12, 2015

irule: if contains with variable

Hello Team,

I do have irule with the following lines:

 binary scan [UDP::payload] @${tmpindex}H${hsize}cc attr_value3 attr_code3 attr_len3
 if { $attr_value3 contains "audit-session-id" } {         

And it looks like that if is never satisfied. I should have a string there which contains "audit_session_id". What am i doing wrong ?

Thanks,

1 Reply

  • Hi Teknet,

     

    $attr_value3 is a string containing hexadecimal digits. So you'll never find the string "audit-session-id" in it.

     

    But you may...

     

    • Check if $attr_value3 contains "61756469745f73657373696f6e5f6964" (aka. hexadecimal representation of "audit_session_id")
    • Check if [binary format H* $attr_value3] contains "audit_session_id"
    • Change the binary scan format to "@${tmpindex}A${hsize}cc" and then check if $attr_value3 contains "audit_session_id"

    Cheers, Kai