tftp

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderSize   = 4
	BlockSize    = 512
	DatagramSize = HeaderSize + BlockSize
)

Variables

This section is empty.

Functions

func RemoveNullByte

func RemoveNullByte(name string) string

Types

type Ack

type Ack uint16

func (Ack) MarshalBinary

func (ack Ack) MarshalBinary() ([]byte, error)

func (*Ack) UnmarshalBinary

func (ack *Ack) UnmarshalBinary(p []byte) error

type Data

type Data struct {
	Block   uint16
	Payload io.Reader
}

func (*Data) MarshalBinary

func (d *Data) MarshalBinary() ([]byte, error)

func (*Data) UnmarshalBinary

func (d *Data) UnmarshalBinary(p []byte) error

type Err

type Err struct {
	Error   ErrCode
	Message string
}

func (Err) MarshalBinary

func (e Err) MarshalBinary() ([]byte, error)

func (*Err) UnmarshalBinary

func (e *Err) UnmarshalBinary(p []byte) error

type ErrCode

type ErrCode uint16
const (
	ErrUnknown ErrCode = iota
	ErrNotFound
	ErrAccessViolation
	ErrDiskFull
	ErrIllegalOp
	ErrUnknownID
	ErrFileExists
	ErrNoUser
)

type OpCode

type OpCode uint16
const (
	OpRRQ OpCode = iota + 1

	OpData
	OpAck
	OpErr
)

type ReadReq

type ReadReq struct {
	Filename string
	Mode     string
}

func (ReadReq) MarshalBinary

func (rr ReadReq) MarshalBinary() ([]byte, error)

func (*ReadReq) UnmarshalBinary

func (rr *ReadReq) UnmarshalBinary(p []byte) error

type Server

type Server struct {
	Payload []byte        // Payload served for all read requests
	Retries uint8         // Number of times to retry a failed transmission
	Timeout time.Duration // the duration to wait for an acknowledgement
}

func (Server) ListenAndServe

func (s Server) ListenAndServe(addr string) error

func (*Server) Serve

func (s *Server) Serve(conn net.PacketConn) error

Jump to

Keyboard shortcuts

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