Documentation
¶
Overview ¶
Pages 131 - 132 Listing 6-9: Server type implementation.
Pages 120-121 Listing 6-1: Types and codes used by the TFTP server.
Index ¶
Constants ¶
const ( // TFTP limits datagram packets to 516 bytes or fewer to avoid // fragmentation. // We define two constant size. // The maximum block si ze is the datagram size minus a 4-byte header. DatagramSize = 516 // the maximum supported datagram size BlockSize = DatagramSize - 4 // the DatagramSize minus a 4-byte header )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ack ¶
type Ack uint16 // Acknowledgement packet represented by a 16-bit, unsigned integer.
Pages 128 - 129 Listing 6-6: Acknowledgement type implementation.
func (Ack) MarshalBinary ¶
func (*Ack) UnmarshalBinary ¶
type Data ¶
Page 126 Listing 6-4: Date type and its binary marshaling method. Data struct keeps track of the current block number and the data source.
func (*Data) MarshalBinary ¶
MarshalBinary will return 516 bytes per call at most by relying on the io.CopyN function and the BlockSize constant.
func (*Data) UnmarshalBinary ¶
Page 127 Listing 6-5: Data type implementation.
type Err ¶
Page 129 - 130 Listing 6-7: Error type used for conveying errors between the client and server.
func (Err) MarshalBinary ¶
func (*Err) UnmarshalBinary ¶
Page 130 Listing 6-8: Error type's binary unmarshaler implementation.
type ErrCode ¶
type ErrCode uint16
We define a series of unsigned 16-bit integer error codes per the RFC. Although we don't use all error codes in our server since it only allows downloads, a client could return these error codes in lieu of an acknowledgement packet.
type OpCode ¶
type OpCode uint16
The first two bytes of a TFTP packet's header is an operation code. Each operation code is a 2-byte, unsigned integer.
type ReadReq ¶
The struct representing the read request needs to keep track of the filename and the mode.
func (ReadReq) MarshalBinary ¶
Although not used by our server, a client would make use of this method.
func (*ReadReq) UnmarshalBinary ¶
Pages 123-124 Listing 6-3: Read request type implementation. This rounds out the read request's implementation by defining a method that allows the server to unmarshal a read request from a byte slice, typically read from a network connection with a client.