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


Golang Message.UnmarshalBinary方法代码示例

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


在下文中一共展示了Message.UnmarshalBinary方法的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.UnmarshalBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。