本文整理汇总了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
}
示例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
}
示例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
}