当前位置: 首页>>代码示例>>Golang>>正文


Golang openflow.Factory类代码示例

本文整理汇总了Golang中github.com/superkkt/cherry/cherryd/openflow.Factory的典型用法代码示例。如果您正苦于以下问题:Golang Factory类的具体用法?Golang Factory怎么用?Golang Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Factory类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: sendLLDP

func sendLLDP(deviceID string, f openflow.Factory, w trans.Writer, p openflow.Port) error {
	lldp, err := newLLDPEtherFrame(deviceID, p)
	if err != nil {
		return err
	}

	outPort := openflow.NewOutPort()
	outPort.SetValue(p.Number())

	// Packet out to the port
	action, err := f.NewAction()
	if err != nil {
		return err
	}
	action.SetOutPort(outPort)

	out, err := f.NewPacketOut()
	if err != nil {
		return err
	}
	// From controller
	out.SetInPort(openflow.NewInPort())
	out.SetAction(action)
	out.SetData(lldp)

	return w.Write(out)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:27,代码来源:session.go

示例2: sendPortDescriptionRequest

func sendPortDescriptionRequest(f openflow.Factory, w trans.Writer) error {
	msg, err := f.NewPortDescRequest()
	if err != nil {
		return err
	}

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:8,代码来源:session.go

示例3: sendBarrierRequest

func sendBarrierRequest(f openflow.Factory, w trans.Writer) error {
	msg, err := f.NewBarrierRequest()
	if err != nil {
		return err
	}

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:8,代码来源:session.go

示例4: sendHello

func sendHello(f openflow.Factory, w trans.Writer) error {
	msg, err := f.NewHello()
	if err != nil {
		return err
	}

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:8,代码来源:session.go

示例5: sendSetConfig

func sendSetConfig(f openflow.Factory, w trans.Writer) error {
	msg, err := f.NewSetConfig()
	if err != nil {
		return err
	}
	msg.SetFlags(openflow.FragNormal)
	msg.SetMissSendLength(0xFFFF)

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:10,代码来源:session.go

示例6: sendQueueConfigRequest

func sendQueueConfigRequest(f openflow.Factory, w trans.Writer, port uint32) error {
	msg, err := f.NewQueueGetConfigRequest()
	if err != nil {
		return err
	}
	p := openflow.NewOutPort()
	p.SetValue(port)
	msg.SetPort(p)

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:11,代码来源:session.go

示例7: sendRemovingAllFlows

func sendRemovingAllFlows(f openflow.Factory, w trans.Writer) error {
	match, err := f.NewMatch() // Wildcard
	if err != nil {
		return err
	}

	msg, err := f.NewFlowMod(openflow.FlowDelete)
	if err != nil {
		return err
	}
	// Wildcard
	msg.SetTableID(0xFF)
	msg.SetFlowMatch(match)

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:16,代码来源:session.go

示例8: 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
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:23,代码来源:of13_session.go

示例9: setTableMiss

func (r *of13Session) setTableMiss(f openflow.Factory, w trans.Writer, tableID uint8, inst openflow.Instruction) error {
	match, err := f.NewMatch() // Wildcard
	if err != nil {
		return err
	}

	msg, err := f.NewFlowMod(openflow.FlowAdd)
	if err != nil {
		return err
	}
	// We use MSB to represent whether the flow is table miss or not
	msg.SetCookie(0x1 << 63)
	msg.SetTableID(tableID)
	// Permanent flow entry
	msg.SetIdleTimeout(0)
	msg.SetHardTimeout(0)
	// Table-miss entry should have zero priority
	msg.SetPriority(0)
	msg.SetFlowMatch(match)
	msg.SetFlowInstruction(inst)

	return w.Write(msg)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:23,代码来源:of13_session.go

示例10: 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
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:36,代码来源:of13_session.go

示例11: 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)
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:38,代码来源:session.go


注:本文中的github.com/superkkt/cherry/cherryd/openflow.Factory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。