wire

package
v0.0.0-...-f4fa09b Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2019 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OpRRQ   uint16 = 1
	OpWRQ          = 2
	OpData         = 3
	OpAck          = 4
	OpError        = 5
)
View Source
const MaxPacketSize = 2048

larger than a typical mtu (1500), and largest DATA packet (516). may limit the length of filenames in RRQ/WRQs -- RFC1350 doesn't offer a bound for these.

Variables

This section is empty.

Functions

This section is empty.

Types

type Packet

type Packet interface {
	// Parse parses a packet from its wire representation
	Parse([]byte) error
	// Serialize serializes a packet to its wire representation
	Serialize() []byte
}

packet is the interface met by all packet structs

func ParsePacket

func ParsePacket(buf []byte) (p Packet, err error)

ParsePacket parses a packet from its wire representation.

type PacketAck

type PacketAck struct {
	BlockNum uint16
}

PacketAck acknowledges receipt of a data packet

func (*PacketAck) Parse

func (p *PacketAck) Parse(buf []byte) (err error)

func (*PacketAck) Serialize

func (p *PacketAck) Serialize() []byte

type PacketData

type PacketData struct {
	BlockNum uint16
	Data     []byte
}

PacketData carries a block of data in a file transmission.

func (*PacketData) Parse

func (p *PacketData) Parse(buf []byte) (err error)

func (*PacketData) Serialize

func (p *PacketData) Serialize() []byte

type PacketError

type PacketError struct {
	Code uint16
	Msg  string
}

PacketError is sent by a peer who has encountered an error condition

func (*PacketError) Parse

func (p *PacketError) Parse(buf []byte) (err error)

func (*PacketError) Serialize

func (p *PacketError) Serialize() []byte

type PacketRequest

type PacketRequest struct {
	Op       uint16 // OpRRQ or OpWRQ
	Filename string
	Mode     string
}

PacketRequest represents a request to read or rite a file.

func (*PacketRequest) Parse

func (p *PacketRequest) Parse(buf []byte) (err error)

func (*PacketRequest) Serialize

func (p *PacketRequest) Serialize() []byte

Jump to

Keyboard shortcuts

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