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


Golang util.Message類代碼示例

本文整理匯總了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;未經允許,請勿轉載。