Documentation ¶
Overview ¶
Package ndn implements named-data networking.
Index ¶
- Constants
- Variables
- func EncodeCertificate(key Key, w io.Writer) error
- func EncodePrivateKey(key Key, w io.Writer) error
- func NewCRC32C() hash.Hash
- func SendControl(w Sender, module, command string, params *Parameters, key Key) error
- func SignData(key Key, d *Data) (err error)
- func VerifyData(key Key, d *Data) error
- type Cache
- type Command
- type CommandResponse
- type Data
- type ECDSAKey
- type Exclude
- type FIBEntry
- type Face
- type FaceStatus
- type FinalBlockID
- type ForwarderStatus
- type HMACKey
- type Interest
- type Interval
- type Key
- type KeyLocator
- type MetaInfo
- type Name
- type NextHopRecord
- type Parameters
- type RIBEntry
- type RSAKey
- type Route
- type Selectors
- type Sender
- type SignatureInfo
- type Strategy
- type StrategyChoice
- type ValidityPeriod
Constants ¶
const ( CompressionTypeNone uint64 = 0 CompressionTypeGZIP = 1 )
CompressionType specifies compression algorithm for data packets.
const ( CacheControlPublic uint64 = 0 CacheControlNoStore = 1 CacheControlPrivate = 2 )
CacheControl specifies caching strategy for data packets.
const ( EncryptionTypeNone uint64 = 0 EncryptionTypeAESWithCTR = 1 )
EncryptionType specifies encryption algorithm for data packets.
const ( SignatureTypeDigestSHA256 uint64 = 0 SignatureTypeSHA256WithRSA = 1 SignatureTypeDigestCRC32C = 2 SignatureTypeSHA256WithECDSA = 3 SignatureTypeSHA256WithHMAC = 4 )
SignatureType specifies signing algorithm for data packets.
const (
ISO8601 = "20060102T150405"
)
ISO8601 is the time format for ValidityPeriod.
Variables ¶
var ( ErrNotSupported = errors.New("feature not supported") ErrInvalidSignature = errors.New("invalid signature") ErrInvalidPEM = errors.New("invalid pem") )
Errors introduced by Key.
var ( ErrTimeout = errors.New("timeout") ErrResponseStatus = errors.New("bad command response status") )
Errors introduced by communicating with forwarder.
Functions ¶
func EncodeCertificate ¶
EncodeCertificate invokes CertificateToData and encodes this data packet in base64 encoding.
See DecodeCertificate.
func EncodePrivateKey ¶
EncodePrivateKey encodes the private key in PEM encoding.
See DecodePrivateKey.
func SendControl ¶
func SendControl(w Sender, module, command string, params *Parameters, key Key) error
SendControl sends command and waits for its response.
ErrResponseStatus is returned if the status code is not 200.
func VerifyData ¶
VerifyData verifies a data packet with the given key.
It also checks ValidityPeriod.
Types ¶
type Command ¶
type Command struct { Local string `tlv:"8"` NFD string `tlv:"8"` Module string `tlv:"8"` Command string `tlv:"8"` Parameters parametersComponent `tlv:"8"` Timestamp uint64 `tlv:"8"` Nonce uint64 `tlv:"8"` SignatureInfo signatureInfoComponent `tlv:"8"` SignatureValue signatureValueComponent `tlv:"8*"` }
Command alters forwarder state.
See http://redmine.named-data.net/projects/nfd/wiki/Management.
type CommandResponse ¶
type CommandResponse struct { StatusCode uint64 `tlv:"102"` StatusText string `tlv:"103"` Parameters Parameters `tlv:"104?"` }
CommandResponse contains status code and text.
StatusCode generally follows HTTP convention [RFC2616].
type Data ¶
type Data struct { Name Name `tlv:"7"` MetaInfo MetaInfo `tlv:"20"` Content []byte `tlv:"21"` SignatureInfo SignatureInfo `tlv:"22"` SignatureValue []byte `tlv:"23*"` }
Data represents some arbitrary binary data (held in the Content element) together with its Name, some additional bits of information (MetaInfo), and a digital Signature of the other three elements.
func CertificateToData ¶
CertificateToData creates a data packet from a self-signed public key.
See CertificateFromData.
type ECDSAKey ¶
type ECDSAKey struct { Name *ecdsa.PrivateKey }
ECDSAKey implements Key.
func (*ECDSAKey) SignatureType ¶
SignatureType returns signature type generated from the key.
type Exclude ¶
type Exclude []Interval
Exclude allows requester to specify list and/or ranges of names components that MUST NOT appear as a continuation of the Name prefix in the responding Data packet to the Interest.
See http://named-data.net/doc/ndn-tlv/interest.html#exclude.
func (Exclude) MarshalBinary ¶
MarshalBinary encodes Exclude in tlv.
Exclude is a special case in tlv package. It needs to implement encoding.BinaryMarshaler to marshal itself into a binary form.
func (*Exclude) UnmarshalBinary ¶
UnmarshalBinary decodes Exclude tlv-encoded data.
Exclude is a special case in tlv package. It needs to implement encoding.BinaryUnmarshaler to unmarshal a binary representation of itself.
type FIBEntry ¶
type FIBEntry struct { Name Name `tlv:"7"` NextHop []NextHopRecord `tlv:"129"` }
FIBEntry is not available in go-nfd.
type FaceStatus ¶
type FaceStatus struct { FaceID uint64 `tlv:"105"` URI string `tlv:"114"` LocalURI string `tlv:"129"` ExpirationPeriod uint64 `tlv:"109?"` Scope uint64 `tlv:"132"` Persistency uint64 `tlv:"133"` LinkType uint64 `tlv:"134"` Flags uint64 `tlv:"108"` InInterest uint64 `tlv:"144"` InData uint64 `tlv:"145"` InNack uint64 `tlv:"151"` OutInterest uint64 `tlv:"146"` OutData uint64 `tlv:"147"` OutNack uint64 `tlv:"152"` InByte uint64 `tlv:"148"` OutByte uint64 `tlv:"149"` }
FaceStatus is not available in go-nfd.
type FinalBlockID ¶
FinalBlockID indicates the identifier of the final block in a sequence of fragments. It should be present in the final block itself, and may also be present in other fragments to provide advanced warning of the end to consumers. The value here should be equal to the last explicit Name Component of the final block.
type ForwarderStatus ¶
type ForwarderStatus struct { NFDVersion string `tlv:"128"` StartTimestamp uint64 `tlv:"129"` CurrentTimestamp uint64 `tlv:"130"` NameTreeEntry uint64 `tlv:"131"` FIBEntry uint64 `tlv:"132"` PITEntry uint64 `tlv:"133"` MeasurementEntry uint64 `tlv:"134"` CSEntry uint64 `tlv:"135"` InInterest uint64 `tlv:"144"` InData uint64 `tlv:"145"` InNack uint64 `tlv:"151"` OutInterest uint64 `tlv:"146"` OutData uint64 `tlv:"147"` OutNack uint64 `tlv:"152"` }
ForwarderStatus is not available in go-nfd.
type HMACKey ¶
HMACKey implements Key.
func (*HMACKey) SignatureType ¶
SignatureType returns signature type generated from the key.
type Interest ¶
type Interest struct { Name Name `tlv:"7"` Selectors Selectors `tlv:"9?"` Nonce uint64 `tlv:"10"` LifeTime uint64 `tlv:"12?"` }
Interest carries a name that identifies the desired data.
type Interval ¶
Interval is part of an Exclude list.
If none of the Any components are specified, the filter excludes only to the names specified in the Exclude list.
If a leading Any component is specified, then the filter excludes all names that are smaller or equal (in NDN name component canonical ordering) to the first NameComponent in the Exclude list.
If a trailing Any component is specified, then the filter excludes all names that are larger or equal (in NDN name component canonical ordering) to the last NameComponent in the Exclude list.
If Any component is specified between two NameComponents in the list, then the filter excludes all names from the range from the right NameComponent to the left NameComponent, including both ends.
type Key ¶
type Key interface { Locator() Name SignatureType() uint64 // If the key is symmetric, Private is identical to Public. Private() ([]byte, error) Public() ([]byte, error) Sign(interface{}) ([]byte, error) Verify(interface{}, []byte) error }
Key signs and verifies data packets.
func CertificateFromData ¶
CertificateFromData creates a public key from a data packet.
See CertificateToData.
func DecodeCertificate ¶
DecodeCertificate decodes a data packet in base64 encoding, and invokes CertificateFromData.
See EncodeCertificate.
type KeyLocator ¶
KeyLocator specifies either Name that points to another Data packet containing certificate or public key or KeyDigest to identify the public key within a specific trust model.
type MetaInfo ¶
type MetaInfo struct { ContentType uint64 `tlv:"24?"` FreshnessPeriod uint64 `tlv:"25?"` FinalBlockID FinalBlockID `tlv:"26?"` CompressionType uint64 `tlv:"128?"` EncryptionType uint64 `tlv:"129?"` EncryptionKeyLocator KeyLocator `tlv:"130?"` EncryptionIV []byte `tlv:"131?"` CacheControl uint64 `tlv:"132?"` }
MetaInfo contains information about the data packet itself.
type Name ¶
type Name struct { Components []lpm.Component `tlv:"8"` ImplicitDigestSHA256 lpm.Component `tlv:"1?"` }
Name is a hierarchical name for NDN content, which contains a sequence of name components.
func (*Name) Compare ¶
Compare compares two names according to http://named-data.net/doc/ndn-tlv/name.html#canonical-order.
-1 if a < b; 0 if a == b; 1 if a > b
type NextHopRecord ¶
NextHopRecord is not available in go-nfd.
type Parameters ¶
type Parameters struct { Name Name `tlv:"7?"` FaceID uint64 `tlv:"105?"` URI string `tlv:"114?"` Origin uint64 `tlv:"111?"` Cost uint64 `tlv:"106?"` Flags uint64 `tlv:"108?"` Mask uint64 `tlv:"112?"` Strategy Strategy `tlv:"107?"` ExpirationPeriod uint64 `tlv:"109?"` FacePersistency uint64 `tlv:"133?"` }
Parameters contains arguments to command.
type RSAKey ¶
type RSAKey struct { Name *rsa.PrivateKey }
RSAKey implements Key.
func (*RSAKey) SignatureType ¶
SignatureType returns signature type generated from the key.
type Route ¶
type Route struct { FaceID uint64 `tlv:"105"` Origin uint64 `tlv:"111"` Cost uint64 `tlv:"106"` Flags uint64 `tlv:"108"` ExpirationPeriod uint64 `tlv:"109?"` }
Route contains information about a route.
type Selectors ¶
type Selectors struct { MinComponents uint64 `tlv:"133?"` MaxComponents uint64 `tlv:"134?"` PublisherPublicKeyLocator KeyLocator `tlv:"15?"` Exclude Exclude `tlv:"16?"` ChildSelector uint64 `tlv:"17?"` MustBeFresh bool `tlv:"18?"` }
Selectors are optional elements that further qualify Data that may match the Interest. They are used for discovering and selecting the Data that matches best to what the application wants.
type Sender ¶
Sender sends interest and data packets. This is the minimum abstraction for NDN nodes.
type SignatureInfo ¶
type SignatureInfo struct { SignatureType uint64 `tlv:"27"` KeyLocator KeyLocator `tlv:"28?"` ValidityPeriod ValidityPeriod `tlv:"253?"` }
SignatureInfo is included in signature calculation and fully describes the signature, signature algorithm, and any other relevant information to obtain parent certificate(s), such as KeyLocator.
type Strategy ¶
type Strategy struct {
Name Name `tlv:"7"`
}
Strategy is a forwarding strategy for a namespace.
type StrategyChoice ¶
StrategyChoice is not available in go-nfd.
type ValidityPeriod ¶
ValidityPeriod specifies a range when the signature is valid.