utils

package
v0.1.14 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ARPRequestPacket

func ARPRequestPacket(theirIP []byte, ourMAC []byte, ourIP []byte) ([]byte, error)

ARPRequestPacket returns packet bytes with an ARP request for the specified IP address

func ControllerLLDPPacket

func ControllerLLDPPacket(chassisID string, egressPort uint32) ([]byte, error)

ControllerLLDPPacket returns packet bytes for an ONOS link discovery packet

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 added in v0.1.6

func DecodeValueAsUint32(value []byte) uint32

DecodeValueAsUint32 decodes the specified bytes as uint32 value

func GenerateFieldMatch

func GenerateFieldMatch(mf *p4info.MatchField) *p4api.FieldMatch

GenerateFieldMatch generates field match compliant with the specified match schema

func GenerateFieldMatches

func GenerateFieldMatches(tableInfo *p4info.Table) []*p4api.FieldMatch

GenerateFieldMatches generates field matches compliant with the specified table schema

func GenerateTableAction

func GenerateTableAction(tableInfo *p4info.Table) *p4api.TableAction

GenerateTableAction generates a table action compliant with the specified table schema

func GenerateTableEntry

func GenerateTableEntry(tableInfo *p4info.Table, priority int32, action *p4api.TableAction) *p4api.TableEntry

GenerateTableEntry generates a table entry compliant with the specified table schema

func IP

func IP(addr string) []byte

IP returns the given IP address as bytes

func IPString added in v0.1.3

func IPString(addr []byte) string

IPString returns a string representation of an IP address

func JoinPath

func JoinPath(segments []string) string

JoinPath joins the given path segments into a path string

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 MAC

func MAC(addr string) []byte

MAC returns the given MAC address as bytes

func MACString added in v0.1.3

func MACString(addr []byte) string

MACString returns a string representation of a MAC address

func NameKey

func NameKey(e string) (string, map[string]string, bool)

NameKey splits the string representation of the path segment into name and an optional key

func P4InfoBytes

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

P4InfoBytes serializes the given P4 info structure into prototext bytes

func RandomBytes

func RandomBytes(bitwidth int32) []byte

RandomBytes returns a buffer spanning at least the specified number of bits, filled with random content

func SplitPath

func SplitPath(path string) []string

SplitPath splits the given string path into its segments

func Subpath

func Subpath(path string, name string, key map[string]string) string

Subpath creates a subpath of a given path

func ToPath

func ToPath(path string) *gnmi.Path

ToPath produces a gNMI path from the given string representation

func ToString

func ToString(path *gnmi.Path) string

ToString produces a deterministic string representation of the given gNMI path structure

func TrimToBitwidth added in v0.1.6

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

TrimToBitwidth trims the specified bytes to the specified width

Types

type ControllerMetadataCodec added in v0.1.3

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

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

func NewControllerMetadataCodec added in v0.1.3

func NewControllerMetadataCodec(info *p4info.P4Info) *ControllerMetadataCodec

NewControllerMetadataCodec creates a new codec from the supplied P4 info

func (*ControllerMetadataCodec) DecodePacketInMetadata added in v0.1.3

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

DecodePacketInMetadata decodes the received metadata into an internal structure

func (*ControllerMetadataCodec) DecodePacketOutMetadata added in v0.1.3

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

DecodePacketOutMetadata decodes the received metadata into an internal structure

func (*ControllerMetadataCodec) EncodePacketInMetadata added in v0.1.3

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

EncodePacketInMetadata encodes the metadata into an external representation

func (*ControllerMetadataCodec) EncodePacketOutMetadata added in v0.1.3

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

EncodePacketOutMetadata encodes the metadata into an external representation

type PacketInMetadata added in v0.1.3

type PacketInMetadata struct {
	IngressPort uint32
	RoleAgentID uint32
}

PacketInMetadata carries basic packet-in metadata contents

type PacketOutMetadata added in v0.1.3

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