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: $clientdata" I get the following response in my log file. I was wondering if someone could assist in figuring out where I went wrong. Here is the return in my log file:
Jul 18 13:22:48 tmm tmm[1121]: Rule RecDB-iRule2 : 0002 New client connection from 172.20.5.30:4833
Jul 18 13:22:48 tmm tmm[1121]: Rule RecDB-iRule2 : 0003 Collecting
Jul 18 13:22:48 tmm tmm[1121]: 01220001:3: TCL error: Rule RecDB-iRule2 - can't read "clientdata": no such variable while executing "log local0. "0004 clientdata: $clientdata""
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 &
set trans_id [findstr $clientdata $TranOrigID 40 "26"]
Look for TranRefNum, offset 40 (Hex) and stop at &
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
}
}
}