當前位置: 首頁>>代碼示例>>Golang>>正文


Golang of.Header類代碼示例

本文整理匯總了Golang中github.com/kandoo/beehive-netctrl/openflow/of.Header的典型用法代碼示例。如果您正苦於以下問題:Golang Header類的具體用法?Golang Header怎麽用?Golang Header使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Header類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: doHandleEchoRequest

func doHandleEchoRequest(req of.Header, res of.Header, c *ofConn) error {
	glog.V(2).Infof("Received echo request from %v", c.node)
	res.SetXid(req.Xid())
	err := c.WriteHeaders([]of.Header{res})
	if err != nil {
		return err
	}
	c.Flush()
	glog.V(2).Infof("Sent echo reply to %v", c.node)
	return nil
}
開發者ID:dknyxh,項目名稱:beehive-netctrl,代碼行數:11,代碼來源:echo.go

示例2: handlePkt

func (d *of10Driver) handlePkt(pkt of.Header, c *ofConn) error {
	pkt10, err := of10.ToHeader10(pkt)
	if err != nil {
		return err
	}

	switch {
	case of10.IsEchoRequest(pkt10):
		return d.handleEchoRequest(of10.NewEchoRequestWithBuf(pkt10.Buf), c)
	case of10.IsFeaturesReply(pkt10):
		return d.handleFeaturesReply(of10.NewFeaturesReplyWithBuf(pkt10.Buf), c)
	case of10.IsPacketIn(pkt10):
		return d.handlePacketIn(of10.NewPacketInWithBuf(pkt10.Buf), c)
	case of10.IsErrorMsg(pkt10):
		return d.handleErrorMsg(of10.NewErrorMsgWithBuf(pkt10.Buf), c)
	case of10.IsStatsReply(pkt10):
		return d.handleStatsReply(of10.NewStatsReplyWithBuf(pkt10.Buf), c)
	default:
		return fmt.Errorf("Received unsupported packet: %v", pkt.Type())
	}
}
開發者ID:dknyxh,項目名稱:beehive-netctrl,代碼行數:21,代碼來源:driver.go

示例3: handlePkt

func (d *of12Driver) handlePkt(pkt of.Header, c *ofConn) error {
	pkt12, err := of12.ToHeader12(pkt)
	if err != nil {
		return err
	}

	switch {
	case of12.IsEchoRequest(pkt12):
		return d.handleEchoRequest(of12.NewEchoRequestWithBuf(pkt12.Buf), c)
	case of12.IsFeaturesReply(pkt12):
		return d.handleFeaturesReply(of12.NewFeaturesReplyWithBuf(pkt12.Buf), c)
	case of12.IsPacketIn(pkt12):
		return d.handlePacketIn(of12.NewPacketInWithBuf(pkt12.Buf), c)
	case of12.IsErrorMsg(pkt12):
		return d.handleErrorMsg(of12.NewErrorMsgWithBuf(pkt12.Buf), c)
	case of12.IsStatsReply(pkt12):
		return d.handleStatsReply(of12.NewStatsReplyWithBuf(pkt12.Buf), c)
	case of12.IsRoleReply(pkt12):
		return d.handleRoleReply(of12.NewRoleReplyWithBuf(pkt12.Buf), c)
	default:
		glog.Errorf("received unsupported packet: %v", pkt.Type())
		return nil
	}
}
開發者ID:kandoo,項目名稱:beehive-netctrl,代碼行數:24,代碼來源:driver.go


注:本文中的github.com/kandoo/beehive-netctrl/openflow/of.Header類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。