stages

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 stages contains internal stages of a TCPCLv4 session.

Index

Constants

This section is empty.

Variables

View Source
var StageClose = errors.New("stage closed down")

StageClose signals a closed stage, after calling the Close() method.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	// ActivePeer indicates it this peer is the "active" entity in the session.
	ActivePeer bool

	// ContactFlags determine the Contact Header.
	ContactFlags msgs.ContactFlags

	// Keepalive in seconds. A zero value indicates a disabled keepalive.
	Keepalive uint16

	// SegmentMru is the largest allowed single-segment payload to be received in bytes.
	SegmentMru uint64

	// TransferMru is the largest allowed total-bundle payload to be received in bytes.
	TransferMru uint64

	// NodeId is this node's ID.
	NodeId bpv7.EndpointID
}

Configuration for stages.

type ContactStage

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

ContactStage models the initial ContactHeader exchange.

func (*ContactStage) Handle

func (cs *ContactStage) Handle(state *State, closeChan <-chan struct{})

Handle this Stage's action based on the previous Stage's State and the StageHandler's close channel.

type SessEstablishedStage

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

SessEstablishedStage models an established TCPCLv4 session after a successfully SESS_INIT.

func (*SessEstablishedStage) Handle

func (se *SessEstablishedStage) Handle(state *State, closeChan <-chan struct{})

Handle this Stage's action based on the previous Stage's State and the StageHandler's close channel.

type SessInitStage

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

SessInitStage models the session initialization resp. SESS_INIT exchange.

func (*SessInitStage) Handle

func (ci *SessInitStage) Handle(state *State, closeChan <-chan struct{})

Handle this Stage's action based on the previous Stage's State and the StageHandler's close channel.

type Stage

type Stage interface {
	// Handle this Stage's action based on the previous Stage's State and the StageHandler's close channel.
	Handle(state *State, closeChan <-chan struct{})
}

Stage described by this interface.

type StageHandler

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

StageHandler executes a sequence of Stages and passes the State from one Stage to another. Errors might be propagated back through the Error method.

func NewStageHandler

func NewStageHandler(stages []StageSetup, msgIn <-chan msgs.Message, msgOut chan<- msgs.Message, config Configuration) (sh *StageHandler)

NewStageHandler for a slice of Stages, Message channels and a Configuration.

func (*StageHandler) Close

func (sh *StageHandler) Close() error

Close this StageHandler and the current Stage.

func (*StageHandler) Error

func (sh *StageHandler) Error() <-chan error

Error might return errors risen in a Stage.

func (*StageHandler) Exchanges

func (sh *StageHandler) Exchanges() (incoming <-chan msgs.Message, outgoing chan<- msgs.Message)

Exchanges returns two channels for Message exchange with the peer.

type StageSetup

type StageSetup struct {
	// Stage to be executed.
	Stage Stage

	// PreHook will be executed before starting the Stage, if not nil.
	PreHook func(*StageHandler, *State) error
	// PostHook will be executed after a finished Stage, if not nil.
	PostHook func(*StageHandler, *State) error
}

StageSetup wraps a Stage with two possible hooks (pre and post) to be used within the StageHandler.

type State

type State struct {
	// Configuration to be used; should not be altered.
	Configuration Configuration

	// MsgIn and MsgOut are channels for incoming (receiving) and outgoing (sending) TCPCLv4 messages with an underlying
	// connector, e.g., an util.MessageSwitch.
	MsgIn  <-chan msgs.Message
	MsgOut chan<- msgs.Message

	// ExchangeMsgIn and ExchangeMsgOut are channels for incoming (receiving) and outgoing (sending) TCPCLv4 messages
	// with a higher-level util, e.g., an util.TransferManager.
	ExchangeMsgIn  chan msgs.Message
	ExchangeMsgOut chan msgs.Message

	// StageError reports back the failure of a stage.
	StageError error

	// CONTACT STAGE
	// ContactFlags are the received ContactFlags.
	ContactFlags msgs.ContactFlags

	// SESS INIT STAGE
	// Keepalive is the minimum of the own configured and the received keepalive. Zero indicates a disabled keepalive.
	Keepalive uint16
	// SegmentMtu is the peer's segment MTU.
	SegmentMtu uint64
	// TransferMtu is the peer's transfer MTU.
	TransferMtu uint64
	// PeerNodeId is the peer's node ID.
	PeerNodeId bpv7.EndpointID
}

State for stages, both used as input and as an altered output.

Jump to

Keyboard shortcuts

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