Documentation ¶
Index ¶
- Constants
- Variables
- func BytesReader() valueReader
- func ChildrenReader() valueReader
- func IsValue(v interface{}) bool
- func NewDecoder(r io.Reader) encoding.Decoder
- func NewEncoder(w io.Writer) encoding.Encoder
- func ReadNumber(r io.Reader) (uint64, int64, error)
- func ReadUint(r io.Reader) (uint64, int64, error)
- func ReadValue(r io.Reader, t uint64) (interface{}, int64, error)
- func UintReader() valueReader
- func WriteNumber(w io.Writer, num uint64) (int64, error)
- func WriteUint(w io.Writer, v uint64) (n int64, err error)
- type ByteTLV
- type BytesValue
- type ChildrenValue
- type Decoder
- type Encoder
- type GenericTLV
- type Marshaler
- type ParentTLV
- type TLV
- type UintTLV
- type UintValue
- type UnsupportedTypeError
- type Value
Constants ¶
const ( // Packet Types InterestType uint64 = 0x05 DataType uint64 = 0x06 // Common Fields NameType uint64 = 0x07 NameComponentType uint64 = 0x08 ImplicitSha256DigestComponentType uint64 = 0x01 // Interest Packet SelectorsType uint64 = 0x09 NonceType uint64 = 0x0A ScopeType uint64 = 0x0B InterestLifetimeType uint64 = 0x0C // Interest/Selectors MinSuffixComponentsType uint64 = 0x0D MaxSuffixComponentsType uint64 = 0x0E PublisherPublicKeyLocatorType uint64 = 0x0F ExcludeType uint64 = 0x10 ChildSelectorType uint64 = 0x11 MustBeFreshType uint64 = 0x12 AnyType uint64 = 0x13 // Data Packet MetaInfoType uint64 = 0x14 ContentType uint64 = 0x15 SignatureInfoType uint64 = 0x16 SignatureValueType uint64 = 0x17 // Data/MetaInfo ContentTypeType uint64 = 0x18 FreshnessPeriodType uint64 = 0x19 FinalBlockIdType uint64 = 0x1A // Data/Signature SignatureTypeType uint64 = 0x1B KeyLocatorType uint64 = 0x1C KeyDigestType uint64 = 0x1D )
Variables ¶
var Any = tlv(AnyType, empty)
Any ::= ANY-TYPE TLV-LENGTH(=0)
var Byte = parserFunc(func(input []byte) (interface{}, []byte, error) { if len(input) <= 0 { return nil, input, io.ErrUnexpectedEOF } return input[0], input[1:], nil })
var Bytes bytesParserType = func(n int) parser {
return bytesWithLengthParser(n)
}
var ChildSelector = tlv(ChildSelectorType, nonNegativeInteger)
ChildSelector ::= CHILD-SELECTOR-TYPE TLV-LENGTH
nonNegativeInteger
var Content = tlv(ContentType, Bytes)
Content ::= CONTENT-TYPE TLV-LENGTH BYTE*
var ContentTypeParser = tlv(ContentTypeType, nonNegativeInteger)
ContentType ::= CONTENT-TYPE-TYPE TLV-LENGTH
nonNegativeInteger
Data ::= DATA-TLV TLV-LENGTH
Name MetaInfo Content Signature
var DigestSha256SignatureInfo = tlv(SignatureInfoType, tlv(SignatureTypeType, exactly(0)), )
SignatureInfo ::= SIGNATURE-INFO-TYPE TLV-LENGTH(=3)
SIGNATURE-TYPE-TYPE TLV-LENGTH(=1) 0
var DigestSha256SignatureValue = tlv(SignatureValueType, Bytes(32), )
SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH(=32)
BYTE+(=SHA256{Name, MetaInfo, Content, SignatureInfo})
var ErrUnexpectexUintTLVLengthValue = errors.New("Unexpected UintTLV length value")
var Exclude = tlv(ExcludeType, maybe(Any), oneOrMore(NameComponent, maybe(Any)))
Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
var FinalBlockID = tlv(FinalBlockIdType, NameComponent)
FinalBlockId ::= FINAL-BLOCK-ID-TLV TLV-LENGTH
NameComponent
var FreshnessPeriod = tlv(FreshnessPeriodType, nonNegativeInteger)
FreshnessPeriod ::= FRESHNESS-PERIOD-TLV TLV-LENGTH
nonNegativeInteger
var GenericNameComponent = tlv(NameComponentType, Bytes)
GenericNameComponent ::= NAME-COMPONENT-TYPE TLV-LENGTH BYTE*
var ImplicitSha256DigestComponent = tlv(ImplicitSha256DigestComponentType, Bytes(32))
ImplicitSha256DigestComponent ::= IMPLICIT-SHA256-DIGEST-COMPONENT-TYPE TLV-LENGTH(=32)
BYTE{32}
var Interest = tlv(InterestType, Name, maybe(Selectors), Nonce, maybe(Scope), maybe(InterestLifetime), )
Interest ::= INTEREST-TYPE TLV-LENGTH
Name Selectors? Nonce Scope? InterestLifetime?
var InterestLifetime = tlv(InterestLifetimeType, nonNegativeInteger)
InterestLifetime ::= INTEREST-LIFETIME-TYPE TLV-LENGTH nonNegativeInteger
var KeyDigest = tlv(KeyDigestType, Bytes)
KeyDigest ::= KEY-DIGEST-TYPE TLV-LENGTH BYTE+
var KeyLocator = tlv(KeyLocatorType, or(Name, KeyDigest))
KeyLocator ::= KEY-LOCATOR-TYPE TLV-LENGTH (Name | KeyDigest)
var MaxSuffixComponents = tlv(MaxSuffixComponentsType, nonNegativeInteger)
MaxSuffixComponents ::= MAX-SUFFIX-COMPONENTS-TYPE TLV-LENGTH
nonNegativeInteger
var MetaInfo = tlv(MetaInfoType, maybe(ContentTypeParser), maybe(FreshnessPeriod), maybe(FinalBlockID), )
MetaInfo ::= META-INFO-TYPE TLV-LENGTH
ContentType? FreshnessPeriod? FinalBlockId?
var MinSuffixComponents = tlv(MinSuffixComponentsType, nonNegativeInteger)
MinSuffixComponents ::= MIN-SUFFIX-COMPONENTS-TYPE TLV-LENGTH
nonNegativeInteger
var MustBeFresh = tlv(MustBeFreshType, empty)
MustBeFresh ::= MUST-BE-FRESH-TYPE TLV-LENGTH(=0)
var Name = tlv(NameType, zeroOrMore(NameComponent))
Name ::= NAME-TYPE TLV-LENGTH NameComponent*
var NameComponent = or(GenericNameComponent, ImplicitSha256DigestComponent)
NameComponent ::= GenericNameComponent | ImplicitSha256DigestComponent
var Nonce = tlv(NonceType, Bytes(4))
Nonce ::= NONCE-TYPE TLV-LENGTH(=4) BYTE{4}
var PublisherPublicKeyLocator = KeyLocator
PublisherPublicKeyLocator ::= KeyLocator
var Scope = tlv(ScopeType, nonNegativeInteger)
Scope ::= SCOPE-TYPE TLV-LENGTH nonNegativeInteger
var Selectors = tlv(SelectorsType, maybe(MinSuffixComponents), maybe(MaxSuffixComponents), maybe(PublisherPublicKeyLocator), maybe(Exclude), maybe(ChildSelector), maybe(MustBeFresh), )
Selectors ::= SELECTORS-TYPE TLV-LENGTH
MinSuffixComponents? MaxSuffixComponents? PublisherPublicKeyLocator? Exclude? ChildSelector? MustBeFresh?
var Signature = or( seq(DigestSha256SignatureInfo, DigestSha256SignatureValue), seq(SignatureSha256WithRsaInfo, SignatureSha256WithRsaValue), seq(SignatureSha256WithEcdsaInfo, SignatureSha256WithEcdsaValue), )
SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH
... (SignatureType-specific TLVs and BYTE+
var SignatureSha256WithEcdsaInfo = tlv(SignatureInfoType, tlv(SignatureTypeType, exactly(3)), KeyLocator, )
SignatureInfo ::= SIGNATURE-INFO-TYPE TLV-LENGTH
SIGNATURE-TYPE-TYPE TLV-LENGTH(=1) 3 KeyLocator
var SignatureSha256WithEcdsaValue = tlv(SignatureValueType, Bytes, )
SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH
BYTE+(=ECDSA over SHA256{Name, MetaInfo, Content, SignatureInfo})
var SignatureSha256WithRsaInfo = tlv(SignatureInfoType, tlv(SignatureTypeType, exactly(1)), KeyLocator, )
SignatureInfo ::= SIGNATURE-INFO-TYPE TLV-LENGTH
SIGNATURE-TYPE-TYPE TLV-LENGTH(=1) 1 KeyLocator
var SignatureSha256WithRsaValue = tlv(SignatureValueType, Bytes, )
SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH
BYTE+(=RSA over SHA256{Name, MetaInfo, Content, SignatureInfo})
var SignatureType = tlv(SignatureTypeType, nonNegativeInteger)
SignatureType ::= SIGNATURE-TYPE-TYPE TLV-LENGTH
nonNegativeInteger
Functions ¶
func BytesReader ¶
func BytesReader() valueReader
func ChildrenReader ¶
func ChildrenReader() valueReader
func IsValue ¶
func IsValue(v interface{}) bool
IsValue reports whether v is a valid Value parameter type.
func UintReader ¶
func UintReader() valueReader
Types ¶
type ByteTLV ¶
func (ByteTLV) MarshalBinary ¶
type BytesValue ¶
type BytesValue []TLV
type ChildrenValue ¶
type ChildrenValue []TLV
type GenericTLV ¶
type GenericTLV struct { T uint64 V interface{} }
func (GenericTLV) Bytes ¶
func (t GenericTLV) Bytes() []byte
func (GenericTLV) Children ¶
func (t GenericTLV) Children() []TLV
func (GenericTLV) MarshalBinary ¶
func (t GenericTLV) MarshalBinary() ([]byte, error)
func (GenericTLV) Type ¶
func (t GenericTLV) Type() uint64
func (GenericTLV) Uint ¶
func (t GenericTLV) Uint() uint64
type ParentTLV ¶
func (ParentTLV) MarshalBinary ¶
type UintTLV ¶
func (UintTLV) MarshalBinary ¶
type UnsupportedTypeError ¶
func (UnsupportedTypeError) Error ¶
func (e UnsupportedTypeError) Error() string