本文整理汇总了Golang中github.com/superkkt/cherry/cherryd/openflow.Factory.NewInstruction方法的典型用法代码示例。如果您正苦于以下问题:Golang Factory.NewInstruction方法的具体用法?Golang Factory.NewInstruction怎么用?Golang Factory.NewInstruction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/superkkt/cherry/cherryd/openflow.Factory
的用法示例。
在下文中一共展示了Factory.NewInstruction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: setARPSender
func setARPSender(f openflow.Factory, w trans.Writer) error {
match, err := f.NewMatch()
if err != nil {
return err
}
match.SetEtherType(0x0806) // ARP
outPort := openflow.NewOutPort()
outPort.SetController()
action, err := f.NewAction()
if err != nil {
return err
}
action.SetOutPort(outPort)
inst, err := f.NewInstruction()
if err != nil {
return err
}
inst.ApplyAction(action)
flow, err := f.NewFlowMod(openflow.FlowAdd)
if err != nil {
return err
}
// Permanent flow
flow.SetIdleTimeout(0)
flow.SetHardTimeout(0)
flow.SetPriority(100)
flow.SetFlowMatch(match)
flow.SetFlowInstruction(inst)
if err := w.Write(flow); err != nil {
return err
}
return sendBarrierRequest(f, w)
}
示例2: setDefaultTableMiss
func (r *of13Session) setDefaultTableMiss(f openflow.Factory, w trans.Writer) error {
inst, err := f.NewInstruction()
if err != nil {
return err
}
// 0 -> Controller
outPort := openflow.NewOutPort()
outPort.SetController()
action, err := f.NewAction()
if err != nil {
return err
}
action.SetOutPort(outPort)
inst.ApplyAction(action)
if err := r.setTableMiss(f, w, 0, inst); err != nil {
return fmt.Errorf("failed to set table_miss flow entry: %v", err)
}
r.device.setFlowTableID(0)
return nil
}
示例3: setHP2920TableMiss
func (r *of13Session) setHP2920TableMiss(f openflow.Factory, w trans.Writer) error {
// Table-100 is a hardware table, and Table-200 is a software table
// that has very low performance.
inst, err := f.NewInstruction()
if err != nil {
return err
}
// 0 -> 100
inst.GotoTable(100)
if err := r.setTableMiss(f, w, 0, inst); err != nil {
return fmt.Errorf("failed to set table_miss flow entry: %v", err)
}
// 100 -> 200
inst.GotoTable(200)
if err := r.setTableMiss(f, w, 100, inst); err != nil {
return fmt.Errorf("failed to set table_miss flow entry: %v", err)
}
// 200 -> Controller
outPort := openflow.NewOutPort()
outPort.SetController()
action, err := f.NewAction()
if err != nil {
return err
}
action.SetOutPort(outPort)
inst.ApplyAction(action)
if err := r.setTableMiss(f, w, 200, inst); err != nil {
return fmt.Errorf("failed to set table_miss flow entry: %v", err)
}
r.device.setFlowTableID(200)
return nil
}