zmodem

package
v0.0.0-...-2589023 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZRQINIT    = 0x00 /* request receive init (s->r) */
	ZRINIT     = 0x01 /* receive init (r->s) */
	ZSINIT     = 0x02 /* send init sequence (optional) (s->r) */
	ZACK       = 0x03 /* ack to ZRQINIT ZRINIT or ZSINIT (s<->r) */
	ZFILE      = 0x04 /* file name (s->r) */
	ZSKIP      = 0x05 /* skip this file (r->s) */
	ZNAK       = 0x06 /* last packet was corrupted (?) */
	ZABORT     = 0x07 /* abort batch transfers (?) */
	ZFIN       = 0x08 /* finish session (s<->r) */
	ZRPOS      = 0x09 /* resume data transmission here (r->s) */
	ZDATA      = 0x0a /* data packet(s) follow (s->r) */
	ZEOF       = 0x0b /* end of file reached (s->r) */
	ZFERR      = 0x0c /* fatal read or write error detected (?) */
	ZCRC       = 0x0d /* request for file CRC and response (?) */
	ZCHALLENGE = 0x0e /* security challenge (r->s) */
	ZCOMPL     = 0x0f /* request is complete (?) */
	ZCAN       = 0x10 /* pseudo frame; other end cancelled session with 5* CAN */
	ZFREECNT   = 0x11 /* request free bytes on file system (s->r) */
	ZCOMMAND   = 0x12 /* issue command (s->r) */
	ZSTDERR    = 0x13 /* output data to stderr (??) */
)

FRAME TYPES

View Source
const (
	ZDLE = 0x18 /* ctrl-x zmodem escape */

	// ZPAD *
	ZPAD = 0x2a /* pad character; begins frames */

	// ZBIN A
	ZBIN = 0x41 /* binary frame indicator (CRC16) */

	// ZHEX B
	ZHEX = 0x42 /* hex frame indicator */

	// ZBIN32 C
	ZBIN32 = 0x43 /* binary frame indicator (CRC32) */

	CAN = 0x18
)
View Source
const (
	ZCRCE = 0x68 /* CRC next, frame ends, header packet follows */
	ZCRCG = 0x69 /* CRC next, frame continues nonstop */
	ZCRCQ = 0x6a /* CRC next, frame continuous, ZACK expected */
	ZCRCW = 0x6b /* CRC next, ZACK expected, end of frame */

	ZRUB0 = 0x6c /* translate to rubout 0x7f */
	ZRUB1 = 0x6d /* translate to rubout 0xff */
)

ZDLE SEQUENCES

View Source
const (
	ZParserStatusNone    = ""
	ZParserStatusSend    = "Send"
	ZParserStatusReceive = "Receive"
)
View Source
const (
	TypeUpload   = "upload"
	TypeDownload = "download"
)
View Source
const (
	TransferStatusStart    = "start"
	TransferStatusFinished = "end"
	TransferStatusAbort    = "abort"
)

Variables

View Source
var (
	HexHeaderPrefix = []byte{ZPAD, ZPAD, ZDLE, ZHEX}

	Binary16HeaderPrefix = []byte{ZPAD, ZDLE, ZBIN}

	Binary32HeaderPrefix = []byte{ZPAD, ZDLE, ZBIN32}

	AbortSession = []byte{CAN, CAN, CAN, CAN, CAN}

	CancelSequence = []byte{CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN,
		0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}
)
View Source
var HexOctetValue = InitHexOctetValue()
View Source
var SkipSequence = []byte{
	0x2a, 0x2a, 0x18, 0x42,
	0x30, 0x35, 0x30, 0x30,
	0x30, 0x30, 0x30, 0x30,
	0x36, 0x33, 0x37, 0x66,
	0x39, 0x32, 0x0d, 0x8a, 0x11,
}

Functions

func ConvertHexToOctets

func ConvertHexToOctets(p []byte) []byte

func InitHexOctetValue

func InitHexOctetValue() map[byte]int

Types

type FrameType

type FrameType byte

func (FrameType) String

func (t FrameType) String() string

type StatusEvent

type StatusEvent string
const (
	StartEvent StatusEvent = "ZMODEM_START"

	EndEvent StatusEvent = "ZMODEM_END"
)

type ZFileInfo

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

func (*ZFileInfo) Filename

func (z *ZFileInfo) Filename() string

func (*ZFileInfo) Time

func (z *ZFileInfo) Time() time.Time

func (*ZFileInfo) Type

func (z *ZFileInfo) Type() string

type ZSession

type ZSession struct {
	Type string

	ZFileHeaderCallback func(zInfo *ZFileInfo)

	AbnormalFinish bool
	// contains filtered or unexported fields
}

func (*ZSession) IsEnd

func (s *ZSession) IsEnd() bool

func (*ZSession) IsNeedSubPacket

func (s *ZSession) IsNeedSubPacket() bool

type ZmodemHeader

type ZmodemHeader struct {
	Type byte
	ZF0  byte
	ZF1  byte
	ZF2  byte
	ZF3  byte
}

func DecodeB16FrameHeader

func DecodeB16FrameHeader(p []byte) (h ZmodemHeader, offset int, ok bool)

func DecodeB32FrameHeader

func DecodeB32FrameHeader(p []byte) (h ZmodemHeader, offset int, ok bool)

func DecodeHexFrameHeader

func DecodeHexFrameHeader(p []byte) (h ZmodemHeader, offset int, ok bool)

func ParseHexHeader

func ParseHexHeader(p []byte) (int, *ZmodemHeader)

func ParseNonZDLEBinary16

func ParseNonZDLEBinary16(p []byte) *ZmodemHeader

type ZmodemParser

type ZmodemParser struct {
	sync.Mutex

	FileEventCallback func(zinfo *ZFileInfo, status bool)

	FireStatusEvent func(event StatusEvent)

	AbnormalFinish bool
	// contains filtered or unexported fields
}

func New

func New() *ZmodemParser

func (*ZmodemParser) Cleanup

func (z *ZmodemParser) Cleanup()

func (*ZmodemParser) GetCurrentZFileInfo

func (z *ZmodemParser) GetCurrentZFileInfo() *ZFileInfo

func (*ZmodemParser) IsStartSession

func (z *ZmodemParser) IsStartSession() bool

func (*ZmodemParser) IsZFilePacket

func (z *ZmodemParser) IsZFilePacket() bool

func (*ZmodemParser) OnHeader

func (z *ZmodemParser) OnHeader(hd *ZmodemHeader)

func (*ZmodemParser) Parse

func (z *ZmodemParser) Parse(p []byte)

func (*ZmodemParser) SessionType

func (z *ZmodemParser) SessionType() string

func (*ZmodemParser) SetAbortMark

func (z *ZmodemParser) SetAbortMark()

func (*ZmodemParser) Status

func (z *ZmodemParser) Status() string

Jump to

Keyboard shortcuts

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