client

package
v0.0.0-...-372ceeb Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const (
	P4RuntimePort = 9559
)

Variables

View Source
var DefaultCloneSessionOptions = CloneSessionOptions{
	ClassOfService: 0,
	PacketLenBytes: 0,
}

Functions

func DisableCanonicalBytestrings

func DisableCanonicalBytestrings(options *ClientOptions)

func ToCanonicalIf

func ToCanonicalIf(v []byte, cond bool) []byte

Types

type ActionProfileActionSet

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

func (*ActionProfileActionSet) AddAction

func (s *ActionProfileActionSet) AddAction(
	action string,
	params [][]byte,
	weight int32,
	port Port,
) *ActionProfileActionSet

func (*ActionProfileActionSet) TableAction

func (s *ActionProfileActionSet) TableAction() *p4_v1.TableAction

type Client

type Client struct {
	ClientOptions
	p4_v1.P4RuntimeClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	p4RuntimeClient p4_v1.P4RuntimeClient,
	deviceID uint64,
	electionID *p4_v1.Uint128,
	optionsModifierFns ...func(*ClientOptions),
) *Client

func NewClientForRole

func NewClientForRole(
	p4RuntimeClient p4_v1.P4RuntimeClient,
	deviceID uint64,
	electionID *p4_v1.Uint128,
	role *p4_v1.Role,
	optionsModifierFns ...func(*ClientOptions),
) *Client

func (*Client) AckDigestList

func (c *Client) AckDigestList(ctx context.Context, digestList *p4_v1.DigestList) error

func (*Client) CommitFwdPipe

func (*Client) DeleteActionProfileGroup

func (c *Client) DeleteActionProfileGroup(ctx context.Context, entry *p4_v1.ActionProfileGroup) error

func (*Client) DeleteActionProfileMember

func (c *Client) DeleteActionProfileMember(ctx context.Context, entry *p4_v1.ActionProfileMember) error

func (*Client) DeleteCloneSession

func (c *Client) DeleteCloneSession(ctx context.Context, id uint32) error

func (*Client) DeleteMulticastGroup

func (c *Client) DeleteMulticastGroup(ctx context.Context, mgid uint32) error

func (*Client) DeleteTableEntry

func (c *Client) DeleteTableEntry(ctx context.Context, entry *p4_v1.TableEntry) error

func (*Client) DisableDigest

func (c *Client) DisableDigest(ctx context.Context, digest string) error

func (*Client) EnableDigest

func (c *Client) EnableDigest(ctx context.Context, digest string, config *p4_v1.DigestEntry_Config) error

func (*Client) GetFwdPipe

func (c *Client) GetFwdPipe(ctx context.Context, responseType GetFwdPipeResponseType) (*FwdPipeConfig, error)

GetFwdPipe retrieves the current pipeline config used in the remote switch.

responseType is oneof:

GetFwdPipeAll, GetFwdPipeCookieOnly, GetFwdPipeP4InfoAndCookie, GetFwdPipeDeviceConfigAndCookie

See https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-getforwardingpipelineconfig-rpc

func (*Client) InsertActionProfileGroup

func (c *Client) InsertActionProfileGroup(ctx context.Context, entry *p4_v1.ActionProfileGroup) error

func (*Client) InsertActionProfileMember

func (c *Client) InsertActionProfileMember(ctx context.Context, entry *p4_v1.ActionProfileMember) error

func (*Client) InsertCloneSession

func (c *Client) InsertCloneSession(ctx context.Context, id uint32, ports []uint32, options CloneSessionOptions) error

func (*Client) InsertMulticastGroup

func (c *Client) InsertMulticastGroup(ctx context.Context, mgid uint32, ports []uint32) error

func (*Client) InsertTableEntry

func (c *Client) InsertTableEntry(ctx context.Context, entry *p4_v1.TableEntry) error

func (*Client) ModifyActionProfileGroup

func (c *Client) ModifyActionProfileGroup(ctx context.Context, entry *p4_v1.ActionProfileGroup) error

func (*Client) ModifyActionProfileMember

func (c *Client) ModifyActionProfileMember(ctx context.Context, entry *p4_v1.ActionProfileMember) error

func (*Client) ModifyCounterEntry

func (c *Client) ModifyCounterEntry(ctx context.Context, counter string, index int64, data *p4_v1.CounterData) error

func (*Client) ModifyDigest

func (c *Client) ModifyDigest(ctx context.Context, digest string, config *p4_v1.DigestEntry_Config) error

func (*Client) ModifyTableEntry

func (c *Client) ModifyTableEntry(ctx context.Context, entry *p4_v1.TableEntry) error

func (*Client) NewActionProfileActionSet

func (c *Client) NewActionProfileActionSet() *ActionProfileActionSet

func (*Client) NewActionProfileGroup

func (c *Client) NewActionProfileGroup(
	actionProfile string,
	groupID uint32,
	members []*p4_v1.ActionProfileGroup_Member,
	size int32,
) *p4_v1.ActionProfileGroup

func (*Client) NewActionProfileMember

func (c *Client) NewActionProfileMember(
	actionProfile string,
	memberID uint32,
	action string,
	params [][]byte,
) *p4_v1.ActionProfileMember

func (*Client) NewTableActionDirect

func (c *Client) NewTableActionDirect(
	action string,
	params [][]byte,
) *p4_v1.TableAction

func (*Client) NewTableActionGroup

func (c *Client) NewTableActionGroup(
	groupID uint32,
) *p4_v1.TableAction

func (*Client) NewTableActionMember

func (c *Client) NewTableActionMember(
	memberID uint32,
) *p4_v1.TableAction

func (*Client) NewTableEntry

func (c *Client) NewTableEntry(
	table string,
	mfs map[string]MatchInterface,
	action *p4_v1.TableAction,
	options *TableEntryOptions,
) *p4_v1.TableEntry

for default entries: to set use nil for mfs, to unset use nil for mfs and nil for action

func (*Client) ReadCounterEntry

func (c *Client) ReadCounterEntry(ctx context.Context, counter string, index int64) (*p4_v1.CounterData, error)

func (*Client) ReadCounterEntryWildcard

func (c *Client) ReadCounterEntryWildcard(ctx context.Context, counter string) ([]*p4_v1.CounterData, error)

func (*Client) ReadEntitySingle

func (c *Client) ReadEntitySingle(ctx context.Context, entity *p4_v1.Entity) (*p4_v1.Entity, error)

func (*Client) ReadEntityWildcard

func (c *Client) ReadEntityWildcard(ctx context.Context, entity *p4_v1.Entity, readEntityCh chan<- *p4_v1.Entity) error

ReadEntityWildcard will block and send all read entities on readEntityCh. It will close the channel when the RPC completes and return any error that may have occurred.

func (*Client) ReadMeterEntry

func (c *Client) ReadMeterEntry(ctx context.Context, meter string, index int64) (*p4_v1.MeterConfig, error)

func (*Client) ReadMeterEntryWildcard

func (c *Client) ReadMeterEntryWildcard(ctx context.Context, meter string) ([]*p4_v1.MeterEntry, error)

func (*Client) ReadTableEntry

func (c *Client) ReadTableEntry(ctx context.Context, table string, mfs []MatchInterface) (*p4_v1.TableEntry, error)

func (*Client) ReadTableEntryWildcard

func (c *Client) ReadTableEntryWildcard(ctx context.Context, table string) ([]*p4_v1.TableEntry, error)

func (*Client) Run

func (c *Client) Run(
	stopCh <-chan struct{},
	arbitrationCh chan<- bool,
	messageCh chan<- *p4_v1.StreamMessageResponse,
) error

func (*Client) SaveFwdPipeFromBytes

func (c *Client) SaveFwdPipeFromBytes(ctx context.Context, binBytes, p4infoBytes []byte, cookie uint64) (*FwdPipeConfig, error)

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, msg *p4_v1.StreamMessageRequest) error

func (*Client) SendPacketOut

func (c *Client) SendPacketOut(ctx context.Context, pkt *p4_v1.PacketOut) error

func (*Client) SetFwdPipe

func (c *Client) SetFwdPipe(ctx context.Context, binPath string, p4infoPath string, cookie uint64) (*FwdPipeConfig, error)

func (*Client) SetFwdPipeFromBytes

func (c *Client) SetFwdPipeFromBytes(ctx context.Context, binBytes, p4infoBytes []byte, cookie uint64) (*FwdPipeConfig, error)

func (*Client) SetFwdPipeFromBytesWithAction

func (c *Client) SetFwdPipeFromBytesWithAction(ctx context.Context, binBytes, p4infoBytes []byte, cookie uint64, action p4_v1.SetForwardingPipelineConfigRequest_Action) (*FwdPipeConfig, error)

func (*Client) WriteUpdate

func (c *Client) WriteUpdate(ctx context.Context, update *p4_v1.Update) error

type ClientOptions

type ClientOptions struct {
	CanonicalBytestrings bool
}

type CloneSessionOptions

type CloneSessionOptions struct {
	// ClassOfService defines class_of_service that should be set for cloned packets.
	ClassOfService uint32
	// PacketLenBytes defines packet size (in bytes) for cloned packets.
	// Should be set to non-zero value if packets should be truncated.
	PacketLenBytes int32
}

type ExactMatch

type ExactMatch struct {
	Value []byte
}

type FwdPipeConfig

type FwdPipeConfig struct {
	P4Info         *p4_config_v1.P4Info
	P4DeviceConfig []byte
	Cookie         uint64
}

type GetFwdPipeResponseType

type GetFwdPipeResponseType int32

type LpmMatch

type LpmMatch struct {
	Value []byte
	PLen  int32
}

type MatchInterface

type MatchInterface interface {
	// contains filtered or unexported methods
}

type OptionalMatch

type OptionalMatch struct {
	Value []byte
}

type Port

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

func NewPort

func NewPort(bytes []byte) Port

func NewPortFromInt

func NewPortFromInt(i uint32) Port

func (Port) AsBytes

func (p Port) AsBytes() []byte

type RangeMatch

type RangeMatch struct {
	Low  []byte
	High []byte
}

type TableEntryOptions

type TableEntryOptions struct {
	IdleTimeout time.Duration
	Priority    int32
}

type TernaryMatch

type TernaryMatch struct {
	Value []byte
	Mask  []byte
}

Jump to

Keyboard shortcuts

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