fwdport

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package fwdport contains routines and types to manage forwarding ports.

A Port is an entry or exit point for packets within the forwarding plane. Lucius has different types of ports (implemented by various types). All ports are created by provisioning.

This package defines the following mechanisms to manage ports

  1. It allows different types of ports to register builders during package initialization.
  2. Provisioning can create ports using the registered builders.
  3. It defines an interface that can be used to operate on a port.

Index

Constants

This section is empty.

Variables

CounterList is a set of counters incremented by ports.

Functions

func GetID

func GetID(port Port) *fwdpb.PortId

GetID returns the PortID for the given port.

func Increment

func Increment(port Port, octets int, packetID, octetID fwdpb.CounterId)

Increment increments a packet and octet counters on the port.

func Input

func Input(port Port, packet fwdpacket.Packet, dir fwdpb.PortAction, ctx *fwdcontext.Context) (err error)

Input processes an incoming packet. The specified port actions are applied to the packet, and if the packet has an output port, output actions are performed on the packet. All appropriate counters are incremented.

func MakeID

func MakeID(id fwdobject.ID) *fwdpb.PortId

MakeID makes a PortID corresponding to the specified object ID.

func Output

func Output(port Port, packet fwdpacket.Packet, dir fwdpb.PortAction, _ *fwdcontext.Context) (err error)

Output processes an outgoing packet. The specified port actions are applied to the packet, and if allowed the packet is written out of the port. All appropriate counters are incremented.

func Process

func Process(port Port, packet fwdpacket.Packet, dir fwdpb.PortAction, ctx *fwdcontext.Context, prefix string)

Process processes a packet on the specified port, action direction and context. If the attribute "PacketDebug" is set, then the packet debugging is enabled.

func Register

func Register(portType fwdpb.PortType, builder Builder)

Register registers a builder for a port type. Note that builders are expected to be registered during package initialization.

func Release

func Release(port Port) error

Release releases a reference to a port.

func SetInputPort

func SetInputPort(packet fwdpacket.Packet, port Port)

SetInputPort initializes the input port of the packet.

func SetOutputPort

func SetOutputPort(packet fwdpacket.Packet, port Port)

SetOutputPort initializes the output port of the packet.

func Write

func Write(port Port, packet fwdpacket.Packet)

Write writes out a packet through a port without changing it. No actions are applied.

Types

type Builder

type Builder interface {
	// Build builds a port.
	Build(portDesc *fwdpb.PortDesc, ctx *fwdcontext.Context) (Port, error)
}

A Builder can build Ports of the specified type.

type Port

type Port interface {
	fwdobject.Object

	// Update updates a port.
	Update(upd *fwdpb.PortUpdateDesc) error

	// Write writes a packet out. If successful, the port returns
	// fwdaction.CONSUME.
	Write(packet fwdpacket.Packet) (fwdaction.State, error)

	// Actions returns the port actions of the specified type
	Actions(dir fwdpb.PortAction) fwdaction.Actions

	// State manages the state of the port.
	State(op *fwdpb.PortInfo) (*fwdpb.PortStateReply, error)
}

A Port is an entry or exit point within the forwarding plane. Each port has a set of actions to apply for incoming and outgoing packets.

Ports are always created by provisioning.

func Acquire

func Acquire(id *fwdpb.PortId, ctx *fwdcontext.Context) (Port, error)

Acquire acquires a reference to a port.

func Find

func Find(id *fwdpb.PortId, ctx *fwdcontext.Context) (Port, error)

Find finds a port.

func InputPort

func InputPort(packet fwdpacket.Packet, ctx *fwdcontext.Context) (Port, error)

InputPort returns the input port of the packet.

func New

func New(desc *fwdpb.PortDesc, ctx *fwdcontext.Context) (Port, error)

New creates a new port.

func OutputPort

func OutputPort(packet fwdpacket.Packet, ctx *fwdcontext.Context) (Port, error)

OutputPort returns the output port of the packet.

Directories

Path Synopsis
Package mock_fwdpacket is a generated GoMock package.
Package mock_fwdpacket is a generated GoMock package.
Package ports implements various types of ports supported within Lucius.
Package ports implements various types of ports supported within Lucius.
Package porttestutil contains routines used to create and manage ports for test cases.
Package porttestutil contains routines used to create and manage ports for test cases.

Jump to

Keyboard shortcuts

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