tftp

package
v0.0.0-...-949ac08 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2014 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RRQ   uint16 = 1
	WRQ   uint16 = 2
	DATA  uint16 = 3
	ACK   uint16 = 4
	ERROR uint16 = 5
	OACK  uint16 = 6

	DEFAULT_BLOCKSIZE = 512

	// modes
	OCTET    = 1
	NETASCII = 2

	// Error codes
	// http://tools.ietf.org/html/rfc1350#page-10
	UNKNOWN_ERROR     uint16 = 0 // Not defined, see error message (if any).
	NOT_FOUND         uint16 = 1 // File not found.
	ACCESS_VIOLATION  uint16 = 2 // Access violation.
	DISK_FULL         uint16 = 3 // Disk full or allocation exceeded.
	ILLEGAL_OPERATION uint16 = 4 // Illegal TFTP operation.
	UNKNOWN_ID        uint16 = 5 // Unknown transfer ID.
	ALREADY_EXISTS    uint16 = 6 // File already exists.
	NO_SUCH_USER      uint16 = 7 // No such user.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	ReadFrom(b []byte) (n int, addr net.Addr, err error)
	Write(p []byte) (n int, err error)
}

type RRQParseError

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

func (*RRQParseError) Error

func (e *RRQParseError) Error() string

type RRQresponse

type RRQresponse struct {
	Request *Request
	// contains filtered or unexported fields
}

func NewRRQresponse

func NewRRQresponse(clientaddr *net.UDPAddr, request *Request, badinternet bool) (*RRQresponse, error)

func (*RRQresponse) End

func (res *RRQresponse) End() (int, error)

func (*RRQresponse) SimulateBadInternet

func (res *RRQresponse) SimulateBadInternet() bool

func (*RRQresponse) Write

func (res *RRQresponse) Write(p []byte) (int, error)

func (*RRQresponse) WriteError

func (res *RRQresponse) WriteError(code uint16, message string) error

func (*RRQresponse) WriteOACK

func (res *RRQresponse) WriteOACK() error

type Request

type Request struct {
	Opcode    uint16
	Blocksize int
	Mode      int
	Path      string
	Addr      *net.Addr
}

func ParseRequest

func ParseRequest(data []byte) (*Request, error)

type Server

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

func NewTFTPServer

func NewTFTPServer(addr *net.UDPAddr) (*Server, error)

func (*Server) Accept

func (server *Server) Accept() (*RRQresponse, error)

Jump to

Keyboard shortcuts

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