Documentation
¶
Overview ¶
Package bundle provides a library for interaction with Bundles as defined in the Bundle Protocol Version 7 (draft-ietf-dtn-bpbis-26.txt). This includes Bundle creation, modification, serialization and deserialization.
The easiest way to create new Bundles is to use the BundleBuilder.
bndl, err := bundle.Builder(). CRC(bundle.CRC32). Source("dtn://src/"). Destination("dtn://dest/"). CreationTimestampNow(). Lifetime("30m"). HopCountBlock(64). PayloadBlock([]byte("hello world!")). Build()
Both serializing and deserializing bundles into the CBOR is supported.
// An existing Bundle bndl1 is serialized. The new bundle bndl2 is created // from this. A common bytes.Buffer will be used. buff := new(bytes.Buffer) err1 := bndl1.WriteBundle(buff) bndl2, err2 := bundle.ParseBundle(buff)
Index ¶
- Constants
- func IsBundleReassemblable(bs []Bundle) bool
- type AdministrativeRecord
- type AdministrativeRecordManager
- func (arm *AdministrativeRecordManager) IsKnown(typeCode uint64) (known bool)
- func (arm *AdministrativeRecordManager) ReadAdministrativeRecord(r io.Reader) (ar AdministrativeRecord, err error)
- func (arm *AdministrativeRecordManager) Register(ar AdministrativeRecord) (err error)
- func (arm *AdministrativeRecordManager) Unregister(ar AdministrativeRecord)
- func (arm *AdministrativeRecordManager) WriteAdministrativeRecord(ar AdministrativeRecord, w io.Writer) (err error)
- type BlockControlFlags
- type Bundle
- func BuildFromMap(m map[string]interface{}) (bndl Bundle, err error)
- func MustNewBundle(primary PrimaryBlock, canonicals []CanonicalBlock) Bundle
- func NewBundle(primary PrimaryBlock, canonicals []CanonicalBlock) (b Bundle, err error)
- func ParseBundle(r io.Reader) (b Bundle, err error)
- func ReassembleFragments(bs []Bundle) (b Bundle, err error)
- func (b *Bundle) AddExtensionBlock(block CanonicalBlock)
- func (b Bundle) CheckValid() (errs error)
- func (b *Bundle) ExtensionBlock(blockType uint64) (*CanonicalBlock, error)
- func (b Bundle) Fragment(mtu int) (bs []Bundle, err error)
- func (b Bundle) ID() BundleID
- func (b Bundle) IsAdministrativeRecord() bool
- func (b *Bundle) MarshalCbor(w io.Writer) error
- func (b Bundle) MarshalJSON() ([]byte, error)
- func (b *Bundle) PayloadBlock() (*CanonicalBlock, error)
- func (b *Bundle) SetCRCType(crcType CRCType)
- func (b Bundle) String() string
- func (b *Bundle) UnmarshalCbor(r io.Reader) error
- func (b *Bundle) WriteBundle(w io.Writer) error
- type BundleAgeBlock
- func (bab *BundleAgeBlock) Age() uint64
- func (bab *BundleAgeBlock) BlockTypeCode() uint64
- func (bab *BundleAgeBlock) CheckValid() error
- func (bab *BundleAgeBlock) Increment(offset uint64) uint64
- func (bab *BundleAgeBlock) MarshalCbor(w io.Writer) error
- func (bab *BundleAgeBlock) UnmarshalCbor(r io.Reader) error
- type BundleBuilder
- func (bldr *BundleBuilder) Build() (bndl Bundle, err error)
- func (bldr *BundleBuilder) BundleAgeBlock(args ...interface{}) *BundleBuilder
- func (bldr *BundleBuilder) BundleCtrlFlags(bcf BundleControlFlags) *BundleBuilder
- func (bldr *BundleBuilder) CRC(crcType CRCType) *BundleBuilder
- func (bldr *BundleBuilder) Canonical(args ...interface{}) *BundleBuilder
- func (bldr *BundleBuilder) CreationTimestampEpoch() *BundleBuilder
- func (bldr *BundleBuilder) CreationTimestampNow() *BundleBuilder
- func (bldr *BundleBuilder) CreationTimestampTime(t time.Time) *BundleBuilder
- func (bldr *BundleBuilder) Destination(eid interface{}) *BundleBuilder
- func (bldr *BundleBuilder) Error() error
- func (bldr *BundleBuilder) HopCountBlock(args ...interface{}) *BundleBuilder
- func (bldr *BundleBuilder) Lifetime(duration interface{}) *BundleBuilder
- func (bldr *BundleBuilder) PayloadBlock(args ...interface{}) *BundleBuilder
- func (bldr *BundleBuilder) PreviousNodeBlock(args ...interface{}) *BundleBuilder
- func (bldr *BundleBuilder) ReportTo(eid interface{}) *BundleBuilder
- func (bldr *BundleBuilder) Source(eid interface{}) *BundleBuilder
- type BundleControlFlags
- type BundleID
- type BundleStatusItem
- type CRCType
- type CanonicalBlock
- func (cb CanonicalBlock) CheckValid() (errs error)
- func (cb CanonicalBlock) GetCRCType() CRCType
- func (cb CanonicalBlock) HasCRC() bool
- func (cb *CanonicalBlock) MarshalCbor(w io.Writer) error
- func (cb CanonicalBlock) MarshalJSON() ([]byte, error)
- func (cb *CanonicalBlock) SetCRCType(crcType CRCType)
- func (cb CanonicalBlock) String() string
- func (cb CanonicalBlock) TypeCode() uint64
- func (cb *CanonicalBlock) UnmarshalCbor(r io.Reader) error
- type CreationTimestamp
- func (ct CreationTimestamp) DtnTime() DtnTime
- func (ct CreationTimestamp) IsZeroTime() bool
- func (ct *CreationTimestamp) MarshalCbor(w io.Writer) error
- func (ct CreationTimestamp) MarshalJSON() ([]byte, error)
- func (ct CreationTimestamp) SequenceNumber() uint64
- func (ct CreationTimestamp) String() string
- func (ct *CreationTimestamp) UnmarshalCbor(r io.Reader) error
- type DtnEndpoint
- func (e DtnEndpoint) Authority() string
- func (e DtnEndpoint) CheckValid() (err error)
- func (e DtnEndpoint) IsSingleton() bool
- func (e DtnEndpoint) MarshalCbor(w io.Writer) error
- func (e DtnEndpoint) Path() string
- func (_ DtnEndpoint) SchemeName() string
- func (_ DtnEndpoint) SchemeNo() uint64
- func (e DtnEndpoint) String() string
- func (e *DtnEndpoint) UnmarshalCbor(r io.Reader) error
- type DtnTime
- type EndpointID
- func (eid EndpointID) Authority() string
- func (eid EndpointID) CheckValid() error
- func (eid EndpointID) IsSingleton() bool
- func (eid *EndpointID) MarshalCbor(w io.Writer) error
- func (eid EndpointID) Path() string
- func (eid EndpointID) String() string
- func (eid *EndpointID) UnmarshalCbor(r io.Reader) error
- type EndpointType
- type ExtensionBlock
- type ExtensionBlockManager
- func (ebm *ExtensionBlockManager) IsKnown(typeCode uint64) bool
- func (ebm *ExtensionBlockManager) ReadBlock(typeCode uint64, r io.Reader) (b ExtensionBlock, err error)
- func (ebm *ExtensionBlockManager) Register(eb ExtensionBlock) error
- func (ebm *ExtensionBlockManager) Unregister(eb ExtensionBlock)
- func (ebm *ExtensionBlockManager) WriteBlock(b ExtensionBlock, w io.Writer) error
- type GenericExtensionBlock
- type HopCountBlock
- func (hcb *HopCountBlock) BlockTypeCode() uint64
- func (hcb *HopCountBlock) CheckValid() error
- func (hcb *HopCountBlock) Decrement()
- func (hcb *HopCountBlock) Increment() bool
- func (hcb HopCountBlock) IsExceeded() bool
- func (hcb *HopCountBlock) MarshalCbor(w io.Writer) error
- func (hcb *HopCountBlock) UnmarshalCbor(r io.Reader) error
- type IpnEndpoint
- func (e IpnEndpoint) Authority() string
- func (e IpnEndpoint) CheckValid() error
- func (_ IpnEndpoint) IsSingleton() bool
- func (e IpnEndpoint) MarshalCbor(w io.Writer) error
- func (e IpnEndpoint) Path() string
- func (e IpnEndpoint) SchemeName() string
- func (e IpnEndpoint) SchemeNo() uint64
- func (e IpnEndpoint) String() string
- func (e *IpnEndpoint) UnmarshalCbor(r io.Reader) error
- type PayloadBlock
- type PreviousNodeBlock
- type PrimaryBlock
- func (pb PrimaryBlock) CheckValid() (errs error)
- func (pb PrimaryBlock) GetCRCType() CRCType
- func (pb PrimaryBlock) HasCRC() bool
- func (pb PrimaryBlock) HasFragmentation() bool
- func (pb PrimaryBlock) IsLifetimeExceeded() bool
- func (pb *PrimaryBlock) MarshalCbor(w io.Writer) error
- func (pb PrimaryBlock) MarshalJSON() ([]byte, error)
- func (pb *PrimaryBlock) SetCRCType(crcType CRCType)
- func (pb PrimaryBlock) String() string
- func (pb *PrimaryBlock) UnmarshalCbor(r io.Reader) error
- type StatusInformationPos
- type StatusReport
- type StatusReportReason
- type Valid
Constants ¶
const ARTypeStatusReport uint64 = 1
const ExtBlockTypeBundleAgeBlock uint64 = 7
ExtBlockTypeBundleAgeBlock is the block type code for a Bundle Age Block.
const ExtBlockTypeHopCountBlock uint64 = 10
ExtBlockTypeHopCountBlock is the block type code for a Hop Count Block.
const ExtBlockTypePayloadBlock uint64 = 1
ExtBlockTypePayloadBlock is the block type code for a Payload Block.
const ExtBlockTypePreviousNodeBlock uint64 = 6
ExtBlockTypePreviousNodeBlock is the block type code for a Previous Node Block.
Variables ¶
This section is empty.
Functions ¶
func IsBundleReassemblable ¶ added in v0.5.2
IsBundleReassemblable checks if a Bundle can be reassembled from the given fragments. This method might sort the given array as a side effect.
Types ¶
type AdministrativeRecord ¶ added in v0.6.1
type AdministrativeRecord interface { cboring.CborMarshaler // RecordTypeCode returns this AdministrativeRecord's type code. RecordTypeCode() uint64 }
AdministrativeRecord describes an administrative record, e.g., a status report.
func NewAdministrativeRecordFromCbor ¶ added in v0.6.1
func NewAdministrativeRecordFromCbor(data []byte) (ar AdministrativeRecord, err error)
NewAdministrativeRecordFromCbor creates a new AdministrativeRecord from a given byte array. TODO: remove this function; replace by AdministrativeRecordManager
type AdministrativeRecordManager ¶ added in v0.7.0
type AdministrativeRecordManager struct {
// contains filtered or unexported fields
}
AdministrativeRecordManager keeps a book on various types of AdministrativeRecords that can be changed at runtime. Thus, new AdministrativeRecords can be created based on their block type code.
A singleton AdministrativeRecordManager can be fetched by GetAdministrativeRecordManager.
func GetAdministrativeRecordManager ¶ added in v0.7.0
func GetAdministrativeRecordManager() *AdministrativeRecordManager
GetAdministrativeRecordManager returns the singleton AdministrativeRecordManager. If none exists, a new one will be generated with "sane defaults".
func NewAdministrativeRecordManager ¶ added in v0.7.0
func NewAdministrativeRecordManager() *AdministrativeRecordManager
NewAdministrativeRecordManager creates an empty AdministrativeRecordManager. To use a singleton AdministrativeRecordManager one can use GetAdministrativeRecordManager.
func (*AdministrativeRecordManager) IsKnown ¶ added in v0.7.0
func (arm *AdministrativeRecordManager) IsKnown(typeCode uint64) (known bool)
IsKnown returns true if the AdministrativeRecord for this record type code is known.
func (*AdministrativeRecordManager) ReadAdministrativeRecord ¶ added in v0.7.0
func (arm *AdministrativeRecordManager) ReadAdministrativeRecord(r io.Reader) (ar AdministrativeRecord, err error)
ReadAdministrativeRecord from a Reader within its CBOR array and returns the wrapped data type.
func (*AdministrativeRecordManager) Register ¶ added in v0.7.0
func (arm *AdministrativeRecordManager) Register(ar AdministrativeRecord) (err error)
Register a new AdministrativeRecord type through an exemplary instance.
func (*AdministrativeRecordManager) Unregister ¶ added in v0.7.0
func (arm *AdministrativeRecordManager) Unregister(ar AdministrativeRecord)
Unregister an AdministrativeRecord type through an exemplary instance.
func (*AdministrativeRecordManager) WriteAdministrativeRecord ¶ added in v0.7.0
func (arm *AdministrativeRecordManager) WriteAdministrativeRecord(ar AdministrativeRecord, w io.Writer) (err error)
WriteAdministrativeRecord to a Writer wrapped in an CBOR array with both its record type code and its representation.
type BlockControlFlags ¶
type BlockControlFlags uint64
BlockControlFlags is an uint which represents the Block Processing Control Flags as specified in 4.1.4.
const ( // ReplicateBlock requires this block to be replicated in every fragment. ReplicateBlock BlockControlFlags = 0x01 // StatusReportBlock requires transmission of a status report if this block cannot be processed. StatusReportBlock BlockControlFlags = 0x02 // DeleteBundle requires bundle deletion if this block cannot be processed. DeleteBundle BlockControlFlags = 0x04 // RemoveBlock requires the block to be removed from the bundle if it cannot be processed. RemoveBlock BlockControlFlags = 0x10 )
func (BlockControlFlags) CheckValid ¶ added in v0.1.1
func (bcf BlockControlFlags) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (BlockControlFlags) Has ¶
func (bcf BlockControlFlags) Has(flag BlockControlFlags) bool
Has returns true if a given flag or mask of flags is set.
func (BlockControlFlags) MarshalJSON ¶ added in v0.6.0
func (bcf BlockControlFlags) MarshalJSON() ([]byte, error)
MarshalJSON returns a JSON array of control flags.
func (BlockControlFlags) String ¶ added in v0.1.1
func (bcf BlockControlFlags) String() string
func (BlockControlFlags) Strings ¶ added in v0.6.0
func (bcf BlockControlFlags) Strings() (fields []string)
Strings returns an array of all flags as a string representation.
type Bundle ¶
type Bundle struct { PrimaryBlock PrimaryBlock CanonicalBlocks []CanonicalBlock }
Bundle represents a bundle as defined in section 4.2.1. Each Bundle contains one primary block and multiple canonical blocks.
func BuildFromMap ¶ added in v0.6.0
BuildFromMap creates a Bundle from a map which "calls" the BundleBuilder's methods.
This function does not use reflection or other dark magic. So it is safe to be called by unchecked data.
args := map[string]interface{}{ "destination": "dtn://dst/", "source": "dtn://src/", "creation_timestamp_now": true, "lifetime": "24h", "payload_block": "hello world", } b, err := BuildFromMap(args)
func MustNewBundle ¶
func MustNewBundle(primary PrimaryBlock, canonicals []CanonicalBlock) Bundle
MustNewBundle creates a new Bundle like NewBundle, but skips the validity check. No panic will be called!
func NewBundle ¶
func NewBundle(primary PrimaryBlock, canonicals []CanonicalBlock) (b Bundle, err error)
NewBundle creates a new Bundle. The values and flags of the blocks will be checked and an error might be returned.
func ParseBundle ¶ added in v0.1.1
ParseBundle reads a new CBOR encoded Bundle from a Reader.
func ReassembleFragments ¶ added in v0.5.2
ReassembleFragments merges a slice of Bundle fragments into the reassembled Bundle.
func (*Bundle) AddExtensionBlock ¶
func (b *Bundle) AddExtensionBlock(block CanonicalBlock)
AddExtensionBlock adds a new ExtensionBlock to this Bundle. The block number will be calculated and overwritten within this method.
func (Bundle) CheckValid ¶ added in v0.1.1
CheckValid returns an array of errors for incorrect data.
func (*Bundle) ExtensionBlock ¶
func (b *Bundle) ExtensionBlock(blockType uint64) (*CanonicalBlock, error)
ExtensionBlock returns this Bundle's canonical block/extension block matching the requested block type code. If no such block was found, an error will be returned.
func (Bundle) Fragment ¶ added in v0.5.2
Fragment a Bundle into multiple Bundles, with each serialized Bundle limited to mtu bytes.
func (Bundle) IsAdministrativeRecord ¶
IsAdministrativeRecord returns if this Bundle's control flags indicate this has an administrative record payload.
func (*Bundle) MarshalCbor ¶ added in v0.1.1
MarshalCbor writes this Bundle's CBOR representation.
func (Bundle) MarshalJSON ¶ added in v0.6.0
MarshalJSON creates a JSON object for this Bundle.
func (*Bundle) PayloadBlock ¶
func (b *Bundle) PayloadBlock() (*CanonicalBlock, error)
PayloadBlock returns this Bundle's payload block or an error, if it does not exists.
func (*Bundle) SetCRCType ¶
SetCRCType sets the given CRCType for each block. To also calculate and set the CRC value, one should also call the CalculateCRC method.
func (*Bundle) UnmarshalCbor ¶ added in v0.1.1
UnmarshalCbor creates this Bundle based on a CBOR representation.
type BundleAgeBlock ¶
type BundleAgeBlock uint64
BundleAgeBlock implements the Bundle Protocol's Bundle Age Block.
func NewBundleAgeBlock ¶
func NewBundleAgeBlock(ms uint64) *BundleAgeBlock
NewBundleAgeBlock creates a new BundleAgeBlock for the given milliseconds.
func (*BundleAgeBlock) Age ¶ added in v0.1.1
func (bab *BundleAgeBlock) Age() uint64
Age returns the age in milliseconds.
func (*BundleAgeBlock) BlockTypeCode ¶ added in v0.1.1
func (bab *BundleAgeBlock) BlockTypeCode() uint64
BlockTypeCode must return a constant integer, indicating the block type code.
func (*BundleAgeBlock) CheckValid ¶ added in v0.1.1
func (bab *BundleAgeBlock) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (*BundleAgeBlock) Increment ¶ added in v0.1.1
func (bab *BundleAgeBlock) Increment(offset uint64) uint64
Increment with an offset in milliseconds and return the new time.
func (*BundleAgeBlock) MarshalCbor ¶ added in v0.1.1
func (bab *BundleAgeBlock) MarshalCbor(w io.Writer) error
MarshalCbor writes a CBOR representation for a Bundle Age Block.
func (*BundleAgeBlock) UnmarshalCbor ¶ added in v0.1.1
func (bab *BundleAgeBlock) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads the CBOR representation for a Bundle Age Block.
type BundleBuilder ¶
type BundleBuilder struct {
// contains filtered or unexported fields
}
BundleBuilder is a simple framework to create bundles by method chaining.
bndl, err := bundle.Builder(). CRC(bundle.CRC32). Source("dtn://src/"). Destination("dtn://dest/"). CreationTimestampNow(). Lifetime("30m"). HopCountBlock(64). PayloadBlock([]byte("hello world!")). Build()
func (*BundleBuilder) Build ¶
func (bldr *BundleBuilder) Build() (bndl Bundle, err error)
Build creates a new Bundle and returns an optional error.
func (*BundleBuilder) BundleAgeBlock ¶
func (bldr *BundleBuilder) BundleAgeBlock(args ...interface{}) *BundleBuilder
BundleAgeBlock adds a bundle age block to this bundle. The parameters are:
Age[, BlockControlFlags] where Age is the age as an uint in milliseconds, a format string or a time.Duration and BlockControlFlags are _optional_ block processing control flags
func (*BundleBuilder) BundleCtrlFlags ¶
func (bldr *BundleBuilder) BundleCtrlFlags(bcf BundleControlFlags) *BundleBuilder
BundleCtrlFlags sets the bundle processing control flags in the primary block.
func (*BundleBuilder) CRC ¶
func (bldr *BundleBuilder) CRC(crcType CRCType) *BundleBuilder
CRC sets the bundle's CRC value.
func (*BundleBuilder) Canonical ¶
func (bldr *BundleBuilder) Canonical(args ...interface{}) *BundleBuilder
Canonical adds a canonical block to this bundle. The parameters are:
ExtensionBlock[, BlockControlFlags] or CanonicalBlock where ExtensionBlock is a bundle.ExtensionBlock and BlockControlFlags are _optional_ block processing control flags or CanonicalBlock is a CanonicalBlock
func (*BundleBuilder) CreationTimestampEpoch ¶
func (bldr *BundleBuilder) CreationTimestampEpoch() *BundleBuilder
CreationTimestampEpoch sets the bundle's creation timestamp to the epoch time, stored in its primary block.
func (*BundleBuilder) CreationTimestampNow ¶
func (bldr *BundleBuilder) CreationTimestampNow() *BundleBuilder
CreationTimestampNow sets the bundle's creation timestamp to the current time, stored in its primary block.
func (*BundleBuilder) CreationTimestampTime ¶
func (bldr *BundleBuilder) CreationTimestampTime(t time.Time) *BundleBuilder
CreationTimestampTime sets the bundle's creation timestamp to a given time, stored in its primary block.
func (*BundleBuilder) Destination ¶
func (bldr *BundleBuilder) Destination(eid interface{}) *BundleBuilder
Destination sets the bundle's destination, stored in its primary block.
func (*BundleBuilder) Error ¶
func (bldr *BundleBuilder) Error() error
Error returns the BundleBuilder's error, if one is present.
func (*BundleBuilder) HopCountBlock ¶
func (bldr *BundleBuilder) HopCountBlock(args ...interface{}) *BundleBuilder
HopCountBlock adds a hop count block to this bundle. The parameters are:
Limit[, BlockControlFlags] where Limit is the limit of this Hop Count Block and BlockControlFlags are _optional_ block processing control flags
func (*BundleBuilder) Lifetime ¶
func (bldr *BundleBuilder) Lifetime(duration interface{}) *BundleBuilder
Lifetime sets the bundle's lifetime, stored in its primary block. Possible values are an uint/int, representing the lifetime in milliseconds, a format string (compare time.ParseDuration) for the duration or a time.Duration.
Lifetime(1000) // Lifetime of 1000ms Lifetime("1000ms") // Lifetime of 1000ms Lifetime("10m") // Lifetime of 10min Lifetime(10 * time.Minute) // Lifetime of 10min
func (*BundleBuilder) PayloadBlock ¶
func (bldr *BundleBuilder) PayloadBlock(args ...interface{}) *BundleBuilder
PayloadBlock adds a payload block to this bundle. The parameters are:
Data[, BlockControlFlags] where Data is the payload's data and BlockControlFlags are _optional_ block processing control flags
func (*BundleBuilder) PreviousNodeBlock ¶
func (bldr *BundleBuilder) PreviousNodeBlock(args ...interface{}) *BundleBuilder
PreviousNodeBlock adds a previous node block to this bundle. The parameters are:
PrevNode[, BlockControlFlags] where PrevNode is an EndpointID or a string describing an endpoint and BlockControlFlags are _optional_ block processing control flags
func (*BundleBuilder) ReportTo ¶
func (bldr *BundleBuilder) ReportTo(eid interface{}) *BundleBuilder
ReportTo sets the bundle's report-to address, stored in its primary block.
func (*BundleBuilder) Source ¶
func (bldr *BundleBuilder) Source(eid interface{}) *BundleBuilder
Source sets the bundle's source, stored in its primary block.
type BundleControlFlags ¶
type BundleControlFlags uint64
BundleControlFlags is an uint which represents the Bundle Processing Control Flags as specified in section 4.1.3.
const ( // IsFragment indicates this bundle is a fragment. IsFragment BundleControlFlags = 0x000001 // AdministrativeRecordPayload indicates the payload is an administrative record. AdministrativeRecordPayload BundleControlFlags = 0x000002 // MustNotFragmented forbids bundle fragmentation. MustNotFragmented BundleControlFlags = 0x000004 // RequestUserApplicationAck requests an acknowledgement from the application agent. RequestUserApplicationAck BundleControlFlags = 0x000020 // RequestStatusTime requests a status time in all status reports. RequestStatusTime BundleControlFlags = 0x000040 // StatusRequestReception requests a bundle reception status report. StatusRequestReception BundleControlFlags = 0x004000 // StatusRequestForward requests a bundle forwarding status report. StatusRequestForward BundleControlFlags = 0x010000 // StatusRequestDelivery requests a bundle delivery status report. StatusRequestDelivery BundleControlFlags = 0x020000 // StatusRequestDeletion requests a bundle deletion status report. StatusRequestDeletion BundleControlFlags = 0x040000 )
func (BundleControlFlags) CheckValid ¶ added in v0.1.1
func (bcf BundleControlFlags) CheckValid() (errs error)
CheckValid returns an array of errors for incorrect data.
func (BundleControlFlags) Has ¶
func (bcf BundleControlFlags) Has(flag BundleControlFlags) bool
Has returns true if a given flag or mask of flags is set.
func (BundleControlFlags) MarshalJSON ¶ added in v0.6.0
func (bcf BundleControlFlags) MarshalJSON() ([]byte, error)
MarshalJSON creates a JSON array of control flags.
func (BundleControlFlags) String ¶
func (bcf BundleControlFlags) String() string
func (BundleControlFlags) Strings ¶ added in v0.6.0
func (bcf BundleControlFlags) Strings() (fields []string)
Strings returns an array of all flags as a string representation.
type BundleID ¶ added in v0.1.1
type BundleID struct { SourceNode EndpointID Timestamp CreationTimestamp IsFragment bool FragmentOffset uint64 TotalDataLength uint64 }
BundleID identifies a bundle by its source node, creation timestamp and fragmentation offset paired the total data length. The last two fields are only available if and only if the referenced bundle is a fragment.
Furthermore, a BundleID can be serialized and deserialized with the cboring library. Therefore, all required fields will be written in series. For deserialization, the IsFragment field MUST be set beforehand. This will determine if two or four values will be read.
func (BundleID) Len ¶ added in v0.1.1
Len returns the amount of fields, dependent on the fragmentation.
func (*BundleID) MarshalCbor ¶ added in v0.1.1
MarshalCbor writes the Bundle ID's CBOR representation.
type BundleStatusItem ¶ added in v0.6.1
BundleStatusItem represents the a bundle status item, as used as an element in the bundle status information array of each Bundle Status Report.
func NewBundleStatusItem ¶ added in v0.6.1
func NewBundleStatusItem(asserted bool) BundleStatusItem
NewBundleStatusItem returns a new BundleStatusItem, indicating an optional assertion - givenas asserted -, but no status time request.
func NewTimeReportingBundleStatusItem ¶ added in v0.6.1
func NewTimeReportingBundleStatusItem(time DtnTime) BundleStatusItem
NewTimeReportingBundleStatusItem returns a new BundleStatusItem, indicating both a positive assertion and a requested status time report.
func (*BundleStatusItem) MarshalCbor ¶ added in v0.6.1
func (bsi *BundleStatusItem) MarshalCbor(w io.Writer) error
func (BundleStatusItem) String ¶ added in v0.6.1
func (bsi BundleStatusItem) String() string
func (*BundleStatusItem) UnmarshalCbor ¶ added in v0.6.1
func (bsi *BundleStatusItem) UnmarshalCbor(r io.Reader) error
type CRCType ¶
type CRCType uint64
CRCType indicates which CRC type is used. Only the three defined consts CRCNo, CRC16 and CRC32 are valid, as specified in section 4.1.1.
type CanonicalBlock ¶
type CanonicalBlock struct { BlockNumber uint64 BlockControlFlags BlockControlFlags CRCType CRCType CRC []byte Value ExtensionBlock }
CanonicalBlock represents the canonical bundle block defined in section 4.2.3.
func AdministrativeRecordToCbor ¶ added in v0.6.1
func AdministrativeRecordToCbor(ar AdministrativeRecord) (blk CanonicalBlock, err error)
AdministrativeRecordToCbor creates a canonical block, containing this administrative record. The surrounding bundle _must_ have a set AdministrativeRecordPayload bundle processing control flag. TODO: remove this function; replace by AdministrativeRecordManager
func NewCanonicalBlock ¶
func NewCanonicalBlock(no uint64, bcf BlockControlFlags, value ExtensionBlock) CanonicalBlock
NewCanonicalBlock based on its number, some control flags and an Extension Block.
func (CanonicalBlock) CheckValid ¶ added in v0.1.1
func (cb CanonicalBlock) CheckValid() (errs error)
CheckValid returns an array of errors for incorrect data.
func (CanonicalBlock) GetCRCType ¶
func (cb CanonicalBlock) GetCRCType() CRCType
GetCRCType returns the CRCType of this block.
func (CanonicalBlock) HasCRC ¶
func (cb CanonicalBlock) HasCRC() bool
HasCRC returns if the CRCType indicates a CRC is present for this block.
func (*CanonicalBlock) MarshalCbor ¶ added in v0.1.1
func (cb *CanonicalBlock) MarshalCbor(w io.Writer) error
MarshalCbor writes this Canonical Block's CBOR representation.
func (CanonicalBlock) MarshalJSON ¶ added in v0.6.0
func (cb CanonicalBlock) MarshalJSON() ([]byte, error)
MarshalJSON writes a JSON object for this Canonical Block.
func (*CanonicalBlock) SetCRCType ¶
func (cb *CanonicalBlock) SetCRCType(crcType CRCType)
SetCRCType sets the CRC type.
func (CanonicalBlock) String ¶
func (cb CanonicalBlock) String() string
func (CanonicalBlock) TypeCode ¶ added in v0.5.1
func (cb CanonicalBlock) TypeCode() uint64
TypeCode returns the block type code.
func (*CanonicalBlock) UnmarshalCbor ¶ added in v0.1.1
func (cb *CanonicalBlock) UnmarshalCbor(r io.Reader) error
UnmarshalCbor creates this Canonical Block based on a CBOR representation.
type CreationTimestamp ¶
type CreationTimestamp [2]uint64
CreationTimestamp is a tuple of a DtnTime and a sequence number (to differ bundles with the same DtnTime (seconds) from the same endpoint). It is specified in section 4.1.7.
func NewCreationTimestamp ¶
func NewCreationTimestamp(time DtnTime, sequence uint64) CreationTimestamp
NewCreationTimestamp creates a new creation timestamp from a given DTN time and a sequence number, resulting in a hopefully unique tuple.
func (CreationTimestamp) DtnTime ¶
func (ct CreationTimestamp) DtnTime() DtnTime
DtnTime returns the creation timestamp's DTN time part.
func (CreationTimestamp) IsZeroTime ¶ added in v0.2.0
func (ct CreationTimestamp) IsZeroTime() bool
IsZeroTime returns if the time part is set to zero, indicating the lack of an accurate clock.
func (*CreationTimestamp) MarshalCbor ¶ added in v0.1.1
func (ct *CreationTimestamp) MarshalCbor(w io.Writer) error
MarshalCbor writes a CBOR representation for this CreationTimestamp.
func (CreationTimestamp) MarshalJSON ¶ added in v0.6.0
func (ct CreationTimestamp) MarshalJSON() ([]byte, error)
MarshalJSON creates a JSON object representing this CreationTimestamp.
func (CreationTimestamp) SequenceNumber ¶
func (ct CreationTimestamp) SequenceNumber() uint64
SequenceNumber returns the creation timestamp's sequence number.
func (CreationTimestamp) String ¶
func (ct CreationTimestamp) String() string
func (*CreationTimestamp) UnmarshalCbor ¶ added in v0.1.1
func (ct *CreationTimestamp) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads a CBOR representation of a CreationTimestamp.
type DtnEndpoint ¶ added in v0.6.0
DtnEndpoint describes the dtn URI for EndpointIDs, as defined in ietf-dtn-bpbis.
Format of a "normal" dtn URI: "dtn:" "//" NodeName "/" Demux ^------^ 1*VCHAR ^---^ VCHAR Format of the null endpoint: "dtn:none"
func (DtnEndpoint) Authority ¶ added in v0.6.0
func (e DtnEndpoint) Authority() string
Authority is the authority part of the Endpoint URI, e.g., "foo" for "dtn://foo/bar" or "none" for "dtn:none".
func (DtnEndpoint) CheckValid ¶ added in v0.6.0
func (e DtnEndpoint) CheckValid() (err error)
CheckValid returns an error for incorrect data.
func (DtnEndpoint) IsSingleton ¶ added in v0.7.0
func (e DtnEndpoint) IsSingleton() bool
IsSingleton checks if this Endpoint represents a singleton.
- If a "dtn" URI's demux start with "~", this Endpoint is not a singleton. - "dtn:none" cannot be a singleton.
func (DtnEndpoint) MarshalCbor ¶ added in v0.6.0
func (e DtnEndpoint) MarshalCbor(w io.Writer) error
MarshalCbor writes this DtnEndpoint's CBOR representation.
func (DtnEndpoint) Path ¶ added in v0.6.0
func (e DtnEndpoint) Path() string
Path is the path part of the Endpoint URI, e.g., "/bar" for "dtn://foo/bar" or "/" for "dtn:none".
func (DtnEndpoint) SchemeName ¶ added in v0.6.0
func (_ DtnEndpoint) SchemeName() string
SchemeName is "dtn" for DtnEndpoints.
func (DtnEndpoint) SchemeNo ¶ added in v0.6.0
func (_ DtnEndpoint) SchemeNo() uint64
SchemeNo is 1 for DtnEndpoints.
func (DtnEndpoint) String ¶ added in v0.6.0
func (e DtnEndpoint) String() string
func (*DtnEndpoint) UnmarshalCbor ¶ added in v0.6.0
func (e *DtnEndpoint) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads a CBOR representation.
type DtnTime ¶
type DtnTime uint64
DtnTime is an integer representation of milliseconds since the start of the year 2000 (UTC).
const ( // DtnTimeEpoch represents the zero timestamp/epoch. DtnTimeEpoch DtnTime = 0 )
func DtnTimeFromTime ¶
DtnTimeFromTime returns the DtnTime for the time.Time.
type EndpointID ¶
type EndpointID struct {
EndpointType EndpointType
}
EndpointID represents an Endpoint ID as defined in section 4.1.5.1. Its form is specified in an EndpointType, e.g., DtnEndpoint.
func DtnNone ¶
func DtnNone() EndpointID
DtnNone returns a new instance of the null endpoint "dtn:none".
func MustNewEndpointID ¶
func MustNewEndpointID(uri string) EndpointID
MustNewEndpointID based on an URI like NewEndpointID, but panics on an error.
func NewEndpointID ¶
func NewEndpointID(uri string) (e EndpointID, err error)
NewEndpointID based on an URI, e.g., "dtn://seven/".
func (EndpointID) Authority ¶ added in v0.6.0
func (eid EndpointID) Authority() string
Authority is the authority part of the Endpoint URI, e.g., "foo" for "dtn://foo/bar".
func (EndpointID) CheckValid ¶ added in v0.1.1
func (eid EndpointID) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (EndpointID) IsSingleton ¶ added in v0.7.0
func (eid EndpointID) IsSingleton() bool
IsSingleton checks if this Endpoint represents a singleton.
func (*EndpointID) MarshalCbor ¶ added in v0.1.1
func (eid *EndpointID) MarshalCbor(w io.Writer) error
MarshalCbor writes the CBOR representation of this Endpoint ID.
func (EndpointID) Path ¶ added in v0.6.0
func (eid EndpointID) Path() string
Path is the path part of the Endpoint URI, e.g., "/bar" for "dtn://foo/bar".
func (EndpointID) String ¶
func (eid EndpointID) String() string
func (*EndpointID) UnmarshalCbor ¶ added in v0.1.1
func (eid *EndpointID) UnmarshalCbor(r io.Reader) error
UnmarshalCbor creates this Endpoint ID based on a CBOR representation.
type EndpointType ¶ added in v0.6.0
type EndpointType interface { // SchemeName must return the static URI scheme type for this endpoint, e.g., "dtn" or "ipn". SchemeName() string // SchemeNo must return the static URI scheme type number for this endpoint, e.g., 1 for "dtn". SchemeNo() uint64 // Authority is the authority part of the Endpoint URI, e.g., "foo" for "dtn://foo/bar". Authority() string // Path is the path part of the Endpoint URI, e.g., "/bar" for "dtn://foo/bar". Path() string // IsSingleton checks if this Endpoint represents a singleton. IsSingleton() bool // MarshalCbor is the marshalling CBOR function from the cboring library. MarshalCbor(io.Writer) error Valid fmt.Stringer }
EndpointType describes a discrete EndpointID. Because of Go's type system, the MarshalCbor function from the cboring library must be implemented as a value receiver in this interface. In addition, the UnmarshalCbor function MUST be implemented as a pointer receiver. Afaik, this is not possible to describe with a Golang interface..
func NewDtnEndpoint ¶ added in v0.6.0
func NewDtnEndpoint(uri string) (e EndpointType, err error)
NewDtnEndpoint from an URI with the dtn scheme.
func NewIpnEndpoint ¶ added in v0.6.0
func NewIpnEndpoint(uri string) (e EndpointType, err error)
NewIpnEndpoint from an URI with the ipn scheme.
type ExtensionBlock ¶ added in v0.1.1
type ExtensionBlock interface { Valid // BlockTypeCode must return a constant integer, indicating the block type code. BlockTypeCode() uint64 }
ExtensionBlock describes the block-type specific data of any Canonical Block. Such an ExtensionBlock must implement either the cboring.CborMarshaler interface, if its serializable to / from CBOR, or both encoding.BinaryMarshaler and encoding.BinaryUnmarshaler. The latter allows any kind of serialization, e.g., to a totally custom format.
type ExtensionBlockManager ¶ added in v0.1.1
type ExtensionBlockManager struct {
// contains filtered or unexported fields
}
ExtensionBlockManager keeps a book on various types of ExtensionBlocks that can be changed at runtime. Thus, new ExtensionBlocks can be created based on their block type code.
A singleton ExtensionBlockManager can be fetched by GetExtensionBlockManager.
func GetExtensionBlockManager ¶ added in v0.1.1
func GetExtensionBlockManager() *ExtensionBlockManager
GetExtensionBlockManager returns the singleton ExtensionBlockManager. If none exists, a new ExtensionBlockManager will be generated with a knowledge of the PayloadBlock, PreviousNodeBlock, BundleAgeBlock and HopCountBlock.
func NewExtensionBlockManager ¶ added in v0.1.1
func NewExtensionBlockManager() *ExtensionBlockManager
NewExtensionBlockManager creates an empty ExtensionBlockManager. To use a singleton ExtensionBlockManager one can use GetExtensionBlockManager.
func (*ExtensionBlockManager) IsKnown ¶ added in v0.1.1
func (ebm *ExtensionBlockManager) IsKnown(typeCode uint64) bool
IsKnown returns true if the ExtensionBlock for this block type code is known.
func (*ExtensionBlockManager) ReadBlock ¶ added in v0.5.1
func (ebm *ExtensionBlockManager) ReadBlock(typeCode uint64, r io.Reader) (b ExtensionBlock, err error)
ReadBlock reads an ExtensionBlock from its correct binary format from the io.Reader. Unknown block types are treated as GenericExtensionBlock.
func (*ExtensionBlockManager) Register ¶ added in v0.1.1
func (ebm *ExtensionBlockManager) Register(eb ExtensionBlock) error
Register a new ExtensionBlock type through an exemplary instance.
func (*ExtensionBlockManager) Unregister ¶ added in v0.1.1
func (ebm *ExtensionBlockManager) Unregister(eb ExtensionBlock)
Unregister an ExtensionBlock type through an exemplary instance.
func (*ExtensionBlockManager) WriteBlock ¶ added in v0.5.1
func (ebm *ExtensionBlockManager) WriteBlock(b ExtensionBlock, w io.Writer) error
WriteBlock writes an ExtensionBlock in its correct binary format into the io.Writer. Unknown block types are treated as GenericExtensionBlock.
type GenericExtensionBlock ¶ added in v0.5.1
type GenericExtensionBlock struct {
// contains filtered or unexported fields
}
GenericExtensionBlock is a dummy ExtensionBlock to cover for unknown or unregistered ExtensionBlocks.
func NewGenericExtensionBlock ¶ added in v0.5.1
func NewGenericExtensionBlock(data []byte, typeCode uint64) *GenericExtensionBlock
NewGenericExtensionBlock creates a new GenericExtensionBlock from some payload and a block type code.
func (*GenericExtensionBlock) BlockTypeCode ¶ added in v0.5.1
func (geb *GenericExtensionBlock) BlockTypeCode() uint64
BlockTypeCode must return a constant integer, indicating the block type code.
func (*GenericExtensionBlock) CheckValid ¶ added in v0.5.1
func (geb *GenericExtensionBlock) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (*GenericExtensionBlock) MarshalBinary ¶ added in v0.5.1
func (geb *GenericExtensionBlock) MarshalBinary() ([]byte, error)
MarshalBinary writes a binary representation of this block.
func (*GenericExtensionBlock) UnmarshalBinary ¶ added in v0.5.1
func (geb *GenericExtensionBlock) UnmarshalBinary(data []byte) error
UnmarshalBinary reads a binary representation of a generic block.
type HopCountBlock ¶
HopCountBlock implements the Bundle Protocol's Hop Count Block.
func NewHopCountBlock ¶
func NewHopCountBlock(limit uint8) *HopCountBlock
NewHopCountBlock creates a new HopCountBlock with a given hop limit.
func (*HopCountBlock) BlockTypeCode ¶ added in v0.1.1
func (hcb *HopCountBlock) BlockTypeCode() uint64
BlockTypeCode must return a constant integer, indicating the block type code.
func (*HopCountBlock) CheckValid ¶ added in v0.1.1
func (hcb *HopCountBlock) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (*HopCountBlock) Decrement ¶ added in v0.1.1
func (hcb *HopCountBlock) Decrement()
Decrement the hop counter.
func (*HopCountBlock) Increment ¶ added in v0.1.1
func (hcb *HopCountBlock) Increment() bool
Increment the hop counter and returns if the hop limit is exceeded afterwards.
func (HopCountBlock) IsExceeded ¶ added in v0.1.1
func (hcb HopCountBlock) IsExceeded() bool
IsExceeded returns true if the hop limit exceeded.
func (*HopCountBlock) MarshalCbor ¶ added in v0.1.1
func (hcb *HopCountBlock) MarshalCbor(w io.Writer) error
MarshalCbor writes a CBOR representation of this Hop Count Block.
func (*HopCountBlock) UnmarshalCbor ¶ added in v0.1.1
func (hcb *HopCountBlock) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads a CBOR representation of a Hop Count Block.
type IpnEndpoint ¶ added in v0.6.0
IpnEndpoint describes the ipn URI for EndpointIDs, as defined in RFC 6260.
func (IpnEndpoint) Authority ¶ added in v0.6.0
func (e IpnEndpoint) Authority() string
Authority is the authority part of the Endpoint URI, e.g., "23" for "ipn:23.42".
func (IpnEndpoint) CheckValid ¶ added in v0.6.0
func (e IpnEndpoint) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (IpnEndpoint) IsSingleton ¶ added in v0.7.0
func (_ IpnEndpoint) IsSingleton() bool
IsSingleton checks if this Endpoint represents a singleton.
All IPN Endpoints are singletons by definition.
func (IpnEndpoint) MarshalCbor ¶ added in v0.6.0
func (e IpnEndpoint) MarshalCbor(w io.Writer) error
MarshalCbor writes this IpnEndpoint's CBOR representation.
func (IpnEndpoint) Path ¶ added in v0.6.0
func (e IpnEndpoint) Path() string
Path is the path part of the Endpoint URI, e.g., "42" for "ipn:23.42".
func (IpnEndpoint) SchemeName ¶ added in v0.6.0
func (e IpnEndpoint) SchemeName() string
SchemeName is "ipn" for IpnEndpoints.
func (IpnEndpoint) SchemeNo ¶ added in v0.6.0
func (e IpnEndpoint) SchemeNo() uint64
SchemeNo is 2 for IpnEndpoints.
func (IpnEndpoint) String ¶ added in v0.6.0
func (e IpnEndpoint) String() string
func (*IpnEndpoint) UnmarshalCbor ¶ added in v0.6.0
func (e *IpnEndpoint) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads a CBOR representation for an IpnEndpoint.
type PayloadBlock ¶
type PayloadBlock []byte
PayloadBlock implements the Bundle Protocol's Payload Block.
func NewPayloadBlock ¶
func NewPayloadBlock(data []byte) *PayloadBlock
NewPayloadBlock creates a new PayloadBlock with the given payload.
func (*PayloadBlock) BlockTypeCode ¶ added in v0.1.1
func (pb *PayloadBlock) BlockTypeCode() uint64
BlockTypeCode must return a constant integer, indicating the block type code.
func (*PayloadBlock) CheckValid ¶ added in v0.1.1
func (pb *PayloadBlock) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (*PayloadBlock) Data ¶ added in v0.1.1
func (pb *PayloadBlock) Data() []byte
Data returns this PayloadBlock's payload.
func (*PayloadBlock) MarshalBinary ¶ added in v0.5.1
func (pb *PayloadBlock) MarshalBinary() ([]byte, error)
MarshalBinary writes the binary representation of a PayloadBlock.
func (*PayloadBlock) UnmarshalBinary ¶ added in v0.5.1
func (pb *PayloadBlock) UnmarshalBinary(data []byte) error
UnmarshalBinary reads a binary PayloadBlock.
type PreviousNodeBlock ¶
type PreviousNodeBlock EndpointID
PreviousNodeBlock implements the Bundle Protocol's Previous Node Block.
func NewPreviousNodeBlock ¶
func NewPreviousNodeBlock(prev EndpointID) *PreviousNodeBlock
NewPreviousNodeBlock creates a new Previous Node Block for an Endpoint ID.
func (*PreviousNodeBlock) BlockTypeCode ¶ added in v0.1.1
func (pnb *PreviousNodeBlock) BlockTypeCode() uint64
BlockTypeCode must return a constant integer, indicating the block type code.
func (*PreviousNodeBlock) CheckValid ¶ added in v0.1.1
func (pnb *PreviousNodeBlock) CheckValid() error
CheckValid returns an array of errors for incorrect data.
func (*PreviousNodeBlock) Endpoint ¶ added in v0.1.1
func (pnb *PreviousNodeBlock) Endpoint() EndpointID
Endpoint returns this Previous Node Block's Endpoint ID.
func (*PreviousNodeBlock) MarshalCbor ¶ added in v0.1.1
func (pnb *PreviousNodeBlock) MarshalCbor(w io.Writer) error
MarshalCbor writes the CBOR representation of a PreviousNodeBlock.
func (*PreviousNodeBlock) UnmarshalCbor ¶ added in v0.1.1
func (pnb *PreviousNodeBlock) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads a CBOR representation of a PreviousNodeBlock.
type PrimaryBlock ¶
type PrimaryBlock struct { Version uint64 BundleControlFlags BundleControlFlags CRCType CRCType Destination EndpointID SourceNode EndpointID ReportTo EndpointID CreationTimestamp CreationTimestamp Lifetime uint64 FragmentOffset uint64 TotalDataLength uint64 CRC []byte }
PrimaryBlock is a representation of the primary bundle block as defined in section 4.2.2.
func NewPrimaryBlock ¶
func NewPrimaryBlock(bundleControlFlags BundleControlFlags, destination EndpointID, sourceNode EndpointID, creationTimestamp CreationTimestamp, lifetime uint64) PrimaryBlock
NewPrimaryBlock creates a new primary block with the given parameters. All other fields are set to default values. The lifetime is passed in milliseconds.
func (PrimaryBlock) CheckValid ¶ added in v0.1.1
func (pb PrimaryBlock) CheckValid() (errs error)
CheckValid returns an array of errors for incorrect data.
func (PrimaryBlock) GetCRCType ¶
func (pb PrimaryBlock) GetCRCType() CRCType
GetCRCType returns the CRCType of this block.
func (PrimaryBlock) HasCRC ¶
func (pb PrimaryBlock) HasCRC() bool
HasCRC returns if the CRCType indicates a CRC is present for this block. This should be always true for the Primary Block.
func (PrimaryBlock) HasFragmentation ¶
func (pb PrimaryBlock) HasFragmentation() bool
HasFragmentation returns true if the bundle processing control flags indicates a fragmented bundle. In this case the FragmentOffset and TotalDataLength fields should become relevant.
func (PrimaryBlock) IsLifetimeExceeded ¶
func (pb PrimaryBlock) IsLifetimeExceeded() bool
IsLifetimeExceeded returns true if this PrimaryBlock's lifetime is exceeded. This method only compares the tuple of the CreationTimestamp and Lifetime against the current time.
If the creation timestamp's time value is zero, this method will always return false.
func (*PrimaryBlock) MarshalCbor ¶ added in v0.1.1
func (pb *PrimaryBlock) MarshalCbor(w io.Writer) error
MarshalCbor writes the CBOR representation of a PrimaryBlock.
func (PrimaryBlock) MarshalJSON ¶ added in v0.6.0
func (pb PrimaryBlock) MarshalJSON() ([]byte, error)
MarshalJSON writes a JSON object representing this PrimaryBlock.
func (*PrimaryBlock) SetCRCType ¶
func (pb *PrimaryBlock) SetCRCType(crcType CRCType)
SetCRCType sets the CRC type.
func (PrimaryBlock) String ¶
func (pb PrimaryBlock) String() string
func (*PrimaryBlock) UnmarshalCbor ¶ added in v0.1.1
func (pb *PrimaryBlock) UnmarshalCbor(r io.Reader) error
UnmarshalCbor reads the CBOR representation of a PrimaryBlock.
type StatusInformationPos ¶ added in v0.6.1
type StatusInformationPos int
StatusInformationPos describes the different bundle status information entries. Each bundle status report must contain at least the following bundle status items.
const ( // ReceivedBundle is the first bundle status information entry, indicating // the reporting node received this bundle. ReceivedBundle StatusInformationPos = 0 // ForwardedBundle is the second bundle status information entry, indicating // the reporting node forwarded this bundle. ForwardedBundle StatusInformationPos = 1 // DeliveredBundle is the third bundle status information entry, indicating // the reporting node delivered this bundle. DeliveredBundle StatusInformationPos = 2 // DeletedBundle is the fourth bundle status information entry, indicating // the reporting node deleted this bundle. DeletedBundle StatusInformationPos = 3 )
func (StatusInformationPos) String ¶ added in v0.6.1
func (sip StatusInformationPos) String() string
type StatusReport ¶ added in v0.6.1
type StatusReport struct { StatusInformation []BundleStatusItem ReportReason StatusReportReason RefBundle BundleID }
StatusReport is the bundle status report, used in an administrative record.
func NewStatusReport ¶ added in v0.6.1
func NewStatusReport(bndl Bundle, statusItem StatusInformationPos, reason StatusReportReason, time DtnTime) StatusReport
NewStatusReport creates a bundle status report for the given bundle and StatusInformationPos, which creates the right bundle status item. The bundle status report reason code will be used and the bundle status item gets the given timestamp.
func (*StatusReport) MarshalCbor ¶ added in v0.6.1
func (sr *StatusReport) MarshalCbor(w io.Writer) error
func (*StatusReport) RecordTypeCode ¶ added in v0.7.0
func (sr *StatusReport) RecordTypeCode() uint64
func (StatusReport) StatusInformations ¶ added in v0.6.1
func (sr StatusReport) StatusInformations() (sips []StatusInformationPos)
StatusInformations returns an array of available StatusInformationPos.
func (StatusReport) String ¶ added in v0.6.1
func (sr StatusReport) String() string
func (*StatusReport) UnmarshalCbor ¶ added in v0.6.1
func (sr *StatusReport) UnmarshalCbor(r io.Reader) error
type StatusReportReason ¶ added in v0.6.1
type StatusReportReason uint64
StatusReportReason is the bundle status report reason code, which is used as the second element of the bundle status report array.
const ( // NoInformation is the "No additional information" bundle status report // reason code. NoInformation StatusReportReason = 0 // LifetimeExpired is the "Lifetime expired" bundle status report reason code. LifetimeExpired StatusReportReason = 1 // ForwardUnidirectionalLink is the "Forwarded over unidirectional link" // bundle status report reason code. ForwardUnidirectionalLink StatusReportReason = 2 // TransmissionCanceled is the "Transmission canceled" bundle status report // reason code. TransmissionCanceled StatusReportReason = 3 // DepletedStorage is the "Depleted storage" bundle status report reason code. DepletedStorage StatusReportReason = 4 // DestEndpointUnintelligible is the "Destination endpoint ID unintelligible" // bundle status report reason code. DestEndpointUnintelligible StatusReportReason = 5 // NoRouteToDestination is the "No known route to destination from here" // bundle status report reason code. NoRouteToDestination StatusReportReason = 6 // NoNextNodeContact is the "No timely contact with next node on route" bundle // status report reason code. NoNextNodeContact StatusReportReason = 7 // BlockUnintelligible is the "Block unintelligible" bundle status report // reason code. BlockUnintelligible StatusReportReason = 8 // HopLimitExceeded is the "Hop limit exceeded" bundle status report reason // code. HopLimitExceeded StatusReportReason = 9 )
func (StatusReportReason) String ¶ added in v0.6.1
func (srr StatusReportReason) String() string
type Valid ¶ added in v0.1.1
type Valid interface { // CheckValid returns an array of errors for incorrect data. CheckValid() error }
Valid is an interface with the CheckValid function. This function should return an errors for incorrect data. It should be implemented for the different types and sub-types of a Bundle. Each type is able to check its sub-types and by tree-like calls all errors of a whole Bundle can be detected. For non-trivial code, the multierror package might be used.
Source Files
¶
- 0doc.go
- administrative_record.go
- administrative_record_status_report.go
- block.go
- block_control_flags.go
- bundle.go
- bundle_builder.go
- bundle_control_flags.go
- bundle_id.go
- canonical_block.go
- canonical_block_sort.go
- crc.go
- endpoint.go
- endpoint_dtn.go
- endpoint_ipn.go
- extension_block.go
- extension_block_bundle_age.go
- extension_block_generic.go
- extension_block_hop_count.go
- extension_block_payload.go
- extension_block_previous_node.go
- fragmentation.go
- primary_block.go
- time.go
- valid.go