utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 13 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(egressPort uint32) ([]byte, error)

ControllerLLDPPacket returns packet bytes for an ONOS link discovery packet

func CreateMastershipArbitration

func CreateMastershipArbitration(electionID *p4api.Uint128) *p4api.StreamMessageRequest

CreateMastershipArbitration returns stream message request with the specified election ID components

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 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 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

Types

This section is empty.

Jump to

Keyboard shortcuts

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