client

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P4RuntimePort = 9559
)

Variables

This section is empty.

Functions

func DisableCanonicalBytestrings

func DisableCanonicalBytestrings(options *ClientOptions)

func ToCanonicalIf

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

Types

type Action added in v1.0.1

type Action struct {
	Name   string         `json:"action_name"`
	Params []*ActionParam `json:"table_params"`
}

func (*Action) String added in v1.0.1

func (action *Action) String() string

type ActionParam added in v1.0.1

type ActionParam struct {
	Name  string `json:"param_name"`
	Value []byte `json:"param_value"`
}

func (*ActionParam) String added in v1.0.1

func (ap *ActionParam) String() string

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 (*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, session_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, session_id uint32, packet_length int32, ports []uint32) 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) ModifyCloneSession

func (c *Client) ModifyCloneSession(ctx context.Context, session_id uint32, packet_length int32, ports []uint32) error

modify multicast group

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

func (c *Client) ModifyManyCounterEntry(ctx context.Context, counter string, indexs []int64, data *p4_v1.CounterData) error

可以一次性更新一个Counter的多个Index为相同数据,主要用于重置计数器为0的场景

func (*Client) ModifyMulticastGroup

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

modify multicast group

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

func (c *Client) ReadCloneSession(ctx context.Context, session_id uint32) (*p4_v1.CloneSessionEntry, error)

read one clone session entry

func (*Client) ReadCloneSessionWildcard

func (c *Client) ReadCloneSessionWildcard(ctx context.Context) ([]*p4_v1.CloneSessionEntry, error)

read all clone session entry

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

func (c *Client) ReadMulticastGroup(ctx context.Context, mgid uint32) (*p4_v1.MulticastGroupEntry, error)

read one mutlicast group entry

func (*Client) ReadMulticastGroupWildcard

func (c *Client) ReadMulticastGroupWildcard(ctx context.Context) ([]*p4_v1.MulticastGroupEntry, error)

read all mutlicast group entry

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) 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) TableEntryDecode added in v1.0.1

func (c *Client) TableEntryDecode(p4_table_entry *p4_v1.TableEntry) (table_entry *TableEntry, err error)

TableEntryDecode p4_v1.TableEntry to TableEntry

func (*Client) TableEntryEncode added in v1.0.1

func (c *Client) TableEntryEncode(table_entry *TableEntry) (p4_table_entry *p4_v1.TableEntry, err error)

TableEntryEncode convert TableEntry to p4_v1.TableEntry

func (*Client) WriteManyUpdate

func (c *Client) WriteManyUpdate(ctx context.Context, updates []*p4_v1.Update) error

func (*Client) WriteUpdate

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

type ClientOptions

type ClientOptions struct {
	CanonicalBytestrings bool
}

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 MatchField added in v1.0.1

type MatchField struct {
	Name      string    `json:"field_name"`           // field name
	Type      MatchType `json:"match_type"`           // match type
	Value     []byte    `json:"value,omitempty"`      // match value  for
	Mask      []byte    `json:"mask,omitempty"`       // just for type Ternary
	PrefixLen int32     `json:"prefix_len,omitempty"` // just for type Lpm
	Low       []byte    `json:"low,omitempty"`        // just for type Range
	High      []byte    `json:"high,omitempty"`       // just for type Range

}

func (*MatchField) String added in v1.0.1

func (mf *MatchField) String() string

type MatchInterface

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

type MatchType added in v1.0.1

type MatchType string
const (
	Exact    MatchType = "exact"
	Ternary  MatchType = "ternary"
	Lpm      MatchType = "lpm"
	Range    MatchType = "range"
	Optional MatchType = "optional"
	Other    MatchType = "other"
)

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 TableEntry added in v1.0.1

type TableEntry struct {
	Name     string        `json:"table_name"`
	Fields   []*MatchField `json:"fields"`
	Action   *Action       `json:"action"`
	Priority int32         `json:"priority"`
}

func (*TableEntry) String added in v1.0.1

func (table_entry *TableEntry) String() string

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