Forum Discussion
Nathan_Pearce_4
May 21, 2010Historic F5 Account
ISO8583 payload interpreter/switch
The previous verion of ISO8583 switch only processed the MTI (Message Type Identifier). This version goes far beyond and dives into the bitmap and payload.
What does it do:
1) It reads and interprets the ISO8583 bitmap
2) It calculate the offset based on the fields present in the message
With these two points we now have access to the message payload allowing one to pick out client identifier or location information (bits 41 & 42) or anything else you want access to. This information can be used for simple logging, routing or anything else you might be after.
The following rule grabs field 63. Being a variable length field, it must retrieve the field length from within the payload before being able to locate the desired field data.
when RULE_INIT {
Build list of Bitmap Attribute Lengths
'var' represents a variable length field
set static::bmAttrLengths [list 64 LL 6 12 12 12 10 8 8 8 6 6 4 4 4 4 4 4 3 3 3 3 3 3 2 2 1 8 8 8 8 LL LL LL LL LLL 12 6 2 3 8 15 40 LL LL LLL LLL LLL 3 3 3 64 16 LLL LLL LLL 12 12 12 LLL LLL LLL LLL 64]
}
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set clientData [TCP::payload]
log local0. "Client Data raw: $clientData"
Collect the bitmap from the payload - it follows the MTI.
binary scan [binary format H* [string range $clientData 6 21]] B* data
Start the offset at 22 for MTA & BitMap padding
set offset 22
set i 0
while { $i < [string length $data]} {
if {[string index $data $i] == 1} {
set attr [lindex $static::bmAttrLengths $i]
if { $attr == "LL" } {
This is a variable length field. The next 2 values in the string tell us how long the field is.
set beginData [expr { $offset + 2 }]
set endData [expr { $beginData + [scan [string range $clientData $offset [expr { $offset + 1 }]] %d ]}]
log local0. "Value for the field length is: [string range $clientData $offset [expr { $offset + 1 }]]"
log local0. "Value for the Field is: [string range $clientData $beginData $endData]"
} elseif { $attr == "LLL" } {
This is a variable length field. The next 3 values in the string tell us how long the field is.
set beginData [expr { $offset + 3 }]
set endData [expr { $beginData + [scan [string range $clientData $offset [expr { $offset + 2 }]] %d ]}]
log local0. "Value for the field length is: [string range $clientData $offset [expr { $offset + 2 }]]"
log local0. "Value for the Field is: [string range $clientData $beginData $endData]"
} else {
We got a 1 in the bitmap - increment the offset.
incr offset [lindex $static::bmAttrLengths $i]
}
}
incr i
}
TCP::release
}
Tester feedback welcom and encourage - I only have access to an ISO8583 emulator written in python.
No RepliesBe the first to reply
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