ltm rule command UDP payload
iRule(1) BIG-IP TMSH Manual iRule(1)
UDP::payload
Returns the content or length of the current UDP payload.
SYNOPSIS
UDP::payload (LENGTH | (OFFSET LENGTH))?
UDP::payload length
UDP::payload replace OFFSET LENGTH UDP_PAYLOAD
DESCRIPTION
Returns the content or length of the current UDP payload. Notice that, unlike TCP, there is no need to trigger a collect,
and there is no corresponding release. Moreover, this command is valid not only in CLIENT_DATA and SERVER_DATA, but may be
invoked within CLIENT_ACCEPTED. In that case, it will evaluate to the data contained in the segment that triggered the
CLIENT_ACCEPTED event - though not necessarily every segment in a UDP stream (see CLIENT_ACCEPTED event description for
more details).
Syntax
UDP::payload [] []
* Returns the content of the current UDP payload. If is
specified, and more than bytes are available, only the first
bytes of collected data are returned.
UDP::payload replace
* Replaces bytes of the collected payload data starting at
with the given .
UDP::payload length
* Returns the length, in bytes, of the current UDP payload.
RETURN VALUE
VALID DURING
CLIENT_ACCEPTED, CLIENT_CLOSED, CLIENT_DATA, SERVER_CLOSED, SERVER_CONNECTED, SERVER_DATA, STREAM_MATCHED
EXAMPLES
when CLIENT_DATA {
# empty payload entirely so there is no packet to send to the server
UDP::payload replace 0 [UDP::payload length] ""
# craft a string to hold our packet data, 0x01 0x00 0x00 0x00 0x02 0x00 0x000x00 0x03 0x00 0x00 0x00
set packetdata [binary format i1i1i1 1 2 3 ]
# then fill payload with our own data from arbitrary length string called packetdata to send to the server
# this actually inserts it at the start of the packet, but because we emptiedthe packet above it becomes the new packet
UDP::payload replace 0 0 $packetdata
# Unlike TCP, UDP has no "collect" or "release"
}
In at least BIG-IP 9.3.0 you can't use UDP::payload replace 0 0
$packetdata after emptying the payload entirely
A workaround is to insert your data at the start of the packet, then
empty the old data from the end
when CLIENT_DATA {
# remember how big the incoming packet was
set oldlength [UDP::payload length]
# craft a string to hold our packet data, 0x01 0x00 0x00 0x00 0x02 0x00 0x000x00 0x03 0x00 0x00 0x00
set packetdata [binary format i1i1i1 1 2 3 ]
# then fill payload with our own data from arbitrary length string called packetdata to send to the server
# this actually inserts it at the start of the packet, but because we emptiedthe packet above it becomes the new packet
UDP::payload replace 0 0 $packetdata
# now empty the old packet off the end
UDP::payload replace [string length $packetdata] [expr [UDP::payload length] - [string length $packetdata]] ""
}
HINTS
SEE ALSO
CHANGE LOG
@BIGIP-9.0.0 --First introduced the command.
BIG-IP 2022-04-12 iRule(1)