Forum Discussion
Matthew_Gamble_
Nimbostratus
Mar 12, 2009TFTP Server?
Is it possible to write a simple TFTP server as an iRule to return static content? I see some examples for load balancing TFTP requests, but not for actually acting as a TFTP server. I have a very s...
James_Quinby_46
Mar 13, 2009Historic F5 Account
OK, stuck again. I can't test it because I can't get it to parse right in the IRE. I'm missing something dumb here, but am going cross-eyed trying to find it. I'll post what I have and come back to it later after I clear my head.
(updated with some comments and a little visual cleanup)
when CLIENT_ACCEPTED {
log local0. "Client connected from [IP::client_addr]"
binary scan [UDP::payload] xc opcode
log local0. "Opcode is $opcode"
if { $opcode == 1 } {
binary scan [UDP::payload] xxa* string
log local0. "String is $string"
set stringlist [split $string \000]
set file [lindex $stringlist 0]
set mode [lindex $stringlist 1]
log local0. "File is $file, Mode is $mode"
if { $mode != "octet" && $mode != "netascii" } {
reject
} else {
log local0. "Send the file!"
set block_id 1
set block_start 0
set block_len 512
set last 0
while { $last < 1 } {
log local0. "Block number $block_id"
set data [binary format xcSa* 3 $block_id [string range $::tftp_file $block_start $block_end]]
test for the last block - is it less than 512 bytes? If so, set a flag
if { [string length [string range $::tftp_file $block_start $block_end]] < 512 } then {
set last 1
}
log local0. "data = $data"
send the data
UDP::respond $data
increment block_id and shift the pointers to the
next block of data to send
incr block_id
block_start = block_len
set block_len = block_len + 512
}
We should be breaking out of the while loop now
The last block should have been sent.
}
}
} else { reject }
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
