Documentation ¶
Index ¶
- type Control
- type ControlTable
- type CounterControl
- type CounterData
- type DigestControl
- type DirectCounterData
- type SimpleControl
- func (sc *SimpleControl) Counter(counterName string) CounterControl
- func (sc *SimpleControl) Digest(digestName string) DigestControl
- func (sc *SimpleControl) InstallProgram(binPath, p4InfoPath string) error
- func (sc *SimpleControl) IsMaster() bool
- func (sc *SimpleControl) PerformArbitration()
- func (sc *SimpleControl) Run()
- func (sc *SimpleControl) SetMastershipStatus(status bool)
- func (sc *SimpleControl) StartArbitrationUpdateListener()
- func (sc *SimpleControl) StartMessageRouter()
- func (sc *SimpleControl) Table(tableName string) TableControl
- type TableControl
- func (tc TableControl) InsertEntry(action string, data map[string]interface{}) error
- func (tc TableControl) InsertEntryRaw(action string, mf []entities.Match, params [][]byte) error
- func (tc TableControl) ReadDirectCounterValueOnEntry(matches []entities.Match) (*DirectCounterData, error)
- func (tc TableControl) ReadDirectCounterValuesSync() ([]*DirectCounterData, error)
- func (tc TableControl) RegisterTransformer(transformer entities.TableEntryTransformer)
- func (tc TableControl) StreamDirectCounterValues() (chan *DirectCounterData, error)
- type TableEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Control ¶
type Control interface { ControlTable PerformArbitration() IsMaster() bool SetMastershipStatus(bool) Run() InstallProgram(string, string) error }
Control represents a controller's control over a switch.
type ControlTable ¶
type ControlTable interface { Table(string) TableControl Digest(string) DigestControl Counter(string) CounterControl }
type CounterControl ¶
type CounterControl struct {
// contains filtered or unexported fields
}
CounterControl will contain all the information required to do stuff with a P4 counter
func (*CounterControl) ReadValueAtIndex ¶
func (cc *CounterControl) ReadValueAtIndex(index int64) (*CounterData, error)
ReadValueAtIndex will return the value of the target counter at the target index. Duh.
func (*CounterControl) ReadValues ¶
func (cc *CounterControl) ReadValues() ([]*CounterData, error)
ReadValues will return a list of counter values at all indices
func (*CounterControl) StreamValues ¶
func (cc *CounterControl) StreamValues() (chan *CounterData, error)
StreamValues is like ReadValues, except it will return a channel on which all the counter values will be sent. Use this when you want to get all values asynchronously
type CounterData ¶
CounterData represents a counter's value at a given index
type DigestControl ¶
type DigestControl struct {
// contains filtered or unexported fields
}
DigestControl contains all the information needed to handle DigestEntries in the controller
func (DigestControl) Acknowledge ¶
func (dc DigestControl) Acknowledge(digestList *p4V1.DigestList)
Acknowledge will acknowledge that the control plane did receive a DigestList of a given ID
func (DigestControl) Delete ¶
func (dc DigestControl) Delete() error
Delete will delete the selected DigestEntry from the switch i.e. no digest messages corresponding to that DigestEntry will be received.
type DirectCounterData ¶
type DirectCounterData struct { TableEntry *TableEntry ByteCount int64 PacketCount int64 }
type SimpleControl ¶
type SimpleControl struct { Client core.P4RClient DigestChannel chan *p4V1.StreamMessageResponse_Digest ArbitrationChannel chan *p4V1.StreamMessageResponse_Arbitration // contains filtered or unexported fields }
SimpleControl implements the Control interface. I could not think of a better name
func (*SimpleControl) Counter ¶
func (sc *SimpleControl) Counter(counterName string) CounterControl
Counter will return a CounterControl struct
func (*SimpleControl) Digest ¶
func (sc *SimpleControl) Digest(digestName string) DigestControl
Digest will return a DigestControl struct
func (*SimpleControl) InstallProgram ¶
func (sc *SimpleControl) InstallProgram(binPath, p4InfoPath string) error
InstallProgram will install a p4 compiled binary on a given target
func (*SimpleControl) IsMaster ¶
func (sc *SimpleControl) IsMaster() bool
IsMaster will return true if the control has mastership
func (*SimpleControl) PerformArbitration ¶
func (sc *SimpleControl) PerformArbitration()
PerformArbitration will send an Arbitration Request down the Stream Channel to participate in arbitration
func (*SimpleControl) Run ¶
func (sc *SimpleControl) Run()
Run will do all the work required to actually get the control instance up and running
func (*SimpleControl) SetMastershipStatus ¶
func (sc *SimpleControl) SetMastershipStatus(status bool)
SetMastershipStatus will call a method of the same name on P4RClient. We need to keep track of mastership to reason about which control can be used for what.
func (*SimpleControl) StartArbitrationUpdateListener ¶
func (sc *SimpleControl) StartArbitrationUpdateListener()
StartArbitrationUpdateListener will start a goroutine to listen on the ArbitrationChannel to check for any updates in arbitration
func (*SimpleControl) StartMessageRouter ¶
func (sc *SimpleControl) StartMessageRouter()
StartMessageRouter will start a goroutine that takes incoming messages from the stream and then sends them to corresponding channels based on message types
func (*SimpleControl) Table ¶
func (sc *SimpleControl) Table(tableName string) TableControl
Table will return a TableControl struct
type TableControl ¶
type TableControl struct {
// contains filtered or unexported fields
}
TableControl will contain all the information required to do stuff with a P4 table
func (TableControl) InsertEntry ¶
func (tc TableControl) InsertEntry(action string, data map[string]interface{}) error
InsertEntry is a less ugly version of InsertEntryRaw, since it supports pretty input (which can be serialized from incoming json, yay!). This method will call the table's Transformer function to convert the data into raw match fields and params, and will then call InsertEntryRaw with these values.
func (TableControl) InsertEntryRaw ¶
InsertEntryRaw is used to insert an entry into a table using raw values of match fields and params
func (TableControl) ReadDirectCounterValueOnEntry ¶
func (tc TableControl) ReadDirectCounterValueOnEntry(matches []entities.Match) (*DirectCounterData, error)
ReadDirectCounterValueOnEntry will read the value of the DirectCounter against an entry in the table
func (TableControl) ReadDirectCounterValuesSync ¶
func (tc TableControl) ReadDirectCounterValuesSync() ([]*DirectCounterData, error)
ReadDirectCounterValuesSync will return a list of DirectCounter values against all the entries of the table.
func (TableControl) RegisterTransformer ¶
func (tc TableControl) RegisterTransformer(transformer entities.TableEntryTransformer)
RegisterTransformer will register a transformer function for the table managed by this TableControl instance
func (TableControl) StreamDirectCounterValues ¶
func (tc TableControl) StreamDirectCounterValues() (chan *DirectCounterData, error)
StreamDirectCounterValues does what ReadDirectCounterValuesSync does, except that instead of returning a list of values, it returns a channel on which these values can be asynchronously sent.
type TableEntry ¶
type TableEntry p4V1.TableEntry