p4utils

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Overview

Package p4utils contains various utilities for working with P4Info and P4RT entities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMastershipArbitration

func CreateMastershipArbitration(electionID *p4api.Uint128, role *p4api.Role) *p4api.StreamMessageRequest

CreateMastershipArbitration returns stream message request with the specified election ID components

func DecodeValueAsUint32

func DecodeValueAsUint32(value []byte) uint32

DecodeValueAsUint32 decodes the specified bytes as uint32 value

func FindAction added in v0.1.6

func FindAction(info *p4info.P4Info, actionName string) *p4info.Action

FindAction returns the named action from the specified P4Info; nil if not found

func FindActionParam added in v0.1.6

func FindActionParam(action *p4info.Action, paramName string) *p4info.Action_Param

FindActionParam returns the named action parameter from the specified action; nil if not found

func FindTable added in v0.1.6

func FindTable(info *p4info.P4Info, tableName string) *p4info.Table

FindTable returns the named table from the specified P4Info; nil if not found

func FindTableMatchField added in v0.1.7

func FindTableMatchField(table *p4info.Table, fieldName string) *p4info.MatchField

FindTableMatchField returns the named match field from the specified table; nil if not found

func LoadP4Info

func LoadP4Info(path string) (*p4info.P4Info, error)

LoadP4Info loads the specified file containing protoJSON representation of a P4Info and returns its descriptor

func NewStratumRole added in v0.1.4

func NewStratumRole(roleName string, roleAgentIDMetaDataID uint32, roleAgentID []byte,
	receivesPacketIns bool, canPushPipeline bool) *p4api.Role

NewStratumRole produces a P4 Role with stratum.P4RoleConfig, and configured using the supplied parameters.

func P4InfoBytes

func P4InfoBytes(info *p4info.P4Info) []byte

P4InfoBytes serializes the given P4 info structure into prototext bytes

func TimeBasedElectionID added in v0.1.3

func TimeBasedElectionID() *p4api.Uint128

TimeBasedElectionID returns election ID generated from the UnixNano timestamp High contains seconds, Low contains remaining nanos

func TrimToBitwidth

func TrimToBitwidth(b []byte, bits int32) []byte

TrimToBitwidth trims the specified bytes to the specified width

Types

type ControllerMetadataCodec

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

ControllerMetadataCodec allows basic encoding and decoding of packet out/in metadata

func NewControllerMetadataCodec

func NewControllerMetadataCodec(info *p4info.P4Info) *ControllerMetadataCodec

NewControllerMetadataCodec creates a new codec from the supplied P4 info

func (*ControllerMetadataCodec) DecodePacketInMetadata

func (c *ControllerMetadataCodec) DecodePacketInMetadata(md []*p4api.PacketMetadata) *PacketInMetadata

DecodePacketInMetadata decodes the received metadata into an internal structure

func (*ControllerMetadataCodec) DecodePacketOutMetadata

func (c *ControllerMetadataCodec) DecodePacketOutMetadata(md []*p4api.PacketMetadata) *PacketOutMetadata

DecodePacketOutMetadata decodes the received metadata into an internal structure

func (*ControllerMetadataCodec) EgressPortMetadataID added in v0.1.3

func (c *ControllerMetadataCodec) EgressPortMetadataID() uint32

EgressPortMetadataID returns egress port metadata ID

func (*ControllerMetadataCodec) EncodePacketInMetadata

func (c *ControllerMetadataCodec) EncodePacketInMetadata(pim *PacketInMetadata) []*p4api.PacketMetadata

EncodePacketInMetadata encodes the metadata into an external representation

func (*ControllerMetadataCodec) EncodePacketOutMetadata

func (c *ControllerMetadataCodec) EncodePacketOutMetadata(pom *PacketOutMetadata) []*p4api.PacketMetadata

EncodePacketOutMetadata encodes the metadata into an external representation

func (*ControllerMetadataCodec) InressPortMetadataID added in v0.1.3

func (c *ControllerMetadataCodec) InressPortMetadataID() uint32

InressPortMetadataID returns ingress port metadata ID

func (*ControllerMetadataCodec) RoleAgentIDMetadataID added in v0.1.5

func (c *ControllerMetadataCodec) RoleAgentIDMetadataID() uint32

RoleAgentIDMetadataID returns role agent ID metadata ID

type PacketInMetadata

type PacketInMetadata struct {
	IngressPort uint32
	RoleAgentID uint32
}

PacketInMetadata carries basic packet-in metadata contents

type PacketOutMetadata

type PacketOutMetadata struct {
	EgressPort uint32
}

PacketOutMetadata carries basic packet-out metadata contents

Jump to

Keyboard shortcuts

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