I'm writing a small TFTP client and server for class, and I have to send TFTP ERROR packets when things go wrong. Here is the TFTP RFC for reference.
So, error code 4 is "Illegal TFTP operation", in which cases would you send that ERROR packet?
For example, if the Server is listening on port 69 for RRQ/WRQ packets, but it instead receives a random DATA packet, should it send an ERROR (error code 4) packet in response?
Anything that does not follow the flow and semantics of the spec is "illegal". A packet with an unknown opcode
, a packet with a malformed payload, or a packet that is out of sequence with the normal flow of commands/responses would all be considered "illegal". So an unexpected DATA
packet for a non-existent transfer could be considered "illegal" and use error code 4, though error code 5 (Unknown Transfer ID) would be more appropriate.