packets

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: AGPL-3.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CommandReadAt           = CommandRequest | byte(1)
	CommandWriteAt          = CommandRequest | byte(2)
	CommandNeedAt           = CommandRequest | byte(3)
	CommandDontNeedAt       = CommandRequest | byte(4)
	CommandDirtyList        = CommandRequest | byte(5)
	CommandDevInfo          = CommandRequest | byte(6)
	CommandEvent            = CommandRequest | byte(7)
	CommandHashes           = CommandRequest | byte(8)
	CommandWriteAtWithMap   = CommandRequest | byte(9)
	CommandRemoveDev        = CommandRequest | byte(10)
	CommandRemoveFromMap    = CommandRequest | byte(11)
	CommandAlternateSources = CommandRequest | byte(12)
)
View Source
const (
	CommandReadAtResponse     = CommandResponse | byte(1)
	CommandReadAtResponseErr  = CommandResponse | byte(2)
	CommandWriteAtResponse    = CommandResponse | byte(3)
	CommandWriteAtResponseErr = CommandResponse | byte(4)
	CommandEventResponse      = CommandResponse | byte(5)
	CommandHashesResponse     = CommandResponse | byte(6)
	CommandDirtyListResponse  = CommandResponse | byte(7)
)
View Source
const CommandRequest = byte(0)
View Source
const CommandResponse = byte(0x80)
View Source
const EventCompleted = EventType(4)
View Source
const EventCustom = EventType(5)
View Source
const EventPostLock = EventType(1)
View Source
const EventPostUnlock = EventType(3)
View Source
const EventPreLock = EventType(0)
View Source
const EventPreUnlock = EventType(2)
View Source
const WriteAtCompRLE = 2
View Source
const WriteAtData = 0
View Source
const WriteAtHash = 1

Variables

View Source
var ErrInvalidPacket = errors.New("invalid packet")
View Source
var ErrReadError = errors.New("remote read error")
View Source
var ErrWriteError = errors.New("remote write error")
View Source
var EventsByType = map[EventType]string{
	EventPreLock:    "PreLock",
	EventPostLock:   "PostLock",
	EventPreUnlock:  "PreUnlock",
	EventPostUnlock: "PostUnlock",
	EventCompleted:  "Completed",
	EventCustom:     "Custom",
}

Functions

func DecodeDirtyList

func DecodeDirtyList(buff []byte) (int, []uint, error)

func DecodeDirtyListResponse added in v0.0.6

func DecodeDirtyListResponse(buff []byte) error

func DecodeDontNeedAt

func DecodeDontNeedAt(buff []byte) (int64, int32, error)

func DecodeEventResponse

func DecodeEventResponse(buff []byte) error

func DecodeHashes

func DecodeHashes(buff []byte) (map[uint][sha256.Size]byte, error)

func DecodeHashesResponse

func DecodeHashesResponse(buff []byte) error

func DecodeNeedAt

func DecodeNeedAt(buff []byte) (int64, int32, error)

func DecodeReadAt

func DecodeReadAt(buff []byte) (int64, int32, error)

func DecodeRemoveDev added in v0.0.6

func DecodeRemoveDev(buff []byte) error

func DecodeRemoveFromMap added in v0.0.6

func DecodeRemoveFromMap(buff []byte) ([]uint64, error)

func DecodeWriteAt

func DecodeWriteAt(buff []byte) (offset int64, data []byte, err error)

func DecodeWriteAtComp

func DecodeWriteAtComp(buff []byte) (offset int64, data []byte, err error)

func DecodeWriteAtHash added in v0.0.10

func DecodeWriteAtHash(buff []byte) (offset int64, length int64, hash []byte, err error)

func DecodeWriteAtWithMap added in v0.0.6

func DecodeWriteAtWithMap(buff []byte) (int64, []byte, map[uint64]uint64, error)

func EncodeAlternateSources added in v0.0.10

func EncodeAlternateSources(sources []AlternateSource) []byte

func EncodeDevInfo

func EncodeDevInfo(di *DevInfo) []byte

func EncodeDirtyList

func EncodeDirtyList(blockSize int, blocks []uint) []byte

func EncodeDirtyListResponse added in v0.0.6

func EncodeDirtyListResponse() []byte

func EncodeDontNeedAt

func EncodeDontNeedAt(offset int64, length int32) []byte

func EncodeEvent

func EncodeEvent(e *Event) []byte

func EncodeEventResponse

func EncodeEventResponse() []byte

func EncodeHashes

func EncodeHashes(hashes map[uint][sha256.Size]byte) []byte

func EncodeHashesResponse

func EncodeHashesResponse() []byte

func EncodeNeedAt

func EncodeNeedAt(offset int64, length int32) []byte

func EncodeReadAt

func EncodeReadAt(offset int64, length int32) []byte

func EncodeReadAtResponse

func EncodeReadAtResponse(rar *ReadAtResponse) []byte

func EncodeRemoveDev added in v0.0.6

func EncodeRemoveDev() []byte

func EncodeRemoveFromMap added in v0.0.6

func EncodeRemoveFromMap(ids []uint64) []byte

func EncodeWriteAt

func EncodeWriteAt(offset int64, data []byte) []byte

func EncodeWriteAtComp

func EncodeWriteAtComp(offset int64, data []byte) []byte

func EncodeWriteAtHash added in v0.0.10

func EncodeWriteAtHash(offset int64, length int64, hash []byte) []byte

func EncodeWriteAtResponse

func EncodeWriteAtResponse(war *WriteAtResponse) []byte

func EncodeWriteAtWithMap added in v0.0.6

func EncodeWriteAtWithMap(offset int64, data []byte, idmap map[uint64]uint64) []byte

func EncodeWriterWriteAt

func EncodeWriterWriteAt(offset int64, data []byte) (uint32, func(w io.Writer) error)

func IsResponse

func IsResponse(cmd byte) bool

Types

type AlternateSource added in v0.0.10

type AlternateSource struct {
	Offset   int64
	Length   int64
	Hash     [sha256.Size]byte
	Location string
}

func DecodeAlternateSources added in v0.0.10

func DecodeAlternateSources(buff []byte) ([]AlternateSource, error)

type DevInfo

type DevInfo struct {
	Size      uint64
	BlockSize uint32
	Name      string
	Schema    string
}

func DecodeDevInfo

func DecodeDevInfo(buff []byte) (*DevInfo, error)

type Event

type Event struct {
	Type          EventType
	CustomType    byte
	CustomPayload []byte
}

func DecodeEvent

func DecodeEvent(buff []byte) (*Event, error)

type EventType

type EventType byte

type ReadAtResponse

type ReadAtResponse struct {
	Bytes int
	Data  []byte
	Error error
}

func DecodeReadAtResponse

func DecodeReadAtResponse(buff []byte) (*ReadAtResponse, error)

type WriteAtResponse

type WriteAtResponse struct {
	Bytes int
	Error error
}

func DecodeWriteAtResponse

func DecodeWriteAtResponse(buff []byte) (*WriteAtResponse, error)

Jump to

Keyboard shortcuts

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