p4

package
v0.0.0-...-30f0efb Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAXMODVAL              = (4095 - 1)
	DEFAULT_UUID_CNT_CACHE = 512
	PROTO_TCP              = 6
	PROTO_UDP              = 17
)
View Source
const (
	DEFAULT_CNIID_CNT_CACHE = 4094
	DEFAULT_SVCID_CNT_CACHE = 64
)

Variables

View Source
var (
	Errorcase    bool = false
	ASelMemError bool = false
	ASelGrpError bool = false
)
View Source
var (
	JsonFilePath = "/share/infra/jsonfiles/"
)
View Source
var Mask = []uint8{1, 2, 4, 8, 16, 32, 64, 128}

Functions

func CheckIPAddress

func CheckIPAddress(ip string) error

Checks needed for empty or small strings For MAC the net library checks for len(s) < 14 so no need

func ConfigureTable

func ConfigureTable(ctx context.Context, p4RtC *client.Client, P4w P4RtCWrapper, tablenames []string, tblactionmap map[string][]UpdateTable, actionnames []string, actiontype bool) error

This function calls Insert_table_entry or delete_table_entry based on actiontype flag

func GenerateMask

func GenerateMask(index int) uint8

this function to generate rulemask or ipsetmask for each rule under each ipsetidx

func GetStr

func GetStr(action InterfaceType) string

func IP4toInt

func IP4toInt(IPv4Address net.IP) int64

func Pack32BinaryIP4

func Pack32BinaryIP4(ip4Address string) []byte

Binary conversion function for IPaddress strings

func ParseIPCIDR

func ParseIPCIDR(cidr string) (net.IP, *net.IPNet, error)

func PrepareTable

func PrepareTable(tblaction map[string][]UpdateTable, tbl *Table)

This function utilizes the data from the Table struct To prepare UpdateTable struct and then adds each instances to map. TODO - Add all KeyMatch interfaces

func ToBytes

func ToBytes(data interface{}) []byte

Binary conversion functions for int and strings

Types

type ActionParam

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

type IdGenerator

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

func NewIdGenerator

func NewIdGenerator(cni uint32, svc uint32) *IdGenerator

type InterfaceType

type InterfaceType int
const (
	HOST InterfaceType = iota
	PROXY
	ENDPOINT
	EXCEPTION
)
const (
	Insert InterfaceType = iota
	Delete
	Update
)

type KeyData

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

type MockP4

type MockP4 struct {
	P4RtCWrapper
}

func (MockP4) DeleteActionProfileGroup

func (m MockP4) DeleteActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error

func (MockP4) DeleteActionProfileMember

func (m MockP4) DeleteActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error

func (MockP4) DeleteTableEntry

func (m MockP4) DeleteTableEntry(ctx context.Context, p4RtC *client.Client, entry *p4_v1.TableEntry) error

func (MockP4) InsertActionProfileGroup

func (m MockP4) InsertActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error

func (MockP4) InsertActionProfileMember

func (m MockP4) InsertActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error

func (MockP4) InsertTableEntry

func (m MockP4) InsertTableEntry(ctx context.Context, p4RtC *client.Client, entry *p4_v1.TableEntry) error

func (MockP4) ModifyActionProfileGroup

func (m MockP4) ModifyActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error

func (MockP4) ModifyActionProfileMember

func (m MockP4) ModifyActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error

func (MockP4) NewActionProfileGroup

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

func (MockP4) NewActionProfileMember

func (m MockP4) NewActionProfileMember(p4RtC *client.Client, actionProfile string, memberID uint32, action string, params [][]byte) *p4_v1.ActionProfileMember

func (MockP4) NewTableActionDirect

func (m MockP4) NewTableActionDirect(p4RtC *client.Client, action string, params [][]byte) *p4_v1.TableAction

func (MockP4) NewTableActionGroup

func (m MockP4) NewTableActionGroup(p4RtC *client.Client, groupID uint32) *p4_v1.TableAction

func (MockP4) NewTableEntry

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

type P4RtCWrapper

type P4RtCWrapper interface {
	NewTableEntry(p4RtC *client.Client, table string, mfs map[string]client.MatchInterface, action *p4_v1.TableAction, options *client.TableEntryOptions) *p4_v1.TableEntry
	NewTableActionDirect(p4RtC *client.Client, action string, params [][]byte) *p4_v1.TableAction
	InsertTableEntry(ctx context.Context, p4RtC *client.Client, entry *p4_v1.TableEntry) error
	DeleteTableEntry(ctx context.Context, p4RtC *client.Client, entry *p4_v1.TableEntry) error
	NewActionProfileMember(p4RtC *client.Client, actionProfile string, memberID uint32, action string, params [][]byte) *p4_v1.ActionProfileMember
	InsertActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error
	DeleteActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error
	NewActionProfileGroup(p4RtC *client.Client, actionProfile string, groupID uint32, members []*p4_v1.ActionProfileGroup_Member, size int32) *p4_v1.ActionProfileGroup
	InsertActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error
	DeleteActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error
	ModifyActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error
	ModifyActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error
	NewTableActionGroup(p4RtC *client.Client, groupID uint32) *p4_v1.TableAction
}
var P4w P4RtCWrapper

func GetP4Wrapper

func GetP4Wrapper(env string) P4RtCWrapper

type P4RtCWrapperStruct

type P4RtCWrapperStruct struct {
	P4RtCWrapper
}

func (P4RtCWrapperStruct) DeleteActionProfileGroup

func (P4RtC P4RtCWrapperStruct) DeleteActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error

func (P4RtCWrapperStruct) DeleteActionProfileMember

func (P4RtC P4RtCWrapperStruct) DeleteActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error

func (P4RtCWrapperStruct) DeleteTableEntry

func (P4RtC P4RtCWrapperStruct) DeleteTableEntry(ctx context.Context, p4RtC *client.Client, entry *p4_v1.TableEntry) error

func (P4RtCWrapperStruct) InsertActionProfileGroup

func (P4RtC P4RtCWrapperStruct) InsertActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error

func (P4RtCWrapperStruct) InsertActionProfileMember

func (P4RtC P4RtCWrapperStruct) InsertActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error

func (P4RtCWrapperStruct) InsertTableEntry

func (P4RtC P4RtCWrapperStruct) InsertTableEntry(ctx context.Context, p4RtC *client.Client, entry *p4_v1.TableEntry) error

func (P4RtCWrapperStruct) ModifyActionProfileGroup

func (P4RtC P4RtCWrapperStruct) ModifyActionProfileGroup(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileGroup) error

func (P4RtCWrapperStruct) ModifyActionProfileMember

func (P4RtC P4RtCWrapperStruct) ModifyActionProfileMember(ctx context.Context, p4RtC *client.Client, entry *p4_v1.ActionProfileMember) error

func (P4RtCWrapperStruct) NewActionProfileGroup

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

func (P4RtCWrapperStruct) NewActionProfileMember

func (P4RtC P4RtCWrapperStruct) NewActionProfileMember(p4RtC *client.Client, actionProfile string, memberID uint32, action string, params [][]byte) *p4_v1.ActionProfileMember

func (P4RtCWrapperStruct) NewTableActionDirect

func (P4RtC P4RtCWrapperStruct) NewTableActionDirect(p4RtC *client.Client, action string, params [][]byte) *p4_v1.TableAction

func (P4RtCWrapperStruct) NewTableActionGroup

func (P4RtC P4RtCWrapperStruct) NewTableActionGroup(p4RtC *client.Client, groupID uint32) *p4_v1.TableAction

func (P4RtCWrapperStruct) NewTableEntry

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

type Table

type Table struct {
	TableName        string        `json:"tableName"`
	ActionName       string        `json:"actionName"`
	EntryCount       int           `json:"entryCount"`
	KeyCount         int           `json:"keyCount"`
	ActionParamCount int           `json:"actionParamCount"`
	KeyMatchType     []string      `json:"keyMatchType"`
	KeyName          []string      `json:"keyName"`
	Key              []interface{} `json:"-"`
	Action           []interface{} `json:"-"`
}

Structure reads table details from json file

type UUIDGenerator

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

type UpdateTable

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

its a common structure to insert and delete entries from table

Jump to

Keyboard shortcuts

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