Forum Discussion
serge_faller_83
Altostratus
Jun 29, 2005How to read a data in the UDP payload ?
I would like to use an UDP payload information (not header) to target a specific node. I need to read and handle this data (6 octets).
IP message example : Field "01007d" (radius).
81 66 07 14 00 85 8d a9 01 01 00 7d 26 fc f1 f2 ...
UDP/ 81 66 07 14 00 85 8d a9 /endUDP
radius/ 01 "01 00 7d" 26 fc f1 f2 ...
How can I select this data ? (set info [UDP::payload] xxx] ?)
Does anybody have an example ?
Thanks for help.
- unRuleY_95363Historic F5 AccountThis should help get you there:
when RULE_INIT { set ::radius_signature [binary format c3 {1 0 0x7d}] } when CLIENT_DATA { if { [UDP::payload length] > 4 } { binary scan [UDP::payload] x1c3 radius_stuff if { $radius_stuff == $::radius_signature } { node a.b.c.d 123 } } }
- serge_faller_83
Altostratus
Thanks for the irule and your reactivity ! - unRuleY_95363Historic F5 AccountYes, your assumptions are correct. "UDP::collect 50" collects the first 50 octets of the payload (not including the IP/UDP headers).
binary scan [UDP::payload] x2I1 Radius_Length
- unRuleY_95363Historic F5 AccountWoops. I just re-read your post and it looks like radius length is really only two bytes so you'll want to use "S" instead:
binary scan [UDP::payload] x2S1 Radius_Length
- serge_faller_83
Altostratus
thanks for the answers, - drteeth_127330Historic F5 AccountUDP::collect is undefined. Since UDP does not guarantee ordering, collecting doesn't make much sense. Use UDP::payload instead. I'm not sure I completely understand your second issue, but you can use the binary format command to convert the binary data to a hex string.
- unRuleY_95363Historic F5 AccountWhat you are seeing is merely the ascii equivalent of your binary data (as I assume you might have logged it). Follow Dr.Teeth's suggestion of using binary format if you would actually like to see the values in HEX. Probably something like:
log "Packet rcvd: [binary format h* [UDP::payload]]"
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