• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang util.Message类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: UnmarshalBinary

func (s *MultipartRequest) UnmarshalBinary(data []byte) error {
	err := s.Header.UnmarshalBinary(data)
	n := s.Header.Len()

	s.Type = binary.BigEndian.Uint16(data[n:])
	n += 2
	s.Flags = binary.BigEndian.Uint16(data[n:])
	n += 2
	n += 4 // for padding

	var req util.Message
	switch s.Type {
	case MultipartType_Aggregate:
		req = s.Body.(*AggregateStatsRequest)
		err = req.UnmarshalBinary(data[n:])
	case MultipartType_Desc:
		break
	case MultipartType_Flow:
		req = s.Body.(*FlowStatsRequest)
		err = req.UnmarshalBinary(data[n:])
	case MultipartType_Port:
		req = s.Body.(*PortStatsRequest)
		err = req.UnmarshalBinary(data[n:])
	case MultipartType_Table:
		break
	case MultipartType_Queue:
		req = s.Body.(*QueueStatsRequest)
		err = req.UnmarshalBinary(data[n:])
	case MultipartType_Experimenter:
		break
	}
	return err
}
开发者ID:jojimt,项目名称:netplugin,代码行数:33,代码来源:multipart.go


示例2: DecodeMatchField

func DecodeMatchField(class uint16, field uint8, data []byte) util.Message {
	if class == OXM_CLASS_OPENFLOW_BASIC {
		var val util.Message
		switch field {
		case OXM_FIELD_IN_PORT:
			val = new(InPortField)
		case OXM_FIELD_IN_PHY_PORT:
		case OXM_FIELD_METADATA:
		case OXM_FIELD_ETH_DST:
			val = new(EthDstField)
		case OXM_FIELD_ETH_SRC:
			val = new(EthSrcField)
		case OXM_FIELD_ETH_TYPE:
			val = new(EthTypeField)
		case OXM_FIELD_VLAN_VID:
			val = new(VlanIdField)
		case OXM_FIELD_VLAN_PCP:
		case OXM_FIELD_IP_DSCP:
		case OXM_FIELD_IP_ECN:
		case OXM_FIELD_IP_PROTO:
			val = new(IpProtoField)
		case OXM_FIELD_IPV4_SRC:
			val = new(Ipv4SrcField)
		case OXM_FIELD_IPV4_DST:
			val = new(Ipv4DstField)
		case OXM_FIELD_TCP_SRC:
			val = new(PortField)
		case OXM_FIELD_TCP_DST:
			val = new(PortField)
		case OXM_FIELD_UDP_SRC:
			val = new(PortField)
		case OXM_FIELD_UDP_DST:
			val = new(PortField)
		case OXM_FIELD_SCTP_SRC:
		case OXM_FIELD_SCTP_DST:
		case OXM_FIELD_ICMPV4_TYPE:
		case OXM_FIELD_ICMPV4_CODE:
		case OXM_FIELD_ARP_OP:
		case OXM_FIELD_ARP_SPA:
		case OXM_FIELD_ARP_TPA:
		case OXM_FIELD_ARP_SHA:
		case OXM_FIELD_ARP_THA:
		case OXM_FIELD_IPV6_SRC:
		case OXM_FIELD_IPV6_DST:
		case OXM_FIELD_IPV6_FLABEL:
		case OXM_FIELD_ICMPV6_TYPE:
		case OXM_FIELD_ICMPV6_CODE:
		case OXM_FIELD_IPV6_ND_TARGET:
		case OXM_FIELD_IPV6_ND_SLL:
		case OXM_FIELD_IPV6_ND_TLL:
		case OXM_FIELD_MPLS_LABEL:
		case OXM_FIELD_MPLS_TC:
		case OXM_FIELD_MPLS_BOS:
		case OXM_FIELD_PBB_ISID:
		case OXM_FIELD_TUNNEL_ID:
			val = new(TunnelIdField)
		case OXM_FIELD_IPV6_EXTHDR:
		case OXM_FIELD_TCP_FLAGS:
			val = new(TcpFlagsField)
		}

		val.UnmarshalBinary(data)
		return val
	} else {
		log.Panic("Unsupported match field class")
	}

	return nil
}
开发者ID:rtrentin73,项目名称:netplugin,代码行数:69,代码来源:match.go


示例3: DecodeMatchField

func DecodeMatchField(class uint16, field uint8, data []byte) util.Message {
	if class == OXM_CLASS_OPENFLOW_BASIC {
		var val util.Message
		val = nil
		switch field {
		case OXM_FIELD_IN_PORT:
			val = new(InPortField)
		case OXM_FIELD_IN_PHY_PORT:
		case OXM_FIELD_METADATA:
			val = new(MetadataField)
		case OXM_FIELD_ETH_DST:
			val = new(EthDstField)
		case OXM_FIELD_ETH_SRC:
			val = new(EthSrcField)
		case OXM_FIELD_ETH_TYPE:
			val = new(EthTypeField)
		case OXM_FIELD_VLAN_VID:
			val = new(VlanIdField)
		case OXM_FIELD_VLAN_PCP:
		case OXM_FIELD_IP_DSCP:
			val = new(IpDscpField)
		case OXM_FIELD_IP_ECN:
		case OXM_FIELD_IP_PROTO:
			val = new(IpProtoField)
		case OXM_FIELD_IPV4_SRC:
			val = new(Ipv4SrcField)
		case OXM_FIELD_IPV4_DST:
			val = new(Ipv4DstField)
		case OXM_FIELD_TCP_SRC:
			val = new(PortField)
		case OXM_FIELD_TCP_DST:
			val = new(PortField)
		case OXM_FIELD_UDP_SRC:
			val = new(PortField)
		case OXM_FIELD_UDP_DST:
			val = new(PortField)
		case OXM_FIELD_SCTP_SRC:
		case OXM_FIELD_SCTP_DST:
		case OXM_FIELD_ICMPV4_TYPE:
		case OXM_FIELD_ICMPV4_CODE:
		case OXM_FIELD_ARP_OP:
			val = new(ArpOperField)
		case OXM_FIELD_ARP_SPA:
		case OXM_FIELD_ARP_TPA:
		case OXM_FIELD_ARP_SHA:
		case OXM_FIELD_ARP_THA:
		case OXM_FIELD_IPV6_SRC:
			val = new(Ipv6SrcField)
		case OXM_FIELD_IPV6_DST:
			val = new(Ipv6DstField)
		case OXM_FIELD_IPV6_FLABEL:
		case OXM_FIELD_ICMPV6_TYPE:
		case OXM_FIELD_ICMPV6_CODE:
		case OXM_FIELD_IPV6_ND_TARGET:
		case OXM_FIELD_IPV6_ND_SLL:
		case OXM_FIELD_IPV6_ND_TLL:
		case OXM_FIELD_MPLS_LABEL:
			val = new(MplsLabelField)
		case OXM_FIELD_MPLS_TC:
		case OXM_FIELD_MPLS_BOS:
			val = new(MplsBosField)
		case OXM_FIELD_PBB_ISID:
		case OXM_FIELD_TUNNEL_ID:
			val = new(TunnelIdField)
		case OXM_FIELD_IPV6_EXTHDR:
		case OXM_FIELD_TCP_FLAGS:
			val = new(TcpFlagsField)
		default:
			log.Printf("Unhandled Field: %d in Class: %d", field, class)
		}

		if val == nil {
			log.Printf("Bad pkt class: %v field: %v data: %v", class, field, data)
			return nil
		}

		val.UnmarshalBinary(data)
		return val
	} else if class == OXM_CLASS_NXM_1 {
		var val util.Message
		switch field {
		case NXM_NX_TUN_IPV4_SRC:
			val = new(TunnelIpv4SrcField)
		case NXM_NX_TUN_IPV4_DST:
			val = new(TunnelIpv4DstField)
		default:
			log.Printf("Unhandled Field: %d in Class: %d", field, class)
			return nil
		}

		val.UnmarshalBinary(data)
		return val
	} else {
		log.Panic("Unsupported match field: %d in class: %d", field, class)
	}

	return nil
}
开发者ID:jojimt,项目名称:netplugin,代码行数:98,代码来源:match.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sslerr.SSLErrorMessage函数代码示例发布时间:2022-05-28
下一篇:
Golang protocol.NewEthernet函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap