cla

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cla defines two interfaces for Convergence Layer Adapters.

The ConvergenceReceiver specifies a type which receives bundles and forwards those to an exposed channel.

The ConvergenceSender specifies a type which sends bundles to a remote endpoint.

An implemented convergence layer can be a ConvergenceReceiver, ConvergenceSender or even both. This depends on the convergence layer's specification and is an implementation matter.

Furthermore, the ConvergenceProvider provides the ability to create new instances of Convergence objects.

Those types are generalized by the Convergable interface.

A centralized instance for CLA management offers the Manager, designed to work seamlessly with the types above.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLAType

type CLAType uint

CLAType is one of the supported Convergence Layer Adaptors

const (
	// TCPCLv4 identifies the Delay-Tolerant Networking TCP Convergence Layer Protocol Version 4, implemented in cla/tcpclv4.
	TCPCLv4 CLAType = 0

	// TCPCLv4WebSocket identifies a variation of TCPCLv4 based on WebSockets.
	TCPCLv4WebSocket CLAType = 1

	// MTCP identifies the Minimal TCP Convergence-Layer Protocol, implemented in cla/mtcp.
	MTCP CLAType = 10

	// BBC identifies the Bundle Broadcasting Connector, implemented in cla/bbc.
	// Only here for completeness
	BBC CLAType = 20
)

func (CLAType) CheckValid

func (claType CLAType) CheckValid() (err error)

CheckValid checks if its value is known.

func (CLAType) String

func (claType CLAType) String() string

type Convergable

type Convergable interface {
	io.Closer
}

Convergable describes any kind of type which supports convergence layer- related services. This can be both a more specified Convergence interface type or a ConvergenceProvider.

type Convergence

type Convergence interface {
	Convergable

	// Start this Convergence{Receiver,Sender} and return both an error
	// and a boolean indicating if another Start should be tried later.
	Start() (error, bool)

	// Channel represents a return channel for transmitted bundles, status
	// messages, etc.
	Channel() chan ConvergenceStatus

	// Address should return a unique address string to both identify this
	// Convergence{Receiver,Sender} and ensure it will not opened twice.
	Address() string

	// IsPermanent returns true, if this CLA should not be removed after failures.
	IsPermanent() bool
}

Convergence is an interface to describe all kinds of Convergence Layer Adapters. There should not be a direct implementation of this interface. One must implement ConvergenceReceiver and/or ConvergenceSender, which are both extending this interface. A type can be both a ConvergenceReceiver and ConvergenceSender.

type ConvergenceMessageType

type ConvergenceMessageType uint

ConvergenceMessageType indicates the kind of a ConvergenceStatus.

const (

	// ReceivedBundle shows the reception of a bundle. The Message's type must be
	// a ConvergenceReceivedBundle struct.
	ReceivedBundle ConvergenceMessageType

	// PeerDisappeared shows the disappearance of a peer. The Message's type must
	// be a bpv7.EndpointID.
	PeerDisappeared

	// PeerAppeared shows the appearance of a peer. The Message's type must be
	// a bpv7.EndpointID
	PeerAppeared
)

func (ConvergenceMessageType) String

func (cms ConvergenceMessageType) String() string

type ConvergenceProvider

type ConvergenceProvider interface {
	Convergable

	// RegisterManager tells the ConvergenceProvider where to report new instances
	// of Convergence to.
	RegisterManager(*Manager)

	// Start this ConvergenceProvider. Before being started, the the
	// RegisterManager method tells this ConvergenceProvider its Manager. The
	// Manager will both call the RegisterManager and Start methods.
	Start() error
}

ConvergenceProvider is a more general kind of CLA service which does not transfer any Bundles by itself, but supplies/creates new Convergence types. Those Convergence objects will be passed to a Manager. Thus, one might think of a ConvergenceProvider as some kind of middleware.

type ConvergenceReceivedBundle

type ConvergenceReceivedBundle struct {
	Endpoint bpv7.EndpointID
	Bundle   *bpv7.Bundle
}

ConvergenceReceivedBundle is an optional Message content for a ConvergenceStatus for the ReceivedBundle MessageType.

type ConvergenceReceiver

type ConvergenceReceiver interface {
	Convergence

	// GetEndpointID returns the endpoint ID assigned to this CLA.
	GetEndpointID() bpv7.EndpointID
}

ConvergenceReceiver is an interface for types which are able to receive bundles and write them to a channel. This channel can be accessed through the Channel method.

type ConvergenceSender

type ConvergenceSender interface {
	Convergence

	// Send a bundle to this ConvergenceSender's endpoint. This method should
	// be thread safe and finish transmitting one bundle, before acting on the
	// next. This could be achieved by using a mutex or the like.
	Send(bpv7.Bundle) error

	// GetPeerEndpointID returns the endpoint ID assigned to this CLA's peer,
	// if it's known. Otherwise the zero endpoint will be returned.
	GetPeerEndpointID() bpv7.EndpointID
}

ConvergenceSender is an interface for types which are able to transmit bundles to another node.

type ConvergenceStatus

type ConvergenceStatus struct {
	Sender      Convergence
	MessageType ConvergenceMessageType
	Message     interface{}
}

ConvergenceStatus allows transmission of information via a return channel from a Convergence instance.

func NewConvergencePeerAppeared

func NewConvergencePeerAppeared(sender Convergence, peerEid bpv7.EndpointID) ConvergenceStatus

NewConvergencePeerAppeared creates a new ConvergenceStatus for a PeerAppeared type, transmission the appeared EndpointID.

func NewConvergencePeerDisappeared

func NewConvergencePeerDisappeared(sender Convergence, peerEid bpv7.EndpointID) ConvergenceStatus

NewConvergencePeerDisappeared creates a new ConvergenceStatus for a PeerDisappeared type, transmission the disappeared EndpointID.

func NewConvergenceReceivedBundle

func NewConvergenceReceivedBundle(sender Convergence, eid bpv7.EndpointID, bndl *bpv7.Bundle) ConvergenceStatus

NewConvergenceReceivedBundle creates a new ConvergenceStatus for a ReceivedBundle type, transmitting both EndpointID and Bundle pointer.

func (ConvergenceStatus) String

func (cs ConvergenceStatus) String() string

type Manager

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

Manager monitors and manages the various CLAs, restarts them if necessary, and forwards the ConvergenceStatus messages. The recipient can perform further actions based on these, but does not have to take care of the CLA administration themselves.

func NewManager

func NewManager() *Manager

NewManager creates a new Manager to supervise different CLAs.

func (*Manager) Channel

func (manager *Manager) Channel() chan ConvergenceStatus

Channel references the outgoing channel for ConvergenceStatus messages.

func (*Manager) Close

func (manager *Manager) Close() error

Close the Manager and all supervised CLAs.

func (*Manager) EndpointIDs

func (manager *Manager) EndpointIDs(claType CLAType) []bpv7.EndpointID

EndpointIDs returns the EndpointIDs of all registered CLAs of the specified type. Returns an empty slice if no CLAs of the tye exist.

func (*Manager) HasEndpoint

func (manager *Manager) HasEndpoint(endpoint bpv7.EndpointID) bool

func (*Manager) Receiver

func (manager *Manager) Receiver() (crs []ConvergenceReceiver)

Receiver returns an array of all active ConvergenceReceivers.

func (*Manager) Register

func (manager *Manager) Register(conv Convergable)

Register any kind of Convergable.

func (*Manager) RegisterEndpointID

func (manager *Manager) RegisterEndpointID(claType CLAType, eid bpv7.EndpointID)

func (*Manager) Restart

func (manager *Manager) Restart(conv Convergable)

Restart a known Convergable.

func (*Manager) Sender

func (manager *Manager) Sender() (css []ConvergenceSender)

Sender returns an array of all active ConvergenceSenders.

func (*Manager) Unregister

func (manager *Manager) Unregister(conv Convergable)

Unregister any kind of Convergable.

Directories

Path Synopsis
Package bbc describes a simple Bundle Broadcasting Connector to receive and transmit Bundles over a shared broadcasting medium, e.g., LoRa.
Package bbc describes a simple Bundle Broadcasting Connector to receive and transmit Bundles over a shared broadcasting medium, e.g., LoRa.
Package mtcp provides a library for the Minimal TCP Convergence-Layer Protocol as defined in draft-ietf-dtn-mtcpcl-01 Because of the unidirectional design of MTCP, both MTPCServer and MTCPClient exists.
Package mtcp provides a library for the Minimal TCP Convergence-Layer Protocol as defined in draft-ietf-dtn-mtcpcl-01 Because of the unidirectional design of MTCP, both MTPCServer and MTCPClient exists.
Package tcpclv4 provides a library for the Delay-Tolerant Networking TCP Convergence Layer Protocol Version 4, draft-ietf-dtn-tcpclv4-23.
Package tcpclv4 provides a library for the Delay-Tolerant Networking TCP Convergence Layer Protocol Version 4, draft-ietf-dtn-tcpclv4-23.
internal/msgs
Package msgs defines internal messages for the Delay-Tolerant Networking TCP Convergence Layer Protocol Version 4.
Package msgs defines internal messages for the Delay-Tolerant Networking TCP Convergence Layer Protocol Version 4.
internal/stages
Package stages contains internal stages of a TCPCLv4 session.
Package stages contains internal stages of a TCPCLv4 session.
internal/utils
Package utils provides encapsulated elements of a TCPCLv4 session.
Package utils provides encapsulated elements of a TCPCLv4 session.

Jump to

Keyboard shortcuts

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