Forum Discussion
matt_wheeler_11
Jul 18, 2007Historic F5 Account
Binary Scan help with an iRule
I am working with a customer where we are trying to grab specific content from a SQL response to create persistence. However, when the rule get to the line where I log line "0004 clientdata: $clientd...
Deb_Allen_18
Jul 20, 2007Historic F5 Account
Yes, citizen_elah is correct, those should have been defined as global vars, my bad, sorry guys:
when RULE_INIT {
log local0. "0001 iRule RealEC-iRule initialized"
Convert Text to HEX before Client_Accepted so we only do this task once.
set ::InsertService "0049006e00730065007200740053006500720076006900630065"
set ::TranOrigID "005400720061006e004f00720069006700490044"
set ::TranRefNum "005400720061006e005200650066004e0075006d"
}
when CLIENT_ACCEPTED {
log local0. "0002 New client connection from [IP::client_addr]:[TCP::client_port]"
TCP::collect
log local0. "0003 Collecting"
}
when CLIENT_DATA {
binary scan [TCP::payload] H128 clientdata
log local0. "0004 clientdata: $clientdata"
Look for InsertService 128 bites into the TCP Payload
set svc_event [findstr $clientdata $::InsertService 52 ]
If we see Insert Service set Persist
if { [string first $::InsertService $clientdata] != -1 } {
Look for TranOrigID, offset 40 (Hex) and stop at "&" (0x26)
set trans_id [findstr $clientdata $::TranOrigID 40 "26"]
Look for TranRefNum, offset 40 (Hex) and stop at "&" (0x26)
set ref_id [findstr $clientdata $::TranRefNum 40 "26"]
Concantenate the two values and persist
set db_id $trans_id:$ref_id
if { $db_id != "" } {
log local0. "0005 DB-ID=$db_id"
persist uie $db_id
log local0. "Persisting $db_id to [persist lookup uie $db_id]"
TCP::release
}
}
}
Global variables are shared across all connections, so anything that's constant for all connections should be defined as a global variable to save memory. Any variable whose value is expected to vary per connection must be defined as a non-global variable.HTH
/deb
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects