tftp

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerPort = 33340 // tftp server port
	ClientPort = 33341 // tftp client port
)

Variables

View Source
var ErrShouldWait = fmt.Errorf("target is busy")

ErrShouldWait indicates that the target is busy.

Functions

This section is empty.

Types

type Client

type Client interface {
	Read(ctx context.Context, filename string) (*bytes.Reader, error)
	Write(ctx context.Context, filename string, reader io.ReaderAt, size int64) error
	RemoteAddr() *net.UDPAddr
}

Client is used to Read or Write files to/from a TFTP remote.

type ClientImpl

type ClientImpl struct {
	// contains filtered or unexported fields
}

ClientImpl implements the Client interface; it is exported for testing.

func NewClient

func NewClient(addr *net.UDPAddr, blockSize, windowSize uint16) (*ClientImpl, error)

NewClient returns a Client which can be used to Read or Write files to/from a TFTP remote. A blockSize and windowSize of 0 will use the default values defined in tftp.go.

func (*ClientImpl) Read

func (c *ClientImpl) Read(ctx context.Context, filename string) (*bytes.Reader, error)

Read requests to read a file from the TFTP remote, if the request is successful, the contents of the remote file are returned as a bytes.Reader, if the request is unsuccessful an error is returned, if the error is ErrShouldWait, the request can be retried at some point in the future.

func (*ClientImpl) RemoteAddr

func (c *ClientImpl) RemoteAddr() *net.UDPAddr

func (*ClientImpl) Write

func (c *ClientImpl) Write(ctx context.Context, filename string, r io.ReaderAt, size int64) error

Write requests to send a file to the TFTP remote, if the operation is unsuccesful error is returned, if the error is ErrShouldWait, the request can be retried at some point in the future.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL