tlv

package
v0.0.0-...-d9b08a0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Packet types
	Interest = 0x05
	Data     = 0x06

	// Name and components
	Name                            = 0x07
	ImplicitSha256DigestComponent   = 0x01
	ParametersSha256DigestComponent = 0x02
	GenericNameComponent            = 0x08
	KeywordNameComponent            = 0x20
	SegmentNameComponent            = 0x21
	ByteOffsetNameComponent         = 0x22
	VersionNameComponent            = 0x23
	TimestampNameComponent          = 0x24
	SequenceNumNameComponent        = 0x25

	// Interest packets
	CanBePrefix            = 0x21
	MustBeFresh            = 0x12
	ForwardingHint         = 0x1e
	Nonce                  = 0x0a
	InterestLifetime       = 0x0c
	HopLimit               = 0x22
	ApplicationParameters  = 0x24
	InterestSignatureInfo  = 0x2c
	InterestSignatureValue = 0x2e

	// Data packets
	MetaInfo       = 0x14
	Content        = 0x15
	SignatureInfo  = 0x16
	SignatureValue = 0x17

	// Data/MetaInfo
	ContentType     = 0x18
	FreshnessPeriod = 0x19
	FinalBlockID    = 0x1a

	// Signature
	SignatureType   = 0x1b
	KeyLocator      = 0x1c
	KeyDigest       = 0x1d
	SignatureNonce  = 0x26
	SignatureTime   = 0x28
	SignatureSeqNum = 0x2a

	// Link Object
	Delegation = 0x1f
	Preference = 0x1e

	// Certificates
	ValidityPeriod        = 0xfd
	NotBefore             = 0xfe
	NotAfter              = 0xff
	AdditionalDescription = 0x0102
	DescriptionEntry      = 0x0200
	DescriptionKey        = 0x0201
	DescriptionValue      = 0x0202
)

TLV types for NDN.

View Source
const (
	// Core
	ControlParameters             = 0x68
	FaceID                        = 0x69
	URI                           = 0x72
	LocalURI                      = 0x81
	Origin                        = 0x6F
	Cost                          = 0x6A
	Capacity                      = 0x83
	Count                         = 0x84
	BaseCongestionMarkingInterval = 0x87
	DefaultCongestionThreshold    = 0x88
	MTU                           = 0x89
	Flags                         = 0x6C
	Mask                          = 0x70
	Strategy                      = 0x6B
	ExpirationPeriod              = 0x6D
	ControlResponse               = 0x65
	StatusCode                    = 0x66
	StatusText                    = 0x67

	// ForwarderStatus
	NfdVersion            = 0x80
	StartTimestamp        = 0x81
	CurrentTimestamp      = 0x82
	NNameTreeEntries      = 0x83
	NFibEntries           = 0x84
	NPitEntries           = 0x85
	NMeasurementEntries   = 0x86
	NCsEntries            = 0x87
	NInInterests          = 0x90
	NInData               = 0x91
	NInNacks              = 0x97
	NOutInterests         = 0x92
	NOutData              = 0x93
	NOutNacks             = 0x98
	NSatisfiedInterests   = 0x99
	NUnsatisfiedInterests = 0x9A

	// FaceMgmt
	FaceStatus            = 0x80
	ChannelStatus         = 0x82
	URIScheme             = 0x83
	FaceScope             = 0x84
	FacePersistency       = 0x85
	LinkType              = 0x86
	NInBytes              = 0x94
	NOutBytes             = 0x95
	FaceQueryFilter       = 0x96
	FaceEventNotification = 0xC0
	FaceEventKind         = 0xC1

	// FibMgmt
	FibEntry      = 0x80
	NextHopRecord = 0x81

	// CsMgmt
	CsInfo  = 0x80
	NHits   = 0x81
	NMisses = 0x82

	// StrategyMgmt
	StrategyChoice = 0x80

	// MeasurementStatus
	MeasurementEntry = 0x80
	StrategyInfo     = 0x81

	// RibMgmt
	RibEntry = 0x80
	Route    = 0x81
)

TLV types for Management.

View Source
const MaxNDNPacketSize = 8800

MaxNDNPacketSize is the maximum allowed NDN packet size

Variables

View Source
var (
	ErrBufferTooShort       = errors.New("TLV length exceeds buffer size")
	ErrMissingLength        = errors.New("missing TLV length")
	ErrUnexpected           = errors.New("unexpected TLV type")
	ErrUnrecognizedCritical = errors.New("unrecognized critical TLV type")
)

TLV errors.

Functions

func DecodeNNI

func DecodeNNI(value []byte) (uint64, error)

DecodeNNI decodes a non-negative integer value from a TLV value slice.

func DecodeNNIBlock

func DecodeNNIBlock(wire *Block) (uint64, error)

DecodeNNIBlock decodes a non-negative integer value from a block.

func DecodeTypeLength

func DecodeTypeLength(bytes []byte) (uint32, int, int, error)

DecodeTypeLength decodes the TLV type, TLV length, and total size of the block from a byte slice.

func DecodeVarNum

func DecodeVarNum(in []byte) (uint64, int, error)

DecodeVarNum decodes a non-negative integer value from a wire value.

func EncodeNNI

func EncodeNNI(v uint64) []byte

EncodeNNI encodes a non-negative integer value into a TLV value slice.

func EncodeVarNum

func EncodeVarNum(in uint64) []byte

EncodeVarNum encodes a non-negative integer value for encoding.

func GetNNIBlockSize

func GetNNIBlockSize(t uint32, v uint64) int

GetNNIBlockSize returns the size that a non-negative integer block will take when encoded.

func IsCritical

func IsCritical(tlvType uint32) bool

IsCritical returns whether a TLV type is critical.

Types

type Block

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

Block contains an encoded block.

func DecodeBlock

func DecodeBlock(wire []byte) (*Block, uint64, error)

DecodeBlock decodes a block from the wire.

func EncodeNNIBlock

func EncodeNNIBlock(t uint32, v uint64) *Block

EncodeNNIBlock encodes a non-negative integer value in a block of the specified type.

func NewBlock

func NewBlock(tlvType uint32, value []byte) *Block

NewBlock creates a block containing the specified type and value.

func NewEmptyBlock

func NewEmptyBlock(tlvType uint32) *Block

NewEmptyBlock creates an empty encoded block.

func (*Block) Append

func (b *Block) Append(block *Block)

Append appends a subelement onto the end of the block's value.

func (*Block) Clear

func (b *Block) Clear()

Clear erases all subelements of the block.

func (*Block) DeepCopy

func (b *Block) DeepCopy() *Block

DeepCopy creates a deep copy of the block.

func (*Block) Encode

func (b *Block) Encode() error

Encode encodes all subelements into the block's value.

func (*Block) Erase

func (b *Block) Erase(tlvType uint32) bool

Erase erases the first subelement of the specified type and returns whether an element was removed.

func (*Block) EraseAll

func (b *Block) EraseAll(tlvType uint32) int

EraseAll erases all subelements of the specified type and returns the count of elements removed.

func (*Block) Find

func (b *Block) Find(tlvType uint32) *Block

Find returns the first subelement of the specified type, or nil if none exists.

func (*Block) HasWire

func (b *Block) HasWire() bool

HasWire returns whether the block has a valid wire encoding.

func (*Block) Insert

func (b *Block) Insert(in *Block)

Insert inserts the subelement in order of ascending TLV type, after any subelements of the same TLV type. Note that this assumes subelements are ordered by increasing TLV type.

func (*Block) Parse

func (b *Block) Parse() error

Parse parses the block value into subelements, if possible.

func (*Block) Reset

func (b *Block) Reset()

Reset clears the encoded wire buffer, value, and subelements of the block.

func (*Block) SetType

func (b *Block) SetType(tlvType uint32)

SetType sets the TLV type of the block.

func (*Block) SetValue

func (b *Block) SetValue(value []byte)

SetValue sets the value of the block.

func (*Block) Size

func (b *Block) Size() int

Size returns the size of the wire.

func (*Block) Subelements

func (b *Block) Subelements() []*Block

Subelements returns the sub-elements of the block.

func (*Block) Type

func (b *Block) Type() uint32

Type returns the type of the block.

func (*Block) Value

func (b *Block) Value() []byte

Value returns the value contained in the block.

func (*Block) Wire

func (b *Block) Wire() ([]byte, error)

Wire returns the wire-encoded block.

Jump to

Keyboard shortcuts

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