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, got the enconding figured out (I ripped it straight from the Tcl wiki). Here's the latest version.
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 data [binary format xcSa* 3 1 [string range $::tftp_file 0 511]]
log local0. "data = $data"
UDP::respond $data
}
} else { reject }
}
So - incrementing the block ID (the "1" in the format command above) along with moving to the next 512 bytes is all that's left, modulo the changes citizen_elah has added that improve the protocol handling. This is pretty close. This will hopefully let us avoid having to embed the file into the actual rule.
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
