Documentation ¶
Overview ¶
Package tlv implements Type-Length-Value (TLV) encoding in Named Data Networking (NDN).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrIncomplete = errors.New("incomplete input") ErrTail = errors.New("junk after end of TLV") ErrType = errors.New("TLV-TYPE out of range") ErrCritical = errors.New("unrecognized critical TLV-TYPE") )
Simple error conditions.
Functions ¶
func Decode ¶
func Decode(wire []byte, u Unmarshaler) error
Decode unmarshals a buffer that contains a single TLV.
Types ¶
type Decoder ¶
type Decoder []byte
Decoder recognizes TLV elements.
func (*Decoder) Element ¶
func (d *Decoder) Element() (de DecoderElement, e error)
Element recognizes one TLV element from start of input.
func (*Decoder) Elements ¶
func (d *Decoder) Elements() (list []DecoderElement)
Elements recognizes TLV elements from start of input. Bytes that cannot be recognized as TLV elements are left in the decoder.
func (Decoder) ErrUnlessEOF ¶
ErrUnlessEOF returns an error if there is unconsumed input.
type DecoderElement ¶
DecoderElement represents an TLV element during decoding.
func (DecoderElement) IsCriticalType ¶
func (de DecoderElement) IsCriticalType() bool
IsCriticalType returns true if the TLV-TYPE is considered critical for evolvability purpose.
func (DecoderElement) Unmarshal ¶
func (de DecoderElement) Unmarshal(u Unmarshaler) error
Unmarshal unmarshals TLV into a value.
func (DecoderElement) UnmarshalNNI ¶
func (de DecoderElement) UnmarshalNNI(ptr interface{}) error
UnmarshalNNI unmarshals TLV-VALUE as NNI, written to a pointer of integer type.
func (DecoderElement) UnmarshalValue ¶
func (de DecoderElement) UnmarshalValue(u encoding.BinaryUnmarshaler) error
UnmarshalValue unmarshals TLV-VALUE into a value.
func (DecoderElement) WireAfter ¶
func (de DecoderElement) WireAfter() []byte
WireAfter returns Wire+After.
type Element ¶
type Element struct { // Type is the TLV-TYPE. Type uint32 // Value is the TLV-VALUE. Value []byte }
Element represents a TLV element. The zero Element is invalid.
func MakeElement ¶
MakeElement constructs Element from TLV-TYPE and TLV-VALUE. typ can be any integer type.
func MakeElementNNI ¶
MakeElementNNI creates Element from TLV-TYPE and TLV-VALUE encoding as NNI.
func (Element) MarshalTlv ¶
MarshalTlv implements Marshaler interface.
type Marshaler ¶
Marshaler is the interface implemented by an object that can encode itself into an TLV element.
type NNI ¶
type NNI uint64
NNI is a non-negative integer.
func (NNI) MarshalBinary ¶
MarshalBinary encodes this number.
func (*NNI) UnmarshalBinary ¶
UnmarshalBinary decodes this number.
type Unmarshaler ¶
Unmarshaler is the interface implemented by an object that can decode an TLV element representation of itself.