rctx

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2017 ETH Zurich Copyright 2018 ETH Zurich, Anapaya Systems

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package rctx holds the current router context. The context contains a conf object and slices of input and output functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(newCtx *Ctx)

Set updates the current router context.

Types

type Ctx

type Ctx struct {
	// Conf contains the router state for this context.
	Conf *brconf.BRConf
	// HFMacPool is the pool of Hop Field MAC generation instances.
	HFMacPool *sync.Pool
	// LockSockIn is a Sock for receiving packets from the local AS,
	LocSockIn *Sock
	// LocSockOut is a Sock for sending packets to the local AS,
	LocSockOut *Sock
	// ExtSockIn is a map of Sock's for receiving packets from neighbouring
	// ASes, keyed by the interface ID of the relevant link.
	ExtSockIn map[common.IFIDType]*Sock
	// ExtSockOut is a map of Sock's for sending packets to neighbouring ASes,
	// keyed by the interface ID of the relevant link.
	ExtSockOut map[common.IFIDType]*Sock
}

Ctx is the main router context structure.

func Get

func Get() *Ctx

Get returns a pointer to the current router context.

func New

func New(conf *brconf.BRConf) *Ctx

New returns a new Ctx instance.

func (*Ctx) InitMacPool added in v0.4.0

func (ctx *Ctx) InitMacPool() error

initMacPool initializes the hop field mac pool.

func (*Ctx) ResolveSVC added in v0.3.0

func (ctx *Ctx) ResolveSVC(svc addr.HostSVC) ([]*overlay.OverlayAddr, error)

func (*Ctx) ResolveSVCAny added in v0.3.0

func (ctx *Ctx) ResolveSVCAny(svc addr.HostSVC) (*overlay.OverlayAddr, error)

ResolveSVCAny resolves an anycast SVC address (i.e. a single instance of a local infrastructure service).

func (*Ctx) ResolveSVCMulti added in v0.3.0

func (ctx *Ctx) ResolveSVCMulti(svc addr.HostSVC) ([]*overlay.OverlayAddr, error)

ResolveSVCMulti resolves a multicast SVC address (i.e. one packet per machine hosting instances for a local infrastructure service).

type Sock

type Sock struct {
	// Ring is a ring-buffer that's written to by writers, and read from by readers.
	Ring *ringbuf.Ring
	// Conn is the underlying connection that this Sock represents.
	Conn conn.Conn
	// Dir is the direction that a packet is being read from/written to.
	Dir rcmn.Dir
	// Ifid is the interface ID associated with a connection.
	Ifid common.IFIDType
	// Label is the interface label
	Label string
	// NeighIA is the interface remote IA
	NeighIA string
	// Reader is an optional function that reads from Sock.Ring. It is spawned
	// in a go routine when Sock.Start() is called.
	Reader SockFunc
	// Writer is an optional function that writes to Sock.Ring. It is spawned
	// in a go routine when Sock.Start() is called.
	Writer SockFunc
	// Type is the type of the socket.
	Type brconf.SockType
	// contains filtered or unexported fields
}

Sock represents one direction of data-flow from an underlying connection. Each connection will have 2 Sock's associated, one for reading data from the network, the other for writing data to the network.

func NewSock

func NewSock(ring *ringbuf.Ring, conn conn.Conn, dir rcmn.Dir, ifid common.IFIDType,
	neighIA string, reader, writer SockFunc, sockType brconf.SockType) *Sock

func (*Sock) Running added in v0.4.0

func (s *Sock) Running() bool

func (*Sock) Start

func (s *Sock) Start()

Start starts the reader/writer goroutines (if any). Does nothing if they have been started already.

func (*Sock) Started added in v0.4.0

func (s *Sock) Started() bool

func (*Sock) Stop

func (s *Sock) Stop()

Stop stops the running reader/writer goroutines (if any) and waits until the routines are stopped before returning to the caller.

type SockFunc

type SockFunc func(sock *Sock, stop, stopped chan struct{})

SockFunc is a function that is started as a goroutine by Sock.Start()/Sock.Stop() to read/write to the underlying connection.

Jump to

Keyboard shortcuts

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